diff --git a/bonus-modules/bonus-base/src/main/java/com/bonus/base/config/Constants.java b/bonus-modules/bonus-base/src/main/java/com/bonus/base/config/Constants.java index 0470333..14a79be 100644 --- a/bonus-modules/bonus-base/src/main/java/com/bonus/base/config/Constants.java +++ b/bonus-modules/bonus-base/src/main/java/com/bonus/base/config/Constants.java @@ -58,9 +58,9 @@ public class Constants { public static final Integer FAIL = 500; /** - * 登录成功状态 + * 身份证正则表达式 */ - public static final String LOGIN_SUCCESS_STATUS = "0"; + public static final String CREDENTIALS_CODE_PATTERN = "^[1-9]\\d{5}[1-9]\\d{3}((0[1-9])|(1[0-2]))(0[1-9]|([1|2][0-9])|3[0-1])((\\d{4})|\\d{3}X)$"; /** * 登录失败状态 diff --git a/bonus-modules/bonus-base/src/main/java/com/bonus/base/controller/TbBdRecordController.java b/bonus-modules/bonus-base/src/main/java/com/bonus/base/controller/TbBdRecordController.java index 7de02c4..6be35c0 100644 --- a/bonus-modules/bonus-base/src/main/java/com/bonus/base/controller/TbBdRecordController.java +++ b/bonus-modules/bonus-base/src/main/java/com/bonus/base/controller/TbBdRecordController.java @@ -28,7 +28,7 @@ public class TbBdRecordController extends BaseController { /** * 通过主键查询单条数据 */ - @GetMapping("{/id}") + @GetMapping("/{id}") public AjaxResult selectById(@PathVariable("id") Long id) { return success(tbBdRecordService.selectByPrimaryKey(id)); } @@ -49,7 +49,7 @@ public class TbBdRecordController extends BaseController { */ @PostMapping public AjaxResult add(@RequestBody @NotNull(message = "参数不能为空") @Valid TbBdRecord tbBdRecord) { - return toAjax(tbBdRecordService.insertSelective(tbBdRecord)); + return tbBdRecordService.insertSelective(tbBdRecord); } @@ -61,7 +61,7 @@ public class TbBdRecordController extends BaseController { */ @PutMapping public AjaxResult edit(@RequestBody @NotNull(message = "参数不能为空") @Valid TbBdRecord tbBdRecord) { - return toAjax(tbBdRecordService.updateByPrimaryKeySelective(tbBdRecord)); + return tbBdRecordService.updateByPrimaryKeySelective(tbBdRecord); } @@ -73,7 +73,17 @@ public class TbBdRecordController extends BaseController { */ @DeleteMapping("/{id}") public AjaxResult deleteById(@PathVariable("id") Long id) { - return toAjax(tbBdRecordService.deleteByPrimaryKey(id)); + return tbBdRecordService.deleteByPrimaryKey(id); + } + + /** + * 审核 + * @param tbBdRecord + * @return + */ + @PostMapping("/approve") + public AjaxResult approve(@RequestBody @NotNull(message = "参数不能为空") @Valid TbBdRecord tbBdRecord) { + return tbBdRecordService.approve(tbBdRecord); } diff --git a/bonus-modules/bonus-base/src/main/java/com/bonus/base/controller/TbDeviceController.java b/bonus-modules/bonus-base/src/main/java/com/bonus/base/controller/TbDeviceController.java index c10e85f..d8fea76 100644 --- a/bonus-modules/bonus-base/src/main/java/com/bonus/base/controller/TbDeviceController.java +++ b/bonus-modules/bonus-base/src/main/java/com/bonus/base/controller/TbDeviceController.java @@ -51,7 +51,7 @@ public class TbDeviceController extends BaseController { */ @PostMapping public AjaxResult add(@RequestBody TbDevice tbDevice) { - return toAjax(tbDeviceService.insertSelective(tbDevice)); + return tbDeviceService.insertSelective(tbDevice); } diff --git a/bonus-modules/bonus-base/src/main/java/com/bonus/base/controller/TbPeopleController.java b/bonus-modules/bonus-base/src/main/java/com/bonus/base/controller/TbPeopleController.java index 3b1f053..d97023b 100644 --- a/bonus-modules/bonus-base/src/main/java/com/bonus/base/controller/TbPeopleController.java +++ b/bonus-modules/bonus-base/src/main/java/com/bonus/base/controller/TbPeopleController.java @@ -144,7 +144,7 @@ public class TbPeopleController extends BaseController { @PostMapping("/importData") public AjaxResult importData(MultipartFile file) { - return tbPeopleService.importTbProPower(file); + return tbPeopleService.importTbPeople(file); } /** diff --git a/bonus-modules/bonus-base/src/main/java/com/bonus/base/controller/TbProPowerController.java b/bonus-modules/bonus-base/src/main/java/com/bonus/base/controller/TbProPowerController.java index 972d193..f9f6309 100644 --- a/bonus-modules/bonus-base/src/main/java/com/bonus/base/controller/TbProPowerController.java +++ b/bonus-modules/bonus-base/src/main/java/com/bonus/base/controller/TbProPowerController.java @@ -1,6 +1,5 @@ package com.bonus.base.controller; -import com.bonus.base.domain.TbProDepart; import com.bonus.base.domain.TbProPower; import com.bonus.base.service.TbProPowerService; import com.bonus.common.core.utils.poi.ExcelUtil; diff --git a/bonus-modules/bonus-base/src/main/java/com/bonus/base/controller/TbTeamController.java b/bonus-modules/bonus-base/src/main/java/com/bonus/base/controller/TbTeamController.java index 2f6627f..500396b 100644 --- a/bonus-modules/bonus-base/src/main/java/com/bonus/base/controller/TbTeamController.java +++ b/bonus-modules/bonus-base/src/main/java/com/bonus/base/controller/TbTeamController.java @@ -1,5 +1,6 @@ package com.bonus.base.controller; +import com.bonus.base.domain.TbPeople; import com.bonus.base.domain.TbTeam; import com.bonus.base.service.TbTeamService; import com.bonus.base.vo.TbDeviceVo; @@ -125,5 +126,15 @@ public class TbTeamController extends BaseController { public AjaxResult queryByPage(TbDeviceVo tbDeviceVo) { return AjaxResult.success(tbTeamService.selectDeviceList(tbDeviceVo)); } + + /** + * 从北京电科院数据库获取班组列表 + * @return 查询结果 + */ + @GetMapping("/getList") + public AjaxResult queryByPage() { + List list = tbTeamService.getList(); + return AjaxResult.success(list); + } } diff --git a/bonus-modules/bonus-base/src/main/java/com/bonus/base/controller/TbWarnConfigController.java b/bonus-modules/bonus-base/src/main/java/com/bonus/base/controller/TbWarnConfigController.java index 831f61e..619a9eb 100644 --- a/bonus-modules/bonus-base/src/main/java/com/bonus/base/controller/TbWarnConfigController.java +++ b/bonus-modules/bonus-base/src/main/java/com/bonus/base/controller/TbWarnConfigController.java @@ -1,4 +1,5 @@ package com.bonus.base.controller; + import com.bonus.base.domain.TbWarnConfig; import com.bonus.base.service.TbWarnConfigService; import com.bonus.common.core.web.controller.BaseController; @@ -34,6 +35,11 @@ public class TbWarnConfigController extends BaseController { return success(tbWarnConfigService.selectByPrimaryKey(id)); } + /** + * 分页查询所有数据 + * @param tbWarnConfig + * @return + */ @GetMapping("/list") public AjaxResult queryByPage(TbWarnConfig tbWarnConfig) { startPage(); @@ -50,7 +56,7 @@ public class TbWarnConfigController extends BaseController { */ @PostMapping public AjaxResult add(@RequestBody @Valid TbWarnConfig tbWarnConfig) { - return toAjax(tbWarnConfigService.insertSelective(tbWarnConfig)); + return tbWarnConfigService.insertSelective(tbWarnConfig); } @@ -62,7 +68,7 @@ public class TbWarnConfigController extends BaseController { */ @PutMapping public AjaxResult edit(@RequestBody @Valid TbWarnConfig tbWarnConfig) { - return toAjax(tbWarnConfigService.updateByPrimaryKeySelective(tbWarnConfig)); + return tbWarnConfigService.updateByPrimaryKeySelective(tbWarnConfig); } @@ -74,7 +80,7 @@ public class TbWarnConfigController extends BaseController { */ @DeleteMapping("/{id}") public AjaxResult deleteById(@PathVariable("id") Long id) { - return toAjax(tbWarnConfigService.deleteByPrimaryKey(id)); + return tbWarnConfigService.deleteByPrimaryKey(id); } } diff --git a/bonus-modules/bonus-base/src/main/java/com/bonus/base/domain/TbBdRecord.java b/bonus-modules/bonus-base/src/main/java/com/bonus/base/domain/TbBdRecord.java index 7bd9d0b..f7c6e5c 100644 --- a/bonus-modules/bonus-base/src/main/java/com/bonus/base/domain/TbBdRecord.java +++ b/bonus-modules/bonus-base/src/main/java/com/bonus/base/domain/TbBdRecord.java @@ -1,9 +1,11 @@ package com.bonus.base.domain; +import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import java.io.Serializable; import java.util.Date; +import java.util.List; import javax.validation.constraints.NotNull; import javax.validation.constraints.Size; import lombok.Data; @@ -90,6 +92,7 @@ public class TbBdRecord implements Serializable { * 创建时间-申请时间 */ @ApiModelProperty(value="创建时间-申请时间") + @JsonFormat(pattern = "yyyy-MM-dd") private Date createTime; /** @@ -122,5 +125,15 @@ public class TbBdRecord implements Serializable { @ApiModelProperty(value="审核时间") private Date auditTime; + /** + * 申请接入边带数量 + */ + private Integer bdTotal; + + /** + * 边带设备记录 + */ + private List recordList; + private static final long serialVersionUID = 1L; } \ No newline at end of file diff --git a/bonus-modules/bonus-base/src/main/java/com/bonus/base/domain/TbProPower.java b/bonus-modules/bonus-base/src/main/java/com/bonus/base/domain/TbProPower.java index b8bd2f2..3ddde0a 100644 --- a/bonus-modules/bonus-base/src/main/java/com/bonus/base/domain/TbProPower.java +++ b/bonus-modules/bonus-base/src/main/java/com/bonus/base/domain/TbProPower.java @@ -27,16 +27,19 @@ public class TbProPower implements Serializable { * 工程id */ private Long proId; + /** * 经度 */ @Excel(name = "杆塔经度") - private String lat; + private String lon; + /** - * 维度 + * 纬度 */ @Excel(name = "杆塔纬度") - private String lon; + private String lat; + /** * 是否删除 */ diff --git a/bonus-modules/bonus-base/src/main/java/com/bonus/base/domain/TbWarnConfig.java b/bonus-modules/bonus-base/src/main/java/com/bonus/base/domain/TbWarnConfig.java index 22ce796..f3076d1 100644 --- a/bonus-modules/bonus-base/src/main/java/com/bonus/base/domain/TbWarnConfig.java +++ b/bonus-modules/bonus-base/src/main/java/com/bonus/base/domain/TbWarnConfig.java @@ -31,6 +31,12 @@ public class TbWarnConfig implements Serializable { @ApiModelProperty(value="类型(来源码表-设备类型)") private Integer configuType; + /** + * 类型(来源码表-设备类型) + */ + @ApiModelProperty(value="类型(来源码表-设备类型)") + private String typeName; + /** * 配置名称 */ @@ -50,6 +56,9 @@ public class TbWarnConfig implements Serializable { @ApiModelProperty(value="阈值1-min") private BigDecimal configVal1Min; + @ApiModelProperty(value="阈值1组合") + private String configVal1Str; + /** * 阈值2-max */ @@ -62,6 +71,9 @@ public class TbWarnConfig implements Serializable { @ApiModelProperty(value="阈值2-min") private BigDecimal configVal2Min; + @ApiModelProperty(value="阈值2组合") + private String configVal2Str; + /** * 阈值3-max */ @@ -74,6 +86,9 @@ public class TbWarnConfig implements Serializable { @ApiModelProperty(value="阈值3-min") private BigDecimal configVal3Min; + @ApiModelProperty(value="阈值3组合") + private String configVal3Str; + /** * 阈值4-max */ @@ -86,6 +101,9 @@ public class TbWarnConfig implements Serializable { @ApiModelProperty(value="阈值4-min") private BigDecimal configVal4Min; + @ApiModelProperty(value="阈值4组合") + private String configVal4Str; + /** * 阈值5-max */ @@ -98,6 +116,9 @@ public class TbWarnConfig implements Serializable { @ApiModelProperty(value="阈值5-min") private BigDecimal configVal5Min; + @ApiModelProperty(value="阈值5组合") + private String configVal5Str; + /** * 阈值6-max */ @@ -110,6 +131,9 @@ public class TbWarnConfig implements Serializable { @ApiModelProperty(value="阈值6-min") private BigDecimal configVal6Min; + @ApiModelProperty(value="阈值6组合") + private String configVal6Str; + /** * 删除状态 */ diff --git a/bonus-modules/bonus-base/src/main/java/com/bonus/base/mapper/TbBdDeviceRecordMapper.java b/bonus-modules/bonus-base/src/main/java/com/bonus/base/mapper/TbBdDeviceRecordMapper.java index 341027e..e0dcc80 100644 --- a/bonus-modules/bonus-base/src/main/java/com/bonus/base/mapper/TbBdDeviceRecordMapper.java +++ b/bonus-modules/bonus-base/src/main/java/com/bonus/base/mapper/TbBdDeviceRecordMapper.java @@ -31,4 +31,7 @@ public interface TbBdDeviceRecordMapper { List getAll(TbBdDeviceRecord record); + int updateById(Long id); + + TbBdDeviceRecord selectByName(TbBdDeviceRecord deviceRecord); } \ No newline at end of file diff --git a/bonus-modules/bonus-base/src/main/java/com/bonus/base/mapper/TbBdRecordMapper.java b/bonus-modules/bonus-base/src/main/java/com/bonus/base/mapper/TbBdRecordMapper.java index 15376cb..ac253da 100644 --- a/bonus-modules/bonus-base/src/main/java/com/bonus/base/mapper/TbBdRecordMapper.java +++ b/bonus-modules/bonus-base/src/main/java/com/bonus/base/mapper/TbBdRecordMapper.java @@ -1,7 +1,10 @@ package com.bonus.base.mapper; +import com.bonus.base.domain.TbBdDeviceRecord; import com.bonus.base.domain.TbBdRecord; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; +import org.springframework.web.bind.annotation.PathVariable; import java.util.List; @@ -32,4 +35,5 @@ public interface TbBdRecordMapper { List getAll(TbBdRecord record); + TbBdRecord selectByName(TbBdRecord record); } \ No newline at end of file diff --git a/bonus-modules/bonus-base/src/main/java/com/bonus/base/mapper/TbDeviceMapper.java b/bonus-modules/bonus-base/src/main/java/com/bonus/base/mapper/TbDeviceMapper.java index 1cb101b..b5b4758 100644 --- a/bonus-modules/bonus-base/src/main/java/com/bonus/base/mapper/TbDeviceMapper.java +++ b/bonus-modules/bonus-base/src/main/java/com/bonus/base/mapper/TbDeviceMapper.java @@ -29,4 +29,11 @@ public interface TbDeviceMapper { List getAll(TbDevice record); int updateBatch(List list); + + /** + * 根据设备编码查询设备信息 + * @param record + * @return + */ + TbDevice selectByDevCode(TbDevice record); } \ No newline at end of file diff --git a/bonus-modules/bonus-base/src/main/java/com/bonus/base/mapper/TbPeopleMapper.java b/bonus-modules/bonus-base/src/main/java/com/bonus/base/mapper/TbPeopleMapper.java index 51fc1d5..0e0cad0 100644 --- a/bonus-modules/bonus-base/src/main/java/com/bonus/base/mapper/TbPeopleMapper.java +++ b/bonus-modules/bonus-base/src/main/java/com/bonus/base/mapper/TbPeopleMapper.java @@ -59,11 +59,5 @@ public interface TbPeopleMapper { */ TbPeople queryByName(TbPeople tbPeople); - /** - * 批量新增或按主键更新数据 - * @param tbPeople - * @return - */ - int insertOrUpdate(TbPeople tbPeople); } diff --git a/bonus-modules/bonus-base/src/main/java/com/bonus/base/mapper/TbWarnConfigMapper.java b/bonus-modules/bonus-base/src/main/java/com/bonus/base/mapper/TbWarnConfigMapper.java index dc06d5c..017b408 100644 --- a/bonus-modules/bonus-base/src/main/java/com/bonus/base/mapper/TbWarnConfigMapper.java +++ b/bonus-modules/bonus-base/src/main/java/com/bonus/base/mapper/TbWarnConfigMapper.java @@ -33,4 +33,11 @@ public interface TbWarnConfigMapper { int updateByPrimaryKey(TbWarnConfig record); int updateBatch(List list); + + /** + * 根据配置名称查询 + * @param record + * @return + */ + TbWarnConfig selectByName(TbWarnConfig record); } \ No newline at end of file diff --git a/bonus-modules/bonus-base/src/main/java/com/bonus/base/service/TbBdRecordService.java b/bonus-modules/bonus-base/src/main/java/com/bonus/base/service/TbBdRecordService.java index 76ce0a8..6e8662a 100644 --- a/bonus-modules/bonus-base/src/main/java/com/bonus/base/service/TbBdRecordService.java +++ b/bonus-modules/bonus-base/src/main/java/com/bonus/base/service/TbBdRecordService.java @@ -1,6 +1,8 @@ package com.bonus.base.service; import com.bonus.base.domain.TbBdRecord; +import com.bonus.common.core.web.domain.AjaxResult; + import java.util.List; /** *@PackagePath: com.bonus.base.service @@ -11,22 +13,29 @@ import java.util.List; */ public interface TbBdRecordService{ - int deleteByPrimaryKey(Long id); + AjaxResult deleteByPrimaryKey(Long id); - int deleteByPrimaryKeyIn(List list); + int deleteByPrimaryKeyIn(List list); - int insert(TbBdRecord record); + int insert(TbBdRecord record); - int insertSelective(TbBdRecord record); + AjaxResult insertSelective(TbBdRecord record); - TbBdRecord selectByPrimaryKey(Long id); + TbBdRecord selectByPrimaryKey(Long id); - int updateByPrimaryKeySelective(TbBdRecord record); + AjaxResult updateByPrimaryKeySelective(TbBdRecord record); - int updateByPrimaryKey(TbBdRecord record); + int updateByPrimaryKey(TbBdRecord record); - int updateBatch(List list); + int updateBatch(List list); - List getAll(TbBdRecord record); + List getAll(TbBdRecord record); -} + /** + * 审核 + * + * @param tbBdRecord + * @return + */ + AjaxResult approve(TbBdRecord tbBdRecord); + } diff --git a/bonus-modules/bonus-base/src/main/java/com/bonus/base/service/TbDeviceService.java b/bonus-modules/bonus-base/src/main/java/com/bonus/base/service/TbDeviceService.java index e21126a..7953ca7 100644 --- a/bonus-modules/bonus-base/src/main/java/com/bonus/base/service/TbDeviceService.java +++ b/bonus-modules/bonus-base/src/main/java/com/bonus/base/service/TbDeviceService.java @@ -2,7 +2,9 @@ package com.bonus.base.service; import java.util.List; import com.bonus.base.domain.TbDevice; - /** +import com.bonus.common.core.web.domain.AjaxResult; + +/** *@PackagePath: com.bonus.base.service *@author : 阮世耀 *@version : 1.0 @@ -15,7 +17,7 @@ public interface TbDeviceService{ int insert(TbDevice record); - int insertSelective(TbDevice record); + AjaxResult insertSelective(TbDevice record); TbDevice selectByPrimaryKey(Long id); diff --git a/bonus-modules/bonus-base/src/main/java/com/bonus/base/service/TbPeopleService.java b/bonus-modules/bonus-base/src/main/java/com/bonus/base/service/TbPeopleService.java index 39cc81a..4b616e7 100644 --- a/bonus-modules/bonus-base/src/main/java/com/bonus/base/service/TbPeopleService.java +++ b/bonus-modules/bonus-base/src/main/java/com/bonus/base/service/TbPeopleService.java @@ -74,5 +74,5 @@ public interface TbPeopleService { * @param file * @return */ - AjaxResult importTbProPower(MultipartFile file); + AjaxResult importTbPeople(MultipartFile file); } diff --git a/bonus-modules/bonus-base/src/main/java/com/bonus/base/service/TbTeamService.java b/bonus-modules/bonus-base/src/main/java/com/bonus/base/service/TbTeamService.java index abc5636..62ac121 100644 --- a/bonus-modules/bonus-base/src/main/java/com/bonus/base/service/TbTeamService.java +++ b/bonus-modules/bonus-base/src/main/java/com/bonus/base/service/TbTeamService.java @@ -80,7 +80,15 @@ public interface TbTeamService { /** * 智能安全帽列表查询 + * @param tbDeviceVo * @return */ List selectDeviceList(TbDeviceVo tbDeviceVo); + + /** + * 从北京电科院数据库获取班组列表 + * @return + */ + List getList(); + } diff --git a/bonus-modules/bonus-base/src/main/java/com/bonus/base/service/TbWarnConfigService.java b/bonus-modules/bonus-base/src/main/java/com/bonus/base/service/TbWarnConfigService.java index bb9399d..58d3199 100644 --- a/bonus-modules/bonus-base/src/main/java/com/bonus/base/service/TbWarnConfigService.java +++ b/bonus-modules/bonus-base/src/main/java/com/bonus/base/service/TbWarnConfigService.java @@ -1,6 +1,7 @@ package com.bonus.base.service; import com.bonus.base.domain.TbWarnConfig; +import com.bonus.common.core.web.domain.AjaxResult; import java.util.List; @@ -10,17 +11,17 @@ import java.util.List; */ public interface TbWarnConfigService{ - int deleteByPrimaryKey(Long id); + AjaxResult deleteByPrimaryKey(Long id); int deleteByPrimaryKeyIn(List list); int insert(TbWarnConfig record); - int insertSelective(TbWarnConfig record); + AjaxResult insertSelective(TbWarnConfig record); TbWarnConfig selectByPrimaryKey(Long id); - int updateByPrimaryKeySelective(TbWarnConfig record); + AjaxResult updateByPrimaryKeySelective(TbWarnConfig record); int updateByPrimaryKey(TbWarnConfig record); diff --git a/bonus-modules/bonus-base/src/main/java/com/bonus/base/service/impl/TbBdRecordServiceImpl.java b/bonus-modules/bonus-base/src/main/java/com/bonus/base/service/impl/TbBdRecordServiceImpl.java index 3908345..661c0a2 100644 --- a/bonus-modules/bonus-base/src/main/java/com/bonus/base/service/impl/TbBdRecordServiceImpl.java +++ b/bonus-modules/bonus-base/src/main/java/com/bonus/base/service/impl/TbBdRecordServiceImpl.java @@ -1,13 +1,27 @@ package com.bonus.base.service.impl; +import com.alibaba.nacos.common.utils.CollectionUtils; +import com.bonus.base.config.ExceptionEnum; +import com.bonus.base.domain.TbBdDeviceRecord; +import com.bonus.base.mapper.TbBdDeviceRecordMapper; +import com.bonus.common.core.utils.StringUtils; +import com.bonus.common.core.utils.encryption.Sm4Utils; +import com.bonus.common.core.web.domain.AjaxResult; +import com.bonus.common.security.utils.SecurityUtils; import org.springframework.stereotype.Service; import org.springframework.beans.factory.annotation.Autowired; import com.bonus.base.domain.TbBdRecord; + +import java.util.Date; import java.util.List; +import java.util.stream.Collectors; + import com.bonus.base.mapper.TbBdRecordMapper; import com.bonus.base.service.TbBdRecordService; +import org.springframework.transaction.annotation.Transactional; + /** *@PackagePath: com.bonus.base.service.impl *@author : 阮世耀 @@ -21,9 +35,21 @@ public class TbBdRecordServiceImpl implements TbBdRecordService{ @Autowired private TbBdRecordMapper tbBdRecordMapper; + @Autowired + private TbBdDeviceRecordMapper tbBdDeviceRecordMapper; + @Override - public int deleteByPrimaryKey(Long id) { - return tbBdRecordMapper.deleteByPrimaryKey(id); + @Transactional(rollbackFor = Exception.class) + public AjaxResult deleteByPrimaryKey(Long id) { + //先清除设备绑定记录id,在进行删除 + int result = 0; + //根据前端传入的id,删除设备绑定记录 + result += tbBdDeviceRecordMapper.updateById(id); + result += tbBdRecordMapper.deleteByPrimaryKey(id); + if (result > 0) { + return AjaxResult.success(ExceptionEnum.SUCCESS.getMsg(), result); + } + return AjaxResult.error(ExceptionEnum.DELETE_TO_DATABASE.getCode(), ExceptionEnum.DELETE_TO_DATABASE.getMsg()); } @Override @@ -37,18 +63,103 @@ public class TbBdRecordServiceImpl implements TbBdRecordService{ } @Override - public int insertSelective(TbBdRecord record) { - return tbBdRecordMapper.insertSelective(record); + @Transactional(rollbackFor = Exception.class) + public AjaxResult insertSelective(TbBdRecord record) { + //根据项目部和工程判断,同项目部和工程只可接入一次申请 + TbBdRecord tbBdRecord = tbBdRecordMapper.selectByName(record); + if (tbBdRecord != null){ + return AjaxResult.error("该项目部和工程已申请,请勿重复申请"); + } + int result = 0; + //返回主键id + //插入前对手机号进行sm4加密 + record.setRelPhone(Sm4Utils.encode(record.getRelPhone())); + //初始状态赋值待审核 + record.setAuditStatus(0); + record.setCreateUser(SecurityUtils.getUserId()); + result += tbBdRecordMapper.insertSelective(record); + //插入设备记录 + if (record.getRecordList() != null && record.getRecordList().size() > 0) { + for (TbBdDeviceRecord deviceRecord : record.getRecordList()) { + deviceRecord.setRecordId(record.getId()); + if (StringUtils.isNotBlank(deviceRecord.getDevUserPhone())) { + deviceRecord.setDevUserPhone(Sm4Utils.encode(deviceRecord.getDevUserPhone())); + } + //根据设备名称或编码唯一校验 + TbBdDeviceRecord tbBdDeviceRecord = tbBdDeviceRecordMapper.selectByName(deviceRecord); + if (tbBdDeviceRecord != null) { + return AjaxResult.error(tbBdDeviceRecord.getDevName() + "设备名称或编码重复,请勿重复添加"); + } + result += tbBdDeviceRecordMapper.insert(deviceRecord); + } + } + if (result > 0) { + return AjaxResult.success(ExceptionEnum.SUCCESS.getMsg(), result); + } + return AjaxResult.error(ExceptionEnum.SAVE_TO_DATABASE.getCode(), ExceptionEnum.SAVE_TO_DATABASE.getMsg()); } @Override public TbBdRecord selectByPrimaryKey(Long id) { - return tbBdRecordMapper.selectByPrimaryKey(id); + TbBdRecord tbBdRecord = tbBdRecordMapper.selectByPrimaryKey(id); + if (tbBdRecord != null) { + //对外层手机号进行解密处理 + tbBdRecord.setRelPhone(Sm4Utils.decode(tbBdRecord.getRelPhone())); + //查询设备绑定记录 + TbBdDeviceRecord record = new TbBdDeviceRecord(); + record.setRecordId(id); + List list = tbBdDeviceRecordMapper.getAll(record); + if (CollectionUtils.isNotEmpty(list)) { + for (TbBdDeviceRecord deviceRecord : list) { + //对内层手机号进行解密处理 + deviceRecord.setDevUserPhone(Sm4Utils.decode(deviceRecord.getDevUserPhone())); + } + tbBdRecord.setRecordList(list); + } + } + return tbBdRecord; } @Override - public int updateByPrimaryKeySelective(TbBdRecord record) { - return tbBdRecordMapper.updateByPrimaryKeySelective(record); + @Transactional(rollbackFor = Exception.class) + public AjaxResult updateByPrimaryKeySelective(TbBdRecord record) { + //根据项目部和工程判断,同项目部和工程只可接入一次申请 + TbBdRecord tbBdRecord = tbBdRecordMapper.selectByName(record); + if(tbBdRecord != null && !tbBdRecord.getId().equals(record.getId())){ + return AjaxResult.error("该项目部和工程已申请,请勿重复申请"); + } + //校验内层设备名称或编码重复性 + if (record.getRecordList() != null && record.getRecordList().size() > 0) { + for (TbBdDeviceRecord deviceRecord : record.getRecordList()) { + TbBdDeviceRecord tbBdDeviceRecord = tbBdDeviceRecordMapper.selectByName(deviceRecord); + if (tbBdDeviceRecord != null && !tbBdDeviceRecord.getRecordId().equals(deviceRecord.getId())) { + return AjaxResult.error(tbBdDeviceRecord.getDevName() + "设备名称或编码重复,请勿重复添加"); + } + } + } + int result = 0; + //根据前端传入的id,删除设备绑定记录 + result += tbBdDeviceRecordMapper.updateById(record.getId()); + //插入前对手机号进行sm4加密 + record.setRelPhone(Sm4Utils.encode(record.getRelPhone())); + //初始状态赋值待审核 + record.setAuditStatus(0); + record.setUpdateUser(SecurityUtils.getUserId()); + result += tbBdRecordMapper.updateByPrimaryKeySelective(record); + //插入设备记录 + if (record.getRecordList() != null && record.getRecordList().size() > 0) { + for (TbBdDeviceRecord deviceRecord : record.getRecordList()) { + deviceRecord.setRecordId(record.getId()); + if (StringUtils.isNotBlank(deviceRecord.getDevUserPhone())) { + deviceRecord.setDevUserPhone(Sm4Utils.encode(deviceRecord.getDevUserPhone())); + } + result += tbBdDeviceRecordMapper.insert(deviceRecord); + } + } + if (result > 0) { + return AjaxResult.success(ExceptionEnum.SUCCESS.getMsg(), result); + } + return AjaxResult.error(ExceptionEnum.UPDATE_TO_DATABASE.getCode(), ExceptionEnum.UPDATE_TO_DATABASE.getMsg()); } @Override @@ -61,11 +172,34 @@ public class TbBdRecordServiceImpl implements TbBdRecordService{ return tbBdRecordMapper.updateBatch(list); } + @Override public List getAll(TbBdRecord record){ - return tbBdRecordMapper.getAll(record); - } - + List list = tbBdRecordMapper.getAll(record); + if (list != null && list.size() > 0) { + List recordList = list.stream().filter(tbBdRecord -> tbBdRecord.getDepartName() != null).collect(Collectors.toList()); + for (TbBdRecord tbBdRecord : recordList) { + //对手机号进行解密处理 + tbBdRecord.setRelPhone(Sm4Utils.decode(tbBdRecord.getRelPhone())); + } + } + return list; + } + /** + * 审核 + * @param tbBdRecord + * @return + */ + @Override + public AjaxResult approve(TbBdRecord tbBdRecord) { + tbBdRecord.setAuditUser(SecurityUtils.getUserId()); + tbBdRecord.setAuditTime(new Date()); + int result = tbBdRecordMapper.updateByPrimaryKeySelective(tbBdRecord); + if (result > 0) { + return AjaxResult.success(ExceptionEnum.SUCCESS.getMsg(), result); + } + return AjaxResult.error("审核失败,请联系管理员"); + } } diff --git a/bonus-modules/bonus-base/src/main/java/com/bonus/base/service/impl/TbDeviceServiceImpl.java b/bonus-modules/bonus-base/src/main/java/com/bonus/base/service/impl/TbDeviceServiceImpl.java index 8702a92..c51ed4c 100644 --- a/bonus-modules/bonus-base/src/main/java/com/bonus/base/service/impl/TbDeviceServiceImpl.java +++ b/bonus-modules/bonus-base/src/main/java/com/bonus/base/service/impl/TbDeviceServiceImpl.java @@ -1,5 +1,7 @@ package com.bonus.base.service.impl; +import com.bonus.base.config.ExceptionEnum; +import com.bonus.common.core.web.domain.AjaxResult; import org.springframework.stereotype.Service; import org.springframework.beans.factory.annotation.Autowired; @@ -35,8 +37,17 @@ public class TbDeviceServiceImpl implements TbDeviceService{ } @Override - public int insertSelective(TbDevice record) { - return tbDeviceMapper.insertSelective(record); + public AjaxResult insertSelective(TbDevice record) { + //根据传入的devCode判重,确保唯一性 + TbDevice tbDevice = tbDeviceMapper.selectByDevCode(record); + if (tbDevice != null) { + return AjaxResult.error(ExceptionEnum.NAME_DUPLICATE.getCode(), ExceptionEnum.NAME_DUPLICATE.getMsg()); + } + int result = tbDeviceMapper.insertSelective(record); + if (result > 0) { + return AjaxResult.success(ExceptionEnum.SUCCESS.getMsg(), result); + } + return AjaxResult.error(ExceptionEnum.SAVE_TO_DATABASE.getCode(), ExceptionEnum.SAVE_TO_DATABASE.getMsg()); } @Override diff --git a/bonus-modules/bonus-base/src/main/java/com/bonus/base/service/impl/TbPeopleServiceImpl.java b/bonus-modules/bonus-base/src/main/java/com/bonus/base/service/impl/TbPeopleServiceImpl.java index a8496d4..cd02c0b 100644 --- a/bonus-modules/bonus-base/src/main/java/com/bonus/base/service/impl/TbPeopleServiceImpl.java +++ b/bonus-modules/bonus-base/src/main/java/com/bonus/base/service/impl/TbPeopleServiceImpl.java @@ -5,7 +5,6 @@ import com.alibaba.nacos.common.utils.CollectionUtils; import com.bonus.base.config.Constants; import com.bonus.base.config.ExceptionEnum; import com.bonus.base.domain.TbPeople; -import com.bonus.base.domain.TbProPower; import com.bonus.base.mapper.TbPeopleMapper; import com.bonus.base.service.TbPeopleService; import com.bonus.common.core.utils.StringUtils; @@ -15,12 +14,8 @@ import com.bonus.common.core.web.domain.AjaxResult; import com.bonus.common.security.utils.SecurityUtils; import lombok.extern.slf4j.Slf4j; import org.apache.commons.io.IOUtils; -import org.apache.poi.ss.usermodel.Cell; -import org.apache.poi.ss.usermodel.Row; -import org.apache.poi.ss.usermodel.Sheet; -import org.apache.poi.ss.usermodel.Workbook; +import org.apache.poi.ss.usermodel.*; import org.apache.poi.xssf.usermodel.XSSFWorkbook; -import org.bouncycastle.jce.provider.BouncyCastleProvider; import org.springframework.stereotype.Service; import org.springframework.web.multipart.MultipartFile; @@ -29,7 +24,6 @@ import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; -import java.security.Security; import java.sql.*; import java.util.ArrayList; import java.util.List; @@ -80,11 +74,6 @@ public class TbPeopleServiceImpl implements TbPeopleService { return peopleList; } - public static void main(String[] args) { - - System.out.println(Sm4Utils.decode("495d83e0f1f5c928669e1d18bc0f889d806e129ca685d1140c26a10c3e938299")); - - } /** * 新增数据 * @@ -101,9 +90,8 @@ public class TbPeopleServiceImpl implements TbPeopleService { return AjaxResult.error(ExceptionEnum.INVALID_PHONE_NUMBER_FORMAT.getCode(), ExceptionEnum.INVALID_PHONE_NUMBER_FORMAT.getMsg()); } //校验前端传入的身份证号 - String CREDENTIALS_CODE_PATTERN = "^[1-9]\\d{5}[1-9]\\d{3}((0[1-9])|(1[0-2]))(0[1-9]|([1|2][0-9])|3[0-1])((\\d{4})|\\d{3}X)$"; if (StringUtils.isNotBlank(tbPeople.getIdCard())) { - if (!Pattern.matches(CREDENTIALS_CODE_PATTERN, tbPeople.getIdCard())) { + if (!Pattern.matches(Constants.CREDENTIALS_CODE_PATTERN, tbPeople.getIdCard())) { return AjaxResult.error(ExceptionEnum.INVALID_ID_CARD_FORMAT.getCode(), ExceptionEnum.INVALID_ID_CARD_FORMAT.getMsg()); } } @@ -151,9 +139,8 @@ public class TbPeopleServiceImpl implements TbPeopleService { return AjaxResult.error(ExceptionEnum.INVALID_PHONE_NUMBER_FORMAT.getCode(), ExceptionEnum.INVALID_PHONE_NUMBER_FORMAT.getMsg()); } //校验前端传入的身份证号 - String CREDENTIALS_CODE_PATTERN = "^[1-9]\\d{5}[1-9]\\d{3}((0[1-9])|(1[0-2]))(0[1-9]|([1|2][0-9])|3[0-1])((\\d{4})|\\d{3}X)$"; if (StringUtils.isNotBlank(tbPeople.getIdCard())) { - if (!Pattern.matches(CREDENTIALS_CODE_PATTERN, tbPeople.getIdCard())) { + if (!Pattern.matches(Constants.CREDENTIALS_CODE_PATTERN, tbPeople.getIdCard())) { return AjaxResult.error(ExceptionEnum.INVALID_ID_CARD_FORMAT.getCode(), ExceptionEnum.INVALID_ID_CARD_FORMAT.getMsg()); } } @@ -282,7 +269,7 @@ public class TbPeopleServiceImpl implements TbPeopleService { * @return */ @Override - public AjaxResult importTbProPower(MultipartFile file) { + public AjaxResult importTbPeople(MultipartFile file) { String fileName = file.getOriginalFilename(); if (fileName != null) { String fileExtension = fileName.substring(fileName.lastIndexOf(".") + 1); @@ -294,18 +281,15 @@ public class TbPeopleServiceImpl implements TbPeopleService { try { InputStream inputStream = file.getInputStream(); Workbook workbook = new XSSFWorkbook(inputStream); - Sheet sheet = workbook.getSheetAt(0); // 得到Excel的行数 int totalRows = sheet.getPhysicalNumberOfRows(); - // 检查是否有行数 - if (totalRows <= 0) { + if (totalRows <= 1) { throw new IllegalArgumentException("Excel文件中没有数据,请检查后重新导入"); } // 读取第一行表头 Row headerRow = sheet.getRow(0); - if (headerRow == null) { throw new IllegalArgumentException("文件中没有表头"); } @@ -316,37 +300,25 @@ public class TbPeopleServiceImpl implements TbPeopleService { throw new IllegalArgumentException("表头列数与预期不符,请检查导入模板"); } // 读取表头内容并验证每一列 - for (int cellNum = 0; cellNum < totalCells; cellNum++) { - Cell cell = headerRow.getCell(cellNum); - // 获取单元格内容并去除首尾空格 - String headerValue = cell.getStringCellValue().trim(); - // 根据列索引进行验证 - switch (cellNum) { - case 0: - if (!"杆塔名称".equals(headerValue)) { - throw new IllegalArgumentException("第 " + (cellNum + 1) + " 列表头列名与预期不符,请检查导入模板"); - } - break; - case 1: - if (!"杆塔经度".equals(headerValue)) { - throw new IllegalArgumentException("第 " + (cellNum + 1) + " 列表头列名与预期不符,请检查导入模板"); - } - break; - case 2: - if (!"杆塔纬度".equals(headerValue)) { - throw new IllegalArgumentException("第 " + (cellNum + 1) + " 列表头列名与预期不符,请检查导入模板"); - } - break; - default: - break; - } - } + extracted(headerRow, totalCells); + //读取Excel表格数据,做非空及格式判断 + extractedCell(sheet, totalRows, totalCells); ExcelUtil util = new ExcelUtil<>(TbPeople.class); - List tbPeopleList = util.importExcel(file.getInputStream()); + List tbPeopleList = util.importExcel(inputStream); int result = 0; for (TbPeople tbPeople : tbPeopleList) { - tbPeople.setCreateUser(SecurityUtils.getUserId()); - result += tbPeopleDao.insertOrUpdate(tbPeople); + TbPeople people = tbPeopleDao.queryByName(tbPeople); + if (people != null) { + //进行更新操作 + tbPeople.setId(people.getId()); + tbPeople.setUpdateUser(SecurityUtils.getUserId()); + tbPeople.setDelFlag(0); + result += tbPeopleDao.update(tbPeople); + } else { + //新增操作 + tbPeople.setCreateUser(SecurityUtils.getUserId()); + result += tbPeopleDao.insert(tbPeople); + } } if (result > 0) { return AjaxResult.success(ExceptionEnum.SUCCESS.getMsg(), result); @@ -356,4 +328,146 @@ public class TbPeopleServiceImpl implements TbPeopleService { } return AjaxResult.error(ExceptionEnum.SAVE_TO_DATABASE.getCode(), ExceptionEnum.SAVE_TO_DATABASE.getMsg()); } + + /** + * 读取Excel表格数据,做非空判断 + * @param sheet + * @param totalRows + * @param totalCells + */ + private void extractedCell(Sheet sheet, int totalRows, int totalCells) { + //读取Excel表格数据,做非空判断 + // 循环Excel行数 + DataFormatter dataFormatter = new DataFormatter(); + for (int r = 1; r < totalRows; r++) { + Row row = sheet.getRow(r); + // 循环Excel列数 + for (int c = 0; c < totalCells; c++) { + Cell cell = row.getCell(c); + String cellValue = dataFormatter.formatCellValue(row.getCell(c)); + switch (c) { + case 0: + case 2: + checkBlank(cell, r, c); + break; + case 1: + checkBlank(cell, r, c); + checkGender(cellValue, r, c); + break; + case 3: + checkBlank(cell, r, c); + checkCredentialsCode(cellValue, r, c); + break; + case 4: + checkBlank(cell, r, c); + checkPhone(cellValue, r, c); + break; + default: + throw new IllegalArgumentException( + String.format("第 %d 行,第 %d 列超出范围,请检查后重新导入", r + 1, c + 1)); + } + } + } + } + + /** + * 读取Excel表头模板方法抽取 + * @param headerRow + * @param totalCells + */ + private void extracted(Row headerRow, int totalCells) { + for (int cellNum = 0; cellNum < totalCells; cellNum++) { + Cell cell = headerRow.getCell(cellNum); + // 获取单元格内容并去除首尾空格 + String headerValue = cell.getStringCellValue().trim(); + // 根据列索引进行验证 + switch (cellNum) { + case 0: + if (!"姓名".equals(headerValue)) { + throw new IllegalArgumentException("第 " + (cellNum + 1) + " 列表头列名与预期不符,请检查导入模板"); + } + break; + case 1: + if (!"性别(0 女 1 男)".equals(headerValue)) { + throw new IllegalArgumentException("第 " + (cellNum + 1) + " 列表头列名与预期不符,请检查导入模板"); + } + break; + case 2: + if (!"岗位工种".equals(headerValue)) { + throw new IllegalArgumentException("第 " + (cellNum + 1) + " 列表头列名与预期不符,请检查导入模板"); + } + break; + case 3: + if (!"身份证号码".equals(headerValue)) { + throw new IllegalArgumentException("第 " + (cellNum + 1) + " 列表头列名与预期不符,请检查导入模板"); + } + break; + case 4: + if (!"电话".equals(headerValue)) { + throw new IllegalArgumentException("第 " + (cellNum + 1) + " 列表头列名与预期不符,请检查导入模板"); + } + break; + default: + break; + } + } + } + + /** + * 检查数据是否为空 + * @param cell + * @param rowIndex + * @param colIndex + */ + private void checkBlank(Cell cell, int rowIndex, int colIndex) { + if (cell == null) { + throw new IllegalArgumentException( + String.format("第 %d 行,第 %d 列数据为空,请检查后重新导入", rowIndex + 1, colIndex + 1)); + } + } + + /** + * 检查性别是否合法 + * @param cellValue + * @param rowIndex + * @param colIndex + */ + private void checkGender(String cellValue, int rowIndex, int colIndex) { + try { + Integer gender = Integer.parseInt(cellValue); + if (gender != 0 && gender != 1) { + throw new IllegalArgumentException( + String.format("第 %d 行,第 %d 列性别格式不正确,请检查后重新导入", rowIndex + 1, colIndex + 1)); + } + } catch (NumberFormatException e) { + throw new IllegalArgumentException( + String.format("第 %d 行,第 %d 列性别格式不正确,请检查后重新导入", rowIndex + 1, colIndex + 1)); + } + } + + /** + * 检查身份证号码格式 + * @param cellValue + * @param rowIndex + * @param colIndex + */ + private void checkCredentialsCode(String cellValue, int rowIndex, int colIndex) { + if (!Pattern.matches(Constants.CREDENTIALS_CODE_PATTERN, cellValue)) { + throw new IllegalArgumentException( + String.format("第 %d 行,第 %d 列身份证号码格式不正确,请检查后重新导入", rowIndex + 1, colIndex + 1)); + } + } + + /** + * 检查电话号码格式 + * @param cellValue + * @param rowIndex + * @param colIndex + */ + private void checkPhone(String cellValue, int rowIndex, int colIndex) { + if (!PhoneUtil.isMobile(cellValue)) { + throw new IllegalArgumentException( + String.format("第 %d 行,第 %d 列电话号码格式不正确,请检查后重新导入", rowIndex + 1, colIndex + 1)); + } + } } diff --git a/bonus-modules/bonus-base/src/main/java/com/bonus/base/service/impl/TbProPowerServiceImpl.java b/bonus-modules/bonus-base/src/main/java/com/bonus/base/service/impl/TbProPowerServiceImpl.java index ea2186e..2384d38 100644 --- a/bonus-modules/bonus-base/src/main/java/com/bonus/base/service/impl/TbProPowerServiceImpl.java +++ b/bonus-modules/bonus-base/src/main/java/com/bonus/base/service/impl/TbProPowerServiceImpl.java @@ -12,10 +12,7 @@ import com.bonus.common.core.utils.poi.ExcelUtil; import com.bonus.common.core.web.domain.AjaxResult; import lombok.extern.slf4j.Slf4j; import org.apache.commons.io.IOUtils; -import org.apache.poi.ss.usermodel.Cell; -import org.apache.poi.ss.usermodel.Row; -import org.apache.poi.ss.usermodel.Sheet; -import org.apache.poi.ss.usermodel.Workbook; +import org.apache.poi.ss.usermodel.*; import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org.springframework.stereotype.Service; import org.springframework.web.multipart.MultipartFile; @@ -149,7 +146,7 @@ public class TbProPowerServiceImpl implements TbProPowerService { int totalRows = sheet.getPhysicalNumberOfRows(); // 检查是否有行数 - if (totalRows <= 0) { + if (totalRows <= 1) { throw new IllegalArgumentException("Excel文件中没有数据,请检查后重新导入"); } // 读取第一行表头 @@ -164,7 +161,7 @@ public class TbProPowerServiceImpl implements TbProPowerService { if (totalCells != 3) { throw new IllegalArgumentException("表头列数与预期不符,请检查导入模板"); } - // 读取表头内容并验证每一列 + // 读取表头内容并验证每一列,看是否符合模版要求 for (int cellNum = 0; cellNum < totalCells; cellNum++) { Cell cell = headerRow.getCell(cellNum); // 获取单元格内容并去除首尾空格 @@ -190,6 +187,16 @@ public class TbProPowerServiceImpl implements TbProPowerService { break; } } + //读取Excel表格数据,做非空判断 + // 循环Excel行数 + for (int r = 1; r < totalRows; r++) { + Row row = sheet.getRow(r); + // 循环Excel列数 + for (int c = 0; c < totalCells; c++) { + Cell cell = row.getCell(c); + checkCellNotEmpty(cell, r + 1, c + 1); + } + } ExcelUtil util = new ExcelUtil<>(TbProPower.class); List tbProPowerList = util.importExcel(file.getInputStream()); int result = 0; @@ -200,6 +207,7 @@ public class TbProPowerServiceImpl implements TbProPowerService { if (power != null) { //进行更新操作 tbProPower.setId(power.getId()); + tbProPower.setDelFlag(0); result += tbProPowerDao.update(tbProPower); } else { result += tbProPowerDao.insert(tbProPower); @@ -214,6 +222,18 @@ public class TbProPowerServiceImpl implements TbProPowerService { return AjaxResult.error(ExceptionEnum.SAVE_TO_DATABASE.getCode(), ExceptionEnum.SAVE_TO_DATABASE.getMsg()); } + /** + * 提取方法用于检查单元格内容是否为空,并抛出异常 + * @param cell + * @param rowNum + * @param colNum + */ + private void checkCellNotEmpty(Cell cell, int rowNum, int colNum) { + if (cell == null) { + throw new IllegalArgumentException("Excel中第 " + rowNum + " 行第 " + colNum + " 列数据为空,请检查后重新导入"); + } + } + /** * 导入模版下载 * @param response diff --git a/bonus-modules/bonus-base/src/main/java/com/bonus/base/service/impl/TbTeamServiceImpl.java b/bonus-modules/bonus-base/src/main/java/com/bonus/base/service/impl/TbTeamServiceImpl.java index 118d12c..f6aa4b2 100644 --- a/bonus-modules/bonus-base/src/main/java/com/bonus/base/service/impl/TbTeamServiceImpl.java +++ b/bonus-modules/bonus-base/src/main/java/com/bonus/base/service/impl/TbTeamServiceImpl.java @@ -1,12 +1,17 @@ package com.bonus.base.service.impl; import com.alibaba.nacos.common.utils.CollectionUtils; +import com.bonus.base.config.Constants; import com.bonus.base.config.ExceptionEnum; import com.bonus.base.domain.TbPeople; +import com.bonus.base.domain.TbProject; import com.bonus.base.domain.TbTeam; +import com.bonus.base.mapper.TbPeopleMapper; +import com.bonus.base.mapper.TbProjectMapper; import com.bonus.base.mapper.TbTeamMapper; import com.bonus.base.service.TbTeamService; import com.bonus.base.vo.TbDeviceVo; +import com.bonus.base.vo.TbProjectVo; import com.bonus.common.core.utils.StringUtils; import com.bonus.common.core.utils.encryption.Sm4Utils; import com.bonus.common.core.web.domain.AjaxResult; @@ -15,6 +20,8 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; +import java.sql.*; +import java.util.ArrayList; import java.util.List; /** @@ -28,6 +35,12 @@ public class TbTeamServiceImpl implements TbTeamService { @Resource private TbTeamMapper tbTeamDao; + @Resource + private TbPeopleMapper tbPeopleMapper; + + @Resource + private TbProjectMapper tbProjectMapper; + /** * 通过ID查询单条数据 * @@ -36,7 +49,6 @@ public class TbTeamServiceImpl implements TbTeamService { */ @Override public List queryById(Long id) { - //TbTeam tbTeam = tbTeamDao.queryById(id); List list = tbTeamDao.selectList(id); if (CollectionUtils.isNotEmpty(list)) { list.forEach(tbPeople -> { @@ -219,4 +231,70 @@ public class TbTeamServiceImpl implements TbTeamService { public List selectDeviceList(TbDeviceVo tbDeviceVo) { return tbTeamDao.selectDeviceList(tbDeviceVo); } + + /** + * 从北京电科院数据库获取班组列表 + * @return + */ + @Override + public List getList() { + String sourceUrl = Constants.SOURCEURL; + String sourceUser = Constants.SOURCEUSER; + String sourcePassword = Constants.SOURCEPASSWORD; + List list = new ArrayList<>(); + try (Connection sourceConn = DriverManager.getConnection(sourceUrl, sourceUser, sourcePassword); + Statement selectStmt = sourceConn.createStatement()) { + + String selectQuery = "SELECT t1.working_team_name as teamName,t3.gender as sex,t3.id_card as idCard, " + + "t3.real_name as relName,t3.mobile as relPhone,t4.single_project_name as proName " + + "FROM dky_get_working_team t1 " + + "LEFT JOIN dky_get_working_team_member t2 ON t1.id = t2.team_id " + + "and t2.delete_flag = 0 and t2.position_code = 0900101 " + + "LEFT JOIN dky_get_personnel t3 ON t2.personnel_id = t3.id and t3.delete_flag = 0 " + + "LEFT JOIN dky_get_single_project t4 ON t1.single_project_code = t4.single_project_code and t4.delete_flag = 0 " + + "WHERE t1.delete_flag = 0"; + + try (ResultSet rs = selectStmt.executeQuery(selectQuery)) { + while (rs.next()) { + String teamName = rs.getString("teamName"); + String sex = rs.getString("sex"); + String relName = rs.getString("relName"); + String relPhone = rs.getString("relPhone"); + String proName = rs.getString("proName"); + String idCard = rs.getString("idCard"); + TbTeam tbTeam = new TbTeam(); + if (StringUtils.isBlank(teamName)) { + if (StringUtils.isNotBlank(relName)) { + //根据姓名去我们数据库查询,看是否存在此人员信息 + TbPeople people = new TbPeople(); + people.setRelName(relName); + people.setIdCard(idCard); + TbPeople tbPeople = tbPeopleMapper.queryByName(people); + if (tbPeople != null) { + tbTeam.setRelId(tbPeople.getId()); + tbTeam.setRelName(relName); + tbTeam.setRelPhone(tbPeople.getRelPhone()); + } + } + if (StringUtils.isNotBlank(proName)) { + //根据名称去查询 + TbProject tbProject = new TbProject(); + tbProject.setProName(proName); + TbProjectVo tbProjectVo = tbProjectMapper.selectByName(tbProject); + if (tbProjectVo != null) { + tbTeam.setProId(String.valueOf(tbProjectVo.getId())); + tbTeam.setProName(tbProjectVo.getProName()); + } + } + list.add(tbTeam); + } + } + } catch (SQLException e) { + throw new RuntimeException("Failed to execute SQL query", e); + } + } catch (SQLException e) { + throw new RuntimeException("Failed to connect to database", e); + } + return list; + } } diff --git a/bonus-modules/bonus-base/src/main/java/com/bonus/base/service/impl/TbWarnConfigServiceImpl.java b/bonus-modules/bonus-base/src/main/java/com/bonus/base/service/impl/TbWarnConfigServiceImpl.java index 53d210b..93e856f 100644 --- a/bonus-modules/bonus-base/src/main/java/com/bonus/base/service/impl/TbWarnConfigServiceImpl.java +++ b/bonus-modules/bonus-base/src/main/java/com/bonus/base/service/impl/TbWarnConfigServiceImpl.java @@ -1,6 +1,9 @@ package com.bonus.base.service.impl; +import com.bonus.base.config.ExceptionEnum; import com.bonus.base.domain.TbWarnConfig; +import com.bonus.common.core.web.domain.AjaxResult; +import com.bonus.common.security.utils.SecurityUtils; import org.springframework.stereotype.Service; import org.springframework.beans.factory.annotation.Autowired; @@ -22,8 +25,12 @@ public class TbWarnConfigServiceImpl implements TbWarnConfigService{ private TbWarnConfigMapper tbWarnConfigMapper; @Override - public int deleteByPrimaryKey(Long id) { - return tbWarnConfigMapper.deleteByPrimaryKey(id); + public AjaxResult deleteByPrimaryKey(Long id) { + int result = tbWarnConfigMapper.deleteByPrimaryKey(id); + if (result > 0) { + return AjaxResult.success(ExceptionEnum.SUCCESS.getMsg(), result); + } + return AjaxResult.error(ExceptionEnum.DELETE_TO_DATABASE.getCode(), ExceptionEnum.DELETE_TO_DATABASE.getMsg()); } @Override @@ -37,8 +44,21 @@ public class TbWarnConfigServiceImpl implements TbWarnConfigService{ } @Override - public int insertSelective(TbWarnConfig record) { - return tbWarnConfigMapper.insertSelective(record); + public AjaxResult insertSelective(TbWarnConfig record) { + if (record == null || record.getConfigName() == null || record.getConfiguType() == null) { + return AjaxResult.error(ExceptionEnum.TO_PARAM_NULL.getCode(), ExceptionEnum.TO_PARAM_NULL.getMsg()); + } + //根据同类型,同名称规则判重 + TbWarnConfig tbWarnConfig = tbWarnConfigMapper.selectByName(record); + if (tbWarnConfig != null) { + return AjaxResult.error(ExceptionEnum.NAME_DUPLICATE.getCode(), ExceptionEnum.NAME_DUPLICATE.getMsg()); + } + record.setCreateUser(SecurityUtils.getUserId().intValue()); + int result = tbWarnConfigMapper.insertSelective(record); + if (result > 0) { + return AjaxResult.success(ExceptionEnum.SUCCESS.getMsg(), result); + } + return AjaxResult.error(ExceptionEnum.SAVE_TO_DATABASE.getCode(), ExceptionEnum.SAVE_TO_DATABASE.getMsg()); } @Override @@ -47,8 +67,21 @@ public class TbWarnConfigServiceImpl implements TbWarnConfigService{ } @Override - public int updateByPrimaryKeySelective(TbWarnConfig record) { - return tbWarnConfigMapper.updateByPrimaryKeySelective(record); + public AjaxResult updateByPrimaryKeySelective(TbWarnConfig record) { + if (record == null || record.getConfigName() == null || record.getConfiguType() == null) { + return AjaxResult.error(ExceptionEnum.TO_PARAM_NULL.getCode(), ExceptionEnum.TO_PARAM_NULL.getMsg()); + } + //根据同类型,同名称规则判重 + TbWarnConfig tbWarnConfig = tbWarnConfigMapper.selectByName(record); + if (tbWarnConfig != null && !tbWarnConfig.getId().equals(record.getId())) { + return AjaxResult.error(ExceptionEnum.NAME_DUPLICATE.getCode(), ExceptionEnum.NAME_DUPLICATE.getMsg()); + } + record.setUpdateUser(SecurityUtils.getUserId().intValue()); + int result = tbWarnConfigMapper.updateByPrimaryKeySelective(record); + if (result > 0) { + return AjaxResult.success(ExceptionEnum.SUCCESS.getMsg(), result); + } + return AjaxResult.error(ExceptionEnum.UPDATE_TO_DATABASE.getCode(), ExceptionEnum.UPDATE_TO_DATABASE.getMsg()); } @Override @@ -63,10 +96,29 @@ public class TbWarnConfigServiceImpl implements TbWarnConfigService{ @Override public List getAll(TbWarnConfig record){ - return tbWarnConfigMapper.getAll(record); - } - - - - + List list = tbWarnConfigMapper.getAll(record); + if (list != null && list.size() > 0) { + for (TbWarnConfig tbWarnConfig : list) { + if (tbWarnConfig.getConfigVal1Min() != null && tbWarnConfig.getConfigVal1Max() != null) { + tbWarnConfig.setConfigVal1Str(tbWarnConfig.getConfigVal1Min() + "~" + tbWarnConfig.getConfigVal1Max()); + } + if (tbWarnConfig.getConfigVal2Min() != null && tbWarnConfig.getConfigVal2Max() != null) { + tbWarnConfig.setConfigVal2Str(tbWarnConfig.getConfigVal2Min() + "~" + tbWarnConfig.getConfigVal2Max()); + } + if (tbWarnConfig.getConfigVal3Min() != null && tbWarnConfig.getConfigVal3Max() != null) { + tbWarnConfig.setConfigVal3Str(tbWarnConfig.getConfigVal3Min() + "~" + tbWarnConfig.getConfigVal3Max()); + } + if (tbWarnConfig.getConfigVal4Min() != null && tbWarnConfig.getConfigVal4Max() != null) { + tbWarnConfig.setConfigVal4Str(tbWarnConfig.getConfigVal4Min() + "~" + tbWarnConfig.getConfigVal4Max()); + } + if (tbWarnConfig.getConfigVal5Min() != null && tbWarnConfig.getConfigVal5Max() != null) { + tbWarnConfig.setConfigVal5Str(tbWarnConfig.getConfigVal5Min() + "~" + tbWarnConfig.getConfigVal5Max()); + } + if (tbWarnConfig.getConfigVal6Min() != null && tbWarnConfig.getConfigVal6Max() != null) { + tbWarnConfig.setConfigVal6Str(tbWarnConfig.getConfigVal6Min() + "~" + tbWarnConfig.getConfigVal6Max()); + } + } + } + return list; + } } diff --git a/bonus-modules/bonus-base/src/main/resources/mapper/base/TbBdDeviceRecordMapper.xml b/bonus-modules/bonus-base/src/main/resources/mapper/base/TbBdDeviceRecordMapper.xml index 5b8082b..aabe091 100644 --- a/bonus-modules/bonus-base/src/main/resources/mapper/base/TbBdDeviceRecordMapper.xml +++ b/bonus-modules/bonus-base/src/main/resources/mapper/base/TbBdDeviceRecordMapper.xml @@ -24,17 +24,19 @@ from tb_bd_device_record where id = #{id,jdbcType=BIGINT} + delete from tb_bd_device_record where id = #{id,jdbcType=BIGINT} + - insert into tb_bd_device_record (id, record_id, dev_name, + insert into tb_bd_device_record (record_id, dev_name, dev_code, unit_name, area_name, dev_user, dev_user_phone) - values (#{id,jdbcType=BIGINT}, #{recordId,jdbcType=BIGINT}, #{devName,jdbcType=VARCHAR}, + values (#{recordId,jdbcType=BIGINT}, #{devName,jdbcType=VARCHAR}, #{devCode,jdbcType=VARCHAR}, #{unitName,jdbcType=VARCHAR}, #{areaName,jdbcType=VARCHAR}, #{devUser,jdbcType=VARCHAR}, #{devUserPhone,jdbcType=VARCHAR}) @@ -179,6 +181,12 @@ #{item.id,jdbcType=BIGINT} + + + update tb_bd_device_record + set record_id = null + where record_id = #{id} + delete from tb_bd_device_record where id in @@ -187,9 +195,28 @@ + + + \ No newline at end of file diff --git a/bonus-modules/bonus-base/src/main/resources/mapper/base/TbBdRecordMapper.xml b/bonus-modules/bonus-base/src/main/resources/mapper/base/TbBdRecordMapper.xml index 82897bd..794330c 100644 --- a/bonus-modules/bonus-base/src/main/resources/mapper/base/TbBdRecordMapper.xml +++ b/bonus-modules/bonus-base/src/main/resources/mapper/base/TbBdRecordMapper.xml @@ -34,9 +34,50 @@ where id = #{id,jdbcType=BIGINT} + + + + - update tb_bd_record set del_flag = 1 - where id = #{id,jdbcType=BIGINT} + + update tb_bd_record + set del_flag = 1 + where id = #{id} @@ -49,18 +90,15 @@ audit_time) values (#{id,jdbcType=BIGINT}, #{departId,jdbcType=BIGINT}, #{departName,jdbcType=VARCHAR}, #{proId,jdbcType=BIGINT}, #{proName,jdbcType=VARCHAR}, #{relUser,jdbcType=VARCHAR}, - #{relPhone,jdbcType=VARCHAR}, 0, #{auditStatus,jdbcType=INTEGER}, + #{relPhone,jdbcType=VARCHAR}, #{delFlag,jdbcType=INTEGER}, #{auditStatus,jdbcType=INTEGER}, #{remarks,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, #{createUser,jdbcType=BIGINT}, #{updateTime,jdbcType=TIMESTAMP}, #{updateUser,jdbcType=BIGINT}, #{auditUser,jdbcType=BIGINT}, #{auditTime,jdbcType=TIMESTAMP}) - + insert into tb_bd_record - - id, - depart_id, @@ -79,18 +117,14 @@ rel_phone, - del_flag, - audit_status, remarks, - create_time, - create_user, @@ -108,9 +142,6 @@ - - #{id,jdbcType=BIGINT}, - #{departId,jdbcType=BIGINT}, @@ -129,18 +160,14 @@ #{relPhone,jdbcType=VARCHAR}, - - 0, - + 0, #{auditStatus,jdbcType=INTEGER}, #{remarks,jdbcType=VARCHAR}, - - #{createTime,jdbcType=TIMESTAMP}, - + NOW(), #{createUser,jdbcType=BIGINT}, @@ -158,6 +185,7 @@ + update tb_bd_record @@ -189,15 +217,7 @@ remarks = #{remarks,jdbcType=VARCHAR}, - - create_time = #{createTime,jdbcType=TIMESTAMP}, - - - create_user = #{createUser,jdbcType=BIGINT}, - - - update_time = #{updateTime,jdbcType=TIMESTAMP}, - + update_time = NOW(), update_user = #{updateUser,jdbcType=BIGINT}, @@ -323,11 +343,5 @@ - - + \ No newline at end of file diff --git a/bonus-modules/bonus-base/src/main/resources/mapper/base/TbDeviceMapper.xml b/bonus-modules/bonus-base/src/main/resources/mapper/base/TbDeviceMapper.xml index bed6bd8..1183e30 100644 --- a/bonus-modules/bonus-base/src/main/resources/mapper/base/TbDeviceMapper.xml +++ b/bonus-modules/bonus-base/src/main/resources/mapper/base/TbDeviceMapper.xml @@ -70,9 +70,7 @@ dev_warn, - del_flag, - logo_url, @@ -102,9 +100,7 @@ #{devWarn,jdbcType=INTEGER}, - - #{delFlag,jdbcType=INTEGER}, - + 0, #{logoUrl,jdbcType=VARCHAR}, @@ -165,6 +161,9 @@ from tb_device where del_flag = 0 + update tb_device diff --git a/bonus-modules/bonus-base/src/main/resources/mapper/base/TbPeopleMapper.xml b/bonus-modules/bonus-base/src/main/resources/mapper/base/TbPeopleMapper.xml index eb84824..87551e7 100644 --- a/bonus-modules/bonus-base/src/main/resources/mapper/base/TbPeopleMapper.xml +++ b/bonus-modules/bonus-base/src/main/resources/mapper/base/TbPeopleMapper.xml @@ -99,40 +99,6 @@ - - INSERT INTO tb_people - - team_id, - rel_name, - rel_phone, - id_card, - post_code, - sex, - create_user, - create_time, - del_flag - - - #{teamId}, - #{relName}, - #{relPhone}, - #{idCard}, - #{postCode}, - #{sex}, - #{createUser}, - NOW(), - 0 - - ON DUPLICATE KEY UPDATE - team_id = VALUES(team_id), - rel_phone = VALUES(rel_phone), - post_code = VALUES(post_code), - sex = VALUES(sex), - create_user = VALUES(create_user), - create_time = NOW(), - del_flag = 0 - - update tb_people diff --git a/bonus-modules/bonus-base/src/main/resources/mapper/base/TbProDepartMapper.xml b/bonus-modules/bonus-base/src/main/resources/mapper/base/TbProDepartMapper.xml index c679f24..0fdf823 100644 --- a/bonus-modules/bonus-base/src/main/resources/mapper/base/TbProDepartMapper.xml +++ b/bonus-modules/bonus-base/src/main/resources/mapper/base/TbProDepartMapper.xml @@ -53,6 +53,7 @@ where del_flag = '0' and tpd.id = #{id} + + + + + - INSERT INTO tb_pro_power diff --git a/bonus-modules/bonus-base/src/main/resources/mapper/base/TbWarnConfigMapper.xml b/bonus-modules/bonus-base/src/main/resources/mapper/base/TbWarnConfigMapper.xml index c0f7c2f..7bfcda8 100644 --- a/bonus-modules/bonus-base/src/main/resources/mapper/base/TbWarnConfigMapper.xml +++ b/bonus-modules/bonus-base/src/main/resources/mapper/base/TbWarnConfigMapper.xml @@ -25,19 +25,37 @@ + - id, configu_type, config_name, config_val1_max, config_val1_min, config_val2_max, - config_val2_min, config_val3_max, config_val3_min, config_val4_max, config_val4_min, - config_val5_max, config_val5_min, config_val6_max, config_val6_min, del_flag, create_time, - create_user, update_time, update_user + twc.id, + twc.configu_type, + sda.dict_label as typeName, + twc.config_name, + twc.config_val1_max, + twc.config_val1_min, + twc.config_val2_max, + twc.config_val2_min, + twc.config_val3_max, + twc.config_val3_min, + twc.config_val4_max, + twc.config_val4_min, + twc.config_val5_max, + twc.config_val5_min, + twc.config_val6_max, + twc.config_val6_min + @@ -66,9 +84,6 @@ insert into tb_warn_config - - id, - configu_type, @@ -111,26 +126,13 @@ config_val6_min, - del_flag, - - create_time, - create_user, - - update_time, - - - update_user, - - - #{id,jdbcType=BIGINT}, - #{configuType,jdbcType=INTEGER}, @@ -173,21 +175,11 @@ #{configVal6Min,jdbcType=DECIMAL}, - - #{delFlag,jdbcType=INTEGER}, - - - #{createTime,jdbcType=TIMESTAMP}, - + 0, + NOW(), #{createUser,jdbcType=INTEGER}, - - #{updateTime,jdbcType=TIMESTAMP}, - - - #{updateUser,jdbcType=INTEGER}, - @@ -239,21 +231,14 @@ del_flag = #{delFlag,jdbcType=INTEGER}, - - create_time = #{createTime,jdbcType=TIMESTAMP}, - - - create_user = #{createUser,jdbcType=INTEGER}, - - - update_time = #{updateTime,jdbcType=TIMESTAMP}, - + update_time = NOW(), update_user = #{updateUser,jdbcType=INTEGER}, where id = #{id,jdbcType=BIGINT} + update tb_warn_config @@ -394,10 +379,37 @@ - + select * from tb_warn_config where config_name = #{configName} and del_flag = 0 and configu_type = #{configuType} + + + \ No newline at end of file diff --git a/bonus-modules/bonus-base/src/main/resources/template/TbPeopleTemplate.xlsx b/bonus-modules/bonus-base/src/main/resources/template/TbPeopleTemplate.xlsx index e18c37f..9e5035b 100644 Binary files a/bonus-modules/bonus-base/src/main/resources/template/TbPeopleTemplate.xlsx and b/bonus-modules/bonus-base/src/main/resources/template/TbPeopleTemplate.xlsx differ diff --git a/bonus-modules/bonus-base/src/main/resources/template/TbProPowerTemplate.xlsx b/bonus-modules/bonus-base/src/main/resources/template/TbProPowerTemplate.xlsx index 7208abc..d4e1f3a 100644 Binary files a/bonus-modules/bonus-base/src/main/resources/template/TbProPowerTemplate.xlsx and b/bonus-modules/bonus-base/src/main/resources/template/TbProPowerTemplate.xlsx differ