Merge remote-tracking branch 'origin/master'

This commit is contained in:
SjS 2025-04-27 16:01:30 +08:00
commit c7b9a3da9f
15 changed files with 136 additions and 188 deletions

View File

@ -1,16 +1,16 @@
package com.ruoyi.bst.agreement.domain;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
import com.ruoyi.common.core.interfaces.LogBizParam;
import com.ruoyi.common.core.validate.ValidGroup;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
/**
* 协议对象 bst_agreement
*
@ -24,10 +24,6 @@ public class Agreement extends BaseEntity implements LogBizParam
private Long id;
@Excel(name = "商户ID")
@ApiModelProperty("商户ID")
private Long storeId;
@Excel(name = "运营区ID")
@ApiModelProperty("运营区ID")
private Long areaId;

View File

@ -6,6 +6,8 @@ import lombok.Data;
@Data
public class AgreementVO extends Agreement{
@ApiModelProperty("运营商ID")
private Long storeId;
@ApiModelProperty("商户名")
private String userName;
@ -16,7 +18,4 @@ public class AgreementVO extends Agreement{
@ApiModelProperty("代理商ID")
private Long agentId;
@ApiModelProperty("运营商ID")
private Long storeId;
}

View File

@ -0,0 +1,16 @@
package com.ruoyi.bst.agreement.domain.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
@Getter
@AllArgsConstructor
public enum AgreementType {
NOTICE("0", "公告"),
RENT("1", "租赁协议");
private final String code;
private final String name;
}

View File

@ -38,16 +38,6 @@ public interface AgreementMapper
*/
int insertAgreement(Agreement agreement);
/**
* 批量新增协议
*/
int batchInsert(@Param("list") List<? extends Agreement> list);
/**
* 批量修改协议
*/
int batchUpdate(@Param("list") List<? extends Agreement> list);
/**
* 修改协议
*

View File

@ -32,6 +32,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</sql>
<sql id="searchCondition">
<if test="query.storeId != null "> and ba.user_id = #{query.storeId}</if>
<if test="query.areaId != null "> and bag.area_id = #{query.areaId}</if>
<if test="query.title != null and query.title != ''"> and bag.title like concat('%', #{query.title}, '%')</if>
<if test="query.brief != null and query.brief != ''"> and bag.brief like concat('%', #{query.brief}, '%')</if>
@ -103,131 +104,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</trim>
</insert>
<insert id="batchInsert" parameterType="Agreement" useGeneratedKeys="true" keyProperty="id">
insert into bst_agreement
<trim prefix="(" suffix=")" suffixOverrides=",">
area_id,
title,
brief,
content,
agreement_type,
duration,
create_time,
update_time,
</trim>
values
<foreach collection="list" item="i" separator=",">
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="i.areaId != null ">#{i.areaId},</if>
<if test="i.areaId == null ">default,</if>
<if test="i.title != null and i.title != ''">#{i.title},</if>
<if test="i.title == null or i.title == ''">default,</if>
<if test="i.brief != null ">#{i.brief},</if>
<if test="i.brief == null ">default,</if>
<if test="i.content != null ">#{i.content},</if>
<if test="i.content == null ">default,</if>
<if test="i.agreementType != null ">#{i.agreementType},</if>
<if test="i.agreementType == null ">default,</if>
<if test="i.duration != null ">#{i.duration},</if>
<if test="i.duration == null ">default,</if>
<if test="i.createTime != null ">#{i.createTime},</if>
<if test="i.createTime == null ">default,</if>
<if test="i.updateTime != null ">#{i.updateTime},</if>
<if test="i.updateTime == null ">default,</if>
</trim>
</foreach>
</insert>
<update id="batchUpdate">
update bst_agreement
<trim prefix="SET" suffixOverrides=",">
<foreach open="area_id = CASE id" collection="list" item="item" close="END,">
<choose>
<when test="item.areaId != null ">
WHEN #{item.id} THEN #{item.areaId}
</when>
<otherwise>
WHEN #{item.id} THEN `area_id`
</otherwise>
</choose>
</foreach>
<foreach open="title = CASE id" collection="list" item="item" close="END,">
<choose>
<when test="item.title != null and item.title != ''">
WHEN #{item.id} THEN #{item.title}
</when>
<otherwise>
WHEN #{item.id} THEN `title`
</otherwise>
</choose>
</foreach>
<foreach open="brief = CASE id" collection="list" item="item" close="END,">
<choose>
<when test="item.brief != null ">
WHEN #{item.id} THEN #{item.brief}
</when>
<otherwise>
WHEN #{item.id} THEN `brief`
</otherwise>
</choose>
</foreach>
<foreach open="content = CASE id" collection="list" item="item" close="END,">
<choose>
<when test="item.content != null ">
WHEN #{item.id} THEN #{item.content}
</when>
<otherwise>
WHEN #{item.id} THEN `content`
</otherwise>
</choose>
</foreach>
<foreach open="agreement_type = CASE id" collection="list" item="item" close="END,">
<choose>
<when test="item.agreementType != null ">
WHEN #{item.id} THEN #{item.agreementType}
</when>
<otherwise>
WHEN #{item.id} THEN `agreement_type`
</otherwise>
</choose>
</foreach>
<foreach open="duration = CASE id" collection="list" item="item" close="END,">
<choose>
<when test="item.duration != null ">
WHEN #{item.id} THEN #{item.duration}
</when>
<otherwise>
WHEN #{item.id} THEN `duration`
</otherwise>
</choose>
</foreach>
<foreach open="create_time = CASE id" collection="list" item="item" close="END,">
<choose>
<when test="item.createTime != null ">
WHEN #{item.id} THEN #{item.createTime}
</when>
<otherwise>
WHEN #{item.id} THEN `create_time`
</otherwise>
</choose>
</foreach>
<foreach open="update_time = CASE id" collection="list" item="item" close="END,">
<choose>
<when test="item.updateTime != null ">
WHEN #{item.id} THEN #{item.updateTime}
</when>
<otherwise>
WHEN #{item.id} THEN `update_time`
</otherwise>
</choose>
</foreach>
</trim>
where id in
<foreach item="item" collection="list" open="(" separator="," close=")">
#{item.id}
</foreach>
</update>
<update id="updateAgreement" parameterType="Agreement">
update bst_agreement bag
<trim prefix="SET" suffixOverrides=",">

View File

@ -1,9 +1,11 @@
package com.ruoyi.bst.agreement.service;
import java.util.List;
import com.ruoyi.bst.agreement.domain.Agreement;
import com.ruoyi.bst.agreement.domain.AgreementVO;
import com.ruoyi.bst.agreement.domain.AgreementQuery;
import com.ruoyi.bst.agreement.domain.AgreementVO;
import com.ruoyi.bst.agreement.domain.enums.AgreementType;
/**
* 协议Service接口
@ -61,4 +63,12 @@ public interface AgreementService
*/
public int deleteAgreementById(Long id);
/**
* 复制模板
* @param type
* @param areaId
* @return
*/
public int copyTemplate(AgreementType type, Long areaId);
}

