|
|
|
@ -9,7 +9,6 @@ import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProductionPsOutContext;
|
|
|
|
|
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.util.StringUtil;
|
|
|
|
|
import cn.estsh.i3plus.platform.common.convert.ConvertBean;
|
|
|
|
|
import cn.estsh.i3plus.platform.common.tool.MathOperation;
|
|
|
|
|
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
|
|
|
|
|
import cn.estsh.i3plus.pojo.base.enumutil.MesPcnEnumUtil;
|
|
|
|
@ -126,8 +125,6 @@ public class MesWorkOrderSaveNosortStepService extends BaseStepService {
|
|
|
|
|
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.checkNosortAllowStatus(workOrder.getWorkOrderStatus()))
|
|
|
|
|
stepExpSendMsgAndThrowEx(reqBean, resultBean.writeDbLog(), String.format("请检查工单信息,加工单[%s]信息工单状态[%s]!", entry.getKey(), MesExtEnumUtil.ORDER_STATUS.valueOfDescription(workOrder.getWorkOrderStatus())));
|
|
|
|
@ -135,17 +132,16 @@ public class MesWorkOrderSaveNosortStepService extends BaseStepService {
|
|
|
|
|
if (!workOrder.getWorkCenterCode().equals(reqBean.getWorkCenterCode()))
|
|
|
|
|
stepExpSendMsgAndThrowEx(reqBean, resultBean.writeDbLog(), String.format("请检查工单信息,加工单[%s]信息所属生产线[%s]与当前生产线[%s]不一致!", entry.getKey(), workOrder.getWorkCenterCode(), reqBean.getWorkCenterCode()));
|
|
|
|
|
|
|
|
|
|
List<String> propertyNameList = new ArrayList<>();
|
|
|
|
|
Map<String, Object> propertyMap = new HashMap<>();
|
|
|
|
|
|
|
|
|
|
//修改完成数量
|
|
|
|
|
if (calcCompleteQty.compareTo(MesPcnExtConstWords.ZERO) > 0) {
|
|
|
|
|
workOrder.setCompleteQty(MathOperation.add(workOrder.getCompleteQty(), calcCompleteQty));
|
|
|
|
|
propertyNameList.add(MesPcnExtConstWords.COMPLATED_QTY);
|
|
|
|
|
propertyMap.put(MesPcnExtConstWords.COMPLETE_QTY, MathOperation.add(workOrder.getCompleteQty(), calcCompleteQty));
|
|
|
|
|
}
|
|
|
|
|
//修改未完成数量
|
|
|
|
|
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) {
|
|
|
|
|
workOrder.setUnCompleteQty(MathOperation.sub(workOrder.getUnCompleteQty(), new Double(calcCompleteQty)));
|
|
|
|
|
propertyNameList.add(MesPcnExtConstWords.UN_COMPLATED_QTY);
|
|
|
|
|
propertyMap.put(MesPcnExtConstWords.UN_COMPLETE_QTY, MathOperation.sub(workOrder.getUnCompleteQty(), new Double(calcCompleteQty)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -155,43 +151,46 @@ public class MesWorkOrderSaveNosortStepService extends BaseStepService {
|
|
|
|
|
* 上下文中 已经按照工单分组了,因为有一模多腔问题
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!StringUtils.isEmpty(prodResult)) {
|
|
|
|
|
//可疑品
|
|
|
|
|
boolean isSuspicious = MesExtEnumUtil.PRODUCE_QC_STATUS.SUSPICIOUS.getValue() == Integer.parseInt(prodResult);
|
|
|
|
|
if (isSuspicious && !productionPsOutContextList.isEmpty()){
|
|
|
|
|
int suspiciousQty = productionPsOutContextList.size();
|
|
|
|
|
workOrder.setSuspiciousPartQty(MathOperation.add(workOrder.getSuspiciousPartQty(), new Double(suspiciousQty)));
|
|
|
|
|
propertyNameList.add(MesPcnExtConstWords.SUSPICIOUS_PART_QTY);
|
|
|
|
|
if (Integer.valueOf(prodResult).compareTo(MesExtEnumUtil.PRODUCE_QC_STATUS.SUSPICIOUS.getValue()) == 0 && !CollectionUtils.isEmpty(productionPsOutContextList)){
|
|
|
|
|
propertyMap.put(MesPcnExtConstWords.SUSPICIOUS_PART_QTY, MathOperation.add(workOrder.getSuspiciousPartQty(), new Double(productionPsOutContextList.size())));
|
|
|
|
|
}
|
|
|
|
|
//报废数量
|
|
|
|
|
boolean isScrap = MesExtEnumUtil.PRODUCE_QC_STATUS.SCRAP.getValue() == Integer.parseInt(prodResult);
|
|
|
|
|
if (isScrap && !productionPsOutContextList.isEmpty()){
|
|
|
|
|
int scrapQty = productionPsOutContextList.size();
|
|
|
|
|
workOrder.setScrapPartQty(MathOperation.add(workOrder.getScrapPartQty(), new Double(scrapQty)));
|
|
|
|
|
propertyNameList.add(MesPcnExtConstWords.SCRAP_PART_QTY);
|
|
|
|
|
if (Integer.valueOf(prodResult).compareTo(MesExtEnumUtil.PRODUCE_QC_STATUS.SCRAP.getValue()) == 0 && !CollectionUtils.isEmpty(productionPsOutContextList)){
|
|
|
|
|
propertyMap.put(MesPcnExtConstWords.SCRAP_PART_QTY, MathOperation.add(workOrder.getScrapPartQty(), new Double(productionPsOutContextList.size())));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (MathOperation.compareTo(workOrder.getCompleteQty(), workOrder.getQty()) >= 0 && workOrder.getWorkOrderStatus().compareTo(MesExtEnumUtil.ORDER_STATUS.COMPLETE.getValue()) != 0) {
|
|
|
|
|
workOrder.setWorkOrderStatus(MesExtEnumUtil.ORDER_STATUS.COMPLETE.getValue());
|
|
|
|
|
propertyNameList.add(MesPcnExtConstWords.WORK_ORDER_STATUS);
|
|
|
|
|
propertyMap.put(MesPcnExtConstWords.WORK_ORDER_STATUS, MesExtEnumUtil.ORDER_STATUS.COMPLETE.getValue());
|
|
|
|
|
} else if (workOrder.getCompleteQty() > 0 && workOrder.getWorkOrderStatus() == MesExtEnumUtil.ORDER_STATUS.RELEASE.getValue()) {
|
|
|
|
|
workOrder.setWorkOrderStatus(MesExtEnumUtil.ORDER_STATUS.PROCESS.getValue());
|
|
|
|
|
propertyNameList.add(MesPcnExtConstWords.WORK_ORDER_STATUS);
|
|
|
|
|
propertyMap.put(MesPcnExtConstWords.WORK_ORDER_STATUS, MesExtEnumUtil.ORDER_STATUS.PROCESS.getValue());
|
|
|
|
|
}
|
|
|
|
|
//如果数量都没有修改,不操作数据库
|
|
|
|
|
if (!propertyNameList.isEmpty()) {
|
|
|
|
|
ConvertBean.serviceModelUpdate(workOrder, reqBean.getUserInfo());
|
|
|
|
|
workOrder.setModifyDatetime((new SimpleDateFormat(MesPcnExtConstWords.DATE_FORMAT_SSS)).format(new Date()));
|
|
|
|
|
workOrderExtService.update(workOrder);
|
|
|
|
|
|
|
|
|
|
log.info("工厂{}生产线{}工位{}:FSM STATE DISPATCHER --- DO STEP --- {} EXEC --- ORDER:{} --- UPDATE:{}",
|
|
|
|
|
reqBean.getOrganizeCode(), reqBean.getWorkCenterCode(), reqBean.getWorkCellCode(),
|
|
|
|
|
StringUtil.toLowerCaseFirst(this.getClass().getSimpleName()), workOrder.getWorkOrderNo(), JSONObject.toJSONString(workOrder));
|
|
|
|
|
if (CollectionUtils.isEmpty(propertyMap)) continue;
|
|
|
|
|
|
|
|
|
|
propertyMap.put(MesPcnExtConstWords.MODIFY_DATE_TIME, (new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS")).format(new Date()));
|
|
|
|
|
propertyMap.put(MesPcnExtConstWords.MODIFY_USER, reqBean.getUserInfo());
|
|
|
|
|
|
|
|
|
|
String[] propertyName = new String[propertyMap.size()];
|
|
|
|
|
Object[] propertyValue = new Object[propertyMap.size()];
|
|
|
|
|
|
|
|
|
|
Integer index = 0;
|
|
|
|
|
for (Map.Entry<String, Object> innerEntry : propertyMap.entrySet()) {
|
|
|
|
|
if (null == innerEntry) continue;
|
|
|
|
|
propertyName[index] = innerEntry.getKey();
|
|
|
|
|
propertyValue[index] = innerEntry.getValue();
|
|
|
|
|
index ++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
workOrderRepository.updateByProperties(new String[]{MesPcnExtConstWords.ID, MesPcnExtConstWords.ORGANIZE_CODE}, new Object[]{workOrder.getId(), reqBean.getOrganizeCode()}, propertyName, propertyValue);
|
|
|
|
|
|
|
|
|
|
log.info("工厂{}生产线{}工位{}:FSM STATE DISPATCHER --- DO STEP --- {} EXEC --- ORDER:{} --- UPDATE:{}",
|
|
|
|
|
reqBean.getOrganizeCode(), reqBean.getWorkCenterCode(), reqBean.getWorkCellCode(),
|
|
|
|
|
StringUtil.toLowerCaseFirst(this.getClass().getSimpleName()), workOrder.getWorkOrderNo(), JSONObject.toJSONString(propertyMap));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|