Commit f985b2e1 authored by suhuiguang's avatar suhuiguang

fix(jg): 批量删除提示修改

1.批量删除提示修改由于序号不对应,调整为产品、装置名称
parent 811c6c78
...@@ -984,17 +984,17 @@ public class IdxBizJgProjectContraptionServiceImplService extends BaseEntityServ ...@@ -984,17 +984,17 @@ public class IdxBizJgProjectContraptionServiceImplService extends BaseEntityServ
} }
private String getTipMsgString(Map<String, Long> projectContraptionIdUseNumMap, List<String> pIds) { private String getTipMsgString(Map<String, Long> projectContraptionIdUseNumMap, List<String> pIds) {
List<Integer> indexes = new ArrayList<>(); List<String> projectContraptionNames = new ArrayList<>();
for (int i = 0; i < pIds.size(); i++) { List<String> projectContraptionIdInUsed = projectContraptionIdUseNumMap.entrySet().stream().filter(e->e.getValue()>0).map(Map.Entry::getKey).collect(Collectors.toList());
String projectContraptionId = pIds.get(i); Map<String, String> projectContraptionIdNameMap = this.list(new LambdaQueryWrapper<IdxBizJgProjectContraption>()
if (projectContraptionIdUseNumMap.getOrDefault(projectContraptionId, 0L) > 0) { .in(BaseEntity::getSequenceNbr, projectContraptionIdInUsed)
indexes.add(i + 1); .select(BaseEntity::getSequenceNbr, IdxBizJgProjectContraption::getProjectContraption))
} .stream().collect(Collectors.toMap(p->String.valueOf(p.getSequenceNbr()), IdxBizJgProjectContraption::getProjectContraption));
for (String projectContraptionId : projectContraptionIdInUsed) {
projectContraptionNames.add(projectContraptionIdNameMap.get(projectContraptionId));
} }
if (pIds.size() > 1) { if (pIds.size() > 1) {
return String.format("选择的第 %s 行装置已经在业务办理中,不能删除,请先取消勾选!", indexes.stream() return String.format("选择的装置:%s,已经在业务办理中,不能删除,请先取消勾选!", String.join("、", projectContraptionNames));
.map(String::valueOf)
.collect(Collectors.joining(",")));
} else { } else {
return "装置已经在业务办理中,不能删除!"; return "装置已经在业务办理中,不能删除!";
} }
......
...@@ -26,6 +26,7 @@ import com.yeejoin.amos.boot.biz.common.controller.BaseController; ...@@ -26,6 +26,7 @@ import com.yeejoin.amos.boot.biz.common.controller.BaseController;
import com.yeejoin.amos.boot.biz.common.dto.CountDto; import com.yeejoin.amos.boot.biz.common.dto.CountDto;
import com.yeejoin.amos.boot.biz.common.entity.BaseEntity; import com.yeejoin.amos.boot.biz.common.entity.BaseEntity;
import com.yeejoin.amos.boot.biz.common.entity.DataDictionary; import com.yeejoin.amos.boot.biz.common.entity.DataDictionary;
import com.yeejoin.amos.boot.biz.common.entity.TzsBaseEntity;
import com.yeejoin.amos.boot.biz.common.service.impl.DataDictionaryServiceImpl; import com.yeejoin.amos.boot.biz.common.service.impl.DataDictionaryServiceImpl;
import com.yeejoin.amos.boot.biz.common.utils.*; import com.yeejoin.amos.boot.biz.common.utils.*;
import com.yeejoin.amos.boot.module.common.api.dao.ESEquipmentCategory; import com.yeejoin.amos.boot.module.common.api.dao.ESEquipmentCategory;
...@@ -49,6 +50,7 @@ import com.yeejoin.amos.boot.module.jg.biz.reminder.core.event.EquipCreateOrEdit ...@@ -49,6 +50,7 @@ import com.yeejoin.amos.boot.module.jg.biz.reminder.core.event.EquipCreateOrEdit
import com.yeejoin.amos.boot.module.jg.biz.service.*; import com.yeejoin.amos.boot.module.jg.biz.service.*;
import com.yeejoin.amos.boot.module.jg.biz.utils.CodeUtil; import com.yeejoin.amos.boot.module.jg.biz.utils.CodeUtil;
import com.yeejoin.amos.boot.module.jg.biz.utils.JsonUtils; import com.yeejoin.amos.boot.module.jg.biz.utils.JsonUtils;
import com.yeejoin.amos.boot.module.ymt.api.dto.KV;
import com.yeejoin.amos.boot.module.ymt.api.dto.TzBaseEnterpriseInfoDto; import com.yeejoin.amos.boot.module.ymt.api.dto.TzBaseEnterpriseInfoDto;
import com.yeejoin.amos.boot.module.ymt.api.dto.TzsUserInfoDto; import com.yeejoin.amos.boot.module.ymt.api.dto.TzsUserInfoDto;
import com.yeejoin.amos.boot.module.ymt.api.entity.*; import com.yeejoin.amos.boot.module.ymt.api.entity.*;
...@@ -1261,17 +1263,17 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste ...@@ -1261,17 +1263,17 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste
} }
private String getTipMsgString(Map<String, Long> recordUseNumMap, List<String> records) { private String getTipMsgString(Map<String, Long> recordUseNumMap, List<String> records) {
List<Integer> idxs = new ArrayList<>(); List<String> inUsedNames = new ArrayList<>();
for (int i = 0; i < records.size(); i++) { List<String> recordsInUsed = recordUseNumMap.entrySet().stream().filter(e->e.getValue() > 0).map(Map.Entry::getKey).collect(Collectors.toList());
String record = records.get(i); Map<String, String> recordNameMap = idxBizJgRegisterInfoService.list(new LambdaQueryWrapper<IdxBizJgRegisterInfo>()
if(recordUseNumMap.getOrDefault(record, 0L) > 0){ .in(IdxBizJgRegisterInfo::getRecord, recordsInUsed)
idxs.add(i+1); .select(TzsBaseEntity::getSequenceNbr, IdxBizJgRegisterInfo::getProductName))
} .stream().collect(Collectors.toMap(IdxBizJgRegisterInfo::getRecord, IdxBizJgRegisterInfo::getProductName));
for (String record : recordsInUsed) {
inUsedNames.add(recordNameMap.get(record));
} }
if (records.size() > 1) { if (records.size() > 1) {
return String.format("选择的第 %s 行设备已经在业务办理中,不能删除,请先取消勾选!", idxs.stream() return String.format("选择的设备:%s,已经在业务办理中,不能删除,请先取消勾选!", String.join("、", inUsedNames));
.map(String::valueOf)
.collect(Collectors.joining(",")));
} else { } else {
return "设备已经在业务办理中,不能删除!"; return "设备已经在业务办理中,不能删除!";
} }
......
...@@ -53,11 +53,10 @@ public class EnterpriseManageServiceImpl { ...@@ -53,11 +53,10 @@ public class EnterpriseManageServiceImpl {
public Boolean delete(List<String> ids) { public Boolean delete(List<String> ids) {
// 校验 // 校验
List<TzBaseEnterpriseInfo> enterpriseInfos = enterpriseInfoService.getBaseMapper().selectBatchIds(ids); List<TzBaseEnterpriseInfo> enterpriseInfos = enterpriseInfoService.getBaseMapper().selectBatchIds(ids);
List<String> useUnitCodes = this.castIds2UseUnitCodes(ids, enterpriseInfos);
Map<String, Long> useUnitCodeUserNumMap = this.countUserByUnit(enterpriseInfos); Map<String, Long> useUnitCodeUserNumMap = this.countUserByUnit(enterpriseInfos);
this.checkForUse(useUnitCodes, useUnitCodeUserNumMap, "人员"); this.checkForUse(enterpriseInfos, useUnitCodeUserNumMap, "人员");
Map<String, Long> useUnitCodeEquipNumMap = this.countEquipByUnit(enterpriseInfos); Map<String, Long> useUnitCodeEquipNumMap = this.countEquipByUnit(enterpriseInfos);
this.checkForUse(useUnitCodes, useUnitCodeEquipNumMap, "设备"); this.checkForUse(enterpriseInfos, useUnitCodeEquipNumMap, "设备");
// 业务操作 // 业务操作
enterpriseInfos.forEach(e -> { enterpriseInfos.forEach(e -> {
this.deleteEnterprise(e); this.deleteEnterprise(e);
...@@ -185,30 +184,30 @@ public class EnterpriseManageServiceImpl { ...@@ -185,30 +184,30 @@ public class EnterpriseManageServiceImpl {
}); });
} }
private void checkForUse(List<String> ids, Map<String, Long> seqUseNumMap, String type) { private void checkForUse(List<TzBaseEnterpriseInfo> enterpriseInfos, Map<String, Long> seqUseNumMap, String type) {
if (seqUseNumMap.values().stream().reduce(0L, Long::sum) > 0) { if (seqUseNumMap.values().stream().reduce(0L, Long::sum) > 0) {
List<Integer> indexUse = new ArrayList<>(); List<String> useNames = new ArrayList<>();
for (int i = 0; i < ids.size(); i++) { for (TzBaseEnterpriseInfo enterpriseInfo : enterpriseInfos) {
if (seqUseNumMap.getOrDefault(ids.get(i), 0L) > 0) { if (seqUseNumMap.getOrDefault(enterpriseInfo.getUseUnitCode(), 0L) > 0) {
indexUse.add(i + 1); useNames.add(enterpriseInfo.getUseUnit());
} }
} }
this.buildDeleteCheckFailureMsg(indexUse, type); this.buildDeleteCheckFailureMsg(useNames, type);
} }
} }
private void buildDisableCheckFailureMsg(List<Integer> indexDisabled) { private void buildDisableCheckFailureMsg(List<Integer> indexDisabled) {
String msg = indexDisabled.stream().map(String::valueOf).collect(Collectors.joining("、", "第", "行")) + "已经是停用状态,不能重复操作!"; String msg = indexDisabled.stream().map(String::valueOf).collect(Collectors.joining("、", "您选中的企业:", ",已经是停用状态,不能重复操作!"));
throw new BadRequest(msg); throw new BadRequest(msg);
} }
private void buildEnableCheckFailureMsg(List<Integer> indexDisabled) { private void buildEnableCheckFailureMsg(List<Integer> indexDisabled) {
String msg = indexDisabled.stream().map(String::valueOf).collect(Collectors.joining("、", "第", "行")) + "已经是启用状态,不能重复操作!"; String msg = indexDisabled.stream().map(String::valueOf).collect(Collectors.joining("、", "您选中的企业:", ",已经是启用状态,不能重复操作!"));
throw new BadRequest(msg); throw new BadRequest(msg);
} }
private void buildDeleteCheckFailureMsg(List<Integer> indexUse, String type) { private void buildDeleteCheckFailureMsg(List<String> useNames, String type) {
String msg = String.format("%s的企业下存在%s,请先删除%s后再操作!", indexUse.stream().map(String::valueOf).collect(Collectors.joining("、", "第", "行")), type, type); String msg = String.format("企业:%s下存在%s,请先删除%s后再操作!", String.join("、", useNames), type, type);
throw new BadRequest(msg); throw new BadRequest(msg);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment