报工+批次可以重复+其它细节功能改善7

master
zhaoxiaolin 10 months ago
parent ab377c7413
commit 0e86b6715a

@ -24,6 +24,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.op.mes.mapper.MesReportWorkConsumeMapper;
import com.op.mes.service.IMesReportWorkConsumeService;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
/**
@ -169,6 +170,7 @@ public class MesReportWorkConsumeServiceImpl implements IMesReportWorkConsumeSer
@Override
@DS("#header.poolName")
@Transactional(rollbackFor = IllegalArgumentException.class)
public int submitConsumePS(List<MesReportWorkConsume> mesReportWorkConsumes) {
//根据belong_work_order找到sap工单(子子母)
@ -177,54 +179,61 @@ public class MesReportWorkConsumeServiceImpl implements IMesReportWorkConsumeSer
return 0;
}
Date nowTime = DateUtils.getNowDate();
String updateBy = SecurityUtils.getUsername();
for (MesReportWorkConsume mesReportWorkConsume : mesReportWorkConsumes) {
mesReportWorkConsume.setUpdateTime(nowTime);
mesReportWorkConsume.setUpdateBy(updateBy);
}
List<MesReportWorkConsume> updates = mesReportWorkConsumes
.stream()
.filter(u -> u.getCreateTime() != null).collect(Collectors.toList());
List<MesReportWorkConsume> adds = mesReportWorkConsumes
.stream()
.filter(u -> u.getCreateTime() == null).collect(Collectors.toList());
if (!CollectionUtils.isEmpty(adds)) {
Map<String, MesReportWorkConsume> consumeInfoMap = new HashMap<>();
for (MesReportWorkConsume add : adds) {
MesReportWorkConsume newConsumeInfo = consumeInfoMap.get(add.getWorkorderCode());
if (newConsumeInfo == null) {
MesReportWorkConsume mapItem = mesReportWorkConsumeMapper.getNewConsumeInfo(add.getWorkorderCode());
consumeInfoMap.put(add.getWorkorderCode(), mapItem);
}
newConsumeInfo = consumeInfoMap.get(add.getWorkorderCode());
add.setRecordId(IdUtils.fastSimpleUUID());
add.setReportCode(newConsumeInfo.getReportCode());
add.setWorkorderCode(newConsumeInfo.getWorkorderCode());
add.setCreateTime(nowTime);
add.setCreateTime(nowTime);
add.setAttr1("1");//新增标识
add.setParentOrder(newConsumeInfo.getParentOrder());
}
int addNum = mesReportWorkConsumeMapper.addConsumePS(adds);
System.out.println("addNum:" + addNum);
}
int updateNum = mesReportWorkConsumeMapper.submitConsumePS(updates);
System.out.println("updateNum:" + updateNum);
/**修改sap物料损耗组成**/
R updateBomsSap = this.updateAttr1BomsSap(workOrders);
if(updateBomsSap.getCode()== 500){
return 0;
}else {
Date nowTime = DateUtils.getNowDate();
String updateBy = SecurityUtils.getUsername();
for (MesReportWorkConsume mesReportWorkConsume : mesReportWorkConsumes) {
mesReportWorkConsume.setUpdateTime(nowTime);
mesReportWorkConsume.setUpdateBy(updateBy);
}
List<MesReportWorkConsume> updates = mesReportWorkConsumes
.stream()
.filter(u -> u.getCreateTime() != null).collect(Collectors.toList());
List<MesReportWorkConsume> adds = mesReportWorkConsumes
.stream()
.filter(u -> u.getCreateTime() == null).collect(Collectors.toList());
if (!CollectionUtils.isEmpty(adds)) {
Map<String, MesReportWorkConsume> consumeInfoMap = new HashMap<>();
for (MesReportWorkConsume add : adds) {
MesReportWorkConsume newConsumeInfo = consumeInfoMap.get(add.getWorkorderCode());
if (newConsumeInfo == null) {
MesReportWorkConsume mapItem = mesReportWorkConsumeMapper.getNewConsumeInfo(add.getWorkorderCode());
consumeInfoMap.put(add.getWorkorderCode(), mapItem);
}
newConsumeInfo = consumeInfoMap.get(add.getWorkorderCode());
add.setRecordId(IdUtils.fastSimpleUUID());
add.setReportCode(newConsumeInfo.getReportCode());
add.setWorkorderCode(newConsumeInfo.getWorkorderCode());
add.setCreateTime(nowTime);
add.setCreateTime(nowTime);
add.setAttr1("1");//新增标识
add.setParentOrder(newConsumeInfo.getParentOrder());
}
int addNum = mesReportWorkConsumeMapper.addConsumePS(adds);
System.out.println("addNum:" + addNum);
}
int updateNum = mesReportWorkConsumeMapper.submitConsumePS(updates);
System.out.println("addNum:" + updateNum);
return updateNum;
throw new IllegalArgumentException("修改组件异常");
}
return 1;
}
//修改报工物料组成
private R updateAttr1BomsSap(List<MesReportWork> workOrderCodes) {
//是否有变动的物料损耗组成
List<MesReportWorkConsume> updateBoms = mesReportWorkMapper.getUpdateAttr1Boms(workOrderCodes.get(workOrderCodes.size()-1));
MesReportWork workorder = workOrderCodes.get(workOrderCodes.size()-1);
if(workorder == null ){
logger.info(workorder.getWorkorderCode()
+ "报工损耗物料组件修改请求null");
return R.fail();
}
List<MesReportWorkConsume> updateBoms = mesReportWorkMapper.getUpdateAttr1Boms(workorder);
if(!CollectionUtils.isEmpty(updateBoms)){
List<Map<String, Object>> mapList = new ArrayList<>();
Map<String, Object> mapBom = null;
@ -238,14 +247,14 @@ public class MesReportWorkConsumeServiceImpl implements IMesReportWorkConsumeSer
mapList.add(mapBom);
}
logger.info(workOrderCodes.get(workOrderCodes.size()-1).getWorkorderCode()
logger.info(workorder.getWorkorderCode()
+ "报工损耗物料组件修改请求:" + JSONObject.toJSONString(mapList));
R bomUpdateR = remoteSapService.shopOrderBomUpdate(mapList);
logger.info(workOrderCodes.get(workOrderCodes.size()-1).getWorkorderCode()
logger.info(workorder.getWorkorderCode()
+ "报工损耗物料组件修改结果:" + JSONObject.toJSONString(bomUpdateR));
return bomUpdateR;
}
return R.ok();
return R.fail();
}
@Override

@ -12,6 +12,7 @@ import java.util.stream.Collectors;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder;
@ -193,12 +194,17 @@ public class QcCheckTaskIncomeController extends BaseController {
return AjaxResult.error(JSONObject.toJSONString(incomeR));
}
logger.info("来料信息查询结果:" + JSONObject.toJSONString(incomeR));
List<QcCheckTaskIncomeDTO> incomeAll = (List<QcCheckTaskIncomeDTO>)incomeR.getData();
List<QcCheckTaskIncomeDTO> incomeAll = JSONArray.parseArray(JSONObject.toJSONString(incomeR.getData()),QcCheckTaskIncomeDTO.class);
//已经生成过检验任务的采购订单
List<String> todayIncomeLists = qcCheckTaskIncomeService.getTodayIncomeLists();
List<QcCheckTaskIncomeDTO> newIncomes = incomeAll.stream()
.filter(item -> !todayIncomeLists.contains(item.getOrderNo()))
.collect(Collectors.toList());
List<QcCheckTaskIncomeDTO> newIncomes= null;
if(CollectionUtils.isEmpty(todayIncomeLists)){
newIncomes = incomeAll;
}else{
newIncomes = incomeAll.stream()
.filter(item -> !todayIncomeLists.contains(item.getOrderNo()))
.collect(Collectors.toList());
}
int successNum = 0;//成功任务数
int failNum = 0;//失败任务数

Loading…
Cancel
Save