|
|
|
@ -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
|
|
|
|
|