退料编码重复创建接口修改
This commit is contained in:
parent
d19d313683
commit
bc7317d324
|
|
@ -513,4 +513,6 @@ public interface BackApplyInfoMapper {
|
||||||
int syncProject(BackApplyInfo backApplyInfo);
|
int syncProject(BackApplyInfo backApplyInfo);
|
||||||
|
|
||||||
int syncProjectDetails(BackApplyInfo backApplyInfo2);
|
int syncProjectDetails(BackApplyInfo backApplyInfo2);
|
||||||
|
|
||||||
|
BackApplyDetails selectCheckREDetails(BackApplyDetails details);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -145,55 +145,55 @@ public class BackApplyInfoServiceImpl implements IBackApplyInfoService {
|
||||||
}
|
}
|
||||||
|
|
||||||
backApplyRequestVo.setBackApplyInfo(backApplyInfo);
|
backApplyRequestVo.setBackApplyInfo(backApplyInfo);
|
||||||
|
|
||||||
//查询退料详情信息
|
//查询退料详情信息
|
||||||
backApplyInfo.setKeyWord(keyWord);
|
backApplyInfo.setKeyWord(keyWord);
|
||||||
// 移出maCodeList集合中状态不为在用的数据
|
// 移出maCodeList集合中状态不为在用的数据
|
||||||
List<MaCodeVo> newCodeList = new ArrayList<>();
|
List<MaCodeVo> newCodeList = new ArrayList<>();
|
||||||
List<BackApplyDetails> backApplyDetailsList = backApplyInfoMapper.selectBackApplyDetailsListByTaskId(backApplyInfo);
|
List<BackApplyDetails> backApplyDetailsList = backApplyInfoMapper.selectBackApplyDetailsListByTaskId(backApplyInfo);
|
||||||
|
|
||||||
if (CollectionUtils.isNotEmpty(backApplyDetailsList)) {
|
if (CollectionUtils.isNotEmpty(backApplyDetailsList)) {
|
||||||
/*if (!CollectionUtils.isEmpty(typeIdList)) {
|
/*if (!CollectionUtils.isEmpty(typeIdList)) {
|
||||||
backApplyDetailsList = backApplyDetailsList.stream()
|
backApplyDetailsList = backApplyDetailsList.stream()
|
||||||
.filter(item -> typeIdList.contains(item.getFirstId()))
|
.filter(item -> typeIdList.contains(item.getFirstId()))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
// 核心优化:减少数据库查询次数
|
// 核心优化:减少数据库查询次数
|
||||||
// 1. 一次性查询编码设备信息
|
// 1. 一次性查询编码设备信息
|
||||||
List<MaCodeVo> maCodeList = backApplyInfoMapper.selectByCode(id);
|
List<MaCodeVo> maCodeList = backApplyInfoMapper.selectByCode(id);
|
||||||
|
|
||||||
// 2. 处理状态不为在用的设备编码
|
// 2. 处理状态不为在用的设备编码
|
||||||
if ("0".equals(backApplyInfo.getStatus()) && CollectionUtils.isNotEmpty(maCodeList)) {
|
if ("0".equals(backApplyInfo.getStatus()) && CollectionUtils.isNotEmpty(maCodeList)) {
|
||||||
newCodeList = filterNonInUseEquipment(maCodeList);
|
newCodeList = filterNonInUseEquipment(maCodeList);
|
||||||
maCodeList = filterInUseEquipment(maCodeList);
|
maCodeList = filterInUseEquipment(maCodeList);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3. 优化:只有在有编码设备时才查询类型树,减少不必要的复杂查询
|
// 3. 优化:只有在有编码设备时才查询类型树,减少不必要的复杂查询
|
||||||
Map<Long, BigDecimal> typeNumMap = new HashMap<>();
|
Map<Long, BigDecimal> typeNumMap = new HashMap<>();
|
||||||
if (hasCodedEquipment(backApplyDetailsList)) {
|
if (hasCodedEquipment(backApplyDetailsList)) {
|
||||||
List<TypeTreeNode> listL4 = mapper.getUseTypeTreeL4(backApplyInfo);
|
List<TypeTreeNode> listL4 = mapper.getUseTypeTreeL4(backApplyInfo);
|
||||||
typeNumMap = buildTypeNumMappingSimple(listL4);
|
typeNumMap = buildTypeNumMappingSimple(listL4);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 4. 一次性查询所有附件信息
|
// 4. 一次性查询所有附件信息
|
||||||
Map<Long, List<BmFileInfo>> allFileInfoMap = fetchAllFileInfosOptimized(id);
|
Map<Long, List<BmFileInfo>> allFileInfoMap = fetchAllFileInfosOptimized(id);
|
||||||
|
|
||||||
// 5. 预构建映射表
|
// 5. 预构建映射表
|
||||||
Map<Long, List<MaCodeVo>> typeCodeMap = buildTypeCodeMappingSimple(maCodeList);
|
Map<Long, List<MaCodeVo>> typeCodeMap = buildTypeCodeMappingSimple(maCodeList);
|
||||||
Map<Long, MaCodeVo> maIdCodeMap = buildMaIdCodeMappingSimple(maCodeList);
|
Map<Long, MaCodeVo> maIdCodeMap = buildMaIdCodeMappingSimple(maCodeList);
|
||||||
|
|
||||||
// 6. 快速处理每个退料详情
|
// 6. 快速处理每个退料详情
|
||||||
for (BackApplyDetails details : backApplyDetailsList) {
|
for (BackApplyDetails details : backApplyDetailsList) {
|
||||||
processBackApplyDetailsSimple(details, typeNumMap, typeCodeMap, allFileInfoMap, newCodeList, maIdCodeMap);
|
processBackApplyDetailsSimple(details, typeNumMap, typeCodeMap, allFileInfoMap, newCodeList, maIdCodeMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
backApplyRequestVo.setBackApplyDetailsList(backApplyDetailsList);
|
backApplyRequestVo.setBackApplyDetailsList(backApplyDetailsList);
|
||||||
}
|
}
|
||||||
|
|
||||||
AjaxResult ajaxResult = AjaxResult.success();
|
AjaxResult ajaxResult = AjaxResult.success();
|
||||||
ajaxResult.put("data", backApplyRequestVo);
|
ajaxResult.put("data", backApplyRequestVo);
|
||||||
|
|
||||||
if (CollectionUtils.isNotEmpty(newCodeList)) {
|
if (CollectionUtils.isNotEmpty(newCodeList)) {
|
||||||
String msg = buildNotificationMessage(newCodeList);
|
String msg = buildNotificationMessage(newCodeList);
|
||||||
ajaxResult.put("msg", msg);
|
ajaxResult.put("msg", msg);
|
||||||
|
|
@ -379,7 +379,7 @@ public class BackApplyInfoServiceImpl implements IBackApplyInfoService {
|
||||||
queryParam.setTaskId(taskId);
|
queryParam.setTaskId(taskId);
|
||||||
queryParam.setTaskType(3);
|
queryParam.setTaskType(3);
|
||||||
List<BmFileInfo> allFileInfos = bmFileInfoMapper.selectBmFileInfoList(queryParam);
|
List<BmFileInfo> allFileInfos = bmFileInfoMapper.selectBmFileInfoList(queryParam);
|
||||||
|
|
||||||
// 按modelId分组
|
// 按modelId分组
|
||||||
Map<Long, List<BmFileInfo>> fileInfoMap = new HashMap<>();
|
Map<Long, List<BmFileInfo>> fileInfoMap = new HashMap<>();
|
||||||
for (BmFileInfo fileInfo : allFileInfos) {
|
for (BmFileInfo fileInfo : allFileInfos) {
|
||||||
|
|
@ -391,13 +391,13 @@ public class BackApplyInfoServiceImpl implements IBackApplyInfoService {
|
||||||
/**
|
/**
|
||||||
* 简化版退料详情处理
|
* 简化版退料详情处理
|
||||||
*/
|
*/
|
||||||
private void processBackApplyDetailsSimple(BackApplyDetails details,
|
private void processBackApplyDetailsSimple(BackApplyDetails details,
|
||||||
Map<Long, BigDecimal> typeNumMap,
|
Map<Long, BigDecimal> typeNumMap,
|
||||||
Map<Long, List<MaCodeVo>> typeCodeMap,
|
Map<Long, List<MaCodeVo>> typeCodeMap,
|
||||||
Map<Long, List<BmFileInfo>> allFileInfoMap,
|
Map<Long, List<BmFileInfo>> allFileInfoMap,
|
||||||
List<MaCodeVo> newCodeList,
|
List<MaCodeVo> newCodeList,
|
||||||
Map<Long, MaCodeVo> maIdCodeMap) {
|
Map<Long, MaCodeVo> maIdCodeMap) {
|
||||||
|
|
||||||
// 1. 设置在用数量
|
// 1. 设置在用数量
|
||||||
BigDecimal num = typeNumMap.get(details.getTypeId());
|
BigDecimal num = typeNumMap.get(details.getTypeId());
|
||||||
if (num != null) {
|
if (num != null) {
|
||||||
|
|
@ -405,18 +405,18 @@ public class BackApplyInfoServiceImpl implements IBackApplyInfoService {
|
||||||
} else {
|
} else {
|
||||||
details.setNum(BigDecimal.ZERO);
|
details.setNum(BigDecimal.ZERO);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2. 设置附件信息
|
// 2. 设置附件信息
|
||||||
List<BmFileInfo> detailFileInfos = allFileInfoMap.get(details.getId());
|
List<BmFileInfo> detailFileInfos = allFileInfoMap.get(details.getId());
|
||||||
if (CollectionUtils.isNotEmpty(detailFileInfos)) {
|
if (CollectionUtils.isNotEmpty(detailFileInfos)) {
|
||||||
details.setBmFileInfos(detailFileInfos);
|
details.setBmFileInfos(detailFileInfos);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3. 处理编码设备
|
// 3. 处理编码设备
|
||||||
if ("0".equals(details.getManageType())) {
|
if ("0".equals(details.getManageType())) {
|
||||||
processCodedEquipmentSimple(details, typeCodeMap, allFileInfoMap);
|
processCodedEquipmentSimple(details, typeCodeMap, allFileInfoMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 4. 处理非在用状态的设备
|
// 4. 处理非在用状态的设备
|
||||||
processNonInUseEquipmentSimple(details, newCodeList, maIdCodeMap);
|
processNonInUseEquipmentSimple(details, newCodeList, maIdCodeMap);
|
||||||
}
|
}
|
||||||
|
|
@ -424,24 +424,24 @@ public class BackApplyInfoServiceImpl implements IBackApplyInfoService {
|
||||||
/**
|
/**
|
||||||
* 简化版编码设备处理
|
* 简化版编码设备处理
|
||||||
*/
|
*/
|
||||||
private void processCodedEquipmentSimple(BackApplyDetails details,
|
private void processCodedEquipmentSimple(BackApplyDetails details,
|
||||||
Map<Long, List<MaCodeVo>> typeCodeMap,
|
Map<Long, List<MaCodeVo>> typeCodeMap,
|
||||||
Map<Long, List<BmFileInfo>> allFileInfoMap) {
|
Map<Long, List<BmFileInfo>> allFileInfoMap) {
|
||||||
List<MaCodeVo> codeList = typeCodeMap.get(details.getTypeId());
|
List<MaCodeVo> codeList = typeCodeMap.get(details.getTypeId());
|
||||||
if (CollectionUtils.isEmpty(codeList)) {
|
if (CollectionUtils.isEmpty(codeList)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 计算总数
|
// 计算总数
|
||||||
BigDecimal totalGoodNum = BigDecimal.ZERO;
|
BigDecimal totalGoodNum = BigDecimal.ZERO;
|
||||||
BigDecimal totalBadNum = BigDecimal.ZERO;
|
BigDecimal totalBadNum = BigDecimal.ZERO;
|
||||||
List<MaCodeDto> maCodeDtos = new ArrayList<>();
|
List<MaCodeDto> maCodeDtos = new ArrayList<>();
|
||||||
|
|
||||||
for (MaCodeVo maCodeVo : codeList) {
|
for (MaCodeVo maCodeVo : codeList) {
|
||||||
if (StringUtils.isBlank(maCodeVo.getMaCode())) {
|
if (StringUtils.isBlank(maCodeVo.getMaCode())) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 累加数量
|
// 累加数量
|
||||||
if (maCodeVo.getGoodNum() != null) {
|
if (maCodeVo.getGoodNum() != null) {
|
||||||
totalGoodNum = totalGoodNum.add(maCodeVo.getGoodNum());
|
totalGoodNum = totalGoodNum.add(maCodeVo.getGoodNum());
|
||||||
|
|
@ -449,7 +449,7 @@ public class BackApplyInfoServiceImpl implements IBackApplyInfoService {
|
||||||
if (maCodeVo.getBadNum() != null) {
|
if (maCodeVo.getBadNum() != null) {
|
||||||
totalBadNum = totalBadNum.add(maCodeVo.getBadNum());
|
totalBadNum = totalBadNum.add(maCodeVo.getBadNum());
|
||||||
}
|
}
|
||||||
|
|
||||||
// 创建编码DTO
|
// 创建编码DTO
|
||||||
MaCodeDto maCodeDto = createMaCodeDto(maCodeVo);
|
MaCodeDto maCodeDto = createMaCodeDto(maCodeVo);
|
||||||
List<BmFileInfo> fileInfos = allFileInfoMap.get(maCodeVo.getMaId());
|
List<BmFileInfo> fileInfos = allFileInfoMap.get(maCodeVo.getMaId());
|
||||||
|
|
@ -458,7 +458,7 @@ public class BackApplyInfoServiceImpl implements IBackApplyInfoService {
|
||||||
}
|
}
|
||||||
maCodeDtos.add(maCodeDto);
|
maCodeDtos.add(maCodeDto);
|
||||||
}
|
}
|
||||||
|
|
||||||
details.setGoodNum(totalGoodNum);
|
details.setGoodNum(totalGoodNum);
|
||||||
details.setBadNum(totalBadNum);
|
details.setBadNum(totalBadNum);
|
||||||
details.setMaCodeList(maCodeDtos);
|
details.setMaCodeList(maCodeDtos);
|
||||||
|
|
@ -467,20 +467,20 @@ public class BackApplyInfoServiceImpl implements IBackApplyInfoService {
|
||||||
/**
|
/**
|
||||||
* 简化版非在用设备处理
|
* 简化版非在用设备处理
|
||||||
*/
|
*/
|
||||||
private void processNonInUseEquipmentSimple(BackApplyDetails details,
|
private void processNonInUseEquipmentSimple(BackApplyDetails details,
|
||||||
List<MaCodeVo> newCodeList,
|
List<MaCodeVo> newCodeList,
|
||||||
Map<Long, MaCodeVo> maIdCodeMap) {
|
Map<Long, MaCodeVo> maIdCodeMap) {
|
||||||
if (CollectionUtils.isEmpty(newCodeList)) {
|
if (CollectionUtils.isEmpty(newCodeList)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (MaCodeVo maCodeVo : newCodeList) {
|
for (MaCodeVo maCodeVo : newCodeList) {
|
||||||
if (!maCodeVo.getTypeId().equals(details.getTypeId().toString())) {
|
if (!maCodeVo.getTypeId().equals(details.getTypeId().toString())) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
details.setPreNum(details.getPreNum().subtract(BigDecimal.valueOf(1)));
|
details.setPreNum(details.getPreNum().subtract(BigDecimal.valueOf(1)));
|
||||||
|
|
||||||
MaCodeVo info = maIdCodeMap.get(maCodeVo.getMaId());
|
MaCodeVo info = maIdCodeMap.get(maCodeVo.getMaId());
|
||||||
if (info != null) {
|
if (info != null) {
|
||||||
if (info.getGoodNum() != null && info.getGoodNum().compareTo(BigDecimal.ZERO) > 0) {
|
if (info.getGoodNum() != null && info.getGoodNum().compareTo(BigDecimal.ZERO) > 0) {
|
||||||
|
|
@ -499,13 +499,13 @@ public class BackApplyInfoServiceImpl implements IBackApplyInfoService {
|
||||||
MaCodeDto maCodeDto = new MaCodeDto();
|
MaCodeDto maCodeDto = new MaCodeDto();
|
||||||
maCodeDto.setMaCode(maCodeVo.getMaCode());
|
maCodeDto.setMaCode(maCodeVo.getMaCode());
|
||||||
maCodeDto.setMaId(maCodeVo.getMaId());
|
maCodeDto.setMaId(maCodeVo.getMaId());
|
||||||
|
|
||||||
if (maCodeVo.getGoodNum() != null && maCodeVo.getGoodNum().compareTo(BigDecimal.ZERO) > 0) {
|
if (maCodeVo.getGoodNum() != null && maCodeVo.getGoodNum().compareTo(BigDecimal.ZERO) > 0) {
|
||||||
maCodeDto.setApDetection("完好");
|
maCodeDto.setApDetection("完好");
|
||||||
} else if (maCodeVo.getBadNum() != null && maCodeVo.getBadNum().compareTo(BigDecimal.ZERO) > 0) {
|
} else if (maCodeVo.getBadNum() != null && maCodeVo.getBadNum().compareTo(BigDecimal.ZERO) > 0) {
|
||||||
maCodeDto.setApDetection("损坏");
|
maCodeDto.setApDetection("损坏");
|
||||||
}
|
}
|
||||||
|
|
||||||
maCodeDto.setTypeName(maCodeVo.getTypeName());
|
maCodeDto.setTypeName(maCodeVo.getTypeName());
|
||||||
maCodeDto.setMaterialName(maCodeVo.getMaterialName());
|
maCodeDto.setMaterialName(maCodeVo.getMaterialName());
|
||||||
maCodeDto.setTypeId(maCodeVo.getTypeId());
|
maCodeDto.setTypeId(maCodeVo.getTypeId());
|
||||||
|
|
@ -513,7 +513,7 @@ public class BackApplyInfoServiceImpl implements IBackApplyInfoService {
|
||||||
maCodeDto.setMaterialType(maCodeVo.getMaterialType());
|
maCodeDto.setMaterialType(maCodeVo.getMaterialType());
|
||||||
maCodeDto.setGoodNum(maCodeVo.getGoodNum());
|
maCodeDto.setGoodNum(maCodeVo.getGoodNum());
|
||||||
maCodeDto.setBadNum(maCodeVo.getBadNum());
|
maCodeDto.setBadNum(maCodeVo.getBadNum());
|
||||||
|
|
||||||
return maCodeDto;
|
return maCodeDto;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -522,13 +522,13 @@ public class BackApplyInfoServiceImpl implements IBackApplyInfoService {
|
||||||
*/
|
*/
|
||||||
private String buildNotificationMessage(List<MaCodeVo> newCodeList) {
|
private String buildNotificationMessage(List<MaCodeVo> newCodeList) {
|
||||||
StringBuilder msgBuilder = new StringBuilder("您所选择的编码设备编号");
|
StringBuilder msgBuilder = new StringBuilder("您所选择的编码设备编号");
|
||||||
|
|
||||||
String codes = newCodeList.stream()
|
String codes = newCodeList.stream()
|
||||||
.map(MaCodeVo::getMaCode)
|
.map(MaCodeVo::getMaCode)
|
||||||
.collect(Collectors.joining(", "));
|
.collect(Collectors.joining(", "));
|
||||||
|
|
||||||
msgBuilder.append(codes).append("已被他人完成退料,请注意查看!");
|
msgBuilder.append(codes).append("已被他人完成退料,请注意查看!");
|
||||||
|
|
||||||
return msgBuilder.toString().replaceAll("\n", "");
|
return msgBuilder.toString().replaceAll("\n", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1489,7 +1489,7 @@ public class BackApplyInfoServiceImpl implements IBackApplyInfoService {
|
||||||
details.setPreNum(BigDecimal.ONE);
|
details.setPreNum(BigDecimal.ONE);
|
||||||
details.setMaId(maCodeDto.getMaId());
|
details.setMaId(maCodeDto.getMaId());
|
||||||
|
|
||||||
BackApplyDetails checkDetails = backApplyInfoMapper.selectCheckDetails(details);
|
BackApplyDetails checkDetails = backApplyInfoMapper.selectCheckREDetails(details);
|
||||||
if (checkDetails != null) {
|
if (checkDetails != null) {
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
|
|
@ -2456,7 +2456,9 @@ public class BackApplyInfoServiceImpl implements IBackApplyInfoService {
|
||||||
// 退料单位的协议ID如果查不到,就通过别的协议查(例如班组的协议查不到,可能是项目部去领用的)
|
// 退料单位的协议ID如果查不到,就通过别的协议查(例如班组的协议查不到,可能是项目部去领用的)
|
||||||
if (!Objects.equals(record.getAgreementId(), bean.getAgreementId())) {
|
if (!Objects.equals(record.getAgreementId(), bean.getAgreementId())) {
|
||||||
infoList = backApplyInfoMapper.getStlInfo(bean.setAgreementId(record.getAgreementId()));
|
infoList = backApplyInfoMapper.getStlInfo(bean.setAgreementId(record.getAgreementId()));
|
||||||
if (CollectionUtils.isEmpty(infoList)) return 0;
|
if (CollectionUtils.isEmpty(infoList)) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1590,4 +1590,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
and archives_value is not null
|
and archives_value is not null
|
||||||
)
|
)
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="selectCheckREDetails" resultType="com.bonus.material.back.domain.BackApplyDetails">
|
||||||
|
SELECT
|
||||||
|
id AS id,
|
||||||
|
parent_id AS parentId,
|
||||||
|
type_id AS typeId
|
||||||
|
FROM
|
||||||
|
back_check_details
|
||||||
|
where is_finished =0 and type_id = #{typeId}
|
||||||
|
<if test="maId != null">
|
||||||
|
and ma_id = #{maId}
|
||||||
|
</if>
|
||||||
|
|
||||||
|
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue