节拍 变更

tags/yfai-pcn-ext-v1.0
王杰 1 year ago
parent b29fbdbb49
commit 4bfa20e9ed

@ -2,8 +2,8 @@ package cn.estsh.i3plus.ext.mes.pcn.api.base;
import cn.estsh.i3plus.ext.mes.pcn.pojo.bean.MesShiftExt;
import cn.estsh.i3plus.ext.mes.pcn.pojo.bean.MesShiftProd;
import cn.estsh.i3plus.ext.mes.pcn.pojo.bean.MesShiftProdCenterPm;
import cn.estsh.i3plus.ext.mes.pcn.pojo.bean.MesShiftProdCenterRecord;
import cn.estsh.i3plus.ext.mes.pcn.pojo.bean.MesWorkCenterExt;
import cn.estsh.i3plus.ext.mes.pcn.pojo.model.ShiftProdCenterModel;
import cn.estsh.i3plus.ext.mes.pcn.pojo.model.ShiftProdCenterRecordModel;
import cn.estsh.i3plus.ext.mes.pcn.pojo.model.ShiftProdModel;
@ -90,5 +90,17 @@ public interface IShiftProdCenterRecordService {
* @param endTime
* @return
*/
@ApiOperation(value = "根据班次获取生产日期", notes = "根据班次获取生产日期")
String getWorkTime(String startTime, String endTime);
/**
*
* @param organizeCode
* @param workCenterCode 线
* @param shiftCode
* @param workTime
* @return
*/
@ApiOperation(value = "获取停开机班次人员记录信息", notes = "获取停开机班次人员记录信息")
MesShiftProdCenterPm getMesShiftProdCenterPm(String organizeCode, String workCenterCode, String shiftCode, String workTime);
}

