Merge remote-tracking branch 'origin/master'

# Conflicts:
#	bonus-modules/bonus-base/src/main/resources/mapper/base/TbBdDeviceRecordMapper.xml
#	bonus-modules/bonus-base/src/main/resources/mapper/base/TbBdRecordMapper.xml
This commit is contained in:
syruan 2024-09-18 09:31:11 +08:00
commit 106f730d5e
35 changed files with 781 additions and 246 deletions

View File

@ -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)$";
/**
* 登录失败状态

View File

@ -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);
}

View File

@ -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);
}

View File

@ -144,7 +144,7 @@ public class TbPeopleController extends BaseController {
@PostMapping("/importData")
public AjaxResult importData(MultipartFile file)
{
return tbPeopleService.importTbProPower(file);
return tbPeopleService.importTbPeople(file);
}
/**

View File

@ -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;

View File

@ -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<TbTeam> list = tbTeamService.getList();
return AjaxResult.success(list);
}
}

View File

@ -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);
}
}

View File

@ -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<TbBdDeviceRecord> recordList;
private static final long serialVersionUID = 1L;
}

View File

@ -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;
/**
* 是否删除
*/

View File

@ -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;
/**
* 删除状态
*/

View File

@ -31,4 +31,7 @@ public interface TbBdDeviceRecordMapper {
List<TbBdDeviceRecord> getAll(TbBdDeviceRecord record);
int updateById(Long id);
TbBdDeviceRecord selectByName(TbBdDeviceRecord deviceRecord);
}

View File

@ -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<TbBdRecord> getAll(TbBdRecord record);
TbBdRecord selectByName(TbBdRecord record);
}

View File

@ -29,4 +29,11 @@ public interface TbDeviceMapper {
List<TbDevice> getAll(TbDevice record);
int updateBatch(List<TbDevice> list);
/**
* 根据设备编码查询设备信息
* @param record
* @return
*/
TbDevice selectByDevCode(TbDevice record);
}

View File

@ -59,11 +59,5 @@ public interface TbPeopleMapper {
*/
TbPeople queryByName(TbPeople tbPeople);
/**
* 批量新增或按主键更新数据
* @param tbPeople
* @return
*/
int insertOrUpdate(TbPeople tbPeople);
}

View File

@ -33,4 +33,11 @@ public interface TbWarnConfigMapper {
int updateByPrimaryKey(TbWarnConfig record);
int updateBatch(List<TbWarnConfig> list);
/**
* 根据配置名称查询
* @param record
* @return
*/
TbWarnConfig selectByName(TbWarnConfig record);
}

View File

@ -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<Long> list);
int deleteByPrimaryKeyIn(List<Long> 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<TbBdRecord> list);
int updateBatch(List<TbBdRecord> list);
List<TbBdRecord> getAll(TbBdRecord record);
List<TbBdRecord> getAll(TbBdRecord record);
}
/**
* 审核
*
* @param tbBdRecord
* @return
*/
AjaxResult approve(TbBdRecord tbBdRecord);
}

View File

@ -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);

View File

@ -74,5 +74,5 @@ public interface TbPeopleService {
* @param file
* @return
*/
AjaxResult importTbProPower(MultipartFile file);
AjaxResult importTbPeople(MultipartFile file);
}

View File

@ -80,7 +80,15 @@ public interface TbTeamService {
/**
* 智能安全帽列表查询
* @param tbDeviceVo
* @return
*/
List<TbDeviceVo> selectDeviceList(TbDeviceVo tbDeviceVo);
/**
* 从北京电科院数据库获取班组列表
* @return
*/
List<TbTeam> getList();
}

View File

@ -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<Long> 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);

View File

@ -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<TbBdDeviceRecord> 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<TbBdRecord> getAll(TbBdRecord record){
return tbBdRecordMapper.getAll(record);
}
List<TbBdRecord> list = tbBdRecordMapper.getAll(record);
if (list != null && list.size() > 0) {
List<TbBdRecord> 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("审核失败,请联系管理员");
}
}

View File

@ -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

View File

@ -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<TbPeople> util = new ExcelUtil<>(TbPeople.class);
List<TbPeople> tbPeopleList = util.importExcel(file.getInputStream());
List<TbPeople> 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));
}
}
}

View File

@ -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<TbProPower> util = new ExcelUtil<>(TbProPower.class);
List<TbProPower> 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

View File

@ -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<TbPeople> queryById(Long id) {
//TbTeam tbTeam = tbTeamDao.queryById(id);
List<TbPeople> list = tbTeamDao.selectList(id);
if (CollectionUtils.isNotEmpty(list)) {
list.forEach(tbPeople -> {
@ -219,4 +231,70 @@ public class TbTeamServiceImpl implements TbTeamService {
public List<TbDeviceVo> selectDeviceList(TbDeviceVo tbDeviceVo) {
return tbTeamDao.selectDeviceList(tbDeviceVo);
}
/**
* 从北京电科院数据库获取班组列表
* @return
*/
@Override
public List<TbTeam> getList() {
String sourceUrl = Constants.SOURCEURL;
String sourceUser = Constants.SOURCEUSER;
String sourcePassword = Constants.SOURCEPASSWORD;
List<TbTeam> 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;
}
}

View File

@ -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<TbWarnConfig> getAll(TbWarnConfig record){
return tbWarnConfigMapper.getAll(record);
}
List<TbWarnConfig> 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;
}
}

View File

@ -24,17 +24,19 @@
from tb_bd_device_record
where id = #{id,jdbcType=BIGINT}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
<!--@mbg.generated-->
delete from tb_bd_device_record
where id = #{id,jdbcType=BIGINT}
</delete>
<insert id="insert" parameterType="com.bonus.base.domain.TbBdDeviceRecord">
<!--@mbg.generated-->
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})
</insert>
@ -179,6 +181,12 @@
#{item.id,jdbcType=BIGINT}
</foreach>
</update>
<update id="updateById">
<!--@mbg.generated-->
update tb_bd_device_record
set record_id = null
where record_id = #{id}
</update>
<delete id="deleteByPrimaryKeyIn">
<!--@mbg.generated-->
delete from tb_bd_device_record where id in
@ -187,9 +195,28 @@
</foreach>
</delete>
<!--by syruan on 2024-09-11-->
<select id="getAll" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from tb_bd_device_record
select
<include refid="Base_Column_List"/>
from tb_bd_device_record
<where>
<if test="recordId != null">
and record_id = #{recordId}
</if>
</where>
</select>
<select id="selectByName" resultType="com.bonus.base.domain.TbBdDeviceRecord">
select
<include refid="Base_Column_List"/>
from tb_bd_device_record
where
<if test="devName != null and devName != ''">
dev_name = #{devName}
</if>
<if test="devCode != null and devCode != ''">
and dev_code = #{devCode}
</if>
</select>
</mapper>

View File

