|
|
@ -9,6 +9,7 @@ import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProductionProcessContext;
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProductionPsOutContext;
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProductionPsOutContext;
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtConstWords;
|
|
|
|
import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtConstWords;
|
|
|
|
import cn.estsh.i3plus.mes.pcn.serviceimpl.fsm.BaseStepService;
|
|
|
|
import cn.estsh.i3plus.mes.pcn.serviceimpl.fsm.BaseStepService;
|
|
|
|
|
|
|
|
import cn.estsh.i3plus.mes.pcn.util.StringUtil;
|
|
|
|
import cn.estsh.i3plus.platform.common.convert.ConvertBean;
|
|
|
|
import cn.estsh.i3plus.platform.common.convert.ConvertBean;
|
|
|
|
import cn.estsh.i3plus.platform.common.tool.MathOperation;
|
|
|
|
import cn.estsh.i3plus.platform.common.tool.MathOperation;
|
|
|
|
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
|
|
|
|
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
|
|
|
@ -20,6 +21,7 @@ import cn.estsh.i3plus.pojo.mes.model.StationResultBean;
|
|
|
|
import cn.estsh.i3plus.pojo.mes.model.StepResult;
|
|
|
|
import cn.estsh.i3plus.pojo.mes.model.StepResult;
|
|
|
|
import cn.estsh.i3plus.pojo.mes.repository.MesWorkOrderRepository;
|
|
|
|
import cn.estsh.i3plus.pojo.mes.repository.MesWorkOrderRepository;
|
|
|
|
import cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil;
|
|
|
|
import cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil;
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
@ -108,6 +110,9 @@ public class MesWorkOrderSaveStepService extends BaseStepService {
|
|
|
|
Map<String, List<MesProductionPsOutContext>> proMap = productionPsOutContextList.stream().filter(Objects::nonNull).collect(Collectors.groupingBy(MesProductionPsOutContext::getWorkOrderNo));
|
|
|
|
Map<String, List<MesProductionPsOutContext>> proMap = productionPsOutContextList.stream().filter(Objects::nonNull).collect(Collectors.groupingBy(MesProductionPsOutContext::getWorkOrderNo));
|
|
|
|
//产品加工规则 根据foreignKey分组
|
|
|
|
//产品加工规则 根据foreignKey分组
|
|
|
|
Map<Integer, MesProdRuleContext> prMap = prodRuleContextList.stream().filter(o -> (null != o && !StringUtils.isEmpty(o.getForeignKey()))).collect(Collectors.toMap(MesProdRuleContext::getForeignKey, o -> o));
|
|
|
|
Map<Integer, MesProdRuleContext> prMap = prodRuleContextList.stream().filter(o -> (null != o && !StringUtils.isEmpty(o.getForeignKey()))).collect(Collectors.toMap(MesProdRuleContext::getForeignKey, o -> o));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String prodResult = productionDispatchContextStepService.getProductResultContext(reqBean);
|
|
|
|
|
|
|
|
|
|
|
|
//遍历产出零件信息
|
|
|
|
//遍历产出零件信息
|
|
|
|
for(Map.Entry<String, List<MesProductionPartContext>> entry : ppMap.entrySet()) {
|
|
|
|
for(Map.Entry<String, List<MesProductionPartContext>> entry : ppMap.entrySet()) {
|
|
|
|
|
|
|
|
|
|
|
@ -123,11 +128,18 @@ public class MesWorkOrderSaveStepService extends BaseStepService {
|
|
|
|
if (productionPsOutContext.getIsCalcCompleteQty() == CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue()) calcCompleteQty += 1;
|
|
|
|
if (productionPsOutContext.getIsCalcCompleteQty() == CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue()) calcCompleteQty += 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (calcCompleteQty.compareTo(MesPcnExtConstWords.ZERO) == 0 ) continue;
|
|
|
|
if (calcCompleteQty.compareTo(MesPcnExtConstWords.ZERO) == 0) continue;
|
|
|
|
|
|
|
|
|
|
|
|
MesWorkOrder workOrder = workOrderExtService.getWorkOrder(reqBean.getOrganizeCode(), entry.getValue().get(0).getId());
|
|
|
|
MesWorkOrder workOrder = workOrderExtService.getWorkOrder(reqBean.getOrganizeCode(), entry.getValue().get(0).getId());
|
|
|
|
entityManager.detach(workOrder);
|
|
|
|
|
|
|
|
if (null == workOrder) execExpSendMsgAndThrowEx(reqBean, resultBean.writeDbLog(), String.format("请检查工单信息,加工单[%s]信息不存在!", entry.getKey()));
|
|
|
|
if (null == workOrder) execExpSendMsgAndThrowEx(reqBean, resultBean.writeDbLog(), String.format("请检查工单信息,加工单[%s]信息不存在!", entry.getKey()));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
log.info("工厂{}生产线{}工位{}:FSM STATE DISPATCHER --- DO STEP --- {} EXEC --- ORDER:{} --- QURERY:{} --- calcCompleteQty:{} --- prodResult:{}",
|
|
|
|
|
|
|
|
reqBean.getOrganizeCode(), reqBean.getWorkCenterCode(), reqBean.getWorkCellCode(),
|
|
|
|
|
|
|
|
StringUtil.toLowerCaseFirst(this.getClass().getSimpleName()), workOrder.getWorkOrderNo(), JSONObject.toJSONString(workOrder), calcCompleteQty, prodResult);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
entityManager.detach(workOrder);
|
|
|
|
|
|
|
|
|
|
|
|
//工单状态分 排序工单 和非排序工单; 现在必须是非排序工单
|
|
|
|
//工单状态分 排序工单 和非排序工单; 现在必须是非排序工单
|
|
|
|
if (!MesExtEnumUtil.ORDER_STATUS.checkAllowStatus(workCenter.getCenterType(), workOrder.getWorkOrderStatus()))
|
|
|
|
if (!MesExtEnumUtil.ORDER_STATUS.checkAllowStatus(workCenter.getCenterType(), workOrder.getWorkOrderStatus()))
|
|
|
|
execExpSendMsgAndThrowEx(reqBean, resultBean.writeDbLog(), String.format("请检查工单信息,加工单[%s]信息工单状态[%s]!", entry.getKey(), MesExtEnumUtil.ORDER_STATUS.valueOfDescription(workOrder.getWorkOrderStatus())));
|
|
|
|
execExpSendMsgAndThrowEx(reqBean, resultBean.writeDbLog(), String.format("请检查工单信息,加工单[%s]信息工单状态[%s]!", entry.getKey(), MesExtEnumUtil.ORDER_STATUS.valueOfDescription(workOrder.getWorkOrderStatus())));
|
|
|
@ -136,20 +148,16 @@ public class MesWorkOrderSaveStepService extends BaseStepService {
|
|
|
|
execExpSendMsgAndThrowEx(reqBean, resultBean.writeDbLog(), String.format("请检查工单信息,加工单[%s]信息所属生产线[%s]与当前生产线[%s]不一致!", entry.getKey(), workOrder.getWorkCenterCode(), reqBean.getWorkCenterCode()));
|
|
|
|
execExpSendMsgAndThrowEx(reqBean, resultBean.writeDbLog(), String.format("请检查工单信息,加工单[%s]信息所属生产线[%s]与当前生产线[%s]不一致!", entry.getKey(), workOrder.getWorkCenterCode(), reqBean.getWorkCenterCode()));
|
|
|
|
|
|
|
|
|
|
|
|
List<String> propertyNameList = new ArrayList<>();
|
|
|
|
List<String> propertyNameList = new ArrayList<>();
|
|
|
|
List<Object> propertyValueList = new ArrayList<>();
|
|
|
|
|
|
|
|
//修改完成数量
|
|
|
|
//修改完成数量
|
|
|
|
if (calcCompleteQty.compareTo(MesPcnExtConstWords.ZERO) > 0) {
|
|
|
|
if (calcCompleteQty.compareTo(MesPcnExtConstWords.ZERO) > 0) {
|
|
|
|
workOrder.setCompleteQty(MathOperation.add(workOrder.getCompleteQty(), calcCompleteQty));
|
|
|
|
workOrder.setCompleteQty(MathOperation.add(workOrder.getCompleteQty(), calcCompleteQty));
|
|
|
|
propertyNameList.add("completeQty");
|
|
|
|
propertyNameList.add("completeQty");
|
|
|
|
propertyValueList.add(workOrder.getCompleteQty());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//修改未完成数量
|
|
|
|
//修改未完成数量
|
|
|
|
if (calcCompleteQty.compareTo(MesPcnExtConstWords.ZERO) > 0 && workOrder.getUnCompleteQty().compareTo(new Double(0)) > 0 &&
|
|
|
|
if (calcCompleteQty.compareTo(MesPcnExtConstWords.ZERO) > 0 && workOrder.getUnCompleteQty().compareTo(new Double(0)) > 0 &&
|
|
|
|
MathOperation.compareTo(MathOperation.sub(workOrder.getUnCompleteQty(), new Double(calcCompleteQty)), new Double(0)) >= 0) {
|
|
|
|
MathOperation.compareTo(MathOperation.sub(workOrder.getUnCompleteQty(), new Double(calcCompleteQty)), new Double(0)) >= 0) {
|
|
|
|
workOrder.setUnCompleteQty(MathOperation.sub(workOrder.getUnCompleteQty(), new Double(calcCompleteQty)));
|
|
|
|
workOrder.setUnCompleteQty(MathOperation.sub(workOrder.getUnCompleteQty(), new Double(calcCompleteQty)));
|
|
|
|
propertyNameList.add("unCompleteQty");
|
|
|
|
propertyNameList.add("unCompleteQty");
|
|
|
|
propertyValueList.add(workOrder.getUnCompleteQty());
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
@ -159,7 +167,7 @@ public class MesWorkOrderSaveStepService extends BaseStepService {
|
|
|
|
* 上下文中 已经按照工单分组了,因为有一模多腔问题
|
|
|
|
* 上下文中 已经按照工单分组了,因为有一模多腔问题
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
String prodResult = productionDispatchContextStepService.getProductResultContext(reqBean);
|
|
|
|
|
|
|
|
if (!StringUtils.isEmpty(prodResult)) {
|
|
|
|
if (!StringUtils.isEmpty(prodResult)) {
|
|
|
|
//可疑品
|
|
|
|
//可疑品
|
|
|
|
boolean isSuspicious = MesExtEnumUtil.PRODUCE_QC_STATUS.SUSPICIOUS.getValue() == Integer.parseInt(prodResult);
|
|
|
|
boolean isSuspicious = MesExtEnumUtil.PRODUCE_QC_STATUS.SUSPICIOUS.getValue() == Integer.parseInt(prodResult);
|
|
|
@ -167,7 +175,6 @@ public class MesWorkOrderSaveStepService extends BaseStepService {
|
|
|
|
int suspiciousQty = productionPsOutContextList.size();
|
|
|
|
int suspiciousQty = productionPsOutContextList.size();
|
|
|
|
workOrder.setSuspiciousPartQty(MathOperation.add(workOrder.getSuspiciousPartQty(), new Double(suspiciousQty)));
|
|
|
|
workOrder.setSuspiciousPartQty(MathOperation.add(workOrder.getSuspiciousPartQty(), new Double(suspiciousQty)));
|
|
|
|
propertyNameList.add("suspiciousPartQty");
|
|
|
|
propertyNameList.add("suspiciousPartQty");
|
|
|
|
propertyValueList.add(workOrder.getSuspiciousPartQty());
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//报废数量
|
|
|
|
//报废数量
|
|
|
|
boolean isScrap = MesExtEnumUtil.PRODUCE_QC_STATUS.SCRAP.getValue() == Integer.parseInt(prodResult);
|
|
|
|
boolean isScrap = MesExtEnumUtil.PRODUCE_QC_STATUS.SCRAP.getValue() == Integer.parseInt(prodResult);
|
|
|
@ -175,32 +182,27 @@ public class MesWorkOrderSaveStepService extends BaseStepService {
|
|
|
|
int scrapQty = productionPsOutContextList.size();
|
|
|
|
int scrapQty = productionPsOutContextList.size();
|
|
|
|
workOrder.setScrapPartQty(MathOperation.add(workOrder.getScrapPartQty(), new Double(scrapQty)));
|
|
|
|
workOrder.setScrapPartQty(MathOperation.add(workOrder.getScrapPartQty(), new Double(scrapQty)));
|
|
|
|
propertyNameList.add("scrapPartQty");
|
|
|
|
propertyNameList.add("scrapPartQty");
|
|
|
|
propertyValueList.add(workOrder.getScrapPartQty());
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (MathOperation.compareTo(workOrder.getCompleteQty(), workOrder.getQty()) >= 0 && workOrder.getWorkOrderStatus().compareTo(MesExtEnumUtil.ORDER_STATUS.COMPLETE.getValue()) != 0) {
|
|
|
|
if (MathOperation.compareTo(workOrder.getCompleteQty(), workOrder.getQty()) >= 0 && workOrder.getWorkOrderStatus().compareTo(MesExtEnumUtil.ORDER_STATUS.COMPLETE.getValue()) != 0) {
|
|
|
|
workOrder.setWorkOrderStatus(MesExtEnumUtil.ORDER_STATUS.COMPLETE.getValue());
|
|
|
|
workOrder.setWorkOrderStatus(MesExtEnumUtil.ORDER_STATUS.COMPLETE.getValue());
|
|
|
|
propertyNameList.add("workOrderStatus");
|
|
|
|
propertyNameList.add("workOrderStatus");
|
|
|
|
propertyValueList.add(workOrder.getWorkOrderStatus());
|
|
|
|
|
|
|
|
} else if (workOrder.getCompleteQty() > 0 && workOrder.getWorkOrderStatus() == MesExtEnumUtil.ORDER_STATUS.RELEASE.getValue()) {
|
|
|
|
} else if (workOrder.getCompleteQty() > 0 && workOrder.getWorkOrderStatus() == MesExtEnumUtil.ORDER_STATUS.RELEASE.getValue()) {
|
|
|
|
workOrder.setWorkOrderStatus(MesExtEnumUtil.ORDER_STATUS.PROCESS.getValue());
|
|
|
|
workOrder.setWorkOrderStatus(MesExtEnumUtil.ORDER_STATUS.PROCESS.getValue());
|
|
|
|
propertyNameList.add("workOrderStatus");
|
|
|
|
propertyNameList.add("workOrderStatus");
|
|
|
|
propertyValueList.add(workOrder.getWorkOrderStatus());
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//如果数量都没有修改,不操作数据库
|
|
|
|
//如果数量都没有修改,不操作数据库
|
|
|
|
if (!propertyNameList.isEmpty()) {
|
|
|
|
if (!propertyNameList.isEmpty()) {
|
|
|
|
ConvertBean.serviceModelUpdate(workOrder, reqBean.getUserInfo());
|
|
|
|
ConvertBean.serviceModelUpdate(workOrder, reqBean.getUserInfo());
|
|
|
|
workOrder.setModifyDatetime((new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS")).format(new Date()));
|
|
|
|
workOrder.setModifyDatetime((new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS")).format(new Date()));
|
|
|
|
workOrderExtService.update(workOrder);
|
|
|
|
workOrderExtService.update(workOrder);
|
|
|
|
/* propertyNameList.add("modifyUser");
|
|
|
|
|
|
|
|
propertyValueList.add(reqBean.getUserInfo());
|
|
|
|
log.info("工厂{}生产线{}工位{}:FSM STATE DISPATCHER --- DO STEP --- {} EXEC --- ORDER:{} --- UPDATE:{}",
|
|
|
|
propertyNameList.add("modifyDatetime");
|
|
|
|
reqBean.getOrganizeCode(), reqBean.getWorkCenterCode(), reqBean.getWorkCellCode(),
|
|
|
|
propertyValueList.add(TimeTool.getNowTime(true));
|
|
|
|
StringUtil.toLowerCaseFirst(this.getClass().getSimpleName()), workOrder.getWorkOrderNo(), JSONObject.toJSONString(workOrder));
|
|
|
|
DdlPackBean workOrderPackBean = DdlPackBean.getDdlPackBean(reqBean.getOrganizeCode());
|
|
|
|
|
|
|
|
DdlPreparedPack.getNumEqualPack(workOrder.getId(),"id",workOrderPackBean);
|
|
|
|
}
|
|
|
|
workOrderRepository.updateByProperties(propertyNameList.toArray(new String[]{}), propertyValueList.toArray(), workOrderPackBean);
|
|
|
|
|
|
|
|
*/ }
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|