@ -321,7 +321,8 @@ public class ShiftProdCenterRecordService implements IShiftProdCenterRecordServi
shiftProdCenterPmRepository.save(shiftProdCenterPm);
}
private MesShiftProdCenterPm getMesShiftProdCenterPm(String organizeCode, String workCenterCode, String shiftCode, String workTime) {
@Override
public MesShiftProdCenterPm getMesShiftProdCenterPm(String organizeCode, String workCenterCode, String shiftCode, String workTime) {
return shiftProdCenterPmRepository.getByProperty(
new String[]{MesPcnExtConstWords.ORGANIZE_CODE, MesPcnExtConstWords.IS_DELETED, MesPcnExtConstWords.IS_VALID,
MesPcnExtConstWords.WORK_CENTER_CODE, MesPcnExtConstWords.SHIFT_CODE, MesPcnExtConstWords.WORK_TIME},

@ -19,6 +19,8 @@ public class SxThirdPartyPlcCollectCellTaktHandler extends SxThirdPartyPlcCollec
private volatile String limit;
private volatile String scanCellCode;
public SxThirdPartyPlcCollectCellTaktHandler(String org, String key) {
super(org, key);
super.doSubmit();
@ -31,14 +33,17 @@ public class SxThirdPartyPlcCollectCellTaktHandler extends SxThirdPartyPlcCollec
Map<String, String> paramMap = JSONObject.parseObject(obj.toString(), Map.class);
String[] plcCodeArr = paramMap.get(MesPcnExtConstWords.PLC_CODE_UC).split(MesPcnExtConstWords.COMMA);
String limit = paramMap.get(MesPcnExtConstWords.LIMIT);
String scanCellCode = paramMap.get(MesPcnExtConstWords.WORK_CELL_CODE);
if (StringUtils.isEmpty(plcCode2Flag) || !plcCode2Flag.equals(plcCodeArr[0])) plcCode2Flag = null;
if (StringUtils.isEmpty(plcCode2Data) || !plcCode2Data.equals(plcCodeArr[1])) plcCode2Data = null;
if (null == this.limit || !this.limit.equals(limit)) this.limit = null;
if (!StringUtils.isEmpty(plcCode2Flag) && !StringUtils.isEmpty(plcCode2Data) && null != this.limit) return this;
if (StringUtils.isEmpty(this.limit) || !this.limit.equals(limit)) this.limit = null;
if (StringUtils.isEmpty(this.scanCellCode) || !this.scanCellCode.equals(scanCellCode)) this.scanCellCode = null;
if (!StringUtils.isEmpty(plcCode2Flag) && !StringUtils.isEmpty(plcCode2Data) && !StringUtils.isEmpty(this.limit) && !StringUtils.isEmpty(this.scanCellCode)) return this;
isRetry = true;
plcCode2Flag = plcCodeArr[0];
plcCode2Data = plcCodeArr[1];
this.limit = limit;
this.scanCellCode = scanCellCode;
return this;
}
@ -47,7 +52,7 @@ public class SxThirdPartyPlcCollectCellTaktHandler extends SxThirdPartyPlcCollec
while (isOpen) {
if (StringUtils.isEmpty(plcCode2Flag) || StringUtils.isEmpty(plcCode2Data) || null == limit) continue;
if (StringUtils.isEmpty(plcCode2Flag) || StringUtils.isEmpty(plcCode2Data) || StringUtils.isEmpty(limit) || StringUtils.isEmpty(scanCellCode)) continue;
if (isRetry || null == filterChain) instanceFilterChain();
@ -62,7 +67,7 @@ public class SxThirdPartyPlcCollectCellTaktHandler extends SxThirdPartyPlcCollec
.add(new SxThirdPartyPlcCollectReadPlcStepService(plcCode2Flag).targetValue(new StringJoiner(MesPcnExtConstWords.COMMA).add(CommonEnumUtil.TRUE_OR_FALSE.TRUE.name().toLowerCase()).add(CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValueStr()).toString()))
.add(new SxThirdPartyPlcCollectReadPlcStepService(plcCode2Data))
.add(new SxThirdPartyPlcCollectWritePlcStepService(plcCode2Flag).targetValue(MesPcnExtConstWords.ZERO_STR))
.add(new SxThirdPartyPlcCollectCellTaktStepService().targetField(plcCode2Data).limit(limit));
.add(new SxThirdPartyPlcCollectCellTaktStepService().targetField(plcCode2Data).limit(limit).scanCellCode(scanCellCode));
isRetry = false;
}

@ -55,7 +55,7 @@ public class SxThirdPartyPlcCollectCellTaktService implements ISxThirdPartyPlcCo
}
private Map<String, Object> getWorkCellTaktCollectPlcCfgList(String organizeCode, String limitCfg) {
String value = "{\"PLC_CODE\":\"%s\", \"LIMIT\":\"%s\"}";
String value = "{\"PLC_CODE\":\"%s\", \"LIMIT\":\"%s\", \"workCellCode\":\"%s\"}";
List<SxWorkCellTaktCollectPlcCfg> workCellTaktCollectPlcCfgList = workCellTaktCollectPlcCfgRepository.findByProperty(
new String[]{MesPcnExtConstWords.ORGANIZE_CODE, MesPcnExtConstWords.IS_DELETED, MesPcnExtConstWords.IS_VALID, MesPcnExtConstWords.STATUS},
new Object[]{organizeCode, CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue(), CommonEnumUtil.IS_VAILD.VAILD.getValue(), CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue()});
@ -67,7 +67,7 @@ public class SxThirdPartyPlcCollectCellTaktService implements ISxThirdPartyPlcCo
Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(SxWorkCellTaktCollectPlcCfg::getPlcCode))), ArrayList::new));
return CollectionUtils.isEmpty(workCellTaktCollectPlcCfgList) ? new HashMap<>() :
workCellTaktCollectPlcCfgList.stream().filter(o -> null != o).collect(Collectors.toMap(o ->
new StringJoiner(MesPcnExtConstWords.COLON).add(MesPcnExtConstWords.CELL_TAKT).add(organizeCode).add(o.getWorkCenterCode()).add(o.getWorkCellCode()).toString(), o -> String.format(value, o.getPlcCode(), limitCfg)));
new StringJoiner(MesPcnExtConstWords.COLON).add(MesPcnExtConstWords.CELL_TAKT).add(organizeCode).add(o.getWorkCenterCode()).add(o.getWorkCellCode()).toString(), o -> String.format(value, o.getPlcCode(), limitCfg, o.getScanCellCode())));
}
}