@ -34,9 +34,50 @@
where id = #{id,jdbcType=BIGINT}
</select>
<select id="getAll" resultType="com.bonus.base.domain.TbBdRecord">
select
tbr.id as id, tbr.depart_id as departId, tbr.depart_name as departName, tbr.pro_id as proId, tbr.pro_name as
proName, tbr.rel_user as relUser, tbr.rel_phone as relPhone, tbr.create_time as createTime,
tbr.audit_status as auditStatus,tbr.remarks as remarks, tbr.audit_user as auditUser, tbr.audit_time as auditTime,
count(tbd.record_id) as bdTotal
from tb_bd_record tbr
left join tb_bd_device_record tbd on tbd.record_id = tbr.id
where del_flag = 0
<if test="departName != null and departName != ''">
and tbr.depart_name like concat('%',#{departName},'%')
</if>
<if test="proName != null and proName != ''">
and tbr.pro_name like concat('%',#{proName},'%')
</if>
<if test="relUser != null and relUser != ''">
and tbr.rel_user like concat('%',#{relUser},'%')
</if>
<if test="auditStatus != null and auditStatus != ''">
and tbr.audit_status = #{auditStatus}
</if>
</select>
<select id="selectByName" resultType="com.bonus.base.domain.TbBdRecord">
select
tbr.id as id, tbr.depart_id as departId, tbr.depart_name as departName, tbr.pro_id as proId, tbr.pro_name as
proName, tbr.rel_user as relUser, tbr.rel_phone as relPhone, tbr.create_time as createTime,
tbr.audit_status as auditStatus,tbr.remarks as remarks, tbr.audit_user as auditUser, tbr.audit_time as auditTime
from tb_bd_record tbr
left join tb_bd_device_record tbd on tbd.record_id = tbr.id
where del_flag = 0
<if test="departId != null">
and tbr.depart_id = #{departId}
</if>
<if test="proId != null">
and tbr.pro_id = #{proId}
</if>
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
update tb_bd_record set del_flag = 1
where id = #{id,jdbcType=BIGINT}
<!--@mbg.generated-->
update tb_bd_record
set del_flag = 1
where id = #{id}
</delete>
<insert id="insert" parameterType="com.bonus.base.domain.TbBdRecord">
@ -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>
<insert id="insertSelective" parameterType="com.bonus.base.domain.TbBdRecord">
<insert id="insertSelective" parameterType="com.bonus.base.domain.TbBdRecord" useGeneratedKeys="true" keyProperty="id">
<!--@mbg.generated-->
insert into tb_bd_record
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="departId != null">
depart_id,
</if>
@ -79,18 +117,14 @@
<if test="relPhone != null and relPhone != ''">
rel_phone,
</if>
<if test="delFlag != null">
del_flag,
</if>
<if test="auditStatus != null">
audit_status,
</if>
<if test="remarks != null and remarks != ''">
remarks,
</if>
<if test="createTime != null">
create_time,
</if>
<if test="createUser != null">
create_user,
</if>
@ -108,9 +142,6 @@
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=BIGINT},
</if>
<if test="departId != null">
#{departId,jdbcType=BIGINT},
</if>
@ -129,18 +160,14 @@
<if test="relPhone != null and relPhone != ''">
#{relPhone,jdbcType=VARCHAR},
</if>
<if test="delFlag != null">
0,
</if>
0,
<if test="auditStatus != null">
#{auditStatus,jdbcType=INTEGER},
</if>
<if test="remarks != null and remarks != ''">
#{remarks,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
#{createTime,jdbcType=TIMESTAMP},
</if>
NOW(),
<if test="createUser != null">
#{createUser,jdbcType=BIGINT},
</if>
@ -158,6 +185,7 @@
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.bonus.base.domain.TbBdRecord">
<!--@mbg.generated-->
update tb_bd_record
@ -189,15 +217,7 @@
<if test="remarks != null and remarks != ''">
remarks = #{remarks,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
<if test="createUser != null">
create_user = #{createUser,jdbcType=BIGINT},
</if>
<if test="updateTime != null">
update_time = #{updateTime,jdbcType=TIMESTAMP},
</if>
update_time = NOW(),
<if test="updateUser != null">
update_user = #{updateUser,jdbcType=BIGINT},
</if>
@ -323,11 +343,5 @@
</foreach>
</delete>
<!--by syruan on 2024-09-11-->
<select id="getAll" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from tb_bd_record
where del_flag = 0 or del_flag is null
</select>
</mapper>

View File

@ -70,9 +70,7 @@
<if test="devWarn != null">
dev_warn,
</if>
<if test="delFlag != null">
del_flag,
</if>
<if test="logoUrl != null and logoUrl != ''">
logo_url,
</if>
@ -102,9 +100,7 @@
<if test="devWarn != null">
#{devWarn,jdbcType=INTEGER},
</if>
<if test="delFlag != null">
#{delFlag,jdbcType=INTEGER},
</if>
0,
<if test="logoUrl != null and logoUrl != ''">
#{logoUrl,jdbcType=VARCHAR},
</if>
@ -165,6 +161,9 @@
from tb_device
where del_flag = 0
</select>
<select id="selectByDevCode" resultType="com.bonus.base.domain.TbDevice">
select * from tb_device where dev_code = #{devCode}
</select>
<update id="updateBatch" parameterType="java.util.List">
<!--@mbg.generated-->
update tb_device

View File

@ -99,40 +99,6 @@
</trim>
</insert>
<insert id="insertOrUpdate">
INSERT INTO tb_people
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="teamId != null and teamId != ''">team_id,</if>
<if test="relName != null and relName != ''">rel_name,</if>
<if test="relPhone != null and relPhone != ''">rel_phone,</if>
<if test="idCard != null and idCard != ''">id_card,</if>
<if test="postCode != null">post_code,</if>
<if test="sex != null">sex,</if>
<if test="createUser != null">create_user,</if>
create_time,
del_flag
</trim>
<trim prefix="VALUES (" suffix=")" suffixOverrides=",">
<if test="teamId != null and teamId != ''">#{teamId},</if>
<if test="relName != null and relName != ''">#{relName},</if>
<if test="relPhone != null and relPhone != ''">#{relPhone},</if>
<if test="idCard != null and idCard != ''">#{idCard},</if>
<if test="postCode != null">#{postCode},</if>
<if test="sex != null">#{sex},</if>
<if test="createUser != null">#{createUser},</if>
NOW(),
0
</trim>
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
</insert>
<!--通过主键修改数据-->
<update id="update">
update tb_people

View File

@ -53,6 +53,7 @@
where del_flag = '0'
and tpd.id = #{id}
</select>
<select id="getAreaList" resultType="com.bonus.base.domain.TbArea">
select id as areaId, area_name as areaName, area_type as areaType, p_id as pId
from tb_area
@ -61,6 +62,7 @@
and area_type = #{areaType}
</if>
</select>
<select id="getDataList" resultType="com.bonus.base.domain.TbData">
select dict_code as dictCode, dict_label as dictLabel, dict_value as dictValue, dict_sort as dictSort, dict_type as
dictType
@ -70,6 +72,7 @@
and dict_type = #{dictType}
</if>
</select>
<select id="selectByName" resultType="com.bonus.base.domain.TbProDepart">
select id as id, depart_name as departName, depart_type as departType, area_id as areaId, head_user as headUser,
head_user_phone as headUserPhone, remarks as remarks, create_time as createTime, create_user as createUser,

View File

@ -7,16 +7,21 @@
tb.id as id, tb.gt_name as gtName, tb.pro_id as proId, tb.lat as lat, tb.lon as lon, tb.del_flag as delFlag
from tb_pro_power tb
where tb.del_flag = '0'
<if test="id != null">
and tb.pro_id = #{proId}
</if>
<if test="gtName != null and gtName != ''">
and tb.gt_name like concat('%',#{gtName},'%')
</if>
</select>
<select id="queryById" resultType="com.bonus.base.domain.TbProPower">
select
id, gt_name, pro_id, lat, lon, del_flag
from tb_pro_power
where id = #{id}
</select>
<select id="selectByName" resultType="com.bonus.base.domain.TbProPower">
select
id, gt_name, pro_id, lat, lon, del_flag
@ -30,7 +35,6 @@
</if>
</select>
<insert id="insert">
INSERT INTO tb_pro_power
<trim prefix="(" suffix=")" suffixOverrides=",">

View File

@ -25,19 +25,37 @@
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
<result column="update_user" jdbcType="INTEGER" property="updateUser" />
</resultMap>
<sql id="Base_Column_List">
<!--@mbg.generated-->
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
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
<!--@mbg.generated-->
select
<include refid="Base_Column_List" />
from tb_warn_config
where id = #{id,jdbcType=BIGINT}
from tb_warn_config twc
left join sys_dict_data sda on twc.configu_type = sda.dict_code
where id = #{id}
<if test="configuType != null and configuType != ''">
and twc.configu_type = #{configuType}
</if>
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
@ -66,9 +84,6 @@
<!--@mbg.generated-->
insert into tb_warn_config
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="configuType != null">
configu_type,
</if>
@ -111,26 +126,13 @@
<if test="configVal6Min != null">
config_val6_min,
</if>
<if test="delFlag != null">
del_flag,
</if>
<if test="createTime != null">
create_time,
</if>
<if test="createUser != null">
create_user,
</if>
<if test="updateTime != null">
update_time,
</if>
<if test="updateUser != null">
update_user,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=BIGINT},
</if>
<if test="configuType != null">
#{configuType,jdbcType=INTEGER},
</if>
@ -173,21 +175,11 @@
<if test="configVal6Min != null">
#{configVal6Min,jdbcType=DECIMAL},
</if>
<if test="delFlag != null">
#{delFlag,jdbcType=INTEGER},
</if>
<if test="createTime != null">
#{createTime,jdbcType=TIMESTAMP},
</if>
0,
NOW(),
<if test="createUser != null">
#{createUser,jdbcType=INTEGER},
</if>
<if test="updateTime != null">
#{updateTime,jdbcType=TIMESTAMP},
</if>
<if test="updateUser != null">
#{updateUser,jdbcType=INTEGER},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.bonus.base.domain.TbWarnConfig">
@ -239,21 +231,14 @@
<if test="delFlag != null">
del_flag = #{delFlag,jdbcType=INTEGER},
</if>
<if test="createTime != null">
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
<if test="createUser != null">
create_user = #{createUser,jdbcType=INTEGER},
</if>
<if test="updateTime != null">
update_time = #{updateTime,jdbcType=TIMESTAMP},
</if>
update_time = NOW(),
<if test="updateUser != null">
update_user = #{updateUser,jdbcType=INTEGER},
</if>
</set>
where id = #{id,jdbcType=BIGINT}
</update>
<update id="updateByPrimaryKey" parameterType="com.bonus.base.domain.TbWarnConfig">
<!--@mbg.generated-->
update tb_warn_config
@ -394,10 +379,37 @@
</delete>
<!--by syruan on 2024-09-10-->
<select id="getAll" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from tb_warn_config
where del_flag = 0
<select id="selectByName" resultType="com.bonus.base.domain.TbWarnConfig">
select * from tb_warn_config where config_name = #{configName} and del_flag = 0 and configu_type = #{configuType}
</select>
<select id="getAll" resultType="com.bonus.base.domain.TbWarnConfig">
select
twc.id as id,
twc.configu_type as configuType,
sda.dict_label as typeName,
twc.config_name as configName,
twc.config_val1_max as configVal1Max,
twc.config_val1_min as configVal1Min,
twc.config_val2_max as configVal2Max,
twc.config_val2_min as configVal2Min,
twc.config_val3_max as configVal3Max,
twc.config_val3_min as configVal3Min,
twc.config_val4_max as configVal4Max,
twc.config_val4_min as configVal4Min,
twc.config_val5_max as configVal5Max,
twc.config_val5_min as configVal5Min,
twc.config_val6_max as configVal6Max,
twc.config_val6_min as configVal6Min
from tb_warn_config twc
left join sys_dict_data sda on twc.configu_type = sda.dict_code
where twc.del_flag = 0
<if test="configuType != null and configuType != ''">
and twc.configu_type = #{configuType}
</if>
<if test="configName != null and configName != ''">
and twc.config_name like concat('%',#{configName},'%')
</if>
</select>
</mapper>