bug优化

This commit is contained in:
mashuai 2024-10-12 15:22:35 +08:00
parent 11181279c1
commit f5bb426c37
8 changed files with 50 additions and 20 deletions

View File

@ -82,5 +82,7 @@ public interface TbProDepartMapper {
* @return * @return
*/ */
int getProPowerListByProId(Long id); int getProPowerListByProId(Long id);
int updateBdRecord(TbProDepart tbProDepart);
} }

View File

@ -101,5 +101,7 @@ public interface TbProjectMapper {
* @return * @return
*/ */
int getList(Long id); int getList(Long id);
int updateBdRecord(TbProject tbProject);
} }

View File

@ -56,21 +56,36 @@ public class TbBdRecordServiceImpl implements TbBdRecordService{
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public AjaxResult insertSelective(TbBdRecord record) { public AjaxResult insertSelective(TbBdRecord record) {
//根据项目部和工程判断同项目部和工程只可接入一次申请 if (record == null || CollectionUtils.isEmpty(record.getRecordList())) {
TbBdRecord tbBdRecord = tbBdRecordMapper.selectByName(record); return AjaxResult.error(1112, "申请边带数量不能为空");
if (tbBdRecord != null){
return AjaxResult.error(1113,"该项目部和工程已申请,请勿重复申请");
} }
int result = 0; 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) { if (record.getRecordList() != null && record.getRecordList().size() > 0) {
// 检查设备名称是否重复
long distinctNames = record.getRecordList().stream().map(TbBdDeviceRecord::getDevName).distinct().count();
if (distinctNames < record.getRecordList().size()) {
return AjaxResult.error(1114,"提交的数据中设备名称存在重复,请勿重复添加");
}
// 检查设备编码是否重复
long distinctCodes = record.getRecordList().stream().map(TbBdDeviceRecord::getDevCode).distinct().count();
if (distinctCodes < record.getRecordList().size()) {
return AjaxResult.error(1114,"提交的数据中设备编码存在重复,请勿重复添加");
}
for (TbBdDeviceRecord bdDeviceRecord : record.getRecordList()) {
//根据设备名称或编码唯一校验
List<TbBdDeviceRecord> tbBdDeviceRecord = tbBdDeviceRecordMapper.selectByName(bdDeviceRecord);
if (CollectionUtils.isNotEmpty(tbBdDeviceRecord)) {
return AjaxResult.error(1113,"设备名称或编码与库中重复,请勿重复添加");
}
}
//返回主键id
//插入前对手机号进行sm4加密
record.setRelPhone(Sm4Utils.encode(record.getRelPhone()));
//初始状态赋值待审核
record.setAuditStatus(0);
record.setCreateUser(SecurityUtils.getUserId());
result += tbBdRecordMapper.insertSelective(record);
for (TbBdDeviceRecord deviceRecord : record.getRecordList()) { for (TbBdDeviceRecord deviceRecord : record.getRecordList()) {
deviceRecord.setRecordId(record.getId()); deviceRecord.setRecordId(record.getId());
deviceRecord.setProId(record.getProId()); deviceRecord.setProId(record.getProId());
@ -80,11 +95,6 @@ public class TbBdRecordServiceImpl implements TbBdRecordService{
} }
deviceRecord.setDevUserPhone(Sm4Utils.encode(deviceRecord.getDevUserPhone())); deviceRecord.setDevUserPhone(Sm4Utils.encode(deviceRecord.getDevUserPhone()));
} }
//根据设备名称或编码唯一校验
List<TbBdDeviceRecord> tbBdDeviceRecord = tbBdDeviceRecordMapper.selectByName(deviceRecord);
if (CollectionUtils.isNotEmpty(tbBdDeviceRecord)) {
return AjaxResult.error(1113,"设备名称或编码与库中重复,请勿重复添加");
}
result += tbBdDeviceRecordMapper.insertSelective(deviceRecord); result += tbBdDeviceRecordMapper.insertSelective(deviceRecord);
} }
} }
@ -107,10 +117,8 @@ public class TbBdRecordServiceImpl implements TbBdRecordService{
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public AjaxResult updateByPrimaryKeySelective(TbBdRecord record) { public AjaxResult updateByPrimaryKeySelective(TbBdRecord record) {
//根据项目部和工程判断同项目部和工程只可接入一次申请 if (record == null || CollectionUtils.isEmpty(record.getRecordList())) {
TbBdRecord tbBdRecord = tbBdRecordMapper.selectByName(record); return AjaxResult.error(1112, "申请边带数量不能为空");
if(tbBdRecord != null && !tbBdRecord.getId().equals(record.getId())){
return AjaxResult.error(1113,"该项目部和工程已申请,请勿重复申请");
} }
//校验内层设备名称或编码重复性 //校验内层设备名称或编码重复性
if (record.getRecordList() != null && record.getRecordList().size() > 0) { if (record.getRecordList() != null && record.getRecordList().size() > 0) {
@ -187,6 +195,7 @@ public class TbBdRecordServiceImpl implements TbBdRecordService{
public AjaxResult approve(TbBdRecord tbBdRecord) { public AjaxResult approve(TbBdRecord tbBdRecord) {
tbBdRecord.setAuditUser(SecurityUtils.getUserId()); tbBdRecord.setAuditUser(SecurityUtils.getUserId());
tbBdRecord.setAuditTime(new Date()); tbBdRecord.setAuditTime(new Date());
tbBdRecord.setRelPhone(Sm4Utils.encode(tbBdRecord.getRelPhone()));
int result = tbBdRecordMapper.updateByPrimaryKeySelective(tbBdRecord); int result = tbBdRecordMapper.updateByPrimaryKeySelective(tbBdRecord);
if (result > 0) { if (result > 0) {
return AjaxResult.success(ExceptionEnum.SUCCESS.getMsg(), result); return AjaxResult.success(ExceptionEnum.SUCCESS.getMsg(), result);

View File

@ -145,6 +145,8 @@ public class TbProDepartServiceImpl implements TbProDepartService {
tbProDepart.setHeadUserPhone(Sm4Utils.encode(tbProDepart.getHeadUserPhone())); tbProDepart.setHeadUserPhone(Sm4Utils.encode(tbProDepart.getHeadUserPhone()));
} }
int result = tbProDepartDao.update(tbProDepart); int result = tbProDepartDao.update(tbProDepart);
//根据项目部id修改接入申请信息
result += tbProDepartDao.updateBdRecord(tbProDepart);
if (result > 0) { if (result > 0) {
return AjaxResult.success(ExceptionEnum.SUCCESS.getMsg(), result); return AjaxResult.success(ExceptionEnum.SUCCESS.getMsg(), result);
} else { } else {

View File

@ -109,6 +109,8 @@ public class TbProjectServiceImpl implements TbProjectService {
int result = tbProjectDao.update(tbProject); int result = tbProjectDao.update(tbProject);
//根据工程id改变班组表中的项目信息 //根据工程id改变班组表中的项目信息
result += tbProjectDao.updateProjectPower(tbProject); result += tbProjectDao.updateProjectPower(tbProject);
//根据工程id修改接入申请记录
result += tbProjectDao.updateBdRecord(tbProject);
if (result > 0) { if (result > 0) {
return AjaxResult.success(ExceptionEnum.SUCCESS.getMsg(), result); return AjaxResult.success(ExceptionEnum.SUCCESS.getMsg(), result);
} else { } else {

View File

@ -294,6 +294,7 @@
<if test="devStatus != null"> <if test="devStatus != null">
and td.dev_status = #{devStatus} and td.dev_status = #{devStatus}
</if> </if>
ORDER BY td.id DESC
</select> </select>
<select id="selectByDevCode" resultType="com.bonus.base.domain.TbDevice"> <select id="selectByDevCode" resultType="com.bonus.base.domain.TbDevice">

View File

@ -149,5 +149,11 @@
where id = #{id} where id = #{id}
</update> </update>
<update id="updateBdRecord">
update tb_bd_record
set depart_name = #{departName}
where depart_id = #{id}
</update>
</mapper> </mapper>

View File

@ -180,6 +180,12 @@
where pro_id = #{id} where pro_id = #{id}
</update> </update>
<update id="updateBdRecord">
update tb_bd_record
set pro_name = #{proName}
where pro_id = #{id}
</update>
<select id="getProjectView" resultType="com.bonus.screen.vo.ProjectViewVo"> <select id="getProjectView" resultType="com.bonus.screen.vo.ProjectViewVo">
select count(1) as projectTotal, select count(1) as projectTotal,
count(case when tb.pro_type = #{powerCode} then 1 end) as projectPowerTotal, count(case when tb.pro_type = #{powerCode} then 1 end) as projectPowerTotal,