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

master
zhaoxiaolin 10 months ago
parent c5e85f71af
commit ab377c7413

@ -347,12 +347,6 @@ public class IWCInterfaceServiceImpl implements IWCSInterfaceService {
return R.fail("子母工单信息缺失");
}
/**修改sap物料损耗组成**/
R updateBomsSap = this.updateAttr1BomsSap(workOrders);
if(updateBomsSap.getCode()== 500){
return updateBomsSap;
}
R sapRson = null;
if(workOrders.size()==1){
/**(一层报工)工单报工**/
@ -440,32 +434,6 @@ public class IWCInterfaceServiceImpl implements IWCSInterfaceService {
}
return sapRson;
}
//修改报工物料组成
private R updateAttr1BomsSap(List<MesReportWork> workOrderCodes) {
//是否有变动的物料损耗组成
List<MesReportWorkConsume> updateBoms = mesReportWorkMapper.getUpdateAttr1Boms(workOrderCodes.get(workOrderCodes.size()-1));
if(!CollectionUtils.isEmpty(updateBoms)){
List<Map<String, Object>> mapList = new ArrayList<>();
Map<String, Object> mapBom = null;
for(MesReportWorkConsume updateBom:updateBoms){
mapBom = new HashMap<String, Object>();
mapBom.put("P_AUFNR",updateBom.getWorkorderCodeSap());// 订单号 例如000100308287
mapBom.put("P_MATNR",updateBom.getMaterialCode());// 物料号 例如000000040000015089
//mapBom.put("P_GMEIN",updateBom.getUnit());// 基本计量单位 例如m
mapBom.put("P_WERKS",workOrderCodes.get(0).getFactoryCode());//物料工厂 例如1000
mapBom.put("P_LGORT",updateBom.getWarehouseCode());//仓库编号 例如0013
mapList.add(mapBom);
}
logger.info(workOrderCodes.get(workOrderCodes.size()-1).getWorkorderCode()
+ "报工损耗物料组件修改请求:" + JSONObject.toJSONString(mapList));
R bomUpdateR = remoteSapService.shopOrderBomUpdate(mapList);
logger.info(workOrderCodes.get(workOrderCodes.size()-1).getWorkorderCode()
+ "报工损耗物料组件修改结果:" + JSONObject.toJSONString(bomUpdateR));
return bomUpdateR;
}
return R.ok();
}
/**
*

@ -4,13 +4,16 @@ import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;
import com.alibaba.fastjson2.JSONObject;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.op.common.core.domain.R;
import com.op.common.core.utils.DateUtils;
import com.op.common.core.utils.bean.BeanUtils;
import com.op.common.core.utils.uuid.IdUtils;
import com.op.common.security.utils.SecurityUtils;
import com.op.mes.domain.*;
import com.op.mes.mapper.MesReportWorkMapper;
import com.op.system.api.RemoteSapService;
import com.op.system.api.domain.dto.BaseBomDTO;
import com.op.system.api.domain.mes.BaseProductDTO;
import com.op.system.api.domain.mes.BaseTeamTDTO;
@ -38,6 +41,9 @@ public class MesReportWorkConsumeServiceImpl implements IMesReportWorkConsumeSer
@Autowired
private MesReportWorkMapper mesReportWorkMapper;
@Autowired
private RemoteSapService remoteSapService;
/**
*
*
@ -164,6 +170,18 @@ public class MesReportWorkConsumeServiceImpl implements IMesReportWorkConsumeSer
@Override
@DS("#header.poolName")
public int submitConsumePS(List<MesReportWorkConsume> mesReportWorkConsumes) {
//根据belong_work_order找到sap工单(子子母)
List<MesReportWork> workOrders = mesReportWorkMapper.getSapWorkOrder(mesReportWorkConsumes.get(0).getParentOrder());
if (CollectionUtils.isEmpty(workOrders)) {
return 0;
}
/**修改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) {
@ -172,17 +190,17 @@ public class MesReportWorkConsumeServiceImpl implements IMesReportWorkConsumeSer
}
List<MesReportWorkConsume> updates = mesReportWorkConsumes
.stream()
.filter(u -> u.getCreateTime()!=null).collect(Collectors.toList());
.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){
.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){
if (newConsumeInfo == null) {
MesReportWorkConsume mapItem = mesReportWorkConsumeMapper.getNewConsumeInfo(add.getWorkorderCode());
consumeInfoMap.put(add.getWorkorderCode(),mapItem);
consumeInfoMap.put(add.getWorkorderCode(), mapItem);
}
newConsumeInfo = consumeInfoMap.get(add.getWorkorderCode());
@ -194,13 +212,41 @@ public class MesReportWorkConsumeServiceImpl implements IMesReportWorkConsumeSer
add.setAttr1("1");//新增标识
add.setParentOrder(newConsumeInfo.getParentOrder());
}
int addNum =mesReportWorkConsumeMapper.addConsumePS(adds);
System.out.println("addNum:"+addNum);
int addNum = mesReportWorkConsumeMapper.addConsumePS(adds);
System.out.println("addNum:" + addNum);
}
int updateNum =mesReportWorkConsumeMapper.submitConsumePS(updates);
System.out.println("addNum:"+updateNum);
int updateNum = mesReportWorkConsumeMapper.submitConsumePS(updates);
System.out.println("addNum:" + updateNum);
return updateNum;
}
}
//修改报工物料组成
private R updateAttr1BomsSap(List<MesReportWork> workOrderCodes) {
//是否有变动的物料损耗组成
List<MesReportWorkConsume> updateBoms = mesReportWorkMapper.getUpdateAttr1Boms(workOrderCodes.get(workOrderCodes.size()-1));
if(!CollectionUtils.isEmpty(updateBoms)){
List<Map<String, Object>> mapList = new ArrayList<>();
Map<String, Object> mapBom = null;
for(MesReportWorkConsume updateBom:updateBoms){
mapBom = new HashMap<String, Object>();
mapBom.put("P_AUFNR",updateBom.getWorkorderCodeSap());// 订单号 例如000100308287
mapBom.put("P_MATNR",updateBom.getMaterialCode());// 物料号 例如000000040000015089
//mapBom.put("P_GMEIN",updateBom.getUnit());// 基本计量单位 例如m
mapBom.put("P_WERKS",workOrderCodes.get(0).getFactoryCode());//物料工厂 例如1000
mapBom.put("P_LGORT",updateBom.getWarehouseCode());//仓库编号 例如0013
mapList.add(mapBom);
}
logger.info(workOrderCodes.get(workOrderCodes.size()-1).getWorkorderCode()
+ "报工损耗物料组件修改请求:" + JSONObject.toJSONString(mapList));
R bomUpdateR = remoteSapService.shopOrderBomUpdate(mapList);
logger.info(workOrderCodes.get(workOrderCodes.size()-1).getWorkorderCode()
+ "报工损耗物料组件修改结果:" + JSONObject.toJSONString(bomUpdateR));
return bomUpdateR;
}
return R.ok();
}
@Override
@DS("#header.poolName")

@ -105,7 +105,8 @@
pow.workorder_code_sap workorderCodeSap,
mrwc.attr1,
mrwc.warehouse_code warehouseCode,
mpd.quantity planQuantity
mpd.quantity planQuantity,
mrwc.parent_order parentOrder
from mes_report_work_consume mrwc
left join pro_order_workorder pow on mrwc.workorder_code = pow.workorder_code
left join mes_prepare_detail mpd on mpd.parent_work_order = pow.belong_work_order

@ -1093,10 +1093,12 @@ public class ProOrderServiceImpl implements IProOrderService {
@DS("#header.poolName")
@Transactional(rollbackFor = Exception.class)
public int deleteOrder(String[] orderIds) {
//只准一个个的删
//未拆分、部分拆分,直接关闭订单
List<ProOrderWorkorder> checkOrders = proOrderWorkorderMapper.getOrderByOrders(orderIds);
if(!CollectionUtils.isEmpty(checkOrders)){
if(checkOrders.get(0).equals("o0")){
//未拆分,直接关闭订单
List<String> allOrderIds = new ArrayList<>();
for(ProOrderWorkorder order:checkOrders){
String topOrderCode = order.getOrderCode();
@ -1118,8 +1120,9 @@ public class ProOrderServiceImpl implements IProOrderService {
logger.info(orderIds[0]+"删除订单m0:"+m0);
return 1;
}
}
//已经存在工单可以进行订单关闭的数据
//完全拆分已经存在工单可以进行订单关闭的数据
List<ProOrderWorkorder> checkWorkOrders = proOrderWorkorderMapper.getWorkOrderByOrders(orderIds);
if(checkWorkOrders.size() != orderIds.length){
return 2;

@ -541,7 +541,7 @@
<foreach item="orderId" collection="orderIds" open="(" separator="," close=")">
#{orderId}
</foreach>
and status in ('o1','o0') and del_flag = '0'
and del_flag = '0'
</select>
<select id="checkBatchCodes" resultType="java.lang.String">
select distinct batch_code

@ -181,7 +181,6 @@ public class QcCheckTaskIncomeController extends BaseController {
}
public AjaxResult createIncomeBatchTaskFunc(String poolName){
try {
DynamicDataSourceContextHolder.push(poolName);// 这是数据源的key
Date taskTime = DateUtils.getNowDate();
logger.info("++++++++++++" + poolName + "工厂来料检验批量创建任务开始+++时间:"+ taskTime +"++++++++++");
@ -220,10 +219,6 @@ public class QcCheckTaskIncomeController extends BaseController {
}
logger.info("++++++++++++" + poolName + "工厂来料检验批量创建任务结束:成功"+ successNum +"失败"+ failNum +"+++++");
return success();
} catch (Exception e) {
logger.info("++++++++++++" + poolName + "工厂来料检验批量创建任务失败++++++++++");
return error("++++++++++++" + poolName + "工厂来料检验批量创建任务失败++++++++++");
}
}
@PostMapping("/createIncomeTask")

Loading…
Cancel
Save