This commit is contained in:
sxu 2024-09-07 12:10:55 +08:00
parent 99fc70cf0c
commit adf408ae8e
1 changed files with 113 additions and 106 deletions

View File

@ -21,6 +21,7 @@ import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
/** /**
* @author hay * @author hay
@ -151,30 +152,43 @@ public class BackReceiveServiceImpl implements BackReceiveService {
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public int endBack(BackApplyInfo record) { public int endBack(BackApplyInfo record) {
int res = 0; int res = 0;
// try {
int taskId = record.getTaskId(); int taskId = record.getTaskId();
int maxBackNumBackEnd = 0;
int passNum = 0;
int maintenanceNum = 0;
int scrapNum = 0;
List<BackApplyInfo> allList1 = backReceiveMapper.getAllList(record);
if (allList1 != null && allList1.size() > 0) {
BackApplyInfo b = allList1.get(0);
record.setTypeId(b.getTypeId());
int num = backReceiveMapper.getmaChineByCt(record);
record.setNum(num);
}
//先判断是否已经完成退料了 //先判断是否已经完成退料了
int taskStatus = selectTaskStatus(taskId); int taskStatus = selectTaskStatus(taskId);
if (taskStatus == 0) { if (taskStatus == 0) {
throw new RuntimeException("该退料单已完成退料"); throw new RuntimeException("该退料单已完成退料");
} }
List<BackApplyInfo> allList1 = backReceiveMapper.getAllList(record);
res += getEndBackResult(record, allList1, taskId);
return res;
}
private int getEndBackResult(BackApplyInfo record, List<BackApplyInfo> allList1, int taskId) {
int res = 0;
int maxBackNumBackEnd = 0;
int passNum = 0;
int maintenanceNum = 0;
int scrapNum = 0;
List<BackApplyInfo> totalList = backReceiveMapper.receiveView4Backend(record);
boolean allZeros = totalList.stream().allMatch(n -> Double.valueOf(n.getNum()).intValue() == 0);
if (allZeros) {
res = updateTaskStatus(taskId, 40);
if (res == 0) {
throw new RuntimeException("tm_task修改状态");
}
}
if (allList1 != null && allList1.size() > 0) {
for (BackApplyInfo bai : allList1) {
record.setTypeId(bai.getTypeId());
int num = backReceiveMapper.getmaChineByCt(record);
record.setNum(num);
//修改任务状态 //修改任务状态
List<BackApplyInfo> list = backReceiveMapper.receiveView4Backend(record); List<BackApplyInfo> list = totalList.stream().filter(o -> o.getTypeId().equals(record.getTypeId())).collect(Collectors.toList());
if (!CollectionUtils.isEmpty(list)) { if (!CollectionUtils.isEmpty(totalList)) {
for (BackApplyInfo backApplyInfo : list) { for (BackApplyInfo backApplyInfo : list) {
maxBackNumBackEnd += (int) backApplyInfo.getMaxBackNumBackend(); maxBackNumBackEnd += backApplyInfo.getMaxBackNumBackend();
} }
} }
List<BackApplyInfo> hgList = backReceiveMapper.getHgList(record); List<BackApplyInfo> hgList = backReceiveMapper.getHgList(record);
@ -195,17 +209,11 @@ public class BackReceiveServiceImpl implements BackReceiveService {
scrapNum += bi.getBackNum(); scrapNum += bi.getBackNum();
} }
} }
log.error("check001退料接收:{},{},{},{}",maxBackNumBackEnd,passNum,maintenanceNum,scrapNum); log.error("check001退料接收:{},{},{},{}", maxBackNumBackEnd, passNum, maintenanceNum, scrapNum);
if (maxBackNumBackEnd < passNum + maintenanceNum + scrapNum) { if (maxBackNumBackEnd < passNum + maintenanceNum + scrapNum) {
throw new RuntimeException("提交退料数量大于最大退料数,可能您的退料已被别人退掉了"); throw new RuntimeException("提交退料数量大于最大退料数,可能您的退料已被别人退掉了");
} }
boolean allZeros = list.stream().allMatch(n -> Double.valueOf(n.getNum()).intValue() == 0);
if (allZeros) {
res = updateTaskStatus(taskId, 40);
if (res == 0) {
throw new RuntimeException("tm_task修改状态");
}
}
//更加退料接收的数据创建下一步流程 //更加退料接收的数据创建下一步流程
//合格的插入入库记录input_apply_details修改库存ma_type,修改机具状态 //合格的插入入库记录input_apply_details修改库存ma_type,修改机具状态
if (hgList != null && hgList.size() > 0) { if (hgList != null && hgList.size() > 0) {
@ -266,14 +274,13 @@ public class BackReceiveServiceImpl implements BackReceiveService {
finishBackCheckDetails(record); finishBackCheckDetails(record);
//库存日志 //库存日志
record.setBackNum(passNum+maintenanceNum+scrapNum); record.setBackNum(passNum + maintenanceNum + scrapNum);
record.setPassNum(passNum); record.setPassNum(passNum);
record.setMaintenanceNum(maintenanceNum); record.setMaintenanceNum(maintenanceNum);
record.setScrapNum(scrapNum); record.setScrapNum(scrapNum);
}
}
// } catch (Exception e) {
// throw new RuntimeException(e.getMessage());
// }
return res; return res;
} }