退料接收多类型机具时的问题优化
This commit is contained in:
parent
99fc70cf0c
commit
352291ba23
|
|
@ -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;
|
||||||
|
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) {
|
||||||
|
int maxBackNumBackEnd = 0;
|
||||||
|
int passNum = 0;
|
||||||
|
int maintenanceNum = 0;
|
||||||
|
int scrapNum = 0;
|
||||||
|
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.getModelId().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,12 @@ public class BackReceiveServiceImpl implements BackReceiveService {
|
||||||
scrapNum += bi.getBackNum();
|
scrapNum += bi.getBackNum();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
log.error("check001退料接收:{},{},{},{}",maxBackNumBackEnd,passNum,maintenanceNum,scrapNum);
|
log.error("退料接收总数与详细数据对比结果:maxBackNumBackEnd={},passNum={},maintenanceNum={},scrapNum={}", maxBackNumBackEnd, passNum, maintenanceNum, scrapNum);
|
||||||
if (maxBackNumBackEnd < passNum + maintenanceNum + scrapNum) {
|
if (maxBackNumBackEnd < passNum + maintenanceNum + scrapNum) {
|
||||||
throw new RuntimeException("提交退料数量大于最大退料数,可能您的退料已被别人退掉了");
|
log.error("TypeId={}所提交的退料数量大于最大退料数,可能您的退料已被别人退掉了!", bai.getTypeId());
|
||||||
}
|
continue;
|
||||||
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) {
|
||||||
|
|
@ -250,30 +259,25 @@ public class BackReceiveServiceImpl implements BackReceiveService {
|
||||||
res = insertSad(newTaskId, bfList);
|
res = insertSad(newTaskId, bfList);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<BackApplyInfo> allList = backReceiveMapper.getAllList(record);
|
//更新结算表 slt_agreement_info
|
||||||
if (allList != null && allList.size() > 0) {
|
res = updateSlt4Bean(record, bai);
|
||||||
res = updateSlt(record, allList);
|
|
||||||
if (res == 0) {
|
if (res == 0) {
|
||||||
throw new RuntimeException("该机具未被领料使用");
|
throw new RuntimeException("该机具未被领料使用");
|
||||||
}
|
}
|
||||||
BackApplyInfo b = allList.get(0);
|
|
||||||
record.setTypeId(b.getTypeId());
|
|
||||||
int postStoreNum = backReceiveMapper.getmaChineByCt(record);
|
|
||||||
record.setPostStoreNum(postStoreNum);
|
|
||||||
}
|
|
||||||
|
|
||||||
//完成退料的部分,更新 back_check_details 为 is_finished=1,此部分不支持撤回
|
//完成退料的部分,更新 back_check_details 为 is_finished=1,此部分不支持撤回
|
||||||
finishBackCheckDetails(record);
|
finishBackCheckDetails(record);
|
||||||
|
|
||||||
//库存日志
|
//库存日志
|
||||||
record.setBackNum(passNum+maintenanceNum+scrapNum);
|
int postStoreNum = backReceiveMapper.getmaChineByCt(record);
|
||||||
|
record.setPostStoreNum(postStoreNum);
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -286,8 +290,7 @@ public class BackReceiveServiceImpl implements BackReceiveService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private int updateSlt(BackApplyInfo record, List<BackApplyInfo> hgList) {
|
private int updateSlt4Bean(BackApplyInfo record, BackApplyInfo bean) {
|
||||||
for (BackApplyInfo bean : hgList) {
|
|
||||||
List<SltAgreementInfo> infoList = backReceiveMapper.getStlInfo(bean);
|
List<SltAgreementInfo> infoList = backReceiveMapper.getStlInfo(bean);
|
||||||
if (infoList.size() > 0) {
|
if (infoList.size() > 0) {
|
||||||
Integer backNum = bean.getBackNum();
|
Integer backNum = bean.getBackNum();
|
||||||
|
|
@ -309,10 +312,36 @@ public class BackReceiveServiceImpl implements BackReceiveService {
|
||||||
} else {
|
} else {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// private int updateSlt(BackApplyInfo record, List<BackApplyInfo> hgList) {
|
||||||
|
// for (BackApplyInfo bean : hgList) {
|
||||||
|
// List<SltAgreementInfo> infoList = backReceiveMapper.getStlInfo(bean);
|
||||||
|
// if (infoList.size() > 0) {
|
||||||
|
// Integer backNum = bean.getBackNum();
|
||||||
|
// for (SltAgreementInfo info : infoList) {
|
||||||
|
// Integer num = info.getNum();
|
||||||
|
// if (backNum.equals(num)) {
|
||||||
|
// backReceiveMapper.updateStlInfo(info, record);
|
||||||
|
// break;
|
||||||
|
// } else if (backNum > num) {
|
||||||
|
// backNum = backNum - num;
|
||||||
|
// backReceiveMapper.updateStlInfo(info, record);
|
||||||
|
// } else if (backNum < num) {
|
||||||
|
// Integer many = num - backNum;
|
||||||
|
// backReceiveMapper.updateStlInfoTwo(info, record, backNum);
|
||||||
|
// backReceiveMapper.insStlInfoTwo(info, many);
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// } else {
|
||||||
|
// return 0;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// return 1;
|
||||||
|
// }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<BackApplyInfo> codeQuery(BackApplyInfo record) {
|
public List<BackApplyInfo> codeQuery(BackApplyInfo record) {
|
||||||
return backReceiveMapper.codeQuery(record);
|
return backReceiveMapper.codeQuery(record);
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,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.Objects;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import cn.hutool.core.bean.BeanUtil;
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
|
|
@ -509,7 +510,7 @@ public class ScrapApplyDetailsServiceImpl implements IScrapApplyDetailsService {
|
||||||
}
|
}
|
||||||
BackApplyInfo backApplyInfo = new BackApplyInfo();
|
BackApplyInfo backApplyInfo = new BackApplyInfo();
|
||||||
backApplyInfo.setAgreementId(tmTaskAgreement.getAgreementId().intValue());
|
backApplyInfo.setAgreementId(tmTaskAgreement.getAgreementId().intValue());
|
||||||
backApplyInfo.setMaId(bean.getMaId().intValue());
|
backApplyInfo.setMaId(Objects.isNull(bean.getMaId()) ? 0 : bean.getMaId().intValue());
|
||||||
backApplyInfo.setTypeId(String.valueOf(bean.getTypeId()));
|
backApplyInfo.setTypeId(String.valueOf(bean.getTypeId()));
|
||||||
backApplyInfo.setCompanyId(String.valueOf(bean.getCompanyId()));
|
backApplyInfo.setCompanyId(String.valueOf(bean.getCompanyId()));
|
||||||
backApplyInfo.setBackNum(bean.getScrapNum().intValue());
|
backApplyInfo.setBackNum(bean.getScrapNum().intValue());
|
||||||
|
|
|
||||||
|
|
@ -778,7 +778,24 @@
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="getmaChineByCt" resultType="java.lang.Integer">
|
<select id="getmaChineByCt" resultType="java.lang.Integer">
|
||||||
select num from ma_type WHERE type_id = #{typeId}
|
SELECT
|
||||||
|
CASE mt.manage_type
|
||||||
|
WHEN 0 THEN
|
||||||
|
IFNULL(subquery0.num, 0)
|
||||||
|
ELSE
|
||||||
|
IFNULL(mt.num, 0)
|
||||||
|
END as num
|
||||||
|
FROM ma_type mt
|
||||||
|
left join (SELECT mt.type_id,
|
||||||
|
mt2.type_name AS typeName,
|
||||||
|
mt.type_name AS typeModelName,
|
||||||
|
count(mm.ma_id) num
|
||||||
|
FROM ma_machine mm
|
||||||
|
LEFT JOIN ma_type mt ON mt.type_id = mm.type_id
|
||||||
|
LEFT JOIN ma_type mt2 ON mt2.type_id = mt.parent_id
|
||||||
|
WHERE mm.ma_code is not null and mm.ma_status in (15)
|
||||||
|
GROUP BY mt.type_id) AS subquery0 ON subquery0.type_id = mt.type_id
|
||||||
|
WHERE mt.del_flag = '0' and mt.type_id = #{typeId}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectTaskNumByMonthWx" resultType="java.lang.Integer">
|
<select id="selectTaskNumByMonthWx" resultType="java.lang.Integer">
|
||||||
|
|
@ -802,6 +819,7 @@
|
||||||
LEFT JOIN tm_task_agreement tta on tta.task_id=bai.task_id
|
LEFT JOIN tm_task_agreement tta on tta.task_id=bai.task_id
|
||||||
WHERE
|
WHERE
|
||||||
parent_id=#{parentId}
|
parent_id=#{parentId}
|
||||||
|
and bcd.type_id=#{typeId}
|
||||||
and bcd.back_status='1' and (bcd.is_finished is null or bcd.is_finished != 1)
|
and bcd.back_status='1' and (bcd.is_finished is null or bcd.is_finished != 1)
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
|
@ -822,6 +840,7 @@
|
||||||
LEFT JOIN tm_task_agreement tta on tta.task_id=bai.task_id
|
LEFT JOIN tm_task_agreement tta on tta.task_id=bai.task_id
|
||||||
WHERE
|
WHERE
|
||||||
parent_id=#{parentId}
|
parent_id=#{parentId}
|
||||||
|
and bcd.type_id=#{typeId}
|
||||||
and bcd.back_status='2' and (bcd.is_finished is null or bcd.is_finished != 1)
|
and bcd.back_status='2' and (bcd.is_finished is null or bcd.is_finished != 1)
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
|
@ -842,6 +861,7 @@
|
||||||
LEFT JOIN tm_task_agreement tta on tta.task_id=bai.task_id
|
LEFT JOIN tm_task_agreement tta on tta.task_id=bai.task_id
|
||||||
WHERE
|
WHERE
|
||||||
parent_id=#{parentId}
|
parent_id=#{parentId}
|
||||||
|
and bcd.type_id=#{typeId}
|
||||||
and bcd.back_status='3' and (bcd.is_finished is null or bcd.is_finished != 1)
|
and bcd.back_status='3' and (bcd.is_finished is null or bcd.is_finished != 1)
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -450,7 +450,24 @@
|
||||||
mt.type_id = #{typeId}
|
mt.type_id = #{typeId}
|
||||||
</select>
|
</select>
|
||||||
<select id="getmaChineByCt" resultType="java.lang.Integer">
|
<select id="getmaChineByCt" resultType="java.lang.Integer">
|
||||||
select num from ma_type WHERE type_id = #{typeId}
|
SELECT
|
||||||
|
CASE mt.manage_type
|
||||||
|
WHEN 0 THEN
|
||||||
|
IFNULL(subquery0.num, 0)
|
||||||
|
ELSE
|
||||||
|
IFNULL(mt.num, 0)
|
||||||
|
END as num
|
||||||
|
FROM ma_type mt
|
||||||
|
left join (SELECT mt.type_id,
|
||||||
|
mt2.type_name AS typeName,
|
||||||
|
mt.type_name AS typeModelName,
|
||||||
|
count(mm.ma_id) num
|
||||||
|
FROM ma_machine mm
|
||||||
|
LEFT JOIN ma_type mt ON mt.type_id = mm.type_id
|
||||||
|
LEFT JOIN ma_type mt2 ON mt2.type_id = mt.parent_id
|
||||||
|
WHERE mm.ma_code is not null and mm.ma_status in (15)
|
||||||
|
GROUP BY mt.type_id) AS subquery0 ON subquery0.type_id = mt.type_id
|
||||||
|
WHERE mt.del_flag = '0' and mt.type_id = #{typeId}
|
||||||
</select>
|
</select>
|
||||||
<select id="getLeaseApplyDetails" resultType="com.bonus.sgzb.app.domain.LeaseApplyDetails">
|
<select id="getLeaseApplyDetails" resultType="com.bonus.sgzb.app.domain.LeaseApplyDetails">
|
||||||
SELECT
|
SELECT
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue