|
|
@ -17,6 +17,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;
|
|
|
@ -26,7 +27,9 @@ import org.springframework.util.StringUtils;
|
|
|
|
import javax.persistence.EntityManager;
|
|
|
|
import javax.persistence.EntityManager;
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
import java.util.Date;
|
|
|
|
import java.util.Date;
|
|
|
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* @Description : 保存加工单信息工步 【排序】
|
|
|
|
* @Description : 保存加工单信息工步 【排序】
|
|
|
@ -89,42 +92,68 @@ public class MesWorkOrderSaveSortStepService extends BaseStepService {
|
|
|
|
|
|
|
|
|
|
|
|
private void doHandleWorkOrderData(StationRequestBean reqBean, StationResultBean resultBean, List<MesProductionPartContext> productionPartContextList, MesWorkCell workCell) {
|
|
|
|
private void doHandleWorkOrderData(StationRequestBean reqBean, StationResultBean resultBean, List<MesProductionPartContext> productionPartContextList, MesWorkCell workCell) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//获取上下文加工结果
|
|
|
|
|
|
|
|
String productResult = productionDispatchContextStepService.getProductResultContext(reqBean);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Map<String, Object> propertyMap;
|
|
|
|
|
|
|
|
|
|
|
|
for (MesProductionPartContext productionPartContext : productionPartContextList) {
|
|
|
|
for (MesProductionPartContext productionPartContext : productionPartContextList) {
|
|
|
|
|
|
|
|
|
|
|
|
if (null == productionPartContext || StringUtils.isEmpty(productionPartContext.getForeignKey())) continue;
|
|
|
|
if (null == productionPartContext || StringUtils.isEmpty(productionPartContext.getForeignKey())) continue;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//判断是否末道工位
|
|
|
|
Boolean isEndWorkCell = (!StringUtils.isEmpty(workCell.getIsEndWorkCell()) && workCell.getIsEndWorkCell().compareTo(CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue()) == 0) ? true : false;
|
|
|
|
Boolean isEndWorkCell = (!StringUtils.isEmpty(workCell.getIsEndWorkCell()) && workCell.getIsEndWorkCell().compareTo(CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue()) == 0) ? true : false;
|
|
|
|
|
|
|
|
|
|
|
|
if (!isEndWorkCell && productionPartContext.getWorkOrderStatus().compareTo(MesExtEnumUtil.ORDER_STATUS.PROCESS.getValue()) == 0) continue;
|
|
|
|
propertyMap = new HashMap<>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//质量非合格
|
|
|
|
|
|
|
|
if (!StringUtils.isEmpty(productResult) && !productResult.equals(MesExtEnumUtil.PRODUCE_QC_STATUS.QUALIFIED.getValue() + MesPcnExtConstWords.EMPTY)) {
|
|
|
|
|
|
|
|
propertyMap.put(MesPcnExtConstWords.QC_STATUS, Integer.valueOf(productResult));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//末工位 或者 非加工中
|
|
|
|
|
|
|
|
if (isEndWorkCell || productionPartContext.getWorkOrderStatus().compareTo(MesExtEnumUtil.ORDER_STATUS.PROCESS.getValue()) != 0) {
|
|
|
|
if (!isEndWorkCell) {
|
|
|
|
if (!isEndWorkCell) {
|
|
|
|
workOrderRepository.updateByPropertiesNoSync(
|
|
|
|
propertyMap.put(MesPcnExtConstWords.WORK_ORDER_STATUS, MesExtEnumUtil.ORDER_STATUS.PROCESS.getValue());
|
|
|
|
new String[]{MesPcnExtConstWords.ID, MesPcnExtConstWords.ORGANIZE_CODE},
|
|
|
|
propertyMap.put(MesPcnExtConstWords.START_TIME, productionPartContext.getOnlineTime());
|
|
|
|
new Object[]{productionPartContext.getId(), reqBean.getOrganizeCode()},
|
|
|
|
propertyMap.put(MesPcnExtConstWords.ONLINE_TIME, productionPartContext.getOnlineTime());
|
|
|
|
new String[]{MesPcnExtConstWords.MODIFY_USER, MesPcnExtConstWords.MODIFY_DATE_TIME,
|
|
|
|
|
|
|
|
MesPcnExtConstWords.SYSTEM_SYNC_STATUS, MesPcnExtConstWords.SYSTEM_SYNC_DATE_TIME,
|
|
|
|
|
|
|
|
MesPcnExtConstWords.WORK_ORDER_STATUS, MesPcnExtConstWords.START_TIME, MesPcnExtConstWords.ONLINE_TIME},
|
|
|
|
|
|
|
|
new Object[]{reqBean.getUserInfo(), (new SimpleDateFormat(MesPcnExtConstWords.DATE_FORMAT_SSS)).format(new Date()),
|
|
|
|
|
|
|
|
CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue(), MesPcnExtConstWords.EMPTY,
|
|
|
|
|
|
|
|
MesExtEnumUtil.ORDER_STATUS.PROCESS.getValue(), productionPartContext.getOnlineTime(), productionPartContext.getOnlineTime()});
|
|
|
|
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
productionPartContext.setOfflineTime(TimeTool.getNowTime(true));
|
|
|
|
productionPartContext.setOfflineTime(TimeTool.getNowTime(true));
|
|
|
|
workOrderRepository.updateByPropertiesNoSync(
|
|
|
|
propertyMap.put(MesPcnExtConstWords.WORK_ORDER_STATUS, MesExtEnumUtil.ORDER_STATUS.COMPLETE.getValue());
|
|
|
|
new String[]{MesPcnExtConstWords.ID, MesPcnExtConstWords.ORGANIZE_CODE},
|
|
|
|
propertyMap.put(MesPcnExtConstWords.START_TIME, productionPartContext.getOnlineTime());
|
|
|
|
new Object[]{productionPartContext.getId(), reqBean.getOrganizeCode()},
|
|
|
|
propertyMap.put(MesPcnExtConstWords.ONLINE_TIME, productionPartContext.getOnlineTime());
|
|
|
|
new String[]{MesPcnExtConstWords.MODIFY_USER, MesPcnExtConstWords.MODIFY_DATE_TIME,
|
|
|
|
propertyMap.put(MesPcnExtConstWords.END_TIME, productionPartContext.getOfflineTime());
|
|
|
|
MesPcnExtConstWords.SYSTEM_SYNC_STATUS, MesPcnExtConstWords.SYSTEM_SYNC_DATE_TIME,
|
|
|
|
propertyMap.put(MesPcnExtConstWords.OFFLINE_TIME, productionPartContext.getOfflineTime());
|
|
|
|
MesPcnExtConstWords.WORK_ORDER_STATUS, MesPcnExtConstWords.COMPLETE_QTY, MesPcnExtConstWords.UN_COMPLETE_QTY,
|
|
|
|
propertyMap.put(MesPcnExtConstWords.COMPLETE_QTY, new Double(1));
|
|
|
|
MesPcnExtConstWords.START_TIME, MesPcnExtConstWords.ONLINE_TIME, MesPcnExtConstWords.END_TIME, MesPcnExtConstWords.OFFLINE_TIME},
|
|
|
|
propertyMap.put(MesPcnExtConstWords.UN_COMPLETE_QTY, new Double(0));
|
|
|
|
new Object[]{reqBean.getUserInfo(), (new SimpleDateFormat(MesPcnExtConstWords.DATE_FORMAT_SSS)).format(new Date()),
|
|
|
|
}
|
|
|
|
CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue(), MesPcnExtConstWords.EMPTY,
|
|
|
|
|
|
|
|
MesExtEnumUtil.ORDER_STATUS.COMPLETE.getValue(), new Double(1), new Double(0),
|
|
|
|
|
|
|
|
productionPartContext.getOnlineTime(), productionPartContext.getOnlineTime(), productionPartContext.getOfflineTime(), productionPartContext.getOfflineTime()});
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
log.info("工厂{}生产线{}工位{}:FSM STATE DISPATCHER --- DO STEP --- {} EXEC --- ORDER:{} --- UPDATE:[{}:{}]",
|
|
|
|
//当存在修改字段的情况下进行修改工单信息
|
|
|
|
|
|
|
|
if (!CollectionUtils.isEmpty(propertyMap) && propertyMap.size() > 0) {
|
|
|
|
|
|
|
|
propertyMap.put(MesPcnExtConstWords.MODIFY_USER, reqBean.getUserInfo());
|
|
|
|
|
|
|
|
propertyMap.put(MesPcnExtConstWords.MODIFY_DATE_TIME, (new SimpleDateFormat(MesPcnExtConstWords.DATE_FORMAT_SSS)).format(new Date()));
|
|
|
|
|
|
|
|
propertyMap.put(MesPcnExtConstWords.SYSTEM_SYNC_STATUS, CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue());
|
|
|
|
|
|
|
|
propertyMap.put(MesPcnExtConstWords.SYSTEM_SYNC_DATE_TIME, MesPcnExtConstWords.EMPTY);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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.updateByPropertiesNoSync(new String[]{MesPcnExtConstWords.ID, MesPcnExtConstWords.ORGANIZE_CODE}, new Object[]{productionPartContext.getId(), reqBean.getOrganizeCode()}, propertyName, propertyValue);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
log.info("工厂{}生产线{}工位{}:FSM STATE DISPATCHER --- DO STEP --- {} EXEC --- ORDER:{} --- UPDATE:{}",
|
|
|
|
reqBean.getOrganizeCode(), reqBean.getWorkCenterCode(), reqBean.getWorkCellCode(),
|
|
|
|
reqBean.getOrganizeCode(), reqBean.getWorkCenterCode(), reqBean.getWorkCellCode(),
|
|
|
|
StringUtil.toLowerCaseFirst(this.getClass().getSimpleName()), productionPartContext.getWorkOrderNo(), MesPcnExtConstWords.WORK_ORDER_STATUS, !isEndWorkCell ? MesExtEnumUtil.ORDER_STATUS.PROCESS.getValue() : MesExtEnumUtil.ORDER_STATUS.COMPLETE.getValue());
|
|
|
|
StringUtil.toLowerCaseFirst(this.getClass().getSimpleName()), productionPartContext.getWorkOrderNo(), JSONObject.toJSONString(propertyMap));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|