报工+批次可以重复+其它细节功能改善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,42 +170,82 @@ public class MesReportWorkConsumeServiceImpl implements IMesReportWorkConsumeSer
@Override
@DS("#header.poolName")
public int submitConsumePS(List<MesReportWorkConsume> mesReportWorkConsumes) {
Date nowTime = DateUtils.getNowDate();
String updateBy = SecurityUtils.getUsername();
for (MesReportWorkConsume mesReportWorkConsume : mesReportWorkConsumes) {
mesReportWorkConsume.setUpdateTime(nowTime);
mesReportWorkConsume.setUpdateBy(updateBy);
//根据belong_work_order找到sap工单(子子母)
List<MesReportWork> workOrders = mesReportWorkMapper.getSapWorkOrder(mesReportWorkConsumes.get(0).getParentOrder());
if (CollectionUtils.isEmpty(workOrders)) {
return 0;
}
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);
/**修改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());
}
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;
}
}
//修改报工物料组成
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);
}
int addNum =mesReportWorkConsumeMapper.addConsumePS(adds);
System.out.println("addNum:"+addNum);
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;
}
int updateNum =mesReportWorkConsumeMapper.submitConsumePS(updates);
System.out.println("addNum:"+updateNum);
return updateNum;
return R.ok();
}
@Override

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

@ -687,7 +687,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
pow.workorder_code_sap workorderCodeSap,
mrwc.warehouse_code warehouseCode
from mes_report_work_consume mrwc
left join pro_order_workorder pow on mrwc.workorder_code = pow.workorder_code
left join pro_order_workorder pow on mrwc.workorder_code = pow.workorder_code
where mrwc.attr1 = '1' and mrwc.del_flag = '0'
and mrwc.parent_order = #{workorderCode}
</select>

@ -1093,33 +1093,36 @@ 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)){
List<String> allOrderIds = new ArrayList<>();
for(ProOrderWorkorder order:checkOrders){
String topOrderCode = order.getOrderCode();
allOrderIds.add(order.getOrderId());
Boolean run = true;
while (run) {
//下级
ProOrderWorkorder sonOrder = proOrderWorkorderMapper.selectSonOrder(topOrderCode);
//有下级code
if (sonOrder != null) {
allOrderIds.add(sonOrder.getOrderId());
topOrderCode = sonOrder.getOrderCode();
} else {
run = false;
if(checkOrders.get(0).equals("o0")){
//未拆分,直接关闭订单
List<String> allOrderIds = new ArrayList<>();
for(ProOrderWorkorder order:checkOrders){
String topOrderCode = order.getOrderCode();
allOrderIds.add(order.getOrderId());
Boolean run = true;
while (run) {
//下级
ProOrderWorkorder sonOrder = proOrderWorkorderMapper.selectSonOrder(topOrderCode);
//有下级code
if (sonOrder != null) {
allOrderIds.add(sonOrder.getOrderId());
topOrderCode = sonOrder.getOrderCode();
} else {
run = false;
}
}
}
int m0 = proOrderMapper.deleteProOrderByIds(allOrderIds.toArray(new String[allOrderIds.size()]));
logger.info(orderIds[0]+"删除订单m0:"+m0);
return 1;
}
int m0 = proOrderMapper.deleteProOrderByIds(allOrderIds.toArray(new String[allOrderIds.size()]));
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,49 +181,44 @@ public class QcCheckTaskIncomeController extends BaseController {
}
public AjaxResult createIncomeBatchTaskFunc(String poolName){
try {
DynamicDataSourceContextHolder.push(poolName);// 这是数据源的key
Date taskTime = DateUtils.getNowDate();
logger.info("++++++++++++" + poolName + "工厂来料检验批量创建任务开始+++时间:"+ taskTime +"++++++++++");
Map<String, Object> mapBom = new HashMap<String, Object>();
mapBom.put("P_WERKS",poolName.replace("ds_",""));//物料工厂 例如1000
logger.info("来料信息查询请求:" + JSONObject.toJSONString(mapBom));
R incomeR = remoteSapService.inComingCheck(mapBom);
if(incomeR.getCode()==500){
logger.info("来料信息查询请求:" + JSONObject.toJSONString(incomeR));
return AjaxResult.error(JSONObject.toJSONString(incomeR));
}
logger.info("来料信息查询结果:" + JSONObject.toJSONString(incomeR));
List<QcCheckTaskIncomeDTO> incomeAll = (List<QcCheckTaskIncomeDTO>)incomeR.getData();
//已经生成过检验任务的采购订单
List<String> todayIncomeLists = qcCheckTaskIncomeService.getTodayIncomeLists();
List<QcCheckTaskIncomeDTO> newIncomes = incomeAll.stream()
.filter(item -> !todayIncomeLists.contains(item.getOrderNo()))
.collect(Collectors.toList());
int successNum = 0;//成功任务数
int failNum = 0;//失败任务数
if(!CollectionUtils.isEmpty(newIncomes)){
logger.info("工厂来料检验任务生成参数:" + JSONObject.toJSONString(newIncomes));
for(QcCheckTaskIncomeDTO income:newIncomes){
AjaxResult ajaxResult = createIncomeTask(income);
if(ajaxResult.isSuccess()){
successNum = successNum + 1;
logger.info(poolName + "工厂的" + income.getCheckNo()+"来料检验创建任务成功++++++++++");
}else if(ajaxResult.isError()){
failNum = failNum +1;
logger.info(poolName + "工厂的" + income.getCheckNo()+"来料检验创建任务失败++++++++++");
}
DynamicDataSourceContextHolder.push(poolName);// 这是数据源的key
Date taskTime = DateUtils.getNowDate();
logger.info("++++++++++++" + poolName + "工厂来料检验批量创建任务开始+++时间:"+ taskTime +"++++++++++");
Map<String, Object> mapBom = new HashMap<String, Object>();
mapBom.put("P_WERKS",poolName.replace("ds_",""));//物料工厂 例如1000
logger.info("来料信息查询请求:" + JSONObject.toJSONString(mapBom));
R incomeR = remoteSapService.inComingCheck(mapBom);
if(incomeR.getCode()==500){
logger.info("来料信息查询请求:" + JSONObject.toJSONString(incomeR));
return AjaxResult.error(JSONObject.toJSONString(incomeR));
}
logger.info("来料信息查询结果:" + JSONObject.toJSONString(incomeR));
List<QcCheckTaskIncomeDTO> incomeAll = (List<QcCheckTaskIncomeDTO>)incomeR.getData();
//已经生成过检验任务的采购订单
List<String> todayIncomeLists = qcCheckTaskIncomeService.getTodayIncomeLists();
List<QcCheckTaskIncomeDTO> newIncomes = incomeAll.stream()
.filter(item -> !todayIncomeLists.contains(item.getOrderNo()))
.collect(Collectors.toList());
int successNum = 0;//成功任务数
int failNum = 0;//失败任务数
if(!CollectionUtils.isEmpty(newIncomes)){
logger.info("工厂来料检验任务生成参数:" + JSONObject.toJSONString(newIncomes));
for(QcCheckTaskIncomeDTO income:newIncomes){
AjaxResult ajaxResult = createIncomeTask(income);
if(ajaxResult.isSuccess()){
successNum = successNum + 1;
logger.info(poolName + "工厂的" + income.getCheckNo()+"来料检验创建任务成功++++++++++");
}else if(ajaxResult.isError()){
failNum = failNum +1;
logger.info(poolName + "工厂的" + income.getCheckNo()+"来料检验创建任务失败++++++++++");
}
}else{
logger.info("++++++++++++" + poolName + "工厂来料检验没有可创建的任务++++++++++");
}
logger.info("++++++++++++" + poolName + "工厂来料检验批量创建任务结束:成功"+ successNum +"失败"+ failNum +"+++++");
return success();
} catch (Exception e) {
logger.info("++++++++++++" + poolName + "工厂来料检验批量创建任务失败++++++++++");
return error("++++++++++++" + poolName + "工厂来料检验批量创建任务失败++++++++++");
}else{
logger.info("++++++++++++" + poolName + "工厂来料检验没有可创建的任务++++++++++");
}
logger.info("++++++++++++" + poolName + "工厂来料检验批量创建任务结束:成功"+ successNum +"失败"+ failNum +"+++++");
return success();
}
@PostMapping("/createIncomeTask")

Loading…
Cancel
Save