View File

@ -28,7 +28,9 @@ public class AgreementConverterImpl implements AgreementConverter {
po.setTitle(data.getTitle());
if (SecurityUtils.isAdmin()){
po.setContentType(data.getContentType());
}else po.setContentType(AgreementContentType.TEXT.getCode());
}else po.setContentType(
AgreementContentType.TEXT.getCode()
);
po.setAgreementType(data.getAgreementType());
po.setBrief(data.getBrief());
po.setContent(data.getContent());

View File

@ -2,25 +2,23 @@ package com.ruoyi.bst.agreement.service.impl;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.support.TransactionTemplate;
import org.springframework.util.CollectionUtils;
import com.github.pagehelper.PageHelper;
import com.ruoyi.bst.agreement.domain.Agreement;
import com.ruoyi.bst.agreement.domain.AgreementQuery;
import com.ruoyi.bst.agreement.domain.AgreementVO;
import com.ruoyi.bst.agreement.domain.enums.AgreementContentType;
import com.ruoyi.bst.area.domain.AreaQuery;
import com.ruoyi.bst.area.domain.AreaVO;
import com.ruoyi.bst.agreement.domain.enums.AgreementType;
import com.ruoyi.bst.agreement.mapper.AgreementMapper;
import com.ruoyi.bst.agreement.service.AgreementService;
import com.ruoyi.bst.area.service.AreaService;
import com.ruoyi.bst.device.domain.DeviceVO;
import com.ruoyi.bst.model.domain.ModelVO;
import com.ruoyi.common.core.domain.vo.UserVO;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.ServiceUtil;
import com.ruoyi.system.user.service.UserService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.bst.agreement.mapper.AgreementMapper;
import com.ruoyi.bst.agreement.domain.Agreement;
import com.ruoyi.bst.agreement.domain.AgreementVO;
import com.ruoyi.bst.agreement.domain.AgreementQuery;
import com.ruoyi.bst.agreement.service.AgreementService;
import org.springframework.transaction.support.TransactionTemplate;
/**
* 协议Service业务层处理
@ -76,17 +74,17 @@ public class AgreementServiceImpl implements AgreementService
contentTypeAreaCheck(agreement);
agreement.setCreateTime(DateUtils.getNowDate());
Integer result = transactionTemplate.execute(status -> {
// 创建设备
int insert = agreementMapper.insertAgreement(agreement);
ServiceUtil.assertion(insert != 1,"新增设备失败");
// 创建设备
int insert = agreementMapper.insertAgreement(agreement);
ServiceUtil.assertion(insert != 1,"新增协议失败");
// 后校验
AgreementVO vo = this.selectAgreementById(agreement.getId());
distinct(vo);
// 后校验
AgreementVO vo = this.selectAgreementById(agreement.getId());
distinct(vo);
return insert;
return insert;
});
});
return result==null? 0 : result;
}
@ -158,4 +156,33 @@ public class AgreementServiceImpl implements AgreementService
}
@Override
public int copyTemplate(AgreementType type, Long areaId) {
if (type == null || areaId == null) {
return 0;
}
// 查询模板
AgreementQuery query = new AgreementQuery();
query.setAgreementType(type.getCode());
query.setContentType(AgreementContentType.TEMPLATE.getCode());
AgreementVO template = this.selectOne(query);
ServiceUtil.assertion(template == null, "协议模板不存在");
Agreement data = new Agreement();
data.setAreaId(areaId);
data.setTitle(template.getTitle());
data.setBrief(template.getBrief());
data.setContent(template.getContent());
data.setAgreementType(template.getAgreementType());
data.setContentType(AgreementContentType.TEXT.getCode());
data.setDuration(template.getDuration());
return this.insertAgreement(data);
}
private AgreementVO selectOne(AgreementQuery query) {
PageHelper.startPage(1, 1);
List<AgreementVO> list = agreementMapper.selectAgreementList(query);
return CollectionUtils.firstElement(list);
}
}

View File

@ -6,8 +6,11 @@ import java.util.List;
import org.locationtech.jts.geom.Geometry;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.support.TransactionTemplate;
import com.github.pagehelper.PageHelper;
import com.ruoyi.bst.agreement.domain.enums.AgreementType;
import com.ruoyi.bst.agreement.service.AgreementService;
import com.ruoyi.bst.area.domain.Area;
import com.ruoyi.bst.area.domain.AreaQuery;
import com.ruoyi.bst.area.domain.AreaVO;
@ -19,6 +22,7 @@ import com.ruoyi.bst.areaJoin.domain.enums.AreaJoinPermission;
import com.ruoyi.bst.areaSub.domain.AreaSubVO;
import com.ruoyi.bst.areaSub.service.AreaSubService;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.ServiceUtil;
import com.ruoyi.common.utils.collection.CollectionUtils;
import com.ruoyi.common.utils.map.GeoUtils;
@ -40,6 +44,12 @@ public class AreaServiceImpl implements AreaService
@Autowired
private AreaSubService areaSubService;
@Autowired
private AgreementService agreementService;
@Autowired
private TransactionTemplate transactionTemplate;
/**
* 查询运营区
*
@ -103,7 +113,20 @@ public class AreaServiceImpl implements AreaService
area.setBoundary(GeoUtils.wkt(geometry));
}
area.setCreateTime(DateUtils.getNowDate());
return areaMapper.insertArea(area);
Integer result = transactionTemplate.execute(status -> {
int rows = areaMapper.insertArea(area);
if (rows > 0) {
// 复制一份租赁协议到运营区内
int copy = agreementService.copyTemplate(AgreementType.RENT, area.getId());
ServiceUtil.assertion(copy != 1, "复制协议模板失败");
}
return rows;
});
return result == null ? 0 : result;
}
/**

View File

@ -2,7 +2,6 @@ package com.ruoyi.bst.customerService.service.impl;
import java.util.List;
import com.ruoyi.common.utils.ServiceUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -47,6 +46,7 @@ public class CustomerServiceServiceImpl implements CustomerServiceService
CustomerServiceQuery query = new CustomerServiceQuery();
query.setId(id);
query.setScope(scope);
query.addAreaPermission(AreaJoinPermission.CUSTOMER_SERVICE_VIEW.getCode());
return this.selectOne(query);
}

View File

@ -1,6 +1,5 @@
package com.ruoyi.iot.service.impl;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;
@ -70,10 +69,6 @@ public class IotConverterImpl implements IotConverter {
if (sys == null) {
return;
}
// 旧版硬件BUG电压超过100V的需要除以10
if (sys.getBat() != null && sys.getBat().compareTo(BigDecimal.valueOf(100)) >= 0) {
sys.setBat(sys.getBat().divide(BigDecimal.valueOf(10), 2, BigDecimal.ROUND_HALF_UP));
}
device.setSys(sys);
}

View File

@ -85,9 +85,16 @@ public class IotReceiveServiceImpl implements IotReceiveService {
}
// 转为设备信息
log.info("收到sys数据" + msg.getValue());
IotDeviceSysInfo sys = IotUtil.toSysInfo(msg.getValue());
LocalDateTime at = DateUtils.toLocalDateTime(msg.getAt());
// 0,0定位不处理
if (MathUtils.equals(sys.getLon(), BigDecimal.ZERO) && MathUtils.equals(sys.getLat(), BigDecimal.ZERO)) {
log.info("设备{}定位异常:{},{},不处理", msg.getDevName(), sys.getLon(), sys.getLat());
return;
}
// 处理设备定位BUG若出现BUG则重启设备
int handle = this.handleDeviceLocationBug(device, sys, at);
if (handle == 1) {
@ -135,10 +142,6 @@ public class IotReceiveServiceImpl implements IotReceiveService {
if (device == null || StringUtils.isBlank(device.getMac()) || device.getLastLocationTime() == null || at == null) {
return 0;
}
// 0,0定位不处理
if (MathUtils.equals(sys.getLon(), BigDecimal.ZERO) && MathUtils.equals(sys.getLat(), BigDecimal.ZERO)) {
return 0;
}
// 相差一分钟以上的消息不做处理
Duration duration = Duration.between(at, LocalDateTime.now());
if (duration.getSeconds() > 60) {

View File

@ -1,6 +1,7 @@
package com.ruoyi.iot.util;
import java.io.UnsupportedEncodingException;
import java.math.BigDecimal;
import java.nio.charset.StandardCharsets;
import java.security.InvalidAlgorithmParameterException;
import java.security.InvalidKeyException;
@ -220,6 +221,13 @@ public class IotUtil {
if (value == null) {
return null;
}
return JSON.parseObject(value.toString(), IotDeviceSysInfo.class);
IotDeviceSysInfo sys = JSON.parseObject(value.toString(), IotDeviceSysInfo.class);
// 旧版硬件BUG电压超过100V的需要除以10
if (sys.getBat() != null && sys.getBat().compareTo(BigDecimal.valueOf(100)) >= 0) {
sys.setBat(sys.getBat().divide(BigDecimal.valueOf(10), 2, BigDecimal.ROUND_HALF_UP));
}
return sys;
}
}

View File

@ -4,8 +4,6 @@ import java.util.List;
import javax.servlet.http.HttpServletResponse;
import com.ruoyi.bst.agreement.service.AgreementConverter;
import com.ruoyi.common.core.validate.ValidGroup;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
@ -21,12 +19,14 @@ import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.bst.agreement.domain.Agreement;
import com.ruoyi.bst.agreement.domain.AgreementQuery;
import com.ruoyi.bst.agreement.domain.AgreementVO;
import com.ruoyi.bst.agreement.service.AgreementConverter;
import com.ruoyi.bst.agreement.service.AgreementService;
import com.ruoyi.bst.agreement.service.AgreementValidator;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.core.validate.ValidGroup;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.enums.LogBizType;
import com.ruoyi.common.utils.poi.ExcelUtil;

View File

@ -17,6 +17,7 @@ import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.bst.area.service.AreaService;
import com.ruoyi.bst.area.service.AreaValidator;
import com.ruoyi.bst.areaJoin.domain.enums.AreaJoinPermission;
import com.ruoyi.bst.customerService.domain.CustomerService;
import com.ruoyi.bst.customerService.domain.CustomerServiceQuery;
import com.ruoyi.bst.customerService.domain.CustomerServiceVO;
@ -62,6 +63,7 @@ public class CustomerServiceController extends BaseController
startPage();
startOrderBy();
query.setScope(true);
query.addAreaPermission(AreaJoinPermission.CUSTOMER_SERVICE_VIEW.getCode());
List<CustomerServiceVO> list = customerServiceService.selectCustomerServiceList(query);
return getDataTable(list);
}
@ -75,6 +77,7 @@ public class CustomerServiceController extends BaseController
public void export(HttpServletResponse response, CustomerServiceQuery query)
{
query.setScope(true);
query.addAreaPermission(AreaJoinPermission.CUSTOMER_SERVICE_VIEW.getCode());
List<CustomerServiceVO> list = customerServiceService.selectCustomerServiceList(query);
ExcelUtil<CustomerServiceVO> util = new ExcelUtil<CustomerServiceVO>(CustomerServiceVO.class);
util.exportExcel(response, list, "客服数据");