@ -1,6 +1,7 @@
package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.busi.collect;
import cn.estsh.i3plus.ext.mes.pcn.api.busi.ISxThirdPartyPlcCollectDataStepService;
import cn.estsh.i3plus.ext.mes.pcn.api.busi.jx.IJxPlcExtService;
import cn.estsh.i3plus.ext.mes.pcn.api.busi.jx.IJxWorkCellTaktCollectRecordService;
import cn.estsh.i3plus.ext.mes.pcn.pojo.bean.SxWorkCellTaktCollectRecord;
import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtConstWords;
@ -13,6 +14,7 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.util.StringUtils;
import java.util.Map;
import java.util.StringJoiner;
/**
* PLC------
@ -22,12 +24,17 @@ public class SxThirdPartyPlcCollectCellTaktStepService implements ISxThirdPartyP
private IJxWorkCellTaktCollectRecordService workCellTaktCollectRecordService;
private IJxPlcExtService plcExtService;
protected String targetField;
protected String limit;
protected String scanCellCode;
public SxThirdPartyPlcCollectCellTaktStepService() {
this.workCellTaktCollectRecordService = (IJxWorkCellTaktCollectRecordService) SpringContextsUtil.getBean("jxWorkCellTaktCollectRecordService");
this.plcExtService = (IJxPlcExtService) SpringContextsUtil.getBean("jxPlcExtService");
}
public SxThirdPartyPlcCollectCellTaktStepService targetField(String targetField) {
@ -40,6 +47,11 @@ public class SxThirdPartyPlcCollectCellTaktStepService implements ISxThirdPartyP
return this;
}
public SxThirdPartyPlcCollectCellTaktStepService scanCellCode(String scanCellCode) {
this.scanCellCode = scanCellCode;
return this;
}
@Override
public StepResult exec(StepResult stepResult) {
@ -54,6 +66,20 @@ public class SxThirdPartyPlcCollectCellTaktStepService implements ISxThirdPartyP
workCellTaktCollectRecord.setWorkCenterCode(workCenterCode);
workCellTaktCollectRecord.setWorkCellCode(workCellCode);
workCellTaktCollectRecord.setWorkTakt(String.valueOf(MathOperation.div(new Double(targetValue), new Double(10))));
String key = new StringJoiner(MesPcnExtConstWords.COLON).add(MesPcnExtConstWords.CELL_TAKT).add(organizeCode).add(workCenterCode).add(scanCellCode).toString();
String timeShiftQty = plcExtService.getCachedData(key, MesPcnExtConstWords.TIME_SHIFT_QTY);
String partData = plcExtService.getCachedData(key, MesPcnExtConstWords.PART_NO);
String[] timeShiftQtyArr = !StringUtils.isEmpty(timeShiftQty) ? timeShiftQty.split(MesPcnExtConstWords.AND) : null;
String[] partDataArr = !StringUtils.isEmpty(partData) ? partData.split(MesPcnExtConstWords.AND) : null;
workCellTaktCollectRecord.setWorkTime(null != timeShiftQtyArr ? timeShiftQtyArr[0] : null);
workCellTaktCollectRecord.setShiftCode(null != timeShiftQtyArr ? timeShiftQtyArr[1] : null);
workCellTaktCollectRecord.setWorkerQty(null != timeShiftQtyArr ? new Double(timeShiftQtyArr[2]) : new Double(1));
workCellTaktCollectRecord.setPartNo(null != partDataArr ? partDataArr[0] : null);
workCellTaktCollectRecord.setPartNameRdd(null != partDataArr ? partDataArr[1] : null);
workCellTaktCollectRecord.setStandardWork(null != partDataArr ? new Double(partDataArr[2]) : new Double(0));
workCellTaktCollectRecord.setScanCellCode(scanCellCode);
workCellTaktCollectRecord.setOrganizeCode(organizeCode);
workCellTaktCollectRecord.setSystemSyncStatus(MesPcnExtEnumUtil.IF_SYNC_STATUS.NO_SYNC.getValue());
ConvertBean.serviceModelInitialize(workCellTaktCollectRecord, MesPcnExtConstWords.JOB);

@ -702,11 +702,28 @@ public class JxProdBusiStrategyCommonService implements IJxProdBusiStrategyServi
String workTime = shiftProdCenterRecordService.getWorkTime(shiftDb.getStartTime(), shiftDb.getEndTime());
if (StringUtils.isEmpty(workTime) || !workTime.equals(workCenterExtDb.getWorkTime())) return stepResult.msg(String.format("生产线[%s]需要重新启动班次,操作失败", params.getWorkCenterCode()));
//缓存节拍采集工位需要的人数信息
doCacheData2CellTakt(params, workCenterExtDb);
params.workCenterExtDb(workCenterExtDb);
return stepResult.isCompleted(true);
}
private void doCacheData2CellTakt(JxProdBusiStrategyParamsBuilder params, MesWorkCenterExt workCenterExtDb) {
String key = new StringJoiner(MesPcnExtConstWords.COLON).add(MesPcnExtConstWords.CELL_TAKT).add(params.getOrganizeCode()).add(params.getWorkCenterCode()).add(params.getWorkCellCode()).toString();
WorkCellDataCacheDispatch dispatch = new WorkCellDataCacheDispatch.builder().key(key).item(MesPcnExtConstWords.TIME_SHIFT_QTY).org(params.getOrganizeCode()).build().get();
if (!StringUtils.isEmpty(dispatch.getValue()) && dispatch.getValue().contains(new StringJoiner(MesPcnExtConstWords.AND).add(workCenterExtDb.getWorkTime()).add(workCenterExtDb.getShiftCode()).toString())) return;
new WorkCellDataCacheDispatch.builder().key(key).item(MesPcnExtConstWords.TIME_SHIFT_QTY)
.value(new StringJoiner(MesPcnExtConstWords.AND).add(workCenterExtDb.getWorkTime()).add(workCenterExtDb.getShiftCode()).add(getWorkQtyByPm(workCenterExtDb)).toString())
.timeSecond(MesPcnEnumUtil.EXPIRE_TIME.NEVER.getValue()).org(params.getOrganizeCode()).build().save();
}
private String getWorkQtyByPm(MesWorkCenterExt workCenterExtDb) {
MesShiftProdCenterPm shiftProdCenterPmDb = shiftProdCenterRecordService.getMesShiftProdCenterPm(workCenterExtDb.getOrganizeCode(), workCenterExtDb.getWorkCenterCode(), workCenterExtDb.getShiftCode(), workCenterExtDb.getWorkTime());
return (null != shiftProdCenterPmDb && !StringUtils.isEmpty(shiftProdCenterPmDb.getWorkerQty())) ? shiftProdCenterPmDb.getWorkerQty().toString() : (!StringUtils.isEmpty(workCenterExtDb.getWorkerQty()) ? workCenterExtDb.getWorkerQty().toString() : "1");
}
private void getPartDb(JxProdBusiStrategyParamsBuilder params) {
MesPart partDb = partExtService.getPart(params.getOrganizeCode(), params.getOrderModel().getPartNo());
if (null != partDb) params.setPartDb(partDb);

@ -1,11 +1,16 @@
package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.busi.step.jx;
import cn.estsh.i3plus.ext.mes.pcn.api.base.IPartExtService;
import cn.estsh.i3plus.ext.mes.pcn.api.busi.jx.IJxPlcExtService;
import cn.estsh.i3plus.ext.mes.pcn.pojo.bean.MesPartExt;
import cn.estsh.i3plus.ext.mes.pcn.pojo.model.WorkOrderExtModel;
import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtConstWords;
import cn.estsh.i3plus.mes.pcn.actor.shipping.dispatch.IFsmCommonService;
import cn.estsh.i3plus.mes.pcn.api.iservice.base.IModuleService;
import cn.estsh.i3plus.mes.pcn.serviceimpl.base.BaseStepService;
import cn.estsh.i3plus.mes.pcn.serviceimpl.busi.dispatch.cachedispatch.WorkCellDataCacheDispatch;
import cn.estsh.i3plus.platform.common.util.MesPcnConstWords;
import cn.estsh.i3plus.pojo.base.enumutil.MesPcnEnumUtil;
import cn.estsh.i3plus.pojo.mes.bean.MesPlc;
import cn.estsh.i3plus.pojo.mes.model.StationRequestBean;
import cn.estsh.i3plus.pojo.mes.model.StationResultBean;
@ -37,6 +42,9 @@ public class JxCenterPlcPassStepService extends BaseStepService {
@Autowired
private IJxPlcExtService plcExtService;
@Autowired
private IPartExtService partExtService;
@Override
public StepResult execute(StationRequestBean reqBean) {
@ -70,13 +78,36 @@ public class JxCenterPlcPassStepService extends BaseStepService {
if (reqBean.getDataMap().containsKey(MesPcnExtConstWords.PLC_PASS_VALUE)) reqBean.getDataMap().remove(MesPcnExtConstWords.PLC_PASS_VALUE);
log.info("工厂{}生产线{}工位{}: --- STEP EXECUTE --- JxCenterPlcPassStepService --- SUCCESS ---", reqBean.getOrganizeCode(), reqBean.getWorkCenterCode(), reqBean.getWorkCellCode());
WorkOrderExtModel orderModel = getWorkOrderExtModel(reqBean);
if (null != orderModel) doCachePartInfo2CellTakt(reqBean, orderModel);
log.info("工厂{}生产线{}工位{}: --- STEP EXECUTE --- JxCenterPlcPassStepService --- PART_NO:{} --- SUCCESS ---", reqBean.getOrganizeCode(), reqBean.getWorkCenterCode(), reqBean.getWorkCellCode(), null != orderModel ? orderModel.getPartNo() : MesPcnExtConstWords.EMPTY);
if (!forceCmd) return execSuccessCompleteAndSendMsgReturn(reqBean, resultBean,
String.format("%s产线放行成功!", StringUtils.isEmpty(reqBean.getProductSn()) ? String.format("管理编码[%s]", getManageCode(reqBean.getTray(), 1)) : String.format("产品条码[%s]", reqBean.getProductSn())));
else return execSuccessCompleteAndSendMsgReturn(reqBean, resultBean, "产线强制放行成功!");
}
private void doCachePartInfo2CellTakt(StationRequestBean reqBean, WorkOrderExtModel orderModel) {
String key = new StringJoiner(MesPcnExtConstWords.COLON).add(MesPcnExtConstWords.CELL_TAKT).add(reqBean.getOrganizeCode()).add(reqBean.getWorkCenterCode()).add(reqBean.getWorkCellCode()).toString();
WorkCellDataCacheDispatch dispatch = new WorkCellDataCacheDispatch.builder().key(key).item(MesPcnExtConstWords.PART_NO).org(reqBean.getOrganizeCode()).build().get();
if (!StringUtils.isEmpty(dispatch.getValue()) && dispatch.getValue().split(MesPcnExtConstWords.AND)[0].equals(orderModel.getPartNo())) return;
new WorkCellDataCacheDispatch.builder().key(key).item(MesPcnExtConstWords.PART_NO)
.value(new StringJoiner(MesPcnExtConstWords.AND).add(orderModel.getPartNo()).add(orderModel.getPartNameRdd()).add(getStandardWork(reqBean.getOrganizeCode(), orderModel.getPartNo())).toString())
.timeSecond(MesPcnEnumUtil.EXPIRE_TIME.NEVER.getValue()).org(reqBean.getOrganizeCode()).build().save();
}
private String getStandardWork(String organizeCode, String partNo) {
MesPartExt partExtDb = partExtService.getPartExt(organizeCode, partNo);
return (null != partExtDb && !StringUtils.isEmpty(partExtDb.getStandardWork())) ? partExtDb.getStandardWork().toString() : MesPcnExtConstWords.ZERO_STR;
}
private WorkOrderExtModel getWorkOrderExtModel(StationRequestBean reqBean) {
return !reqBean.getDataMap().containsKey(MesPcnExtConstWords.WORK_ORDER) ? null :
JSONObject.parseObject(JSONObject.toJSONString(reqBean.getDataMap().get(MesPcnExtConstWords.WORK_ORDER)), WorkOrderExtModel.class);
}
private MesPlc getPlcDb(StationRequestBean reqBean, StationResultBean resultBean, String plcCode) {
String plcStr = (String) doHandlePlcData(reqBean, resultBean, plcCode, 1, null);
MesPlc plcDb = !StringUtils.isEmpty(plcStr) ? JSONObject.parseObject(plcStr, MesPlc.class) : plcExtService.getPlcDb(reqBean.getOrganizeCode(), plcCode);

@ -42,6 +42,10 @@ public class SxWorkCellTaktCollectPlcCfg extends BaseBean implements Serializabl
@ApiParam("工作中心代码")
private String workCellCode;
@Column(name = "SCAN_CELL_CODE")
@ApiParam("扫码工位代码")
private String scanCellCode;
@Column(name = "PLC_CODE")
@ApiParam("PLC代码")
private String plcCode;

@ -47,6 +47,36 @@ public class SxWorkCellTaktCollectRecord extends BaseBean implements Serializabl
@ApiParam("生产节拍")
private String workTakt;
@Column(name = "SCAN_CELL_CODE")
@ApiParam("扫码工位代码")
private String scanCellCode;
@Column(name = "SHIFT_CODE")
@ApiParam("班次代码")
private String shiftCode;
@Column(name = "WORK_TIME")
@ApiParam("作业时间")
private String workTime;
@Column(name = "PART_NO")
@ApiParam("物料编码")
private String partNo;
@Column(name = "PART_NAME_RDD")
@ApiParam("物料名称")
private String partNameRdd;
@Column(name = "STANDARD_WORK", columnDefinition = "decimal(18,8)")
@ColumnDefault("0")
@ApiParam("标准工数")
private Double standardWork;
@Column(name = "WORKER_QTY", columnDefinition = "decimal(18,8)")
@ColumnDefault("0")
@ApiParam("作业人数")
private Double workerQty;
@Column(name = "SYSTEM_SYNC_STATUS")
@ColumnDefault("2")
@ApiParam(value = "系统同步标志")

@ -1031,6 +1031,8 @@ public class MesPcnExtConstWords {
//工位节拍
public final static String CELL_TAKT = "CellTakt";
//作业时间班次人数
public final static String TIME_SHIFT_QTY = "TIME_SHIFT_QTY";
//生产数据
public final static String PRODUCT_DATA = "ProductData";

Loading…
Cancel
Save