Merge branch 'dev-temp-workorder-report' into test

tags/yfai-pcn-ext-v2.5
王杰 5 months ago
commit e12c33f573

@ -0,0 +1,36 @@
package cn.estsh.i3plus.ext.mes.pcn.api.base;
import cn.estsh.i3plus.pojo.mes.bean.MesMediaFileCfg;
import io.swagger.annotations.ApiOperation;
import java.util.List;
import java.util.Map;
/**
* @Description :
* @Reference :
* @Author : wangjie
* @CreateDate 2024/6/13 15:18
* @Modify:
**/
public interface IMesMediaFileCfgService {
@ApiOperation(value = "根据ID查询资源文件信息")
MesMediaFileCfg getMediaFileCfg(String organizeCode, Long id);
@ApiOperation(value = "根据ID查询资源文件信息")
MesMediaFileCfg getMediaFileCfg(String organizeCode, String idStr);
@ApiOperation(value = "根据ID查询资源文件信息")
String getMediaFileUrl(String organizeCode, Long id);
@ApiOperation(value = "根据ID查询资源文件信息")
String getMediaFileUrl(String organizeCode, String idStr);
@ApiOperation(value = "根据ID集合查询资源文件信息")
List<MesMediaFileCfg> getMediaFileCfgList(String organizeCode, List<Long> idList);
@ApiOperation(value = "根据ID集合查询资源文件信息")
Map<Long, String> getMediaFileCfgMap(String organizeCode, List<Long> idList);
}

@ -1,11 +1,13 @@
package cn.estsh.i3plus.ext.mes.pcn.api.base;
import cn.estsh.i3plus.pojo.mes.bean.MesCraft;
import cn.estsh.i3plus.pojo.mes.bean.MesWorkCell;
import cn.estsh.i3plus.pojo.mes.bean.MesWorkCellExtendCfg;
import cn.estsh.i3plus.pojo.mes.bean.MesWorkCenter;
import io.swagger.annotations.ApiOperation;
import java.util.List;
import java.util.Map;
public interface IMesProdOrgExtService {
@ -24,6 +26,24 @@ public interface IMesProdOrgExtService {
@ApiOperation(value = "根据生产线代码查询工位信息")
List<MesWorkCell> getWorkCellList(String organizeCode, String workCenterCode);
@ApiOperation(value = "根据生产线代码查询生产线信息")
List<MesWorkCenter> getWorkCenterList(String organizeCode, List<String> workCenterCodeList);
@ApiOperation(value = "根据生产线代码查询生产线信息")
Map<String, String> getWorkCenterCodeMap(String organizeCode, List<String> workCenterCodeList);
@ApiOperation(value = "根据工位代码查询工位信息")
List<MesWorkCell> getWorkCellList(String organizeCode, List<String> workCellCodeList);
@ApiOperation(value = "根据工位代码查询工位信息")
Map<String, String> getWorkCellCodeMap(String organizeCode, List<String> workCellCodeList);
@ApiOperation(value = "根据工艺代码查询工艺信息")
List<MesCraft> getCraftList(String organizeCode, List<String> craftCodeList);
@ApiOperation(value = "根据工艺代码查询工艺信息")
Map<String, String> getCraftCodeMap(String organizeCode, List<String> craftCodeList);
@ApiOperation(value = "根据子生产线代码,子工位代码,关系类型查询主子工位关系信息")
MesWorkCellExtendCfg getWorkCellExtendCfg(String organizeCode, String workCenterCodeBak, String workCellCodeBak, Integer extendType);

@ -1,6 +1,7 @@
package cn.estsh.i3plus.ext.mes.pcn.api.base;
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProdShiftContext;
import cn.estsh.i3plus.pojo.base.bean.ListPager;
import cn.estsh.i3plus.pojo.base.common.Pager;
import cn.estsh.i3plus.pojo.mes.bean.MesProdShiftRecord;
@ -40,4 +41,10 @@ public interface IMesProdShiftRecordService {
@ApiOperation(value = "获取展示组件班组班次内容")
List<StationKvBean> getShiftRecordStationKvBeans(String organizeCode, String workCenterCode);
@ApiOperation(value = "获取生产线的当前班组班次信息")
MesProdShiftContext getMesProdShiftKvBean(String organizeCode, String workCenterCode);
@ApiOperation(value = "封装当前班组班次信息")
MesProdShiftContext getMesProdShiftKvBean(List<StationKvBean> prodShiftDataContext);
}

@ -39,4 +39,7 @@ public interface IMesConfigService {
@ApiOperation(value = "获取配置信息")
List<MesConfig> findMesConfigList(String organizeCode, String cfgCode);
@ApiOperation(value = "获取配置信息")
MesConfig getCfgValueByCode(String organizeCode, String cfgCode);
}

@ -11,6 +11,8 @@ import java.util.List;
import java.util.Map;
public interface IMesProduceSnExtService {
@ApiOperation(value = "装箱防错获取正常的条码")
MesProduceSn getProduceSnForBox(String produceSn ,String PartNo,String organizeCode);
@ApiOperation(value = "根据零件条码查询零件条码信息")
List<MesProduceSn> getProduceSnList(String organizeCode, List<String> productSnList);
@ -18,6 +20,9 @@ public interface IMesProduceSnExtService {
@ApiOperation(value = "根据零件条码查询零件条码信息")
List<MesProduceSn> getProduceSnList(String organizeCode, String productSn);
@ApiOperation(value = "根据零件条码查询零件条码信息, 创建时间倒序")
List<MesProduceSn> getProduceSnListCreateDatetimeDesc(String organizeCode, String productSn);
@ApiOperation(value = "根据客户条码查询零件条码信息[排序]")
MesProduceSn getProduceSnByCustSn(String organizeCode, String custSn);

@ -42,12 +42,12 @@ public interface IMesProductionCustomContextStepService {
@ApiOperation(value = "发送工步内容")
void sendStepContextMessage(StationRequestBean reqBean, List<StationKvBean> resultList);
@ApiOperation(value = "验证上下文班次班组信息是否存在")
Boolean checkProdShiftDataIsExistContext(String orgainzeCode, String workCenterCode);
@ApiOperation(value = "获取上下文班次班组信息")
List<StationKvBean> getProdShiftDataContext(String orgainzeCode, String workCenterCode);
@ApiOperation(value = "验证上下文班次班组信息是否存在")
Boolean checkProdShiftDataIsExistContext(String orgainzeCode, String workCenterCode);
@ApiOperation(value = "保存上下文班次班组信息", notes = "[JSON]List<StationKvBean>")
Boolean dispatchProdShiftDataContext(String orgainzeCode, String workCenterCode, List<StationKvBean> prodShiftDatList);
@ -57,18 +57,18 @@ public interface IMesProductionCustomContextStepService {
@ApiOperation(value = "获取上下文工位加工数统计信息")
List<StationKvBean> getProductionStatisticsContext(StationRequestBean reqBean);
@ApiOperation(value = "封装加工数信息")
List<StationKvBean> getProductionStatisticsContext(MesProdShiftContext mesProdShiftKvBean, String countStr);
@ApiOperation(value = "保存上下文工位加工数统计信息", notes = "[JSON]List<StationKvBean>")
Boolean dispatchProductionStatisticsContext(StationRequestBean reqBean, List<StationKvBean> prodShiftDatList);
@ApiOperation(value = "新增上下文工位加工数统计信息")
Integer dispatchProductionStatisticsContext(StationRequestBean reqBean, int count);
Integer dispatchProductionStatisticsContext(StationRequestBean reqBean, int count, MesProdShiftContext mesProdShiftKvBean);
@ApiOperation(value = "删除上下文工位加工数统计信息")
void removeProductionStatisticsContext(StationRequestBean reqBean);
@ApiOperation(value = "获取生产线的当前班组班次信息")
MesProdShiftContext getMesProdShiftKvBean(String organizeCode, String workCenterCode);
@ApiOperation(value = "根据装配件信息获取可复用条码")
String getRepeatAssemblySn(String organizeCode, String workCenterCode, String workCellCode, MesProductionAssemblyContext productionAssemblyContext);

@ -2,6 +2,7 @@ package cn.estsh.i3plus.ext.mes.pcn.api.busi;
import cn.estsh.i3plus.pojo.mes.bean.MesProductionRecord;
import cn.estsh.i3plus.pojo.mes.model.MesProductionRecordModel;
import cn.estsh.impp.framework.boot.util.ResultBean;
import io.swagger.annotations.ApiOperation;
import java.util.List;
@ -18,6 +19,9 @@ public interface IMesProductionRecordService {
@ApiOperation(value = "根据零件条码查询加工记录信息")
List<MesProductionRecord> findProductionRecordList(String organizeCode, String productSn);
@ApiOperation(value = "查询加工记录, 根据完成时间倒序")
List<MesProductionRecord> findProductionRecordListCompleteDateTimeDesc(String organizeCode, String productSn);
@ApiOperation(value = "根据零件条码,零件编码查询加工记录信息")
List<MesProductionRecord> findProductionRecordList(String organizeCode, String productSn, String partNo);
@ -34,8 +38,8 @@ public interface IMesProductionRecordService {
void updateProductionRecord(String organizeCode, String userName, Long id, String errorMsg);
@ApiOperation(value = "根据零件条码查询加工记录信息")
List<MesProductionRecordModel> findMesProductionRecordList(String organizeCode, String productSn);
@ApiOperation(value = "查询加工记录信息PDA报表")
ResultBean queryMesProductionRecordReport(String organizeCode, String productSn);
@ApiOperation(value = "更新加工记录")
void updateProductionRecord(List<MesProductionRecord> recordList,String userName,Integer reportStatus,String msg);

@ -1,33 +0,0 @@
package cn.estsh.i3plus.ext.mes.pcn.api.busi;
import cn.estsh.i3plus.pojo.mes.bean.MesEquipmentVariable;
import cn.estsh.i3plus.pojo.mes.model.MesEquipVariableRwResult;
import cn.estsh.i3plus.pojo.mes.model.StationRequestBean;
import org.springframework.beans.factory.annotation.Autowired;
/**
* @Description :
* @Author : zxw
**/
public interface IWriteVariableService {
/**
*
* @param value
* @param equipmentVariable
* @param kepwareFlag
*/
MesEquipVariableRwResult writeVariable(StationRequestBean reqBean, String value, MesEquipmentVariable equipmentVariable, String kepwareFlag, Integer foreignKey, Integer index,Integer maxRetryTimes);
/**
*
* @param reqBean
* @param value
* @param foreignKey
* @param index
* @return
*/
String transferValue(StationRequestBean reqBean, String value, Integer foreignKey, Integer index);
}

@ -63,12 +63,12 @@ public class MesBusiController {
}
@GetMapping("/mesProductionRecord/query")
@ApiOperation(value = "查询加工记录信息")
public ResultBean queryMesProductionRecord(MesProductionRecord mesProductionRecord) {
@ApiOperation(value = "查询加工记录信息PDA报表")
public ResultBean queryMesProductionRecordReport(MesProductionRecord mesProductionRecord) {
try {
ValidatorBean.checkNotNull(mesProductionRecord.getOrganizeCode(), "工厂代码不能为空");
ValidatorBean.checkNotNull(mesProductionRecord.getProductSn(), "零件条码不能为空");
return ResultBean.success("查询成功").setResultList(mesProductionRecordService.findMesProductionRecordList(mesProductionRecord.getOrganizeCode(), mesProductionRecord.getProductSn()));
return mesProductionRecordService.queryMesProductionRecordReport(mesProductionRecord.getOrganizeCode(), mesProductionRecord.getProductSn());
} catch (ImppBusiException imppException) {
return ResultBean.fail(imppException);
} catch (Exception e) {

@ -89,20 +89,22 @@ public class MesReportWorkByPreDayJob extends BaseMesScheduleJob {
w -> w.getWorkCenterCode().equalsIgnoreCase(mesWorkOrder.getWorkCenterCode())
&& w.getPartNo().equalsIgnoreCase(mesWorkOrder.getPartNo())).collect(Collectors.toList());
workOrderService.doPcnJobProductReport(mesProductionRecords, mesShiftList, wmsJobParamModel.getOrganizeCode(), userName, mesWorkOrder);
}
for (MesProductionRecord mesProductionRecord : mesProductionRecordList) {
if(StringUtil.isEmpty(mesProductionRecord.getWorkOrderNo())){
List<MesWorkOrder> collect = mesWorkOrders.stream().filter(w -> w.getWorkCenterCode().equalsIgnoreCase(mesProductionRecord.getWorkCenterCode())
&& w.getPartNo().equalsIgnoreCase(mesProductionRecord.getPartNo())).collect(Collectors.toList());
if (!CollectionUtils.isEmpty(collect)){
mesProductionRecord.setWorkOrderNo(collect.get(0).getWorkOrderNo());
for (MesProductionRecord mesProductionRecord : mesProductionRecords) {
if(StringUtil.isEmpty(mesProductionRecord.getWorkOrderNo())){
List<MesWorkOrder> collect = mesWorkOrders.stream().filter(w -> w.getWorkCenterCode().equalsIgnoreCase(mesProductionRecord.getWorkCenterCode())
&& w.getPartNo().equalsIgnoreCase(mesProductionRecord.getPartNo())).collect(Collectors.toList());
if (!CollectionUtils.isEmpty(collect)){
mesProductionRecord.setWorkOrderNo(collect.get(0).getWorkOrderNo());
}
}
mesProductionRecord.setReportStatus(MesExtEnumUtil.REPORT_STATUS.REPORT_STATUS_20.getValue());
mesProductionRecord.setSystemSyncStatus(CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue());
ConvertBean.serviceModelUpdate(mesProductionRecord, userName);
}
mesProductionRecord.setReportStatus(MesExtEnumUtil.REPORT_STATUS.REPORT_STATUS_20.getValue());
mesProductionRecord.setSystemSyncStatus(CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue());
ConvertBean.serviceModelUpdate(mesProductionRecord, userName);
productionRecordRao.saveAll(mesProductionRecords);
}
productionRecordRao.saveAll(mesProductionRecordList);
} catch (ImppBusiException e) {
LOGGER.error("产线:{}报工失败:{}", workCenterCode, e.getErrorDetail());
}

@ -0,0 +1,72 @@
package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.base;
import cn.estsh.i3plus.ext.mes.pcn.api.base.IMesMediaFileCfgService;
import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtConstWords;
import cn.estsh.i3plus.pojo.base.bean.DdlPackBean;
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
import cn.estsh.i3plus.pojo.base.tool.DdlPreparedPack;
import cn.estsh.i3plus.pojo.mes.bean.MesMediaFileCfg;
import cn.estsh.i3plus.pojo.mes.repository.MesMediaFileCfgRepository;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Slf4j
@Service
public class MesMediaFileCfgService implements IMesMediaFileCfgService {
@Autowired
private MesMediaFileCfgRepository mediaFileCfgRepository;
@Override
public MesMediaFileCfg getMediaFileCfg(String organizeCode, Long id) {
if (StringUtils.isEmpty(organizeCode) || StringUtils.isEmpty(id)) return null;
MesMediaFileCfg mediaFileCfg = mediaFileCfgRepository.getByProperty(
new String[]{MesPcnExtConstWords.ORGANIZE_CODE, MesPcnExtConstWords.IS_DELETED, MesPcnExtConstWords.IS_VALID, MesPcnExtConstWords.ID},
new Object[]{organizeCode, CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue(), CommonEnumUtil.IS_VAILD.VAILD.getValue(), id});
return (null == mediaFileCfg || StringUtils.isEmpty(mediaFileCfg.getFileUrl())) ? null : mediaFileCfg;
}
@Override
public MesMediaFileCfg getMediaFileCfg(String organizeCode, String idStr) {
Long id = null;
try { id = Long.valueOf(idStr);} catch (NumberFormatException e) {}
return getMediaFileCfg(organizeCode, id);
}
@Override
public String getMediaFileUrl(String organizeCode, Long id) {
MesMediaFileCfg mediaFileCfg = getMediaFileCfg(organizeCode, id);
return (null == mediaFileCfg || StringUtils.isEmpty(mediaFileCfg.getFileUrl())) ? null : mediaFileCfg.getFileUrl();
}
@Override
public String getMediaFileUrl(String organizeCode, String idStr) {
MesMediaFileCfg mediaFileCfg = getMediaFileCfg(organizeCode, idStr);
return (null == mediaFileCfg || StringUtils.isEmpty(mediaFileCfg.getFileUrl())) ? null : mediaFileCfg.getFileUrl();
}
@Override
public List<MesMediaFileCfg> getMediaFileCfgList(String organizeCode, List<Long> idList) {
if (StringUtils.isEmpty(organizeCode) || CollectionUtils.isEmpty(idList)) return null;
if (idList.size() != 1) idList = idList.stream().filter(o -> !StringUtils.isEmpty(o)).distinct().collect(Collectors.toList());
DdlPackBean packBean = DdlPackBean.getDdlPackBean(organizeCode);
if (idList.size() == 1) DdlPreparedPack.getNumEqualPack(idList.get(0), MesPcnExtConstWords.ID, packBean);
else DdlPreparedPack.getInPackList(idList, MesPcnExtConstWords.ID, packBean);
return mediaFileCfgRepository.findByHqlWhere(packBean);
}
@Override
public Map<Long, String> getMediaFileCfgMap(String organizeCode, List<Long> idList) {
if (StringUtils.isEmpty(organizeCode) || CollectionUtils.isEmpty(idList)) return null;
List<MesMediaFileCfg> mediaFileCfgList = getMediaFileCfgList(organizeCode, idList);
if (CollectionUtils.isEmpty(mediaFileCfgList)) return null;
return mediaFileCfgList.stream().filter(o -> (null != o && !StringUtils.isEmpty(o.getFileUrl()))).collect(Collectors.toMap(MesMediaFileCfg::getId, MesMediaFileCfg::getFileUrl));
}
}

@ -2,11 +2,14 @@ package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.base;
import cn.estsh.i3plus.ext.mes.pcn.api.base.IMesProdOrgExtService;
import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtConstWords;
import cn.estsh.i3plus.pojo.base.bean.DdlPackBean;
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
import cn.estsh.i3plus.pojo.mes.bean.MesEquipmentVariable;
import cn.estsh.i3plus.pojo.base.tool.DdlPreparedPack;
import cn.estsh.i3plus.pojo.mes.bean.MesCraft;
import cn.estsh.i3plus.pojo.mes.bean.MesWorkCell;
import cn.estsh.i3plus.pojo.mes.bean.MesWorkCellExtendCfg;
import cn.estsh.i3plus.pojo.mes.bean.MesWorkCenter;
import cn.estsh.i3plus.pojo.mes.repository.MesCraftRepository;
import cn.estsh.i3plus.pojo.mes.repository.MesWorkCellExtendCfgRepository;
import cn.estsh.i3plus.pojo.mes.repository.MesWorkCellRepository;
import cn.estsh.i3plus.pojo.mes.repository.MesWorkCenterRepository;
@ -31,6 +34,9 @@ public class MesProdOrgExtService implements IMesProdOrgExtService {
private MesWorkCellRepository workCellRepository;
@Autowired
private MesCraftRepository craftRepository;
@Autowired
private MesWorkCellExtendCfgRepository workCellExtendCfgRepository;
@Override
@ -77,6 +83,71 @@ public class MesProdOrgExtService implements IMesProdOrgExtService {
}
@Override
public List<MesWorkCenter> getWorkCenterList(String organizeCode, List<String> workCenterCodeList) {
if (StringUtils.isEmpty(organizeCode) || CollectionUtils.isEmpty(workCenterCodeList)) return null;
if (workCenterCodeList.size() != 1) workCenterCodeList = workCenterCodeList.stream().filter(o -> !StringUtils.isEmpty(o)).distinct().collect(Collectors.toList());
DdlPackBean packBean = DdlPackBean.getDdlPackBean(organizeCode);
if (workCenterCodeList.size() == 1) DdlPreparedPack.getStringEqualPack(workCenterCodeList.get(0), MesPcnExtConstWords.WORK_CENTER_CODE, packBean);
else DdlPreparedPack.getInPackList(workCenterCodeList, MesPcnExtConstWords.WORK_CENTER_CODE, packBean);
return workCenterRepository.findByHqlWhere(packBean);
}
@Override
public Map<String, String> getWorkCenterCodeMap(String organizeCode, List<String> workCenterCodeList) {
if (StringUtils.isEmpty(organizeCode) || CollectionUtils.isEmpty(workCenterCodeList)) return null;
List<MesWorkCenter> workCenterList = getWorkCenterList(organizeCode, workCenterCodeList);
if (CollectionUtils.isEmpty(workCenterList)) return null;
workCenterList = workCenterList.stream().filter(o -> null != o).distinct().collect(
Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(MesWorkCenter::getWorkCenterCode))), ArrayList::new)
);
return workCenterList.stream().filter(o -> null != o).collect(Collectors.toMap(MesWorkCenter::getWorkCenterCode, MesWorkCenter::getWorkCenterName));
}
@Override
public List<MesWorkCell> getWorkCellList(String organizeCode, List<String> workCellCodeList) {
if (StringUtils.isEmpty(organizeCode) || CollectionUtils.isEmpty(workCellCodeList)) return null;
if (workCellCodeList.size() != 1) workCellCodeList = workCellCodeList.stream().filter(o -> !StringUtils.isEmpty(o)).distinct().collect(Collectors.toList());
DdlPackBean packBean = DdlPackBean.getDdlPackBean(organizeCode);
if (workCellCodeList.size() == 1) DdlPreparedPack.getStringEqualPack(workCellCodeList.get(0), MesPcnExtConstWords.WORK_CELL_CODE, packBean);
else DdlPreparedPack.getInPackList(workCellCodeList, MesPcnExtConstWords.WORK_CELL_CODE, packBean);
return workCellRepository.findByHqlWhere(packBean);
}
@Override
public Map<String, String> getWorkCellCodeMap(String organizeCode, List<String> workCellCodeList) {
if (StringUtils.isEmpty(organizeCode) || CollectionUtils.isEmpty(workCellCodeList)) return null;
List<MesWorkCell> workCellList = getWorkCellList(organizeCode, workCellCodeList);
if (CollectionUtils.isEmpty(workCellList)) return null;
workCellList = workCellList.stream().filter(o -> null != o).distinct().collect(
Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(
o -> new StringJoiner(MesPcnExtConstWords.AND).add(o.getWorkCenterCode()).add(o.getWorkCellCode()).toString()))), ArrayList::new)
);
return workCellList.stream().filter(o -> null != o).collect(Collectors.toMap(
o -> new StringJoiner(MesPcnExtConstWords.AND).add(o.getWorkCenterCode()).add(o.getWorkCellCode()).toString(), MesWorkCell::getWorkCellName));
}
@Override
public List<MesCraft> getCraftList(String organizeCode, List<String> craftCodeList) {
if (StringUtils.isEmpty(organizeCode) || CollectionUtils.isEmpty(craftCodeList)) return null;
if (craftCodeList.size() != 1) craftCodeList = craftCodeList.stream().filter(o -> !StringUtils.isEmpty(o)).distinct().collect(Collectors.toList());
DdlPackBean packBean = DdlPackBean.getDdlPackBean(organizeCode);
if (craftCodeList.size() == 1) DdlPreparedPack.getStringEqualPack(craftCodeList.get(0), MesPcnExtConstWords.CRAFT_CODE, packBean);
else DdlPreparedPack.getInPackList(craftCodeList, MesPcnExtConstWords.CRAFT_CODE, packBean);
return craftRepository.findByHqlWhere(packBean);
}
@Override
public Map<String, String> getCraftCodeMap(String organizeCode, List<String> craftCodeList) {
if (StringUtils.isEmpty(organizeCode) || CollectionUtils.isEmpty(craftCodeList)) return null;
List<MesCraft> craftList = getCraftList(organizeCode, craftCodeList);
if (CollectionUtils.isEmpty(craftList)) return null;
craftList = craftList.stream().filter(o -> null != o).distinct().collect(
Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(MesCraft::getCraftCode))), ArrayList::new)
);
return craftList.stream().filter(o -> null != o).collect(Collectors.toMap(MesCraft::getCraftCode, MesCraft::getCraftName));
}
@Override
public MesWorkCellExtendCfg getWorkCellExtendCfg(String organizeCode, String workCenterCodeBak, String workCellCodeBak, Integer extendType) {
if (StringUtils.isEmpty(organizeCode) || StringUtils.isEmpty(workCenterCodeBak) || StringUtils.isEmpty(workCellCodeBak) || StringUtils.isEmpty(extendType)) return null;
return workCellExtendCfgRepository.getByProperty(

@ -5,6 +5,7 @@ import cn.estsh.i3plus.ext.mes.pcn.api.base.IMesProdShiftRecordService;
import cn.estsh.i3plus.ext.mes.pcn.api.base.IMesShiftService;
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesProductionCustomContextStepService;
import cn.estsh.i3plus.ext.mes.pcn.apiservice.util.MesPcnException;
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProdShiftContext;
import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtConstWords;
import cn.estsh.i3plus.mes.pcn.util.StationKvBeanUtil;
import cn.estsh.i3plus.platform.common.convert.ConvertBean;
@ -256,6 +257,7 @@ public class MesProdShiftRecordServiceImpl implements IMesProdShiftRecordService
//获取展示组件班组班次内容
@Override
public List<StationKvBean> getShiftRecordStationKvBeans(String organizeCode, String workCenterCode) {
if (StringUtils.isEmpty(organizeCode) || StringUtils.isEmpty(workCenterCode)) return null;
// 获取班次信息 redis
List<StationKvBean> prodShiftDataContext = productionCustomContextStepService.getProdShiftDataContext(organizeCode, workCenterCode);
if (CollectionUtils.isEmpty(prodShiftDataContext)) {
@ -268,4 +270,29 @@ public class MesProdShiftRecordServiceImpl implements IMesProdShiftRecordService
}
return prodShiftDataContext;
}
//获取生产线的当前班组班次信息
@Override
public MesProdShiftContext getMesProdShiftKvBean(String organizeCode, String workCenterCode) {
List<StationKvBean> prodShiftDataContext = getShiftRecordStationKvBeans(organizeCode, workCenterCode);
if (CollectionUtils.isEmpty(prodShiftDataContext)) return null;
return getMesProdShiftKvBean(prodShiftDataContext);
}
//封装当前班组班次信息
@Override
public MesProdShiftContext getMesProdShiftKvBean(List<StationKvBean> prodShiftDataContext) {
if (CollectionUtils.isEmpty(prodShiftDataContext)) return null;
StationKvBean shiftGroupKvBean = prodShiftDataContext.stream().filter(stationKvBean -> com.google.common.base.Objects.equal(stationKvBean.getKey(), MesPcnExtConstWords.SHIFT_GROUP)).findFirst().orElse(null);
StationKvBean shiftCodeKvBean = prodShiftDataContext.stream().filter(stationKvBean -> com.google.common.base.Objects.equal(stationKvBean.getKey(), MesPcnExtConstWords.SHIFT_CODE)).findFirst().orElse(null);
MesProdShiftContext mesProdShiftContext = new MesProdShiftContext();
mesProdShiftContext.setShiftCode(shiftGroupKvBean == null ? null : shiftCodeKvBean.getValue());
mesProdShiftContext.setShiftGroup(shiftCodeKvBean == null ? null : shiftGroupKvBean.getValue());
return mesProdShiftContext;
}
}

@ -288,7 +288,10 @@ public class MesReworkTaskServiceImpl implements IMesReworkTaskService {
mesPartInspection.setNcStatus(MesExtEnumUtil.PART_INSPECTION_NC_STATUS.DISASSEMBLY.getValue());
}
mesPartInspection.setQmsSync(CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue());
ConvertBean.serviceModelUpdate(mesPartInspection, requestModel.getUserName());
/**
* bug 44178 NC
*/
// ConvertBean.serviceModelUpdate(mesPartInspection, requestModel.getUserName());
mesPartInspectionRepository.update(mesPartInspection);
}
}

@ -157,6 +157,8 @@ public class DcsForEquipmentServiceImpl implements IDcsForEquipmentService {
mesProductionRecord.setReportStatus(MesExtEnumUtil.REPORT_STATUS.REPORT_STATUS_30.getValue());
mesProductionRecord.setReportType(MesExtEnumUtil.MES_REPORT_TYPE.NO_REPORT.getValue());
mesProductionRecord.setOrganizeCode(organizeCode);
mesProductionRecord.setStartDateTime(TimeTool.getNowTime(true));
mesProductionRecord.setCompleteDateTime(TimeTool.getNowTime(true));
mesProductionRecord.setRemark("电测试:"+result);
ConvertBean.saveOrUpdate(mesProductionRecord,"电测试");
recordRao.insert(mesProductionRecord);

@ -1,5 +1,6 @@
package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.busi;
import cn.estsh.i3plus.ext.mes.pcn.api.base.IMesMediaFileCfgService;
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesAssemblyExtService;
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesProductionCustomContextStepService;
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesProductionProcessContextStepService;
@ -11,7 +12,10 @@ import cn.estsh.i3plus.pojo.base.bean.DdlPackBean;
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
import cn.estsh.i3plus.pojo.base.tool.DdlPreparedPack;
import cn.estsh.i3plus.pojo.mes.bean.*;
import cn.estsh.i3plus.pojo.mes.repository.*;
import cn.estsh.i3plus.pojo.mes.repository.MesAssemblyNosortCfgRepository;
import cn.estsh.i3plus.pojo.mes.repository.MesProductionAssemblyRepository;
import cn.estsh.i3plus.pojo.mes.repository.MesProductionAssemblyUniqueRepository;
import cn.estsh.i3plus.pojo.mes.repository.MesWorkOrderAssemblyRepository;
import cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
@ -47,7 +51,7 @@ public class MesAssemblyExtService implements IMesAssemblyExtService {
private IMesProductionProcessContextStepService productionProcessContextStepService;
@Autowired
private MesFileRepository fileRepository;
private IMesMediaFileCfgService mediaFileCfgService;
//【排序线】获取生产工单装配件绑定记录
@Override
@ -69,7 +73,7 @@ public class MesAssemblyExtService implements IMesAssemblyExtService {
o.getAssemblyStatus().compareTo(MesExtEnumUtil.ASSEMBLY_STATUS.ASSEMBLY_STATUS_20.getValue()) == 0))).collect(Collectors.toList());
//获取排序FILE文件URL
Map<Long, String> fileMap = getFileMap(prodRuleContext.getOrganizeCode(), filterSortFileIdList(unBindList));
Map<Long, String> fileMap = mediaFileCfgService.getMediaFileCfgMap(prodRuleContext.getOrganizeCode(), filterSortFileIdList(unBindList));
List<MesProductionAssemblySortContext> productionAssemblySortContextList = new ArrayList<>();
@ -177,7 +181,7 @@ public class MesAssemblyExtService implements IMesAssemblyExtService {
if (CollectionUtils.isEmpty(assemblyNosortCfgList)) return null;
//获取非排序FILE文件URL
Map<Long, String> fileMap = getFileMap(prodRuleContext.getOrganizeCode(), filterNosortFileIdList(assemblyNosortCfgList));
Map<Long, String> fileMap = mediaFileCfgService.getMediaFileCfgMap(prodRuleContext.getOrganizeCode(), filterNosortFileIdList(assemblyNosortCfgList));
List<MesProductionAssemblyNosortContext> productionAssemblyNosortContextList = new ArrayList<>();
@ -271,17 +275,6 @@ public class MesAssemblyExtService implements IMesAssemblyExtService {
return imageFileIdList;
}
//获取FILE文件URL
private Map<Long, String> getFileMap(String organizeCode, List<Long> fileIdList) {
if (StringUtils.isEmpty(organizeCode) || CollectionUtils.isEmpty(fileIdList)) return null;
fileIdList = fileIdList.stream().filter(o -> !StringUtils.isEmpty(o)).distinct().collect(Collectors.toList());
DdlPackBean packBean = DdlPackBean.getDdlPackBean(organizeCode);
if (fileIdList.size() == 1) DdlPreparedPack.getNumEqualPack(fileIdList.get(0), MesPcnExtConstWords.ID, packBean);
DdlPreparedPack.getInPackList(fileIdList, MesPcnExtConstWords.ID, packBean);
List<MesFile> fileDbList = fileRepository.findByHqlWhere(packBean);
return CollectionUtils.isEmpty(fileIdList) ? null : fileDbList.stream().filter(o -> (null != o && !StringUtils.isEmpty(o.getFileUrl()))).collect(Collectors.toMap(MesFile::getId, MesFile::getFileUrl));
}
//根据生产工单装配件清单ID分组
private Map<Long, List<MesProductionAssembly>> groupProductionAssembly(List<MesProductionAssembly> productionAssemblyList) {
return CollectionUtils.isEmpty(productionAssemblyList) ? null :

@ -147,7 +147,7 @@ public class MesBoxingErrorProofingService implements IMesBoxingErrorProofingSer
MesPcnException.throwMesBusiException("箱条码已封箱,不允许扫描零件条码,请检查数据!");
}
//校验条码规则
MesPart mesPart = getMesPart(mesPackageDetail, mesPackage, packingDefine);
MesPart mesPart = getMesPartNew(mesPackageDetail, mesPackage, packingDefine);
//包装规格明细
MesPackageDetail saveMesPackageDetail = getPackageDetail(mesPackageDetail, mesPart);
if (mesPackageDetail.getIsMemoryBoolean()) {
@ -232,7 +232,9 @@ public class MesBoxingErrorProofingService implements IMesBoxingErrorProofingSer
//校验是否重复扫描
List<MesPackageDetail> mesPackageDetails = getMesPackageDetailList(mesPackageDetail);
//校验条码是否符合规则
MesPart mesPart = getMesPart(mesPackageDetail, mesPackageDb, null);
//获取包装定义
MesPackingDefine packingDefine = getMesPackingDefine(mesPackageDetail);
MesPart mesPart = getMesPartNew(mesPackageDetail, mesPackageDb, packingDefine);
boolean exist = false;
for (MesPackageDetail packageDetail : mesPackageDetails) {
//替换条码是否已经存在
@ -281,9 +283,18 @@ public class MesBoxingErrorProofingService implements IMesBoxingErrorProofingSer
//获取包装定义明细
List<MesPackingDefineDetails> defineDetails = getMesPackingDefineDetails(mesPackageDetail.getOrganizeCode(), mesPackage.getPackageSn());
//校验是否包含
String partNo = getPartNo(mesPackageDetail, mesPackage, defineDetails);
// String partNo = getPartNo(mesPackageDetail, mesPackage, defineDetails);
//校验条码信息
String partNo = checkSn(mesPackageDetail, packingDefine, mesPackage, defineDetails);
//物料信息
return getPart(mesPackageDetail.getOrganizeCode(), partNo);
}
private MesPart getMesPartNew(MesPackageDetail mesPackageDetail, MesPackage mesPackage, MesPackingDefine packingDefine) {
//校验是否重复扫描
checkSerialNumber(mesPackageDetail);
//校验条码信息
checkSn(mesPackageDetail, packingDefine,partNo);
String partNo = checkSnNew(mesPackageDetail, packingDefine, mesPackage);
//物料信息
return getPart(mesPackageDetail.getOrganizeCode(), partNo);
}
@ -306,6 +317,17 @@ public class MesBoxingErrorProofingService implements IMesBoxingErrorProofingSer
return defineDetails;
}
private List<MesPackingDefineDetails> getMesPackingDefineDetailsNew(String organizeCode, String packCode,String partNo) {
DdlPackBean ddlPackBean = DdlPackBean.getDdlPackBean(organizeCode);
DdlPreparedPack.getStringEqualPack(packCode, "packCode", ddlPackBean);
DdlPreparedPack.getStringEqualPack(partNo, "partNo", ddlPackBean);
List<MesPackingDefineDetails> defineDetails = mesPackingDefineDetailsRDao.findByHqlWhere(ddlPackBean);
if (CollectionUtils.isEmpty(defineDetails)) {
MesPcnException.throwMesBusiException("箱类别代号【%s】包装定义明细未维护请检查数据", packCode);
}
return defineDetails;
}
private void unboxing(MesPackage mesPackage, String userName, MesPackage mesPackageDb) {
//更新包装表
mesPackageDb.setQty(0d);
@ -391,8 +413,39 @@ public class MesBoxingErrorProofingService implements IMesBoxingErrorProofingSer
return saveMesPackageDetail;
}
private void checkSn(MesPackageDetail mesPackageDetail, MesPackingDefine packingDefine,String partNo) {
private String checkSn(MesPackageDetail mesPackageDetail, MesPackingDefine packingDefine,MesPackage mesPackage,List<MesPackingDefineDetails> defineDetails ) {
List<MesProduceSn> produceSnList = mesProduceSnExtService.getProduceSnList(mesPackageDetail.getOrganizeCode(), mesPackageDetail.getSerialNumber());
String packageBarcodeRule;
String partNo = null;
if (!produceSnList.isEmpty()){
/**
* by castle 2024-12-18 bug 44247
*
*/
partNo = produceSnList.get(0).getPartNo();
}else {
for (MesPackingDefineDetails defineDetail : defineDetails) {
//条码规则为空
if (StringUtils.isEmpty(defineDetail.getPackageBarcodeRule())) {
MesPcnException.throwMesBusiException("箱类别代号【%s】零件号【%s】条码规则未维护请检查数据", mesPackage.getPackageSn(), defineDetail.getPartNo());
}
packageBarcodeRule = defineDetail.getPackageBarcodeRule().replace("*", "");
//包含箱条码
if (mesPackageDetail.getSerialNumber().contains(packageBarcodeRule)) {
partNo = defineDetail.getPartNo();
break;
}
}
}
if (Objects.isNull(partNo)) {
MesPcnException.throwMesBusiException("零件条码【%s】未匹配到符合条码规则的数据请检查数据", mesPackageDetail.getSerialNumber());
}
//校验零件是否一致
if (!partNo.equals(mesPackage.getPartNo())) {
MesPcnException.throwMesBusiException("零件条码【%s】包装定义明细零件【%s】和箱零件【%s】不一致请检查数据", mesPackageDetail.getSerialNumber(), partNo, mesPackage.getPartNo());
}
if (!CollectionUtils.isEmpty(produceSnList)) {
MesProduceSn nextMesProduceSn = produceSnList.stream().sorted(Comparator.comparing(MesProduceSn::getCreateDatetime).reversed()).collect(Collectors.toList()).iterator().next();
if (!MesExtEnumUtil.PRODUCE_SN_STATUS.checkAllowBoxingErrorProofing(nextMesProduceSn.getSnStatus()) || !MesExtEnumUtil.PRODUCE_QC_STATUS.checkAllowBoxingErrorProofing(nextMesProduceSn.getQcStatus())) {
@ -420,6 +473,102 @@ public class MesBoxingErrorProofingService implements IMesBoxingErrorProofingSer
MesPcnException.throwMesBusiException("条码[%s]校验装箱防错对应工艺[%s]失败,请检查数据!", mesPackageDetail.getSerialNumber(),packingDefine.getCraft());
}
}
return partNo;
}
/**
* 2024/12/19 10:50 by castle fix bug 44247
*
* 1.
* 2. &
*
* 2.1
*
* 2.2.1 ---
*
* 2.2.2 ( qcStatus=10 15 snStatus = 10 20)
*
* 2.2
*
*
* @param mesPackageDetail
* @param packingDefine
* @param mesPackage
* @return
*/
private String checkSnNew(MesPackageDetail mesPackageDetail, MesPackingDefine packingDefine,MesPackage mesPackage ) {
String partNo = mesPackage.getPartNo();
//1.查询包装明细是否包含此零件
List<MesPackingDefineDetails> defineDetails = getMesPackingDefineDetailsNew(mesPackageDetail.getOrganizeCode(), mesPackage.getPackageSn(), partNo);
if (defineDetails.isEmpty()) {
MesPcnException.throwMesBusiException("箱类别代号【%s】零件号【%s】未维护请检查数据", mesPackage.getPackageSn(), partNo);
}
MesPackingDefineDetails mesPackingDefineDetails = defineDetails.get(0);
if (StringUtils.isEmpty(mesPackingDefineDetails.getPackageBarcodeRule())){
//是自制件
MesProduceSn produceSn = mesProduceSnExtService.getProduceSnForBox(mesPackageDetail.getSerialNumber(), partNo, mesPackageDetail.getOrganizeCode());
if (produceSn == null){
MesPcnException.throwMesBusiException("扫描条码【%s】零件号【%s】在条码表不存在请检查数据", mesPackage.getPackageSn(), partNo);
}
//QC 检查
if (produceSn.getQcStatus() == MesExtEnumUtil.PRODUCE_QC_STATUS.SUSPICIOUS.getValue()){
MesPcnException.throwMesBusiException("扫描条码【%s】零件号【%s】,QC可疑状态不能包装此零件", mesPackage.getPackageSn(), partNo);
}
if (produceSn.getQcStatus() == MesExtEnumUtil.PRODUCE_QC_STATUS.SCRAP.getValue()){
MesPcnException.throwMesBusiException("扫描条码【%s】零件号【%s】,QC为报废状态不能包装此零件", mesPackage.getPackageSn(), partNo);
}
//SN 条码状态
if (produceSn.getSnStatus() == MesExtEnumUtil.PRODUCE_SN_STATUS.UNKNOW.getValue()){
MesPcnException.throwMesBusiException("扫描条码【%s】零件号【%s】,条码状态为未知,不能包装此零件!", mesPackage.getPackageSn(), partNo);
}
if (produceSn.getSnStatus() == MesExtEnumUtil.PRODUCE_SN_STATUS.PROCESSING.getValue()){
MesPcnException.throwMesBusiException("扫描条码【%s】零件号【%s】,条码状态为加工中,不能包装此零件!", mesPackage.getPackageSn(), partNo);
}
if (produceSn.getSnStatus() == MesExtEnumUtil.PRODUCE_SN_STATUS.ASSEMBLY_BACK.getValue()){
MesPcnException.throwMesBusiException("扫描条码【%s】零件号【%s】,条码状态为已拆解,不能包装此零件!", mesPackage.getPackageSn(), partNo);
}
if (produceSn.getSnStatus() == MesExtEnumUtil.PRODUCE_SN_STATUS.ASSEMBLY.getValue()){
MesPcnException.throwMesBusiException("扫描条码【%s】零件号【%s】,条码状态为已装配,不能包装此零件!", mesPackage.getPackageSn(), partNo);
}
if (produceSn.getSnStatus() == MesExtEnumUtil.PRODUCE_SN_STATUS.CHECKED.getValue()){
MesPcnException.throwMesBusiException("扫描条码【%s】零件号【%s】,条码状态为已校验,不能包装此零件!", mesPackage.getPackageSn(), partNo);
}
if (produceSn.getSnStatus() == MesExtEnumUtil.PRODUCE_SN_STATUS.SHIPPED.getValue()){
MesPcnException.throwMesBusiException("扫描条码【%s】零件号【%s】,条码状态为已发运,不能包装此零件!", mesPackage.getPackageSn(), partNo);
}
if (produceSn.getSnStatus() == MesExtEnumUtil.PRODUCE_SN_STATUS.ASSEMBLY_DISASSEMBLY.getValue()){
MesPcnException.throwMesBusiException("扫描条码【%s】零件号【%s】,条码状态为已总成拆解,不能包装此零件!", mesPackage.getPackageSn(), partNo);
}
}else{
//外协件
String packageBarcodeRule = mesPackingDefineDetails.getPackageBarcodeRule().replace("*", "");
boolean checkResult = mesPackageDetail.getSerialNumber().contains(packageBarcodeRule);
if (!checkResult){
MesPcnException.throwMesBusiException("零件条码【%s】未匹配到符合条码规则的数据请检查数据", mesPackageDetail.getSerialNumber());
}
}
//工艺校验
if(!Objects.isNull(packingDefine) && !Objects.isNull(packingDefine.getCheckCraftFlag()) && CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue() == packingDefine.getCheckCraftFlag()){
//查询加工记录
List<MesProductionRecord> productionRecordList = mesProductionRecordService.findProductionRecordList(mesPackageDetail.getOrganizeCode(), mesPackageDetail.getSerialNumber());
if(CollectionUtils.isEmpty(productionRecordList)){
MesPcnException.throwMesBusiException("条码【%s】校验装箱防错对应工艺失败加工记录信息不存在请检查数据", mesPackageDetail.getSerialNumber());
}
if(StringUtils.isEmpty(packingDefine.getCraft())){
MesPcnException.throwMesBusiException("条码【%s】校验装箱防错对应工艺为空请检查数据", mesPackageDetail.getSerialNumber());
}
//校验条码是否经过该工艺
Optional<MesProductionRecord> productionRecordOptional = productionRecordList.stream().filter(t -> !StringUtils.isEmpty(t.getCraftCode()) && packingDefine.getCraft().equals(t.getCraftCode())).findFirst();
if(!productionRecordOptional.isPresent()){
MesPcnException.throwMesBusiException("条码【%s】校验装箱防错对应工艺【%s】失败请检查数据", mesPackageDetail.getSerialNumber(),packingDefine.getCraft());
}
}
return partNo;
}
private String getPartNo(MesPackageDetail mesPackageDetail, MesPackage mesPackage, List<MesPackingDefineDetails> defineDetails) {

@ -113,5 +113,13 @@ public class MesConfigService implements IMesConfigService {
return configList;
}
@Override
public MesConfig getCfgValueByCode(String organizeCode,String cfgCode) {
if (StringUtils.isEmpty(organizeCode) || StringUtils.isEmpty(cfgCode)) return null;
return configRepository.getByProperty(
new String[]{MesPcnExtConstWords.ORGANIZE_CODE, MesPcnExtConstWords.IS_DELETED, MesPcnExtConstWords.IS_VALID, MesPcnExtConstWords.CFG_CODE},
new Object[]{organizeCode, CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue(), CommonEnumUtil.IS_VAILD.VAILD.getValue(), cfgCode});
}
}

@ -11,6 +11,7 @@ import cn.estsh.i3plus.pojo.base.common.PagerHelper;
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
import cn.estsh.i3plus.pojo.base.tool.DdlPreparedPack;
import cn.estsh.i3plus.pojo.mes.bean.MesProduceSn;
import cn.estsh.i3plus.pojo.mes.bean.MesProductionRecord;
import cn.estsh.i3plus.pojo.mes.bean.MesQueueOrder;
import cn.estsh.i3plus.pojo.mes.model.StationRequestBean;
import cn.estsh.i3plus.pojo.mes.repository.MesProduceSnRepository;
@ -34,6 +35,15 @@ public class MesProduceSnExtService implements IMesProduceSnExtService {
@Autowired
private MesQueueOrderRepository queueOrderRepository;
@Override
public MesProduceSn getProduceSnForBox(String produceSn, String partNo,String organizeCode) {
DdlPackBean ddlPackBean = DdlPackBean.getDdlPackBean(organizeCode);
DdlPreparedPack.getStringEqualPack(produceSn,"productSn",ddlPackBean);
DdlPreparedPack.getStringEqualPack(partNo,"partNo",ddlPackBean);
List<MesProduceSn> produceSnList = produceSnRepository.findByHqlWhere(ddlPackBean);
return produceSnList.isEmpty() ? null : produceSnList.get(0);
}
//根据零件条码查询零件条码信息
@Override
public List<MesProduceSn> getProduceSnList(String organizeCode, List<String> productSnList) {
@ -49,6 +59,7 @@ public class MesProduceSnExtService implements IMesProduceSnExtService {
return produceSnRepository.findByHqlWhere(packBean);
}
//根据零件条码查询零件条码信息
@Override
public List<MesProduceSn> getProduceSnList(String organizeCode, String productSn) {
@ -60,6 +71,15 @@ public class MesProduceSnExtService implements IMesProduceSnExtService {
return produceSnRepository.findByHqlWhere(packBean);
}
//根据零件条码查询零件条码信息, 创建时间倒序
@Override
public List<MesProduceSn> getProduceSnListCreateDatetimeDesc(String organizeCode, String productSn) {
List<MesProduceSn> produceSnList = getProduceSnList(organizeCode, productSn);
if (CollectionUtils.isEmpty(produceSnList)) return produceSnList;
return produceSnList.stream().filter(o -> null != o).sorted(Comparator.comparing(MesProduceSn::getCreateDatetime).reversed()).collect(Collectors.toList());
}
//根据客户条码查询零件条码信息[排序]
@Override
public MesProduceSn getProduceSnByCustSn(String organizeCode, String custSn) {
@ -71,6 +91,7 @@ public class MesProduceSnExtService implements IMesProduceSnExtService {
return produceSnRepository.getByProperty(packBean);
}
//根据产品条码查询零件条码信息[排序]
@Override
public MesProduceSn getProduceSn(String organizeCode, String productSn, String workOrderNo) {

@ -1,5 +1,7 @@
package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.busi;
import cn.estsh.i3plus.ext.mes.pcn.api.base.IMesProdOrgExtService;
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesProduceSnExtService;
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesProductionRecordService;
import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtConstWords;
import cn.estsh.i3plus.platform.common.convert.ConvertBean;
@ -7,11 +9,11 @@ import cn.estsh.i3plus.platform.common.tool.TimeTool;
import cn.estsh.i3plus.pojo.base.bean.DdlPackBean;
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
import cn.estsh.i3plus.pojo.base.tool.DdlPreparedPack;
import cn.estsh.i3plus.pojo.mes.bean.*;
import cn.estsh.i3plus.pojo.mes.model.MesProductionRecordModel;
import cn.estsh.i3plus.pojo.mes.bean.MesProduceSn;
import cn.estsh.i3plus.pojo.mes.bean.MesProductionRecord;
import cn.estsh.i3plus.pojo.mes.repository.*;
import cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil;
import org.springframework.beans.BeanUtils;
import cn.estsh.impp.framework.boot.util.ResultBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
@ -31,6 +33,12 @@ import java.util.stream.Collectors;
public class MesProductionRecordService implements IMesProductionRecordService {
@Autowired
private IMesProduceSnExtService produceSnExtService;
@Autowired
private IMesProdOrgExtService prodOrgExtService;
@Autowired
private MesTimeEfficientCfgRepository timeEfficientCfgRepository;
@Autowired
@ -59,6 +67,14 @@ public class MesProductionRecordService implements IMesProductionRecordService {
new Object[]{organizeCode, CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue(), CommonEnumUtil.IS_VAILD.VAILD.getValue(), productSn});
}
//查询加工记录, 根据完成时间倒序
@Override
public List<MesProductionRecord> findProductionRecordListCompleteDateTimeDesc(String organizeCode, String productSn) {
List<MesProductionRecord> productionRecordList = findProductionRecordList(organizeCode, productSn);
if (CollectionUtils.isEmpty(productionRecordList)) return productionRecordList;
return productionRecordList.stream().filter(o -> null != o).sorted(Comparator.comparing(MesProductionRecord::getCompleteDateTime).reversed()).collect(Collectors.toList());
}
@Override
public List<MesProductionRecord> findProductionRecordList(String organizeCode, String productSn, String partNo) {
if (StringUtils.isEmpty(organizeCode) || StringUtils.isEmpty(productSn) || StringUtils.isEmpty(partNo)) return null;
@ -114,30 +130,113 @@ public class MesProductionRecordService implements IMesProductionRecordService {
}
@Override
public List<MesProductionRecordModel> findMesProductionRecordList(String organizeCode, String productSn) {
List<MesProductionRecord> productionRecordList = findProductionRecord(organizeCode, productSn);
List<MesProductionRecordModel> mesProductionRecordModelList = new ArrayList<>();
if (!CollectionUtils.isEmpty(productionRecordList)) {
//数据查询
Map<String, MesCraft> craftMap = getStringMesCraftMap(organizeCode, productionRecordList.stream().map(MesProductionRecord::getCraftCode).distinct().collect(Collectors.toList()));
Map<String, MesProduceSn> produceSnMap = getStringMesProduceSnMap(organizeCode, productSn);
Map<String, MesWorkCenter> mesWorkCenterMap = getStringMesWorkCenterMap(organizeCode, productionRecordList.stream().map(MesProductionRecord::getWorkCenterCode).distinct().collect(Collectors.toList()));
Map<String, MesWorkCell> workCellMap = getStringMesWorkCellMap(organizeCode, productionRecordList.stream().map(MesProductionRecord::getWorkCellCode).distinct().collect(Collectors.toList()));
//数据组装
MesProductionRecordModel mesProductionRecordModel = null;
for (MesProductionRecord mesProductionRecord : productionRecordList) {
mesProductionRecordModel = new MesProductionRecordModel();
BeanUtils.copyProperties(mesProductionRecord, mesProductionRecordModel);
mesProductionRecordModel.setCraftName(Objects.isNull(craftMap) || Objects.isNull(craftMap.get(mesProductionRecord.getCraftCode())) || StringUtils.isEmpty(mesProductionRecord.getCraftCode()) ? "" : craftMap.get(mesProductionRecord.getCraftCode()).getCraftName());
mesProductionRecordModel.setSnStatus(Objects.isNull(produceSnMap.get(mesProductionRecord.getSerialNumber())) || StringUtils.isEmpty(mesProductionRecord.getSerialNumber()) ? 0 : produceSnMap.get(mesProductionRecord.getSerialNumber()).getSnStatus());
mesProductionRecordModel.setSnStatusDesc(0 == mesProductionRecordModel.getSnStatus() ?"" : MesExtEnumUtil.PRODUCE_SN_STATUS.valueOfDescription(mesProductionRecordModel.getSnStatus()));
mesProductionRecordModel.setReportStatusDesc(MesExtEnumUtil.REPORT_STATUS.valueOfDescription(mesProductionRecordModel.getReportStatus()));
mesProductionRecordModel.setWorkCenterName(Objects.isNull(mesWorkCenterMap.get(mesProductionRecord.getWorkCenterCode())) || StringUtils.isEmpty(mesProductionRecord.getWorkCenterCode()) ? "" : mesWorkCenterMap.get(mesProductionRecord.getWorkCenterCode()).getWorkCenterName());
mesProductionRecordModel.setWorkCellName(Objects.isNull(workCellMap.get(mesProductionRecord.getWorkCellCode())) || StringUtils.isEmpty(mesProductionRecord.getWorkCellCode()) ? "" : workCellMap.get(mesProductionRecord.getWorkCellCode()).getWorkCellName());
mesProductionRecordModelList.add(mesProductionRecordModel);
public ResultBean queryMesProductionRecordReport(String organizeCode, String productSn) {
//查询条码信息, 根据创建时间倒序
List<MesProduceSn> produceSnList = produceSnExtService.getProduceSnListCreateDatetimeDesc(organizeCode, productSn);
if (CollectionUtils.isEmpty(produceSnList)) return ResultBean.fail(String.format("零件条码[%s]信息不存在!", productSn));
MesProduceSn produceSnDb = produceSnList.get(0);
//查询加工记录, 根据完成时间倒序
List<MesProductionRecord> productionRecordList = findProductionRecordListCompleteDateTimeDesc(organizeCode, productSn);
//查询生产线名称
Map<String, String> workCenterCodeMap = getProductionRecordReportCenterMap(organizeCode, produceSnDb.getWorkCenterCode(), productionRecordList);
//查询工位名称
Map<String, String> workCellCodeMap = getProductionRecordReportCellMap(organizeCode, produceSnDb.getWorkCellCode(), productionRecordList);
//查询工艺名称
Map<String, String> craftCodeMap = getProductionRecordReportCraftMap(organizeCode, produceSnDb.getCraftCode(), productionRecordList);
Map<String, Object> produceSnMap = new HashMap<>();
produceSnMap.put(MesPcnExtConstWords.PRODUCT_SN, productSn);
produceSnMap.put(MesPcnExtConstWords.PART_NO, produceSnDb.getPartNo());
produceSnMap.put(MesPcnExtConstWords.PART_NAME, produceSnDb.getPartName());
produceSnMap.put(MesPcnExtConstWords.WORK_CENTER_CODE, produceSnDb.getWorkCenterCode());
produceSnMap.put(MesPcnExtConstWords.WORK_CELL_CODE, produceSnDb.getWorkCellCode());
produceSnMap.put(MesPcnExtConstWords.CRAFT_CODE, produceSnDb.getCraftCode());
produceSnMap.put(MesPcnExtConstWords.WORK_CENTER_NAME, getMap2Value(workCenterCodeMap, produceSnDb.getWorkCenterCode()));
produceSnMap.put(MesPcnExtConstWords.WORK_CELL_NAME, getMap2Value(workCellCodeMap, getCellCodeSuffix(produceSnDb.getWorkCenterCode(), produceSnDb.getWorkCellCode())));
produceSnMap.put(MesPcnExtConstWords.CRAFT_NAME, getMap2Value(craftCodeMap, produceSnDb.getCraftCode()));
produceSnMap.put(MesPcnExtConstWords.SN_STATUS, produceSnDb.getSnStatus());
produceSnMap.put(MesPcnExtConstWords.QC_STATUS, produceSnDb.getQcStatus());
produceSnMap.put(MesPcnExtConstWords.SN_STATUS_NAME, MesExtEnumUtil.PRODUCE_SN_STATUS.valueOfDescription(produceSnDb.getSnStatus()));
produceSnMap.put(MesPcnExtConstWords.QC_STATUS_NAME, MesExtEnumUtil.PRODUCE_QC_STATUS.valueOfDescription(produceSnDb.getQcStatus()));
produceSnMap.put(MesPcnExtConstWords.MODIFY_USER, produceSnDb.getModifyUser());
produceSnMap.put(MesPcnExtConstWords.MODIFY_DATE_TIME, produceSnDb.getModifyDatetime());
ResultBean resultBean = ResultBean.success("查询成功!").setResultObject(produceSnMap);
if (CollectionUtils.isEmpty(productionRecordList)) return resultBean;
Map<String, List<MesProduceSn>> produceSnMap2Part = produceSnList.stream().filter(o -> (null != o && !StringUtils.isEmpty(o.getPartNo()))).collect(Collectors.groupingBy(MesProduceSn::getPartNo));
List<Map<String, Object>> productionRecordMapList = new ArrayList<>();
MesProduceSn produceSnItem;
for (MesProductionRecord productionRecord : productionRecordList) {
if (null == productionRecord) continue;
Map<String, Object> productionRecordMap = new HashMap<>();
productionRecordMap.put(MesPcnExtConstWords.PRODUCT_SN, productSn);
productionRecordMap.put(MesPcnExtConstWords.PART_NO, productionRecord.getPartNo());
productionRecordMap.put(MesPcnExtConstWords.PART_NAME, productionRecord.getPartName());
productionRecordMap.put(MesPcnExtConstWords.WORK_CENTER_CODE, productionRecord.getWorkCenterCode());
productionRecordMap.put(MesPcnExtConstWords.WORK_CELL_CODE, productionRecord.getWorkCellCode());
productionRecordMap.put(MesPcnExtConstWords.CRAFT_CODE, productionRecord.getCraftCode());
productionRecordMap.put(MesPcnExtConstWords.WORK_CENTER_NAME, getMap2Value(workCenterCodeMap, productionRecord.getWorkCenterCode()));
productionRecordMap.put(MesPcnExtConstWords.WORK_CELL_NAME, getMap2Value(workCellCodeMap, getCellCodeSuffix(productionRecord.getWorkCenterCode(), productionRecord.getWorkCellCode())));
productionRecordMap.put(MesPcnExtConstWords.CRAFT_NAME, getMap2Value(craftCodeMap, productionRecord.getCraftCode()));
if (!CollectionUtils.isEmpty(produceSnMap2Part) && !StringUtils.isEmpty(productionRecord.getPartNo()) && produceSnMap2Part.containsKey(productionRecord.getPartNo())) {
produceSnItem = produceSnMap2Part.get(productionRecord.getPartNo()).get(0);
productionRecordMap.put(MesPcnExtConstWords.SN_STATUS, produceSnItem.getSnStatus());
productionRecordMap.put(MesPcnExtConstWords.QC_STATUS, produceSnItem.getQcStatus());
productionRecordMap.put(MesPcnExtConstWords.SN_STATUS_NAME, !StringUtils.isEmpty(produceSnItem.getSnStatus()) ? MesExtEnumUtil.PRODUCE_SN_STATUS.valueOfDescription(produceSnItem.getSnStatus()) : MesPcnExtConstWords.EMPTY);
productionRecordMap.put(MesPcnExtConstWords.QC_STATUS_NAME, !StringUtils.isEmpty(produceSnItem.getQcStatus()) ? MesExtEnumUtil.PRODUCE_QC_STATUS.valueOfDescription(produceSnItem.getQcStatus()) : MesPcnExtConstWords.EMPTY);
}
productionRecordMap.put(MesPcnExtConstWords.COMPLETE_DATE_TIME, productionRecord.getCompleteDateTime());
productionRecordMap.put(MesPcnExtConstWords.CREATE_USER, productionRecord.getCreateUser());
productionRecordMap.put(MesPcnExtConstWords.REPORT_STATUS, productionRecord.getReportStatus());
productionRecordMap.put(MesPcnExtConstWords.REPORT_STATUS_NAME, !StringUtils.isEmpty(productionRecord.getReportStatus()) ? MesExtEnumUtil.REPORT_STATUS.valueOfDescription(productionRecord.getReportStatus()) : MesPcnExtConstWords.EMPTY);
productionRecordMapList.add(productionRecordMap);
}
return mesProductionRecordModelList;
return resultBean.setResultList(productionRecordMapList);
}
private String getCellCodeSuffix(String workCenterCode, String workCellCode) {
if (StringUtils.isEmpty(workCenterCode) || StringUtils.isEmpty(workCellCode)) return null;
return new StringJoiner(MesPcnExtConstWords.AND).add(workCenterCode).add(workCellCode).toString();
}
private String getMap2Value(Map<String, String> map, String key) {
if (StringUtils.isEmpty(key)) return MesPcnExtConstWords.EMPTY;
if (CollectionUtils.isEmpty(map) || !map.containsKey(key)) return MesPcnExtConstWords.EMPTY;
return map.get(key);
}
private Map<String, String> getProductionRecordReportCenterMap(String organizeCode, String workCenterCode, List<MesProductionRecord> productionRecordList) {
List<String> workCenterCodeList = CollectionUtils.isEmpty(productionRecordList) ? null :
productionRecordList.stream().filter(o -> (null != o && !StringUtils.isEmpty(o.getWorkCenterCode()))).map(MesProductionRecord::getWorkCenterCode).collect(Collectors.toList());
if (CollectionUtils.isEmpty(workCenterCodeList) && !StringUtils.isEmpty(workCenterCode)) workCenterCodeList = new ArrayList<>();
if (!StringUtils.isEmpty(workCenterCode)) workCenterCodeList.add(workCenterCode);
return prodOrgExtService.getWorkCenterCodeMap(organizeCode, workCenterCodeList);
}
private Map<String, String> getProductionRecordReportCellMap(String organizeCode, String workCellCode, List<MesProductionRecord> productionRecordList) {
List<String> workCellCodeList = CollectionUtils.isEmpty(productionRecordList) ? null :
productionRecordList.stream().filter(o -> (null != o && !StringUtils.isEmpty(o.getWorkCellCode()))).map(MesProductionRecord::getWorkCellCode).collect(Collectors.toList());
if (CollectionUtils.isEmpty(workCellCodeList) && !StringUtils.isEmpty(workCellCode)) workCellCodeList = new ArrayList<>();
if (!StringUtils.isEmpty(workCellCode)) workCellCodeList.add(workCellCode);
return prodOrgExtService.getWorkCellCodeMap(organizeCode, workCellCodeList);
}
private Map<String, String> getProductionRecordReportCraftMap(String organizeCode, String craftCode, List<MesProductionRecord> productionRecordList) {
List<String> craftCodeList = CollectionUtils.isEmpty(productionRecordList) ? null :
productionRecordList.stream().filter(o -> (null != o && !StringUtils.isEmpty(o.getCraftCode()))).map(MesProductionRecord::getCraftCode).collect(Collectors.toList());
if (CollectionUtils.isEmpty(craftCodeList) && !StringUtils.isEmpty(craftCode)) craftCodeList = new ArrayList<>();
if (!StringUtils.isEmpty(craftCode)) craftCodeList.add(craftCode);
return prodOrgExtService.getCraftCodeMap(organizeCode, craftCodeList);
}
@Override
@ -152,68 +251,4 @@ public class MesProductionRecordService implements IMesProductionRecordService {
productionRecordRepository.saveAll(recordList);
}
private Map<String, MesCraft> getStringMesCraftMap(String organizeCode, List<String> craftCodeList) {
DdlPackBean packBean = DdlPackBean.getDdlPackBean(organizeCode);
DdlPreparedPack.getInPackList(craftCodeList, MesPcnExtConstWords.CRAFT_CODE,packBean);
List<MesCraft> craftList = mesCraftRepository.findByHqlWhere(packBean);
Map<String, MesCraft> craftMap = null;
if(!CollectionUtils.isEmpty(craftList)){
craftMap = craftList.stream().collect(Collectors.toMap(MesCraft::getCraftCode, t -> t));
}
return craftMap;
}
private Map<String, MesProduceSn> getStringMesProduceSnMap(String organizeCode, String productSn) {
DdlPackBean packBean = DdlPackBean.getDdlPackBean(organizeCode);
DdlPreparedPack.getStringEqualPack(productSn, MesPcnExtConstWords.PRODUCT_SN,packBean);
List<MesProduceSn> mesProduceSns = mesProduceSnRepository.findByHqlWhere(packBean);
Map<String, MesProduceSn> mesProduceSnMap = new HashMap<>();
if(!CollectionUtils.isEmpty(mesProduceSns)){
for (MesProduceSn mesProduceSn : mesProduceSns) {
if(!mesProduceSnMap.containsKey(mesProduceSn.getSerialNumber())){
mesProduceSnMap.put(mesProduceSn.getSerialNumber(),mesProduceSn);
}
}
}
return mesProduceSnMap;
}
private Map<String, MesWorkCenter> getStringMesWorkCenterMap(String organizeCode, List<String> workCenterNoList) {
DdlPackBean packBean = DdlPackBean.getDdlPackBean(organizeCode);
DdlPreparedPack.getInPackList(workCenterNoList, MesPcnExtConstWords.WORK_CENTER_CODE,packBean);
List<MesWorkCenter> mesWorkCenterList = mesWorkCenterRepository.findByHqlWhere(packBean);
Map<String, MesWorkCenter> mesWorkCenterMap = new HashMap<>();
if(!CollectionUtils.isEmpty(mesWorkCenterList)){
for (MesWorkCenter workCenter : mesWorkCenterList) {
if(!mesWorkCenterMap.containsKey(workCenter.getWorkCenterCode())){
mesWorkCenterMap.put(workCenter.getWorkCenterCode(),workCenter);
}
}
}
return mesWorkCenterMap;
}
private Map<String, MesWorkCell> getStringMesWorkCellMap(String organizeCode, List<String> workCenterNoList) {
DdlPackBean packBean = DdlPackBean.getDdlPackBean(organizeCode);
DdlPreparedPack.getInPackList(workCenterNoList, MesPcnExtConstWords.WORK_CELL_CODE,packBean);
List<MesWorkCell> mesWorkCellList = mesWorkCellRepository.findByHqlWhere(packBean);
Map<String, MesWorkCell> mesProduceSnMap = new HashMap<>();
if(!CollectionUtils.isEmpty(mesWorkCellList)){
for (MesWorkCell mesWorkCell : mesWorkCellList) {
if(!mesProduceSnMap.containsKey(mesWorkCell.getWorkCellCode())){
mesProduceSnMap.put(mesWorkCell.getWorkCellCode(),mesWorkCell);
}
}
}
return mesProduceSnMap;
}
public List<MesProductionRecord> findProductionRecord(String organizeCode, String productSn) {
if (StringUtils.isEmpty(organizeCode) || StringUtils.isEmpty(productSn)) return null;
DdlPackBean packBean = DdlPackBean.getDdlPackBean(organizeCode);
DdlPreparedPack.getStringEqualPack(productSn,MesPcnExtConstWords.PRODUCT_SN,packBean);
DdlPreparedPack.getOrderBy(MesPcnExtConstWords.CREATE_DATE_TIME,CommonEnumUtil.ASC_OR_DESC.DESC.getValue(),packBean);
return productionRecordRepository.findByHqlWhere(packBean);
}
}

@ -241,6 +241,19 @@ public class MesWorkOrderService implements IMesWorkOrderService {
MesProductOffLine newMesProductOffLine;
for (MesProductionRecord mesProductionRecord : mesProductionRecordList) {
for (MesBom mesBom : mesBoms) {
DdlPackBean productPackBean = DdlPackBean.getDdlPackBean(mesProductionRecord.getOrganizeCode());
DdlPreparedPack.getStringEqualPack(mesBom.getItemPartNo(),"itemPartNo", productPackBean);
DdlPreparedPack.getStringEqualPack(mesWorkOrderDb.getPartNo(),"reportPartNo", productPackBean);
DdlPreparedPack.getStringEqualPack(mesProductionRecord.getProductSn(),"reportSn", productPackBean);
int count = mesProductOffLineRDao.findByHqlWhereCount(productPackBean);
if (count > 0) {
String msg = String.format("子零件【%s】产成零件【%s】条码【%s】对应报工信息已存在",
mesBom.getItemPartNo(),mesWorkOrderDb.getPartNo(), mesProductionRecord.getProductSn());
LOGGER.info(msg);
continue;
}
newMesProductOffLine = new MesProductOffLine();
newMesProductOffLine.setReportPartNo(mesWorkOrderDb.getPartNo());
newMesProductOffLine.setReportPartNameRdd(mesWorkOrderDb.getPartName());
@ -359,12 +372,18 @@ public class MesWorkOrderService implements IMesWorkOrderService {
}
public List<MesBom> findMesBomByPartNoAndBomVersion(String partNo, String organizeCode, String bomVersion) {
//MES汇报查询BOM是否携带结束查询条件
MesConfig config = configService.getCfgValueByCode(organizeCode, MesPcnExtConstWords.MES_REPORT_FIND_BOM_WITH_EFFENDTIME);
Boolean isWithEffEndTime = (null != config && !StringUtils.isEmpty(config.getCfgValue()) && config.getCfgValue().equals(CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValueStr())) ? true : false;
DdlPackBean ddlPackBean = DdlPackBean.getDdlPackBean(organizeCode);
DdlPreparedPack.getStringEqualPack(partNo, "partNo", ddlPackBean);
DdlPreparedPack.getStringEqualPack(bomVersion, "bomVersion", ddlPackBean);
DdlPreparedPack.getStringSmallerPack(TimeTool.getNowTime(true), "effStartTime", ddlPackBean);
DdlPreparedPack.getStringBiggerPack(TimeTool.getNowTime(true), "effEndTime", ddlPackBean);
DdlPreparedPack.getOrderBy("effStartTime", CommonEnumUtil.ASC_OR_DESC.DESC.getValue(), ddlPackBean);
DdlPreparedPack.getStringEqualPack(partNo, MesPcnExtConstWords.PART_NO, ddlPackBean);
DdlPreparedPack.getStringEqualPack(bomVersion, MesPcnExtConstWords.BOM_VERSION, ddlPackBean);
DdlPreparedPack.getStringSmallerPack(TimeTool.getNowTime(true), MesPcnExtConstWords.EFF_START_TIME, ddlPackBean);
if (isWithEffEndTime) DdlPreparedPack.getStringBiggerPack(TimeTool.getNowTime(true), MesPcnExtConstWords.EFF_END_TIME, ddlPackBean);
DdlPreparedPack.getOrderBy(MesPcnExtConstWords.EFF_START_TIME, CommonEnumUtil.ASC_OR_DESC.DESC.getValue(), ddlPackBean);
List<MesBom> mesBoms = mesBomRDao.findByHqlWhere(ddlPackBean);
if (org.springframework.util.CollectionUtils.isEmpty(mesBoms)) {
LOGGER.info("物料{}生产版本{}对应bom信息不存在", partNo, bomVersion );
@ -572,6 +591,23 @@ public class MesWorkOrderService implements IMesWorkOrderService {
return bom;
}));
if (MesExtEnumUtil.NOSORT_REPORT_TYPE.REPORT.getValue() == productionRecord.getReportType()) {
DdlPackBean productPackBean = DdlPackBean.getDdlPackBean(productionRecord.getOrganizeCode());
DdlPreparedPack.getStringEqualPack(oldMesWorkOrder.getPartNo(),"reportPartNo", productPackBean);
DdlPreparedPack.getStringEqualPack(productionRecord.getProductSn(),"reportSn", productPackBean);
int count = mesProductOffLineRDao.findByHqlWhereCount(productPackBean);
if (count > 0) {
String msg = String.format("产成零件【%s】条码【%s】对应报工信息已存在",
oldMesWorkOrder.getPartNo(), productionRecord.getProductSn());
LOGGER.error(msg);
LOGGER.info("条码【{}】重复报工更新成已报工", productionRecord.getProductSn());
DdlPackBean packBean = DdlPackBean.getDdlPackBean(organizeCode);
DdlPreparedPack.getNumEqualPack(productionRecord.getId(), "id", packBean);
productionRecordRao.updateByProperties(new String[]{"modifyUser", "modifyDatetime", "workOrderNo", "reportStatus","description"},
new Object[]{userName, TimeTool.getNowTime(true), oldMesWorkOrder.getWorkOrderNo(), MesExtEnumUtil.REPORT_STATUS.REPORT_STATUS_20.getValue(), "重复报工更新成已报工"}, packBean);
return;
}
for (Map.Entry<MesBom, List<MesBom>> entry : map.entrySet()) {
mesProductOffLineList.add(getMesProductOffLine(productionRecord, userName, oldMesWorkOrder, mesProductVersion, entry.getValue().get(0), productionRecord.getProductSn(), false,false,map.size()));
}
@ -817,6 +853,10 @@ public class MesWorkOrderService implements IMesWorkOrderService {
DdlPackBean ddlPackBean = DdlPackBean.getDdlPackBean(organizeCode);
DdlPreparedPack.getStringEqualPack(productionRecord.getPartNo(), "partNo", ddlPackBean);
// 获取5分钟之前的时间
String startTime = TimeTool.timeCalc(new Date(), Calendar.MINUTE, -2, "yyyy-MM-dd HH:mm:ss");
DdlPreparedPack.getStringSmallerNotEqualPack(startTime, "createDatetime", ddlPackBean);
DdlPreparedPack.getStringEqualPack(productionRecord.getWorkCenterCode(), "workCenterCode", ddlPackBean);
if (!StringUtils.isEmpty(productionRecord.getWorkOrderNo())) {
DdlPreparedPack.getStringEqualPack(productionRecord.getWorkOrderNo(), "workOrderNo", ddlPackBean);

@ -1,7 +1,6 @@
package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.equiplog;
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesEquipVariableRwExtService;
import cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.rulematch.WriteVariableService;
import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtConstWords;
import cn.estsh.i3plus.mes.pcn.api.iservice.base.IConfigService;
import cn.estsh.i3plus.platform.common.tool.HttpClientTool;
@ -32,7 +31,7 @@ import java.util.stream.Collectors;
@Service
public class MesEquipmentRwExtService implements IMesEquipVariableRwExtService {
public static final Logger LOGGER = LoggerFactory.getLogger(WriteVariableService.class);
public static final Logger LOGGER = LoggerFactory.getLogger(MesEquipmentRwExtService.class);
@Autowired
private IConfigService configService;

@ -0,0 +1,103 @@
package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.print.strategy;
import cn.estsh.i3plus.ext.mes.pcn.api.base.IMesCustomerPartService;
import cn.estsh.i3plus.ext.mes.pcn.api.base.IMesPartService;
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesPrintedSnLogService;
import cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.print.IPrintTemplateStrategyService;
import cn.estsh.i3plus.ext.mes.pcn.apiservice.util.MesPcnException;
import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesProduceSnPrintDataModel;
import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesProduceSnPrintModel;
import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtConstWords;
import cn.estsh.i3plus.mes.pcn.api.iservice.busi.ISyncFuncService;
import cn.estsh.i3plus.platform.common.tool.TimeTool;
import cn.estsh.i3plus.pojo.base.codemaker.SnowflakeIdMaker;
import cn.estsh.i3plus.pojo.mes.bean.MesNumberRule;
import cn.estsh.i3plus.pojo.mes.bean.MesPart;
import cn.estsh.i3plus.pojo.mes.model.GenSerialNoModel;
import cn.estsh.i3plus.pojo.mes.model.StationRequestBean;
import cn.estsh.i3plus.pojo.mes.model.StepResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import java.util.HashMap;
import java.util.Map;
/**
* @Description : 线
* @Reference :
* @Author : wangjie
* @CreateDate 2024/9/27 18:25
* @Modify:
**/
@Component
@Slf4j
public class WuHanPaintCenterPrintStrategy implements IPrintTemplateStrategyService {
@Autowired
private ISyncFuncService syncFuncService;
@Autowired
private SnowflakeIdMaker snowflakeIdMaker;
@Autowired
private IMesPartService mesPartService;
@Autowired
private IMesPrintedSnLogService mesPrintedSnLogService;
@Autowired
private IMesCustomerPartService mesCustomerPartService;
private static final String SUPPLIER_CODE_DEFAULT = "V280156";
@Override
public MesProduceSnPrintModel execute(GenSerialNoModel genSerialNoModel, MesProduceSnPrintModel mesProduceSnPrintModel, MesNumberRule numberRule, StepResult stepResult, StationRequestBean reqBean, Boolean isStep) {
if (isStep) return mesProduceSnPrintModel;
String organizeCode = mesProduceSnPrintModel.getOrganizeCode();
MesPart mesPart = (!CollectionUtils.isEmpty(genSerialNoModel.getDataMap()) && genSerialNoModel.getDataMap().containsKey(MesPart.class.getSimpleName())) ?
(MesPart) genSerialNoModel.getDataMap().get(MesPart.class.getSimpleName()) :mesPartService.getMesPartByPartNo(mesProduceSnPrintModel.getPartNo(), organizeCode);
if (null == mesPart) MesPcnException.throwBusiException("物料[%s]信息不存在!", mesProduceSnPrintModel.getPartNo());
if (StringUtils.isEmpty(mesPart.getPartSnParam())) MesPcnException.throwBusiException("物料[%s]信息未维护[零件条码参数]!", mesProduceSnPrintModel.getPartNo());
String nowTime = TimeTool.getNowTime(true);
//{PREFIX}{SPILTRULE}{PARTSNPARAM}{SPILTRULE}{YEAR}{}{MONTH}{DAY}{SPILTRULE} prefix字段维护成:WuHanPaint spiltRule字段维护成: P,#T,#V280156#
genSerialNoModel.partSnParam(mesPart.getPartSnParam()).year(nowTime.substring(2, 4));
String qrCode = syncFuncService.syncSerialNo(genSerialNoModel, mesProduceSnPrintModel.getUserName(), organizeCode, 1).getResultList().get(0).toString();
if (StringUtils.isEmpty(qrCode)) MesPcnException.throwBusiException("根据编码规则[%s]生成条码失败!", numberRule.getRuleCode());
if (!StringUtils.isEmpty(numberRule.getPrefix())) qrCode = qrCode.replace(numberRule.getPrefix(), MesPcnExtConstWords.EMPTY);
String[] barCodeArr = qrCode.split(MesPcnExtConstWords.WELL_NO);
for (int i = 0; i < mesProduceSnPrintModel.getPrintQty(); i++) {
Map<String, Object> printTemplateData = new HashMap<>();
printTemplateData.put(MesPcnExtConstWords.QR_CODE, qrCode);
if (barCodeArr.length >= 1) printTemplateData.put(MesPcnExtConstWords.PART_SN_PARAM, barCodeArr[0] + MesPcnExtConstWords.WELL_NO);
if (barCodeArr.length >= 2) printTemplateData.put(MesPcnExtConstWords.CREATE_DATE_TIME, barCodeArr[1] + MesPcnExtConstWords.WELL_NO);
if (barCodeArr.length >= 3) printTemplateData.put(MesPcnExtConstWords.SUPPLIER_CODE_L, barCodeArr[2] + MesPcnExtConstWords.WELL_NO);
mesProduceSnPrintModel.getPrintContextList().add(printTemplateData);
}
//保存打印记录
MesProduceSnPrintDataModel printDataModel = new MesProduceSnPrintDataModel();
printDataModel.setBarcode(qrCode);
printDataModel.setPartNo(mesPart.getPartNo());
printDataModel.setPartName(mesPart.getPartName());
printDataModel.setPrintDate(nowTime);
printDataModel.setProductDate(TimeTool.getToday());
printDataModel.setUserName(mesProduceSnPrintModel.getUserName());
printDataModel.setPrintData(String.format("{%s:%s, %s:%s}", MesPcnExtConstWords.QR_CODE, qrCode, MesPcnExtConstWords.QTY, mesProduceSnPrintModel.getPrintQty()));
mesProduceSnPrintModel.getMesPrintedSnLogList().add(mesPrintedSnLogService.getMesPrintedSnLog(mesProduceSnPrintModel.getUserName(), organizeCode, printDataModel));
return mesProduceSnPrintModel;
}
}

@ -1,162 +0,0 @@
package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.rulematch;
import cn.estsh.i3plus.ext.mes.pcn.api.busi.*;
import cn.estsh.i3plus.ext.mes.pcn.apiservice.schedulejob.BaseMesScheduleJob;
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProdShiftContext;
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProductionPartContext;
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProductionPsInContext;
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProductionPsOutContext;
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
import cn.estsh.i3plus.pojo.mes.bean.MesEquipmentVariable;
import cn.estsh.i3plus.pojo.mes.model.MesEquipVariableRwResult;
import cn.estsh.i3plus.pojo.mes.model.StationRequestBean;
import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import java.util.Date;
import java.util.List;
import java.util.Objects;
/**
* @Description :
* @Author : zxw
**/
@Service
public class WriteVariableService implements IWriteVariableService {
public static final Logger LOGGER = LoggerFactory.getLogger(WriteVariableService.class);
@Autowired
private IMesEquipVariableRwExtService equipVariableRwExtService;
@Autowired
private IMesProductionDispatchContextStepService mesProductionDispatchContextStepService;
@Autowired
private IMesProductionDispatchContextStepService productionDispatchContextStepService;
@Autowired
private IMesProductionCustomContextStepService productionCustomContextStepService;
/**
*
* @param value
* @param equipmentVariable
* @param kepwareFlag
*/
public MesEquipVariableRwResult writeVariable(StationRequestBean reqBean, String value, MesEquipmentVariable equipmentVariable, String kepwareFlag, Integer foreignKey, Integer index, Integer maxTimes) {
// 需要不同的策略不同的转换方式
String newValue = transferValue(reqBean, value, foreignKey, index);
if (StringUtils.isEmpty(newValue)) {
LOGGER.info("发送的值为空,不予发送");
return null;
}
MesEquipVariableRwResult mesEquipVariableRwResult = equipVariableRwExtService.writeVariable(newValue, equipmentVariable, kepwareFlag);
if (!mesEquipVariableRwResult.getIsSuccessed() && mesEquipVariableRwResult.getIsNoCfg()) {
for (int i = 0;i < maxTimes; i++) {
mesEquipVariableRwResult = equipVariableRwExtService.writeVariable(newValue, equipmentVariable, kepwareFlag);
if (mesEquipVariableRwResult.getIsSuccessed()){
break;
}
}
}
return mesEquipVariableRwResult;
}
@Override
public String transferValue(StationRequestBean reqBean, String value, Integer foreignKey, Integer index) {
List<MesProductionPartContext> productionPartContextList = mesProductionDispatchContextStepService.getProductionPartContext(reqBean);
List<MesProductionPsOutContext> productionPsOutContexts = mesProductionDispatchContextStepService.getProductionPsOutContext(reqBean);
List<MesProductionPsInContext> productionPsInContexts = mesProductionDispatchContextStepService.getProductionPsInContext(reqBean);
String productResult = productionDispatchContextStepService.getProductResultContext(reqBean);
MesProdShiftContext mesProdShiftKvBean = productionCustomContextStepService.getMesProdShiftKvBean(reqBean.getOrganizeCode(), reqBean.getWorkCenterCode());
MesProductionPartContext mesProductionPartContext = null;
MesProductionPsOutContext productionPsOutSn = null;
if (!Objects.isNull(foreignKey)) {
if (!CollectionUtils.isEmpty(productionPartContextList)) {
mesProductionPartContext = productionPartContextList.stream().filter(context -> Objects.equals(context.getForeignKey(), foreignKey)).findFirst().orElse(null);
}
if (!CollectionUtils.isEmpty(productionPsOutContexts)) {
productionPsOutSn = productionPsOutContexts.stream().filter(context -> Objects.equals(context.getForeignKey(), foreignKey)).findFirst().orElse(null);
}
String newValue = "";
if (StringUtils.isEmpty(value)) {
return null;
}
if (mesProductionPartContext == null) {
mesProductionPartContext = new MesProductionPartContext();
}
if (productionPsOutSn == null) {
productionPsOutSn = new MesProductionPsOutContext();
}
switch (value.toUpperCase()) {
case "%RESULT%" : newValue = mesProductionPartContext.getPartNo(); break;
case "%PARAM%": newValue = mesProductionPartContext.getWorkOrderNo(); break;
case "%ORDERCODE%": newValue = mesProductionPartContext.getWorkOrderNo(); break;
case "%CUSTPARTNO%": newValue = mesProductionPartContext.getCustPartNo(); break;
case "%EMPLOYEENO%": newValue = reqBean.getUserInfo(); break;///当前操作员工号 用户名
case "%BARCODE%": newValue = productionPsOutSn.getProductSn(); break;// 条码
case "%BARCODE2%": newValue = productionPsOutContexts.get(1).getProductSn(); break;///条码
case "%BARCODE3%": newValue = productionPsOutContexts.get(2).getProductSn(); break;///条码
case "%BARCODE4%": newValue = productionPsOutContexts.get(3).getProductSn(); break;///条码
case "%BARCODE5%": newValue = productionPsOutContexts.get(4).getProductSn(); break;///条码
case "%BARCODE6%": newValue = productionPsOutContexts.get(5).getProductSn(); break;///条码
case "%BARCODE7%": newValue = productionPsOutContexts.get(6).getProductSn(); break;///条码
case "%BARCODE8%": newValue = productionPsOutContexts.get(7).getProductSn(); break;///条码
case "%BARCODE9%": newValue = productionPsOutContexts.get(8).getProductSn(); break;///条码
case "%BARCODE10%": newValue = productionPsOutContexts.get(9).getProductSn(); break;///条码
case "%BARCODE11%": newValue = productionPsOutContexts.get(10).getProductSn(); break;///条码
case "%BARCODE12%": newValue = productionPsOutContexts.get(11).getProductSn(); break;///条码
case "%BARCODE13%": newValue = productionPsOutContexts.get(12).getProductSn(); break;///条码
case "%BARCODE14%": newValue = productionPsOutContexts.get(13).getProductSn(); break;///条码
case "%BARCODE15%": newValue = productionPsOutContexts.get(14).getProductSn(); break;///条码
case "%BARCODE16%": newValue = productionPsOutContexts.get(15).getProductSn(); break;///条码
case "%BARCODE17%": newValue = productionPsOutContexts.get(16).getProductSn(); break;///条码
case "%BARCODE18%": newValue = productionPsOutContexts.get(17).getProductSn(); break;///条码
case "%BARCODE19%": newValue = productionPsOutContexts.get(18).getProductSn(); break;///条码
case "%BARCODE20%": newValue = productionPsOutContexts.get(19).getProductSn(); break;///条码
case "%CREATEDATE%": newValue = DateUtil.format(new Date(), DatePattern.NORM_DATETIME_PATTERN); break;///加工记录的创建时间
case "%CREATEUSER%": newValue = reqBean.getUserInfo(); break;///当前操作员工号 用户名
case "%SHIFT%": newValue = mesProdShiftKvBean.getShiftGroup(); break;///当前操作员工号 用户名
//case "%STATUS%": newValue = productionPsInContexts.get(0).get() +"" ; break;//进料条码状态
// case "%CUSTORDERCOD%": newValue = mesProductionPartContext.getCustOrderNo(); break;///客户订单号
case "%PARTNO%": newValue = mesProductionPartContext.getPartNo(); break;///工单对应的零件号
//case "%VINCODE%": newValue = mesProductionPartContext.getv(); break;///工单对应的vincode
case "%SEQUENCE%": newValue = reqBean.getUserInfo(); break;///工单顺序号 不是生产顺序号
case "%CUSTBARCODE%": newValue = productionPsOutSn.getCustSn(); break;///客户条码
case "%GETDATE%": newValue = DateUtil.format(new Date(), DatePattern.NORM_DATETIME_PATTERN); break;///客户条码
default:
newValue = value;
}
return newValue;
} else {
if (index != null && foreignKey == null) {
mesProductionPartContext = productionPartContextList.get(index);
if (mesProductionPartContext == null || Objects.equals(CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue(), mesProductionPartContext.getIsFinishCode())) {
return null;
}
return value;
}
}
return null;
}
}

@ -1,5 +1,6 @@
package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.station;
import cn.estsh.i3plus.ext.mes.pcn.api.base.IMesMediaFileCfgService;
import cn.estsh.i3plus.ext.mes.pcn.api.base.IMesProdShiftRecordService;
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesProductionCustomContextStepService;
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesProductionDispatchContextStepService;
@ -7,28 +8,22 @@ import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesProductionProcessContextStepServ
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesWorkOrderExtService;
import cn.estsh.i3plus.ext.mes.pcn.apiservice.util.MesPcnException;
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProdShiftContext;
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProductionPartContext;
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProductionProcessContext;
import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtConstWords;
import cn.estsh.i3plus.mes.pcn.serviceimpl.fsm.BaseModuleService;
import cn.estsh.i3plus.mes.pcn.serviceimpl.fsm.IStepService;
import cn.estsh.i3plus.mes.pcn.util.StationKvBeanUtil;
import cn.estsh.i3plus.pojo.base.bean.DdlPackBean;
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
import cn.estsh.i3plus.pojo.base.enumutil.MesPcnEnumUtil;
import cn.estsh.i3plus.pojo.base.tool.DdlPreparedPack;
import cn.estsh.i3plus.pojo.mes.bean.MesFile;
import cn.estsh.i3plus.pojo.mes.bean.MesStateMachineStatus;
import cn.estsh.i3plus.pojo.mes.bean.MesWorkCell;
import cn.estsh.i3plus.pojo.mes.bean.MesWorkOrder;
import cn.estsh.i3plus.pojo.mes.model.StationKvBean;
import cn.estsh.i3plus.pojo.mes.model.StationRequestBean;
import cn.estsh.i3plus.pojo.mes.model.StationResultBean;
import cn.estsh.i3plus.pojo.mes.repository.MesFileRepository;
import cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil;
import cn.estsh.impp.framework.boot.util.SpringContextsUtil;
import com.alibaba.fastjson.JSONObject;
import com.google.common.base.Objects;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -38,7 +33,6 @@ import org.springframework.util.StringUtils;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.StringJoiner;
/**
* @Description :
@ -64,7 +58,7 @@ public class MesProductionNoSortModuleService extends BaseModuleService {
private IMesWorkOrderExtService workOrderExtService;
@Autowired
private MesFileRepository mesFileRepository;
private IMesMediaFileCfgService mediaFileCfgService;
@Override
public void init(StationRequestBean reqBean) {
@ -73,37 +67,44 @@ public class MesProductionNoSortModuleService extends BaseModuleService {
MesProductionProcessContext productionProcessContext = productionProcessContextStepService.getProductionProcessContext(reqBean, false);
//配置错误 抛出异常
if (!productionProcessContext.getSuccess()) {
this.sendMessage(reqBean, new StationResultBean().resultObj(MesPcnExtConstWords.STEP_DISABLE_SCAN), String.format("信息: %s!", productionProcessContext.getMessage()), MesPcnEnumUtil.STATION_BUSI_TYPE.STEP_TITLE, MesPcnEnumUtil.STATION_DATA_TYPE.TITLE);
this.sendMessage(reqBean, new StationResultBean().writeDbLog(), productionProcessContext.getMessage(), MesPcnEnumUtil.STATION_BUSI_TYPE.MESSAGE, MesPcnEnumUtil.STATION_DATA_TYPE.EXP_TEXT);
this.sendMessage(reqBean, new StationResultBean()
.busiType(MesPcnEnumUtil.STATION_BUSI_TYPE.BUSI_LIST.getValue())
.addStationResultBeans(new StationResultBean().resultObj(MesPcnExtConstWords.STEP_DISABLE_SCAN)
.busiType(MesPcnEnumUtil.STATION_BUSI_TYPE.STEP_TITLE.getValue()).dataType(MesPcnEnumUtil.STATION_DATA_TYPE.TITLE.getValue()).message(String.format("信息: %s!", productionProcessContext.getMessage())))
.addStationResultBeans(new StationResultBean().writeDbLog()
.busiType(MesPcnEnumUtil.STATION_BUSI_TYPE.MESSAGE.getValue()).dataType(MesPcnEnumUtil.STATION_DATA_TYPE.TEXT.getValue()).message(productionProcessContext.getMessage()))
);
MesPcnException.throwBusiException(productionProcessContext.getMessage());
}
// 获取工单信息
List<List<StationKvBean>> moduleContentContext = productionDispatchContextStepService.getModuleContentContext(reqBean);
//获取班次信息,先查询缓存,缓存没有在查询数据库
List<StationKvBean> prodShiftDataContext = prodShiftRecordService.getShiftRecordStationKvBeans(reqBean.getOrganizeCode(), reqBean.getWorkCenterCode());
if (CollectionUtils.isEmpty(prodShiftDataContext)) {
this.sendMessage(reqBean, new StationResultBean().resultObj(MesPcnExtConstWords.STEP_DISABLE_SCAN), "信息: 请先开班!", MesPcnEnumUtil.STATION_BUSI_TYPE.STEP_TITLE, MesPcnEnumUtil.STATION_DATA_TYPE.TITLE);
this.sendMessage(reqBean, new StationResultBean().writeDbLog(), "请先开班!", MesPcnEnumUtil.STATION_BUSI_TYPE.MESSAGE, MesPcnEnumUtil.STATION_DATA_TYPE.TEXT);
this.sendMessage(reqBean, new StationResultBean()
.busiType(MesPcnEnumUtil.STATION_BUSI_TYPE.BUSI_LIST.getValue())
.addStationResultBeans(new StationResultBean().resultObj(MesPcnExtConstWords.STEP_DISABLE_SCAN)
.busiType(MesPcnEnumUtil.STATION_BUSI_TYPE.STEP_TITLE.getValue()).dataType(MesPcnEnumUtil.STATION_DATA_TYPE.TITLE.getValue()).message("信息: 请先开班!"))
.addStationResultBeans(new StationResultBean().writeDbLog()
.busiType(MesPcnEnumUtil.STATION_BUSI_TYPE.MESSAGE.getValue()).dataType(MesPcnEnumUtil.STATION_DATA_TYPE.TEXT.getValue()).message("请先开班!"))
);
MesPcnException.throwBusiException("请先开班!");
}
// 发送班次班组和工单
// 获取工单信息
List<List<StationKvBean>> moduleContentContext = productionDispatchContextStepService.getModuleContentContext(reqBean);
//封装数据: 班次班组和工单
StationResultBean resultBean = getStationResultBean(reqBean, moduleContentContext, prodShiftDataContext);
this.sendMessage(reqBean, resultBean);
//获取生产线的当前班组班次信息
MesProdShiftContext mesProdShiftKvBean = productionCustomContextStepService.getMesProdShiftKvBean(reqBean.getOrganizeCode(), reqBean.getWorkCenterCode());
// 整合班次加工数量
List<StationKvBean> productionStatisticsContext = productionCustomContextStepService.getProductionStatisticsContext(reqBean);
if (CollectionUtils.isEmpty(productionStatisticsContext)) {
productionStatisticsContext = StationKvBeanUtil.addStationKvBeanList(new ArrayList<>(),
new StationKvBean(new StringJoiner(MesPcnExtConstWords.AND).add(mesProdShiftKvBean.getShiftGroup()).add(mesProdShiftKvBean.getShiftCode()).toString(), "加工数", MesPcnExtConstWords.ZERO_STR),
new StationKvBean(MesPcnExtConstWords.COLOR, "颜色", MesExtEnumUtil.COLOR.BLACK.getValue()));
}
StationResultBean shiftCountBean = getStationResultBean(reqBean, productionStatisticsContext, productionProcessContext.getWorkCell(), mesProdShiftKvBean);
this.sendMessage(reqBean, shiftCountBean);
//封装当前班组班次信息
MesProdShiftContext mesProdShiftKvBean = prodShiftRecordService.getMesProdShiftKvBean(prodShiftDataContext);
//封装工位展示的客制化信息 (优先级: 工位图/视频/柱状图-->加工数)
StationResultBean resultBeanCustom = getStationResultBean(reqBean, productionProcessContext.getWorkCell(), mesProdShiftKvBean);
if (null == resultBeanCustom) this.sendMessage(reqBean, resultBean);
else this.sendMessage(reqBean, new StationResultBean().busiType(MesPcnEnumUtil.STATION_BUSI_TYPE.BUSI_LIST.getValue()).addStationResultBeans(resultBean).addStationResultBeans(resultBeanCustom));
//验证工位是否锁定
reqBean.getDataMap().put(MesPcnEnumUtil.ACTOR_RECEIVE_STRATEGY.WS_CMD_INIT_MODULE.getCode(), CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValueStr());
@ -126,65 +127,58 @@ public class MesProductionNoSortModuleService extends BaseModuleService {
return resultBean;
}
private StationResultBean getStationResultBean(StationRequestBean reqBean, List<StationKvBean> productionStatisticsContext, MesWorkCell mesWorkCell, MesProdShiftContext mesProdShiftKvBean) {
//封装工位展示的客制化信息(优先级: 工位图/视频/柱状图-->加工数)
private StationResultBean getStationResultBean(StationRequestBean reqBean, MesWorkCell workCell, MesProdShiftContext mesProdShiftKvBean) {
StationResultBean resultBean = new StationResultBean();
resultBean.setBusiType(MesPcnEnumUtil.STATION_BUSI_TYPE.MODULE_CUSTOM_CONTENT.getValue());
String dataType = MesPcnEnumUtil.STATION_DATA_TYPE.ECHART.getValue();
JSONObject reqJson = new JSONObject();
String url = "";
List<MesProductionPartContext> productionPartContextList = productionDispatchContextStepService.getProductionPartContext(reqBean);
List<List<StationKvBean>> orderQtyKvBeans = new ArrayList<>();
if (!StringUtils.isEmpty(mesWorkCell.getFileId())) {
DdlPackBean packBean = DdlPackBean.getDdlPackBean();
resultBean.setCustomPageName(MesPcnExtConstWords.CUSTOM_PAGE_NAME_WORK_CELL);
DdlPreparedPack.getNumEqualPack(Long.parseLong(mesWorkCell.getFileId()), MesPcnExtConstWords.ID, packBean);
MesFile mesFile = mesFileRepository.getByProperty(packBean);
if (mesFile != null) {
url = mesFile.getFileUrl();
}
}
if (Objects.equal(MesExtEnumUtil.WORK_FILE_TYPE.HISTOGRAM.getValue(), mesWorkCell.getIsShowMsg())) {
dataType = MesPcnEnumUtil.STATION_DATA_TYPE.ECHART.getValue();
List<MesWorkOrder> workOrderList = workOrderExtService.getWorkOrderListByShiftCode(reqBean.getOrganizeCode(), mesWorkCell.getWorkCenterCode(), mesProdShiftKvBean.getShiftCode());
//验证是否展示柱状图
if (!StringUtils.isEmpty(workCell.getIsShowMsg()) && workCell.getIsShowMsg().compareTo(MesExtEnumUtil.WORK_FILE_TYPE.HISTOGRAM.getValue()) == 0) {
List<MesWorkOrder> workOrderList = workOrderExtService.getWorkOrderListByShiftCode(reqBean.getOrganizeCode(), workCell.getWorkCenterCode(), mesProdShiftKvBean.getShiftCode());
List<List<StationKvBean>> stationKvBeans = new ArrayList<>();
if (CollectionUtils.isEmpty(workOrderList)) {
StationKvBeanUtil.addStationKvBeanList(orderQtyKvBeans, new ArrayList<>(),
StationKvBeanUtil.addStationKvBeanList(stationKvBeans, new ArrayList<>(),
new StationKvBean(MesPcnExtConstWords.QTY, "工单计划数", MesPcnExtConstWords.ZERO_STR),
new StationKvBean(MesPcnExtConstWords.COMPLETE_QTY, "工单完成数", MesPcnExtConstWords.ZERO_STR));
} else {
Double qty = workOrderList.stream().map(MesWorkOrder::getQty).reduce((a, b) -> a + b).get();
Double complateQty = workOrderList.stream().map(MesWorkOrder::getCompleteQty).reduce((a, b) -> a + b).get();
StationKvBeanUtil.addStationKvBeanList(orderQtyKvBeans, new ArrayList<>(),
StationKvBeanUtil.addStationKvBeanList(stationKvBeans, new ArrayList<>(),
new StationKvBean(MesPcnExtConstWords.QTY, "工单计划数", qty.toString()),
new StationKvBean(MesPcnExtConstWords.COMPLETE_QTY, "工单完成数", complateQty.toString()));
}
if (!CollectionUtils.isEmpty(productionPartContextList)) {
resultBean.setDataType(MesPcnEnumUtil.STATION_DATA_TYPE.ECHART.getValue());
resultBean.setResultList(stationKvBeans);
return resultBean;
}
//判断是否配置的是展示文件
String url = null;
if (!StringUtils.isEmpty(workCell.getIsShowMsg()) && !StringUtils.isEmpty(MesExtEnumUtil.WORK_FILE_TYPE.valueOfDescription(workCell.getIsShowMsg()))) {
url = mediaFileCfgService.getMediaFileUrl(reqBean.getOrganizeCode(), workCell.getFileId());
if (!StringUtils.isEmpty(url)) {
JSONObject reqJson = new JSONObject();
if (workCell.getIsShowMsg().compareTo(MesExtEnumUtil.WORK_FILE_TYPE.WORK_CELL_PICTURE.getValue()) == 0) resultBean.setDataType(MesPcnEnumUtil.STATION_DATA_TYPE.IMAGE.getValue());
else resultBean.setDataType(MesPcnEnumUtil.STATION_DATA_TYPE.VIDEO.getValue());
reqJson.put(MesPcnExtConstWords.URL, url);
resultBean.setResultObj(reqJson);
return resultBean;
}
resultBean.setResultList(orderQtyKvBeans);
} else if (Objects.equal(MesExtEnumUtil.WORK_FILE_TYPE.PROD_VIDEO.getValue(), mesWorkCell.getIsShowMsg())) {
dataType = MesPcnEnumUtil.STATION_DATA_TYPE.VIDEO.getValue();
reqJson.put(MesPcnExtConstWords.URL, url);
resultBean.setResultObj(reqJson);
} else if (Objects.equal(MesExtEnumUtil.WORK_FILE_TYPE.WORK_CELL_PICTURE.getValue(), mesWorkCell.getIsShowMsg())) {
dataType = MesPcnEnumUtil.STATION_DATA_TYPE.IMAGE.getValue();
reqJson.put(MesPcnExtConstWords.URL, url);
resultBean.setResultObj(reqJson);
}
if (Objects.equal(CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue(),mesWorkCell.getIsCountFinish())) {
dataType = MesPcnEnumUtil.STATION_DATA_TYPE.TEXT.getValue();
if (StringUtils.isEmpty(url) && !StringUtils.isEmpty(workCell.getIsCountFinish()) && workCell.getIsCountFinish().compareTo(CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue()) == 0) {
//获取上下文工位加工数统计信息
List<StationKvBean> productionStatisticsContext = productionCustomContextStepService.getProductionStatisticsContext(reqBean);
if (CollectionUtils.isEmpty(productionStatisticsContext)) productionStatisticsContext = productionCustomContextStepService.getProductionStatisticsContext(mesProdShiftKvBean, MesPcnExtConstWords.ZERO_STR);
resultBean.setDataType(MesPcnEnumUtil.STATION_DATA_TYPE.TEXT.getValue());
resultBean.setResultList(productionStatisticsContext);
return resultBean;
}
resultBean.setDataType(dataType);
resultBean.setCustomPageName(MesPcnExtConstWords.CUSTOM_PAGE_NAME_WORK_CELL);
return resultBean;
return null;
}
@Override

@ -18,6 +18,7 @@ import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
import cn.estsh.i3plus.pojo.base.enumutil.MesPcnEnumUtil;
import cn.estsh.i3plus.pojo.base.tool.DdlPreparedPack;
import cn.estsh.i3plus.pojo.mes.bean.MesQueueOrder;
import cn.estsh.i3plus.pojo.mes.bean.MesStateMachineStatus;
import cn.estsh.i3plus.pojo.mes.model.AttrBean;
import cn.estsh.i3plus.pojo.mes.model.StationKvBean;
import cn.estsh.i3plus.pojo.mes.model.StationRequestBean;
@ -34,6 +35,7 @@ import org.springframework.util.StringUtils;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@ -64,33 +66,47 @@ public class MesProductionSortModuleService extends BaseModuleService {
MesProductionProcessContext productionProcessContext = productionProcessContextStepService.getProductionProcessContext(reqBean, false);
//配置错误 抛出异常
if (!productionProcessContext.getSuccess()) {
this.sendMessage(reqBean, new StationResultBean().resultObj(MesPcnExtConstWords.STEP_DISABLE_SCAN), String.format("信息: %s!", productionProcessContext.getMessage()), MesPcnEnumUtil.STATION_BUSI_TYPE.STEP_TITLE, MesPcnEnumUtil.STATION_DATA_TYPE.TITLE);
this.sendMessage(reqBean, new StationResultBean().writeDbLog(), productionProcessContext.getMessage(), MesPcnEnumUtil.STATION_BUSI_TYPE.MESSAGE, MesPcnEnumUtil.STATION_DATA_TYPE.EXP_TEXT);
this.sendMessage(reqBean, new StationResultBean()
.busiType(MesPcnEnumUtil.STATION_BUSI_TYPE.BUSI_LIST.getValue())
.addStationResultBeans(new StationResultBean().resultObj(MesPcnExtConstWords.STEP_DISABLE_SCAN)
.busiType(MesPcnEnumUtil.STATION_BUSI_TYPE.STEP_TITLE.getValue()).dataType(MesPcnEnumUtil.STATION_DATA_TYPE.TITLE.getValue()).message(String.format("信息: %s!", productionProcessContext.getMessage())))
.addStationResultBeans(new StationResultBean().writeDbLog()
.busiType(MesPcnEnumUtil.STATION_BUSI_TYPE.MESSAGE.getValue()).dataType(MesPcnEnumUtil.STATION_DATA_TYPE.TEXT.getValue()).message(productionProcessContext.getMessage()))
);
MesPcnException.throwBusiException(productionProcessContext.getMessage());
}
// 获取工单信息
List<List<StationKvBean>> moduleContentContext = productionDispatchContextStepService.getModuleContentContext(reqBean);
// 获取产成零件信息
List<MesProductionPartContext> productionPartContext = productionDispatchContextStepService.getProductionPartContext(reqBean);
// 排除掉空腔的产成零件
productionPartContext = CollectionUtils.isEmpty(productionPartContext) ? null : productionPartContext.stream().filter(o -> o.getForeignKey() != null).collect(Collectors.toList());
//获取班次信息,先查询缓存,缓存没有在查询数据库
List<StationKvBean> prodShiftDataContext = prodShiftRecordService.getShiftRecordStationKvBeans(reqBean.getOrganizeCode(), reqBean.getWorkCenterCode());
if (CollectionUtils.isEmpty(prodShiftDataContext)) {
this.sendMessage(reqBean, new StationResultBean().resultObj(MesPcnExtConstWords.STEP_DISABLE_SCAN), "信息: 请先开班!", MesPcnEnumUtil.STATION_BUSI_TYPE.STEP_TITLE, MesPcnEnumUtil.STATION_DATA_TYPE.TITLE);
this.sendMessage(reqBean, new StationResultBean().writeDbLog(), "请先开班!", MesPcnEnumUtil.STATION_BUSI_TYPE.MESSAGE, MesPcnEnumUtil.STATION_DATA_TYPE.TEXT);
this.sendMessage(reqBean, new StationResultBean()
.busiType(MesPcnEnumUtil.STATION_BUSI_TYPE.BUSI_LIST.getValue())
.addStationResultBeans(new StationResultBean().resultObj(MesPcnExtConstWords.STEP_DISABLE_SCAN)
.busiType(MesPcnEnumUtil.STATION_BUSI_TYPE.STEP_TITLE.getValue()).dataType(MesPcnEnumUtil.STATION_DATA_TYPE.TITLE.getValue()).message("信息: 请先开班!"))
.addStationResultBeans(new StationResultBean().writeDbLog()
.busiType(MesPcnEnumUtil.STATION_BUSI_TYPE.MESSAGE.getValue()).dataType(MesPcnEnumUtil.STATION_DATA_TYPE.TEXT.getValue()).message("请先开班!"))
);
MesPcnException.throwBusiException("请先开班!");
}
// 获取工单信息
List<List<StationKvBean>> moduleContentContext = productionDispatchContextStepService.getModuleContentContext(reqBean);
// 发送班次班组和工单
StationResultBean resultBean = getStationResultBean(reqBean, moduleContentContext, prodShiftDataContext);
this.sendMessage(reqBean, resultBean);
// 获取当前工位最新修改的完成状态的队列单据数据 并根据其零件生产组代码按生产序号倒序前50条
resultBean = getStationResultBean(queryQueueOrderTopFiftyProductSeq(reqBean, getNewPartProdGroupCode(reqBean, productionPartContext)));
this.sendMessage(reqBean, resultBean);
// 获取产成零件信息
List<MesProductionPartContext> productionPartContext = productionDispatchContextStepService.getProductionPartContext(reqBean);
// 排除掉空腔的产成零件
productionPartContext = CollectionUtils.isEmpty(productionPartContext) ? null : productionPartContext.stream().filter(o -> !StringUtils.isEmpty(o.getForeignKey())).collect(Collectors.toList());
//封装工位展示的客制化信息 (获取当前工位最新修改的完成状态的队列单据数据 并根据其零件生产组代码按生产序号倒序前50条)
StationResultBean resultBeanCustom = getStationResultBean(queryQueueOrderTopFiftyProductSeq(reqBean, getNewPartProdGroupCode(reqBean, productionPartContext)));
if (null == resultBeanCustom) this.sendMessage(reqBean, resultBean);
else this.sendMessage(reqBean, new StationResultBean().busiType(MesPcnEnumUtil.STATION_BUSI_TYPE.BUSI_LIST.getValue()).addStationResultBeans(resultBean).addStationResultBeans(resultBeanCustom));
//验证工位是否锁定
reqBean.getDataMap().put(MesPcnEnumUtil.ACTOR_RECEIVE_STRATEGY.WS_CMD_INIT_MODULE.getCode(), CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValueStr());
@ -99,9 +115,9 @@ public class MesProductionSortModuleService extends BaseModuleService {
}
private StationResultBean getStationResultBean(List<MesQueueOrderModel> mesQueueOrderModelList) {
if (CollectionUtils.isEmpty(mesQueueOrderModelList)) return null;
return new StationResultBean().busiType(MesPcnEnumUtil.STATION_BUSI_TYPE.MODULE_CUSTOM_CONTENT.getValue())
.customPageName(MesPcnExtConstWords.CUSTOM_PAGE_NAME_WORK_CELL)
.dataType(MesPcnEnumUtil.STATION_DATA_TYPE.TABLE.getValue())
.dataType(MesPcnEnumUtil.STATION_DATA_TYPE.TABLE.getValue()).customPageName(MesPcnExtConstWords.CUSTOM_PAGE_NAME_WORK_CELL)
.dataAttrList(dataAttrList()).resultList(mesQueueOrderModelList);
}
@ -117,9 +133,9 @@ public class MesProductionSortModuleService extends BaseModuleService {
private List<MesQueueOrderModel> queryQueueOrderTopFiftyProductSeq(StationRequestBean reqBean, List<String> partProdGroupCodeList) {
if (CollectionUtils.isEmpty(partProdGroupCodeList)) return new ArrayList<>();
if (CollectionUtils.isEmpty(partProdGroupCodeList)) return null;
List<MesQueueOrderModel> queueOrderModels = new ArrayList<>();
List<MesQueueOrderModel> queueOrderModelList = null;
for (String partProdGroupCode : partProdGroupCodeList) {
Pager pager = new Pager();
pager.setStartRow(1);
@ -133,9 +149,8 @@ public class MesProductionSortModuleService extends BaseModuleService {
List<MesQueueOrder> queueOrderList = queueOrderRepository.findByHqlWherePage(packBean, pager);
if (!CollectionUtils.isEmpty(queueOrderList)) {
boolean isComplete = false;
int index = MesPcnExtConstWords.ONE;
Boolean isComplete = false;
Integer index = MesPcnExtConstWords.ONE;
for (MesQueueOrder mesQueueOrder : queueOrderList) {
MesQueueOrderModel queueOrderModel = new MesQueueOrderModel();
BeanUtils.copyProperties(mesQueueOrder, queueOrderModel);
@ -145,13 +160,15 @@ public class MesProductionSortModuleService extends BaseModuleService {
//跳号标黄色
if (index < queueOrderList.size() && checkJumpNumber(queueOrderList.get(index).getWorkOrderSeq(), mesQueueOrder.getWorkOrderSeq())) color = MesExtEnumUtil.COLOR.YELLOW.getValue();
queueOrderModel.setColor(color);
queueOrderModels.add(queueOrderModel);
index++;
if (CollectionUtils.isEmpty(queueOrderModelList)) queueOrderModelList = new ArrayList<>();
queueOrderModelList.add(queueOrderModel);
index ++;
}
}
}
return queueOrderModels;
return queueOrderModelList;
}
private List<String> getNewPartProdGroupCode(StationRequestBean reqBean, List<MesProductionPartContext> productionPartContext) {
@ -165,7 +182,6 @@ public class MesProductionSortModuleService extends BaseModuleService {
return queueOrder == null ? null : Stream.of(queueOrder.getPartProdGroupCode()).collect(Collectors.toList());
}
private boolean checkJumpNumber(String nextWorkOrderSeq, String currentWorkOrderSeq) {
if (StringUtils.isEmpty(nextWorkOrderSeq) || StringUtils.isEmpty(currentWorkOrderSeq) || !CheckTool.isNumber(nextWorkOrderSeq) || !CheckTool.isNumber(currentWorkOrderSeq)) return false;
return Integer.parseInt(currentWorkOrderSeq) != Integer.parseInt(nextWorkOrderSeq) + MesPcnExtConstWords.ONE;
@ -192,4 +208,10 @@ public class MesProductionSortModuleService extends BaseModuleService {
return resultBean;
}
@Override
public boolean execStateModule(StationRequestBean reqBean, List<MesStateMachineStatus> states, Map<String, String> wcpcMap) {
init(reqBean);
return true;
}
}

@ -1,39 +1,26 @@
package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.station.function;
import cn.estsh.i3plus.ext.mes.pcn.api.base.IMesMediaFileCfgService;
import cn.estsh.i3plus.ext.mes.pcn.api.base.IMesProdShiftRecordService;
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesProductionCustomContextStepService;
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesProductionDispatchContextStepService;
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesProductionProcessContextStepService;
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesWorkOrderExtService;
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProdShiftContext;
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProductionPartContext;
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProductionProcessContext;
import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtConstWords;
import cn.estsh.i3plus.mes.pcn.serviceimpl.fsm.BaseSwsService;
import cn.estsh.i3plus.mes.pcn.serviceimpl.fsm.function.IFsmModuleFunctionService;
import cn.estsh.i3plus.mes.pcn.util.StationKvBeanUtil;
import cn.estsh.i3plus.pojo.base.bean.DdlPackBean;
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
import cn.estsh.i3plus.pojo.base.enumutil.MesPcnEnumUtil;
import cn.estsh.i3plus.pojo.base.tool.DdlPreparedPack;
import cn.estsh.i3plus.pojo.mes.bean.MesFile;
import cn.estsh.i3plus.pojo.mes.bean.MesWorkCell;
import cn.estsh.i3plus.pojo.mes.bean.MesWorkOrder;
import cn.estsh.i3plus.pojo.mes.model.ButtonDynamicModel;
import cn.estsh.i3plus.pojo.mes.model.StationKvBean;
import cn.estsh.i3plus.pojo.mes.model.StationRequestBean;
import cn.estsh.i3plus.pojo.mes.model.StationResultBean;
import cn.estsh.i3plus.pojo.mes.repository.MesFileRepository;
import cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil;
import com.alibaba.fastjson.JSONObject;
import com.google.common.base.Objects;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import java.util.ArrayList;
import java.util.List;
import java.util.StringJoiner;
/**
* @Description :
@ -45,94 +32,56 @@ public class MesFunctionProductionStatisticsService extends BaseSwsService imple
private IMesProductionCustomContextStepService productionCustomContextStepService;
@Autowired
private MesFileRepository mesFileRepository;
private IMesMediaFileCfgService mediaFileCfgService;
@Autowired
private IMesWorkOrderExtService workOrderExtService;
@Autowired
private IMesProductionDispatchContextStepService productionDispatchContextStepService;
private IMesProductionProcessContextStepService productionProcessContextStepService;
@Autowired
private IMesProductionProcessContextStepService productionProcessContextStepService;
private IMesProdShiftRecordService prodShiftRecordService;
@Override
public Boolean doFunction(StationRequestBean reqBean, StationResultBean resultBean, ButtonDynamicModel buttonDynamicModel) {
productionCustomContextStepService.removeProductionStatisticsContext(reqBean);
this.sendMessage(reqBean, resultBean.writeDbLog(MesPcnEnumUtil.WORK_CELL_SCAN_MONITOR_LOG_TYPE.PICK.getValue()).scanInfo(buttonDynamicModel.getFunctionValue()),
String.format("生产线[%s]工位[%s]%s成功!", reqBean.getWorkCenterCode(), reqBean.getWorkCellCode(), buttonDynamicModel.getButtonName()), MesPcnEnumUtil.STATION_BUSI_TYPE.MESSAGE, MesPcnEnumUtil.STATION_DATA_TYPE.TEXT);
// 刷新加工数
MesProductionProcessContext productionProcessContext = productionProcessContextStepService.getEquipmentVariableList(reqBean, MesExtEnumUtil.EQUIP_VARIABLE_TYPE.PRODUCTION.getValue());
MesWorkCell mesWorkCell = productionProcessContext.getWorkCell();
//重置页面的加工数
resetStationData(reqBean, productionProcessContextStepService.getProductionProcessContext(reqBean, false).getWorkCell());
MesProdShiftContext mesProdShiftKvBean = productionCustomContextStepService.getMesProdShiftKvBean(reqBean.getOrganizeCode(), reqBean.getWorkCenterCode());
return true;
List<StationKvBean> productionStatisticsContext = StationKvBeanUtil.addStationKvBeanList(new ArrayList<>(), new StationKvBean(new StringJoiner(MesPcnExtConstWords.AND).add(mesProdShiftKvBean.getShiftGroup()).add(mesProdShiftKvBean.getShiftCode()).toString(), "加工数", "0"),
new StationKvBean("color", "颜色", MesExtEnumUtil.COLOR.BLACK.getValue()));
}
StationResultBean shiftCountBean = getStationResultBean(reqBean, productionStatisticsContext,mesWorkCell, mesProdShiftKvBean);
//重置页面的加工数
private void resetStationData(StationRequestBean reqBean, MesWorkCell workCell) {
if (null == workCell) return;
this.sendMessage(reqBean, shiftCountBean);
//如果工位当前配置的是展示柱状图则无须重置加工数
if (!StringUtils.isEmpty(workCell.getIsShowMsg()) && workCell.getIsShowMsg().compareTo(MesExtEnumUtil.WORK_FILE_TYPE.HISTOGRAM.getValue()) == 0) return;
return true;
}
private StationResultBean getStationResultBean(StationRequestBean reqBean, List<StationKvBean> productionStatisticsContext, MesWorkCell mesWorkCell, MesProdShiftContext mesProdShiftKvBean) {
StationResultBean resultBean = new StationResultBean();
resultBean.setBusiType(MesPcnEnumUtil.STATION_BUSI_TYPE.MODULE_CUSTOM_CONTENT.getValue());
String dataType = MesPcnEnumUtil.STATION_DATA_TYPE.ECHART.getValue();
JSONObject reqJson = new JSONObject();
String url = "";
List<List<StationKvBean>> orderQtyKvBeans = new ArrayList<>();
if (!StringUtils.isEmpty(mesWorkCell.getFileId())) {
DdlPackBean packBean = DdlPackBean.getDdlPackBean();
DdlPreparedPack.getNumEqualPack(Long.parseLong(mesWorkCell.getFileId()), "id", packBean);
MesFile mesFile = mesFileRepository.getByProperty(packBean);
if (mesFile != null) {
url = mesFile.getFileUrl();
}
}
if (Objects.equal(MesExtEnumUtil.WORK_FILE_TYPE.HISTOGRAM.getValue(), mesWorkCell.getIsShowMsg())) {
dataType = MesPcnEnumUtil.STATION_DATA_TYPE.ECHART.getValue();
List<MesWorkOrder> workOrderList = workOrderExtService.getWorkOrderListByShiftCode(reqBean.getOrganizeCode(), mesWorkCell.getWorkCenterCode(), mesProdShiftKvBean.getShiftCode());
if (CollectionUtils.isEmpty(workOrderList)) {
StationKvBeanUtil.addStationKvBeanList(orderQtyKvBeans, new ArrayList<>(),
new StationKvBean(MesPcnExtConstWords.QTY, "工单计划数", 0 + ""),
new StationKvBean(MesPcnExtConstWords.COMPLETE_QTY, "工单完成数", 0 + ""));
} else {
double qty = workOrderList.stream().map(MesWorkOrder::getQty).reduce((a, b) -> a + b).get();
double complateQty = workOrderList.stream().map(MesWorkOrder::getCompleteQty).reduce((a, b) -> a + b).get();
StationKvBeanUtil.addStationKvBeanList(orderQtyKvBeans, new ArrayList<>(),
new StationKvBean(MesPcnExtConstWords.QTY, "工单计划数", qty + ""),
new StationKvBean(MesPcnExtConstWords.COMPLETE_QTY, "工单完成数", complateQty + ""));
}
resultBean.setResultList(orderQtyKvBeans);
} else if (Objects.equal(MesExtEnumUtil.WORK_FILE_TYPE.PROD_VIDEO.getValue(), mesWorkCell.getIsShowMsg())) {
dataType = MesPcnEnumUtil.STATION_DATA_TYPE.VIDEO.getValue();
reqJson.put("url", url);
resultBean.setResultObj(reqJson);
} else if (Objects.equal(MesExtEnumUtil.WORK_FILE_TYPE.WORK_CELL_PICTURE.getValue(), mesWorkCell.getIsShowMsg())) {
dataType = MesPcnEnumUtil.STATION_DATA_TYPE.IMAGE.getValue();
reqJson.put("url", url);
resultBean.setResultObj(reqJson);
//判断是否配置的是展示文件
String url = null;
if (!StringUtils.isEmpty(workCell.getIsShowMsg()) && !StringUtils.isEmpty(MesExtEnumUtil.WORK_FILE_TYPE.valueOfDescription(workCell.getIsShowMsg()))) {
url = mediaFileCfgService.getMediaFileUrl(reqBean.getOrganizeCode(), workCell.getFileId());
}
if (Objects.equal(CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue(),mesWorkCell.getIsCountFinish())) {
dataType = MesPcnEnumUtil.STATION_DATA_TYPE.TEXT.getValue();
//如果不存在文件, 且当前工位配置需要统计加工数的情况下才进行重置加工数
if (StringUtils.isEmpty(url) && !StringUtils.isEmpty(workCell.getIsCountFinish()) && workCell.getIsCountFinish().compareTo(CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue()) == 0) {
//获取生产线的当前班组班次信息
MesProdShiftContext mesProdShiftKvBean = prodShiftRecordService.getMesProdShiftKvBean(reqBean.getOrganizeCode(), reqBean.getWorkCenterCode());
List<StationKvBean> productionStatisticsContext = productionCustomContextStepService.getProductionStatisticsContext(mesProdShiftKvBean, MesPcnExtConstWords.ZERO_STR);
StationResultBean resultBean = new StationResultBean();
resultBean.setBusiType(MesPcnEnumUtil.STATION_BUSI_TYPE.MODULE_CUSTOM_CONTENT.getValue());
resultBean.setDataType(MesPcnEnumUtil.STATION_DATA_TYPE.TEXT.getValue());
resultBean.setCustomPageName(MesPcnExtConstWords.CUSTOM_PAGE_NAME_WORK_CELL);
resultBean.setResultList(productionStatisticsContext);
this.sendMessage(reqBean, resultBean);
}
resultBean.setDataType(dataType);
resultBean.setCustomPageName(MesPcnExtConstWords.CUSTOM_PAGE_NAME_WORK_CELL);
return resultBean;
}
}

@ -184,10 +184,12 @@ public class MesAssemblyGeneratePartNoStepService extends BaseStepService {
return stepDynamicsCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog().scanInfo(assemblySn), stepResult,
isEnoughQty ? true : stepResult.isCompleted(false).nextTriggerEvent(MesPcnExtConstWords.NEXT_TRIGGER_EVENT_PRODUCT_SN).isCompleted(),
MesPcnEnumUtil.STATION_BUSI_TYPE.MESSAGE, MesPcnEnumUtil.STATION_DATA_TYPE.TEXT,
String.format("%s装配件条码%s匹配成功!当前扫描的主条码数量[%s]%s设备腔数[%s]!", suffix, assemblySn, productionPsInContextList.size(), isEnoughQty ? "已满足" : "未满足", cellEquipContext.getCavity()));
String.format("%s装配件条码%s匹配成功!当前扫描的主条码数量[%s]%s设备腔数[%s]!", suffix, assemblySn, productionPsInContextList.size(), isEnoughQty ? "已满足" : "未满足", cellEquipContext.getCavity()),
MesPcnEnumUtil.PROMPT_SOUND.SUCCESS.getValue());
}
return stepSuccessCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog().scanInfo(assemblySn), stepResult, String.format("装配件条码%s匹配成功!", assemblySn));
return stepSuccessCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog().scanInfo(assemblySn), stepResult, String.format("装配件条码%s匹配成功!", assemblySn),
MesPcnEnumUtil.PROMPT_SOUND.SUCCESS.getValue());
}

@ -184,10 +184,12 @@ public class MesAssemblyMatchNosortRetrodictStepService extends BaseStepService
return stepDynamicsCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog().scanInfo(assemblySn), stepResult,
isEnoughQty ? true : stepResult.isCompleted(false).nextTriggerEvent(MesPcnExtConstWords.NEXT_TRIGGER_EVENT_PRODUCT_SN).isCompleted(),
MesPcnEnumUtil.STATION_BUSI_TYPE.MESSAGE, MesPcnEnumUtil.STATION_DATA_TYPE.TEXT,
String.format("%s装配件条码%s匹配成功!当前扫描的主条码数量[%s]%s设备腔数[%s]!", suffix, assemblySn, productionPsInContextList.size(), isEnoughQty ? "已满足" : "未满足", cellEquipContext.getCavity()));
String.format("%s装配件条码%s匹配成功!当前扫描的主条码数量[%s]%s设备腔数[%s]!", suffix, assemblySn, productionPsInContextList.size(), isEnoughQty ? "已满足" : "未满足", cellEquipContext.getCavity()),
MesPcnEnumUtil.PROMPT_SOUND.SUCCESS.getValue());
}
return stepSuccessCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog().scanInfo(assemblySn), stepResult, String.format("装配件条码%s匹配成功!", assemblySn));
return stepSuccessCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog().scanInfo(assemblySn), stepResult, String.format("装配件条码%s匹配成功!", assemblySn),
MesPcnEnumUtil.PROMPT_SOUND.SUCCESS.getValue());
}

@ -100,7 +100,7 @@ public class MesAssemblyMatchNosortStepService extends BaseStepService {
if (!isNeedScanAssembly || !hasUnBindAssembly) {
return stepDynamicsCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(), stepResult,
(CollectionUtils.isEmpty(productionPsInContextList) || productionPsInContextList.size() >= needQty) ? true : stepResult.isCompleted(false).nextTriggerEvent(MesPcnExtConstWords.NEXT_TRIGGER_EVENT_PRODUCT_SN).isCompleted(),
MesPcnEnumUtil.STATION_BUSI_TYPE.MESSAGE, MesPcnEnumUtil.STATION_DATA_TYPE.TEXT, !isNeedScanAssembly ? "当前加工规则未配置装配件扫描项,当前无需匹配装配件条码!" : "当前加工规则对应的装配件扫描项均匹配完毕!");
MesPcnEnumUtil.STATION_BUSI_TYPE.RUNNING_INFO, MesPcnEnumUtil.STATION_DATA_TYPE.TEXT, !isNeedScanAssembly ? "当前加工规则无装配件清单,当前无需匹配装配件条码!" : "当前加工规则对应的装配件清单均匹配完毕!");
}
//获取上下文生产扫/读信息:装配件条码
@ -136,12 +136,16 @@ public class MesAssemblyMatchNosortStepService extends BaseStepService {
if (!hasUnBindAssembly) {
return stepDynamicsCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog().scanInfo(assemblySn), stepResult,
(CollectionUtils.isEmpty(productionPsInContextList) || productionPsInContextList.size() >= needQty) ? true : stepResult.isCompleted(false).nextTriggerEvent(MesPcnExtConstWords.NEXT_TRIGGER_EVENT_PRODUCT_SN).isCompleted(),
MesPcnEnumUtil.STATION_BUSI_TYPE.MESSAGE, MesPcnEnumUtil.STATION_DATA_TYPE.TEXT, String.format("%s当前加工规则对应的装配件扫描项均匹配完毕!", suffix));
MesPcnEnumUtil.STATION_BUSI_TYPE.MESSAGE, MesPcnEnumUtil.STATION_DATA_TYPE.TEXT, String.format("%s当前加工规则对应的装配件清单均匹配完毕!", suffix),
MesPcnEnumUtil.PROMPT_SOUND.SUCCESS.getValue());
}
//单次匹配成功
if (result) return stepDynamicsCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog().scanInfo(assemblySn),
stepResult.nextTriggerEvent(MesPcnExtConstWords.NEXT_TRIGGER_EVENT_ASSEMBLY), false, MesPcnEnumUtil.STATION_BUSI_TYPE.MESSAGE, MesPcnEnumUtil.STATION_DATA_TYPE.TEXT, suffix);
if (result) {
return stepDynamicsCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog().scanInfo(assemblySn),
stepResult.nextTriggerEvent(MesPcnExtConstWords.NEXT_TRIGGER_EVENT_ASSEMBLY), false, MesPcnEnumUtil.STATION_BUSI_TYPE.MESSAGE, MesPcnEnumUtil.STATION_DATA_TYPE.TEXT, suffix,
MesPcnEnumUtil.PROMPT_SOUND.SUCCESS.getValue());
}
//匹配失败验证是否重置装配件扫描项
MesWorkCell workCell = productionProcessContext.getWorkCell();

@ -72,11 +72,17 @@ public class MesAssemblyMatchSortStepService extends BaseStepService {
if (CollectionUtils.isEmpty(prodRuleContextList)) stepExpSendMsgAndThrowEx(reqBean, resultBean.writeDbLog(), "当前不存在非排序加工规则数据,请重置工序!");
//判断是否存在装配件清单
if (!checkIsNeedScanAssembly(prodRuleContextList)) return stepSuccessCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(), stepResult, "当前加工规则未配置装配件扫描项,当前无需匹配装配件条码!");
if (!checkIsNeedScanAssembly(prodRuleContextList)) {
return stepDynamicsCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(), stepResult, true,
MesPcnEnumUtil.STATION_BUSI_TYPE.RUNNING_INFO, MesPcnEnumUtil.STATION_DATA_TYPE.TEXT, "当前加工规则无装配件清单,当前无需匹配装配件条码!");
}
//验证是否存在待绑定数据
Boolean hasUnBindAssembly = hasUnBindAssembly(prodRuleContextList);
if (!hasUnBindAssembly) return stepSuccessCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(), stepResult, "当前加工规则对应的装配件扫描项均匹配完毕!");
if (!hasUnBindAssembly) {
return stepDynamicsCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(), stepResult, true,
MesPcnEnumUtil.STATION_BUSI_TYPE.RUNNING_INFO, MesPcnEnumUtil.STATION_DATA_TYPE.TEXT, "当前加工规则对应的装配件清单均匹配完毕!");
}
//获取上下文生产扫/读信息:装配件条码
List<MesEquipVariableCollectContext> equipVariableCollectContextList = productionDispatchContextStepService.getScanAssemblySnContext(reqBean);
@ -113,11 +119,17 @@ public class MesAssemblyMatchSortStepService extends BaseStepService {
}
//验证是否存在待绑定数据
if (!hasUnBindAssembly) return stepSuccessCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(), stepResult, String.format("%s当前加工规则对应的装配件扫描项均匹配完毕!", suffix));
if (!hasUnBindAssembly) {
return stepSuccessCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(), stepResult, String.format("%s当前加工规则对应的装配件清单均匹配完毕!", suffix),
MesPcnEnumUtil.PROMPT_SOUND.SUCCESS.getValue());
}
//单次匹配成功
if (result) return stepDynamicsCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog().scanInfo(assemblySn),
stepResult.nextTriggerEvent(MesPcnExtConstWords.NEXT_TRIGGER_EVENT_ASSEMBLY), false, MesPcnEnumUtil.STATION_BUSI_TYPE.MESSAGE, MesPcnEnumUtil.STATION_DATA_TYPE.TEXT, suffix);
if (result) {
return stepDynamicsCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog().scanInfo(assemblySn),
stepResult.nextTriggerEvent(MesPcnExtConstWords.NEXT_TRIGGER_EVENT_ASSEMBLY), false, MesPcnEnumUtil.STATION_BUSI_TYPE.MESSAGE, MesPcnEnumUtil.STATION_DATA_TYPE.TEXT, suffix,
MesPcnEnumUtil.PROMPT_SOUND.SUCCESS.getValue());
}
stepResult.msg(String.format("装配件条码%s匹配失败!%s", assemblySn, StringUtils.isEmpty(stepResult.getMsg()) ? MesPcnExtConstWords.EMPTY : stepResult.getMsg()));

@ -106,8 +106,10 @@ public class MesAssemblyReadStepService extends BaseStepService {
List<MesProdRuleContext> prodRuleContextList = productionDispatchContextStepService.getProdRuleDataContext(reqBean);
//验证当前是否需要读装配件条码: 是否存在装配件清单
if (!CollectionUtils.isEmpty(prodRuleContextList) && !checkIsNeedReedAssembly(prodRuleContextList))
return stepSuccessCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(), stepResult, String.format("当前加工规则未配置装配件扫描项,无需读设备[%s]装配件条码!", cellEquipContext.getEquipmentName()));
if (!CollectionUtils.isEmpty(prodRuleContextList) && !checkIsNeedReedAssembly(prodRuleContextList)) {
return stepDynamicsCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(), stepResult, true,
MesPcnEnumUtil.STATION_BUSI_TYPE.RUNNING_INFO, MesPcnEnumUtil.STATION_DATA_TYPE.TEXT, String.format("当前加工规则未装配件清单,无需读设备[%s]装配件条码!", cellEquipContext.getEquipmentName()));
}
//获取生产过程上下文对象有异常信息 抛出异常
if (!productionProcessContextStepService.getEquipmentVariableCfgList(productionProcessContext).getSuccess()) stepExpSendMsgAndThrowEx(reqBean, resultBean.writeDbLog(), productionProcessContext.getMessage());

@ -25,10 +25,7 @@ import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.*;
import java.util.stream.Collectors;
/**
@ -78,6 +75,12 @@ public class MesAssemblySaveStepService extends BaseStepService {
if (CollectionUtils.isEmpty(prodRuleContextList)) stepExpSendMsgAndThrowEx(reqBean, resultBean.writeDbLog(), "当前不存在非排序加工规则数据,请重置工序!");
//判断是否存在装配件清单
if (!checkIsNeedScanAssembly(prodRuleContextList)) {
return stepDynamicsCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(), stepResult, true,
MesPcnEnumUtil.STATION_BUSI_TYPE.RUNNING_INFO, MesPcnEnumUtil.STATION_DATA_TYPE.TEXT, "当前加工规则无装配件清单,当前无需保存装配件记录!");
}
//获取上下文产出条码数据信息集合
List<MesProductionPsOutContext> productionPsOutContextList = productionDispatchContextStepService.getProductionPsOutContext(reqBean);
@ -101,6 +104,12 @@ public class MesAssemblySaveStepService extends BaseStepService {
}
//判断是否存在装配件清单
private Boolean checkIsNeedScanAssembly(List<MesProdRuleContext> prodRuleContextList) {
Optional<MesProdRuleContext> optional = prodRuleContextList.stream().filter(o -> (null != o && !StringUtils.isEmpty(o.getAssemblyDataJson()))).findFirst();
return (null == optional || !optional.isPresent()) ? false : true;
}
private void saveProductionAssemblyData(StationRequestBean reqBean, List<Long> productSnIdList, MesProductionProcessContext productionProcessContext, MesProdRuleContext prodRuleContext,
Map<Integer, MesProductionPsOutContext> ppMap, MesCellEquipContext cellEquipContext, MesScanMonitorContext scanMonitorContext) {

@ -86,19 +86,25 @@ public class MesAssemblyScanStepService extends BaseStepService {
Integer busiType = getBusiType(productionPsInContextListNoFinishCode, prodRuleContextList);
//验证场景1 当前是否需要扫描装配件条码: 是否存在装配件清单 【当前验证只能对内部触发生效】
if (busiType == BUSI_TYPE.ONE.value && !CollectionUtils.isEmpty(prodRuleContextList) && !checkIsNeedScanAssembly(prodRuleContextList))
return stepSuccessCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(), stepResult, "当前加工规则未配置装配件扫描项,当前无需扫描装配件条码!");
if (busiType == BUSI_TYPE.ONE.value && !CollectionUtils.isEmpty(prodRuleContextList) && !checkIsNeedScanAssembly(prodRuleContextList)) {
return stepDynamicsCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(), stepResult, true,
MesPcnEnumUtil.STATION_BUSI_TYPE.RUNNING_INFO, MesPcnEnumUtil.STATION_DATA_TYPE.TEXT, "当前加工规则无装配件清单,当前无需扫描装配件条码!");
}
//场景1 处理装配件的装配爆炸图和音频文件
if (busiType == BUSI_TYPE.ONE.value) doHandleAssemblyFile(reqBean, productionProcessContext.getWorkCenter(), prodRuleContextList);
//验证场景1 当前是否需要扫描装配件条码: 验证是否存在待绑定数据 【当前验证只能对内部触发生效】
if (busiType == BUSI_TYPE.ONE.value && !CollectionUtils.isEmpty(prodRuleContextList) && !hasUnBindAssembly(prodRuleContextList))
return stepSuccessCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(), stepResult, "当前加工规则对应的装配件清单已扫描完毕,当前无需扫描装配件条码!");
if (busiType == BUSI_TYPE.ONE.value && !CollectionUtils.isEmpty(prodRuleContextList) && !hasUnBindAssembly(prodRuleContextList)) {
return stepDynamicsCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(), stepResult, true,
MesPcnEnumUtil.STATION_BUSI_TYPE.RUNNING_INFO, MesPcnEnumUtil.STATION_DATA_TYPE.TEXT, "当前加工规则对应的装配件清单已扫描完毕,当前无需扫描装配件条码!");
}
//验证场景3的当前未匹配的主条码是否是空腔码
if (busiType == BUSI_TYPE.THREE.value && CollectionUtils.isEmpty(curProductionPsInContextList))
return stepSuccessCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(), stepResult, "当前主条码对应的装配件清单已扫描完毕,当前无需扫描装配件条码!");
if (busiType == BUSI_TYPE.THREE.value && CollectionUtils.isEmpty(curProductionPsInContextList)) {
return stepDynamicsCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(), stepResult, true,
MesPcnEnumUtil.STATION_BUSI_TYPE.RUNNING_INFO, MesPcnEnumUtil.STATION_DATA_TYPE.TEXT, "当前主条码对应的装配件清单已扫描完毕,当前无需扫描装配件条码!");
}
if (StringUtils.isEmpty(scanInfo)) stepSendGuideAndThrowEx(reqBean, resultBean.writeDbLog(MesPcnEnumUtil.WORK_CELL_SCAN_MONITOR_LOG_TYPE.PROCESS.getValue()), "请扫描装配件条码!");
@ -274,9 +280,9 @@ public class MesAssemblyScanStepService extends BaseStepService {
ONE(1, "唯一加工规则场景或排序线"),//通过 产出零件 + 进料条码零件 + 设备 找到唯一的非排序产品加工规则, 产出零件与进料条码零件至少存在1个 或者 排序线
TWO(2, "无进无出扫装配件生成零件号场景"),//产出零件与进料条码零件均不扫描, 直接扫描装配件, 通过生成零件号工步反向匹配非排序产品加工规则
TWO(2, "无出无进扫装配件,非排序无显示装配件匹配场景"),//产出零件与进料条码零件均不扫描, 直接扫描装配件, 通过非排序无显示装配件匹配工步反向匹配非排序产品加工规则
THREE(3, "有进未匹配加工规则扫装配件生成零件号场景");//产出零件不扫描, 扫描进料条码零件 + 设备 会对应多个非排序产品加工规则, 通过扫描装配件, 生成零件号工步反向匹配非排序产品加工规则, 将匹配的规则再匹配进料条码零件
THREE(3, "无出有进扫装配件,非排序无显示装配件匹配场景");//产出零件不扫描, 扫描进料条码零件, 扫描装配, 通过非排序无显示装配件匹配工步反向匹配非排序产品加工规则, 将匹配的规则再匹配进料条码零件
private Integer value;

@ -74,7 +74,7 @@ public class MesAssemblyScanStepServiceBak extends BaseStepService {
//验证当前是否需要扫描装配件条码: 是否存在装配件清单 【当前验证只能对内部触发生效】
if (!CollectionUtils.isEmpty(prodRuleContextList) && !checkIsNeedScanAssembly(prodRuleContextList))
return stepSuccessCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(), stepResult, "当前加工规则未配置装配件扫描项,当前无需扫描装配件条码!");
return stepSuccessCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(), stepResult, "当前加工规则无配置装配件清单,当前无需扫描装配件条码!");
//处理装配件的装配爆炸图和音频文件
doHandleAssemblyFile(reqBean, productionProcessContext.getWorkCenter(), prodRuleContextList);

@ -111,9 +111,11 @@ public class MesAssemblyShowNosortStepService extends BaseStepService {
}
//显示装配件信息
showProductionAssembly(reqBean, resultBean, workCenter, prodRuleContextList);
Boolean isShow = showProductionAssembly(reqBean, resultBean, workCenter, prodRuleContextList);
return stepSuccessCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(MesPcnEnumUtil.WORK_CELL_SCAN_MONITOR_LOG_TYPE.PROCESS.getValue()), stepResult, "装配件扫描项已查询完毕,请查看!");
return stepSuccessCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(MesPcnEnumUtil.WORK_CELL_SCAN_MONITOR_LOG_TYPE.PROCESS.getValue()), stepResult,
isShow ? "已显示装配件清单,请查看!" : "当前腔匹配的加工规则无装配件清单!",
MesPcnEnumUtil.PROMPT_SOUND.SUCCESS.getValue());
}
private StepResult doHandleProdRuleData(StationRequestBean reqBean, StationResultBean resultBean, StepResult stepResult, MesWorkCenter workCenter, MesProductionProcessContext productionProcessContext, MesCellEquipContext cellEquipContext,
@ -468,6 +470,8 @@ public class MesAssemblyShowNosortStepService extends BaseStepService {
}
if (CollectionUtils.isEmpty(allAssemblyList)) return false;
//获取前端置顶信息 【sourceId&MatchDatetime】
String topRowInfo = getTopRowInfo(allAssemblyList);

@ -104,10 +104,11 @@ public class MesAssemblyShowSortStepService extends BaseStepService {
}
//显示装配件信息
if (!showProductionAssembly(reqBean, resultBean, workCenter, prodRuleContextList))
return stepSuccessCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(MesPcnEnumUtil.WORK_CELL_SCAN_MONITOR_LOG_TYPE.PROCESS.getValue()), stepResult, "当前未查询到相关的装配件清单");
Boolean isShow = showProductionAssembly(reqBean, resultBean, workCenter, prodRuleContextList);
return stepSuccessCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(MesPcnEnumUtil.WORK_CELL_SCAN_MONITOR_LOG_TYPE.PROCESS.getValue()), stepResult, "显示装配件扫描项成功!");
return stepSuccessCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(MesPcnEnumUtil.WORK_CELL_SCAN_MONITOR_LOG_TYPE.PROCESS.getValue()), stepResult,
isShow ? "已显示装配件清单,请查看!" : "当前腔匹配的加工规则无装配件清单!",
MesPcnEnumUtil.PROMPT_SOUND.SUCCESS.getValue());
}

@ -0,0 +1,71 @@
package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.step;
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProdRuleContext;
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProductionAssemblyNosortContext;
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProductionProcessContext;
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProductionPsOutContext;
import cn.estsh.i3plus.pojo.base.enumutil.MesPcnEnumUtil;
import cn.estsh.i3plus.pojo.mes.bean.MesBarcodeCountShareInfo;
import cn.estsh.i3plus.pojo.mes.model.StationRequestBean;
import cn.estsh.i3plus.pojo.mes.model.StationResultBean;
import cn.estsh.i3plus.pojo.mes.model.StepResult;
import cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import java.util.List;
/**
* @Description :
* @Author : wangjie
**/
@Slf4j
@Service("mesBarcodeCountShareAssemblySnSaveStepService")
public class MesBarcodeCountShareAssemblySnSaveStepService extends MesBarcodeCountShareInfoSaveStepService {
@Override
public StepResult execute(StationRequestBean reqBean) {
StationResultBean resultBean = new StationResultBean();
StepResult stepResult = StepResult.getSuccessComplete();
//获取上下文信息
MesProductionProcessContext productionProcessContext = productionProcessContextStepService.dispatchCurCellEquipment(reqBean);
//配置错误 抛出异常
if (!productionProcessContext.getSuccess()) stepExpSendMsgAndThrowEx(reqBean, resultBean.writeDbLog(), productionProcessContext.getMessage());
//存储生产过程上下文对象
productionProcessContextStepService.dispatchProductionProcessContext(reqBean, productionProcessContext);
//获取上下文产出条码数据信息集合
List<MesProductionPsOutContext> productionPsOutContextList = productionDispatchContextStepService.getProductionPsOutContext(reqBean);
if (CollectionUtils.isEmpty(productionPsOutContextList)) stepExpSendMsgAndThrowEx(reqBean, resultBean.writeDbLog(), "当前不存在产出零件条码信息,请重置工序解决!");
//获取上下文产品加工规则数据信息集合
List<MesProdRuleContext> prodRuleContextList = productionDispatchContextStepService.getProdRuleDataContext(reqBean);
if (CollectionUtils.isEmpty(prodRuleContextList)) stepExpSendMsgAndThrowEx(reqBean, resultBean.writeDbLog(), "当前不存在非排序加工规则数据,请重置工序!");
prodRuleContextList.stream().filter(o -> (null != o && !StringUtils.isEmpty(o.getAssemblyDataJson()))).forEach(o -> {
List<MesProductionAssemblyNosortContext> productionAssemblyNosortContextList = o.getNosortAssemblyDataContext();
if (!CollectionUtils.isEmpty(productionAssemblyNosortContextList)) {
MesProductionPsOutContext productionPsOutContext = productionPsOutContextList.stream().filter(i -> (null != i && i.getForeignKey().compareTo(o.getForeignKey()) == 0)).findFirst().get();
for (MesProductionAssemblyNosortContext productionAssemblyNosortContext : productionAssemblyNosortContextList) {
if (StringUtils.isEmpty(productionAssemblyNosortContext.getAssemblySn())) continue;
saveBarcodeCountShareInfo(reqBean, productionProcessContext, new MesBarcodeCountShareInfo(
MesExtEnumUtil.BARCODE_COUNT_SHARE_INFO.BARCODE_COUNT_SHARE_INFO_20.getValue(),
productionAssemblyNosortContext.getAssemblySn(), productionPsOutContext.getPartNo(), productionPsOutContext.getPartName()));
}
}
});
return stepSuccessCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(MesPcnEnumUtil.WORK_CELL_SCAN_MONITOR_LOG_TYPE.PROCESS.getValue()), stepResult, "保存激光装配件信息成功!");
}
}

@ -0,0 +1,99 @@
package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.step;
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesProductionDispatchContextStepService;
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesProductionProcessContextStepService;
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProductionProcessContext;
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.IStepService;
import cn.estsh.i3plus.mes.pcn.util.StringUtil;
import cn.estsh.i3plus.platform.common.convert.ConvertBean;
import cn.estsh.i3plus.pojo.base.enumutil.MesPcnEnumUtil;
import cn.estsh.i3plus.pojo.mes.bean.MesBarcodeCountShareInfo;
import cn.estsh.i3plus.pojo.mes.bean.MesProdRouteOptParam;
import cn.estsh.i3plus.pojo.mes.model.StationRequestBean;
import cn.estsh.i3plus.pojo.mes.model.StationResultBean;
import cn.estsh.i3plus.pojo.mes.model.StepResult;
import cn.estsh.i3plus.pojo.mes.repository.MesBarcodeCountShareInfoRepository;
import cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil;
import cn.estsh.impp.framework.boot.util.SpringContextsUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import java.util.Map;
import java.util.Optional;
import java.util.UUID;
/**
* @Description : OEE
* @Author : wangjie
**/
@Slf4j
@Service("mesBarcodeCountShareInfoSaveStepService")
public class MesBarcodeCountShareInfoSaveStepService extends BaseStepService {
@Autowired
public IMesProductionProcessContextStepService productionProcessContextStepService;
@Autowired
public IMesProductionDispatchContextStepService productionDispatchContextStepService;
@Autowired
private MesBarcodeCountShareInfoRepository barcodeCountShareInfoRepository;
@Override
public StepResult execute(StationRequestBean reqBean) {
StationResultBean resultBean = new StationResultBean();
StepResult stepResult = StepResult.getSuccessComplete();
//获取工步参数
Optional<Map<String, MesProdRouteOptParam>> stepParamMap = getStepParams(reqBean);
String stepParam = (null != stepParamMap && stepParamMap.isPresent() && stepParamMap.get().containsKey(MesPcnExtConstWords.BARCODE_COUNT_SHARE_INFO)) ? stepParamMap.get().get(MesPcnExtConstWords.BARCODE_COUNT_SHARE_INFO).getParamValue() : null;
if (StringUtils.isEmpty(stepParam) && StringUtils.isEmpty(MesExtEnumUtil.BARCODE_COUNT_SHARE_INFO.valueOfDescription(stepParam))) {
return stepDynamicsCompleteAndSendMsgReturn(reqBean,
resultBean.writeDbLog(MesPcnEnumUtil.WORK_CELL_SCAN_MONITOR_LOG_TYPE.PROCESS.getValue()), stepResult, true,
MesPcnEnumUtil.STATION_BUSI_TYPE.RUNNING_INFO, MesPcnEnumUtil.STATION_DATA_TYPE.TEXT, String.format("未配置有效的工步参数[{}]跳过执行保存零件条码统计共享信息工步!", MesPcnExtConstWords.BARCODE_COUNT_SHARE_INFO));
}
Boolean isAllExec = false;
if (MesExtEnumUtil.BARCODE_COUNT_SHARE_INFO.BARCODE_COUNT_SHARE_INFO_30.getValue().equals(stepParam)) isAllExec = true;
//零件条码统计工步
if (isAllExec || MesExtEnumUtil.BARCODE_COUNT_SHARE_INFO.BARCODE_COUNT_SHARE_INFO_10.getValue().equals(stepParam)) {
((IStepService) SpringContextsUtil.getBean("mesBarcodeCountShareProductSnSaveStepService")).executeInState(reqBean);
}
//保存激光装配件工步
if (isAllExec || MesExtEnumUtil.BARCODE_COUNT_SHARE_INFO.BARCODE_COUNT_SHARE_INFO_20.getValue().equals(stepParam)) {
((IStepService) SpringContextsUtil.getBean("mesBarcodeCountShareAssemblySnSaveStepService")).executeInState(reqBean);
}
log.info("工厂{}生产线{}工位{}:FSM STATE DISPATCHER --- DO STEP --- {} EXEC --- {}={}[{}]",
reqBean.getOrganizeCode(), reqBean.getWorkCenterCode(), reqBean.getWorkCellCode(),
StringUtil.toLowerCaseFirst(this.getClass().getSimpleName()), MesPcnExtConstWords.BARCODE_COUNT_SHARE_INFO, stepParam, MesExtEnumUtil.BARCODE_COUNT_SHARE_INFO.valueOfDescription(stepParam));
return stepResult;
}
public void saveBarcodeCountShareInfo(StationRequestBean reqBean, MesProductionProcessContext productionProcessContext, MesBarcodeCountShareInfo barcodeCountShareInfo) {
barcodeCountShareInfo.setAreaCode(reqBean.getAreaCode());
barcodeCountShareInfo.setWorkCenterCode(reqBean.getWorkCenterCode());
barcodeCountShareInfo.setWorkCellCode(reqBean.getWorkCellCode());
barcodeCountShareInfo.setProcessCode(reqBean.getProcessCode());
barcodeCountShareInfo.setCraftCode(productionProcessContext.getCraftCode());
barcodeCountShareInfo.setEquipmentCode(productionProcessContext.getCurCellEquip().getEquipmentCode());
barcodeCountShareInfo.setOrganizeCode(reqBean.getOrganizeCode());
barcodeCountShareInfo.setFid(UUID.randomUUID().toString());
ConvertBean.serviceModelInitialize(barcodeCountShareInfo, reqBean.getUserInfo());
barcodeCountShareInfo.setProductEndTime(barcodeCountShareInfo.getModifyDatetime());
barcodeCountShareInfoRepository.insert(barcodeCountShareInfo);
}
}

@ -0,0 +1,55 @@
package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.step;
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProductionProcessContext;
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProductionPsOutContext;
import cn.estsh.i3plus.pojo.base.enumutil.MesPcnEnumUtil;
import cn.estsh.i3plus.pojo.mes.bean.MesBarcodeCountShareInfo;
import cn.estsh.i3plus.pojo.mes.model.StationRequestBean;
import cn.estsh.i3plus.pojo.mes.model.StationResultBean;
import cn.estsh.i3plus.pojo.mes.model.StepResult;
import cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.util.List;
/**
* @Description :
* @Author : wangjie
**/
@Slf4j
@Service("mesBarcodeCountShareProductSnSaveStepService")
public class MesBarcodeCountShareProductSnSaveStepService extends MesBarcodeCountShareInfoSaveStepService {
@Override
public StepResult execute(StationRequestBean reqBean) {
StationResultBean resultBean = new StationResultBean();
StepResult stepResult = StepResult.getSuccessComplete();
//获取上下文信息
MesProductionProcessContext productionProcessContext = productionProcessContextStepService.dispatchCurCellEquipment(reqBean);
//配置错误 抛出异常
if (!productionProcessContext.getSuccess()) stepExpSendMsgAndThrowEx(reqBean, resultBean.writeDbLog(), productionProcessContext.getMessage());
//存储生产过程上下文对象
productionProcessContextStepService.dispatchProductionProcessContext(reqBean, productionProcessContext);
//获取上下文产出条码数据信息集合
List<MesProductionPsOutContext> productionPsOutContextList = productionDispatchContextStepService.getProductionPsOutContext(reqBean);
if (CollectionUtils.isEmpty(productionPsOutContextList)) stepExpSendMsgAndThrowEx(reqBean, resultBean.writeDbLog(), "当前不存在产出零件条码信息,请重置工序解决!");
productionPsOutContextList.stream().filter(o -> null != o).forEach(o ->
saveBarcodeCountShareInfo(reqBean, productionProcessContext, new MesBarcodeCountShareInfo(
MesExtEnumUtil.BARCODE_COUNT_SHARE_INFO.BARCODE_COUNT_SHARE_INFO_10.getValue(), o.getProductSn(), o.getPartNo(), o.getPartName()))
);
return stepSuccessCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(MesPcnEnumUtil.WORK_CELL_SCAN_MONITOR_LOG_TYPE.PROCESS.getValue()), stepResult, "保存零件条码统计信息成功!");
}
}

@ -1,7 +1,7 @@
package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.step;
import cn.estsh.i3plus.ext.mes.pcn.api.base.IMesProdShiftRecordService;
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesProduceSnExtService;
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesProductionCustomContextStepService;
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesProductionDispatchContextStepService;
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesProductionProcessContextStepService;
import cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.step.method.MesPartDataMapSaveStepService;
@ -54,9 +54,6 @@ public class MesProductSnGenerateStepService extends BaseStepService {
private IMesProductionDispatchContextStepService productionDispatchContextStepService;
@Autowired
private IMesProductionCustomContextStepService productionCustomContextStepService;
@Autowired
private MesPartDataMapSaveStepService partDataMapSaveStepService;
@Autowired
@ -74,6 +71,9 @@ public class MesProductSnGenerateStepService extends BaseStepService {
@Autowired
private IFsmRouteDataService fsmRouteDataService;
@Autowired
private IMesProdShiftRecordService prodShiftRecordService;
@Override
public StepResult execute(StationRequestBean reqBean) {
@ -105,7 +105,7 @@ public class MesProductSnGenerateStepService extends BaseStepService {
if (CollectionUtils.isEmpty(prodRuleContextList)) stepExpSendMsgAndThrowEx(reqBean, resultBean.writeDbLog(), "当前不存在加工规则信息,请重置工序解决!");
//获取生产线的当前班组班次信息
MesProdShiftContext prodShiftContext = productionCustomContextStepService.getMesProdShiftKvBean(reqBean.getOrganizeCode(), reqBean.getWorkCenterCode());
MesProdShiftContext prodShiftContext = prodShiftRecordService.getMesProdShiftKvBean(reqBean.getOrganizeCode(), reqBean.getWorkCenterCode());
if (null == prodShiftContext) stepExpSendMsgAndThrowEx(reqBean, resultBean.writeDbLog(), "当前不存在生产开班记录,请重新开班!");

@ -138,6 +138,11 @@ public class MesProductSnPrintNosortStepService extends BaseStepService {
}
}
if (CollectionUtils.isEmpty(printModelList) && CollectionUtils.isEmpty(resultMapList)) {
return stepDynamicsCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(MesPcnEnumUtil.WORK_CELL_SCAN_MONITOR_LOG_TYPE.PROCESS.getValue()), stepResult, true,
MesPcnEnumUtil.STATION_BUSI_TYPE.RUNNING_INFO, MesPcnEnumUtil.STATION_DATA_TYPE.TEXT, "当前加工规则无需执行打印!");
}
//前端接收到busiTyep是customComponent并且 dataType是file类型的消息就需要打印后续消息里的数据一个模板对应多个打印数据
resultBean.setBusiType(MesPcnEnumUtil.STATION_BUSI_TYPE.CUSTOM_COMPONENT.getValue());
resultBean.setDataType(MesPcnEnumUtil.STATION_DATA_TYPE.FILE.getValue());

@ -109,16 +109,11 @@ public class MesProductSnPrintSortStepService extends BaseStepService {
// 根据工单号获取工单信息
MesWorkOrder workOrder = workOrderMap.get(sn.getWorkOrderNo());
if (workOrder == null) {
log.error("MesCustSnPrintStepService --- exec --- 工单号:{}无效", sn.getWorkOrderNo());
stepExpSendMsgAndThrowEx(reqBean, resultBean, String.format("工单号:{}无效!", sn.getWorkOrderNo()));
continue;
}
if ((partDataContext == null) || (!partDataContext.containsKey(workOrder.getPartNo()))) {
log.error("MesCustSnPrintStepService --- exec --- 工单号:{}零件{}丢失缓存", sn.getWorkOrderNo(), sn.getPartNo());
if (null == workOrder) stepExpSendMsgAndThrowEx(reqBean, resultBean, String.format("工单号:{}无效!", sn.getWorkOrderNo()));
if (CollectionUtils.isEmpty(partDataContext) || !partDataContext.containsKey(workOrder.getPartNo()))
stepExpSendMsgAndThrowEx(reqBean, resultBean, String.format("工单号[%s]零件号[%s]丢失零件信息缓存!", sn.getWorkOrderNo(), sn.getPartNo()));
}
MesPart mesPart = partDataContext.get(sn.getPartNo());
String custMatchRule = StringUtils.isEmpty(mesPart.getCustMatchRule()) ? "WH_CUST_SN_RULE" : mesPart.getCustMatchRule();
@ -126,25 +121,18 @@ public class MesProductSnPrintSortStepService extends BaseStepService {
DdlPreparedPack.getStringEqualPack(custMatchRule, MesPcnExtConstWords.RULE_CODE, packBean);
MesNumberRule numberRule = numberRuleRepository.getByProperty(packBean);
if (numberRule == null) {
log.error("MesCustSnPrintStepService --- exec --- 客户条码编码规则[WH_CUST_SN_RULE]无效");
stepExpSendMsgAndThrowEx(reqBean, resultBean, String.format("工单号[%s]零件号[%s]客户条码编码规则[%s]无效!", sn.getWorkOrderNo(), sn.getPartNo(), custMatchRule));
}
if (null == numberRule) stepExpSendMsgAndThrowEx(reqBean, resultBean, String.format("工单号[%s]零件号[%s]客户条码编码规则[%s]无效!", sn.getWorkOrderNo(), sn.getPartNo(), custMatchRule));
// 从物料信息中获取标签模板
String labelTemplateCode = partDataContext.get(sn.getPartNo()).getCustLabelTemplate();
if (labelTemplateCode == null) {
stepExpSendMsgAndThrowEx(reqBean, resultBean, String.format("工单号[%s]零件号[%s]未在ERP物料信息维护打印模板,请检查并修改!", sn.getWorkOrderNo(), sn.getPartNo()));
}
if (null == labelTemplateCode) stepExpSendMsgAndThrowEx(reqBean, resultBean, String.format("工单号[%s]零件号[%s]未在ERP物料信息维护打印模板,请检查并修改!", sn.getWorkOrderNo(), sn.getPartNo()));
MesProduceSnPrintModel mesProduceSnPrintModel = new MesProduceSnPrintModel();
// 查模板代码
MesLabelTemplate labelTemplate = mesTemplateService.getLabelTemplate(labelTemplateCode, organizeCode);
if (labelTemplate == null) {
stepExpSendMsgAndThrowEx(reqBean, resultBean, String.format("工单号[%s]零件号[%s]的模板代码[%s]无效,请检查并修改!", sn.getWorkOrderNo(), sn.getPartNo(), labelTemplateCode));
}
if (null == labelTemplate) stepExpSendMsgAndThrowEx(reqBean, resultBean, String.format("工单号[%s]零件号[%s]的模板代码[%s]无效,请检查并修改!", sn.getWorkOrderNo(), sn.getPartNo(), labelTemplateCode));
mesProduceSnPrintModel.setMesLabelTemplate(labelTemplate);
mesProduceSnPrintModel.setPrinter(partDataContext.get(sn.getPartNo()).getProductPrinterCode());
@ -155,11 +143,9 @@ public class MesProductSnPrintSortStepService extends BaseStepService {
//根据反射获取策略类--封装打印数据
String methodCode = labelTemplate.getMethodCode();
//模板信息丢失抛出异常
if (StringUtils.isEmpty(methodCode)) {
stepExpSendMsgAndThrowEx(reqBean, resultBean, String.format("工单号[%s]零件号[%s]的模板代码[%s]的反射类丢失,请配置!", sn.getWorkOrderNo(), sn.getPartNo(), labelTemplateCode));
}
if (StringUtils.isEmpty(methodCode)) stepExpSendMsgAndThrowEx(reqBean, resultBean, String.format("工单号[%s]零件号[%s]的模板代码[%s]的反射类丢失,请配置!", sn.getWorkOrderNo(), sn.getPartNo(), labelTemplateCode));
IPrintTemplateStrategyService strategyService = (IPrintTemplateStrategyService) SpringContextsUtil.getBean(methodCode);
// GenSerialNoModel model , MesProduceSnPrintModel mesProduceSnPrintModel, MesNumberRule numberRule, StepResult stepResult, StationRequestBean reqBean, Boolean isStep
MesProduceSnPrintModel printModel = strategyService.execute(null, mesProduceSnPrintModel, numberRule, stepResult, reqBean, true);
resultMap.addAll(printModel.getPrintContextList());
snLogList.add(getMesPrintedSnLog(reqBean, workOrder, JSONObject.toJSONString(printModel.getPrintContextList().iterator().next().get(MesPcnExtConstWords.TEMPLATE_DATA))));
@ -192,13 +178,17 @@ public class MesProductSnPrintSortStepService extends BaseStepService {
private Map<String, MesWorkOrder> getMesWorkOrderMap(StationRequestBean reqBean, List<MesProductionPartContext> productionPartContextList) {
// 从产成物料上下文中获取 工单号集合
List<String> workOrderNoList = productionPartContextList.stream().map(MesProductionPartContext::getWorkOrderNo).distinct().collect(Collectors.toList());
List<String> workOrderNoList = (productionPartContextList.stream().filter(o ->
(null != o && !StringUtils.isEmpty(o.getForeignKey()))).map(MesProductionPartContext::getWorkOrderNo).collect(Collectors.toList())).stream().filter(o -> !StringUtils.isEmpty(o)
).distinct().collect(Collectors.toList());
DdlPackBean packBean = DdlPackBean.getDdlPackBean(reqBean.getOrganizeCode());
DdlPreparedPack.getInPackList(workOrderNoList, MesPcnExtConstWords.WORK_ORDER_NO, packBean);
if (workOrderNoList.size() == 1) DdlPreparedPack.getStringEqualPack(workOrderNoList.get(0), MesPcnExtConstWords.WORK_ORDER_NO, packBean);
else DdlPreparedPack.getInPackList(workOrderNoList, MesPcnExtConstWords.WORK_ORDER_NO, packBean);
List<MesWorkOrder> workOrderList = workOrderRepository.findByHqlWhere(packBean);
// 根据工单号分组
return workOrderList.stream().collect(Collectors.toMap(MesWorkOrder::getWorkOrderNo, Function.identity(), (x, y) -> y));
return CollectionUtils.isEmpty(workOrderList) ? null :
workOrderList.stream().collect(Collectors.toMap(MesWorkOrder::getWorkOrderNo, Function.identity(), (x, y) -> y));
}
}

@ -1,7 +1,7 @@
package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.step;
import cn.estsh.i3plus.ext.mes.pcn.api.base.IMesProdShiftRecordService;
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesProduceSnExtService;
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesProductionCustomContextStepService;
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesProductionDispatchContextStepService;
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesProductionProcessContextStepService;
import cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.step.method.MesPartDataMapSaveStepService;
@ -49,9 +49,6 @@ public class MesProductSnSaveStepService extends BaseStepService {
private IMesProductionDispatchContextStepService productionDispatchContextStepService;
@Autowired
private IMesProductionCustomContextStepService productionCustomContextStepService;
@Autowired
private MesPartDataMapSaveStepService partDataMapSaveStepService;
@Autowired
@ -60,6 +57,9 @@ public class MesProductSnSaveStepService extends BaseStepService {
@Autowired
private MesProduceSnRepository produceSnRepository;
@Autowired
private IMesProdShiftRecordService prodShiftRecordService;
@Override
public StepResult execute(StationRequestBean reqBean) {
@ -82,7 +82,7 @@ public class MesProductSnSaveStepService extends BaseStepService {
if (CollectionUtils.isEmpty(productionPsOutContextList)) stepExpSendMsgAndThrowEx(reqBean, resultBean.writeDbLog(), "当前不存在产出零件条码信息,请重置工序解决!");
//获取生产线的当前班组班次信息
MesProdShiftContext prodShiftContext = productionCustomContextStepService.getMesProdShiftKvBean(reqBean.getOrganizeCode(), reqBean.getWorkCenterCode());
MesProdShiftContext prodShiftContext = prodShiftRecordService.getMesProdShiftKvBean(reqBean.getOrganizeCode(), reqBean.getWorkCenterCode());
if (null == prodShiftContext) stepExpSendMsgAndThrowEx(reqBean, resultBean.writeDbLog(), "当前不存在生产开班记录,请重新开班!");

@ -10,6 +10,7 @@ import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProductionProcessContext;
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.StationKvBeanUtil;
import cn.estsh.i3plus.pojo.base.enumutil.MesEnumUtil;
import cn.estsh.i3plus.pojo.base.enumutil.MesPcnEnumUtil;
import cn.estsh.i3plus.pojo.mes.bean.MesPart;
import cn.estsh.i3plus.pojo.mes.model.StationKvBean;
@ -82,7 +83,7 @@ public class MesProductionPartNoScanStepService extends BaseStepService {
if (CollectionUtils.isEmpty(chooseCavityPart) && StringUtils.isEmpty(scanInfo)) stepSendGuideAndThrowEx(reqBean, resultBean.writeDbLog(MesPcnEnumUtil.WORK_CELL_SCAN_MONITOR_LOG_TYPE.PROCESS.getValue()), "请扫描产成零件!");
List<MesProductionPartContext> productionPartContextList = null;
List<MesProductionPartContext> productionPartContextList;
List<String> readList;
List<String> partNoList;
String cellMessageSorce = null;
@ -152,7 +153,7 @@ public class MesProductionPartNoScanStepService extends BaseStepService {
if (cellEquipContext.getCavity().compareTo(productionPartContextList.size()) > 0) return stepDynamicsCompleteAndSendMsgReturn(
reqBean, resultBean.writeDbLog().scanInfo(scanInfo),
stepResult, false, MesPcnEnumUtil.STATION_BUSI_TYPE.MESSAGE, MesPcnEnumUtil.STATION_DATA_TYPE.TEXT,
String.format("当前%s验证成功,已知腔数[%s],还需要再连续扫描[%s]次加工单!", suffix, cellEquipContext.getCavity(), cellEquipContext.getCavity() - productionPartContextList.size()));
String.format("当前%s验证成功,已知腔数[%s],还需要再连续扫描[%s]次产成零件!", suffix, cellEquipContext.getCavity(), cellEquipContext.getCavity() - productionPartContextList.size()));
}
//存储展示组件MODULE_CONTENT内容

@ -1,5 +1,6 @@
package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.step;
import cn.estsh.i3plus.ext.mes.pcn.api.base.IMesProdShiftRecordService;
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesProductionCustomContextStepService;
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesProductionDispatchContextStepService;
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesProductionProcessContextStepService;
@ -56,6 +57,9 @@ public class MesProductionRecordGenerateStepService extends BaseStepService {
@Autowired
private IMesProductionRecordService productionRecordService;
@Autowired
private IMesProdShiftRecordService prodShiftRecordService;
//当前非排序线, 排序线有差异
@Override
public StepResult execute(StationRequestBean reqBean) {
@ -106,7 +110,8 @@ public class MesProductionRecordGenerateStepService extends BaseStepService {
if (Objects.equal(CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue(), workCell.getIsCountFinish())) {
// 保存班次加工数量上下文
Integer amount = productionCustomContextStepService.dispatchProductionStatisticsContext(reqBean, productionPsOutContextList.size());
MesProdShiftContext mesProdShiftKvBean = prodShiftRecordService.getMesProdShiftKvBean(reqBean.getOrganizeCode(), reqBean.getWorkCenterCode());
Integer amount = productionCustomContextStepService.dispatchProductionStatisticsContext(reqBean, productionPsOutContextList.size(), mesProdShiftKvBean);
this.sendMessage(reqBean, new StationResultBean().writeDbLog(MesPcnEnumUtil.WORK_CELL_SCAN_MONITOR_LOG_TYPE.PROCESS.getValue()), String.format("生产线[%s]工位[%s]当前累加数[%s]已累计加工数[%s]", reqBean.getWorkCenterCode(), reqBean.getWorkCellCode(), productionPsOutContextList.size(), amount), MesPcnEnumUtil.STATION_BUSI_TYPE.RUNNING_INFO, MesPcnEnumUtil.STATION_DATA_TYPE.TEXT);
}

@ -2,8 +2,8 @@ package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.step;
import cn.estsh.i3plus.ext.mes.pcn.api.base.IMesEquipmentExtService;
import cn.estsh.i3plus.ext.mes.pcn.api.base.IMesEquipmentProdParamCfgService;
import cn.estsh.i3plus.ext.mes.pcn.api.base.IMesProdShiftRecordService;
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesEquipVariableRwExtService;
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesProductionCustomContextStepService;
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesProductionDispatchContextStepService;
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesProductionProcessContextStepService;
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.*;
@ -46,9 +46,6 @@ public class MesSendEquipParamsCmdStepService extends BaseStepService {
private IMesProductionDispatchContextStepService productionDispatchContextStepService;
@Autowired
private IMesProductionCustomContextStepService productionCustomContextStepService;
@Autowired
private IMesEquipmentProdParamCfgService equipmentProdParamCfgService;
@Autowired
@ -57,6 +54,9 @@ public class MesSendEquipParamsCmdStepService extends BaseStepService {
@Autowired
private IMesEquipmentExtService equipmentExtService;
@Autowired
private IMesProdShiftRecordService prodShiftRecordService;
@Override
public StepResult execute(StationRequestBean reqBean) {
@ -107,7 +107,7 @@ public class MesSendEquipParamsCmdStepService extends BaseStepService {
List<MesProductionPartContext> productionPartContextList = productionDispatchContextStepService.getProductionPartContext(reqBean);
List<MesProductionPsInContext> productionPsInContexts = productionDispatchContextStepService.getProductionPsInContext(reqBean);
List<MesProductionPsOutContext> productionPsOutContexts = productionDispatchContextStepService.getProductionPsOutContext(reqBean);
MesProdShiftContext mesProdShiftKvBean = productionCustomContextStepService.getMesProdShiftKvBean(reqBean.getOrganizeCode(), reqBean.getWorkCenterCode());
MesProdShiftContext mesProdShiftKvBean = prodShiftRecordService.getMesProdShiftKvBean(reqBean.getOrganizeCode(), reqBean.getWorkCenterCode());
//发送设备加工参数
prodRuleContextList.stream().filter(o -> null != o).forEach(o -> {

@ -2,8 +2,8 @@ package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.step;
import cn.estsh.i3plus.ext.mes.pcn.api.base.IMesEquipmentExtService;
import cn.estsh.i3plus.ext.mes.pcn.api.base.IMesEquipmentProdParamCfgService;
import cn.estsh.i3plus.ext.mes.pcn.api.base.IMesProdShiftRecordService;
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesEquipVariableRwExtService;
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesProductionCustomContextStepService;
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesProductionDispatchContextStepService;
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesProductionProcessContextStepService;
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.*;
@ -46,9 +46,6 @@ public class MesSendEquipParamsCmdStepService2 extends BaseStepService {
private IMesProductionDispatchContextStepService productionDispatchContextStepService;
@Autowired
private IMesProductionCustomContextStepService productionCustomContextStepService;
@Autowired
private IMesEquipmentProdParamCfgService equipmentProdParamCfgService;
@Autowired
@ -57,6 +54,9 @@ public class MesSendEquipParamsCmdStepService2 extends BaseStepService {
@Autowired
private IMesEquipmentExtService equipmentExtService;
@Autowired
private IMesProdShiftRecordService prodShiftRecordService;
@Override
public StepResult execute(StationRequestBean reqBean) {
@ -107,7 +107,7 @@ public class MesSendEquipParamsCmdStepService2 extends BaseStepService {
List<MesProductionPartContext> productionPartContextList = productionDispatchContextStepService.getProductionPartContext(reqBean);
List<MesProductionPsInContext> productionPsInContexts = productionDispatchContextStepService.getProductionPsInContext(reqBean);
List<MesProductionPsOutContext> productionPsOutContexts = productionDispatchContextStepService.getProductionPsOutContext(reqBean);
MesProdShiftContext mesProdShiftKvBean = productionCustomContextStepService.getMesProdShiftKvBean(reqBean.getOrganizeCode(), reqBean.getWorkCenterCode());
MesProdShiftContext mesProdShiftKvBean = prodShiftRecordService.getMesProdShiftKvBean(reqBean.getOrganizeCode(), reqBean.getWorkCenterCode());
//发送设备加工参数
prodRuleContextList.stream().filter(o -> null != o).forEach(o -> {

@ -1,13 +1,14 @@
package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.step;
import cn.estsh.i3plus.ext.mes.pcn.api.busi.*;
import cn.estsh.i3plus.ext.mes.pcn.api.base.IMesProdShiftRecordService;
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesProduceSnExtService;
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesProductionDispatchContextStepService;
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesProductionProcessContextStepService;
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.*;
import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesWorkOrderCutDetailModel;
import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtConstWords;
import cn.estsh.i3plus.mes.pcn.actor.shipping.dispatch.IFsmRouteDataService;
import cn.estsh.i3plus.mes.pcn.api.iservice.busi.ISyncFuncService;
import cn.estsh.i3plus.mes.pcn.serviceimpl.fsm.BaseStepService;
import cn.estsh.i3plus.mes.pcn.serviceimpl.fsm.IStepService;
import cn.estsh.i3plus.mes.pcn.util.StringUtil;
import cn.estsh.i3plus.platform.common.convert.ConvertBean;
import cn.estsh.i3plus.platform.common.tool.TimeTool;
@ -15,12 +16,13 @@ import cn.estsh.i3plus.pojo.base.bean.DdlPackBean;
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
import cn.estsh.i3plus.pojo.base.enumutil.MesPcnEnumUtil;
import cn.estsh.i3plus.pojo.base.tool.DdlPreparedPack;
import cn.estsh.i3plus.pojo.mes.bean.*;
import cn.estsh.i3plus.pojo.mes.bean.MesPart;
import cn.estsh.i3plus.pojo.mes.bean.MesProduceSn;
import cn.estsh.i3plus.pojo.mes.bean.MesWorkCell;
import cn.estsh.i3plus.pojo.mes.model.GenSerialNoModel;
import cn.estsh.i3plus.pojo.mes.model.StationRequestBean;
import cn.estsh.i3plus.pojo.mes.model.StationResultBean;
import cn.estsh.i3plus.pojo.mes.model.StepResult;
import cn.estsh.i3plus.pojo.mes.repository.MesProductionAssemblyRepository;
import cn.estsh.i3plus.pojo.mes.repository.MesWorkOrderCutDetailRepository;
import cn.estsh.i3plus.pojo.mes.repository.MesWorkOrderCutRepository;
import cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil;
@ -54,9 +56,6 @@ public class MesWorkOrderCutProductSnSaveStepService extends BaseStepService {
private IMesProductionDispatchContextStepService productionDispatchContextStepService;
@Autowired
private IMesProductionCustomContextStepService productionCustomContextStepService;
@Autowired
private MesWorkOrderCutRepository workOrderCutRepository;
@Autowired
@ -69,10 +68,10 @@ public class MesWorkOrderCutProductSnSaveStepService extends BaseStepService {
private IFsmRouteDataService fsmRouteDataService;
@Autowired
private MesProductionAssemblyRepository productionAssemblyRepository;
private MesWorkOrderCutDetailRepository workOrderCutDetailRepository;
@Autowired
private MesWorkOrderCutDetailRepository workOrderCutDetailRepository;
private IMesProdShiftRecordService prodShiftRecordService;
@Override
public StepResult execute(StationRequestBean reqBean) {
@ -88,11 +87,6 @@ public class MesWorkOrderCutProductSnSaveStepService extends BaseStepService {
//存储生产过程上下文对象
productionProcessContextStepService.dispatchProductionProcessContext(reqBean, productionProcessContext);
////获取上下文生产扫/读信息:加工单
//List<MesEquipVariableCollectContext> equipVariableCollectContextList = productionDispatchContextStepService.getScanWorkOrderNoContext(reqBean);
//
//String cutWorkOrderNo = equipVariableCollectContextList.get(0).getEquipVariableValue();
//看是否修改裁片工单状态
//获取上下文进料零件条码信息集合
List<MesProductionPsInContext> productionPsInContextList = productionDispatchContextStepService.getProductionPsInContext(reqBean);
@ -121,7 +115,7 @@ public class MesWorkOrderCutProductSnSaveStepService extends BaseStepService {
MesWorkCell workCell = productionProcessContext.getWorkCell();
//获取生产线的当前班组班次信息
MesProdShiftContext prodShiftContext = productionCustomContextStepService.getMesProdShiftKvBean(reqBean.getOrganizeCode(), reqBean.getWorkCenterCode());
MesProdShiftContext prodShiftContext = prodShiftRecordService.getMesProdShiftKvBean(reqBean.getOrganizeCode(), reqBean.getWorkCenterCode());
// 无进料条码则生成条码
if (CollectionUtils.isEmpty(productionPsInContextList)) {
@ -193,9 +187,6 @@ public class MesWorkOrderCutProductSnSaveStepService extends BaseStepService {
new String[]{MesPcnExtConstWords.PRODUCT_SN, MesPcnExtConstWords.MODIFY_USER, MesPcnExtConstWords.MODIFY_DATE_TIME},
new Object[]{cutWorkOrderNo, reqBean.getUserInfo(), TimeTool.getNowTime(true)});
// 新增装配件加工记录
//saveProductionAssembly(reqBean, productionProcessContext, cellEquipContext, mesProdRuleContext, productionPsOutContext);
}
//保存上下文产出条码数据信息集合
@ -218,11 +209,6 @@ public class MesWorkOrderCutProductSnSaveStepService extends BaseStepService {
if (productionPsOutContext == null)
stepExpSendMsgAndThrowEx(reqBean, resultBean.writeDbLog(), String.format("产出零件号[%s]不存在,请重置工序解决!", mesProductionPartContext.getPartNo()));
//MesProdRuleContext mesProdRuleContext = prodRuleContextMapByOutPartNo.get(mesProductionPartContext.getPartNo());
// 新增装配件加工记录
//saveProductionAssembly(reqBean, productionProcessContext, cellEquipContext, mesProdRuleContext, productionPsOutContext);
}
}
@ -267,51 +253,6 @@ public class MesWorkOrderCutProductSnSaveStepService extends BaseStepService {
}
private void saveProductionAssembly(StationRequestBean reqBean, MesProductionProcessContext productionProcessContext,
MesCellEquipContext cellEquipContext, MesProdRuleContext mesProdRuleContext,
MesProductionPsOutContext productionPsOutContext) {
MesProductionAssembly productionAssembly = new MesProductionAssembly();
productionAssembly.setAssemblySn("");
productionAssembly.setDataSource(MesExtEnumUtil.PRODUCTION_ASSEMBLY_DATA_SOURCE.NOSORT.getValue());
productionAssembly.setIsOrigSn(CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue());
productionAssembly.setIsSkip(CommonEnumUtil.FALSE);
productionAssembly.setAreaCode(reqBean.getAreaCode());
productionAssembly.setWorkCenterCode(reqBean.getWorkCenterCode());
productionAssembly.setWorkCellCode(reqBean.getWorkCellCode());
productionAssembly.setProcessCode(reqBean.getProcessCode());
productionAssembly.setProcessName(productionProcessContext.getProcessName());
productionAssembly.setCraftCode(productionProcessContext.getCraftCode());
productionAssembly.setCraftName(productionProcessContext.getCraftName());
productionAssembly.setEquipmentCode(cellEquipContext.getEquipmentCode());
productionAssembly.setProductionRecordId(mesProdRuleContext.getProductionRecordId());
productionAssembly.setMouldNo(mesProdRuleContext.getMouldNo());
if (null != productionPsOutContext) {
productionAssembly.setPartNo(productionPsOutContext.getPartNo());
productionAssembly.setPartName(productionPsOutContext.getPartName());
productionAssembly.setSerialNumber(productionPsOutContext.getSerialNumber());
productionAssembly.setProductSn(productionPsOutContext.getProductSn());
productionAssembly.setCustSn(productionPsOutContext.getCustSn());
}
MesScanMonitorContext scanMonitorContext = productionProcessContextStepService.dispatchScanMonitorContext(reqBean, true);
if (null != scanMonitorContext) productionAssembly.setMouldRecordId(scanMonitorContext.getMouldRecordId());
productionAssembly.setOrganizeCode(reqBean.getOrganizeCode());
ConvertBean.serviceModelInitialize(productionAssembly, reqBean.getUserInfo());
productionAssembly.setFid(UUID.randomUUID().toString());
productionAssemblyRepository.insert(productionAssembly);
}
private void updateWorkOrderCutStatus(StationRequestBean reqBean, String cutWorkOrderNo, Integer status) {
DdlPackBean packBean = DdlPackBean.getDdlPackBean(reqBean.getOrganizeCode());
DdlPreparedPack.getStringEqualPack(cutWorkOrderNo, MesPcnExtConstWords.CUT_WORK_ORDER_NO, packBean);

@ -14,7 +14,6 @@ import cn.estsh.i3plus.pojo.mes.model.StationRequestBean;
import cn.estsh.i3plus.pojo.mes.model.StationResultBean;
import cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil;
import com.alibaba.fastjson.JSONObject;
import com.google.common.base.Objects;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
@ -110,22 +109,6 @@ public class MesProductionCustomContextStepService extends BaseStepService imple
this.sendMessage(reqBean, resultBean);
}
//获取生产线的当前班组班次信息
@Override
public MesProdShiftContext getMesProdShiftKvBean(String organizeCode, String workCenterCode) {
List<StationKvBean> stationKvBeans = getProdShiftDataContext(organizeCode, workCenterCode);
if (CollectionUtils.isEmpty(stationKvBeans)) return null;
StationKvBean shiftGroupKvBean = stationKvBeans.stream().filter(stationKvBean -> Objects.equal(stationKvBean.getKey(), MesPcnExtConstWords.SHIFT_GROUP)).findFirst().orElse(null);
StationKvBean shiftCodeKvBean = stationKvBeans.stream().filter(stationKvBean -> Objects.equal(stationKvBean.getKey(), MesPcnExtConstWords.SHIFT_CODE)).findFirst().orElse(null);
MesProdShiftContext mesProdShiftContext = new MesProdShiftContext();
mesProdShiftContext.setShiftCode(shiftGroupKvBean == null ? null : shiftCodeKvBean.getValue());
mesProdShiftContext.setShiftGroup(shiftCodeKvBean == null ? null : shiftGroupKvBean.getValue());
return mesProdShiftContext;
}
//开班信息KEY 【PS:生产线级别】
private String getProdShiftContextKey(String orgainzeCode, String workCenterCode) { return new StringJoiner(MesPcnExtConstWords.COLON).add(orgainzeCode).add(MesPcnExtConstWords.PROD_SHIFT_DATA_CONTEXT).add(workCenterCode).toString(); }
@ -166,6 +149,13 @@ public class MesProductionCustomContextStepService extends BaseStepService imple
return !StringUtils.isEmpty(productionStatisticsJson) ? JSONObject.parseArray(productionStatisticsJson, StationKvBean.class) : null;
}
//封装加工数信息
@Override
public List<StationKvBean> getProductionStatisticsContext(MesProdShiftContext mesProdShiftKvBean, String countStr) {
return StationKvBeanUtil.addStationKvBeanList(new ArrayList<>(),
new StationKvBean(mesProdShiftKvBean.getShiftGroup(), "加工数", countStr), new StationKvBean(MesPcnExtConstWords.COLOR, "颜色", MesExtEnumUtil.COLOR.BLACK.getValue()));
}
//保存上下文工位加工数统计信息 [JSON]List<StationKvBean>
@Override
public Boolean dispatchProductionStatisticsContext(StationRequestBean reqBean, List<StationKvBean> productionStatisticsList) {
@ -180,9 +170,9 @@ public class MesProductionCustomContextStepService extends BaseStepService imple
}
@Override
public Integer dispatchProductionStatisticsContext(StationRequestBean reqBean, int count) {
public Integer dispatchProductionStatisticsContext(StationRequestBean reqBean, int count, MesProdShiftContext mesProdShiftKvBean) {
MesProdShiftContext mesProdShiftKvBean = getMesProdShiftKvBean(reqBean.getOrganizeCode(), reqBean.getWorkCenterCode());
if (null == mesProdShiftKvBean) return null;
List<StationKvBean> stationKvBeans = getProductionStatisticsContext(reqBean);
@ -191,9 +181,7 @@ public class MesProductionCustomContextStepService extends BaseStepService imple
amount.set(count);
if (CollectionUtils.isEmpty(stationKvBeans)) {
String name = "加工数";
stationKvBeans = StationKvBeanUtil.addStationKvBeanList(new ArrayList<>(),
new StationKvBean(mesProdShiftKvBean.getShiftGroup(), name, countStr), new StationKvBean(MesPcnExtConstWords.COLOR, "颜色", MesExtEnumUtil.COLOR.BLACK.getValue()));
stationKvBeans = getProductionStatisticsContext(mesProdShiftKvBean, countStr);
} else {
AtomicReference<Boolean> flag = new AtomicReference<>(false);
stationKvBeans.stream().forEach(stationKvBean -> {
@ -203,13 +191,7 @@ public class MesProductionCustomContextStepService extends BaseStepService imple
flag.set(true);
}
});
if (!flag.get()) {
String name = "加工数";
stationKvBeans = StationKvBeanUtil.addStationKvBeanList(new ArrayList<>(),
new StationKvBean(mesProdShiftKvBean.getShiftGroup(), name, countStr), new StationKvBean(MesPcnExtConstWords.COLOR, "颜色", MesExtEnumUtil.COLOR.BLACK.getValue()));
}
if (!flag.get()) stationKvBeans = getProductionStatisticsContext(mesProdShiftKvBean, countStr);
}
dispatchProductionStatisticsContext(reqBean, stationKvBeans);

@ -37,6 +37,7 @@ public class MesPcnExtConstWords {
public static final String ORGANIZE_NAME = "ORGANIZE_NAME";
//供应商常量
public static final String SUPPLIER_CODE = "SUPPLIER_CODE";
public static final String SUPPLIER_CODE_L = "supplierCode";
//获取供应商广州key
public static final String SUPPLIER_CODE_NO_SORT_GZ = "SUPPLIER_CODE_NO_SORT_GZ";
// 系统配置代码
@ -187,8 +188,12 @@ public class MesPcnExtConstWords {
public static final String CUST_SN = "custSn";
// 条码状态
public static final String SN_STATUS = "snStatus";
// 条码状态
public static final String SN_STATUS_NAME = "snStatusName";
// 质量状态
public static final String QC_STATUS = "qcStatus";
// 质量状态
public static final String QC_STATUS_NAME = "qcStatusName";
// 过程标签模板
public static final String PROCESS_LABEL_TEMPLATE = "processLabelTemplate";
// 产品标签模板
@ -285,6 +290,23 @@ public class MesPcnExtConstWords {
public static final String SCAN_TYPE = "scanType";
//点检单id
public static final String SPOT_CHECK_ORDER_ID = "spotCheckOrderId";
//零件条码参数
public static final String PART_SN_PARAM = "partSnParam";
//完成时间
public static final String COMPLETE_DATE_TIME = "completeDateTime";
//汇报状态
public static final String REPORT_STATUS = "reportStatus";
//汇报状态
public static final String REPORT_STATUS_NAME = "reportStatusName";
//BOM版本
public static final String BOM_VERSION = "bomVersion";
//生效时间
public static final String EFF_START_TIME = "effStartTime";
//失效时间
public static final String EFF_END_TIME = "effEndTime";
//MES汇报查询BOM是否携带结束查询条件
public static final String MES_REPORT_FIND_BOM_WITH_EFFENDTIME = "MES_REPORT_FIND_BOM_WITH_EFFENDTIME";
//BaseBean字段不包含工厂, 用于对象复制剔除属性BeanUtils.copyProperties(Object source, Object target, String... ignoreProperties)
@ -357,6 +379,8 @@ public class MesPcnExtConstWords {
public static final String NEED_CHECK_IS_PS = "NEED_CHECK_IS_PS";
// 流程包含解绑工步[工步参数]
public static final String CONTEXT_UNBINDING_STEP = "CONTEXT_UNBINDING_STEP";
// 零件条码统计OEE共享信息[工步参数]
public static final String BARCODE_COUNT_SHARE_INFO = "BARCODE_COUNT_SHARE_INFO";
// 装配件显示规则配置[工位参数]
public static final String ASSEMBLY_SHOW_MR_CFG = "ASSEMBLY_SHOW_MR_CFG";
@ -466,6 +490,8 @@ public class MesPcnExtConstWords {
public static final String DECIMAL_POINT_ESCAPE = "\\.";
//.
public static final String DECIMAL_POINT = ".";
// #
public static final String WELL_NO = "#";
// 自动初始化工位按钮URL
public static final String AUTO_INIT_WORK_CELL_MODULE_URL = "AUTO_INIT_WORK_CELL_MODULE_URL";
@ -723,6 +749,8 @@ public class MesPcnExtConstWords {
// 产线名称
public static final String WORK_CENTER_NAME = "workCenterName";
// 工位名称
public static final String WORK_CELL_NAME = "workCellName";
//
public static final int PALLET_CODE_93_WIDTH = 93;

Loading…
Cancel
Save