Merge branch 'dev_temp_xw_202503310000_45843' into dev

# Conflicts:
#	modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/schedulejob/MesReportWorkByPreDayJob.java
#	modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesNcProcessingService.java
#	modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesSortShippingCheckService.java
#	modules/i3plus-ext-mes-pcn-pojo/src/main/java/cn/estsh/i3plus/ext/mes/pcn/pojo/util/MesPcnExtConstWords.java
#	pom.xml
dev
xiangwei.zhang 5 months ago
commit 5e486a0b5b

@ -14,4 +14,7 @@ import java.util.List;
public interface IMesOrgService {
List<MesOrg> queryMesOrg(MesOrg mesOrg);
List<MesOrg> queryMesOrgSplit(MesOrg mesOrg);
}

@ -0,0 +1,7 @@
package cn.estsh.i3plus.ext.mes.pcn.api.base;
import cn.estsh.i3plus.pojo.mes.bean.MesPartPackageType;
public interface IMesPartPackageTypeService {
MesPartPackageType getMesPartPackageType(String organizeCode, String packageTypeCode);
}

@ -1,9 +1,6 @@
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 cn.estsh.i3plus.pojo.mes.bean.*;
import io.swagger.annotations.ApiOperation;
import java.util.List;
@ -56,4 +53,7 @@ public interface IMesProdOrgExtService {
@ApiOperation(value = "根据生产线代码,工位代码查询主子工位实虚关系信息")
List<MesWorkCellExtendCfg> getWorkCellExtendCfgRvListByBak(String organizeCode, String workCenterCodeBak, String workCellCodeBak);
@ApiOperation(value = "根据生产线代码,工位代码查询工位零件打印机配置信息")
List<MesWorkCellPartPrinterCfg> getWorkCellPartPrinterCfgList(String organizeCode, String workCenterCode, String workCellCode);
}

@ -21,6 +21,9 @@ public interface IMesAssemblyExtService {
@ApiOperation(value = "【排序线】获取生产工单装配件清单")
List<MesWorkOrderAssembly> getWorkOrderAssemblyList(MesProdRuleContext prodRuleContext, Boolean isShowAll);
@ApiOperation(value = "【排序线】获取生产工单装配件清单[前道所有装配件]")
List<MesWorkOrderAssembly> getWorkOrderAssemblyListAllCell(MesProdRuleContext prodRuleContext, List<MesWorkCell> workCellList);
@ApiOperation(value = "获取装配件绑定记录【排序】")
List<MesProductionAssembly> getProductionAssemblySortList(String organizeCode, String productSn);

@ -35,4 +35,6 @@ public interface IMesNcProcessingService {
@ApiOperation(value = "NC处理")
void saveNc(MesNcProcessingInputModel model, String org, boolean isOrder);
List<String> queryPartInspectionCreateUser(String organizeCode);
}

@ -5,6 +5,7 @@ import cn.estsh.i3plus.pojo.mes.bean.MesPartShippingGroup;
import cn.estsh.i3plus.pojo.mes.bean.MesPartShippingGroupDetail;
import cn.estsh.i3plus.pojo.mes.bean.shipping.MesShippingOrderManagement;
import cn.estsh.i3plus.pojo.mes.model.MesShippingOrderManagementModel;
import cn.estsh.impp.framework.boot.util.ResultBean;
import io.swagger.annotations.ApiOperation;
import java.util.List;
@ -24,7 +25,7 @@ public interface IMesPartShippingGroupService {
MesPartShippingGroup getMesPartShippingGroup(String organizeCode, String shippingGroupCode);
@ApiOperation(value = "打印发运单数据")
List<MesShippingOrderManagementModel> doMesMesShippingOrderManagementPrint(MesShippingOrderManagement model);
ResultBean doMesMesShippingOrderManagementPrint(MesShippingOrderManagement model);
@ApiOperation(value = "发运组明细")
MesPartShippingGroupDetail getMesPartShippingGroupDetail(String organizeCode, String shippingGroupCode, String partNo, String custPartNo);

@ -61,7 +61,7 @@ public interface IMesProduceSnExtService {
void saveProduceSnList(StationRequestBean reqBean, Integer snStatus, List<Long> idList);
@ApiOperation(value = "根据条件修改条码状态")
void saveProduceSntatusByDdlPackBean(DdlPackBean packBean, String userInfo, Integer snStatus);
void saveProduceSnStatusByDdlPackBean(DdlPackBean packBean, String userInfo, Integer snStatus);
MesProduceSn insert(MesProduceSn item);

@ -103,13 +103,16 @@ public interface IMesProductionCustomContextStepService {
@ApiOperation(value = "删除打包数据")
void removePackageDataContext(StationRequestBean reqBean);
@ApiOperation(value = "获取排序线工单队列推送锁数据")
List<String> getSortQueuePushLockContext(String orgainzeCode, String workCenterCode);
@ApiOperation(value = "获取排序线工单队列推送锁数据, 返回的值是工位代码")
String getSortQueuePushLockContext(StationRequestBean reqBean, String queuePushId);
@ApiOperation(value = "保存排序线工单队列推送锁数据")
Boolean dispatchSortQueuePushLockContext(String organizeCode, String workCenterCode, String queuePushId);
@ApiOperation(value = "获取排序线工单队列推送锁数据, 返回的值是工单队列ID集合")
List<String> getSortQueuePushLockContext(StationRequestBean reqBean);
@ApiOperation(value = "保存排序线工单队列推送锁数据【保存LOCK信息:item=id,value=工位】【保存当前工位锁定的信息:item=工位,value=idList】")
Boolean dispatchSortQueuePushLockContext(StationRequestBean reqBean, List<String> queuePushIdList);
@ApiOperation(value = "删除排序线工单队列推送锁数据")
void removeSortQueuePushLockContext(String orgainzeCode, String workCenterCode, String queuePushId);
void removeSortQueuePushLockContext(StationRequestBean reqBean, String queuePushId);
}

@ -191,4 +191,7 @@ public interface IMesProductionProcessContextStepService {
@ApiOperation(value = "处理排序线推单配置上下文, 返回推送工位类型对应的配置信息")
List<MesQueueOrderPushCellCfg> dispatchQueueOrderPushCellCfgContext(StationRequestBean reqBean, Integer pushType);
@ApiOperation(value = "处理工位零件打印机配置")
List<MesWorkCellPartPrinterCfg> disPatchWorkCellPartPrinterCfg(StationRequestBean reqBean, Boolean pcNosortPrinterCfg);
}

@ -2,11 +2,14 @@ package cn.estsh.i3plus.ext.mes.pcn.api.busi;
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProductionPartContext;
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProductionPsOutContext;
import cn.estsh.i3plus.pojo.base.bean.DdlPackBean;
import cn.estsh.i3plus.pojo.base.bean.ListPager;
import cn.estsh.i3plus.pojo.base.common.Pager;
import cn.estsh.i3plus.pojo.mes.bean.MesProduceSn;
import cn.estsh.i3plus.pojo.mes.bean.MesQueueOrderPush;
import cn.estsh.i3plus.pojo.mes.bean.MesQueueOrderPushCellCfg;
import cn.estsh.i3plus.pojo.mes.bean.MesWorkOrder;
import cn.estsh.i3plus.pojo.mes.model.StationRequestBean;
import io.swagger.annotations.ApiOperation;
import java.util.List;
@ -21,20 +24,35 @@ public interface IMesQueueOrderPushService {
List<MesQueueOrderPushCellCfg> getQueueOrderPushCellCfgList(String organizeCode, String workCenterCode);
//递增步长10,取整10位; 例如:查询=10 >> 返回=20 ; 查询=29 >> 返回=30
@ApiOperation(value = "获取当前工单对应的工位推单队列中最大的顺序号")
Integer getQueueOrderPushMaxSeq(String organizeCode, String workOrderNo);
@ApiOperation(value = "获取当前生产线推单代码中最大的顺序号")
Integer getQueueOrderPushMaxSeq(String organizeCode, MesQueueOrderPushCellCfg queueOrderPushCellCfg);
@ApiOperation(value = "根据条件顺序号查询上一个顺序号,返回加一")
Integer getQueueOrderPushCalcSeq(String organizeCode, MesQueueOrderPushCellCfg queueOrderPushCellCfg, Integer processSeqUp);
@ApiOperation(value = "写入工位工单推送信息")
void insertQueueOrderPush(String organizeCode, String userInfo, List<MesQueueOrderPushCellCfg> queueOrderPushCellCfgList,
MesProductionPsOutContext productionPsOutContext, MesProductionPartContext productionPartContext);
@ApiOperation(value = "写入工位工单推送信息")
void insertQueueOrderPush(StationRequestBean reqBean, MesWorkOrder workOrder, MesQueueOrderPushCellCfg queueOrderPushCellCfg, String processSeqUp);
@ApiOperation(value = "根据ID查询生产队列工位推送信息")
MesQueueOrderPush getQueueOrderPush(String organizeCode, Long id);
@ApiOperation(value = "根据配置查询创建状态的生产队列工位推送信息")
List<MesQueueOrderPush> getQueueOrderPushList(String organizeCode, List<MesQueueOrderPushCellCfg> queueOrderPushCellCfgList);
@ApiOperation(value = "根据配置查询生产队列工位推送信息")
List<MesQueueOrderPush> getQueueOrderPushListByStatus(String organizeCode, List<MesQueueOrderPushCellCfg> queueOrderPushCellCfgList, Integer cdtAscOrDesc, Integer... queueStatusArr);
List<MesQueueOrderPush> getQueueOrderPushListByStatus(String organizeCode, List<MesQueueOrderPushCellCfg> queueOrderPushCellCfgList, Integer ascOrDesc, Integer... queueStatusArr);
@ApiOperation(value = "根据分页条件查询生产队列工位推送信息")
ListPager<MesQueueOrderPush> queryQueueOrderPushListPager(Map<String, String> paramMap, List<String> pushSourceCodeList, Pager pager);
@ApiOperation(value = "根据条件修改生产队列工位推送信息状态")
void saveQueueOrderPushStatusByDdlPackBean(DdlPackBean packBean, String userInfo, Integer queueStatus, String targerWorkCellCode);
@ApiOperation(value = "根据条件修改生产队列工位推送信息")
void saveQueueOrderPushByCondition(String[] conditionName, Object[] conditionValue, String[] propertyName, Object[] propertyValue);
}

@ -4,7 +4,7 @@ import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesShippingKanbanCfgModel;
import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesShippingKanbanModel;
public interface IMesShippingKanbanCfgService {
MesShippingKanbanCfgModel queryShippingKanbanCfg(String organizeCode);
MesShippingKanbanCfgModel queryShippingKanbanCfg(String organizeCode, String shippingGroupCode);
void doSaveShippingKanbanCfg(MesShippingKanbanCfgModel request, String organizeCode, String username);
MesShippingKanbanModel queryShippingKanbanContext(String organizeCode);
MesShippingKanbanModel queryShippingKanbanContext(String organizeCode, String shippingGroupCode);
}

@ -20,6 +20,9 @@ public interface IMesSortShippingCheckService {
@ApiOperation(value = "扫描发运单")
MesSortShippingCheckModel doShippingOrderNoQuery(MesShippingOrderManagement shippingOrderManagement);
@ApiOperation(value = "保存料架条码")
MesSortShippingCheckModel saveRackNo(MesSortShippingCheckModel model, String organizeCode, String userInfo);
@ApiOperation(value = "保存条码")
MesSortShippingCheckModel saveSn(MesSortShippingCheckModel model);

@ -38,7 +38,7 @@ public interface IMesWorkOrderService {
List<MesProductionRecord> getPreDayReportMesProductionRecord(String organizeCode , List<MesShift> mesShiftList, String workCenterCode);
@ApiOperation("新增工单")
List<MesWorkOrder> insertMesWorkOrder(List<MesProductionRecord> mesProductionRecordList,List<MesShift> mesShiftList,String organizeCode, String userName );
MesWorkOrder insertMesWorkOrder(List<MesProductionRecord> mesProductionRecordList,List<MesShift> mesShiftList,String organizeCode, String userName );
@ApiOperation(value = "根据前一天待报工记录数插入工单并报工JOB(工单报工)")
void doPcnJobProductReport(List<MesProductionRecord> mesProductionRecordList,List<MesShift> mesShiftList,String organizeCode, String userName, MesWorkOrder mesWorkOrder);

@ -0,0 +1,20 @@
package cn.estsh.i3plus.ext.mes.pcn.api.report;
import cn.estsh.i3plus.pojo.base.bean.ListPager;
import cn.estsh.i3plus.pojo.base.common.Pager;
import cn.estsh.i3plus.pojo.mes.bean.seres.MesCimSeresJisQueue;
import cn.estsh.i3plus.pojo.mes.bean.seres.MesCimSeresSrmRunSheetJis;
import java.util.List;
public interface IMesCimSeresReportService {
ListPager<MesCimSeresSrmRunSheetJis> querySrmSunSheetJisLogByPager(Integer status, String docNo, Pager pager);
void doSrmSunSheetJisNormal(List<Long> ids);
ListPager<MesCimSeresJisQueue> queryJisQueueLogByPager(Integer checkStatus, String vin, String materielCode, Pager pager);
void doJisQueueNormal(List<Long> ids);
}

@ -0,0 +1,57 @@
package cn.estsh.i3plus.ext.mes.pcn.apiservice.controller.busi;
import cn.estsh.i3plus.ext.mes.pcn.api.base.IMesTemplateService;
import cn.estsh.i3plus.ext.mes.pcn.pojo.constant.MesCommonConstant;
import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtConstWords;
import cn.estsh.i3plus.mes.pcn.api.iservice.base.IConfigService;
import cn.estsh.impp.framework.boot.exception.ImppBusiException;
import cn.estsh.impp.framework.boot.exception.ImppExceptionBuilder;
import cn.estsh.impp.framework.boot.util.ResultBean;
import cn.estsh.impp.framework.boot.util.ValidatorBean;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.Map;
@Api("获取系统配置的模版信息")
@RestController
@RequestMapping(MesCommonConstant.MES_YANFEN)
public class MesLabelTemplateExtController {
@Autowired
private IConfigService configService;
@Autowired
private IMesTemplateService mesTemplateService;
@GetMapping("/label-template/by-module-or-template/get")
@ApiOperation(value = "获取系统配置的模版信息")
public ResultBean queryMesLabelTemplate(String organizeCode, String moduleCode, String templateCode) {
try {
ValidatorBean.checkNotNull(organizeCode, "工厂代码不能为空");
if (StringUtils.isEmpty(moduleCode) && StringUtils.isEmpty(templateCode)) {
ValidatorBean.checkNotNull(moduleCode, "模版配置代码不能为空");
}
if (!StringUtils.isEmpty(moduleCode)) {
Map<String, String> configMap = configService.getConfigMapByCfgCode(moduleCode, organizeCode);
String templateCustomHtml = configMap.get(MesPcnExtConstWords.TEMPLATE_CUSTOM_HTML);
if (!StringUtils.isEmpty(templateCustomHtml)) return ResultBean.success("查询成功").setResultObject(templateCustomHtml);
String templateCfg = configMap.get(moduleCode);
if (!StringUtils.isEmpty(templateCfg)) templateCode = templateCfg;
}
ValidatorBean.checkNotNull(templateCode, "模版代码不能为空");
return ResultBean.success("查询成功").setResultObject(mesTemplateService.getMesLabelTemplate(templateCode, organizeCode));
} catch (ImppBusiException imppException) {
return ResultBean.fail(imppException);
} catch (Exception e) {
return ImppExceptionBuilder.newInstance().buildExceptionResult(e);
}
}
}

@ -110,4 +110,18 @@ public class MesNcProcessingController {
}
}
@GetMapping("/query-part-inspection-create-user")
@ApiOperation(value = "查询检验人NC-零件检测-单据 表的createUser")
public ResultBean queryPartInspectionCreateUser(String organizeCode) {
try {
ValidatorBean.checkNotNull(organizeCode, "工厂不能为空");
return ResultBean.success("查询成功").setResultList(
ncProcessingService.queryPartInspectionCreateUser(organizeCode));
} catch (ImppBusiException imppException) {
return ResultBean.fail(imppException);
} catch (Exception e) {
return ImppExceptionBuilder.newInstance().buildExceptionResult(e);
}
}
}

@ -39,4 +39,19 @@ public class MesOrgController {
return ResultBean.fail(e);
}
}
@GetMapping(value = "/query-split")
@ApiOperation(value = "查询责任人区域关系(拆分责任人)")
public ResultBean queryMesOrgSplit(MesOrg mesOrg) {
try {
List<MesOrg> mesOrgList= mesOrgService.queryMesOrgSplit(mesOrg);
return ResultBean.success("查询成功")
.setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode()).setResultList(mesOrgList);
} catch (ImppBusiException e) {
return ResultBean.fail(e).build();
} catch (Exception e) {
return ResultBean.fail(e);
}
}
}

@ -54,10 +54,7 @@ public class MesPartShippingGroupController {
try {
// 数据校验
ValidatorBean.checkNotNull(model.getShippingGroupCode(), "发运组代码不能为空");
List<MesShippingOrderManagementModel> shippingOrderManagementList = shippingGroupService.doMesMesShippingOrderManagementPrint(model);
return ResultBean.success("发运单打印成功")
.setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode())
.setResultList(shippingOrderManagementList);
return shippingGroupService.doMesMesShippingOrderManagementPrint(model);
} catch (ImppBusiException e) {
return ResultBean.fail(e).build();
} catch (Exception e) {

@ -26,10 +26,10 @@ public class MesShippingKanbanCfgController {
@GetMapping("/query")
@ApiOperation(value = "查询发运看板配置项")
public ResultBean queryShippingKanbanCfg(String organizeCode) {
public ResultBean queryShippingKanbanCfg(String organizeCode, String shippingGroupCode) {
try {
organizeCode = !StringUtils.isEmpty(organizeCode) ? organizeCode : AuthUtil.getOrganize().getOrganizeCode();
return ResultBean.success("查询成功").setResultObject(shippingKanbanCfgService.queryShippingKanbanCfg(organizeCode));
return ResultBean.success("查询成功").setResultObject(shippingKanbanCfgService.queryShippingKanbanCfg(organizeCode, shippingGroupCode));
} catch (ImppBusiException imppException) {
return ResultBean.fail(imppException);
} catch (Exception e) {
@ -53,10 +53,10 @@ public class MesShippingKanbanCfgController {
@GetMapping("/queryContext")
@ApiOperation(value = "查询发运看板内容")
public ResultBean queryShippingKanbanContext(String organizeCode) {
public ResultBean queryShippingKanbanContext(String organizeCode, String shippingGroupCode) {
try {
organizeCode = !StringUtils.isEmpty(organizeCode) ? organizeCode : AuthUtil.getOrganize().getOrganizeCode();
return ResultBean.success("查询成功").setResultObject(shippingKanbanCfgService.queryShippingKanbanContext(organizeCode));
return ResultBean.success("查询成功").setResultObject(shippingKanbanCfgService.queryShippingKanbanContext(organizeCode, shippingGroupCode));
} catch (ImppBusiException imppException) {
return ResultBean.fail(imppException);
} catch (Exception e) {

@ -94,6 +94,49 @@ public class MesSortShippingCheckController {
}
}
@PostMapping("/scan-rack-no")
@ApiOperation(value = "扫描料架条码")
public ResultBean saveRackNo(@RequestBody MesSortShippingCheckModel model) {
Boolean lockFlg = false;
String moduleKey = null;
String organizeCode = null;
String userInfo = null;
try {
if (StringUtils.isEmpty(model.getVolvoRackNo())) MesPcnException.throwBusiException("请扫描料架号!");
organizeCode = !StringUtils.isEmpty(model.getOrganizeCode()) ? model.getOrganizeCode() : AuthUtil.getOrganize().getOrganizeCode();
userInfo = !StringUtils.isEmpty(model.getUserInfo()) ? model.getUserInfo() : AuthUtil.getSessionUser().getUserName();
moduleKey = organizeCode + key + "VOLVO_RACK_NO:" + model.getVolvoRackNo();
log.info("工厂:{} 排序发运扫描料架条码 --- {} --- START --- 操作人:{} --- THREAD:{}", organizeCode, moduleKey, userInfo, Thread.currentThread().getName());
//加锁
lockFlg = redisLockUtil.redisLock(moduleKey);
log.info("工厂:{} 排序发运扫描料架条码 --- {} --- LOCKED --- 操作人:{} --- THREAD:{}", organizeCode, moduleKey, userInfo, Thread.currentThread().getName());
// 数据校验
ValidatorBean.checkNotNull(model.getShippingCode(), "发运单不能为空");
ValidatorBean.checkNotNull(model.getDetailList(), "发运明细不能为空");
sortShippingCheckService.saveRackNo(model, organizeCode, userInfo);
return ResultBean.success("查询成功").setResultObject(model);
} catch (ImppBusiException imppException) {
return ResultBean.fail(imppException);
} catch (Exception e) {
return ImppExceptionBuilder.newInstance().buildExceptionResult(e);
} finally {
//解锁
if (lockFlg) {
redisLockUtil.redisUnLock(lockFlg, moduleKey);
log.info("工厂:{} 排序发运扫描位置码 --- {} --- UNLOCK --- 操作人:{} --- THREAD:{}", organizeCode, moduleKey, userInfo, Thread.currentThread().getName());
}
}
}
@PostMapping("/scan-sn")
@ApiOperation(value = "扫描条码")
public ResultBean saveSn(@RequestBody MesSortShippingCheckModel model) {

@ -0,0 +1,84 @@
package cn.estsh.i3plus.ext.mes.pcn.apiservice.controller.report;
import cn.estsh.i3plus.ext.mes.pcn.api.report.IMesCimSeresReportService;
import cn.estsh.i3plus.ext.mes.pcn.pojo.constant.MesCommonConstant;
import cn.estsh.i3plus.pojo.base.bean.ListPager;
import cn.estsh.i3plus.pojo.base.common.Pager;
import cn.estsh.i3plus.pojo.base.enumutil.ResourceEnumUtil;
import cn.estsh.i3plus.pojo.mes.bean.seres.MesCimSeresJisQueue;
import cn.estsh.i3plus.pojo.mes.bean.seres.MesCimSeresSrmRunSheetJis;
import cn.estsh.impp.framework.boot.exception.ImppBusiException;
import cn.estsh.impp.framework.boot.exception.ImppExceptionBuilder;
import cn.estsh.impp.framework.boot.util.ResultBean;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.Arrays;
import java.util.List;
@Api("赛力斯报表")
@RestController
@RequestMapping(MesCommonConstant.MES_YANFEN + "/mesCimSeresReport")
public class MesCimSeresReportController {
@Autowired
private IMesCimSeresReportService mesCimSeresReportService;
@ApiOperation(value = "赛力斯JIS单接收日志", notes = "赛力斯JIS单接收日志")
@GetMapping("/query-srm-sun-sheet-jis-log")
public ResultBean querySrmSunSheetJisLogByPager(Integer status, String docNo, Pager pager){
try {
ListPager<MesCimSeresSrmRunSheetJis> queryResultListPager = mesCimSeresReportService.querySrmSunSheetJisLogByPager(status, docNo, pager);
return ResultBean.success("查询成功").setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode()).setListPager(queryResultListPager);
} catch (ImppBusiException e) {
return ResultBean.fail(e);
} catch (Exception e) {
return ImppExceptionBuilder.newInstance().buildExceptionResult(e);
}
}
@ApiOperation(value = "赛力斯JIS单转正常", notes = "赛力斯JIS单转正常")
@PostMapping("/srm-sun-sheet-jis-normal")
public ResultBean doSrmSunSheetJisNormal(@RequestBody Long[] idArray) {
try {
List<Long> idList = Arrays.asList(idArray);
mesCimSeresReportService.doSrmSunSheetJisNormal(idList);
return ResultBean.success("执行成功");
} catch (ImppBusiException e) {
return ResultBean.fail(e);
} catch (Exception e) {
return ImppExceptionBuilder.newInstance().buildExceptionResult(e);
}
}
@ApiOperation(value = "赛力斯JIS队列接收日志", notes = "赛力斯JIS队列接收日志")
@GetMapping("/query-jis-queue-log")
public ResultBean queryJisQueueLogByPager(Integer checkStatus, String vin, String materielCode, Pager pager){
try {
ListPager<MesCimSeresJisQueue> queryResultListPager = mesCimSeresReportService.queryJisQueueLogByPager(checkStatus, vin, materielCode, pager);
return ResultBean.success("查询成功").setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode()).setListPager(queryResultListPager);
} catch (ImppBusiException e) {
return ResultBean.fail(e);
} catch (Exception e) {
return ImppExceptionBuilder.newInstance().buildExceptionResult(e);
}
}
@ApiOperation(value = "赛力斯JIS队列转正常", notes = "赛力斯JIS队列转正常")
@PostMapping("/jis-queue-normal")
public ResultBean doJisQueueNormal(@RequestBody Long[] idArray) {
try {
List<Long> idList = Arrays.asList(idArray);
mesCimSeresReportService.doJisQueueNormal(idList);
return ResultBean.success("执行成功");
} catch (ImppBusiException e) {
return ResultBean.fail(e);
} catch (Exception e) {
return ImppExceptionBuilder.newInstance().buildExceptionResult(e);
}
}
}

@ -14,4 +14,6 @@ public interface IMesNcProcessingDao {
@ApiOperation(value = "查询停工统计数据")
List<MesNcProcessingPartAndLotModel> queryDefectRecordByPager(String partNo, String lotNo, String org, Pager pager);
List<String> queryPartInspectionCreateUser(String organizeCode);
}

@ -3,10 +3,12 @@ package cn.estsh.i3plus.ext.mes.pcn.apiservice.daoimpl;
import cn.estsh.i3plus.ext.mes.pcn.apiservice.dao.IMesNcProcessingDao;
import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesNcProcessingPartAndLotModel;
import cn.estsh.i3plus.pojo.base.common.Pager;
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
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 javax.persistence.EntityManager;
import javax.persistence.Query;
@ -89,4 +91,23 @@ public class MesNcProcessingDao implements IMesNcProcessingDao {
return modelList;
}
@Override
public List<String> queryPartInspectionCreateUser(String organizeCode) {
String sql = "SELECT DISTINCT(create_user) " +
"FROM mes_part_inspection " +
"WHERE is_valid = :isValid AND is_deleted = :isDeleted AND organize_code = :organizeCode ";
Query query = entityManager.createNativeQuery(sql);
query.setParameter("isValid", CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue());
query.setParameter("isDeleted", CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue());
query.setParameter("organizeCode", organizeCode);
List resultList = query.getResultList();
log.info("queryPartInspectionCreateUser-查询结果-" + resultList);
if (CollectionUtils.isEmpty(resultList)) {
return null;
}else {
return (List<String>) resultList;
}
}
}

@ -78,61 +78,53 @@ public class MesReportWorkByPreDayJob extends BaseMesScheduleJob {
if (CollectionUtils.isEmpty(mesProductionRecordList)) {
continue;
}
try {
Map<String,List<MesProductionRecord>> recordMap = mesProductionRecordList.stream().collect(Collectors.groupingBy(sn -> sn.getWorkCenterCode() + "=" + sn.getPartNo()));
for (Map.Entry<String, List<MesProductionRecord>> entry : recordMap.entrySet()) {
String k = entry.getKey();
List<MesProductionRecord> v = entry.getValue();
Map<String,List<MesProductionRecord>> recordMap = mesProductionRecordList.stream().collect(Collectors.groupingBy(sn -> sn.getWorkCenterCode() + "=" + sn.getPartNo()));
for (Map.Entry<String, List<MesProductionRecord>> entry : recordMap.entrySet()) {
String k = entry.getKey();
List<MesProductionRecord> v = entry.getValue();
try {
LOGGER.info("产线=-零件号:{},:{},报工mesProductionRecordList:{}",k, v.size());
//3.插入生产工单表
List<MesWorkOrder> mesWorkOrders = workOrderService.insertMesWorkOrder(v, mesShiftList, wmsJobParamModel.getOrganizeCode(), userName);
if (CollectionUtils.isEmpty(mesWorkOrders)) {
//3.插入生产工单表,根据产线和零件号会创建又给工单
MesWorkOrder mesWorkOrder = workOrderService.insertMesWorkOrder(v, mesShiftList, wmsJobParamModel.getOrganizeCode(), userName);
if (mesWorkOrder == null) {
continue;
}
LOGGER.info("产线:{}报工mesWorkOrders:{}", workCenterCode, mesWorkOrders.size());
LOGGER.info("产线:{}报工mesWorkOrder:{}", workCenterCode, mesWorkOrder.getWorkOrderNo());
//4.根据产线+物料产生的工单报工
for (MesWorkOrder mesWorkOrder : mesWorkOrders) {
List<MesProductionRecord> mesProductionRecords = new ArrayList<>();
try {
mesProductionRecords = mesProductionRecordList.stream().filter(
w -> w.getWorkCenterCode().equalsIgnoreCase(mesWorkOrder.getWorkCenterCode())
&& w.getPartNo().equalsIgnoreCase(mesWorkOrder.getPartNo())).collect(Collectors.toList());
workOrderService.doPcnJobProductReport(mesProductionRecords, mesShiftList, wmsJobParamModel.getOrganizeCode(), userName, mesWorkOrder);
List<MesProductionRecord> mesProductionRecords = new ArrayList<>();
try {
mesProductionRecords = v.stream().filter(
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 : mesProductionRecords) {
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.setModifyDatetime((new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS")).format(new Date()));
}
productionRecordRao.saveAll(mesProductionRecords);
} catch (ImppBusiException e) {
List<String> snList = mesProductionRecords.stream().map(MesProductionRecord::getProductSn).collect(Collectors.toList());
String errorMsg = StringUtil.isEmpty(e.getErrorDetail()) ? e.getErrorMsg() : e.getErrorDetail();
LOGGER.info("条码:{}报工失败,{}", snList, errorMsg);
for (MesProductionRecord mesProductionRecord : mesProductionRecords) {
productionRecordService.updateProductionRecord(mesProductionRecord.getOrganizeCode(), userName, mesProductionRecord.getId(), errorMsg);
if (StringUtil.isEmpty(mesProductionRecord.getWorkOrderNo())) {
mesProductionRecord.setWorkOrderNo(mesWorkOrder.getWorkOrderNo());
}
mesProductionRecord.setReportStatus(MesExtEnumUtil.REPORT_STATUS.REPORT_STATUS_20.getValue());
mesProductionRecord.setSystemSyncStatus(CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue());
ConvertBean.serviceModelUpdate(mesProductionRecord, userName);
mesProductionRecord.setModifyDatetime((new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS")).format(new Date()));
}
productionRecordRao.saveAll(mesProductionRecords);
} catch (ImppBusiException e) {
List<String> snList = mesProductionRecords.stream().map(MesProductionRecord::getProductSn).collect(Collectors.toList());
String errorMsg = StringUtil.isEmpty(e.getErrorDetail()) ? e.getErrorMsg() : e.getErrorDetail();
LOGGER.info("条码:{}报工失败,{}", snList, errorMsg);
for (MesProductionRecord mesProductionRecord : mesProductionRecords) {
productionRecordService.updateProductionRecord(mesProductionRecord.getOrganizeCode(), userName, mesProductionRecord.getId(), errorMsg);
}
}
}
} catch (ImppBusiException e) {
List<String> snList = mesProductionRecordList.stream().map(MesProductionRecord::getProductSn).collect(Collectors.toList());
String errorMsg = StringUtil.isEmpty(e.getErrorDetail()) ? e.getErrorMsg() : e.getErrorDetail();
LOGGER.info("条码:{}报工失败,{}", snList, errorMsg);
for (MesProductionRecord mesProductionRecord : mesProductionRecordList) {
productionRecordService.updateProductionRecord(mesProductionRecord.getOrganizeCode(), userName, mesProductionRecord.getId(), errorMsg);
} catch (ImppBusiException e) {
List<String> snList = v.stream().map(MesProductionRecord::getProductSn).collect(Collectors.toList());
String errorMsg = StringUtil.isEmpty(e.getErrorDetail()) ? e.getErrorMsg() : e.getErrorDetail();
LOGGER.info("条码:{}报工失败,{}", snList, errorMsg);
for (MesProductionRecord mesProductionRecord : v) {
productionRecordService.updateProductionRecord(mesProductionRecord.getOrganizeCode(), userName, mesProductionRecord.getId(), errorMsg);
}
}
}
}

@ -10,6 +10,7 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
@ -39,4 +40,41 @@ public class MesOrgServiceImpl implements IMesOrgService {
return mesOrgRDao.findByHqlWhere(packBean);
}
@Override
public List<MesOrg> queryMesOrgSplit(MesOrg mesOrg) {
DdlPackBean packBean = DdlPackBean.getDdlPackBean(mesOrg.getOrganizeCode());
DdlPreparedPack.getStringEqualPack(mesOrg.getInventoryLocationCode(), "inventoryLocationCode", packBean);
if(StringUtil.isEmpty(mesOrg.getResponsibleParty())){
DdlPreparedPack.getIsNotNull( "responsibleParty", packBean);
}else {
DdlPreparedPack.getStringEqualPack(mesOrg.getResponsibleParty(), "responsibleParty", packBean);
}
packBean.setOrderByStr(mesOrg.orderBy());
List<MesOrg> mesOrgList = mesOrgRDao.findByHqlWhere(packBean);
List<MesOrg> resultList = new ArrayList<>();
for (MesOrg org : mesOrgList) {
String responsibleParty = org.getResponsibleParty();
if (StringUtil.isEmpty(responsibleParty)) {
resultList.add(org);
}else {
if (responsibleParty.contains(",")) {
String[] split = responsibleParty.split(",");
for (int i = 0; i < split.length; i++) {
MesOrg mesOrg1 = new MesOrg();
mesOrg1.setId(org.getId());
mesOrg1.setOrganizeCode(org.getOrganizeCode());
mesOrg1.setInventoryLocationCode(org.getInventoryLocationCode());
mesOrg1.setInventoryLocationName(org.getInventoryLocationName());
mesOrg1.setResponsibleParty(split[i]);
resultList.add(mesOrg1);
}
}else {
resultList.add(org);
}
}
}
return resultList;
}
}

@ -0,0 +1,27 @@
package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.base;
import cn.estsh.i3plus.ext.mes.pcn.api.base.IMesPartPackageTypeService;
import cn.estsh.i3plus.pojo.base.bean.DdlPackBean;
import cn.estsh.i3plus.pojo.base.tool.DdlPreparedPack;
import cn.estsh.i3plus.pojo.mes.bean.MesPartPackageType;
import cn.estsh.i3plus.pojo.mes.repository.IMesPartPackageTypeRepository;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* @author jason
*/
@Service
@Slf4j
public class MesPartPackageTypeServiceImpl implements IMesPartPackageTypeService {
@Autowired
private IMesPartPackageTypeRepository partPackageTypeRDao;
@Override
public MesPartPackageType getMesPartPackageType(String organizeCode, String packageTypeCode) {
DdlPackBean packBean = DdlPackBean.getDdlPackBean(organizeCode);
DdlPreparedPack.getStringEqualPack(packageTypeCode, "packageTypeCode", packBean);
return partPackageTypeRDao.getByProperty(packBean);
}
}

@ -5,14 +5,8 @@ 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.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;
import cn.estsh.i3plus.pojo.mes.bean.*;
import cn.estsh.i3plus.pojo.mes.repository.*;
import cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
@ -39,6 +33,9 @@ public class MesProdOrgExtService implements IMesProdOrgExtService {
@Autowired
private MesWorkCellExtendCfgRepository workCellExtendCfgRepository;
@Autowired
private MesWorkCellPartPrinterCfgRepository workCellPartPrinterCfgRepository;
@Override
public MesWorkCenter getWorkCenterDb(String organizeCode, String workCenterCode) {
if (StringUtils.isEmpty(organizeCode) || StringUtils.isEmpty(workCenterCode)) return null;
@ -186,4 +183,11 @@ public class MesProdOrgExtService implements IMesProdOrgExtService {
return getWorkCellExtendCfgList(organizeCode, workCellExtendCfg.getWorkCenterCode(), workCellExtendCfg.getWorkCellCode(), MesExtEnumUtil.WORK_CELL_EXTEND_TYPE.RV.getValue());
}
@Override
public List<MesWorkCellPartPrinterCfg> getWorkCellPartPrinterCfgList(String organizeCode, String workCenterCode, String workCellCode) {
return workCellPartPrinterCfgRepository.findByProperty(
new String[]{MesPcnExtConstWords.ORGANIZE_CODE, MesPcnExtConstWords.IS_DELETED, MesPcnExtConstWords.IS_VALID, MesPcnExtConstWords.WORK_CENTER_CODE, MesPcnExtConstWords.WORK_CELL_CODE},
new Object[]{organizeCode, CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue(), CommonEnumUtil.IS_VAILD.VAILD.getValue(), workCenterCode, workCellCode});
}
}

@ -92,7 +92,7 @@ public class MesProdShiftRecordServiceImpl implements IMesProdShiftRecordService
//唯一性校验
DdlPackBean packBean = DdlPackBean.getDdlPackBean(item.getOrganizeCode());
DdlPreparedPack.getStringEqualPack(item.getWorkCenterCode(), "workCenterCode", packBean);
DdlPreparedPack.getStringEqualPack(item.getShiftGroup(), "shiftGroup", packBean);
// DdlPreparedPack.getStringEqualPack(item.getShiftGroup(), "shiftGroup", packBean);
DdlPreparedPack.getIsNull("endTime", packBean);
boolean flg = mesProdShiftRecordRDao.isExitByHql(packBean);

@ -459,7 +459,7 @@ public class MesReworkTaskServiceImpl implements IMesReworkTaskService {
packBean = DdlPackBean.getDdlPackBean(requestModel.getOrganizeCode());
DdlPreparedPack.getStringEqualPack(produceSn.getProductSn(), MesPcnExtConstWords.PRODUCT_SN, packBean);
DdlPreparedPack.getStringEqualPack(produceSn.getWorkOrderNo(), MesPcnExtConstWords.WORK_ORDER_NO, packBean);
produceSnExtService.saveProduceSntatusByDdlPackBean(packBean, requestModel.getUserName(), MesExtEnumUtil.PRODUCE_SN_STATUS.ASSEMBLY_DISASSEMBLY.getValue());
produceSnExtService.saveProduceSnStatusByDdlPackBean(packBean, requestModel.getUserName(), MesExtEnumUtil.PRODUCE_SN_STATUS.ASSEMBLY_DISASSEMBLY.getValue());
//查询装配件绑定记录表
List<MesProductionAssembly> productionAssemblyList = mesAssemblyExtService.getProductionAssemblySortList(requestModel.getOrganizeCode(), workOrder.getWorkOrderNo());
@ -476,7 +476,7 @@ public class MesReworkTaskServiceImpl implements IMesReworkTaskService {
DdlPreparedPack.getStringEqualPack(productionAssembly.getAssemblySn(), MesPcnExtConstWords.PRODUCT_SN, packBean);
DdlPreparedPack.getStringEqualPack(productionAssembly.getAssemblyPartNo(), MesPcnExtConstWords.PART_NO, packBean);
DdlPreparedPack.getNumEqualPack(MesExtEnumUtil.PRODUCE_SN_STATUS.ASSEMBLY.getValue(), MesPcnExtConstWords.SN_STATUS, packBean);
produceSnExtService.saveProduceSntatusByDdlPackBean(packBean, requestModel.getUserName(), MesExtEnumUtil.PRODUCE_SN_STATUS.ASSEMBLY_BACK.getValue());
produceSnExtService.saveProduceSnStatusByDdlPackBean(packBean, requestModel.getUserName(), MesExtEnumUtil.PRODUCE_SN_STATUS.ASSEMBLY_BACK.getValue());
}
//将装配件绑定记录表的非解绑状态的记录改为解绑状态

@ -98,8 +98,8 @@ public class MesAssemblyExtService implements IMesAssemblyExtService {
if (StringUtils.isEmpty(prodRuleContext.getOrganizeCode()) || StringUtils.isEmpty(prodRuleContext.getWorkCenterCode()) ||
StringUtils.isEmpty(prodRuleContext.getWorkCellCode()) || StringUtils.isEmpty(prodRuleContext.getProcessCode()) || StringUtils.isEmpty(prodRuleContext.getProductSn())) return null;
//【排序线】获取生产工单装配件清单
List<MesWorkOrderAssembly> workOrderAssemblyList = getWorkOrderAssemblyList(prodRuleContext, true);
//【排序线】获取生产工单装配件清单 [前道所有装配件]
List<MesWorkOrderAssembly> workOrderAssemblyList = getWorkOrderAssemblyListAllCell(prodRuleContext, new ArrayList<>(workCellMap.values()));
if (CollectionUtils.isEmpty(workOrderAssemblyList)) return null;
@ -150,6 +150,20 @@ public class MesAssemblyExtService implements IMesAssemblyExtService {
}
//【排序线】获取生产工单装配件清单[前道所有装配件]
@Override
public List<MesWorkOrderAssembly> getWorkOrderAssemblyListAllCell(MesProdRuleContext prodRuleContext, List<MesWorkCell> workCellList) {
//【排序线】获取生产工单装配件清单
List<MesWorkOrderAssembly> workOrderAssemblyList = getWorkOrderAssemblyList(prodRuleContext, true);
if (CollectionUtils.isEmpty(workOrderAssemblyList)) return workOrderAssemblyList;
//判断是否存在其他末道工位[可能存在平行工位]
List<String> workCellList2End = workCellList.stream().filter(o -> (null != o
&& o.getIsEndWorkCell().compareTo(CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue()) == 0
&& !o.getWorkCellCode().equals(prodRuleContext.getWorkCellCode()))).map(MesWorkCell::getWorkCellCode).collect(Collectors.toList());
if (CollectionUtils.isEmpty(workCellList2End)) return workOrderAssemblyList;
return workOrderAssemblyList.stream().filter(o -> (null != o && !workCellList2End.contains(o.getWorkCellCode()))).collect(Collectors.toList());
}
//获取装配件绑定记录【排序】
@Override
public List<MesProductionAssembly> getProductionAssemblySortList(String organizeCode, String productSn) {

@ -37,6 +37,7 @@ import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import java.util.*;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
@ -145,7 +146,7 @@ public class MesNcProcessingService implements IMesNcProcessingService {
DdlPreparedPack.getNumEqualPack(MesExtEnumUtil.PART_INSPECTION_STATUS.FAIL.getValue(), "inspectionStatus", packBean);
DdlPreparedPack.getNumEqualPack(MesExtEnumUtil.PART_INSPECTION_NC_STATUS.CREATE.getValue(), "ncStatus", packBean);
DdlPreparedPack.getNumEqualPack(partInspection.getRefundFlag(), "refundFlag", packBean);
DdlPreparedPack.getStringEqualPack(partInspection.getCreateUser(), "createUser", packBean);
DdlPreparedPack.getOrderByPack(new Object[]{CommonEnumUtil.ASC_OR_DESC.DESC.getValue()}, new String[]{"createDatetime"}, packBean);
pager = PagerHelper.getPager(pager, partInspectionRepository.findByHqlWhereCount(packBean));
@ -235,6 +236,11 @@ public class MesNcProcessingService implements IMesNcProcessingService {
}
}
@Override
public List<String> queryPartInspectionCreateUser(String organizeCode) {
return ncProcessingDao.queryPartInspectionCreateUser(organizeCode);
}
/**
*
*
@ -595,11 +601,11 @@ public class MesNcProcessingService implements IMesNcProcessingService {
}
//更新检验单
DdlPackBean packBean = DdlPackBean.getDdlPackBean(org);
DdlPreparedPack.getStringEqualPack(areaCode, "inventoryLocationCode", packBean);
MesOrg mesOrg = mesOrgRDao.getByProperty(packBean);
// DdlPackBean packBean = DdlPackBean.getDdlPackBean(org);
// DdlPreparedPack.getStringEqualPack(areaCode, "inventoryLocationCode", packBean);
// MesOrg mesOrg = mesOrgRDao.getByProperty(packBean);
//报废时设置责任人
model.getPartInspection().setResponsibleParty(StringUtil.isEmpty(mesOrg)?areaCode:mesOrg.getResponsibleParty());
model.getPartInspection().setResponsibleParty(model.getOnlyPerson());
model.getPartInspection().setDefectTypeId(person.getId());
model.getPartInspection().setNcStatus(MesExtEnumUtil.PART_INSPECTION_NC_STATUS.SCRAP.getValue());
model.getPartInspection().setRejectQty(model.getPartInspection().getQty());

@ -1,51 +1,52 @@
package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.busi;
import cn.estsh.i3plus.ext.mes.pcn.api.base.IMesTemplateService;
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesPartShippingGroupService;
import cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.print.IPrintTemplateStrategyService;
import cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.print.sortshipping.ISortShippingDispatchStrategyService;
import cn.estsh.i3plus.ext.mes.pcn.apiservice.util.MesPcnException;
import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtConstWords;
import cn.estsh.i3plus.platform.common.convert.ConvertBean;
import cn.estsh.i3plus.platform.common.tool.TimeTool;
import cn.estsh.i3plus.mes.pcn.api.iservice.base.IConfigService;
import cn.estsh.i3plus.pojo.base.bean.DdlPackBean;
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
import cn.estsh.i3plus.pojo.base.enumutil.ResourceEnumUtil;
import cn.estsh.i3plus.pojo.base.tool.DdlPreparedPack;
import cn.estsh.i3plus.pojo.base.util.StringUtil;
import cn.estsh.i3plus.pojo.mes.bean.MesConfig;
import cn.estsh.i3plus.pojo.mes.bean.MesLabelTemplate;
import cn.estsh.i3plus.pojo.mes.bean.MesPartShippingGroup;
import cn.estsh.i3plus.pojo.mes.bean.MesPartShippingGroupDetail;
import cn.estsh.i3plus.pojo.mes.bean.edi.wuhu.MesCimCheryOrder;
import cn.estsh.i3plus.pojo.mes.bean.shipping.MesShippingOrderManagement;
import cn.estsh.i3plus.pojo.mes.bean.shipping.MesShippingOrderManagementDetail;
import cn.estsh.i3plus.pojo.mes.model.MesShippingOrderManagementDetailModel;
import cn.estsh.i3plus.pojo.mes.model.MesShippingOrderManagementModel;
import cn.estsh.i3plus.pojo.mes.repository.*;
import cn.estsh.i3plus.pojo.mes.repository.MesConfigRepository;
import cn.estsh.i3plus.pojo.mes.repository.MesPartShippingGroupDetailRepository;
import cn.estsh.i3plus.pojo.mes.repository.MesPartShippingGroupRepository;
import cn.estsh.impp.framework.boot.util.ResultBean;
import cn.estsh.impp.framework.boot.util.SpringContextsUtil;
import com.alibaba.fastjson.JSONObject;
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.*;
import java.util.stream.Collectors;
import java.util.List;
@Service
@Slf4j
public class MesPartShippingGroupService implements IMesPartShippingGroupService {
@Autowired
private MesPartShippingGroupRepository shippingGroupRepository;
private IConfigService configService;
@Autowired
private MesShippingOrderManagementRepository shippingOrderManagementRepository;
private IMesTemplateService templateService;
@Autowired
private MesShippingOrderManagementDetailRepository shippingOrderManagementDetailRepository;
private MesPartShippingGroupRepository shippingGroupRepository;
@Autowired
private MesPartShippingGroupDetailRepository mesPartShippingGroupDetailRepository;
@Autowired
private MesCimCheryOrderRepository cheryOrderRao;
@Autowired
private MesConfigRepository mesConfigRao;
public List<MesPartShippingGroup> findAll(MesPartShippingGroup partShippingGroup) {
@ -64,105 +65,31 @@ public class MesPartShippingGroupService implements IMesPartShippingGroupService
}
@Override
public List<MesShippingOrderManagementModel> doMesMesShippingOrderManagementPrint(MesShippingOrderManagement bean) {
DdlPackBean configPackBean = DdlPackBean.getDdlPackBean(bean.getOrganizeCode());
DdlPreparedPack.getStringEqualPack("WU_HU_SUPPLIER","cfgKey", configPackBean);
List<MesConfig> configList = mesConfigRao.findByHqlWhere(configPackBean);
String supplierNo = "";
if (configList != null && !configList.isEmpty()) {
supplierNo = configList.get(0).getCfgValue();
}
List<MesShippingOrderManagementModel> modelList = new ArrayList<>();
DdlPackBean packBean = DdlPackBean.getDdlPackBean(bean.getOrganizeCode());
//多选
if (!StringUtil.isEmpty(bean.getShippingGroupCode())) {
DdlPreparedPack.getInPackList(Arrays.asList(bean.getShippingGroupCode().split(",")), "shippingGroupCode", packBean);
}
DdlPreparedPack.getStringEqualPack(bean.getShippingCode(), "shippingCode", packBean);
DdlPreparedPack.getIsNull("lastPrintTime", packBean);
DdlPreparedPack.getOrderByPack(new Object[]{CommonEnumUtil.ASC_OR_DESC.ASC.getValue()}, new String[]{"createDatetime"}, packBean);
List<MesShippingOrderManagement> pullingOrderInfos = shippingOrderManagementRepository.findByHqlTopWhere(packBean,10);
if (!CollectionUtils.isEmpty(pullingOrderInfos)) {
//把查出来的发运单打印并修改打印状态为已打印
for (MesShippingOrderManagement shippingOrder : pullingOrderInfos) {
MesShippingOrderManagementModel model = new MesShippingOrderManagementModel();
String shippingCodePrefix = shippingOrder.getShippingCode().substring(0, shippingOrder.getShippingCode().length() - 3);
String shippingCodeSuffix = shippingOrder.getShippingCode().substring(shippingOrder.getShippingCode().length() - 3);
model.setShippingCode(shippingCodePrefix);
model.setShippingCodeAfter3(shippingCodeSuffix);
model.setShippingCodeWhole(shippingOrder.getShippingCode());
//查询原始报文
List<MesCimCheryOrder> cheryOrderList = getCheryOrder(shippingOrder.getOrganizeCode(), shippingOrder.getShippingCode());
Map<String, List<MesCimCheryOrder>> cheryOrderMap = new HashMap<>();
if (cheryOrderList != null && !cheryOrderList.isEmpty()) {
MesCimCheryOrder cheryOrder = cheryOrderList.get(0);
model.setPlantName(cheryOrder.getPlantName());
model.setPartkitName(cheryOrder.getPartkitName());
model.setDeliverySendSequence(cheryOrder.getDeliverySendSequence());
model.setReceiveDockName(cheryOrder.getReceiveDockNo()+"--"+cheryOrder.getReceiveDockName());
model.setLastRecRequireTime(cheryOrder.getLastRecRequireTime());
//根据cheryOrder的workshopNo获取对应的车间名称
String workshopName = getWorkshopName(cheryOrder.getOrganizeCode(), cheryOrder.getWorkshopNo());
model.setWorkShop(workshopName);
model.setCreateDateTime(cheryOrder.getCreateDatetime());
model.setPrintDateTime(TimeTool.getNowTime(true));
cheryOrderMap = cheryOrderList.stream().collect(Collectors.groupingBy(MesCimCheryOrder::getVin));
}
//查询发运单明细
DdlPackBean partPackBean = DdlPackBean.getDdlPackBean(shippingOrder.getOrganizeCode());
DdlPreparedPack.getNumEqualPack(shippingOrder.getId(), "pid", partPackBean);
DdlPreparedPack.getOrderBy("boxNum",CommonEnumUtil.ASC_OR_DESC.ASC.getValue(), partPackBean);
List<MesShippingOrderManagementDetail> shipOrderPartInfos = shippingOrderManagementDetailRepository.findByHqlWhere(partPackBean);
if (!CollectionUtils.isEmpty(shipOrderPartInfos)) {
List<MesShippingOrderManagementDetailModel> detailList = new ArrayList<>();
shipOrderPartInfos = shipOrderPartInfos.stream().sorted(Comparator.comparing(MesShippingOrderManagementDetail::getCustInfoSeq)).collect(Collectors.toList());
for (MesShippingOrderManagementDetail shipOrderPartInfo : shipOrderPartInfos) {
MesShippingOrderManagementDetailModel detailModel = new MesShippingOrderManagementDetailModel();
detailModel.setPartNo(shipOrderPartInfo.getPartNo());
detailModel.setPartName(shipOrderPartInfo.getPartName());
detailModel.setQty(shipOrderPartInfo.getPlanQty());
detailModel.setBoxNo(shipOrderPartInfo.getCustInfoSeq());
detailModel.setSupplierNo(supplierNo);
detailModel.setVin(shipOrderPartInfo.getVin().substring(shipOrderPartInfo.getVin().length()-8));
MesCimCheryOrder order = cheryOrderMap.get(shipOrderPartInfo.getVin()).get(0);
if (order != null) {
detailModel.setWholePartNo(order.getMaterialNo());
}
detailList.add(detailModel);
}
model.setShipOrderPartInfos(detailList);
}
//查询原有报文 根据shippingCode;
shippingOrder.setPrintCount(StringUtil.isEmpty(shippingOrder.getPrintCount())?1:shippingOrder.getPrintCount()+1);
shippingOrder.setLastPrintTime(TimeTool.getNowTime(true));
shippingOrder.setLastPrintUser(bean.getUserInfo());
ConvertBean.serviceModelUpdate(shippingOrder, bean.getUserInfo());
modelList.add(model);
}
shippingOrderManagementRepository.saveAll(pullingOrderInfos);
}
// return pullingOrderInfos;
return modelList;
}
public ResultBean doMesMesShippingOrderManagementPrint(MesShippingOrderManagement bean) {
private String getWorkshopName(String organizeCode, String workshopNo) {
MesConfig config = configService.getMesConfigByCfgCode(MesPcnExtConstWords.SORT_SHIPPING_PRINT_TEMPLATE, bean.getOrganizeCode());
if (null == config || StringUtils.isEmpty(config.getCfgValue())) MesPcnException.throwBusiException("未配置排序发运全局打印配置[%s]", MesPcnExtConstWords.SORT_SHIPPING_PRINT_TEMPLATE);
DdlPackBean ddlPackBean = DdlPackBean.getDdlPackBean(organizeCode);
DdlPreparedPack.getStringEqualPack(workshopNo, "cfgKey", ddlPackBean);
List<MesConfig> configList = mesConfigRao.findByHqlWhere(ddlPackBean);
return configList.isEmpty() ? "" : configList.get(0).getCfgValue();
MesLabelTemplate labelTemplate = templateService.getMesLabelTemplate(config.getCfgValue(), bean.getOrganizeCode());
if (StringUtils.isEmpty(labelTemplate.getMethodCode())) MesPcnException.throwBusiException("排序发运打印模版[%s]未配置策略方法", config.getCfgValue());
ISortShippingDispatchStrategyService dispatchStrategyService = (ISortShippingDispatchStrategyService) SpringContextsUtil.getBean(labelTemplate.getMethodCode());
List<MesShippingOrderManagement> shippingOrderManagementList = dispatchStrategyService.getShippingOrderManagementList(bean);
if (CollectionUtils.isEmpty(shippingOrderManagementList))
return ResultBean.success("不存在需要打印的发运单").setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode());
log.info("工厂{}排序发运打印 --- 获取到打印数据:{}条 --- bean:{} --- shippingOrderManagementList:{} --- {}",
bean.getOrganizeCode(), shippingOrderManagementList.size(), JSONObject.toJSONString(bean), JSONObject.toJSONString(shippingOrderManagementList), Thread.currentThread().getName());
IPrintTemplateStrategyService printStrategyService = (IPrintTemplateStrategyService) SpringContextsUtil.getBean(labelTemplate.getMethodCode());
ResultBean resultBean = printStrategyService.execute(bean, shippingOrderManagementList);
log.info("工厂{}排序发运打印 --- 封装打印数据完成 --- {}", bean.getOrganizeCode(), Thread.currentThread().getName());
return resultBean;
}
private List<MesCimCheryOrder> getCheryOrder(String organizeCode, String sheetNo) {
DdlPackBean ddlPackBean = DdlPackBean.getDdlPackBean(organizeCode);
DdlPreparedPack.getStringEqualPack(sheetNo, "sheetNo", ddlPackBean);
return cheryOrderRao.findByHqlWhere(ddlPackBean);
}
@Override
public MesPartShippingGroupDetail getMesPartShippingGroupDetail(String organizeCode, String shippingGroupCode, String partNo, String custPartNo) {
if(StringUtil.isEmpty(organizeCode) || StringUtil.isEmpty(shippingGroupCode) || StringUtil.isEmpty(partNo) || StringUtil.isEmpty(custPartNo)) return null;
@ -181,4 +108,5 @@ public class MesPartShippingGroupService implements IMesPartShippingGroupService
DdlPreparedPack.getStringEqualPack(partNo, "partNo", packBean);
return mesPartShippingGroupDetailRepository.getByProperty(packBean);
}
}

@ -220,18 +220,20 @@ public class MesProduceSnExtService implements IMesProduceSnExtService {
if (idList.size() == 1) DdlPreparedPack.getNumEqualPack(idList.get(0), MesPcnExtConstWords.ID, packBean);
else DdlPreparedPack.getInPackList(idList, MesPcnExtConstWords.ID, packBean);
produceSnRepository.updateByPropertiesNoSync(
new String[]{MesPcnExtConstWords.MODIFY_USER, MesPcnExtConstWords.MODIFY_DATE_TIME, MesPcnExtConstWords.SYSTEM_SYNC_STATUS, MesPcnExtConstWords.WORK_CENTER_CODE, MesPcnExtConstWords.WORK_CELL_CODE, MesPcnExtConstWords.SN_STATUS},
new Object[]{reqBean.getUserInfo(), TimeTool.getNowTime(true), CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue(), reqBean.getWorkCenterCode(), reqBean.getWorkCellCode(), snStatus},
new String[]{MesPcnExtConstWords.WORK_CENTER_CODE, MesPcnExtConstWords.WORK_CELL_CODE, MesPcnExtConstWords.SN_STATUS,
MesPcnExtConstWords.MODIFY_USER, MesPcnExtConstWords.MODIFY_DATE_TIME, MesPcnExtConstWords.SYSTEM_SYNC_STATUS, MesPcnExtConstWords.SYSTEM_SYNC_DATE_TIME},
new Object[]{reqBean.getWorkCenterCode(), reqBean.getWorkCellCode(), snStatus,
reqBean.getUserInfo(), TimeTool.getNowTime(true), CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue(), MesPcnExtConstWords.EMPTY},
packBean);
}
@Override
public void saveProduceSntatusByDdlPackBean(DdlPackBean packBean, String userInfo, Integer snStatus) {
public void saveProduceSnStatusByDdlPackBean(DdlPackBean packBean, String userInfo, Integer snStatus) {
if (StringUtils.isEmpty(userInfo) || StringUtils.isEmpty(snStatus)) return;
produceSnRepository.updateByPropertiesNoSync(
new String[]{MesPcnExtConstWords.MODIFY_USER, MesPcnExtConstWords.MODIFY_DATE_TIME, MesPcnExtConstWords.SYSTEM_SYNC_STATUS, MesPcnExtConstWords.SN_STATUS},
new Object[]{userInfo, TimeTool.getNowTime(true), CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue(), snStatus},
new String[]{MesPcnExtConstWords.SN_STATUS, MesPcnExtConstWords.MODIFY_USER, MesPcnExtConstWords.MODIFY_DATE_TIME, MesPcnExtConstWords.SYSTEM_SYNC_STATUS, MesPcnExtConstWords.SYSTEM_SYNC_DATE_TIME},
new Object[]{snStatus, userInfo, TimeTool.getNowTime(true), CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue(), MesPcnExtConstWords.EMPTY},
packBean);
}

@ -5,15 +5,17 @@ import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProductionPartContext;
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProductionPsOutContext;
import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtConstWords;
import cn.estsh.i3plus.platform.common.convert.ConvertBean;
import cn.estsh.i3plus.platform.common.tool.TimeTool;
import cn.estsh.i3plus.pojo.base.bean.DdlPackBean;
import cn.estsh.i3plus.pojo.base.bean.ListPager;
import cn.estsh.i3plus.pojo.base.common.Pager;
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.MesPart;
import cn.estsh.i3plus.pojo.mes.bean.MesQueueOrderPush;
import cn.estsh.i3plus.pojo.mes.bean.MesQueueOrderPushCellCfg;
import cn.estsh.i3plus.pojo.mes.bean.MesWorkOrder;
import cn.estsh.i3plus.pojo.mes.model.StationRequestBean;
import cn.estsh.i3plus.pojo.mes.repository.MesQueueOrderPushCellCfgRepository;
import cn.estsh.i3plus.pojo.mes.repository.MesQueueOrderPushRepository;
import cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil;
@ -50,12 +52,13 @@ public class MesQueueOrderPushService implements IMesQueueOrderPushService {
new Object[]{organizeCode, CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue(), CommonEnumUtil.IS_VAILD.VAILD.getValue(), workCenterCode});
}
//获取当前工单对应的工位推单队列中最大的顺序号; 递增步长10,取整10位; 例如:查询=10 >> 返回=20 ; 查询=29 >> 返回=30
//获取当前生产线推单代码中最大的顺序号; 递增步长10,取整10位; 例如:查询=10 >> 返回=20 ; 查询=29 >> 返回=30
@Override
public Integer getQueueOrderPushMaxSeq(String organizeCode, String workOrderNo) {
if (StringUtils.isEmpty(organizeCode) || StringUtils.isEmpty(workOrderNo)) return MesPcnExtConstWords.TEN;
public Integer getQueueOrderPushMaxSeq(String organizeCode, MesQueueOrderPushCellCfg queueOrderPushCellCfg) {
if (StringUtils.isEmpty(organizeCode) || null == queueOrderPushCellCfg) return MesPcnExtConstWords.TEN;
DdlPackBean packBean = DdlPackBean.getDdlPackBean(organizeCode);
DdlPreparedPack.getStringEqualPack(workOrderNo, MesPcnExtConstWords.WORK_ORDER_NO, packBean);
DdlPreparedPack.getStringEqualPack(queueOrderPushCellCfg.getPushSourceCode(), MesPcnExtConstWords.PUSH_SOURCE_CODE, packBean);
DdlPreparedPack.getStringEqualPack(queueOrderPushCellCfg.getWorkCenterCode(), MesPcnExtConstWords.WORK_CENTER_CODE, packBean);
DdlPreparedPack.getOrderByPack(new Object[]{CommonEnumUtil.ASC_OR_DESC.DESC.getValue()}, new String[]{MesPcnExtConstWords.PROCESS_SEQ}, packBean);
MesQueueOrderPush queueOrderPushDb2MaxSeq = queueOrderPushRepository.getByProperty(packBean);
return ((null == queueOrderPushDb2MaxSeq || queueOrderPushDb2MaxSeq.getProcessSeq().compareTo(MesPcnExtConstWords.ZERO) == 0)
@ -63,28 +66,44 @@ public class MesQueueOrderPushService implements IMesQueueOrderPushService {
) * MesPcnExtConstWords.TEN;
}
//根据条件顺序号查询上一个顺序号,返回加一
@Override
public Integer getQueueOrderPushCalcSeq(String organizeCode, MesQueueOrderPushCellCfg queueOrderPushCellCfg, Integer processSeqUp) {
if (StringUtils.isEmpty(organizeCode) || null == queueOrderPushCellCfg) return MesPcnExtConstWords.TEN;
DdlPackBean packBean = DdlPackBean.getDdlPackBean(organizeCode);
DdlPreparedPack.getStringEqualPack(queueOrderPushCellCfg.getPushSourceCode(), MesPcnExtConstWords.PUSH_SOURCE_CODE, packBean);
DdlPreparedPack.getStringEqualPack(queueOrderPushCellCfg.getWorkCenterCode(), MesPcnExtConstWords.WORK_CENTER_CODE, packBean);
DdlPreparedPack.getNumberSmallerPackContainsZero(processSeqUp, MesPcnExtConstWords.PROCESS_SEQ, packBean);
DdlPreparedPack.getOrderByPack(new Object[]{CommonEnumUtil.ASC_OR_DESC.DESC.getValue()}, new String[]{MesPcnExtConstWords.PROCESS_SEQ}, packBean);
MesQueueOrderPush queueOrderPushDb2MaxSeq = queueOrderPushRepository.getByProperty(packBean);
if (null == queueOrderPushDb2MaxSeq) return MesPcnExtConstWords.ONE;
Integer processSeq = queueOrderPushDb2MaxSeq.getProcessSeq() + 1;
if (processSeq.compareTo(processSeqUp) == 0) return queueOrderPushDb2MaxSeq.getProcessSeq();
return processSeq;
}
//写入工位工单推送信息
@Override
public void insertQueueOrderPush(String organizeCode, String userInfo, List<MesQueueOrderPushCellCfg> queueOrderPushCellCfgList,
MesProductionPsOutContext productionPsOutContext, MesProductionPartContext productionPartContext) {
if (StringUtils.isEmpty(organizeCode) || StringUtils.isEmpty(userInfo) || null == productionPsOutContext || CollectionUtils.isEmpty(queueOrderPushCellCfgList)) return;
Integer processSeq = getQueueOrderPushMaxSeq(organizeCode, productionPsOutContext.getWorkOrderNo());
for (MesQueueOrderPushCellCfg queueOrderPushCellCfg : queueOrderPushCellCfgList) {
Integer processSeq = getQueueOrderPushMaxSeq(organizeCode, queueOrderPushCellCfg);
if (null == queueOrderPushCellCfg) continue;
MesQueueOrderPush queueOrderPush = new MesQueueOrderPush();
queueOrderPush.setPushSourceCode(queueOrderPushCellCfg.getPushSourceCode());
queueOrderPush.setProcessSeq(processSeq);
queueOrderPush.setWorkOrderNo(productionPsOutContext.getWorkOrderNo());
queueOrderPush.setProductSn(productionPsOutContext.getProductSn());
queueOrderPush.setCustSn(productionPsOutContext.getCustSn());
queueOrderPush.setPartNo(productionPsOutContext.getPartNo());
queueOrderPush.setPartName(productionPsOutContext.getPartName());
queueOrderPush.setProcessSeq(processSeq);
queueOrderPush.setQueueStatus(MesExtEnumUtil.QUEUE_ORDER_STATUS.CREATE.getValue());
queueOrderPush.setProductSeq(productionPartContext.getProductSeq());
queueOrderPush.setWorkOrderSeq(productionPartContext.getWorkOrderSeq());
queueOrderPush.setCarModelCode(productionPartContext.getCarModelCode());
queueOrderPush.setCustOrderNo(productionPartContext.getCustOrderNo());
queueOrderPush.setPartProdGroupCode(productionPartContext.getPartProdGroupCode());
queueOrderPush.setQueueStatus(MesExtEnumUtil.QUEUE_ORDER_STATUS.CREATE.getValue());
queueOrderPush.setAreaCode(queueOrderPushCellCfg.getAreaCode());
queueOrderPush.setWorkCenterCode(queueOrderPushCellCfg.getWorkCenterCode());
queueOrderPush.setSourceWorkCellCode(queueOrderPushCellCfg.getWorkCellCode());
@ -94,22 +113,65 @@ public class MesQueueOrderPushService implements IMesQueueOrderPushService {
}
}
//写入工位工单推送信息
@Override
public void insertQueueOrderPush(StationRequestBean reqBean, MesWorkOrder workOrder, MesQueueOrderPushCellCfg queueOrderPushCellCfg, String processSeqUp) {
Integer processSeq;
//获取当前生产线推单代码中最大的顺序号
if (StringUtils.isEmpty(processSeqUp)) processSeq = getQueueOrderPushMaxSeq(reqBean.getOrganizeCode(), queueOrderPushCellCfg);
//根据条件顺序号查询上一个顺序号,返回加一
else processSeq = getQueueOrderPushCalcSeq(reqBean.getOrganizeCode(), queueOrderPushCellCfg, Integer.valueOf(processSeqUp));
//新增队列
MesQueueOrderPush queueOrderPush = new MesQueueOrderPush();
queueOrderPush.setPushSourceCode(queueOrderPushCellCfg.getPushSourceCode());
queueOrderPush.setProcessSeq(processSeq);
queueOrderPush.setWorkOrderNo(workOrder.getWorkOrderNo());
queueOrderPush.setProductSn(workOrder.getWorkOrderNo());
queueOrderPush.setCustSn(workOrder.getCustSn());
queueOrderPush.setPartNo(workOrder.getPartNo());
queueOrderPush.setPartName(workOrder.getPartName());
queueOrderPush.setProductSeq(workOrder.getProductSeq());
queueOrderPush.setWorkOrderSeq(workOrder.getWorkOrderSeq());
queueOrderPush.setCarModelCode(workOrder.getCarModelCode());
queueOrderPush.setCustOrderNo(workOrder.getCustOrderNo());
queueOrderPush.setPartProdGroupCode(workOrder.getPartProdGroupCode());
queueOrderPush.setQueueStatus(MesExtEnumUtil.QUEUE_ORDER_STATUS.CREATE.getValue());
queueOrderPush.setAreaCode(reqBean.getAreaCode());
queueOrderPush.setWorkCenterCode(reqBean.getWorkCenterCode());
queueOrderPush.setSourceWorkCellCode(reqBean.getWorkCellCode());
queueOrderPush.setOrganizeCode(reqBean.getOrganizeCode());
ConvertBean.serviceModelInitialize(queueOrderPush, reqBean.getUserInfo());
queueOrderPushRepository.insert(queueOrderPush);
}
///根据ID查询生产队列工位推送信息
@Override
public MesQueueOrderPush getQueueOrderPush(String organizeCode, Long id) {
if (StringUtils.isEmpty(organizeCode) || StringUtils.isEmpty(id)) return null;
return queueOrderPushRepository.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});
}
//根据配置查询创建状态的生产队列工位推送信息
@Override
public List<MesQueueOrderPush> getQueueOrderPushList(String organizeCode, List<MesQueueOrderPushCellCfg> queueOrderPushCellCfgList) {
if (StringUtils.isEmpty(organizeCode) || CollectionUtils.isEmpty(queueOrderPushCellCfgList)) return null;
//搜集推送来源代码 去重; 根据生产线代码,推送来源代码集合查询创建状态的生产队列工位推送信息【创建时间正序】
//搜集推送来源代码 去重; 根据生产线代码,推送来源代码集合查询创建状态的生产队列工位推送信息【工序顺序号正序,创建时间正序】
List<MesQueueOrderPush> queueOrderPushList = getQueueOrderPushListByStatus(organizeCode, queueOrderPushCellCfgList, CommonEnumUtil.ASC_OR_DESC.ASC.getValue(), MesExtEnumUtil.QUEUE_ORDER_STATUS.CREATE.getValue());
//条码去重
return CollectionUtils.isEmpty(queueOrderPushList) ? null :
queueOrderPushList = CollectionUtils.isEmpty(queueOrderPushList) ? null :
queueOrderPushList.stream().filter(o -> (null != o && !StringUtils.isEmpty(o.getProductSn()))).distinct()
.collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(MesQueueOrderPush::getProductSn))), ArrayList::new));
if (!CollectionUtils.isEmpty(queueOrderPushList)) queueOrderPushList = queueOrderPushList.stream().filter(o -> null != o)
.sorted(Comparator.comparing(MesQueueOrderPush::getProcessSeq).thenComparing(MesQueueOrderPush::getCreateDatetime)).collect(Collectors.toList());
return queueOrderPushList;
}
//根据配置查询生产队列工位推送信息
@Override
public List<MesQueueOrderPush> getQueueOrderPushListByStatus(String organizeCode, List<MesQueueOrderPushCellCfg> queueOrderPushCellCfgList, Integer cdtAscOrDesc, Integer... queueStatusArr) {
public List<MesQueueOrderPush> getQueueOrderPushListByStatus(String organizeCode, List<MesQueueOrderPushCellCfg> queueOrderPushCellCfgList, Integer ascOrDesc, Integer... queueStatusArr) {
if (StringUtils.isEmpty(organizeCode) || CollectionUtils.isEmpty(queueOrderPushCellCfgList)) return null;
@ -119,7 +181,7 @@ public class MesQueueOrderPushService implements IMesQueueOrderPushService {
).stream().filter(o -> !StringUtils.isEmpty(o)).distinct().collect(Collectors.toList());
if (CollectionUtils.isEmpty(pushSourceCodeList)) return null;
//根据生产线代码,推送来源代码集合查询入参状态的生产队列工位推送信息【创建时间正序】
//根据生产线代码,推送来源代码集合查询入参状态的生产队列工位推送信息【工艺顺序号,创建时间根据条件排序】
DdlPackBean packBean = DdlPackBean.getDdlPackBean(organizeCode);
DdlPreparedPack.getStringEqualPack(queueOrderPushCellCfgList.get(0).getWorkCenterCode(), MesPcnExtConstWords.WORK_CENTER_CODE, packBean);
@ -130,7 +192,7 @@ public class MesQueueOrderPushService implements IMesQueueOrderPushService {
if (pushSourceCodeList.size() == 1) DdlPreparedPack.getStringEqualPack(pushSourceCodeList.get(0), MesPcnExtConstWords.PUSH_SOURCE_CODE, packBean);
else DdlPreparedPack.getInPackList(pushSourceCodeList, MesPcnExtConstWords.PUSH_SOURCE_CODE, packBean);
if (!StringUtils.isEmpty(cdtAscOrDesc)) DdlPreparedPack.getOrderByPack(new Object[]{cdtAscOrDesc}, new String[]{MesPcnExtConstWords.CREATE_DATE_TIME}, packBean);
if (!StringUtils.isEmpty(ascOrDesc)) DdlPreparedPack.getOrderByPack(new Object[]{ascOrDesc, ascOrDesc}, new String[]{MesPcnExtConstWords.PROCESS_SEQ, MesPcnExtConstWords.CREATE_DATE_TIME}, packBean);
return queueOrderPushRepository.findByHqlWhere(packBean);
}
@ -144,6 +206,7 @@ public class MesQueueOrderPushService implements IMesQueueOrderPushService {
DdlPreparedPack.getStringEqualPack(paramMap.get(MesPcnExtConstWords.WORK_CENTER_CODE), MesPcnExtConstWords.WORK_CENTER_CODE, packBean);
DdlPreparedPack.getStringEqualPack(paramMap.get(MesPcnExtConstWords.PART_NO), MesPcnExtConstWords.PART_NO, packBean);
DdlPreparedPack.getStringEqualPack(paramMap.get(MesPcnExtConstWords.PART_PROD_GROUP_CODE), MesPcnExtConstWords.PART_PROD_GROUP_CODE, packBean);
DdlPreparedPack.getStringEqualPack(paramMap.get(MesPcnExtConstWords.CUST_ORDER_NO), MesPcnExtConstWords.PART_PROD_GROUP_CODE, packBean);
DdlPreparedPack.getStringLikerPack(paramMap.get(MesPcnExtConstWords.WORK_ORDER_NO), MesPcnExtConstWords.WORK_ORDER_NO, packBean);
DdlPreparedPack.getStringLikerPack(paramMap.get(MesPcnExtConstWords.CUST_SN), MesPcnExtConstWords.CUST_SN, packBean);
@ -157,7 +220,7 @@ public class MesQueueOrderPushService implements IMesQueueOrderPushService {
else DdlPreparedPack.getInPackList(queueStatusList, MesPcnExtConstWords.QUEUE_STATUS, packBean);
}
DdlPreparedPack.getOrderByPack(new Object[]{CommonEnumUtil.ASC_OR_DESC.DESC.getValue()}, new String[]{MesPcnExtConstWords.CREATE_DATE_TIME}, packBean);
DdlPreparedPack.getOrderByPack(new Object[]{CommonEnumUtil.ASC_OR_DESC.DESC.getValue(), CommonEnumUtil.ASC_OR_DESC.DESC.getValue()}, new String[]{MesPcnExtConstWords.PROCESS_SEQ, MesPcnExtConstWords.CREATE_DATE_TIME}, packBean);
pager = PagerHelper.getPager(pager, queueOrderPushRepository.findByHqlWhereCount(packBean));
List<MesQueueOrderPush> list = queueOrderPushRepository.findByHqlWherePage(packBean, pager);
@ -165,4 +228,22 @@ public class MesQueueOrderPushService implements IMesQueueOrderPushService {
return new ListPager<>(list, pager);
}
//根据条件修改生产队列工位推送信息状态
@Override
public void saveQueueOrderPushStatusByDdlPackBean(DdlPackBean packBean, String userInfo, Integer queueStatus, String targerWorkCellCode) {
if (StringUtils.isEmpty(userInfo) || StringUtils.isEmpty(queueStatus)) return;
queueOrderPushRepository.updateByPropertiesNoSync(
new String[]{MesPcnExtConstWords.QUEUE_STATUS, MesPcnExtConstWords.TARGET_WORK_CELL_CODE,
MesPcnExtConstWords.MODIFY_USER, MesPcnExtConstWords.MODIFY_DATE_TIME, MesPcnExtConstWords.SYSTEM_SYNC_STATUS, MesPcnExtConstWords.SYSTEM_SYNC_DATE_TIME},
new Object[]{queueStatus, targerWorkCellCode, userInfo, TimeTool.getNowTime(true), CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue(), MesPcnExtConstWords.EMPTY},
packBean);
}
//根据条件修改生产队列工位推送信息
@Override
public void saveQueueOrderPushByCondition(String[] conditionName, Object[] conditionValue, String[] propertyName, Object[] propertyValue) {
queueOrderPushRepository.updateByPropertiesNoSync(conditionName, conditionValue, propertyName, propertyValue);
}
}

@ -54,17 +54,19 @@ public class MesShippingKanbanCfgServiceImpl implements IMesShippingKanbanCfgSer
private EntityManager entityManager;
@Override
public MesShippingKanbanCfgModel queryShippingKanbanCfg(String organizeCode) {
public MesShippingKanbanCfgModel queryShippingKanbanCfg(String organizeCode, String shippingGroupCode) {
MesShippingKanbanCfgModel model = new MesShippingKanbanCfgModel();
DdlPackBean packBean = DdlPackBean.getDdlPackBean(organizeCode);
DdlPreparedPack.getStringEqualPack(shippingGroupCode, "shippingGroupCode", packBean);
MesShippingKanbanCfg kanbanCfg = shippingKanbanCfgRDao.getByProperty(packBean);
if (kanbanCfg != null) {
DdlPackBean detailPackBean = DdlPackBean.getDdlPackBean(organizeCode);
DdlPreparedPack.getNumEqualPack(kanbanCfg.getId(), "configID", packBean);
DdlPreparedPack.getNumEqualPack(kanbanCfg.getId(), "configID", detailPackBean);
List<MesShippingKanbanCfgDetail> details = shippingKanbanCfgDetailRDao.findByHqlWhere(detailPackBean);
model.setDetails(details);
} else {
kanbanCfg = new MesShippingKanbanCfg();
kanbanCfg.setShippingGroupCode(shippingGroupCode);
}
model.setConfig(kanbanCfg);
@ -95,13 +97,13 @@ public class MesShippingKanbanCfgServiceImpl implements IMesShippingKanbanCfgSer
MesShippingKanbanCfg cfg = request.getConfig();
DdlPackBean packBean = DdlPackBean.getDdlPackBean(organizeCode);
DdlPreparedPack.getStringEqualPack(cfg.getShippingGroupCode(), "shippingGroupCode", packBean);
MesShippingKanbanCfg oldCfg = shippingKanbanCfgRDao.getByProperty(packBean);
if (oldCfg == null) {
cfg.setOrganizeCode(organizeCode);
ConvertBean.serviceModelInitialize(cfg, username);
oldCfg = shippingKanbanCfgRDao.insert(cfg);
} else {
oldCfg.setShippingGroupCode(cfg.getShippingGroupCode());
oldCfg.setRefreshFrequency(cfg.getRefreshFrequency());
oldCfg.setKanbanName(cfg.getKanbanName());
oldCfg.setOnlinePoint(cfg.getOnlinePoint());
@ -130,11 +132,11 @@ public class MesShippingKanbanCfgServiceImpl implements IMesShippingKanbanCfgSer
}
@Override
public MesShippingKanbanModel queryShippingKanbanContext(String organizeCode) {
public MesShippingKanbanModel queryShippingKanbanContext(String organizeCode, String shippingGroupCode) {
MesShippingKanbanModel model = new MesShippingKanbanModel();
Map<String, MesShippingKanbanCfgDetail> cfgDetailMap = null;
MesShippingKanbanCfgModel cfgModel = queryShippingKanbanCfg(organizeCode);
MesShippingKanbanCfgModel cfgModel = queryShippingKanbanCfg(organizeCode, shippingGroupCode);
MesShippingKanbanCfg cfg = cfgModel != null ? cfgModel.getConfig() : null;
if (cfg == null) {
return model;
@ -1086,10 +1088,17 @@ public class MesShippingKanbanCfgServiceImpl implements IMesShippingKanbanCfgSer
.getSingleResult();
if (vpCount == null || Objects.equals(vpCount, 0L)) {
values.add(cfg.getCustJph());
if (!StringUtils.isEmpty(cfg.getCustJph())) {
values.add(cfg.getCustJph());
}
} else {
values.add(vpCount.toString());
}
if (values.isEmpty()) {
values.add("1");
}
return values;
}

@ -184,8 +184,6 @@ public class MesShippingLoadingCheckService implements IMesShippingLoadingCheckS
throw new ImppBusiException(String.format("【%s】此发运单扫描顺序错误请检查数据", model.getShippingCode()));
}
}
//更新页面状态
updateLoadingListDetail(model, userInfo, loadingList, loadingListDetail,"扫描完成",MesExtEnumUtil.LOADING_ORDER_DETAIL_SHIPPING_STATUS.SHIPPINGED.getValue(),userInfo);
//根据扫描的装车单找到是否先装车配置
//若配置为否,则查询装车单中所有的发运单是否都进行【排序发运校验】完成,若【排序发运校验】没完成,则提示,先进行排序发运校验。
@ -193,10 +191,13 @@ public class MesShippingLoadingCheckService implements IMesShippingLoadingCheckS
DdlPackBean packBean = DdlPackBean.getDdlPackBean(organizeCode);
DdlPreparedPack.getNumEqualPack(loadingListDetail.getShippingId(),"id",packBean);
MesShippingOrderManagement orderManagement = shippingOrderManagementRepository.getByProperty(packBean);
if (!StringUtils.isEmpty(orderManagement)) {
if (orderManagement == null || orderManagement.getStatus() != MesExtEnumUtil.SHIPPING_ORDER_STATUS.SHIPPED.getValue()) {
throw new ImppBusiException(String.format("【%s】此装车单中发运单为【%s】还未做完【排序发运校验】请检查数据", model.getShippingCode(), loadingListDetail.getShippingCode()));
}
}
//更新页面状态
updateLoadingListDetail(model, userInfo, loadingList, loadingListDetail,"扫描完成",MesExtEnumUtil.LOADING_ORDER_DETAIL_SHIPPING_STATUS.SHIPPINGED.getValue(),userInfo);
scanflg = true;
break;
}
@ -227,9 +228,9 @@ public class MesShippingLoadingCheckService implements IMesShippingLoadingCheckS
//装车单明细
List<MesLoadingListDetail> vehiclesOrderDetailList = model.getDetailList();
vehiclesOrderDetailList.forEach(k -> {
if(MesExtEnumUtil.LOADING_ORDER_DETAIL_SHIPPING_STATUS.SHIPPINGED.getValue() == k.getStatus()){
k.setStatus(MesExtEnumUtil.LOADING_ORDER_DETAIL_SHIPPING_STATUS.PUBLISHED.getValue()); // todo 不改变为发运状态
}
// if(MesExtEnumUtil.LOADING_ORDER_DETAIL_SHIPPING_STATUS.SHIPPINGED.getValue() == k.getStatus()){
// k.setStatus(MesExtEnumUtil.LOADING_ORDER_DETAIL_SHIPPING_STATUS.PUBLISHED.getValue()); // todo 不改变为发运状态
// }
k.setSystemSyncStatus(CommonEnumUtil.FALSE);
ConvertBean.serviceModelUpdate(k, userInfo);
});

@ -45,7 +45,7 @@ public class MesShippingQueueService implements IMesShippingQueueService {
public MesCimSeresJisRfid getCimSeresJisRfid(String organizeCode, String vin) {
if (StringUtils.isEmpty(organizeCode) || StringUtils.isEmpty(vin)) return null;
return cimSeresJisRfidRepository.getByProperty(
new String[]{MesPcnExtConstWords.ORGANIZE_CODE, MesPcnExtConstWords.IS_DELETED, MesPcnExtConstWords.IS_VALID, MesPcnExtConstWords.VIN_CODE, MesPcnExtConstWords.STATUS},
new String[]{MesPcnExtConstWords.ORGANIZE_CODE, MesPcnExtConstWords.IS_DELETED, MesPcnExtConstWords.IS_VALID, MesPcnExtConstWords.VIN, MesPcnExtConstWords.STATUS},
new Object[]{organizeCode, CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue(), CommonEnumUtil.IS_VAILD.VAILD.getValue(), vin, CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue()});
}
}

@ -7,7 +7,6 @@ import cn.estsh.i3plus.ext.mes.pcn.apiservice.aspect.MonitorLog;
import cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.busi.shippingscan.IMesShippingScanStrategyService;
import cn.estsh.i3plus.ext.mes.pcn.apiservice.util.MesPcnException;
import cn.estsh.i3plus.ext.mes.pcn.pojo.constant.MesCommonConstant;
import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesReworkTaskRequestModel;
import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesSortShippingCheckModel;
import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesSortShippingModel;
import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtConstWords;
@ -18,9 +17,11 @@ import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
import cn.estsh.i3plus.pojo.base.tool.DdlPreparedPack;
import cn.estsh.i3plus.pojo.base.util.StringUtil;
import cn.estsh.i3plus.pojo.mes.bean.*;
import cn.estsh.i3plus.pojo.mes.bean.edi.cd.MesCimVolvoJisRackIdDetail;
import cn.estsh.i3plus.pojo.mes.bean.shipping.*;
import cn.estsh.i3plus.pojo.mes.model.MesEquipVariableRwResult;
import cn.estsh.i3plus.pojo.mes.repository.*;
import cn.estsh.i3plus.pojo.mes.repository.edi.cd.MesCimVolvoJisRackIdDetailRepository;
import cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil;
import cn.estsh.impp.framework.boot.exception.ImppBusiException;
import cn.estsh.impp.framework.boot.util.SpringContextsUtil;
@ -121,6 +122,21 @@ public class MesSortShippingCheckService implements IMesSortShippingCheckService
@Autowired
private MesMoveRepository moveRepository;
@Autowired
private MesShippingQueueRepository shippingQueueRDao;
@Autowired
private IMesConfigService mesConfigService;
@Autowired
private MesVolvoRackRepository mesVolvoRackRDao;
@Autowired
private MesCustSoftInfoRepository custSoftInfoRDao;
@Autowired
private MesCimVolvoJisRackIdDetailRepository rackIdDetailRDao;
@Override
public MesSortShippingCheckModel doShippingOrderNoQuery(MesShippingOrderManagement shippingOrderManagement) {
//校验发运单
@ -137,6 +153,7 @@ public class MesSortShippingCheckService implements IMesSortShippingCheckService
if (!StringUtils.isEmpty(orderManagement.getCheckSeqCode())) {
model.setIsScanLocationCode(true);
}
model.setVolvoRackNo(orderManagement.getRackNo());
//发运单号
model.setShippingCode(orderManagement.getShippingCode());
//零件发运组
@ -153,6 +170,15 @@ public class MesSortShippingCheckService implements IMesSortShippingCheckService
}
@Override
public MesSortShippingCheckModel saveRackNo(MesSortShippingCheckModel model, String organizeCode, String userInfo) {
checkVolvoRack(model, organizeCode);
MesShippingOrderManagement orderManagement = checkMesShippingOrderManagement(model);
orderManagement.setRackNo(model.getVolvoRackNo());
shippingOrderManagementRepository.update(orderManagement);
return model;
}
@Override
public MesSortShippingCheckModel saveSn(MesSortShippingCheckModel model) {
//校验发运单是否存在
MesShippingOrderManagement orderManagement = checkMesShippingOrderManagement(model);
@ -211,7 +237,9 @@ public class MesSortShippingCheckService implements IMesSortShippingCheckService
}else{
//自制件校验前道工艺 零件发运组详情中的优先
MesPartShippingGroupDetail groupDetail = mesPartShippingGroupService.getMesPartShippingGroupDetailByPartNo(organizeCode, shippingGroup.getShippingGroupCode(), produceSn.getPartNo());
if (null == groupDetail) return true;
if (null == groupDetail) {
return true;
}
if (!StringUtils.isEmpty(groupDetail.getFrontProcessCode())){
Integer count = mesProductionRecordService.findFrontProcessProductionRecord(organizeCode, produceSn.getProductSn(), groupDetail.getFrontProcessCode());
if (count > 0){
@ -237,6 +265,11 @@ public class MesSortShippingCheckService implements IMesSortShippingCheckService
MesProduceSn produceSn = checkMesProduceSn(model, organizeCode);
//校验发运单是否存在
MesShippingOrderManagement orderManagement = checkMesShippingOrderManagement(model);
final String confirmPartType = getConfirmPartType(orderManagement);
//成都的逻辑
if (Objects.equals(confirmPartType, String.valueOf(MesExtEnumUtil.SHIPPING_GROUP_CONFIRM_PART_TYPE.SHIPPING_GROUP_CONFIRM_PART_TYPE_50.getValue()))) {
return saveChengDuSnAndLocationCode(model, organizeCode, userInfo);
}
//根据条码找到对应的物料号若物料号一致则修改扫描flg将flg改为true.
boolean scanFlg = false;
for (MesShippingOrderManagementDetail detail : model.getDetailList()) {
@ -262,6 +295,77 @@ public class MesSortShippingCheckService implements IMesSortShippingCheckService
return model;
}
private MesSortShippingCheckModel saveChengDuSnAndLocationCode(MesSortShippingCheckModel model, String organizeCode, String userInfo) {
//校验条码
MesProduceSn produceSn = checkMesProduceSn(model, organizeCode);
//校验发运单是否存在
MesShippingOrderManagement orderManagement = checkMesShippingOrderManagement(model);
//根据条码找到对应的物料号若物料号一致则修改扫描flg将flg改为true.
boolean scanFlg = false;
for (MesShippingOrderManagementDetail detail : model.getDetailList()) {
if (detail.getPartNo().equals(produceSn.getPartNo()) && StringUtils.isEmpty(detail.getPartPosition())) {
scanFlg = true;
String tmpAfterBarCode = model.getLocationCode().replaceAll("\\p{Cc}", "");
String tmpMidStr = tmpAfterBarCode.replace("[)>061B", "");
String[] splitStrArray = tmpMidStr.split("1Y");
if (splitStrArray.length > 0) {
if (StringUtils.isEmpty(orderManagement.getRackNo()) || !orderManagement.getRackNo().contains(splitStrArray[0])) {
throw new ImppBusiException(String.format("料箱类型与顺序不一致,请检查数据"));
}
}
String detailPosition = detailPosition(model, detail);
String tmpPosition = tmpAfterBarCode.substring(tmpAfterBarCode.length() - 2);
StringBuilder splitPosition = new StringBuilder();
for (char c : tmpPosition.toCharArray()) {
if (Character.isDigit(c)) {
splitPosition.append(c);
}
}
//验证位置号
if (!detailPosition.contentEquals(splitPosition)) {
throw new ImppBusiException(String.format("零件与位置信息不符,请检查数据"));
}
detail.setIsScanFlg(MesCommonConstant.TRUE_INTEGER);
// detail.setBarcode(detail.getBarcode() + "," + model.getLocationCode());
detail.setPartPosition(model.getLocationCode());
// detail.setStatus(MesExtEnumUtil.SHIPPING_ORDER_STATUS.CREATE.getValue());
shippingOrderManagementDetailRepository.update(detail);
break;
}
}
if (!scanFlg) {
throw new ImppBusiException(String.format("【%s】此条码对应的【%s】物料号与发运单中物料号不匹配请检查数据", model.getSn(), produceSn.getPartNo()));
}
Long count = model.getDetailList().stream().filter(k -> Objects.equals(k.getIsScanFlg(), MesCommonConstant.TRUE_INTEGER)).count();
//当前发运单全部扫描完成
if (count.intValue() == model.getDetailList().size()) {
//保存数据库
saveDate(orderManagement, model, organizeCode, userInfo);
}
return model;
}
private String detailPosition(MesSortShippingCheckModel model, MesShippingOrderManagementDetail detail) {
MesWorkOrder workOrder = mesWorkOrderService.getWorkOrderNoByCustSn(model.getOrganizeCode(), model.getSn());
if (workOrder == null || StringUtils.isEmpty(workOrder.getWorkOrderSource())) {
return "";
}
MesCustSortInfo custSoftInfo = custSoftInfoRDao.getById(Long.parseLong(workOrder.getWorkOrderSource()));
if (custSoftInfo != null) {
MesCimVolvoJisRackIdDetail rackIdDetail = rackIdDetailRDao.getById(custSoftInfo.getSourceId());
if (rackIdDetail != null) {
detail.setVisualOrderNo(workOrder.getWorkOrderNo());
return rackIdDetail.getPosition();
}
}
return "";
}
@Override
public MesShippingOrderManagement queryShippingOrderNoByAutoPushOrder(String shippingGroupNo, String org) {
//查询最近扫描完成的装车单号
@ -275,7 +379,7 @@ public class MesSortShippingCheckService implements IMesSortShippingCheckService
private MesPartShippingGroup getMesPartShippingGroup(String org, String partShippingGroupCode) {
if(StringUtil.isEmpty(org) ||StringUtil.isEmpty(partShippingGroupCode)){
return null;
throw new ImppBusiException("零件发运组信息不存在,请检查数据!");
}
MesPartShippingGroup shippingGroup = mesPartShippingGroupService.getMesPartShippingGroup(org, partShippingGroupCode);
if(Objects.isNull(shippingGroup)){
@ -373,10 +477,22 @@ public class MesSortShippingCheckService implements IMesSortShippingCheckService
}
private List<MesShippingOrderManagementDetail> getMesShippingOrderManagementDetails(MesShippingOrderManagement orderManagement,MesPartShippingGroup mesPartShippingGroup) {
//45550 PDA-MES-PDA发运扫描排序方式修改
List<MesConfig> shippingBusiSoftCfgList = mesConfigService.getConfigList(orderManagement.getOrganizeCode(),
MesCommonConstant.SHIPPING_BUSI_SOFT_CFG, mesPartShippingGroup.getShippingGroupCode(), null);
DdlPackBean orderDetailPackBean = DdlPackBean.getDdlPackBean(orderManagement.getOrganizeCode());
DdlPreparedPack.getNumEqualPack(orderManagement.getId(), "pid", orderDetailPackBean);
DdlPreparedPack.getNumberSmallerPack(MesExtEnumUtil.SHIPPING_ORDER_DETAIL_SHIPPING_STATUS.CLOSE.getValue(),"status",orderDetailPackBean);
DdlPreparedPack.getOrderByPack(new Object[]{CommonEnumUtil.ASC_OR_DESC.ASC.getValue()}, new String[]{"custInfoSeq"}, orderDetailPackBean);
if (CollectionUtils.isEmpty(shippingBusiSoftCfgList)) {
DdlPreparedPack.getOrderByPack(new Object[]{CommonEnumUtil.ASC_OR_DESC.ASC.getValue()}, new String[]{"custInfoSeq"}, orderDetailPackBean);
}else {
MesConfig mesConfig = shippingBusiSoftCfgList.get(0);
if (!Objects.isNull(mesConfig) &&
!StringUtils.isEmpty(mesConfig.getCfgValue()) &&
"logic_seq".equals(mesConfig.getCfgValue())) {
DdlPreparedPack.getOrderByPack(new Object[]{CommonEnumUtil.ASC_OR_DESC.ASC.getValue()}, new String[]{"logicSeq"}, orderDetailPackBean);
}
}
List<MesShippingOrderManagementDetail> detailList = shippingOrderManagementDetailRepository.findByHqlWhere(orderDetailPackBean);
if(CollectionUtils.isEmpty(detailList)){
throw new ImppBusiException(String.format("发运单【%s】明细信息不存在请检查数据", orderManagement.getShippingCode()));
@ -466,10 +582,10 @@ public class MesSortShippingCheckService implements IMesSortShippingCheckService
private MesProduceSn checkMesProduceSn(MesSortShippingCheckModel model, String org) {
//校验条码是否已经扫描
Optional<MesShippingOrderManagementDetail> optional = model.getDetailList().stream().filter(k -> !StringUtils.isEmpty(k.getBarcode()) && k.getBarcode().equals(model.getSn())).findFirst();
if (optional.isPresent()) {
throw new ImppBusiException(String.format("【%s】此条码已经扫描过请检查数据", model.getSn()));
}
// Optional<MesShippingOrderManagementDetail> optional = model.getDetailList().stream().filter(k -> !StringUtils.isEmpty(k.getBarcode()) && k.getBarcode().equals(model.getSn())).findFirst();
// if (optional.isPresent()) {
// throw new ImppBusiException(String.format("【%s】此条码已经扫描过请检查数据", model.getSn()));
// }
DdlPackBean packBean = DdlPackBean.getDdlPackBean(org);
DdlPreparedPack.getStringEqualPack(model.getSn(), "productSn", packBean);
DdlPreparedPack.getOrderByPack(new Object[]{CommonEnumUtil.ASC_OR_DESC.DESC.getValue()}, new String[]{"createDatetime"}, packBean);
@ -497,6 +613,16 @@ public class MesSortShippingCheckService implements IMesSortShippingCheckService
}
}
// 判断维护的条码是否和扫描的条码一致
private void checkVolvoRack(MesSortShippingCheckModel model, String organizeCode) {
DdlPackBean rackPackBean = DdlPackBean.getDdlPackBean(model.getOrganizeCode());
DdlPreparedPack.getStringEqualPack(model.getVolvoRackNo(), "barCode", rackPackBean);
MesVolvoRack volvoRack = mesVolvoRackRDao.getByProperty(rackPackBean);
if (volvoRack == null) {
throw new ImppBusiException(String.format("无效料架条码【%s】请检查数据", model.getVolvoRackNo()));
}
}
private MesShippingOrderManagement checkMesShippingOrderManagement(MesSortShippingCheckModel model) {
//校验发运单是否存在
DdlPackBean orderManagementPackBean = DdlPackBean.getDdlPackBean(model.getOrganizeCode());
@ -514,24 +640,28 @@ public class MesSortShippingCheckService implements IMesSortShippingCheckService
orderManagement.getStatus() == MesExtEnumUtil.SHIPPING_ORDER_STATUS.PUBLISHED.getValue()) {
orderManagement.setStartScanTime(TimeTool.getNowTime(true));
}
//根据发运单查询装车单明细信息
DdlPackBean packBean = DdlPackBean.getDdlPackBean(orderManagement.getOrganizeCode());
DdlPreparedPack.getStringEqualPack(orderManagement.getShippingCode(),"shippingCode",packBean);
MesLoadingListDetail listDetail = listDetailRepository.getByProperty(packBean);
MesLoadingList loadingList = null;
if(!Objects.isNull(listDetail)){
packBean = DdlPackBean.getDdlPackBean(orderManagement.getOrganizeCode());
DdlPreparedPack.getNumEqualPack(listDetail.getPid(), "id", packBean);
loadingList = listRepository.getByProperty(packBean);
//反填装车单信息到发运单
if(!Objects.isNull(loadingList)){
orderManagement.setOrderCode(loadingList.getOrderCode());
orderManagement.setLoadingListId(loadingList.getId());
//零件发运组
MesPartShippingGroup shippingGroup = Objects.isNull(model.getMesPartShippingGroup()) ? getMesPartShippingGroup(orderManagement.getOrganizeCode(), orderManagement.getShippingGroupCode()) : model.getMesPartShippingGroup();
//根据发运单查询装车单明细信息
if (Objects.equals(shippingGroup.getIsFirstInstall(), CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue())) {
DdlPackBean packBean = DdlPackBean.getDdlPackBean(orderManagement.getOrganizeCode());
DdlPreparedPack.getStringEqualPack(orderManagement.getShippingCode(),"shippingCode",packBean);
MesLoadingListDetail listDetail = listDetailRepository.getByProperty(packBean);
if(!Objects.isNull(listDetail)){
packBean = DdlPackBean.getDdlPackBean(orderManagement.getOrganizeCode());
DdlPreparedPack.getNumEqualPack(listDetail.getPid(), "id", packBean);
loadingList = listRepository.getByProperty(packBean);
//反填装车单信息到发运单
if(!Objects.isNull(loadingList)){
orderManagement.setOrderCode(loadingList.getOrderCode());
orderManagement.setLoadingListId(loadingList.getId());
}
//更新装车单明细对应的发运单状态=发运
listDetail.setStatus(MesExtEnumUtil.LOADING_ORDER_DETAIL_SHIPPING_STATUS.SHIPPINGED.getValue());
ConvertBean.serviceModelUpdate(listDetail, userInfo);
listDetailRepository.update(listDetail);
}
//更新装车单明细对应的发运单状态=发运
listDetail.setStatus(MesExtEnumUtil.LOADING_ORDER_DETAIL_SHIPPING_STATUS.SHIPPINGED.getValue());
ConvertBean.serviceModelUpdate(listDetail, userInfo);
listDetailRepository.update(listDetail);
}
//发运单状态修改为校验完成
orderManagement.setSystemSyncStatus(CommonEnumUtil.FALSE);
@ -550,6 +680,7 @@ public class MesSortShippingCheckService implements IMesSortShippingCheckService
//查询条码信息
Map<String, List<MesProduceSn>> produceSnByCustSnMap = getProduceSnByCustSnMap(orderManagement.getIsEnableMemory(), organizeCode, detailList.stream().map(MesShippingOrderManagementDetail::getBarcode).filter(barCode -> !StringUtil.isEmptyAndNull(barCode)).collect(Collectors.toList()));
final String confirmPartType = getConfirmPartType(orderManagement);
List<MesProduceSn> produceSnList = new ArrayList<>();
List<String> workOrderNoList = new ArrayList<>();
List<MesShippingSnUnique> mesShippingSnUniqueList = new ArrayList<>();
@ -580,8 +711,14 @@ public class MesSortShippingCheckService implements IMesSortShippingCheckService
mesEmergencyLocationService.doShippingStockOutOnline(organizeCode, detail.getVisualOrderNo(), userInfo, true);
// 保存到发运队列,后续发运单的条码会拼接,而保存到发运队列中的为拼接前的数据,因此要在拼接前调用。
saveShippingQueue(orderManagement, detail, userInfo);
//条码格式(扫描目视单,扫描条码)
detail.setBarcode(new StringJoiner(MesPcnExtConstWords.COMMA).add(detail.getVisualOrderNo()).add(detail.getBarcode()).toString());
if (!Objects.equals(confirmPartType, String.valueOf(MesExtEnumUtil.SHIPPING_GROUP_CONFIRM_PART_TYPE.SHIPPING_GROUP_CONFIRM_PART_TYPE_40.getValue()))) {
if (Objects.equals(confirmPartType, String.valueOf(MesExtEnumUtil.SHIPPING_GROUP_CONFIRM_PART_TYPE.SHIPPING_GROUP_CONFIRM_PART_TYPE_50.getValue()))) {
detail.setBarcode(detail.getBarcode() + "," + detail.getPartPosition());
} else {
//条码格式(扫描目视单,扫描条码)
detail.setBarcode(new StringJoiner(MesPcnExtConstWords.COMMA).add(detail.getVisualOrderNo()).add(detail.getBarcode()).toString());
}
}
}
}
//客供品移库
@ -624,7 +761,9 @@ public class MesSortShippingCheckService implements IMesSortShippingCheckService
DdlPreparedPack.getNumEqualPack(orderManagement.getLoadingListId(),"pid",orderManagementPackBean);
DdlPreparedPack.getNumberSmallerEqualPack(MesExtEnumUtil.LOADING_ORDER_DETAIL_SHIPPING_STATUS.SKIP.getValue(),"status",orderManagementPackBean);
List<MesLoadingListDetail> listDetails = vehiclesOrderDetailRepository.findByHqlWhere(orderManagementPackBean);
if(CollectionUtils.isEmpty(listDetails)) return;
if(CollectionUtils.isEmpty(listDetails)) {
return;
}
List<String> shippingCodeList = listDetails.stream().map(MesLoadingListDetail::getShippingCode).collect(Collectors.toList());
orderManagementPackBean = DdlPackBean.getDdlPackBean(organizeCode);
@ -698,6 +837,7 @@ public class MesSortShippingCheckService implements IMesSortShippingCheckService
return rule;
}
@Override
public List<MesJisShipping> getMesJisShippings(MesShippingOrderManagement mesShippingOrderManagement,List<MesShippingOrderManagementDetail> shippingOrderManagementDetails,String userName) {
if (CollectionUtils.isEmpty(shippingOrderManagementDetails)) {
DdlPackBean detailPackBean = DdlPackBean.getDdlPackBean(mesShippingOrderManagement.getOrganizeCode());
@ -722,7 +862,9 @@ public class MesSortShippingCheckService implements IMesSortShippingCheckService
}
private void updateShippingOrderDetails(String organizeCode, String userName, long id) {
if(StringUtils.isEmpty(id) || StringUtils.isEmpty(organizeCode)) return;
if(StringUtils.isEmpty(id) || StringUtils.isEmpty(organizeCode)) {
return;
}
DdlPackBean packBean = DdlPackBean.getDdlPackBean(organizeCode);
DdlPreparedPack.getNumEqualPack(id, "pid",packBean);
shippingOrderManagementDetailRepository.updateByProperties(new String[]{"modifyUser", "modifyDatetime", "status","remark"},
@ -841,4 +983,16 @@ public class MesSortShippingCheckService implements IMesSortShippingCheckService
ConvertBean.serviceModelInitialize(move, userName);
moveRepository.insert(move);
}
private String getConfirmPartType(MesShippingOrderManagement orderManagement) {
if (StringUtils.isEmpty(orderManagement.getShippingGroupCode())) {
return "";
}
MesPartShippingGroup shippingGroup = mesPartShippingGroupService.getMesPartShippingGroup(orderManagement.getOrganizeCode(), orderManagement.getShippingGroupCode());
if (shippingGroup == null) {
return "";
}
return shippingGroup.getConfirmPartType();
}
}

@ -1292,15 +1292,12 @@ public class MesWorkOrderService implements IMesWorkOrderService {
}
@Override
public List<MesWorkOrder> insertMesWorkOrder(List<MesProductionRecord> mesProductionRecordList, List<MesShift> mesShiftList, String organizeCode, String userName) {
List<MesWorkOrder> mesWorkOrderList = new ArrayList<>();
Map<String, List<MesProductionRecord>> mesProductionRecordListMap = mesProductionRecordList.stream().collect(Collectors.groupingBy(sn -> sn.getWorkCenterCode() + "=" + sn.getPartNo()));
for (Map.Entry<String, List<MesProductionRecord>> stringListEntry : mesProductionRecordListMap.entrySet()) {
List<MesProductionRecord> value = stringListEntry.getValue();
MesProductionRecord mesProductionRecord = value.get(0);
String[] split = stringListEntry.getKey().split("=");
String workCenterCode = split[0];
String partNo = split[1];
public MesWorkOrder insertMesWorkOrder(List<MesProductionRecord> mesProductionRecordList, List<MesShift> mesShiftList, String organizeCode, String userName) {
MesProductionRecord mesProductionRecord = mesProductionRecordList.get(0);
String workCenterCode = mesProductionRecord.getWorkCenterCode();
String partNo = mesProductionRecord.getPartNo();
//查询工作中心
DdlPackBean ddlPackBean = DdlPackBean.getDdlPackBean(organizeCode);
DdlPreparedPack.getStringEqualPack(workCenterCode, "workCenterCode", ddlPackBean);
@ -1344,7 +1341,7 @@ public class MesWorkOrderService implements IMesWorkOrderService {
item.setProduceTime(TimeTool.getToday());
item.setProductTime(item.getProduceTime());
item.setUnCompleteQty(0d);
item.setQty(value.stream().mapToDouble(MesProductionRecord::getQty).sum());
item.setQty(mesProductionRecordList.stream().mapToDouble(MesProductionRecord::getQty).sum());
item.setCompleteQty(item.getQty());
item.setReportedQty(item.getQty());
item.setWorkOrderStatus(MesExtEnumUtil.ORDER_STATUS.COMPLETE.getValue());
@ -1362,13 +1359,13 @@ public class MesWorkOrderService implements IMesWorkOrderService {
//校验物料生产版本是否存在
MesProductVersion mesProductVersion = checkMesProductVersion(item);
if (Objects.isNull(mesProductVersion)) {
continue;
return null;
}
item.setProductVersion(mesProductVersion.getProductVersion());
//获取bom信息
List<MesBom> bomList = findMesBomByPartNoAndBomVersion(item.getPartNo(), item.getOrganizeCode(), mesProductVersion.getAlternativePartList());
if (org.springframework.util.CollectionUtils.isEmpty(bomList)) {
continue;
return null;
}
}
@ -1377,10 +1374,8 @@ public class MesWorkOrderService implements IMesWorkOrderService {
ConvertBean.serviceModelInitialize(item, userName);
MesWorkOrder mesWorkOrder = workOrderRepository.insert(item);
saveMesWorkOrderLog(mesWorkOrder,MesExtEnumUtil.WORK_ORDER_LOG_TYPE.INSERT.getValue(),item.getQty());
mesWorkOrderList.add(mesWorkOrder);
}
return mesWorkOrderList;
return mesWorkOrder;
}
private MesProductVersion checkMesProductVersion(MesWorkOrder item) {

@ -15,6 +15,7 @@ import cn.estsh.i3plus.pojo.mes.bean.*;
import cn.estsh.i3plus.pojo.mes.repository.*;
import cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil;
import cn.estsh.impp.framework.boot.util.SpringContextsUtil;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -176,7 +177,7 @@ public class WorkOrderAssemblyPrintQueueStrategyService implements IPrintQueueSt
IPrintTemplateStrategyService strategyService = (IPrintTemplateStrategyService) SpringContextsUtil.getBean(labelTemplate.getMethodCode());
snPrintModel = strategyService.execute(null, mesProduceSnPrintModel, null, null, null ,false);
} catch (Exception e) {
log.info("打印队列查询 --- {} --- {} 执行异常! --- {} ---", MesExtEnumUtil.PRINT_QUEUE_TYPE.valueOfDescription(model.getPrintQueueType()), labelTemplate.getMethodCode(), e.toString());
log.info("打印队列查询 --- {} --- {} 执行异常! --- {} ---", MesExtEnumUtil.PRINT_QUEUE_TYPE.valueOfDescription(model.getPrintQueueType()), labelTemplate.getMethodCode(), JSONObject.toJSONString(e));
printQueue.setRemark(String.format("模板代码[%s]方法类[%s]执行异常!", labelTemplate.getTemplateCode(), labelTemplate.getMethodCode()));
printQueue.setPrintStatus(MesExtEnumUtil.PRINT_STATUS.FAILURE.getValue());
printQueue.setSystemSyncStatus(CommonEnumUtil.FALSE);

@ -1,9 +1,6 @@
package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.busi.shippingscan.strategy;
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesCustomerSnTransformService;
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesEmergencyLocationService;
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesProduceSnExtService;
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesWorkOrderExtService;
import cn.estsh.i3plus.ext.mes.pcn.api.busi.*;
import cn.estsh.i3plus.ext.mes.pcn.apiservice.aspect.MonitorLog;
import cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.busi.shippingscan.IMesShippingScanStrategyService;
import cn.estsh.i3plus.ext.mes.pcn.pojo.constant.MesCommonConstant;
@ -14,6 +11,7 @@ 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.MesConfig;
import cn.estsh.i3plus.pojo.mes.bean.MesPartShippingGroup;
import cn.estsh.i3plus.pojo.mes.bean.MesProduceSn;
import cn.estsh.i3plus.pojo.mes.bean.MesWorkOrder;
@ -28,12 +26,10 @@ import cn.estsh.impp.framework.boot.exception.ImppBusiException;
import groovy.util.logging.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.Comparator;
import java.util.Objects;
import java.util.Optional;
import java.util.StringJoiner;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@ -71,6 +67,9 @@ public class MesShippingScanSnAndOrderStrategyServiceImpl implements IMesShippin
@Autowired
private IMesCustomerSnTransformService mesCustomerSnTransformService;
@Autowired
private IMesConfigService mesConfigService;
@Override
public MesSortShippingCheckModel doScan(MesSortShippingCheckModel model, MesShippingOrderManagement orderManagement, MesPartShippingGroup shippingGroup) {
final String barcode = mesCustomerSnTransformService.transformBarCodeGm(model.getSn());
@ -169,9 +168,29 @@ public class MesShippingScanSnAndOrderStrategyServiceImpl implements IMesShippin
private void checkShippingDetails(MesSortShippingCheckModel model, MesShippingOrderManagement orderManagement, MesPartShippingGroup shippingGroup, String partNo, MesShippingOrderManagementDetail detail) {
//校验发运单明细顺序
if (!Objects.isNull(shippingGroup) && !StringUtils.isEmpty(shippingGroup.getIsEnableShippingFailSafe()) && CommonEnumUtil.VALID == shippingGroup.getIsEnableShippingFailSafe()) {
Optional<MesShippingOrderManagementDetail> first = model.getDetailList().stream().filter(k -> k.getCustInfoSeq().compareTo(detail.getCustInfoSeq()) < 0 && !Objects.equals(k.getIsScanFlg(), MesCommonConstant.TRUE_INTEGER)).findFirst();
if (first.isPresent()) {
throw new ImppBusiException(String.format("发运单【%s】启用明细顺序防错序号【%s】前还有未扫描的发运单明细请检查数据", orderManagement.getShippingCode(), detail.getCustInfoSeq()));
//45550 PDA-MES-PDA发运扫描排序方式修改
List<MesConfig> shippingBusiSoftCfgList = mesConfigService.getConfigList(orderManagement.getOrganizeCode(),
MesCommonConstant.SHIPPING_BUSI_SOFT_CFG, shippingGroup.getShippingGroupCode(), null);
if (CollectionUtils.isEmpty(shippingBusiSoftCfgList)) {
Optional<MesShippingOrderManagementDetail> first = model.getDetailList().stream().filter(k -> k.getCustInfoSeq().compareTo(detail.getCustInfoSeq()) < 0 && !Objects.equals(k.getIsScanFlg(), MesCommonConstant.TRUE_INTEGER)).findFirst();
if (first.isPresent()) {
throw new ImppBusiException(String.format("发运单【%s】启用明细顺序防错序号【%s】前还有未扫描的发运单明细请检查数据", orderManagement.getShippingCode(), detail.getCustInfoSeq()));
}
}else {
MesConfig mesConfig = shippingBusiSoftCfgList.get(0);
if (!Objects.isNull(mesConfig) &&
!StringUtils.isEmpty(mesConfig.getCfgValue()) &&
"logic_seq".equals(mesConfig.getCfgValue())) {
Optional<MesShippingOrderManagementDetail> first = model.getDetailList().stream().filter(k -> k.getLogicSeq().compareTo(detail.getLogicSeq()) < 0 && !Objects.equals(k.getIsScanFlg(), MesCommonConstant.TRUE_INTEGER)).findFirst();
if (first.isPresent()) {
throw new ImppBusiException(String.format("发运单【%s】启用明细顺序防错序号【%s】前还有未扫描的发运单明细请检查数据", orderManagement.getShippingCode(), detail.getLogicSeq()));
}
}else {
Optional<MesShippingOrderManagementDetail> first = model.getDetailList().stream().filter(k -> k.getCustInfoSeq().compareTo(detail.getCustInfoSeq()) < 0 && !Objects.equals(k.getIsScanFlg(), MesCommonConstant.TRUE_INTEGER)).findFirst();
if (first.isPresent()) {
throw new ImppBusiException(String.format("发运单【%s】启用明细顺序防错序号【%s】前还有未扫描的发运单明细请检查数据", orderManagement.getShippingCode(), detail.getCustInfoSeq()));
}
}
}
}
//判断是否需要排序校验 默认排序则需要校验

@ -13,6 +13,7 @@ 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.base.util.StringUtil;
import cn.estsh.i3plus.pojo.mes.bean.MesConfig;
import cn.estsh.i3plus.pojo.mes.bean.MesPartShippingGroup;
import cn.estsh.i3plus.pojo.mes.bean.MesPartShippingGroupDetail;
import cn.estsh.i3plus.pojo.mes.bean.MesProduceSn;
@ -28,6 +29,7 @@ import cn.estsh.impp.framework.boot.util.SpringContextsUtil;
import groovy.util.logging.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.Comparator;
@ -97,9 +99,29 @@ public class MesShippingScanSnStrategyServiceImpl implements IMesShippingScanStr
//校验发运单明细顺序
if (!Objects.isNull(shippingGroup) && !StringUtils.isEmpty(shippingGroup.getIsEnableShippingFailSafe()) && CommonEnumUtil.VALID == shippingGroup.getIsEnableShippingFailSafe()) {
Optional<MesShippingOrderManagementDetail> first = model.getDetailList().stream().filter(k -> k.getCustInfoSeq().compareTo(detail.getCustInfoSeq()) < 0 && !Objects.equals(k.getIsScanFlg(), MesCommonConstant.TRUE_INTEGER)).findFirst();
if (first.isPresent()) {
throw new ImppBusiException(String.format("发运单【%s】启用明细顺序防错序号【%s】前还有未扫描的发运单明细请检查数据", orderManagement.getShippingCode(), detail.getCustInfoSeq()));
//45550 PDA-MES-PDA发运扫描排序方式修改
List<MesConfig> shippingBusiSoftCfgList = mesConfigService.getConfigList(orderManagement.getOrganizeCode(),
MesCommonConstant.SHIPPING_BUSI_SOFT_CFG, shippingGroup.getShippingGroupCode(), null);
if (CollectionUtils.isEmpty(shippingBusiSoftCfgList)) {
Optional<MesShippingOrderManagementDetail> first = model.getDetailList().stream().filter(k -> k.getCustInfoSeq().compareTo(detail.getCustInfoSeq()) < 0 && !Objects.equals(k.getIsScanFlg(), MesCommonConstant.TRUE_INTEGER)).findFirst();
if (first.isPresent()) {
throw new ImppBusiException(String.format("发运单【%s】启用明细顺序防错序号【%s】前还有未扫描的发运单明细请检查数据", orderManagement.getShippingCode(), detail.getCustInfoSeq()));
}
}else {
MesConfig mesConfig = shippingBusiSoftCfgList.get(0);
if (!Objects.isNull(mesConfig) &&
!StringUtils.isEmpty(mesConfig.getCfgValue()) &&
"logic_seq".equals(mesConfig.getCfgValue())) {
Optional<MesShippingOrderManagementDetail> first = model.getDetailList().stream().filter(k -> k.getLogicSeq().compareTo(detail.getLogicSeq()) < 0 && !Objects.equals(k.getIsScanFlg(), MesCommonConstant.TRUE_INTEGER)).findFirst();
if (first.isPresent()) {
throw new ImppBusiException(String.format("发运单【%s】启用明细顺序防错序号【%s】前还有未扫描的发运单明细请检查数据", orderManagement.getShippingCode(), detail.getLogicSeq()));
}
}else {
Optional<MesShippingOrderManagementDetail> first = model.getDetailList().stream().filter(k -> k.getCustInfoSeq().compareTo(detail.getCustInfoSeq()) < 0 && !Objects.equals(k.getIsScanFlg(), MesCommonConstant.TRUE_INTEGER)).findFirst();
if (first.isPresent()) {
throw new ImppBusiException(String.format("发运单【%s】启用明细顺序防错序号【%s】前还有未扫描的发运单明细请检查数据", orderManagement.getShippingCode(), detail.getCustInfoSeq()));
}
}
}
}
//判断是否需要排序校验 默认排序则需要校验

@ -0,0 +1,309 @@
package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.busi.shippingscan.strategy;
import cn.estsh.i3plus.ext.mes.pcn.api.busi.*;
import cn.estsh.i3plus.ext.mes.pcn.apiservice.aspect.MonitorLog;
import cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.busi.shippingscan.IMesShippingScanStrategyService;
import cn.estsh.i3plus.ext.mes.pcn.apiservice.util.MesPcnException;
import cn.estsh.i3plus.ext.mes.pcn.pojo.constant.MesCommonConstant;
import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesSortShippingCheckModel;
import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtConstWords;
import cn.estsh.i3plus.platform.common.convert.ConvertBean;
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.base.util.StringUtil;
import cn.estsh.i3plus.pojo.mes.bean.MesPartShippingGroup;
import cn.estsh.i3plus.pojo.mes.bean.MesPartShippingGroupDetail;
import cn.estsh.i3plus.pojo.mes.bean.MesProduceSn;
import cn.estsh.i3plus.pojo.mes.bean.MesWorkOrder;
import cn.estsh.i3plus.pojo.mes.bean.edi.cd.MesCimVolvoJisRackIdDetail;
import cn.estsh.i3plus.pojo.mes.bean.shipping.MesCustSortInfo;
import cn.estsh.i3plus.pojo.mes.bean.shipping.MesShippingOrderManagement;
import cn.estsh.i3plus.pojo.mes.bean.shipping.MesShippingOrderManagementDetail;
import cn.estsh.i3plus.pojo.mes.repository.*;
import cn.estsh.i3plus.pojo.mes.repository.edi.cd.MesCimVolvoJisRackIdDetailRepository;
import cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil;
import cn.estsh.impp.framework.boot.exception.ImppBusiException;
import cn.estsh.impp.framework.boot.util.SpringContextsUtil;
import groovy.util.logging.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.stream.Collectors;
import java.util.stream.Stream;
/**
* @Description :
* @Reference :
* @Author : junsheng.li
* @CreateDate 2024/9/25 10:54
* @Modify:
**/
@Service
@Slf4j
public class mesShippingCheckVolvoRackNoAndPartNoStrategyServiceImpl implements IMesShippingScanStrategyService {
@Autowired
private MesShippingOrderManagementRepository shippingOrderManagementRepository;
@Autowired
private MesShippingOrderManagementDetailRepository shippingOrderManagementDetailRepository;
@Autowired
private MesProduceSnRepository produceSnRepository;
@Autowired
private IMesProduceSnExtService produceSnExtService;
@Autowired
private MesCustomerPartRepository mesCustomerPartRepository;
@Autowired
private IMesConfigService mesConfigService;
@Autowired
private IMesPartShippingGroupService mesPartShippingGroupService;
@Autowired
private IMesShippingSnUniqueService mesShippingSnUniqueService;
@Autowired
private MesWorkOrderRepository workOrderRDao;
@Autowired
private MesCustSoftInfoRepository custSoftInfoRDao;
@Autowired
private MesCimVolvoJisRackIdDetailRepository rackIdDetailRDao;
@Override
public MesSortShippingCheckModel doScan(MesSortShippingCheckModel model, MesShippingOrderManagement orderManagement, MesPartShippingGroup shippingGroup) {
//校验条码
MesProduceSn produceSn = checkSn(model);
MesWorkOrder workOrder = checkWorkOrder(model);
if (!Objects.equals(workOrder.getPartNo(), produceSn.getPartNo())) {
throw new ImppBusiException(String.format("产品条码物料【%s】与工单物料【%s】不一致请检查数据", produceSn.getPartNo(), workOrder.getPartNo()));
}
boolean scanFlg = false;
for (MesShippingOrderManagementDetail detail : model.getDetailList()) {
if (detail.getPartNo().equals(produceSn.getPartNo()) && StringUtils.isEmpty(detail.getBarcode()) && !Objects.equals(detail.getIsScanFlg(), MesCommonConstant.TRUE_INTEGER)) {
if (Objects.equals(detail.getVin(), workOrder.getVinCode())) {
throw new ImppBusiException(String.format("产品条码明细【%s】与发运单明细不匹配请重新扫描", model.getSn()));
}
checkDetailScanSeq(orderManagement, detail, workOrder);
//校验发运明细
checkShippingDetails(model, orderManagement, shippingGroup, produceSn, detail);
scanFlg = true;
//明细更新
updateOrderManagementDetails(produceSn, orderManagement, detail, workOrder, model.getUserInfo());
break;
}
}
if (!scanFlg) {
throw new ImppBusiException(String.format("【%s】此条码对应的【%s】物料号与发运单中物料号不匹配请检查数据", model.getSn(), produceSn.getPartNo()));
}
model.setMsg(String.format("条码【%s】扫描完成请扫描下一个条码", model.getSn()));
return model;
}
private void checkDetailScanSeq(MesShippingOrderManagement orderManagement, MesShippingOrderManagementDetail detail, MesWorkOrder workOrder) {
if (StringUtils.isEmpty(workOrder.getWorkOrderSource())) {
throw new ImppBusiException(String.format("工单【%s】缺少来源", workOrder.getWorkOrderNo()));
}
MesCustSortInfo custSoftInfo = custSoftInfoRDao.getById(Long.parseLong(workOrder.getWorkOrderSource()));
if (custSoftInfo == null || !Objects.equals(detail.getCustInfoSeq(), custSoftInfo.getCustInfoSeq())) {
throw new ImppBusiException(String.format("发运单【%s】启用明细顺序防错序号【%s】前还有未扫描的发运单明细请检查数据", orderManagement.getShippingCode(), custSoftInfo.getCustInfoSeq()));
}
}
private void checkShippingDetails(MesSortShippingCheckModel model, MesShippingOrderManagement orderManagement, MesPartShippingGroup shippingGroup, MesProduceSn produceSn, MesShippingOrderManagementDetail detail) {
//校验发运单明细顺序
if (!Objects.isNull(shippingGroup) && !StringUtils.isEmpty(shippingGroup.getIsEnableShippingFailSafe()) && CommonEnumUtil.VALID == shippingGroup.getIsEnableShippingFailSafe()) {
Optional<MesShippingOrderManagementDetail> first = model.getDetailList().stream().filter(k -> k.getCustInfoSeq().compareTo(detail.getCustInfoSeq()) < 0 && !Objects.equals(k.getIsScanFlg(), MesCommonConstant.TRUE_INTEGER)).findFirst();
if (first.isPresent()) {
throw new ImppBusiException(String.format("发运单【%s】启用明细顺序防错序号【%s】前还有未扫描的发运单明细请检查数据", orderManagement.getShippingCode(), detail.getCustInfoSeq()));
}
}
//判断是否需要排序校验 默认排序则需要校验
if (!StringUtils.isEmpty(orderManagement.getScanSeqWay()) && !Objects.isNull(MesExtEnumUtil.SHIPPING_GROUP_SCAN_CONFIRM_SEQ_MODE.valueOfDescription(orderManagement.getScanSeqWay()))) {
//按照页面显示顺序校验
Optional<MesShippingOrderManagementDetail> nextShippingDetail = model.getDetailList().stream().filter(k -> StringUtils.isEmpty(k.getBarcode()) && !Objects.equals(k.getIsScanFlg(), MesCommonConstant.TRUE_INTEGER)).findFirst();
if (nextShippingDetail.isPresent() && !StringUtils.isEmpty(nextShippingDetail.get().getPartTypeCode()) && !nextShippingDetail.get().getPartNo().equals(produceSn.getPartNo())) {
throw new ImppBusiException(String.format("【%s】此条码扫描顺序错误请检查数据", model.getSn()));
}
}
//校验客户零件信息是否存在 (默认需要验证, 值可能是[空/0/20])
if (StringUtils.isEmpty(shippingGroup.getScanMethodJudgment()) || !shippingGroup.getScanMethodJudgment().equals(MesExtEnumUtil.SHIPPING_GROUP_SCAN_METHOD_JUDGMENT.PART_NO.getValueStr())) {
DdlPackBean packBean = DdlPackBean.getDdlPackBean(model.getOrganizeCode());
DdlPreparedPack.getStringEqualPack(detail.getPartNo(), "erpPartNo", packBean);
DdlPreparedPack.getStringEqualPack(detail.getCustPartNo(), "custPartNo", packBean);
if (!mesCustomerPartRepository.isExitByHql(packBean)) {
throw new ImppBusiException(String.format("零件号【%s】客户零件号【%s】关系不存在请检查数据", detail.getPartNo(), detail.getCustPartNo()));
}
}
}
private MesWorkOrder checkWorkOrder(MesSortShippingCheckModel model) {
DdlPackBean packBean = DdlPackBean.getDdlPackBean(model.getOrganizeCode());
DdlPreparedPack.getStringEqualPack(model.getSn(), "custSn", packBean);
MesWorkOrder workOrder = workOrderRDao.getByProperty(packBean);
if (workOrder == null) {
throw new ImppBusiException(String.format("客户条码【%s】对应的工单号不存在请检查数据", model.getSn()));
}
if (workOrder.getWorkOrderStatus() == MesExtEnumUtil.ORDER_STATUS.SHIPPING.getValue()) {
throw new ImppBusiException(String.format("工单【%s】状态为已发运请检查数据", workOrder.getWorkOrderNo()));
}
if (workOrder.getWorkOrderStatus() == MesExtEnumUtil.ORDER_STATUS.RELEASE.getValue()) {
throw new ImppBusiException(String.format("工单【%s】状态为已发布请检查数据", workOrder.getWorkOrderNo()));
}
if (workOrder.getWorkOrderStatus() != MesExtEnumUtil.ORDER_STATUS.PROCESS.getValue() &&
workOrder.getWorkOrderStatus() != MesExtEnumUtil.ORDER_STATUS.COMPLETE.getValue() &&
workOrder.getWorkOrderStatus() != MesExtEnumUtil.ORDER_STATUS.DISMANTLE.getValue()) {
throw new ImppBusiException(String.format("工单【%s】状态为【%s】请检查数据", workOrder.getWorkOrderNo(), workOrder.getWorkOrderStatus()));
}
if (Objects.equals(workOrder.getOrderFlag(), MesExtEnumUtil.ORDER_TYPE_IDENTIFICATION.X.getValue())) {
throw new ImppBusiException(String.format("工单【%s】的工单标识为空单请检查数据", workOrder.getWorkOrderNo()));
}
return workOrder;
}
private MesProduceSn checkSn(MesSortShippingCheckModel model) {
//校验条码是否重复扫描 (不区分大小写)
Optional<MesShippingOrderManagementDetail> optional = model.getDetailList().stream().filter(k -> !StringUtils.isEmpty(k.getBarcode()) && k.getBarcode().equalsIgnoreCase(model.getSn())).findFirst();
if (optional.isPresent()) {
throw new ImppBusiException(String.format("【%s】此条码已经扫描过请检查数据", model.getSn()));
}
DdlPackBean packBean = DdlPackBean.getDdlPackBean(model.getOrganizeCode());
DdlPreparedPack.getStringEqualPack(model.getSn(), "productSn", packBean);
DdlPreparedPack.getOrderByPack(new Object[]{CommonEnumUtil.ASC_OR_DESC.DESC.getValue()}, new String[]{"createDatetime"}, packBean);
MesProduceSn produceSn = produceSnRepository.getByProperty(packBean);
if (!StringUtils.isEmpty(produceSn)) {
//校验状态
checkStatus(model, produceSn);
} else {
//外部条码解析
MesShippingOrderManagementDetail mesShippingOrderManagementDetail = getMesShippingOrderManagementDetail(model);
//封装信息
produceSn = new MesProduceSn();
produceSn.setSerialNumber(model.getSn());
produceSn.setProductSn(model.getSn());
produceSn.setPartNo(mesShippingOrderManagementDetail.getPartNo());
produceSn.setOrganizeCode(model.getOrganizeCode());
}
return produceSn;
}
private void checkStatus(MesSortShippingCheckModel model, MesProduceSn produceSn) {
//校验产品条码状态 必须是状态为已下线条码
if (produceSn.getSnStatus() != MesExtEnumUtil.PRODUCE_SN_STATUS.OFFLINE.getValue() && produceSn.getSnStatus() != MesExtEnumUtil.PRODUCE_SN_STATUS.CREATE.getValue()) {
throw new ImppBusiException(String.format("【%s】此条码状态为【%s】,请选择状态为【%s】或【%s】状态的条码请检查数据", model.getSn(), MesExtEnumUtil.PRODUCE_SN_STATUS.valueOfDescription(produceSn.getSnStatus()),
MesExtEnumUtil.PRODUCE_SN_STATUS.OFFLINE.getDescription(), MesExtEnumUtil.PRODUCE_SN_STATUS.CREATE.getDescription()));
}
//校验产品质量状态 必须是状态为合格条码
List<Integer> statusList = Stream.of(MesExtEnumUtil.PRODUCE_QC_STATUS.QUALIFIED.getValue(), MesExtEnumUtil.PRODUCE_QC_STATUS.SUSPICIOUS_TO_QUALIFIED.getValue()).collect(Collectors.toList());
if (!statusList.contains(produceSn.getQcStatus())){
throw new ImppBusiException(String.format("【%s】此条码质量状态为【%s】,请选择【%s】状态的条码请检查数据", model.getSn(), MesExtEnumUtil.PRODUCE_QC_STATUS.valueOfDescription(produceSn.getQcStatus()),
MesExtEnumUtil.PRODUCE_QC_STATUS.QUALIFIED.getDescription()));
}
}
private MesShippingOrderManagementDetail getMesShippingOrderManagementDetail(MesSortShippingCheckModel model) {
//外部解析条码长度卡控
String cfgValue = mesConfigService.getCfgValue(model.getOrganizeCode(), MesPcnExtConstWords.MAX_SHIPPING_BARCODE_LENGTH);
if (Integer.parseInt(cfgValue) < model.getSn().length()) {
MesPcnException.throwMesBusiException("【%s】此条码长度超过【%s】位请检查数据", model.getSn(), cfgValue);
}
//唯一性校验
if (mesShippingSnUniqueService.checkMesShippingSnUnique(model.getOrganizeCode(),model.getSn())) {
throw new ImppBusiException(String.format("【%s】条码唯一性校验数据已存在请检查数据", model.getSn()));
}
//发运组代码不存在
if (Objects.isNull(model.getMesPartShippingGroup())) {
MesPcnException.throwMesBusiException("发运组信息不存在,请检查数据!");
}
List<MesShippingOrderManagementDetail> detailList = model.getDetailList().stream().filter(k -> !StringUtils.isEmpty(k.getCustPartNo()) && StringUtils.isEmpty(k.getBarcode()) && !Objects.equals(k.getIsScanFlg(), MesCommonConstant.TRUE_INTEGER)).collect(Collectors.toList());
MesShippingOrderManagementDetail mesShippingOrderManagementDetail = null;
for (MesShippingOrderManagementDetail managementDetail : detailList) {
DdlPackBean packBean = DdlPackBean.getDdlPackBean(model.getOrganizeCode());
DdlPreparedPack.getStringEqualPack(managementDetail.getPartNo(), "erpPartNo", packBean);
DdlPreparedPack.getStringEqualPack(managementDetail.getCustPartNo(), "custPartNo", packBean);
if (checkMesPartShippingGroupDetailRule(model, managementDetail) && mesCustomerPartRepository.isExitByHql(packBean)) {
mesShippingOrderManagementDetail = managementDetail;
break;
}
}
if (Objects.isNull(mesShippingOrderManagementDetail)) {
throw new ImppBusiException(String.format("【%s】此条码未匹配到数据请检查数据", model.getSn()));
}
return mesShippingOrderManagementDetail;
}
private void updateOrderManagementDetails(MesProduceSn produceSn, MesShippingOrderManagement orderManagement, MesShippingOrderManagementDetail detail, MesWorkOrder workOrder, String userInfo) {
// if (StringUtils.isEmpty(orderManagement.getCheckSeqCode())) {
detail.setBarcode(produceSn.getProductSn());
detail.setIsScanFlg(MesCommonConstant.TRUE_INTEGER);
detail.setStatus(MesExtEnumUtil.SHIPPING_ORDER_DETAIL_SHIPPING_STATUS.SHIPPINGED.getValue());
detail.setRemark("扫描完成");
updateDetail(detail);
orderManagement.setCheckSeqCode("1");
update(orderManagement);
// MesCustSortInfo custSoftInfo = custSoftInfoRDao.getById(Long.parseLong(workOrder.getWorkOrderSource()));
// if (custSoftInfo != null) {
// MesCimVolvoJisRackIdDetail rackIdDetail = rackIdDetailRDao.getById(custSoftInfo.getSourceId());
// if (rackIdDetail != null) {
// detail.setPartPosition(rackIdDetail.getPosition());
// }
// }
//根据是否启动记忆判断 若启用记忆,则根据保存数据库
if (!StringUtils.isEmpty(orderManagement.getIsEnableMemory()) && Objects.equals(orderManagement.getIsEnableMemory(), MesCommonConstant.TRUE_INTEGER)) {
//若发运单状态为创建或发布 则写入开始扫描时间
if (!StringUtils.isEmpty(orderManagement.getStatus()) && (orderManagement.getStatus() == MesExtEnumUtil.SHIPPING_ORDER_STATUS.CREATE.getValue() ||
orderManagement.getStatus() == MesExtEnumUtil.SHIPPING_ORDER_STATUS.PUBLISHED.getValue())) {
orderManagement.setStartScanTime(TimeTool.getNowTime(true));
}
orderManagement.setStatus(MesExtEnumUtil.SHIPPING_ORDER_STATUS.SHIPPING.getValue());
orderManagement.setSystemSyncStatus(CommonEnumUtil.FALSE);
ConvertBean.serviceModelUpdate(orderManagement, userInfo);
update(orderManagement);
detail.setActualQty(1);
detail.setSystemSyncStatus(CommonEnumUtil.FALSE);
detail.setVisualOrderNo(workOrder.getWorkOrderNo());
ConvertBean.serviceModelUpdate(detail, userInfo);
updateDetail(detail);
//内部条码更新条码状态
if (!Objects.isNull(produceSn.getId())) {
produceSn.setSnStatus(MesExtEnumUtil.PRODUCE_SN_STATUS.SHIPPED.getValue());
produceSn.setSystemSyncStatus(CommonEnumUtil.FALSE);
ConvertBean.serviceModelUpdate(produceSn, userInfo);
produceSnExtService.update(produceSn);
}else{
//记录唯一性校验表
mesShippingSnUniqueService.insertMesShippingSnUnique(orderManagement.getOrganizeCode(),detail.getBarcode(),orderManagement.getShippingCode(),userInfo);
}
}
// }
}
@MonitorLog
public void update(MesShippingOrderManagement item) {
shippingOrderManagementRepository.update(item);
}
@MonitorLog
public void updateDetail(MesShippingOrderManagementDetail item) {
shippingOrderManagementDetailRepository.update(item);
}
private Boolean checkMesPartShippingGroupDetailRule(MesSortShippingCheckModel model, MesShippingOrderManagementDetail managementDetail) {
MesPartShippingGroupDetail mesPartShippingGroupDetail = mesPartShippingGroupService.getMesPartShippingGroupDetail(model.getOrganizeCode(), model.getMesPartShippingGroup().getShippingGroupCode(), managementDetail.getPartNo(), managementDetail.getCustPartNo());
return !Objects.isNull(mesPartShippingGroupDetail) && !StringUtil.isEmpty(mesPartShippingGroupDetail.getSnRule()) && ((Boolean) ((IMesNumberRuleMatchDispatchService) SpringContextsUtil.getBean(MesExtEnumUtil.ASSEMBLY_MATCH_TYPE.MATCH_TYPE_20.getStrategyClass())).matchNumberRule(model.getOrganizeCode(), model.getSn(), mesPartShippingGroupDetail.getSnRule(), mesPartShippingGroupDetail.getSnRule()).get(MesPcnExtConstWords.RESULT));
}
}

@ -0,0 +1,282 @@
package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.busi.shippingscan.strategy;
import cn.estsh.i3plus.ext.mes.pcn.api.busi.*;
import cn.estsh.i3plus.ext.mes.pcn.apiservice.aspect.MonitorLog;
import cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.busi.shippingscan.IMesShippingScanStrategyService;
import cn.estsh.i3plus.ext.mes.pcn.apiservice.util.MesPcnException;
import cn.estsh.i3plus.ext.mes.pcn.pojo.constant.MesCommonConstant;
import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesSortShippingCheckModel;
import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtConstWords;
import cn.estsh.i3plus.platform.common.convert.ConvertBean;
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.base.util.StringUtil;
import cn.estsh.i3plus.pojo.mes.bean.*;
import cn.estsh.i3plus.pojo.mes.bean.shipping.MesShippingOrderManagement;
import cn.estsh.i3plus.pojo.mes.bean.shipping.MesShippingOrderManagementDetail;
import cn.estsh.i3plus.pojo.mes.repository.MesCustomerPartRepository;
import cn.estsh.i3plus.pojo.mes.repository.MesProduceSnRepository;
import cn.estsh.i3plus.pojo.mes.repository.MesShippingOrderManagementDetailRepository;
import cn.estsh.i3plus.pojo.mes.repository.MesShippingOrderManagementRepository;
import cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil;
import cn.estsh.impp.framework.boot.exception.ImppBusiException;
import cn.estsh.impp.framework.boot.util.SpringContextsUtil;
import groovy.util.logging.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.Objects;
import java.util.Optional;
import java.util.stream.Collectors;
import java.util.stream.Stream;
/**
* @Description :
* @Reference :
* @Author : jason.niu
* @CreateDate 2025/3/11 10:54
* @Modify:
**/
@Service
@Slf4j
public class mesShippingScanOrderStrategyServiceImpl implements IMesShippingScanStrategyService {
@Autowired
private MesShippingOrderManagementRepository shippingOrderManagementRepository;
@Autowired
private MesShippingOrderManagementDetailRepository shippingOrderManagementDetailRepository;
@Autowired
private MesProduceSnRepository produceSnRepository;
@Autowired
private IMesProduceSnExtService produceSnExtService;
@Autowired
private MesCustomerPartRepository mesCustomerPartRepository;
@Autowired
private IMesConfigService mesConfigService;
@Autowired
private IMesPartShippingGroupService mesPartShippingGroupService;
@Autowired
private IMesShippingSnUniqueService mesShippingSnUniqueService;
@Autowired
private IMesWorkOrderService mesWorkOrderService;
@Override
public MesSortShippingCheckModel doScan(MesSortShippingCheckModel model, MesShippingOrderManagement orderManagement, MesPartShippingGroup shippingGroup) {
//校验条码
MesProduceSn produceSn = checkSn(model);
MesWorkOrder workOrder = mesWorkOrderService.getWorkOrderNoByCustSn(model.getOrganizeCode(), model.getSn());
boolean bMatchWorkOrder = false;
for (MesShippingOrderManagementDetail detail : model.getDetailList()) {
if (workOrder != null && Objects.equals(workOrder.getCustPartNo(), detail.getCustPartNo())) {
bMatchWorkOrder = true;
break;
}
}
if (!bMatchWorkOrder) {
throw new ImppBusiException(String.format("发运单明细对应的客户零件号与此客户条码【%s】工单中的客户零件号不匹配请检查数据", model.getSn()));
}
boolean scanFlg = false;
for (MesShippingOrderManagementDetail detail : model.getDetailList()) {
if (detail.getPartNo().equals(produceSn.getPartNo()) && StringUtils.isEmpty(detail.getBarcode()) && !Objects.equals(detail.getIsScanFlg(), MesCommonConstant.TRUE_INTEGER)) {
//校验发运明细
checkShippingDetails(model, orderManagement, shippingGroup, produceSn, detail);
scanFlg = true;
//明细更新
updateOrderManagementDetails(produceSn, orderManagement, detail, workOrder, model.getUserInfo());
break;
}
}
if (!scanFlg) {
throw new ImppBusiException(String.format("【%s】此条码对应的【%s】物料号与发运单中物料号不匹配请检查数据", model.getSn(), produceSn.getPartNo()));
}
model.setMsg(String.format("条码【%s】扫描完成请扫描下一个条码", model.getSn()));
return model;
}
private void checkShippingDetails(MesSortShippingCheckModel model, MesShippingOrderManagement orderManagement, MesPartShippingGroup shippingGroup, MesProduceSn produceSn, MesShippingOrderManagementDetail detail) {
//校验发运单明细顺序
if (!Objects.isNull(shippingGroup) && !StringUtils.isEmpty(shippingGroup.getIsEnableShippingFailSafe()) && CommonEnumUtil.VALID == shippingGroup.getIsEnableShippingFailSafe()) {
//45550 PDA-MES-PDA发运扫描排序方式修改
List<MesConfig> shippingBusiSoftCfgList = mesConfigService.getConfigList(orderManagement.getOrganizeCode(),
MesCommonConstant.SHIPPING_BUSI_SOFT_CFG, shippingGroup.getShippingGroupCode(), null);
if (CollectionUtils.isEmpty(shippingBusiSoftCfgList)) {
Optional<MesShippingOrderManagementDetail> first = model.getDetailList().stream().filter(k -> k.getCustInfoSeq().compareTo(detail.getCustInfoSeq()) < 0 && !Objects.equals(k.getIsScanFlg(), MesCommonConstant.TRUE_INTEGER)).findFirst();
if (first.isPresent()) {
throw new ImppBusiException(String.format("发运单【%s】启用明细顺序防错序号【%s】前还有未扫描的发运单明细请检查数据", orderManagement.getShippingCode(), detail.getCustInfoSeq()));
}
}else {
MesConfig mesConfig = shippingBusiSoftCfgList.get(0);
if (!Objects.isNull(mesConfig) &&
!StringUtils.isEmpty(mesConfig.getCfgValue()) &&
"logic_seq".equals(mesConfig.getCfgValue())) {
Optional<MesShippingOrderManagementDetail> first = model.getDetailList().stream().filter(k -> k.getLogicSeq().compareTo(detail.getLogicSeq()) < 0 && !Objects.equals(k.getIsScanFlg(), MesCommonConstant.TRUE_INTEGER)).findFirst();
if (first.isPresent()) {
throw new ImppBusiException(String.format("发运单【%s】启用明细顺序防错序号【%s】前还有未扫描的发运单明细请检查数据", orderManagement.getShippingCode(), detail.getLogicSeq()));
}
}else {
Optional<MesShippingOrderManagementDetail> first = model.getDetailList().stream().filter(k -> k.getCustInfoSeq().compareTo(detail.getCustInfoSeq()) < 0 && !Objects.equals(k.getIsScanFlg(), MesCommonConstant.TRUE_INTEGER)).findFirst();
if (first.isPresent()) {
throw new ImppBusiException(String.format("发运单【%s】启用明细顺序防错序号【%s】前还有未扫描的发运单明细请检查数据", orderManagement.getShippingCode(), detail.getCustInfoSeq()));
}
}
}
}
//判断是否需要排序校验 默认排序则需要校验
if (!StringUtils.isEmpty(orderManagement.getScanSeqWay()) && !Objects.isNull(MesExtEnumUtil.SHIPPING_GROUP_SCAN_CONFIRM_SEQ_MODE.valueOfDescription(orderManagement.getScanSeqWay()))) {
//按照页面显示顺序校验
Optional<MesShippingOrderManagementDetail> nextShippingDetail = model.getDetailList().stream().filter(k -> StringUtils.isEmpty(k.getBarcode()) && !Objects.equals(k.getIsScanFlg(), MesCommonConstant.TRUE_INTEGER)).findFirst();
if (nextShippingDetail.isPresent() && !StringUtils.isEmpty(nextShippingDetail.get().getPartTypeCode()) && !nextShippingDetail.get().getPartNo().equals(produceSn.getPartNo())) {
throw new ImppBusiException(String.format("【%s】此条码扫描顺序错误请检查数据", model.getSn()));
}
}
//校验客户零件信息是否存在 (默认需要验证, 值可能是[空/0/20])
if (StringUtils.isEmpty(shippingGroup.getScanMethodJudgment()) || !shippingGroup.getScanMethodJudgment().equals(MesExtEnumUtil.SHIPPING_GROUP_SCAN_METHOD_JUDGMENT.PART_NO.getValueStr())) {
DdlPackBean packBean = DdlPackBean.getDdlPackBean(model.getOrganizeCode());
DdlPreparedPack.getStringEqualPack(detail.getPartNo(), "erpPartNo", packBean);
DdlPreparedPack.getStringEqualPack(detail.getCustPartNo(), "custPartNo", packBean);
if (!mesCustomerPartRepository.isExitByHql(packBean)) {
throw new ImppBusiException(String.format("零件号【%s】客户零件号【%s】关系不存在请检查数据", detail.getPartNo(), detail.getCustPartNo()));
}
}
}
private MesProduceSn checkSn(MesSortShippingCheckModel model) {
//校验条码是否重复扫描 (不区分大小写)
Optional<MesShippingOrderManagementDetail> optional = model.getDetailList().stream().filter(k -> !StringUtils.isEmpty(k.getBarcode()) && k.getBarcode().equalsIgnoreCase(model.getSn())).findFirst();
if (optional.isPresent()) {
throw new ImppBusiException(String.format("【%s】此条码已经扫描过请检查数据", model.getSn()));
}
DdlPackBean packBean = DdlPackBean.getDdlPackBean(model.getOrganizeCode());
DdlPreparedPack.getStringEqualPack(model.getSn(), "custSn", packBean);
DdlPreparedPack.getOrderByPack(new Object[]{CommonEnumUtil.ASC_OR_DESC.DESC.getValue()}, new String[]{"createDatetime"}, packBean);
MesProduceSn produceSn = produceSnRepository.getByProperty(packBean);
if (!StringUtils.isEmpty(produceSn)) {
//校验状态
checkStatus(model, produceSn);
}
// else {
// //外部条码解析
// MesShippingOrderManagementDetail mesShippingOrderManagementDetail = getMesShippingOrderManagementDetail(model);
// //封装信息
// produceSn = new MesProduceSn();
// produceSn.setSerialNumber(model.getSn());
// produceSn.setProductSn(model.getSn());
// produceSn.setPartNo(mesShippingOrderManagementDetail.getPartNo());
// produceSn.setOrganizeCode(model.getOrganizeCode());
// }
return produceSn;
}
private void checkStatus(MesSortShippingCheckModel model, MesProduceSn produceSn) {
//校验产品条码状态 必须是状态为已下线条码
if (produceSn.getSnStatus() != MesExtEnumUtil.PRODUCE_SN_STATUS.OFFLINE.getValue() && produceSn.getSnStatus() != MesExtEnumUtil.PRODUCE_SN_STATUS.CREATE.getValue()) {
throw new ImppBusiException(String.format("【%s】此条码状态为【%s】,请选择状态为【%s】或【%s】状态的条码请检查数据", model.getSn(), MesExtEnumUtil.PRODUCE_SN_STATUS.valueOfDescription(produceSn.getSnStatus()),
MesExtEnumUtil.PRODUCE_SN_STATUS.OFFLINE.getDescription(), MesExtEnumUtil.PRODUCE_SN_STATUS.CREATE.getDescription()));
}
//校验产品质量状态 必须是状态为合格条码
List<Integer> statusList = Stream.of(MesExtEnumUtil.PRODUCE_QC_STATUS.QUALIFIED.getValue(), MesExtEnumUtil.PRODUCE_QC_STATUS.SUSPICIOUS_TO_QUALIFIED.getValue()).collect(Collectors.toList());
if (!statusList.contains(produceSn.getQcStatus())){
throw new ImppBusiException(String.format("【%s】此条码质量状态为【%s】,请选择【%s】状态的条码请检查数据", model.getSn(), MesExtEnumUtil.PRODUCE_QC_STATUS.valueOfDescription(produceSn.getQcStatus()),
MesExtEnumUtil.PRODUCE_QC_STATUS.QUALIFIED.getDescription()));
}
}
private MesShippingOrderManagementDetail getMesShippingOrderManagementDetail(MesSortShippingCheckModel model) {
//外部解析条码长度卡控
String cfgValue = mesConfigService.getCfgValue(model.getOrganizeCode(), MesPcnExtConstWords.MAX_SHIPPING_BARCODE_LENGTH);
if (Integer.parseInt(cfgValue) < model.getSn().length()) {
MesPcnException.throwMesBusiException("【%s】此条码长度超过【%s】位请检查数据", model.getSn(), cfgValue);
}
//唯一性校验
if (mesShippingSnUniqueService.checkMesShippingSnUnique(model.getOrganizeCode(),model.getSn())) {
throw new ImppBusiException(String.format("【%s】条码唯一性校验数据已存在请检查数据", model.getSn()));
}
//发运组代码不存在
if (Objects.isNull(model.getMesPartShippingGroup())) {
MesPcnException.throwMesBusiException("发运组信息不存在,请检查数据!");
}
List<MesShippingOrderManagementDetail> detailList = model.getDetailList().stream().filter(k -> !StringUtils.isEmpty(k.getCustPartNo()) && StringUtils.isEmpty(k.getBarcode()) && !Objects.equals(k.getIsScanFlg(), MesCommonConstant.TRUE_INTEGER)).collect(Collectors.toList());
MesShippingOrderManagementDetail mesShippingOrderManagementDetail = null;
for (MesShippingOrderManagementDetail managementDetail : detailList) {
DdlPackBean packBean = DdlPackBean.getDdlPackBean(model.getOrganizeCode());
DdlPreparedPack.getStringEqualPack(managementDetail.getPartNo(), "erpPartNo", packBean);
DdlPreparedPack.getStringEqualPack(managementDetail.getCustPartNo(), "custPartNo", packBean);
if (checkMesPartShippingGroupDetailRule(model, managementDetail) && mesCustomerPartRepository.isExitByHql(packBean)) {
mesShippingOrderManagementDetail = managementDetail;
break;
}
}
if (Objects.isNull(mesShippingOrderManagementDetail)) {
throw new ImppBusiException(String.format("【%s】此条码未匹配到数据请检查数据", model.getSn()));
}
return mesShippingOrderManagementDetail;
}
private void updateOrderManagementDetails(MesProduceSn produceSn, MesShippingOrderManagement orderManagement, MesShippingOrderManagementDetail detail, MesWorkOrder workOrder, String userInfo) {
if (StringUtils.isEmpty(orderManagement.getCheckSeqCode())) {
detail.setBarcode(produceSn.getCustSn());
detail.setVisualOrderNo(workOrder.getWorkOrderNo());
detail.setIsScanFlg(MesCommonConstant.TRUE_INTEGER);
detail.setStatus(MesExtEnumUtil.SHIPPING_ORDER_DETAIL_SHIPPING_STATUS.SHIPPINGED.getValue());
detail.setRemark("扫描完成");
//根据是否启动记忆判断 若启用记忆,则根据保存数据库
if (!StringUtils.isEmpty(orderManagement.getIsEnableMemory()) && Objects.equals(orderManagement.getIsEnableMemory(), MesCommonConstant.TRUE_INTEGER)) {
//若发运单状态为创建或发布 则写入开始扫描时间
if (!StringUtils.isEmpty(orderManagement.getStatus()) && (orderManagement.getStatus() == MesExtEnumUtil.SHIPPING_ORDER_STATUS.CREATE.getValue() ||
orderManagement.getStatus() == MesExtEnumUtil.SHIPPING_ORDER_STATUS.PUBLISHED.getValue())) {
orderManagement.setStartScanTime(TimeTool.getNowTime(true));
}
orderManagement.setStatus(MesExtEnumUtil.SHIPPING_ORDER_STATUS.SHIPPING.getValue());
orderManagement.setSystemSyncStatus(CommonEnumUtil.FALSE);
ConvertBean.serviceModelUpdate(orderManagement, userInfo);
update(orderManagement);
detail.setActualQty(1);
detail.setSystemSyncStatus(CommonEnumUtil.FALSE);
ConvertBean.serviceModelUpdate(detail, userInfo);
updateDetail(detail);
//内部条码更新条码状态
if (!Objects.isNull(produceSn.getId())) {
produceSn.setSnStatus(MesExtEnumUtil.PRODUCE_SN_STATUS.SHIPPED.getValue());
produceSn.setSystemSyncStatus(CommonEnumUtil.FALSE);
ConvertBean.serviceModelUpdate(produceSn, userInfo);
produceSnExtService.update(produceSn);
}else{
//记录唯一性校验表
mesShippingSnUniqueService.insertMesShippingSnUnique(orderManagement.getOrganizeCode(),detail.getBarcode(),orderManagement.getShippingCode(),userInfo);
}
}
}
}
@MonitorLog
public void update(MesShippingOrderManagement item) {
shippingOrderManagementRepository.update(item);
}
@MonitorLog
public void updateDetail(MesShippingOrderManagementDetail item) {
shippingOrderManagementDetailRepository.update(item);
}
private Boolean checkMesPartShippingGroupDetailRule(MesSortShippingCheckModel model, MesShippingOrderManagementDetail managementDetail) {
MesPartShippingGroupDetail mesPartShippingGroupDetail = mesPartShippingGroupService.getMesPartShippingGroupDetail(model.getOrganizeCode(), model.getMesPartShippingGroup().getShippingGroupCode(), managementDetail.getPartNo(), managementDetail.getCustPartNo());
return !Objects.isNull(mesPartShippingGroupDetail) && !StringUtil.isEmpty(mesPartShippingGroupDetail.getSnRule()) && ((Boolean) ((IMesNumberRuleMatchDispatchService) SpringContextsUtil.getBean(MesExtEnumUtil.ASSEMBLY_MATCH_TYPE.MATCH_TYPE_20.getStrategyClass())).matchNumberRule(model.getOrganizeCode(), model.getSn(), mesPartShippingGroupDetail.getSnRule(), mesPartShippingGroupDetail.getSnRule()).get(MesPcnExtConstWords.RESULT));
}
}

@ -95,16 +95,23 @@ public class MesFordFetchWebServiceImpl implements IFordFetchWebService {
map.put("et",parameter.getEndDateTime());
map.put("catacode","0");
map.put("itemcode","0");
HttpResponse response = HttpRequest.get(parameter.getFetchUrl()).cookie(cookies).timeout(60000).form(map).execute();
log.info("doFetchData-查询出来的内容为:{}",response.body());
Document doc = Jsoup.parse(response.body());
Elements trList = doc.select("tr");
//校验最后一条数据是否已经存在数据库中, 特殊逻辑page如果为空则只查最后一页的内容
boolean result = checkLastPage(parameter, cookies, organizeCode);
if (!result){
//分页查询
map.put("page",parameter.getCurrentPageIndex());
HttpResponse response = HttpRequest.get(parameter.getFetchUrl()).cookie(cookies).timeout(60000).form(map).execute();
log.info("doFetchData-查询出来的内容为:{}",response.body());
Document doc = Jsoup.parse(response.body());
int tempCount = 0;
Elements trList = doc.select("tr");
for (int i = 1; i < trList.size(); i++) {
Elements tdList = trList.get(i).select("td");
MesFordJsaSortInfoWithFetchWeb webInfo = new MesFordJsaSortInfoWithFetchWeb();
if (tdList.get(0).text().equals("无数据") || StringUtils.isBlank(tdList.get(0).text())){
break;
}
tempCount++;
webInfo.setSeq(Long.parseLong(tdList.get(0).text()));
webInfo.setFetchDate(tdList.get(1).text());
webInfo.setFetchTime(tdList.get(2).text());
@ -134,7 +141,42 @@ public class MesFordFetchWebServiceImpl implements IFordFetchWebService {
fetchWebRao.insert(webInfo);
infoList.add(webInfo);
}
if (tempCount == parameter.getPageSize()){
parameter.setCurrentPageIndex(parameter.getCurrentPageIndex()+1);
ConvertBean.saveOrUpdate(parameter,"doFetchData-index");
paramRao.update(parameter);
}
}
return infoList;
}
private boolean checkLastPage(MesFordFetchParameter parameter, List<HttpCookie> cookies,String organizeCode) {
Map<String,Object> map = new HashMap<>();
map.put("maxpage",parameter.getPageSize() != null ? parameter.getPageSize().toString() : "1");
map.put("trigger",parameter.getInfoPointCode());
map.put("st",parameter.getStartDateTime());
map.put("et",parameter.getEndDateTime());
map.put("catacode","0");
map.put("itemcode","0");
//校验最后一条数据是否已经存在数据库中, 特殊逻辑page如果为空则只查最后一页的内容
HttpResponse response = HttpRequest.get(parameter.getFetchUrl()).cookie(cookies).timeout(60000).form(map).execute();
log.info("doFetchData-查询出来的内容为:{}",response.body());
Document doc = Jsoup.parse(response.body());
Elements trList = doc.select("tr");
Elements tdList = trList.get(trList.size()-1).select("td");
if (!tdList.isEmpty()){
if (tdList.get(0).text().equals("无数据") || StringUtils.isBlank(tdList.get(0).text())) {
return false;
}
//校验是否已经查询过
DdlPackBean webInfoPackBean = DdlPackBean.getDdlPackBean(organizeCode);
DdlPreparedPack.getNumEqualPack(Long.parseLong(tdList.get(0).text()),"seq",webInfoPackBean);
DdlPreparedPack.getStringEqualPack(tdList.get(1).text(),"fetchDate",webInfoPackBean);
DdlPreparedPack.getStringEqualPack(tdList.get(2).text(),"fetchTime",webInfoPackBean);
int count = fetchWebRao.findByHqlWhereCount(webInfoPackBean);
return count > 0;
}
return false;
return infoList;
}
}

@ -2,9 +2,14 @@ package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.print;
import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesProduceSnPrintModel;
import cn.estsh.i3plus.pojo.mes.bean.MesNumberRule;
import cn.estsh.i3plus.pojo.mes.bean.shipping.MesShippingOrderManagement;
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 cn.estsh.impp.framework.boot.util.ResultBean;
import io.swagger.annotations.ApiOperation;
import java.util.List;
/**
* @Description : , content dataList
@ -14,20 +19,16 @@ import cn.estsh.i3plus.pojo.mes.model.StepResult;
* @Modify:
**/
public interface IPrintTemplateStrategyService {
/**
* dataList
*
* @param sn
* @return
*/
// MesProduceSnPrintDataModel execute(StepResult stepResult, StationRequestBean reqBean, MesProductionPsOutContext sn , String organizeCode);
/**
* GenSerialNoModel
* mesProduceSnPrintModel
* @param model
* @param mesProduceSnPrintModel
* @return
*/
MesProduceSnPrintModel execute(GenSerialNoModel model , MesProduceSnPrintModel mesProduceSnPrintModel, MesNumberRule numberRule, StepResult stepResult, StationRequestBean reqBean, Boolean isStep);
@ApiOperation(value = "单件条码")
default MesProduceSnPrintModel execute(GenSerialNoModel model, MesProduceSnPrintModel mesProduceSnPrintModel,
MesNumberRule numberRule, StepResult stepResult, StationRequestBean reqBean, Boolean isStep) {
return mesProduceSnPrintModel;
}
@ApiOperation(value = "发运单")
default ResultBean execute(MesShippingOrderManagement bean, List<MesShippingOrderManagement> shippingOrderManagementList) {
return null;
}
}

@ -0,0 +1,23 @@
package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.print.sortshipping;
import cn.estsh.i3plus.pojo.mes.bean.shipping.MesShippingOrderManagement;
import cn.estsh.i3plus.pojo.mes.bean.shipping.MesShippingOrderManagementDetail;
import java.util.List;
/**
* @Description :
**/
public interface ISortShippingDispatchStrategyService {
default List<MesShippingOrderManagement> getShippingOrderManagementList(MesShippingOrderManagement bean) {
return null;
}
default List<MesShippingOrderManagementDetail> getShippingOrderManagementDetailList(String organizeCode, List<Long> idList, Object[] obj, String[] str) {
return null;
}
default void saveShippingOrderManagementList(List<MesShippingOrderManagement> pullingOrderInfos) {}
}

@ -0,0 +1,179 @@
package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.print.sortshipping.strategy;
import cn.estsh.i3plus.ext.mes.pcn.api.base.IMesPartPackageTypeService;
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesPartShippingGroupService;
import cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.print.IPrintTemplateStrategyService;
import cn.estsh.i3plus.pojo.base.bean.DdlPackBean;
import cn.estsh.i3plus.pojo.base.enumutil.ResourceEnumUtil;
import cn.estsh.i3plus.pojo.base.tool.DdlPreparedPack;
import cn.estsh.i3plus.pojo.mes.bean.MesPart;
import cn.estsh.i3plus.pojo.mes.bean.MesPartPackageType;
import cn.estsh.i3plus.pojo.mes.bean.MesPartShippingGroup;
import cn.estsh.i3plus.pojo.mes.bean.edi.cd.MesCimVolvoJisRackId;
import cn.estsh.i3plus.pojo.mes.bean.edi.cd.MesCimVolvoJisRackIdDetail;
import cn.estsh.i3plus.pojo.mes.bean.shipping.MesShippingOrderManagement;
import cn.estsh.i3plus.pojo.mes.bean.shipping.MesShippingOrderManagementDetail;
import cn.estsh.i3plus.pojo.mes.model.ChengDuVolvoShippingPrintModel;
import cn.estsh.i3plus.pojo.mes.repository.MesPartRepository;
import cn.estsh.i3plus.pojo.mes.repository.MesShippingOrderManagementDetailRepository;
import cn.estsh.i3plus.pojo.mes.repository.edi.cd.MesCimVolvoJisRackIdDetailRepository;
import cn.estsh.i3plus.pojo.mes.repository.edi.cd.MesCimVolvoJisRackIdRepository;
import cn.estsh.impp.framework.boot.auth.AuthUtil;
import cn.estsh.impp.framework.boot.util.ResultBean;
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.ArrayList;
import java.util.List;
/**
* @Description : volvo
* @Reference :
* @Author : jason.niu
* @CreateDate : 2025/03/20 16:43
* @Modify:
**/
@Component
@Slf4j
public class ChengDuVolvoShippingPrintStrategyService extends SortShippingDispatchStrategyService implements IPrintTemplateStrategyService {
@Autowired
private MesShippingOrderManagementDetailRepository shippingOrderDetailRDao;
@Autowired
private MesCimVolvoJisRackIdRepository rackIdRDao;
@Autowired
private MesCimVolvoJisRackIdDetailRepository rackIdDetailRDao;
@Autowired
private MesPartRepository partRDao;
@Autowired
private IMesPartShippingGroupService shippingGroupService;
@Autowired
private IMesPartPackageTypeService partPackageTypeService;
@Override
public List<MesShippingOrderManagement> getShippingOrderManagementList(MesShippingOrderManagement bean) {
return super.getShippingOrderManagementList(bean);
}
@Override
public List<MesShippingOrderManagementDetail> getShippingOrderManagementDetailList(String organizeCode, List<Long> idList, Object[] obj, String[] str) {
return super.getShippingOrderManagementDetailList(organizeCode, idList, obj, str);
}
@Override
public void saveShippingOrderManagementList(List<MesShippingOrderManagement> shippingOrderManagementList) {
super.saveShippingOrderManagementList(shippingOrderManagementList);
}
@Override
public ResultBean execute(MesShippingOrderManagement bean, List<MesShippingOrderManagement> shippingOrderManagementList) {
List<ChengDuVolvoShippingPrintModel> modelList = new ArrayList<>();
for (MesShippingOrderManagement loadingList : shippingOrderManagementList) {
ChengDuVolvoShippingPrintModel model = getPrintData(loadingList);
if (model != null) {
modelList.add(model);
}
}
return ResultBean.success("装车单打印成功").setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode()).setResultList(modelList);
}
private ChengDuVolvoShippingPrintModel getPrintData(MesShippingOrderManagement shippingOrder) {
final String organizeCode = AuthUtil.getOrganize().getOrganizeCode();
final String userName = AuthUtil.getSessionUser().getUserName();
ChengDuVolvoShippingPrintModel model = new ChengDuVolvoShippingPrintModel();
DdlPackBean shippingDetailPackBean = DdlPackBean.getDdlPackBean(organizeCode);
DdlPreparedPack.getNumEqualPack(shippingOrder.getId(), "pid", shippingDetailPackBean);
List<MesShippingOrderManagementDetail> shippingDetails = shippingOrderDetailRDao.findByHqlWhere(shippingDetailPackBean);
if (CollectionUtils.isEmpty(shippingDetails)) {
return null;
}
List<String> partNos = new ArrayList<>();
List<Long> rackDetailIdList = new ArrayList<>();
for (MesShippingOrderManagementDetail shippingDetail : shippingDetails) {
if (shippingDetail.getSourceId() != null) {
rackDetailIdList.add(shippingDetail.getSourceId());
}
if (!partNos.contains(shippingDetail.getPartNo())) {
partNos.add(shippingDetail.getPartNo());
}
}
DdlPackBean rackDetailPackBean = DdlPackBean.getDdlPackBean(organizeCode);
DdlPreparedPack.getInPackList(rackDetailIdList, "id", rackDetailPackBean);
List<MesCimVolvoJisRackIdDetail> rackIdDetails = rackIdDetailRDao.findByHqlWhere(rackDetailPackBean);
if (CollectionUtils.isEmpty(rackIdDetails)) {
return null;
}
List<Long> rackIdList = new ArrayList<>();
for (MesCimVolvoJisRackIdDetail rackIdDetail : rackIdDetails) {
if (rackIdDetail.getJisRackIdFid() != null && !rackIdList.contains(rackIdDetail.getJisRackIdFid())) {
rackIdList.add(rackIdDetail.getJisRackIdFid());
}
}
DdlPackBean rackPackBean = DdlPackBean.getDdlPackBean(organizeCode);
DdlPreparedPack.getInPackList(rackIdList, "id", rackPackBean);
List<MesCimVolvoJisRackId> rackIds = rackIdRDao.findByHqlWhere(rackPackBean);
if (CollectionUtils.isEmpty(rackIds)) {
return null;
}
// 净重
double totalNetWeight = 0.0;
// 净重单位
String netWom = "";
// 包装重量
double packageWeight = 0.0;
// 包装重量单位
String tmpGwUom = "";
DdlPackBean partPackBean = DdlPackBean.getDdlPackBean(organizeCode);
DdlPreparedPack.getInPackList(partNos, "partNo", rackPackBean);
List<MesPart> parts = partRDao.findByHqlWhere(partPackBean);
if (!CollectionUtils.isEmpty(parts)) {
for (MesPart mesPart : parts) {
if (mesPart.getNetWeight() != null) {
totalNetWeight += mesPart.getNetWeight();
}
netWom = mesPart.getWeightUom();
}
}
MesPartShippingGroup shippingGroup = shippingGroupService.getMesPartShippingGroup(organizeCode, shippingOrder.getShippingGroupCode());
if (shippingGroup != null && !StringUtils.isEmpty(shippingGroup.getPackageTypeCode()) && (shippingGroup.getPackageTypeCode().startsWith("P") || shippingGroup.getPackageTypeCode().startsWith("p"))) {
MesPartPackageType partPackageType = partPackageTypeService.getMesPartPackageType(organizeCode, shippingGroup.getPackageTypeCode());
if (partPackageType != null) {
packageWeight = partPackageType.getNetWeight() != null ? partPackageType.getNetWeight() : 0;
tmpGwUom = partPackageType.getWeightUom();
}
}
MesCimVolvoJisRackId rackId = rackIds.get(0);
model.setRecelver(rackId.getShipToId());
model.setDock(rackId.getIdForPlaceOfDischarge());
model.setAdviceNoteNo(rackId.getAsnNo());
model.setAdviceNoteBarCode(rackId.getAsnNo());
model.setSupplierAddress(StringUtils.isEmpty(rackId.getShipFrom()) ? rackId.getShipFromId() : rackId.getShipFrom());
model.setNetWeight(String.format("%.2f", totalNetWeight));
model.setNWUom(netWom);
model.setGrossWeight(String.format("%.2f", totalNetWeight + packageWeight));
model.setGWUom(tmpGwUom);
model.setRackId(rackId.getJisRackId());
model.setRackBarCode(rackId.getJisRackId());
model.setFirstPreNo(rackId.getFirstSequenceNumber());
model.setFirstPreBarCode(rackId.getFirstSequenceNumber());
model.setLastPreNo(rackId.getLastSequenceNumber());
model.setLastPreBarCode(rackId.getLastSequenceNumber());
model.setSupplierID(rackId.getSellerId());
model.setSupplierBarCode(rackId.getSellerId());
model.setCountryOfOrigin("CN");
model.setNoofCars(rackDetailIdList.size());
model.setDescription(rackId.getRackReference());
model.setPackageId(rackId.getJisRackId());
model.setPackageBarCode(rackId.getJisRackId());
model.setProcess("LDJIS");
return model;
}
}

@ -0,0 +1,161 @@
package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.print.sortshipping.strategy;
import cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.print.IPrintTemplateStrategyService;
import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtConstWords;
import cn.estsh.i3plus.platform.common.convert.ConvertBean;
import cn.estsh.i3plus.platform.common.tool.TimeTool;
import cn.estsh.i3plus.pojo.base.enumutil.ResourceEnumUtil;
import cn.estsh.i3plus.pojo.base.util.StringUtil;
import cn.estsh.i3plus.pojo.mes.bean.shipping.MesShippingOrderManagement;
import cn.estsh.i3plus.pojo.mes.bean.shipping.MesShippingOrderManagementDetail;
import cn.estsh.i3plus.pojo.mes.model.MesShippingOrderManagementDetailModelForLiJia;
import cn.estsh.i3plus.pojo.mes.model.MesShippingOrderManagementModelForLiJia;
import cn.estsh.i3plus.pojo.mes.repository.MesCimCheryOrderRepository;
import cn.estsh.impp.framework.boot.util.ResultBean;
import com.alibaba.fastjson.JSONObject;
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.*;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
/**
* @Description :
**/
@Service
@Slf4j
public class CqLjSortShippingPrintStrategyService extends SortShippingDispatchStrategyService implements IPrintTemplateStrategyService {
@Autowired
private MesCimCheryOrderRepository cimCheryOrderRepository;
@Override
public List<MesShippingOrderManagement> getShippingOrderManagementList(MesShippingOrderManagement bean) {
return super.getShippingOrderManagementList(bean);
}
@Override
public List<MesShippingOrderManagementDetail> getShippingOrderManagementDetailList(String organizeCode, List<Long> idList, Object[] obj, String[] str) {
return super.getShippingOrderManagementDetailList(organizeCode, idList, obj, str);
}
@Override
public void saveShippingOrderManagementList(List<MesShippingOrderManagement> shippingOrderManagementList) {
super.saveShippingOrderManagementList(shippingOrderManagementList);
}
@Override
public ResultBean execute(MesShippingOrderManagement bean, List<MesShippingOrderManagement> shippingOrderManagementList) {
//维护了该参数,则执行礼嘉的新逻辑
List<MesShippingOrderManagementModelForLiJia> mainDataList = new ArrayList<>();
List<Long> pidList = shippingOrderManagementList.stream().map(MesShippingOrderManagement::getId).collect(Collectors.toList());
List<MesShippingOrderManagementDetail> shippingOrderManagementDetailList = getShippingOrderManagementDetailList(bean.getOrganizeCode(), pidList, null, null);
log.info("工厂{}排序发运打印 --- 查询发运单明细信息:{}条 --- {}", bean.getOrganizeCode(),
CollectionUtils.isEmpty(shippingOrderManagementDetailList) ? MesPcnExtConstWords.ZERO : shippingOrderManagementDetailList.size(), Thread.currentThread().getName());
Map<Long, List<MesShippingOrderManagementDetail>> detailByPidMap = CollectionUtils.isEmpty(shippingOrderManagementDetailList) ? null :
shippingOrderManagementDetailList.stream().filter(o -> (null != o && !StringUtils.isEmpty(o.getPid()))).collect(Collectors.groupingBy(MesShippingOrderManagementDetail::getPid));
//遍历处理每个发运单主表
for (MesShippingOrderManagement shippingOrderManagement : shippingOrderManagementList) {
//一张实体发运单包含三部分信息(顶部的通用数据、中部的第一份表格数据,底部的第二份表格数据)
//取出当前发运单的明细信息
List<MesShippingOrderManagementDetail> details = null == detailByPidMap ? null : detailByPidMap.get(shippingOrderManagement.getId());
if (!CollectionUtils.isEmpty(details)) {
//将发运单明细按照 assyCode 分组
//assyCode 的个数 / 2 代表会生成实体发运单的份数(一个 assyCode 就是一个表格,一份实体表单上可以放两个表格)
Map<String, List<MesShippingOrderManagementDetail>> detailByAssyCodeMap =
details.stream().collect(Collectors.groupingBy(MesShippingOrderManagementDetail::getAssyCode));
//将assyCode按照logic_Seq进行排序选取每个assyCode对应的那组数据中的logic_seq最小值根据该值对assyCode进行排序
List<String> assyCodeList = new ArrayList<>(detailByAssyCodeMap.keySet());
Map<Long, String> logicSeqAndAssyCodeMap = new HashMap<>();
for (String assyCode : assyCodeList) {
List<MesShippingOrderManagementDetail> detailList = detailByAssyCodeMap.get(assyCode);
Optional<MesShippingOrderManagementDetail> min =
detailList.stream().min(Comparator.comparing(MesShippingOrderManagementDetail::getLogicSeq));
min.ifPresent(mesShippingOrderManagementDetail -> logicSeqAndAssyCodeMap.put(mesShippingOrderManagementDetail.getLogicSeq(), assyCode));
}
List<Long> collect = logicSeqAndAssyCodeMap.keySet().stream().sorted().collect(Collectors.toList());
List<String> newAssyCodeList = new ArrayList<>();
for (Long logicSeq : collect) {
newAssyCodeList.add(logicSeqAndAssyCodeMap.get(logicSeq));
}
//将 assyCode 两两分组
List<List<String>> physicalOrderList = IntStream.range(0, newAssyCodeList.size())
.filter(i -> i % 2 == 0)
.mapToObj(i -> newAssyCodeList.subList(i, Math.min(i + 2, newAssyCodeList.size())))
.collect(Collectors.toList());
for (List<String> list : physicalOrderList) {
//生成一张实体发运单
log.info("工厂{}排序发运打印 --- 生成一张实体发运单:{} --- {}", bean.getOrganizeCode(), list.toString(), Thread.currentThread().getName());
mainDataList.add(createPhysicalOrder(shippingOrderManagement, list, detailByAssyCodeMap, details));
}
}
shippingOrderManagement.setPrintCount(StringUtil.isEmpty(shippingOrderManagement.getPrintCount())? 1 : shippingOrderManagement.getPrintCount()+1);
shippingOrderManagement.setLastPrintTime(TimeTool.getNowTime(true));
shippingOrderManagement.setLastPrintUser(bean.getUserInfo());
ConvertBean.serviceModelUpdate(shippingOrderManagement, bean.getUserInfo());
}
saveShippingOrderManagementList(shippingOrderManagementList);
return ResultBean.success("发运单打印成功").setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode()).setResultList(mainDataList);
}
private MesShippingOrderManagementModelForLiJia createPhysicalOrder(MesShippingOrderManagement shippingOrderManagement,
List<String> assyCodeList,
Map<String, List<MesShippingOrderManagementDetail>> detailByAssyCodeMap,
List<MesShippingOrderManagementDetail> details) {
MesShippingOrderManagementModelForLiJia model = new MesShippingOrderManagementModelForLiJia();
//顶部的通用数据赋值
model.setShippingGroupName(shippingOrderManagement.getShippingGroupName());
model.setPrintDateTime(TimeTool.getNowTime(true));
model.setShippingCode(shippingOrderManagement.getShippingCode());
model.setDocumentNumber("YFVCQ-MS06-02-01");
//中部表结构赋值
model.setDetailModelsOne(createDetailList(assyCodeList.get(0), detailByAssyCodeMap, details, shippingOrderManagement.getRackNo()));
//底部表结构赋值
model.setDetailModelsTwo(createDetailList(assyCodeList.get(1), detailByAssyCodeMap, details, shippingOrderManagement.getRackNo()));
log.info("工厂{}排序发运打印 --- MesShippingOrderManagementModelForLiJia:{} --- {}", shippingOrderManagement.getOrganizeCode(), JSONObject.toJSONString(model), Thread.currentThread().getName());
return model;
}
private List<MesShippingOrderManagementDetailModelForLiJia> createDetailList(
String assyCode, Map<String, List<MesShippingOrderManagementDetail>> detailByAssyCodeMap,
List<MesShippingOrderManagementDetail> details, String rackNo) {
List<MesShippingOrderManagementDetailModelForLiJia> dataList = new ArrayList<>();
//取出符合条件的发运单明细数据
List<MesShippingOrderManagementDetail> nowDetailList = detailByAssyCodeMap.get(assyCode);
if (!CollectionUtils.isEmpty(nowDetailList)) {
//并按照 logic_seq 升序排列
List<MesShippingOrderManagementDetail> collect = nowDetailList.stream().sorted(
Comparator.comparing(MesShippingOrderManagementDetail::getLogicSeq)).collect(Collectors.toList());
Integer number = 1;
for (MesShippingOrderManagementDetail mesShippingOrderManagementDetail : collect) {
MesShippingOrderManagementDetailModelForLiJia detailModel = new MesShippingOrderManagementDetailModelForLiJia();
detailModel.setNumber(number);
detailModel.setCustInfoSeq(mesShippingOrderManagementDetail.getCustInfoSeq());
if (!StringUtils.isEmpty(mesShippingOrderManagementDetail.getVin())) {
detailModel.setVin(mesShippingOrderManagementDetail.getVin().substring(
mesShippingOrderManagementDetail.getVin().length() - 6));
}
detailModel.setCarSerialCode(mesShippingOrderManagementDetail.getCarSerialCode());
detailModel.setPartNo(mesShippingOrderManagementDetail.getPartNo());
detailModel.setCustPartNo(mesShippingOrderManagementDetail.getCustPartNo());
detailModel.setCustPartName(mesShippingOrderManagementDetail.getPartName());
detailModel.setRackNo(rackNo);
dataList.add(detailModel);
number ++;
}
}
return dataList;
}
}

@ -0,0 +1,156 @@
package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.print.sortshipping.strategy;
import cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.print.IPrintTemplateStrategyService;
import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesSortShippingPrintForCqLxModel;
import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtConstWords;
import cn.estsh.i3plus.platform.common.convert.ConvertBean;
import cn.estsh.i3plus.platform.common.tool.TimeTool;
import cn.estsh.i3plus.pojo.base.bean.DdlPackBean;
import cn.estsh.i3plus.pojo.base.enumutil.ResourceEnumUtil;
import cn.estsh.i3plus.pojo.base.tool.DdlPreparedPack;
import cn.estsh.i3plus.pojo.base.util.StringUtil;
import cn.estsh.i3plus.pojo.mes.bean.seres.MesCimSeresSrmRunSheetJis;
import cn.estsh.i3plus.pojo.mes.bean.seres.MesCimSeresSrmRunSheetJisDetail;
import cn.estsh.i3plus.pojo.mes.bean.shipping.MesShippingOrderManagement;
import cn.estsh.i3plus.pojo.mes.bean.shipping.MesShippingOrderManagementDetail;
import cn.estsh.i3plus.pojo.mes.repository.seres.IMesCimSeresSrmRunSheetJisDetailRepository;
import cn.estsh.i3plus.pojo.mes.repository.seres.IMesCimSeresSrmRunSheetJisRepository;
import cn.estsh.impp.framework.boot.util.ResultBean;
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.CollectionUtils;
import org.springframework.util.StringUtils;
import java.util.*;
import java.util.stream.Collectors;
/**
* @Description :
**/
@Service
@Slf4j
public class CqLxSortShippingPrintStrategyService extends SortShippingDispatchStrategyService implements IPrintTemplateStrategyService {
@Autowired
private IMesCimSeresSrmRunSheetJisRepository cimSeresSrmRunSheetJisRepository;
@Autowired
private IMesCimSeresSrmRunSheetJisDetailRepository cimSeresSrmRunSheetJisDetailRepository;
@Override
public List<MesShippingOrderManagement> getShippingOrderManagementList(MesShippingOrderManagement bean) {
return super.getShippingOrderManagementList(bean);
}
@Override
public List<MesShippingOrderManagementDetail> getShippingOrderManagementDetailList(String organizeCode, List<Long> idList, Object[] obj, String[] str) {
return super.getShippingOrderManagementDetailList(organizeCode, idList, obj, str);
}
@Override
public void saveShippingOrderManagementList(List<MesShippingOrderManagement> shippingOrderManagementList) {
super.saveShippingOrderManagementList(shippingOrderManagementList);
}
@Override
public ResultBean execute(MesShippingOrderManagement bean, List<MesShippingOrderManagement> shippingOrderManagementList) {
List<MesSortShippingPrintForCqLxModel> resultList = new ArrayList<>();
List<String> shippingCodeList = shippingOrderManagementList.stream().map(MesShippingOrderManagement::getShippingCode).collect(Collectors.toList());
List<MesCimSeresSrmRunSheetJis> cimSeresSrmRunSheetJisList = getCimSeresSrmRunSheetJisList(bean.getOrganizeCode(), shippingCodeList);
Map<String, List<MesCimSeresSrmRunSheetJis>> jisByScMap = CollectionUtils.isEmpty(cimSeresSrmRunSheetJisList) ? null :
cimSeresSrmRunSheetJisList.stream().filter(o -> (null != o && !StringUtils.isEmpty(o.getDocNo()))).collect(Collectors.groupingBy(MesCimSeresSrmRunSheetJis::getDocNo));
log.info("工厂{}排序发运打印 --- 查询JIS单信息:{}条 --- {}", bean.getOrganizeCode(),
CollectionUtils.isEmpty(cimSeresSrmRunSheetJisList) ? MesPcnExtConstWords.ZERO : cimSeresSrmRunSheetJisList.size(), Thread.currentThread().getName());
List<Long> jisIdList = CollectionUtils.isEmpty(cimSeresSrmRunSheetJisList) ? null :
cimSeresSrmRunSheetJisList.stream().map(MesCimSeresSrmRunSheetJis::getId).collect(Collectors.toList());
List<MesCimSeresSrmRunSheetJisDetail> cimSeresSrmRunSheetJisDetailList = getCimSeresSrmRunSheetJisDetailList(bean.getOrganizeCode(), jisIdList);
Map<Long, List<MesCimSeresSrmRunSheetJisDetail>> jisDetailByPidMap = CollectionUtils.isEmpty(cimSeresSrmRunSheetJisDetailList) ? null :
cimSeresSrmRunSheetJisDetailList.stream().filter(o -> (null != o && !StringUtils.isEmpty(o.getPid()))).collect(Collectors.groupingBy(MesCimSeresSrmRunSheetJisDetail::getPid));
log.info("工厂{}排序发运打印 --- 查询JIS单详情信息:{}条 --- {}", bean.getOrganizeCode(),
CollectionUtils.isEmpty(cimSeresSrmRunSheetJisDetailList) ? MesPcnExtConstWords.ZERO : cimSeresSrmRunSheetJisDetailList.size(), Thread.currentThread().getName());
//遍历处理每个发运单主表
for (MesShippingOrderManagement shippingOrderManagement : shippingOrderManagementList) {
if (null == shippingOrderManagement) continue;
List<MesCimSeresSrmRunSheetJis> sheetJis = CollectionUtils.isEmpty(jisByScMap) ? null : jisByScMap.get(shippingOrderManagement.getShippingCode());
if (CollectionUtils.isEmpty(sheetJis)) continue;
MesSortShippingPrintForCqLxModel result = new MesSortShippingPrintForCqLxModel();
BeanUtils.copyProperties(sheetJis.get(0), result);
result.setShippingCode(shippingOrderManagement.getShippingCode());
if (shippingOrderManagement.getShippingCode().length() >= 4) {
result.setCarsNo(shippingOrderManagement.getShippingCode().substring(shippingOrderManagement.getShippingCode().length() - 4));
result.setDocNoOther(shippingOrderManagement.getShippingCode().substring(0, shippingOrderManagement.getShippingCode().length() - 4));
}
List<MesCimSeresSrmRunSheetJisDetail> sheetJisDetailList = CollectionUtils.isEmpty(jisDetailByPidMap) ? new ArrayList<>() : jisDetailByPidMap.get(sheetJis.get(0).getId());
if (!CollectionUtils.isEmpty(sheetJisDetailList)) sheetJisDetailList = sheetJisDetailList.stream().filter(o ->
(null != o && !StringUtils.isEmpty(o.getSerialNumber()))).sorted(Comparator.comparing(MesCimSeresSrmRunSheetJisDetail::getSerialNumber)).collect(Collectors.toList());
Integer index = MesPcnExtConstWords.ONE;
for (MesCimSeresSrmRunSheetJisDetail cimSeresSrmRunSheetJisDetail : sheetJisDetailList) {
if (null == cimSeresSrmRunSheetJisDetail) continue;
MesSortShippingPrintForCqLxModel jisDetail = new MesSortShippingPrintForCqLxModel();
BeanUtils.copyProperties(cimSeresSrmRunSheetJisDetail, jisDetail);
//跟cc确认过可以直接写死
jisDetail.setFactoryCode("000003263");
jisDetail.setXh(index);
index ++;
result.addJisDetail(jisDetail);
}
Map<String, List<MesSortShippingPrintForCqLxModel>> sheetJisDetailMap = CollectionUtils.isEmpty(result.getJisDetailList()) ? new HashMap<>() :
result.getJisDetailList().stream().filter(o -> null != o).collect(Collectors.groupingBy(MesSortShippingPrintForCqLxModel::getMaterielCode));
for (Map.Entry<String, List<MesSortShippingPrintForCqLxModel>> entry : sheetJisDetailMap.entrySet()) {
if (null == entry) continue;
List<MesSortShippingPrintForCqLxModel> amountList = entry.getValue();
if (CollectionUtils.isEmpty(amountList)) continue;
MesSortShippingPrintForCqLxModel amount = new MesSortShippingPrintForCqLxModel();
amount.setPartNo(amountList.get(0).getMaterielCode());
amount.setAmountQty(amountList.stream().filter(o -> (null != o && !StringUtils.isEmpty(o.getUseQty()))).mapToDouble(MesSortShippingPrintForCqLxModel::getUseQty).sum());
StringJoiner appendRows = new StringJoiner(MesPcnExtConstWords.COMMA);
amountList.forEach(o -> appendRows.add(o.getXh().toString()));
amount.setAppendRows(appendRows.toString());
amount.setMaterielNames(amountList.get(0).getMaterielNames());
result.addAmount(amount);
}
resultList.add(result);
shippingOrderManagement.setPrintCount(StringUtil.isEmpty(shippingOrderManagement.getPrintCount()) ? MesPcnExtConstWords.ONE : shippingOrderManagement.getPrintCount() + MesPcnExtConstWords.ONE);
shippingOrderManagement.setLastPrintTime(TimeTool.getNowTime(true));
shippingOrderManagement.setLastPrintUser(bean.getUserInfo());
ConvertBean.serviceModelUpdate(shippingOrderManagement, bean.getUserInfo());
}
saveShippingOrderManagementList(shippingOrderManagementList);
return ResultBean.success("发运单打印成功").setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode()).setResultList(resultList);
}
private List<MesCimSeresSrmRunSheetJis> getCimSeresSrmRunSheetJisList(String organizeCode, List<String> shippingCodeList) {
if (StringUtils.isEmpty(organizeCode) || CollectionUtils.isEmpty(shippingCodeList)) return null;
DdlPackBean packBean = DdlPackBean.getDdlPackBean(organizeCode);
if (shippingCodeList.size() == 1) DdlPreparedPack.getStringEqualPack(shippingCodeList.get(0), "docNo", packBean);
else DdlPreparedPack.getInPackList(shippingCodeList, "docNo", packBean);
return cimSeresSrmRunSheetJisRepository.findByHqlWhere(packBean);
}
private List<MesCimSeresSrmRunSheetJisDetail> getCimSeresSrmRunSheetJisDetailList(String organizeCode, List<Long> jisIdList) {
if (StringUtils.isEmpty(organizeCode) || CollectionUtils.isEmpty(jisIdList)) return null;
DdlPackBean packBean = DdlPackBean.getDdlPackBean(organizeCode);
if (jisIdList.size() == 1) DdlPreparedPack.getNumEqualPack(jisIdList.get(0), MesPcnExtConstWords.PID, packBean);
else DdlPreparedPack.getInPackList(jisIdList, MesPcnExtConstWords.PID, packBean);
return cimSeresSrmRunSheetJisDetailRepository.findByHqlWhere(packBean);
}
}

@ -0,0 +1,65 @@
package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.print.sortshipping.strategy;
import cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.print.sortshipping.ISortShippingDispatchStrategyService;
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.base.util.StringUtil;
import cn.estsh.i3plus.pojo.mes.bean.shipping.MesShippingOrderManagement;
import cn.estsh.i3plus.pojo.mes.bean.shipping.MesShippingOrderManagementDetail;
import cn.estsh.i3plus.pojo.mes.repository.MesShippingOrderManagementDetailRepository;
import cn.estsh.i3plus.pojo.mes.repository.MesShippingOrderManagementRepository;
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.Arrays;
import java.util.List;
/**
* @Description :
**/
@Service
@Slf4j
public abstract class SortShippingDispatchStrategyService implements ISortShippingDispatchStrategyService {
@Autowired
public MesShippingOrderManagementRepository shippingOrderManagementRepository;
@Autowired
public MesShippingOrderManagementDetailRepository shippingOrderManagementDetailRepository;
@Override
public List<MesShippingOrderManagement> getShippingOrderManagementList(MesShippingOrderManagement bean) {
DdlPackBean packBean = DdlPackBean.getDdlPackBean(bean.getOrganizeCode());
List<String> shippingGroupCodeList = !StringUtil.isEmpty(bean.getShippingGroupCode()) ? Arrays.asList(bean.getShippingGroupCode().split(MesPcnExtConstWords.COMMA)) : null;
if (!CollectionUtils.isEmpty(shippingGroupCodeList)) {
if (shippingGroupCodeList.size() == 1) DdlPreparedPack.getStringEqualPack(shippingGroupCodeList.get(0), MesPcnExtConstWords.SHIPPING_GROUP_CODE, packBean);
else DdlPreparedPack.getInPackList(shippingGroupCodeList, MesPcnExtConstWords.SHIPPING_GROUP_CODE, packBean);
}
DdlPreparedPack.getStringEqualPack(bean.getShippingCode(), MesPcnExtConstWords.SHIPPING_CODE, packBean);
DdlPreparedPack.getIsNull(MesPcnExtConstWords.LAST_PRINT_TIME, packBean);
DdlPreparedPack.getOrderByPack(new Object[]{CommonEnumUtil.ASC_OR_DESC.ASC.getValue()}, new String[]{MesPcnExtConstWords.CREATE_DATE_TIME}, packBean);
return shippingOrderManagementRepository.findByHqlTopWhere(packBean,10);
}
@Override
public List<MesShippingOrderManagementDetail> getShippingOrderManagementDetailList(String organizeCode, List<Long> idList, Object[] obj, String[] str) {
if (StringUtils.isEmpty(organizeCode) || CollectionUtils.isEmpty(idList)) return null;
DdlPackBean packBean = DdlPackBean.getDdlPackBean(organizeCode);
if (idList.size() == 1) DdlPreparedPack.getNumEqualPack(idList.get(0), MesPcnExtConstWords.PID, packBean);
else DdlPreparedPack.getInPackList(idList, MesPcnExtConstWords.PID, packBean);
if (null != obj && null != str) DdlPreparedPack.getOrderByPack(obj, str, packBean);
return shippingOrderManagementDetailRepository.findByHqlWhere(packBean);
}
@Override
public void saveShippingOrderManagementList(List<MesShippingOrderManagement> shippingOrderManagementList) {
if (CollectionUtils.isEmpty(shippingOrderManagementList)) return;
shippingOrderManagementRepository.saveAll(shippingOrderManagementList);
}
}

@ -0,0 +1,142 @@
package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.print.sortshipping.strategy;
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesConfigService;
import cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.print.IPrintTemplateStrategyService;
import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtConstWords;
import cn.estsh.i3plus.platform.common.convert.ConvertBean;
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.enumutil.ResourceEnumUtil;
import cn.estsh.i3plus.pojo.base.tool.DdlPreparedPack;
import cn.estsh.i3plus.pojo.base.util.StringUtil;
import cn.estsh.i3plus.pojo.mes.bean.MesConfig;
import cn.estsh.i3plus.pojo.mes.bean.edi.wuhu.MesCimCheryOrder;
import cn.estsh.i3plus.pojo.mes.bean.shipping.MesShippingOrderManagement;
import cn.estsh.i3plus.pojo.mes.bean.shipping.MesShippingOrderManagementDetail;
import cn.estsh.i3plus.pojo.mes.model.MesShippingOrderManagementDetailModel;
import cn.estsh.i3plus.pojo.mes.model.MesShippingOrderManagementModel;
import cn.estsh.i3plus.pojo.mes.repository.MesCimCheryOrderRepository;
import cn.estsh.impp.framework.boot.util.ResultBean;
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.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;
/**
* @Description :
**/
@Service
@Slf4j
public class WuhuSortShippingPrintStrategyService extends SortShippingDispatchStrategyService implements IPrintTemplateStrategyService {
@Autowired
private IMesConfigService configService;
@Autowired
private MesCimCheryOrderRepository cimCheryOrderRepository;
@Override
public List<MesShippingOrderManagement> getShippingOrderManagementList(MesShippingOrderManagement bean) {
return super.getShippingOrderManagementList(bean);
}
@Override
public List<MesShippingOrderManagementDetail> getShippingOrderManagementDetailList(String organizeCode, List<Long> idList, Object[] obj, String[] str) {
return super.getShippingOrderManagementDetailList(organizeCode, idList, obj, str);
}
@Override
public void saveShippingOrderManagementList(List<MesShippingOrderManagement> shippingOrderManagementList) {
super.saveShippingOrderManagementList(shippingOrderManagementList);
}
@Override
public ResultBean execute(MesShippingOrderManagement bean, List<MesShippingOrderManagement> shippingOrderManagementList) {
MesConfig config = configService.getMesConfigNoError(bean.getOrganizeCode(), "WU_HU_SUPPLIER");
String supplierNo = (null == config || StringUtils.isEmpty(config.getCfgValue())) ? MesPcnExtConstWords.EMPTY : config.getCfgValue();
List<MesShippingOrderManagementModel> modelList = new ArrayList<>();
//把查出来的发运单打印并修改打印状态为已打印-
for (MesShippingOrderManagement shippingOrderManagement : shippingOrderManagementList) {
MesShippingOrderManagementModel model = new MesShippingOrderManagementModel();
String shippingCodePrefix = shippingOrderManagement.getShippingCode().substring(0, shippingOrderManagement.getShippingCode().length() - 3);
String shippingCodeSuffix = shippingOrderManagement.getShippingCode().substring(shippingOrderManagement.getShippingCode().length() - 3);
model.setShippingCode(shippingCodePrefix);
model.setShippingCodeAfter3(shippingCodeSuffix);
model.setShippingCodeWhole(shippingOrderManagement.getShippingCode());
//查询原始报文
List<MesCimCheryOrder> cheryOrderList = getCheryOrder(shippingOrderManagement.getOrganizeCode(), shippingOrderManagement.getShippingCode());
Map<String, List<MesCimCheryOrder>> cheryOrderMap = new HashMap<>();
if (cheryOrderList != null && !cheryOrderList.isEmpty()) {
MesCimCheryOrder cheryOrder = cheryOrderList.get(0);
model.setPlantName(cheryOrder.getPlantName());
model.setPartkitName(cheryOrder.getPartkitName());
model.setDeliverySendSequence(cheryOrder.getDeliverySendSequence());
model.setReceiveDockName(cheryOrder.getReceiveDockNo()+"--"+cheryOrder.getReceiveDockName());
model.setLastRecRequireTime(cheryOrder.getLastRecRequireTime());
//根据cheryOrder的workshopNo获取对应的车间名称
String workshopName = getWorkshopName(cheryOrder.getOrganizeCode(), cheryOrder.getWorkshopNo());
model.setWorkShop(workshopName);
model.setCreateDateTime(cheryOrder.getCreateDatetime());
model.setPrintDateTime(TimeTool.getNowTime(true));
cheryOrderMap = cheryOrderList.stream().collect(Collectors.groupingBy(MesCimCheryOrder::getVin));
}
//查询发运单明细
List<MesShippingOrderManagementDetail> shipOrderPartInfos = getShippingOrderManagementDetailList(
bean.getOrganizeCode(), Stream.of(shippingOrderManagement.getId()).collect(Collectors.toList()),
new Object[]{CommonEnumUtil.ASC_OR_DESC.ASC.getValue()}, new String[]{"boxNum"});
if (!CollectionUtils.isEmpty(shipOrderPartInfos)) {
List<MesShippingOrderManagementDetailModel> detailList = new ArrayList<>();
shipOrderPartInfos = shipOrderPartInfos.stream().sorted(Comparator.comparing(MesShippingOrderManagementDetail::getCustInfoSeq)).collect(Collectors.toList());
for (MesShippingOrderManagementDetail shipOrderPartInfo : shipOrderPartInfos) {
MesShippingOrderManagementDetailModel detailModel = new MesShippingOrderManagementDetailModel();
detailModel.setPartNo(shipOrderPartInfo.getPartNo());
detailModel.setPartName(shipOrderPartInfo.getPartName());
detailModel.setQty(shipOrderPartInfo.getPlanQty());
detailModel.setBoxNo(shipOrderPartInfo.getCustInfoSeq());
detailModel.setSupplierNo(supplierNo);
detailModel.setVin(shipOrderPartInfo.getVin().substring(shipOrderPartInfo.getVin().length()-8));
MesCimCheryOrder order = cheryOrderMap.get(shipOrderPartInfo.getVin()).get(0);
if (order != null) {
detailModel.setWholePartNo(order.getMaterialNo());
}
detailList.add(detailModel);
}
model.setShipOrderPartInfos(detailList);
}
//查询原有报文 根据shippingCode;
shippingOrderManagement.setPrintCount(StringUtil.isEmpty(shippingOrderManagement.getPrintCount())?1:shippingOrderManagement.getPrintCount()+1);
shippingOrderManagement.setLastPrintTime(TimeTool.getNowTime(true));
shippingOrderManagement.setLastPrintUser(bean.getUserInfo());
ConvertBean.serviceModelUpdate(shippingOrderManagement, bean.getUserInfo());
modelList.add(model);
}
saveShippingOrderManagementList(shippingOrderManagementList);
return ResultBean.success("发运单打印成功").setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode()).setResultList(modelList);
}
private List<MesCimCheryOrder> getCheryOrder(String organizeCode, String sheetNo) {
if (StringUtils.isEmpty(organizeCode) || StringUtils.isEmpty(sheetNo)) return null;
DdlPackBean ddlPackBean = DdlPackBean.getDdlPackBean(organizeCode);
DdlPreparedPack.getStringEqualPack(sheetNo, "sheetNo", ddlPackBean);
return cimCheryOrderRepository.findByHqlWhere(ddlPackBean);
}
private String getWorkshopName(String organizeCode, String workshopNo) {
if (StringUtils.isEmpty(organizeCode) || StringUtils.isEmpty(workshopNo)) return null;
MesConfig config = configService.getMesConfigNoError(organizeCode, workshopNo);
return (null == config || StringUtils.isEmpty(config.getCfgValue())) ? MesPcnExtConstWords.EMPTY : config.getCfgValue();
}
}

@ -0,0 +1,139 @@
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.busi.IMesPrintedSnLogService;
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesProduceSnExtService;
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.util.DateUtil;
import cn.estsh.i3plus.platform.common.tool.TimeTool;
import cn.estsh.i3plus.pojo.mes.bean.MesCustomerPart;
import cn.estsh.i3plus.pojo.mes.bean.MesNumberRule;
import cn.estsh.i3plus.pojo.mes.bean.MesProduceSn;
import cn.estsh.i3plus.pojo.mes.bean.MesWorkOrder;
import cn.estsh.i3plus.pojo.mes.bean.edi.cd.MesCimVolvoJisRackId;
import cn.estsh.i3plus.pojo.mes.bean.edi.cd.MesCimVolvoJisRackIdDetail;
import cn.estsh.i3plus.pojo.mes.bean.shipping.MesCustSortInfo;
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 cn.estsh.i3plus.pojo.mes.repository.MesCustSoftInfoRepository;
import cn.estsh.i3plus.pojo.mes.repository.edi.cd.MesCimVolvoJisRackIdDetailRepository;
import cn.estsh.i3plus.pojo.mes.repository.edi.cd.MesCimVolvoJisRackIdRepository;
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.*;
/**
* @Description : volvo
* @Reference :
* @Author : jason.niu
* @CreateDate : 2025/03/20 16:43
* @Modify:
**/
@Component
@Slf4j
public class ChengDuVolvoPartPrintStrategy implements IPrintTemplateStrategyService {
@Autowired
private IMesPrintedSnLogService mesPrintedSnLogService;
@Autowired
private IMesCustomerPartService mesCustomerPartService;
@Autowired
private MesCustSoftInfoRepository custSoftInfoRDao;
@Autowired
private MesCimVolvoJisRackIdDetailRepository rackIdDetailRDao;
@Autowired
private MesCimVolvoJisRackIdRepository volvoJisRackIdRDao;
@Autowired
private IMesProduceSnExtService produceSnExtService;
@Override
public MesProduceSnPrintModel execute(GenSerialNoModel genSerialNoModel, MesProduceSnPrintModel mesProduceSnPrintModel, MesNumberRule numberRule, StepResult stepResult, StationRequestBean reqBean, Boolean isStep) {
String organizeCode = mesProduceSnPrintModel.getOrganizeCode();
if (!isStep){
MesPcnException.throwBusiException("成都volvo零件标签打印只支持工位端打印!");
}
//物料信息
MesCustomerPart customerPart = (!Objects.isNull(genSerialNoModel) && !CollectionUtils.isEmpty(genSerialNoModel.getDataMap()) && genSerialNoModel.getDataMap().containsKey(MesCustomerPart.class.getSimpleName())) ? (MesCustomerPart) genSerialNoModel.getDataMap().get(MesCustomerPart.class.getSimpleName()) : mesCustomerPartService.getMesCustomerPart(organizeCode,mesProduceSnPrintModel.getPartNo());
// 工单信息
MesWorkOrder workOrder = (MesWorkOrder) mesProduceSnPrintModel.getSourceData();
MesProduceSn mesProduceSn = produceSnExtService.getProduceSnByCustSn(organizeCode, workOrder.getCustSn());
if (mesProduceSn == null) {
MesPcnException.throwBusiException("客户条码[%s]不存在!", workOrder.getCustSn());
}
//封装打印信息
MesProduceSnPrintDataModel printDataModel = getModel(mesProduceSn, customerPart);
mesProduceSnPrintModel.getMesProduceSnPrintDataModelList().clear();
Map<String, Object> printTemplateData = new HashMap<>(getPrintContextMap(mesProduceSn, workOrder));
List<Map<String, Object>> printDataMapList = new ArrayList<>();
printDataMapList.add(printTemplateData);
mesProduceSnPrintModel.getPrintContextList().add(packResultMap(mesProduceSnPrintModel, printDataMapList));
//保存打印记录
mesProduceSnPrintModel.getMesPrintedSnLogList().add(mesPrintedSnLogService.getMesCustomPrintedSnLog(mesProduceSnPrintModel.getUserName(), organizeCode, printDataModel, printTemplateData));
return mesProduceSnPrintModel;
}
private MesProduceSnPrintDataModel getModel(MesProduceSn produceSn, MesCustomerPart customerPart) {
MesProduceSnPrintDataModel mesProduceSnPrintDataModel = new MesProduceSnPrintDataModel();
mesProduceSnPrintDataModel.setPartNo(produceSn.getPartNo());
mesProduceSnPrintDataModel.setPartName(produceSn.getPartName());
if (!Objects.isNull(customerPart)) {
mesProduceSnPrintDataModel.setCustPartNo(customerPart.getCustPartNo());
}
mesProduceSnPrintDataModel.setBarcode(produceSn.getCustSn());
mesProduceSnPrintDataModel.setPrintDate(TimeTool.getNowTime(true));
mesProduceSnPrintDataModel.setUserName(produceSn.getCreateUser());
mesProduceSnPrintDataModel.setProductDate(TimeTool.parseStringFormat(produceSn.getLotNo(), DateUtil.SHORT_FORMAT, "yyyy/MM/dd"));
return mesProduceSnPrintDataModel;
}
private Map<String, Object> getPrintContextMap(MesProduceSn produceSn, MesWorkOrder workOrder) {
if (workOrder == null || StringUtils.isEmpty(workOrder.getWorkOrderSource())) {
MesPcnException.throwBusiException("客户条码[%s]对应的工单信息缺少来源!", workOrder.getCustSn());
}
MesCustSortInfo custSoftInfo = custSoftInfoRDao.getById(Long.parseLong(workOrder.getWorkOrderSource()));
if (custSoftInfo == null) {
MesPcnException.throwBusiException("工单[%s]无法匹配客户排序信息!", workOrder.getWorkOrderNo());
}
MesCimVolvoJisRackIdDetail rackIdDetail = rackIdDetailRDao.getById(custSoftInfo.getSourceId());
if (rackIdDetail == null) {
MesPcnException.throwBusiException("工单[%s]客户排序信息无法匹配RackIdDetail!", workOrder.getWorkOrderNo());
}
MesCimVolvoJisRackId rackId = volvoJisRackIdRDao.getById(rackIdDetail.getJisRackIdFid());
if (rackId == null) {
MesPcnException.throwBusiException("工单[%s]客户排序信息无法匹配RackId!", workOrder.getWorkOrderNo());
}
Map<String, Object> result = new HashMap<>();
result.put(MesPcnExtConstWords.VOLVO_CONSIGNMENT_REFERENCE, rackId.getConsignmentReference());
result.put(MesPcnExtConstWords.PRODUCT_DATE, TimeTool.getNowTime("yyyyMMdd HH:mm"));
result.put(MesPcnExtConstWords.VOLVO_FYON, rackIdDetail.getFyon());
result.put(MesPcnExtConstWords.VOLVO_SEQUENCENUMBER, rackIdDetail.getSequenceNumber());
result.put(MesPcnExtConstWords.VOLVO_RACKID, rackId.getJisRackId());
result.put(MesPcnExtConstWords.VOLVO_POSITION, rackIdDetail.getPosition());
result.put(MesPcnExtConstWords.CUST_PART_NO, custSoftInfo.getCustPartNo());
result.put(MesPcnExtConstWords.PRINT_BAR_CODE, produceSn.getCustSn());
result.put(MesPcnExtConstWords.PRINT_DATE, TimeTool.getNowTime(true));
result.put(MesPcnExtConstWords.USER_NAME, produceSn.getCreateUser());
return result;
}
private Map<String, Object> packResultMap(MesProduceSnPrintModel printModel, List<Map<String, Object>> printTemplateDateList) {
Map<String, Object> resultMap = new HashMap<>();
resultMap.put(MesPcnExtConstWords.LABEL_TEMPLATE, printModel.getMesLabelTemplate());
resultMap.put(MesPcnExtConstWords.TEMPLATE_DATA, printTemplateDateList);
resultMap.put(MesPcnExtConstWords.TEMPLATE_CODE, printModel.getMesLabelTemplate().getTemplateCode());
resultMap.put(MesPcnExtConstWords.PRINTER, printModel.getPrinter());
return resultMap;
}
}

@ -0,0 +1,71 @@
package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.print.strategy;
import cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.print.IPrintTemplateStrategyService;
import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesProduceSnPrintModel;
import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtConstWords;
import cn.estsh.i3plus.pojo.mes.bean.MesNumberRule;
import cn.estsh.i3plus.pojo.mes.bean.MesWorkOrder;
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.stereotype.Component;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @Description :
* @Reference :
* @Author : wangjie
* @CreateDate : 2024/9/29 16:43
* @Modify:
**/
@Component
@Slf4j
public class CommonCustSnPrintStrategy implements IPrintTemplateStrategyService {
@Override
public MesProduceSnPrintModel execute(GenSerialNoModel genSerialNoModel, MesProduceSnPrintModel model,
MesNumberRule numberRule , StepResult stepResult, StationRequestBean reqBean,
Boolean isStep) {
MesWorkOrder workOrder = (MesWorkOrder) model.getSourceData();
if (workOrder == null) {
log.info("CommonCustSnPrintStrategy --- execute --- 工单信息为空");
return null;
}
// 返回的结果集合
List<Map<String, Object>> printDataMapList = new ArrayList<>();
// 单个标签参数值
Map<String, Object> resultMap = new HashMap<>();
// 物料名称
resultMap.put(MesPcnExtConstWords.PART_NAME, workOrder.getPartName());
// 物料名称
resultMap.put(MesPcnExtConstWords.CUST_PART_NO, workOrder.getCustPartNo());
// 客户条码
resultMap.put(MesPcnExtConstWords.CUST_SN, workOrder.getCustSn());
printDataMapList.add(resultMap);
model.setPrintContextList(packResultMapList(model, printDataMapList));
return model;
}
private List<Map<String, Object>> packResultMapList(MesProduceSnPrintModel printModel, List<Map<String, Object>> printTemplateDateList) {
List<Map<String, Object>> resultMapList = new ArrayList<>();
Map<String, Object> resultMap = new HashMap<>();
resultMap.put(MesPcnExtConstWords.LABEL_TEMPLATE, printModel.getMesLabelTemplate());
resultMap.put(MesPcnExtConstWords.TEMPLATE_DATA, printTemplateDateList);
resultMap.put(MesPcnExtConstWords.TEMPLATE_CODE, printModel.getMesLabelTemplate().getTemplateCode());
resultMap.put(MesPcnExtConstWords.PRINTER, printModel.getPrinter());
resultMapList.add(resultMap);
return resultMapList;
}
}

@ -0,0 +1,131 @@
package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.print.strategy;
import cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.print.IPrintTemplateStrategyService;
import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesProduceSnPrintModel;
import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtConstWords;
import cn.estsh.i3plus.platform.common.tool.TimeTool;
import cn.estsh.i3plus.pojo.base.bean.DdlPackBean;
import cn.estsh.i3plus.pojo.base.tool.DdlPreparedPack;
import cn.estsh.i3plus.pojo.mes.bean.*;
import cn.estsh.i3plus.pojo.mes.bean.shipping.MesCustSortInfo;
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 cn.estsh.i3plus.pojo.mes.repository.MesCustSoftInfoRepository;
import cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil;
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.*;
import java.util.stream.Collectors;
/**
* @Description : --
* @Reference :
* @Author : logic
* @CreateDate : 2025/3/13 16:07
* @Modify:
**/
@Component
@Slf4j
public class CqLxAssemblyVisualListPrintStrategy implements IPrintTemplateStrategyService {
@Autowired
private MesCustSoftInfoRepository mesCustSoftInfoRepository;
@Override
public MesProduceSnPrintModel execute(GenSerialNoModel genSerialNoModel, MesProduceSnPrintModel model, MesNumberRule numberRule , StepResult stepResult, StationRequestBean reqBean, Boolean isStep) {
Map<String, Object> modelMap = (Map<String, Object>) model.getSourceData();
// 工单信息
MesWorkOrder workOrder = (MesWorkOrder) modelMap.get("mesWorkOrder");
// 零件生产组信息
MesPartProdGroup partProdGroup = (MesPartProdGroup) modelMap.get("mesPartProdGroup");
// 客户车型配置信息
MesCustomerCarModel customerCarModel = modelMap.containsKey("mesCustomerCarModel") ? (MesCustomerCarModel) modelMap.get("mesCustomerCarModel") : null;
// 工单装配件信息
List<MesWorkOrderAssembly> workOrderAssemblyList = modelMap.containsKey("mesWorkOrderAssemblyList") ? (List<MesWorkOrderAssembly>) modelMap.get("mesWorkOrderAssemblyList") : null;
workOrderAssemblyList = CollectionUtils.isEmpty(workOrderAssemblyList) ? null :
workOrderAssemblyList.stream().filter(o -> (null != o && !StringUtils.isEmpty(o.getDisplaySeq()) && o.getDisplaySeq().compareTo(MesPcnExtConstWords.ZERO) != 0)).collect(Collectors.toList());
// 返回的结果集合
List<Map<String, Object>> printDataMapList = new ArrayList<>();
// 单个标签参数值
Map<String, Object> resultMap = new HashMap<>();
// 产线名称
resultMap.put(MesPcnExtConstWords.WORK_CENTER_NAME, workOrder.getWorkCenterName());
// 车型名称
resultMap.put(MesPcnExtConstWords.CAR_MODEL_NAME, customerCarModel == null ? "" : customerCarModel.getCarModelName());
DdlPackBean ddlPackBean = DdlPackBean.getDdlPackBean(workOrder.getOrganizeCode());
DdlPreparedPack.getStringEqualPack(workOrder.getVinCode(), "vinCode", ddlPackBean);
DdlPreparedPack.getStringEqualPack(workOrder.getCustPartNo(), "custPartNo", ddlPackBean);
MesCustSortInfo mesCustSortInfo = mesCustSoftInfoRepository.getByProperty(ddlPackBean);
if (!Objects.isNull(mesCustSortInfo)) {
// vinCode取值修改-45623 PCN-龙兴装配目视单模板取值调整mes_cust_sort_info 表的 info_point_code + cust_info_seq
resultMap.put(MesPcnExtConstWords.VIN_CODE, (mesCustSortInfo.getInfoPointCode() + mesCustSortInfo.getCustInfoSeq()));
// vinCode 后四位(取值修改-45623 PCN-龙兴装配目视单模板取值调整mes_cust_sort_info 的 cust_info_seq 的后四位,即工单表中的 workOrderSeq 字段)
resultMap.put(MesPcnExtConstWords.VIN_CODE_AFTER_FOUR,
!StringUtils.isEmpty(mesCustSortInfo.getCustInfoSeq()) &&
mesCustSortInfo.getCustInfoSeq().toString().length() > MesPcnExtConstWords.FOUR ?
mesCustSortInfo.getCustInfoSeq().toString().substring(mesCustSortInfo.getCustInfoSeq().toString().length() - MesPcnExtConstWords.FOUR) :
mesCustSortInfo.getCustInfoSeq());
}
// 总成零件号
resultMap.put(MesPcnExtConstWords.PART_NO, workOrder.getPartNo());
// 工单标识
resultMap.put(MesPcnExtConstWords.ORDER_FLAG, workOrder.getOrderFlag().equals(MesExtEnumUtil.ORDER_TYPE_IDENTIFICATION.PTR.getValue()) ? MesExtEnumUtil.ORDER_TYPE_IDENTIFICATION.P.getValue() : workOrder.getOrderFlag());
// 客户订单号
resultMap.put(MesPcnExtConstWords.CUST_ORDER_NO, workOrder.getCustOrderNo());
// 客户零件号
resultMap.put(MesPcnExtConstWords.CUST_PART_NO, workOrder.getCustPartNo());
// 客户条码
resultMap.put(MesPcnExtConstWords.SN, workOrder.getCustSn());
// 工单备注(取值修改-45623 PCN-龙兴装配目视单模板取值调整:取工单表中的 remark
resultMap.put(MesPcnExtConstWords.REMARK, workOrder.getRemark());
// 重打印
resultMap.put(MesPcnExtConstWords.REPRINT, "");
// EDI接口时间 取工单plan_start_time
resultMap.put(MesPcnExtConstWords.EDI_REC_TIME, workOrder.getPlanStartTime());
// 打印时间
resultMap.put(MesPcnExtConstWords.PRINT_TIME, TimeTool.getNowTime("yyyy-MM-dd HH:mm:ss"));
//替换总成SN
resultMap.put(MesPcnExtConstWords.REPLACE_CSN,MesPcnExtConstWords.REPLACE_CSN_CP+workOrder.getCustPartNo().substring(workOrder.getCustPartNo().length() -4));
Map<Integer, List<MesWorkOrderAssembly>> collect = CollectionUtils.isEmpty(workOrderAssemblyList) ? null : workOrderAssemblyList.stream().filter(o -> null != o).collect(Collectors.groupingBy(MesWorkOrderAssembly::getDisplaySeq));
// 为空时显示内容
String isNullViewContent = StringUtils.isEmpty(partProdGroup.getIsNullViewContent()) ? "" : partProdGroup.getIsNullViewContent();
for (int i = 1; i <= 9; i ++) {
List<MesWorkOrderAssembly> orderAssemblyList = CollectionUtils.isEmpty(collect) ? null : collect.get(i);
List<String> disPlayValues = CollectionUtils.isEmpty(orderAssemblyList) ? null :
(orderAssemblyList.stream().filter(o -> (null != o && !StringUtils.isEmpty(o.getDisplayValue()))).map(MesWorkOrderAssembly::getDisplayValue).collect(Collectors.toList()))
.stream().filter(o -> !StringUtils.isEmpty(o)).distinct().collect(Collectors.toList());
String displayValue = isNullViewContent;
if(!CollectionUtils.isEmpty(disPlayValues)){
displayValue = String.join("\r\n", disPlayValues);
}
resultMap.put(MesPcnExtConstWords.ASSEMBLY_PARAM + i, displayValue);
}
printDataMapList.add(resultMap);
model.setPrintContextList(packResultMapList(model, printDataMapList));
return model;
}
private List<Map<String, Object>> packResultMapList(MesProduceSnPrintModel printModel, List<Map<String, Object>> printTemplateDateList) {
List<Map<String, Object>> resultMapList = new ArrayList<>();
Map<String, Object> resultMap = new HashMap<>();
resultMap.put(MesPcnExtConstWords.LABEL_TEMPLATE, printModel.getMesLabelTemplate());
resultMap.put(MesPcnExtConstWords.TEMPLATE_DATA, printTemplateDateList);
resultMap.put(MesPcnExtConstWords.TEMPLATE_CODE, printModel.getMesLabelTemplate().getTemplateCode());
resultMap.put(MesPcnExtConstWords.PRINTER, printModel.getPrinter());
resultMapList.add(resultMap);
return resultMapList;
}
}

@ -114,7 +114,7 @@ public class LiJiaInterPartSnPrintStrategy implements IPrintTemplateStrategyServ
mesProduceSnPrintDataModel.setBarcode(produceSn.getProductSn());
mesProduceSnPrintDataModel.setPrintDate(TimeTool.getNowTime(true));
mesProduceSnPrintDataModel.setUserName(produceSn.getCreateUser());
mesProduceSnPrintDataModel.setProductDate(TimeTool.parseStringFormat(produceSn.getLotNo(), "", DateUtil.BASE_FORMAT));
mesProduceSnPrintDataModel.setProductDate(produceSn.getCreateDatetime());
return mesProduceSnPrintDataModel;
}
}

@ -0,0 +1,78 @@
package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.report;
import cn.estsh.i3plus.ext.mes.pcn.api.report.IMesCimSeresReportService;
import cn.estsh.i3plus.platform.common.tool.TimeTool;
import cn.estsh.i3plus.pojo.base.bean.DdlPackBean;
import cn.estsh.i3plus.pojo.base.bean.ListPager;
import cn.estsh.i3plus.pojo.base.common.Pager;
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.seres.MesCimSeresJisQueue;
import cn.estsh.i3plus.pojo.mes.bean.seres.MesCimSeresSrmRunSheetJis;
import cn.estsh.i3plus.pojo.mes.repository.seres.IMesCimSeresJisQueueRepository;
import cn.estsh.i3plus.pojo.mes.repository.seres.IMesCimSeresSrmRunSheetJisRepository;
import cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil;
import cn.estsh.impp.framework.boot.auth.AuthUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class MesCimSeresReportServiceImpl implements IMesCimSeresReportService {
@Autowired
private IMesCimSeresSrmRunSheetJisRepository runSheetJisRDao;
@Autowired
private IMesCimSeresJisQueueRepository queueJisRDao;
@Override
public ListPager<MesCimSeresSrmRunSheetJis> querySrmSunSheetJisLogByPager(Integer status, String docNo, Pager pager) {
final String organizeCode = AuthUtil.getOrganize().getOrganizeCode();
DdlPackBean packBean = DdlPackBean.getDdlPackBean(organizeCode);
DdlPreparedPack.getStringLikerPack(docNo, "docNo", packBean);
DdlPreparedPack.getNumEqualPack(status, "status", packBean);
DdlPreparedPack.getOrderBy("id", CommonEnumUtil.ASC_OR_DESC.DESC.getValue(), packBean);
pager = PagerHelper.getPager(pager, runSheetJisRDao.findByHqlWhereCount(packBean));
List<MesCimSeresSrmRunSheetJis> list = runSheetJisRDao.findByHqlWherePage(packBean, pager);
return new ListPager<>(list, pager);
}
@Override
public void doSrmSunSheetJisNormal(List<Long> ids) {
final String organizeCode = AuthUtil.getOrganize().getOrganizeCode();
final String username = AuthUtil.getSessionUser().getUserName();
DdlPackBean packBean = DdlPackBean.getDdlPackBean(organizeCode);
DdlPreparedPack.getInPackList(ids, "id", packBean);
runSheetJisRDao.updateByProperties(new String[]{"status","modifyUser","modifyDatetime"},new Object[]{MesExtEnumUtil.CIM_SERES_JIS_STATUS.WAIT_CHECK.getValue(), username, TimeTool.getNowTime(true)}, packBean);
}
@Override
public ListPager<MesCimSeresJisQueue> queryJisQueueLogByPager(Integer checkStatus, String vin, String materielCode, Pager pager) {
final String organizeCode = AuthUtil.getOrganize().getOrganizeCode();
DdlPackBean packBean = DdlPackBean.getDdlPackBean(organizeCode);
DdlPreparedPack.getStringLikerPack(vin, "vin", packBean);
DdlPreparedPack.getStringLikerPack(materielCode, "materielCode", packBean);
DdlPreparedPack.getNumEqualPack(checkStatus, "checkStatus", packBean);
DdlPreparedPack.getOrderBy("id", CommonEnumUtil.ASC_OR_DESC.DESC.getValue(), packBean);
pager = PagerHelper.getPager(pager, queueJisRDao.findByHqlWhereCount(packBean));
List<MesCimSeresJisQueue> list = queueJisRDao.findByHqlWherePage(packBean, pager);
return new ListPager<>(list, pager);
}
@Override
public void doJisQueueNormal(List<Long> ids) {
final String organizeCode = AuthUtil.getOrganize().getOrganizeCode();
final String username = AuthUtil.getSessionUser().getUserName();
DdlPackBean packBean = DdlPackBean.getDdlPackBean(organizeCode);
DdlPreparedPack.getInPackList(ids, "id", packBean);
queueJisRDao.updateByProperties(new String[]{"checkStatus","modifyUser","modifyDatetime"},new Object[]{MesExtEnumUtil.CIM_SERES_JIS_STATUS.WAIT_CHECK.getValue(), username, TimeTool.getNowTime(true)}, packBean);
}
}

@ -1,6 +1,7 @@
package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.rulematch;
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesEquipVariableCfgRuleMatchDispatchService;
import cn.estsh.i3plus.ext.mes.pcn.apiservice.util.BarCodeUtils;
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesEquipVariableCfgCollectContext;
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesEquipVariableCollectContext;
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProductionProcessContext;
@ -55,7 +56,7 @@ public class MesEvcRuleMatchBackValueService implements IMesEquipVariableCfgRule
String realEquipVariableValue = equipVariableCollectContext.getEquipVariableValue();
String equipVariableValue = StringUtils.removePattern(equipVariableCollectContext.getEquipVariableValue(), "[^A-Z^a-z0-9_^\\s^\\-^/^\\.^\\[^\\)^\\>^\\:]");
String equipVariableValue = BarCodeUtils.removePatternSpecialCharacter(equipVariableCollectContext.getEquipVariableValue());
return realEquipVariableValue.equals(equipVariableValue) ? equipVariableCollectContext : equipVariableCollectContext.replaceValue(realEquipVariableValue, equipVariableValue);

@ -154,7 +154,7 @@ public class MesFunctionPackagePartService extends BaseSwsService implements IFs
}
//返回提示信息
private Object packResultMap(StationRequestBean reqBean, StationResultBean resultBean, Map<String, Object> resultMap, String message) {
private Map<String, Object> packResultMap(StationRequestBean reqBean, StationResultBean resultBean, Map<String, Object> resultMap, String message) {
this.sendMessage(reqBean, resultBean, message, MesPcnEnumUtil.STATION_BUSI_TYPE.RUNNING_INFO, MesPcnEnumUtil.STATION_DATA_TYPE.EXP_TEXT);
resultMap.put(MesPcnExtConstWords.MESSAGE, message);
return resultMap;

@ -207,7 +207,7 @@ public class MesFunctionPackageProgressService extends BaseSwsService implements
}
//返回提示信息
private Object packResultMap(StationRequestBean reqBean, StationResultBean resultBean, Map<String, Object> resultMap, String message) {
private Map<String, Object> packResultMap(StationRequestBean reqBean, StationResultBean resultBean, Map<String, Object> resultMap, String message) {
this.sendMessage(reqBean, resultBean, message, MesPcnEnumUtil.STATION_BUSI_TYPE.RUNNING_INFO, MesPcnEnumUtil.STATION_DATA_TYPE.EXP_TEXT);
resultMap.put(MesPcnExtConstWords.MESSAGE, message);
return resultMap;

@ -3,14 +3,21 @@ package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.station.function;
import cn.estsh.i3plus.ext.mes.pcn.api.base.IMesEnumExtService;
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesProductionProcessContextStepService;
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesQueueOrderPushService;
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesWorkOrderExtService;
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.platform.common.tool.TimeTool;
import cn.estsh.i3plus.pojo.base.bean.DdlPackBean;
import cn.estsh.i3plus.pojo.base.bean.ListPager;
import cn.estsh.i3plus.pojo.base.common.Pager;
import cn.estsh.i3plus.pojo.base.common.PagerHelper;
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.MesQueueOrderPush;
import cn.estsh.i3plus.pojo.mes.bean.MesQueueOrderPushCellCfg;
import cn.estsh.i3plus.pojo.mes.bean.MesWorkOrder;
import cn.estsh.i3plus.pojo.mes.model.ButtonDynamicModel;
import cn.estsh.i3plus.pojo.mes.model.StationRequestBean;
import cn.estsh.i3plus.pojo.mes.model.StationResultBean;
@ -21,11 +28,9 @@ import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;
/**
* @Description :
@ -40,6 +45,9 @@ public class MesFunctionQueueOrderPushService extends BaseSwsService implements
private IMesQueueOrderPushService queueOrderPushService;
@Autowired
private IMesWorkOrderExtService workOrderExtService;
@Autowired
private IMesEnumExtService enumExtService;
@Override
@ -69,9 +77,12 @@ public class MesFunctionQueueOrderPushService extends BaseSwsService implements
resultBean.writeDbLog(MesPcnEnumUtil.WORK_CELL_SCAN_MONITOR_LOG_TYPE.PICK.getValue());
resultMap.put(MesPcnExtConstWords.DATA_TYPE, MesPcnEnumUtil.STATION_DATA_TYPE.EXP_TEXT.getValue());
if (BUSI_TYPE.TWO.value.equals(paramMap.get(MesPcnExtConstWords.BUSI_TYPE))) queryQueueOrderPush(reqBean, resultMap, paramMap);
else if (BUSI_TYPE.THREE.value.equals(paramMap.get(MesPcnExtConstWords.BUSI_TYPE))) queryQueueOrderPush(reqBean, resultMap, paramMap);
else queryQueueOrderPush(reqBean, resultMap, paramMap);
//新增
if (BUSI_TYPE.TWO.value.equals(paramMap.get(MesPcnExtConstWords.BUSI_TYPE))) insertQueueOrderPush(reqBean, resultBean, buttonDynamicModel, resultMap, paramMap);
//修改【仅支持修改顺序】
else if (BUSI_TYPE.THREE.value.equals(paramMap.get(MesPcnExtConstWords.BUSI_TYPE))) updateQueueOrderPush(reqBean, resultBean, buttonDynamicModel, resultMap, paramMap);
//关闭
else deleteQueueOrderPush(reqBean, resultBean, buttonDynamicModel, resultMap, paramMap);
if (!resultMap.containsKey(MesPcnExtConstWords.MESSAGE)) {
resultMap.put(MesPcnExtConstWords.DATA_TYPE, MesPcnEnumUtil.STATION_DATA_TYPE.TEXT.getValue());
@ -82,19 +93,24 @@ public class MesFunctionQueueOrderPushService extends BaseSwsService implements
}
private Object queryQueueOrderPush(StationRequestBean reqBean, Map<String, Object> resultMap, Map<String, String> paramMap) {
//查询
private Map<String, Object> queryQueueOrderPush(StationRequestBean reqBean, Map<String, Object> resultMap, Map<String, String> paramMap) {
String currentPage = paramMap.get(MesPcnExtConstWords.CURRENT_PAGE);
String pageSize = paramMap.get(MesPcnExtConstWords.PAGE_SIZE);
String pushSourceCode = paramMap.get(MesPcnExtConstWords.PUSH_SOURCE_CODE);
Pager pager = new Pager();
pager.setCurrentPage(paramMap.containsKey(MesPcnExtConstWords.CURRENT_PAGE) ? Integer.valueOf(paramMap.get(MesPcnExtConstWords.CURRENT_PAGE)) : MesPcnExtConstWords.ONE);
pager.setPageSize(paramMap.containsKey(MesPcnExtConstWords.PAGE_SIZE) ? Integer.valueOf(paramMap.get(MesPcnExtConstWords.PAGE_SIZE)) : MesPcnExtConstWords.FIFTY);
pager.setCurrentPage(!StringUtils.isEmpty(currentPage) ? Integer.valueOf(currentPage) : MesPcnExtConstWords.ONE);
pager.setPageSize(!StringUtils.isEmpty(currentPage) ? Integer.valueOf(pageSize) : MesPcnExtConstWords.FIFTY);
resultMap.put(MesPcnExtConstWords.QUEUE_STATUS, enumExtService.doGetMesEnumByEnumName(reqBean.getOrganizeCode(), MesExtEnumUtil.QUEUE_ORDER_STATUS.class.getSimpleName()));
//处理排序线推单上下文, 返回推送工位类型对应的配置信息 【来源工位】
//处理排序线推单上下文, 返回推送工位类型对应的配置信息 【目标工位】
List<MesQueueOrderPushCellCfg> queueOrderPushCellCfgList = productionProcessContextStepService.dispatchQueueOrderPushCellCfgContext(reqBean, MesExtEnumUtil.QUEUE_ORDER_CELL_PUSH_TYPE.TARGET.getValue());
List<String> pushSourceCodeList = (queueOrderPushCellCfgList.stream()
.filter(o -> (null != o && !StringUtils.isEmpty(o.getPushSourceCode()))).map(MesQueueOrderPushCellCfg::getPushSourceCode).collect(Collectors.toList())
).stream().filter(o -> !StringUtils.isEmpty(o)).distinct().collect(Collectors.toList());
List<String> pushSourceCodeList = CollectionUtils.isEmpty(queueOrderPushCellCfgList) ? null :
(queueOrderPushCellCfgList.stream().filter(o -> (null != o && !StringUtils.isEmpty(o.getPushSourceCode())))
.map(MesQueueOrderPushCellCfg::getPushSourceCode).collect(Collectors.toList())
).stream().filter(o -> !StringUtils.isEmpty(o)).distinct().collect(Collectors.toList());
if (!CollectionUtils.isEmpty(pushSourceCodeList)) resultMap.put(MesPcnExtConstWords.PUSH_SOURCE_CODE, pushSourceCodeList);
else {
@ -105,13 +121,113 @@ public class MesFunctionQueueOrderPushService extends BaseSwsService implements
paramMap.put(MesPcnExtConstWords.ORGANIZE_CODE, reqBean.getOrganizeCode());
//根据配置查询生产队列工位推送信息
resultMap.put(MesPcnExtConstWords.DATA, queueOrderPushService.queryQueueOrderPushListPager(paramMap, pushSourceCodeList, pager));
resultMap.put(MesPcnExtConstWords.DATA, queueOrderPushService.queryQueueOrderPushListPager(
paramMap, StringUtils.isEmpty(pushSourceCode) ? pushSourceCodeList : Stream.of(pushSourceCode).collect(Collectors.toList()), pager));
return resultMap;
}
//新增
private Map<String, Object> insertQueueOrderPush(StationRequestBean reqBean, StationResultBean resultBean,
ButtonDynamicModel buttonDynamicModel, Map<String, Object> resultMap, Map<String, String> paramMap) {
if (StringUtils.isEmpty(paramMap.get(MesPcnExtConstWords.PUSH_SOURCE_CODE))) {
return packResultMap(reqBean, resultBean, resultMap, String.format("[%s]新增:请选择推送来源代码!", buttonDynamicModel.getButtonName()));
}
if (StringUtils.isEmpty(paramMap.get(MesPcnExtConstWords.WORK_ORDER_NO))) {
return packResultMap(reqBean, resultBean, resultMap, String.format("[%s]新增:请扫描加工单或客户条码!", buttonDynamicModel.getButtonName()));
}
//处理排序线推单上下文, 返回推送工位类型对应的配置信息 【目标工位】
List<MesQueueOrderPushCellCfg> queueOrderPushCellCfg = productionProcessContextStepService.dispatchQueueOrderPushCellCfgContext(reqBean, MesExtEnumUtil.QUEUE_ORDER_CELL_PUSH_TYPE.TARGET.getValue());
Optional<MesQueueOrderPushCellCfg> optional = CollectionUtils.isEmpty(queueOrderPushCellCfg) ? null :
queueOrderPushCellCfg.stream().filter(o -> (null != o && o.getPushSourceCode().equals(paramMap.get(MesPcnExtConstWords.PUSH_SOURCE_CODE)))).findFirst();
if (null == optional || !optional.isPresent()) {
return packResultMap(reqBean, resultBean, resultMap, String.format("[%s]新增:当前工位未配置推送来源代码[%s]推送工位类型[%s]的配置信息!",
buttonDynamicModel.getButtonName(), paramMap.get(MesPcnExtConstWords.PUSH_SOURCE_CODE), MesExtEnumUtil.QUEUE_ORDER_CELL_PUSH_TYPE.TARGET.getDescription()));
}
//根据工单或者客户条码 查询生产工单信息(排序)
MesWorkOrder workOrder = (MesWorkOrder) workOrderExtService.getWorkOrderSort(reqBean.getOrganizeCode(), paramMap.get(MesPcnExtConstWords.WORK_ORDER_NO), true);
if (null == workOrder) {
return packResultMap(reqBean, resultBean, resultMap, String.format("[%s]新增:根据扫描信息[%s]未匹配到有效的加工单!", buttonDynamicModel.getButtonName(), paramMap.get(MesPcnExtConstWords.WORK_ORDER_NO)));
}
if (!MesExtEnumUtil.ORDER_STATUS.checkSortAllowStatus(workOrder.getWorkOrderStatus())) {
return packResultMap(reqBean, resultBean, resultMap, String.format("[%s]新增:加工单[%s]状态[%s],操作失败!",
buttonDynamicModel.getButtonName(), paramMap.get(MesPcnExtConstWords.WORK_ORDER_NO), MesExtEnumUtil.ORDER_STATUS.valueOfDescription(workOrder.getWorkOrderStatus())));
}
//写入工位工单推送信息
queueOrderPushService.insertQueueOrderPush(reqBean, workOrder, optional.get(), paramMap.get(MesPcnExtConstWords.PROCESS_SEQ_UP));
return resultMap;
}
//修改【仅支持修改顺序】
private Map<String, Object> updateQueueOrderPush(StationRequestBean reqBean, StationResultBean resultBean,
ButtonDynamicModel buttonDynamicModel, Map<String, Object> resultMap, Map<String, String> paramMap) {
if (StringUtils.isEmpty(paramMap.get(MesPcnExtConstWords.ID))) {
return packResultMap(reqBean, resultBean, resultMap, String.format("[%s]修改:缺少修改数据的ID参数!", buttonDynamicModel.getButtonName()));
}
if (StringUtils.isEmpty(paramMap.get(MesPcnExtConstWords.PROCESS_SEQ)) && StringUtils.isEmpty(paramMap.get(MesPcnExtConstWords.PROCESS_SEQ_UP)) && StringUtils.isEmpty(paramMap.get(MesPcnExtConstWords.PROCESS_SEQ_DOWN))) {
return packResultMap(reqBean, resultBean, resultMap, String.format("[%s]修改:缺少工艺顺序号!", buttonDynamicModel.getButtonName()));
}
//根据ID查询生产队列工位推送信息
MesQueueOrderPush queueOrderPush = queueOrderPushService.getQueueOrderPush(reqBean.getOrganizeCode(), Long.valueOf(paramMap.get(MesPcnExtConstWords.ID)));
if (null == queueOrderPush) {
return packResultMap(reqBean, resultBean, resultMap, String.format("[%s]修改:当前修改的队列ID[%s]对应的数据已不存在!", buttonDynamicModel.getButtonName(), paramMap.get(MesPcnExtConstWords.ID)));
}
if (queueOrderPush.getQueueStatus().compareTo(MesExtEnumUtil.QUEUE_ORDER_STATUS.CREATE.getValue()) != 0) {
return packResultMap(reqBean, resultBean, resultMap, String.format("[%s]修改:当前修改的队列信息状态为[%s],不支持修改操作!", buttonDynamicModel.getButtonName(), MesExtEnumUtil.QUEUE_ORDER_STATUS.valueOfDescription(queueOrderPush.getQueueStatus())));
}
//处理排序线推单上下文, 返回推送工位类型对应的配置信息 【目标工位】
List<MesQueueOrderPushCellCfg> queueOrderPushCellCfg = productionProcessContextStepService.dispatchQueueOrderPushCellCfgContext(reqBean, MesExtEnumUtil.QUEUE_ORDER_CELL_PUSH_TYPE.TARGET.getValue());
Optional<MesQueueOrderPushCellCfg> optional = CollectionUtils.isEmpty(queueOrderPushCellCfg) ? null :
queueOrderPushCellCfg.stream().filter(o -> (null != o && o.getPushSourceCode().equals(queueOrderPush.getPushSourceCode()))).findFirst();
if (null == optional || !optional.isPresent()) {
return packResultMap(reqBean, resultBean, resultMap, String.format("[%s]修改:当前工位未配置推送来源代码[%s]推送工位类型[%s]的配置信息!",
buttonDynamicModel.getButtonName(), paramMap.get(MesPcnExtConstWords.PUSH_SOURCE_CODE), MesExtEnumUtil.QUEUE_ORDER_CELL_PUSH_TYPE.TARGET.getDescription()));
}
Integer processSeq;
if (!StringUtils.isEmpty(paramMap.get(MesPcnExtConstWords.PROCESS_SEQ))) processSeq = Integer.valueOf(paramMap.get(MesPcnExtConstWords.PROCESS_SEQ));
else if (!StringUtils.isEmpty(paramMap.get(MesPcnExtConstWords.PROCESS_SEQ_UP))) processSeq = queueOrderPushService.getQueueOrderPushCalcSeq(reqBean.getOrganizeCode(), optional.get(), Integer.valueOf(paramMap.get(MesPcnExtConstWords.PROCESS_SEQ_UP)));
else processSeq = Integer.valueOf(paramMap.get(MesPcnExtConstWords.PROCESS_SEQ_DOWN)) + 1;
//根据条件修改生产队列工位推送信息
queueOrderPushService.saveQueueOrderPushByCondition(
new String[]{MesPcnExtConstWords.ORGANIZE_CODE, MesPcnExtConstWords.ID},
new Object[]{reqBean.getOrganizeCode(), Long.valueOf(paramMap.get(MesPcnExtConstWords.ID))},
new String[]{MesPcnExtConstWords.PROCESS_SEQ, MesPcnExtConstWords.MODIFY_USER, MesPcnExtConstWords.MODIFY_DATE_TIME, MesPcnExtConstWords.SYSTEM_SYNC_STATUS, MesPcnExtConstWords.SYSTEM_SYNC_DATE_TIME},
new Object[]{processSeq, reqBean.getUserInfo(), TimeTool.getNowTime(true), CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue(), MesPcnExtConstWords.EMPTY});
return resultMap;
}
//关闭
private Map<String, Object> deleteQueueOrderPush(StationRequestBean reqBean, StationResultBean resultBean,
ButtonDynamicModel buttonDynamicModel, Map<String, Object> resultMap, Map<String, String> paramMap) {
if (!paramMap.containsKey(MesPcnExtConstWords.ID)) {
return packResultMap(reqBean, resultBean, resultMap, String.format("[%s]关闭:缺少关闭数据的ID参数!", buttonDynamicModel.getButtonName()));
}
//根据ID查询生产队列工位推送信息
MesQueueOrderPush queueOrderPush = queueOrderPushService.getQueueOrderPush(reqBean.getOrganizeCode(), Long.valueOf(paramMap.get(MesPcnExtConstWords.ID)));
if (null == queueOrderPush) {
return packResultMap(reqBean, resultBean, resultMap, String.format("[%s]修改:当前关闭的队列ID[%s]对应的数据已不存在!", buttonDynamicModel.getButtonName(), paramMap.get(MesPcnExtConstWords.ID)));
}
if (queueOrderPush.getQueueStatus().compareTo(MesExtEnumUtil.QUEUE_ORDER_STATUS.CREATE.getValue()) != 0) {
return packResultMap(reqBean, resultBean, resultMap, String.format("[%s]修改:当前关闭的队列信息状态为[%s],不支持关闭操作!", buttonDynamicModel.getButtonName(), MesExtEnumUtil.QUEUE_ORDER_STATUS.valueOfDescription(queueOrderPush.getQueueStatus())));
}
//根据条件修改生产队列工位推送信息状态
DdlPackBean packBean = DdlPackBean.getDdlPackBean(reqBean.getOrganizeCode());
DdlPreparedPack.getNumEqualPack(Long.valueOf(paramMap.get(MesPcnExtConstWords.ID)), MesPcnExtConstWords.ID, packBean);
queueOrderPushService.saveQueueOrderPushStatusByDdlPackBean(packBean, reqBean.getUserInfo(), MesExtEnumUtil.QUEUE_ORDER_STATUS.CLOSED.getValue(), reqBean.getWorkCellCode());
return resultMap;
}
//返回提示信息
private Object packResultMap(StationRequestBean reqBean, StationResultBean resultBean, Map<String, Object> resultMap, String message) {
private Map<String, Object> packResultMap(StationRequestBean reqBean, StationResultBean resultBean, Map<String, Object> resultMap, String message) {
this.sendMessage(reqBean, resultBean, message, MesPcnEnumUtil.STATION_BUSI_TYPE.RUNNING_INFO, MesPcnEnumUtil.STATION_DATA_TYPE.EXP_TEXT);
resultMap.put(MesPcnExtConstWords.MESSAGE, message);
return resultMap;
@ -126,7 +242,7 @@ public class MesFunctionQueueOrderPushService extends BaseSwsService implements
THREE("3", "修改"),
FOUR("4", "取消");
FOUR("4", "关闭");
private String value;

@ -1,7 +1,6 @@
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.apiservice.serviceimpl.step.method.MesAssemblySaveSortStepService;
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.*;
import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtConstWords;
import cn.estsh.i3plus.mes.pcn.actor.shipping.dispatch.IFsmCommonService;

@ -1,7 +1,8 @@
package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.step.method;
package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.step;
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.util.MesPcnExtConstWords;
import cn.estsh.i3plus.mes.pcn.serviceimpl.fsm.BaseStepService;
@ -9,9 +10,12 @@ import cn.estsh.i3plus.platform.common.convert.ConvertBean;
import cn.estsh.i3plus.platform.common.tool.TimeTool;
import cn.estsh.i3plus.pojo.base.codemaker.SnowflakeIdMaker;
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
import cn.estsh.i3plus.pojo.base.enumutil.MesPcnEnumUtil;
import cn.estsh.i3plus.pojo.mes.bean.MesProductionAssembly;
import cn.estsh.i3plus.pojo.mes.bean.MesProductionAssemblyUnique;
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.MesProductionAssemblyUniqueRepository;
import cn.estsh.i3plus.pojo.mes.repository.MesWorkOrderAssemblyRepository;
@ -27,7 +31,7 @@ import java.util.*;
import java.util.stream.Collectors;
/**
* @Description :
* @Description :
* @Author : wangjie
**/
@Slf4j
@ -35,6 +39,9 @@ import java.util.stream.Collectors;
public class MesAssemblySaveSortStepService extends BaseStepService {
@Autowired
private IMesProductionProcessContextStepService productionProcessContextStepService;
@Autowired
private IMesProductionDispatchContextStepService productionDispatchContextStepService;
@Autowired
@ -52,6 +59,7 @@ public class MesAssemblySaveSortStepService extends BaseStepService {
@Autowired
private IMesProduceSnExtService produceSnExtService;
//保存排序线装配件
public List<MesProdRuleContext> saveSortProductionAssembly(StationRequestBean reqBean, List<MesProdRuleContext> prodRuleContextList, List<MesProductionPsOutContext> productionPsOutContextList, MesScanMonitorContext scanMonitorContext) {
Map<Integer, MesProductionPsOutContext> ppMap = CollectionUtils.isEmpty(productionPsOutContextList) ? null : productionPsOutContextList.stream().filter(o -> (null != o && !StringUtils.isEmpty(o.getForeignKey()))).collect(Collectors.toMap(MesProductionPsOutContext::getForeignKey, o -> o));
@ -106,15 +114,17 @@ public class MesAssemblySaveSortStepService extends BaseStepService {
} else {
productionAssemblyRepository.updateByProperties(
productionAssemblyRepository.updateByPropertiesNoSync(
new String[]{MesPcnExtConstWords.ID, MesPcnExtConstWords.ORGANIZE_CODE},
new Object[]{productionAssemblySortContext.getId(), reqBean.getOrganizeCode()},
new String[]{MesPcnExtConstWords.MODIFY_USER, MesPcnExtConstWords.MODIFY_DATE_TIME, MesPcnExtConstWords.SYSTEM_SYNC_STATUS,
MesPcnExtConstWords.ASSEMBLY_STATUS, MesPcnExtConstWords.ASSEMBLY_SN, MesPcnExtConstWords.IS_SKIP, MesPcnExtConstWords.MOULD_NO,
MesPcnExtConstWords.MOULD_RECORD_ID, MesPcnExtConstWords.PRODUCTION_RECORD_ID, MesPcnExtConstWords.REMARK},
MesPcnExtConstWords.SYSTEM_SYNC_DATE_TIME, MesPcnExtConstWords.ASSEMBLY_STATUS, MesPcnExtConstWords.ASSEMBLY_SN,
MesPcnExtConstWords.IS_SKIP, MesPcnExtConstWords.MOULD_NO, MesPcnExtConstWords.MOULD_RECORD_ID,
MesPcnExtConstWords.PRODUCTION_RECORD_ID, MesPcnExtConstWords.REMARK},
new Object[]{reqBean.getUserInfo(), TimeTool.getNowTime(true), CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue(),
productionAssemblySortContext.getAssemblyStatus(), productionAssemblySortContext.getAssemblySn(), productionAssemblySortContext.getIsSkip(), mouldNo,
mouldRecordId, prodRuleContext.getProductionRecordId(), getRemark(reqBean.getWorkCellCode(), productionAssemblySortContext.getWorkCellCode(), productionAssemblySortContext.getPaRemark())});
MesPcnExtConstWords.EMPTY, productionAssemblySortContext.getAssemblyStatus(), productionAssemblySortContext.getAssemblySn(),
productionAssemblySortContext.getIsSkip(), mouldNo, mouldRecordId,
prodRuleContext.getProductionRecordId(), getRemark(reqBean.getWorkCellCode(), productionAssemblySortContext.getWorkCellCode(), productionAssemblySortContext.getPaRemark())});
}
@ -163,12 +173,53 @@ public class MesAssemblySaveSortStepService extends BaseStepService {
}
private void saveWorkOrderAssembly(StationRequestBean reqBean, MesProductionAssemblySortContext productionAssemblySortContext) {
workOrderAssemblyRepository.updateByProperties(
workOrderAssemblyRepository.updateByPropertiesNoSync(
new String[]{MesPcnExtConstWords.ID, MesPcnExtConstWords.ORGANIZE_CODE},
new Object[]{productionAssemblySortContext.getSourceId(), reqBean.getOrganizeCode()},
new String[]{MesPcnExtConstWords.MODIFY_USER, MesPcnExtConstWords.MODIFY_DATE_TIME, MesPcnExtConstWords.SYSTEM_SYNC_STATUS, MesPcnExtConstWords.ASSEMBLY_STATUS, MesPcnExtConstWords.REMARK},
new Object[]{reqBean.getUserInfo(), TimeTool.getNowTime(true), CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue(), productionAssemblySortContext.getAssemblyStatus(),
new String[]{MesPcnExtConstWords.MODIFY_USER, MesPcnExtConstWords.MODIFY_DATE_TIME, MesPcnExtConstWords.SYSTEM_SYNC_STATUS,
MesPcnExtConstWords.SYSTEM_SYNC_DATE_TIME, MesPcnExtConstWords.ASSEMBLY_STATUS, MesPcnExtConstWords.REMARK},
new Object[]{reqBean.getUserInfo(), TimeTool.getNowTime(true), CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue(),
MesPcnExtConstWords.EMPTY, productionAssemblySortContext.getAssemblyStatus(),
getRemark(reqBean.getWorkCellCode(), productionAssemblySortContext.getWorkCellCode(), productionAssemblySortContext.getWoaRemark())});
}
//删除平行工位的装配件
@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<MesProdRuleContext> prodRuleContextList = productionDispatchContextStepService.getProdRuleDataContext(reqBean);
if (CollectionUtils.isEmpty(prodRuleContextList)) stepExpSendMsgAndThrowEx(reqBean, resultBean.writeDbLog(), "当前不存在非排序加工规则数据,请重置工序!");
for (MesProdRuleContext prodRuleContext : prodRuleContextList) {
if (null == prodRuleContext || StringUtils.isEmpty(prodRuleContext.getAssemblyDataJson())) continue;
List<MesProductionAssemblySortContext> productionAssemblySortContextList = prodRuleContext.getSortAssemblyDataContext();
int count = workOrderAssemblyRepository.updateByPropertiesNoSync(
new String[]{MesPcnExtConstWords.ORGANIZE_CODE, MesPcnExtConstWords.WORK_ORDER_NO, MesPcnExtConstWords.CRAFT_CODE, MesPcnExtConstWords.PROCESS_SEQ, MesPcnExtConstWords.ASSEMBLY_STATUS},
new Object[]{reqBean.getOrganizeCode(), prodRuleContext.getWorkOrderNo(), productionProcessContext.getCraftCode(), productionAssemblySortContextList.get(0).getProcessSeq(), MesExtEnumUtil.ASSEMBLY_STATUS.ASSEMBLY_STATUS_30.getValue()},
new String[]{MesPcnExtConstWords.MODIFY_USER, MesPcnExtConstWords.MODIFY_DATE_TIME, MesPcnExtConstWords.SYSTEM_SYNC_STATUS,
MesPcnExtConstWords.SYSTEM_SYNC_DATE_TIME, MesPcnExtConstWords.IS_VALID, MesPcnExtConstWords.REMARK},
new Object[]{reqBean.getUserInfo(), TimeTool.getNowTime(true), CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue(),
MesPcnExtConstWords.EMPTY, CommonEnumUtil.IS_VAILD.INVAILD.getValue(), String.format("平行工位[%s]标记无效!", reqBean.getWorkCellCode())});
this.sendMessage(reqBean, resultBean.writeDbLog(), String.format("加工单[%s]在工位[%s]标记平行工位的装配件条数[%s]",
prodRuleContext.getWorkOrderNo(), reqBean.getWorkCellCode(), count), MesPcnEnumUtil.STATION_BUSI_TYPE.RUNNING_INFO, MesPcnEnumUtil.STATION_DATA_TYPE.TEXT);
}
return stepResult;
}
}

@ -391,7 +391,6 @@ public class MesAssemblyShowNosortStepService extends BaseStepService {
return stepNonCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog().scanInfo(productionPsInContext.getProductSn()), stepResult, String.format("主条码[%s]零件号[%s]关联的加工单[%s]与产出零件[%s]关联的加工单[%s]不一致!",
productionPsInContext.getProductSn(), productionPsInContext.getPartNo(), productionPsInContext.getWorkOrderNo(), productionPartContext.getPartNo(), productionPartContext.getWorkOrderNo()));
}
//进料存在工单且已经过某工序生产, 不能匹配无工单的产出零件
if (StringUtils.isEmpty(productionPartContext.getWorkOrderNo()) && !StringUtils.isEmpty(productionPsInContext.getWorkOrderNo()) && !StringUtils.isEmpty(productionPsInContext.getProcessCode())) {
if (productionPsInContext.getMessageSource().compareTo(MesExtEnumUtil.CELL_MESSAGE_SOURCE.SCAN.getValue()) == 0) productionPsInContext.busiCheckToDelete();

@ -3,7 +3,6 @@ package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.step;
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesProdRuleCfgExtService;
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.MesAssemblySaveSortStepService;
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.*;
import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtConstWords;
import cn.estsh.i3plus.mes.pcn.actor.shipping.dispatch.IFsmCommonService;

@ -2,22 +2,22 @@ package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.step;
import cn.estsh.i3plus.ext.mes.pcn.api.base.IMesTemplateService;
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.print.IPrintTemplateStrategyService;
import cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.step.method.MesPartDataMapSaveStepService;
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProdRuleContext;
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProductionPsOutContext;
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.base.IConfigService;
import cn.estsh.i3plus.mes.pcn.serviceimpl.fsm.BaseStepService;
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.enumutil.MesPcnEnumUtil;
import cn.estsh.i3plus.pojo.base.tool.DdlPreparedPack;
import cn.estsh.i3plus.pojo.mes.bean.MesLabelTemplate;
import cn.estsh.i3plus.pojo.mes.bean.MesPrintedSnLog;
import cn.estsh.i3plus.pojo.mes.bean.MesProdRouteOptParam;
import cn.estsh.i3plus.pojo.mes.bean.MesProduceSn;
import cn.estsh.i3plus.pojo.mes.bean.*;
import cn.estsh.i3plus.pojo.mes.model.StationRequestBean;
import cn.estsh.i3plus.pojo.mes.model.StationResultBean;
import cn.estsh.i3plus.pojo.mes.model.StepResult;
@ -44,6 +44,9 @@ import java.util.stream.Collectors;
public class MesProductSnPrintNosortStepService extends BaseStepService {
@Autowired
private IMesProductionProcessContextStepService productionProcessContextStepService;
@Autowired
private IMesProductionDispatchContextStepService productionDispatchContextStepService;
@Autowired
@ -54,6 +57,12 @@ public class MesProductSnPrintNosortStepService extends BaseStepService {
@Autowired
private MesProduceSnRepository mesProduceSnRao;
@Autowired
private IConfigService configService;
@Autowired
private MesPartDataMapSaveStepService partDataMapSaveStepService;
@Override
public StepResult execute(StationRequestBean reqBean) {
// /**
@ -78,8 +87,16 @@ public class MesProductSnPrintNosortStepService extends BaseStepService {
return stepSuccessCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(MesPcnEnumUtil.WORK_CELL_SCAN_MONITOR_LOG_TYPE.PROCESS.getValue()), stepResult, String.format("打印失败:%s!", MesExtEnumUtil.PRODUCT_RESULT_EQUIP_PARAM.codeOfDescription(productResult)));
// 根据foreign找出加工规则对应的上下文判断是否需要打印
List<MesProdRuleContext> prodRuleDataContext = productionDispatchContextStepService.getProdRuleDataContext(reqBean);
Map<Integer, List<MesProdRuleContext>> prodRuleContextMap = prodRuleDataContext.stream().collect(Collectors.groupingBy(MesProdRuleContext::getForeignKey));
List<MesProdRuleContext> prodRuleDataContextList = productionDispatchContextStepService.getProdRuleDataContext(reqBean);
Map<Integer, List<MesProdRuleContext>> prodRuleContextMap = prodRuleDataContextList.stream().collect(Collectors.groupingBy(MesProdRuleContext::getForeignKey));
//生产过程控制非排序打印机配置【物料级别=1, 默认打印机=2】
Boolean pcNosortPrinterCfg = getPcNosortPrinterCfg(reqBean.getOrganizeCode());
//保存零件数据信息
Map<String, MesPart> partDataMap = savePartDataMap(reqBean, resultBean, stepResult, prodRuleDataContextList, pcNosortPrinterCfg);
//处理工位零件打印机配置
List<MesWorkCellPartPrinterCfg> workCellPartPrinterCfgList = productionProcessContextStepService.disPatchWorkCellPartPrinterCfg(reqBean, pcNosortPrinterCfg);
//需要打印的数据 String 是打印模板code
Map<String, List<MesProduceSnPrintDataModel>> resultData = new HashMap<>();
//用于保存客户模板代码 和 模板信息关系
@ -117,6 +134,11 @@ public class MesProductSnPrintNosortStepService extends BaseStepService {
mesProduceSnPrintModel.setCustPartNo(sn.getCustPartNo());
mesProduceSnPrintModel.setOrganizeCode(organizeCode);
mesProduceSnPrintModel.setUserName(reqBean.getUserInfo());
if (pcNosortPrinterCfg) {
//赋值打印机
String printer = filterPrinter(reqBean, workCellPartPrinterCfgList, partDataMap, sn.getPartNo());
if (!StringUtils.isEmpty(printer)) mesProduceSnPrintModel.setPrinter(printer);
}
List<MesProduceSn> snList = new ArrayList<>();
snList.add(sn);
mesProduceSnPrintModel.getMesProduceSnList().addAll(snList);
@ -172,6 +194,39 @@ public class MesProductSnPrintNosortStepService extends BaseStepService {
return stepSuccessCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(MesPcnEnumUtil.WORK_CELL_SCAN_MONITOR_LOG_TYPE.PROCESS.getValue()), stepResult, "打印成功!");
}
//获取打印机
private String filterPrinter(StationRequestBean reqBean, List<MesWorkCellPartPrinterCfg> workCellPartPrinterCfgList, Map<String, MesPart> partDataMap, String partNo) {
String priter = null;
if (!CollectionUtils.isEmpty(workCellPartPrinterCfgList)) {
Optional<MesWorkCellPartPrinterCfg> optional = workCellPartPrinterCfgList.stream().filter(o -> (null != o
&& !StringUtils.isEmpty(o.getWorkCenterCode()) && o.getWorkCenterCode().equals(reqBean.getWorkCenterCode())
&& !StringUtils.isEmpty(o.getWorkCellCode()) && o.getWorkCellCode().equals(reqBean.getWorkCellCode())
&& !StringUtils.isEmpty(o.getPartNo()) && o.getPartNo().equals(partNo) && !StringUtils.isEmpty(o.getPrinterCode()))).findFirst();
if (null != optional && optional.isPresent()) priter = optional.get().getPrinterCode();
}
if (StringUtils.isEmpty(priter) && !CollectionUtils.isEmpty(partDataMap) && partDataMap.containsKey(partNo)) {
priter = partDataMap.get(partNo).getProductPrinterCode();
}
return priter;
}
//保存零件数据信息
private Map<String, MesPart> savePartDataMap(StationRequestBean reqBean, StationResultBean resultBean, StepResult stepResult, List<MesProdRuleContext> prodRuleDataContextList, Boolean pcNosortPrinterCfg) {
if (!pcNosortPrinterCfg) return null;
//获取上下文零件数据信息
List<String> partNoList = (prodRuleDataContextList.stream().filter(o -> (null != o && !StringUtils.isEmpty(o.getOutPartNo()))).map(MesProdRuleContext::getOutPartNo).collect(Collectors.toList())).stream().filter(o -> !StringUtils.isEmpty(o)).distinct().collect(Collectors.toList());
//保存零件数据信息
partDataMapSaveStepService.savePartDataMap(reqBean, resultBean, stepResult, partNoList, true, false);
return stepResult.isCompleted() ? (Map<String, MesPart>) stepResult.getObj() : null;
}
//生产过程控制非排序打印机配置【物料级别=1, 默认打印机=2】
private Boolean getPcNosortPrinterCfg(String organizeCode) {
List<MesConfig> config = configService.doCachedConfigList(MesPcnExtConstWords.PRODUCTION_CONTROL_NOSORT_PRINTER_CFG, organizeCode);
if (CollectionUtils.isEmpty(config) || StringUtils.isEmpty(config.get(0).getCfgValue())) return false;
return config.get(0).getCfgValue().equals(CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValueStr()) ? true : false;
}
//验证加工结果是否满足参数条件: 可疑/报废是否打印
private Boolean checkIsMatchProdResult(StationRequestBean reqBean, String productResult, MesExtEnumUtil.PRODUCT_RESULT_EQUIP_PARAM prodResultEnum) {

@ -125,7 +125,7 @@ public class MesProductSnPrintSortStepService extends BaseStepService {
// 根据工单号获取工单信息
MesWorkOrder workOrder = workOrderMap.get(productionPartContext.getWorkOrderNo());
if (null == workOrder) stepExpSendMsgAndThrowEx(reqBean, resultBean, String.format("工单号:{}无效!", productionPartContext.getWorkOrderNo()));
if (null == workOrder) stepExpSendMsgAndThrowEx(reqBean, resultBean, String.format("工单号[%s]信息不存在!", productionPartContext.getWorkOrderNo()));
if (CollectionUtils.isEmpty(partDataContext) || !partDataContext.containsKey(workOrder.getPartNo()))
stepExpSendMsgAndThrowEx(reqBean, resultBean, String.format("工单号[%s]零件号[%s]丢失零件信息缓存!", productionPartContext.getWorkOrderNo(), productionPartContext.getPartNo()));

@ -248,7 +248,8 @@ public class MesProductSnScanStepService extends BaseStepService {
private Boolean checkIsExistRepeatScan(MesProductionProcessContext productionProcessContext, List<MesEquipVariableCollectContext> equipVariableCollectContextList, List<MesProductionPsInContext> productionPsInContextList) {
//扫描条码
List<String> filterList1 = equipVariableCollectContextList.stream().filter(o -> null != o).map(MesEquipVariableCollectContext::getEquipVariableValue).collect(Collectors.toList());
List<String> filterList1 = CollectionUtils.isEmpty(equipVariableCollectContextList) ? null :
equipVariableCollectContextList.stream().filter(o -> null != o).map(MesEquipVariableCollectContext::getEquipVariableValue).collect(Collectors.toList());
//已验证条码 剔除finishCode信息
List<String> filterList2 = CollectionUtils.isEmpty(productionPsInContextList) ? null :
productionPsInContextList.stream().filter(o -> (null != o && o.getIsFinishCode().compareTo(CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue()) == 0)).map(MesProductionPsInContext::getProductSn).collect(Collectors.toList());

@ -12,6 +12,11 @@ import cn.estsh.impp.framework.boot.util.SpringContextsUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import java.util.LinkedList;
import java.util.stream.Collectors;
import java.util.stream.Stream;
/**
* @Description :
@ -24,34 +29,38 @@ public class MesProductionDataSaveStepService extends BaseStepService {
@Autowired
public IMesProductionProcessContextStepService productionProcessContextStepService;
@Override
public StepResult execute(StationRequestBean reqBean) {
//是否排序线
Boolean isSort = MesExtEnumUtil.WORK_CENTER_TYPE.SORT.getValue() == productionProcessContextStepService.getCenterType(reqBean) ? true : false;
//【非排序线】保存结果结果工步集合
//保存开模记录工步>>保存零件条码信息工步>>加工异常处理工步>>生成加工记录工步>>保存装配记录工步>>保存工单信息工步
private static final LinkedList<String> noSortStepList = new LinkedList<>(Stream.of(
"mesMouldRecordGenerateStepService", "mesProductSnSaveStepService", "mesProductResultErrorHandleStepService",
"mesProductionRecordGenerateStepService", "mesAssemblySaveStepService", "mesWorkOrderSaveStepService").collect(Collectors.toList()));
//保存开模记录工步
((IStepService) SpringContextsUtil.getBean("mesMouldRecordGenerateStepService")).executeInState(reqBean);
//【排序线】保存结果结果工步集合
//保存开模记录工步>>保存零件条码信息工步>>保存工位队列信息工步>>加工异常处理工步>>生成加工记录工步>>保存工单信息工步
private static final LinkedList<String> sortStepList = new LinkedList<>(Stream.of(
"mesMouldRecordGenerateStepService", "mesProductSnSaveStepService", "mesWorkOrderQueueSaveStepService",
"mesProductResultErrorHandleStepService", "mesProductionRecordGenerateStepService", "mesWorkOrderSaveStepService").collect(Collectors.toList()));
//保存零件条码信息工步
((IStepService) SpringContextsUtil.getBean("mesProductSnSaveStepService")).executeInState(reqBean);
//保存工位队列信息工步 【排序】
if (isSort) ((IStepService) SpringContextsUtil.getBean("mesWorkOrderQueueSaveStepService")).executeInState(reqBean);
@Override
public StepResult execute(StationRequestBean reqBean) {
//加工异常处理工步
((IStepService) SpringContextsUtil.getBean("mesProductResultErrorHandleStepService")).executeInState(reqBean);
StationResultBean resultBean = new StationResultBean();
//生成加工记录工步
((IStepService) SpringContextsUtil.getBean("mesProductionRecordGenerateStepService")).executeInState(reqBean);
StepResult stepResult = StepResult.getSuccessComplete();
//保存装配记录工步 【非排序】
if (!isSort)((IStepService) SpringContextsUtil.getBean("mesAssemblySaveStepService")).executeInState(reqBean);
//根据生产线类型赋值工步集合
Boolean isSort = MesExtEnumUtil.WORK_CENTER_TYPE.SORT.getValue() == productionProcessContextStepService.getCenterType(reqBean) ? true : false;
LinkedList<String> stepList = !isSort ? noSortStepList : sortStepList;
//保存工单信息工步
((IStepService) SpringContextsUtil.getBean("mesWorkOrderSaveStepService")).executeInState(reqBean);
for (String stepService : stepList) {
if (StringUtils.isEmpty(stepResult)) continue;
StepResult innerStepResult = ((IStepService) SpringContextsUtil.getBean(stepService)).executeInState(reqBean);
if (!StringUtils.isEmpty(innerStepResult.getNextTriggerEvent())) stepResult.nextTriggerEvent(innerStepResult.getNextTriggerEvent());
if (!StringUtils.isEmpty(innerStepResult.getStepAfterState())) stepResult.stepAfterState(innerStepResult.getStepAfterState());
if (!innerStepResult.isCompleted()) return stepNonCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(MesPcnEnumUtil.WORK_CELL_SCAN_MONITOR_LOG_TYPE.PROCESS.getValue()), stepResult, "保存加工结果失败!");
}
return stepSuccessCompleteAndSendMsgReturn(reqBean, new StationResultBean().writeDbLog(MesPcnEnumUtil.WORK_CELL_SCAN_MONITOR_LOG_TYPE.PROCESS.getValue()), "保存加工结果成功!");
return stepSuccessCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(MesPcnEnumUtil.WORK_CELL_SCAN_MONITOR_LOG_TYPE.PROCESS.getValue()), stepResult, "保存加工结果成功!");
}

@ -0,0 +1,84 @@
package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.step;
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.MesEquipVariableCollectContext;
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProductionProcessContext;
import cn.estsh.i3plus.mes.pcn.serviceimpl.fsm.BaseStepService;
import cn.estsh.i3plus.pojo.base.enumutil.MesPcnEnumUtil;
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.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import java.util.ArrayList;
import java.util.List;
/**
* @Description :
* @Reference :
* @Author : wangjie
* @CreateDate 2024/9/11 13:53
* @Modify:
**/
@Slf4j
@Service("mesRecyclablePackageScanStepService")
public class MesRecyclablePackageScanStepService extends BaseStepService {
@Autowired
private IMesProductionProcessContextStepService productionProcessContextStepService;
@Autowired
private IMesProductionDispatchContextStepService productionDispatchContextStepService;
@Autowired
private IMesProductionCustomContextStepService productionCustomContextStepService;
@Override
public StepResult execute(StationRequestBean reqBean) {
StationResultBean resultBean = new StationResultBean();
StepResult stepResult = StepResult.getSuccessComplete();
//获取上下文信息
MesProductionProcessContext productionProcessContext = productionProcessContextStepService.dispatchCurCellEquipment(reqBean);
//当前工序已存在读取待验证的可回用包装条码信息
if (productionDispatchContextStepService.checkScanRecyclablePackageIsExistContext(reqBean)) return stepResult;
//存储生产过程上下文对象
productionProcessContextStepService.dispatchProductionProcessContext(reqBean, productionProcessContext);
if (StringUtils.isEmpty(reqBean.getScanInfo())) stepSendGuideAndThrowEx(reqBean, resultBean.writeDbLog(MesPcnEnumUtil.WORK_CELL_SCAN_MONITOR_LOG_TYPE.PROCESS.getValue()), "请扫描可回用包装条码!");
doHandleScanRecyclablePackageContext(reqBean, stepResult, reqBean.getScanInfo());
return stepSuccessCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(MesPcnEnumUtil.WORK_CELL_SCAN_MONITOR_LOG_TYPE.SCAN.getValue()).scanInfo(reqBean.getScanInfo()), stepResult, stepResult.getMsg());
}
//封装可回用包装条码信息 (扫描)
private List<MesEquipVariableCollectContext> doHandleScanRecyclablePackageContext(StationRequestBean reqBean, StepResult stepResult, String scanInfo) {
List<MesEquipVariableCollectContext> equipVariableCollectContextList = new ArrayList<>();
equipVariableCollectContextList.add(new MesEquipVariableCollectContext(reqBean.getOrganizeCode(), scanInfo, MesExtEnumUtil.CELL_MESSAGE_SOURCE.SCAN.getValue()));
//保存设备当前一轮工序的待验证的可回用包装条码信息
productionDispatchContextStepService.dispatchScanRecyclablePackageContext(reqBean, equipVariableCollectContextList);
//发送工步内容
productionCustomContextStepService.sendStepContextMessage(reqBean, scanInfo, MesExtEnumUtil.CELL_MESSAGE_SOURCE.SCAN);
stepResult.msg(String.format("当前扫描信息可回用包装条码[%s]!", scanInfo));
return equipVariableCollectContextList;
}
}

@ -26,11 +26,9 @@ 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.Optional;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;
/**
* @Description :
@ -78,8 +76,11 @@ public class MesSendEquipParamsCmdStepService extends BaseStepService {
//获取生产线信息
MesWorkCenter workCenter = productionProcessContext.getWorkCenter();
//搜集数据:根据数据关联键分组加工参数关联ID集合
Map<Integer, List<Long>> sourceIdMap2ForeignKey = new HashMap<>();
//搜集加工参数关联ID集合 根据生产线类型区分
List<Long> sourceIdList = getEquipmentProdParamCfgSourceIdList(productionProcessContext, prodRuleContextList, workCenter);
List<Long> sourceIdList = getEquipmentProdParamCfgSourceIdList(productionProcessContext, prodRuleContextList, workCenter, sourceIdMap2ForeignKey);
//根据来源ID查询设备加工参数信息
List<MesEquipmentProdParamCfg> equipmentProdParamCfgList = equipmentProdParamCfgService.getEquipmentProdParamCfgList(reqBean.getOrganizeCode(), sourceIdList);
@ -123,7 +124,7 @@ public class MesSendEquipParamsCmdStepService extends BaseStepService {
productionPsOutContexts.stream().filter(i -> (null != i && !StringUtils.isEmpty(i.getForeignKey()) && i.getForeignKey().compareTo(o.getForeignKey()) == 0)).findFirst();
doSendEquipParamsCmd(reqBean, resultBean, o, cellEquipContext, eppcMap2SourceId, evMap, productResult, productionPartContextOp, productionPsInContextOp, productionPsOutContextOp);
doSendEquipParamsCmd(reqBean, resultBean, o, sourceIdMap2ForeignKey.get(o.getForeignKey()), cellEquipContext, eppcMap2SourceId, evMap, productResult, productionPartContextOp, productionPsInContextOp, productionPsOutContextOp);
});
@ -131,18 +132,24 @@ public class MesSendEquipParamsCmdStepService extends BaseStepService {
}
//搜集加工参数关联ID集合
private List<Long> getEquipmentProdParamCfgSourceIdList(MesProductionProcessContext productionProcessContext, List<MesProdRuleContext> prodRuleContextList, MesWorkCenter workCenter) {
private List<Long> getEquipmentProdParamCfgSourceIdList(MesProductionProcessContext productionProcessContext, List<MesProdRuleContext> prodRuleContextList, MesWorkCenter workCenter, Map<Integer, List<Long>> sourceIdMap2ForeignKey) {
if (MesExtEnumUtil.WORK_CENTER_TYPE.NOSORT.getValue() == workCenter.getCenterType()) {
//非排序
return prodRuleContextList.stream().filter(o -> (null != o && !StringUtils.isEmpty(o.getPid()))).map(MesProdRuleContext::getPid).collect(Collectors.toList());
List<Long> sourceIdList = new ArrayList<>();
prodRuleContextList.stream().filter(o -> (null != o && !StringUtils.isEmpty(o.getPid()))).forEach(o -> {
sourceIdMap2ForeignKey.put(o.getForeignKey(), Stream.of(o.getPid()).collect(Collectors.toList()));
sourceIdList.add(o.getPid());
});
return sourceIdList;
} else {
//排序
List<Long> sourceIdList = null;
for (MesProdRuleContext prodRuleContext : prodRuleContextList) {
if (StringUtils.isEmpty(prodRuleContext.getAssemblyDataJson())) continue;
List<Long> itemIdList = prodRuleContext.getSortAssemblyDataContext().stream().filter(o -> (null != o && !StringUtils.isEmpty(o.getSourceId()))).map(MesProductionAssemblySortContext::getSourceId).collect(Collectors.toList());
List<Long> itemIdList = prodRuleContext.getSortAssemblyDataContext().stream().filter(o -> (null != o && !StringUtils.isEmpty(o.getPid()))).map(MesProductionAssemblySortContext::getPid).collect(Collectors.toList());
if (CollectionUtils.isEmpty(itemIdList)) continue;
if (CollectionUtils.isEmpty(sourceIdList)) sourceIdList = new ArrayList<>();
sourceIdMap2ForeignKey.put(prodRuleContext.getForeignKey(), itemIdList);
sourceIdList.addAll(itemIdList);
}
return sourceIdList;
@ -150,57 +157,65 @@ public class MesSendEquipParamsCmdStepService extends BaseStepService {
}
//发送设备加工参数
private void doSendEquipParamsCmd(StationRequestBean reqBean, StationResultBean resultBean, MesProdRuleContext prodRuleContext, MesCellEquipContext cellEquipContext,
Map<Long, List<MesEquipmentProdParamCfg>> eppcMap2SourceId, Map<Long, MesEquipmentVariable> evMap, String productResult,
Optional<MesProductionPartContext> productionPartContextOp, Optional<MesProductionPsInContext> productionPsInContextOp, Optional<MesProductionPsOutContext> productionPsOutContextOp) {
private void doSendEquipParamsCmd(StationRequestBean reqBean, StationResultBean resultBean, MesProdRuleContext prodRuleContext, List<Long> sourceIdList, MesCellEquipContext cellEquipContext,
Map<Long, List<MesEquipmentProdParamCfg>> eppcMap2SourceId, Map<Long, MesEquipmentVariable> evMap, String productResult,
Optional<MesProductionPartContext> productionPartContextOp, Optional<MesProductionPsInContext> productionPsInContextOp, Optional<MesProductionPsOutContext> productionPsOutContextOp) {
//当前加工规则的PID对应的设备加工参数
List<MesEquipmentProdParamCfg> equipmentProdParamCfgList = eppcMap2SourceId.get(prodRuleContext.getPid());
if (CollectionUtils.isEmpty(sourceIdList)) return;
if (CollectionUtils.isEmpty(equipmentProdParamCfgList)) return;
for (Long sourceId : sourceIdList) {
MesProductionPartContext productionPartContext = (null != productionPartContextOp && productionPartContextOp.isPresent()) ? productionPartContextOp.get() : null;
if (StringUtils.isEmpty(sourceId)) continue;
MesProductionPsInContext productionPsInContext = (null != productionPsInContextOp && productionPsInContextOp.isPresent()) ? productionPsInContextOp.get() : null;
//当前加工规则的PID对应的设备加工参数
List<MesEquipmentProdParamCfg> equipmentProdParamCfgList = eppcMap2SourceId.get(sourceId);
MesProductionPsOutContext productionPsOutContext = (null != productionPsOutContextOp && productionPsOutContextOp.isPresent()) ? productionPsOutContextOp.get() : null;
if (CollectionUtils.isEmpty(equipmentProdParamCfgList)) continue;
//搜集发送规则并去重
List<String> matchRuleList = (equipmentProdParamCfgList.stream().filter(o -> null != o).map(o -> checkTransformUpperCase(o.getMatchRule())).collect(Collectors.toList())).stream().filter(o -> !StringUtils.isEmpty(o)).distinct().collect(Collectors.toList());
MesProductionPartContext productionPartContext = (null != productionPartContextOp && productionPartContextOp.isPresent()) ? productionPartContextOp.get() : null;
for (String matchRule : matchRuleList) {
MesProductionPsInContext productionPsInContext = (null != productionPsInContextOp && productionPsInContextOp.isPresent()) ? productionPsInContextOp.get() : null;
if (StringUtils.isEmpty(matchRule)) continue;
MesProductionPsOutContext productionPsOutContext = (null != productionPsOutContextOp && productionPsOutContextOp.isPresent()) ? productionPsOutContextOp.get() : null;
Optional<MesEquipmentProdParamCfg> equipmentProdParamCfgOp = equipmentProdParamCfgList.stream().filter(o -> (null != o && checkTransformUpperCase(o.getMatchRule()).equals(matchRule) && evMap.containsKey(o.getEquipVariableId()))).findFirst();
//搜集发送规则并去重
List<String> matchRuleList = (equipmentProdParamCfgList.stream().filter(o -> null != o).map(o -> checkTransformUpperCase(o.getMatchRule())).collect(Collectors.toList())).stream().filter(o -> !StringUtils.isEmpty(o)).distinct().collect(Collectors.toList());
if (null == equipmentProdParamCfgOp || !equipmentProdParamCfgOp.isPresent()) continue;
for (String matchRule : matchRuleList) {
evMap.remove(equipmentProdParamCfgOp.get().getId());
if (StringUtils.isEmpty(matchRule)) continue;
//数据转换
String matchValue = transferValue(matchRule, reqBean, prodRuleContext, productResult, productionPartContext, productionPsInContext, productionPsOutContext);
Optional<MesEquipmentProdParamCfg> equipmentProdParamCfgOp = equipmentProdParamCfgList.stream().filter(o -> (null != o && checkTransformUpperCase(o.getMatchRule()).equals(matchRule) && evMap.containsKey(o.getEquipVariableId()))).findFirst();
if (StringUtils.isEmpty(matchValue)) {
this.sendMessage(reqBean, resultBean.writeDbLog(), String.format("发送设备加工参数:[%s]未匹配到业务数据", matchRule), MesPcnEnumUtil.STATION_BUSI_TYPE.RUNNING_INFO, MesPcnEnumUtil.STATION_DATA_TYPE.EXP_TEXT);
continue;
}
if (null == equipmentProdParamCfgOp || !equipmentProdParamCfgOp.isPresent()) continue;
MesEquipmentVariable equipmentVariable = evMap.get(equipmentProdParamCfgOp.get().getEquipVariableId());
if (null == equipmentVariable) {
this.sendMessage(reqBean, resultBean.writeDbLog(), String.format("发送设备加工参数:设备加工参数信息ID[%s]关联的设备数据变量ID[%s]未维护有效的设备数据变量信息!", equipmentProdParamCfgOp.get().getId(), equipmentProdParamCfgOp.get().getEquipVariableId()), MesPcnEnumUtil.STATION_BUSI_TYPE.RUNNING_INFO, MesPcnEnumUtil.STATION_DATA_TYPE.EXP_TEXT);
continue;
}
evMap.remove(equipmentProdParamCfgOp.get().getId());
//写值
MesEquipVariableRwResult equipVariableRwResult = equipVariableRwExtService.writeVariable(matchValue, equipmentVariable, cellEquipContext.getKepwareFlag(equipmentVariable.getChannel()));
//数据转换
String matchValue = transferValue(matchRule, reqBean, prodRuleContext, productResult, productionPartContext, productionPsInContext, productionPsOutContext);
if (!equipVariableRwResult.getIsSuccessed()) {
this.sendMessage(reqBean, new StationResultBean().writeDbLog().checkRepeat(), String.format("设备[%s]:发送设备加工参数失败!原因:%s", cellEquipContext.getEquipmentName(), equipVariableRwResult.getMessage()), MesPcnEnumUtil.STATION_BUSI_TYPE.MESSAGE, MesPcnEnumUtil.STATION_DATA_TYPE.EXP_TEXT);
continue;
}
if (StringUtils.isEmpty(matchValue)) {
this.sendMessage(reqBean, resultBean.writeDbLog(), String.format("发送设备加工参数:[%s]未匹配到业务数据", matchRule), MesPcnEnumUtil.STATION_BUSI_TYPE.RUNNING_INFO, MesPcnEnumUtil.STATION_DATA_TYPE.EXP_TEXT);
continue;
}
this.sendMessage(reqBean, new StationResultBean().writeDbLog(), String.format("设备[%s]:发送设备加工参数成功!%s", cellEquipContext.getEquipmentName(), equipVariableRwResult.getMessage()), MesPcnEnumUtil.STATION_BUSI_TYPE.MESSAGE, MesPcnEnumUtil.STATION_DATA_TYPE.TEXT);
MesEquipmentVariable equipmentVariable = evMap.get(equipmentProdParamCfgOp.get().getEquipVariableId());
if (null == equipmentVariable) {
this.sendMessage(reqBean, resultBean.writeDbLog(), String.format("发送设备加工参数:设备加工参数信息ID[%s]关联的设备数据变量ID[%s]未维护有效的设备数据变量信息!", equipmentProdParamCfgOp.get().getId(), equipmentProdParamCfgOp.get().getEquipVariableId()), MesPcnEnumUtil.STATION_BUSI_TYPE.RUNNING_INFO, MesPcnEnumUtil.STATION_DATA_TYPE.EXP_TEXT);
continue;
}
//写值
MesEquipVariableRwResult equipVariableRwResult = equipVariableRwExtService.writeVariable(matchValue, equipmentVariable, cellEquipContext.getKepwareFlag(equipmentVariable.getChannel()));
if (!equipVariableRwResult.getIsSuccessed()) {
this.sendMessage(reqBean, new StationResultBean().writeDbLog().checkRepeat(), String.format("设备[%s]:发送设备加工参数失败!原因:%s", cellEquipContext.getEquipmentName(), equipVariableRwResult.getMessage()), MesPcnEnumUtil.STATION_BUSI_TYPE.MESSAGE, MesPcnEnumUtil.STATION_DATA_TYPE.EXP_TEXT);
continue;
}
this.sendMessage(reqBean, new StationResultBean().writeDbLog(), String.format("设备[%s]:发送设备加工参数成功!%s", cellEquipContext.getEquipmentName(), equipVariableRwResult.getMessage()), MesPcnEnumUtil.STATION_BUSI_TYPE.MESSAGE, MesPcnEnumUtil.STATION_DATA_TYPE.TEXT);
}
}

@ -1,6 +1,7 @@
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.apiservice.util.BarCodeUtils;
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesEquipVariableCollectContext;
import cn.estsh.i3plus.mes.pcn.serviceimpl.fsm.BaseStepService;
import cn.estsh.i3plus.pojo.base.enumutil.MesPcnEnumUtil;
@ -41,8 +42,10 @@ public class MesShippingRfidMatchStepService extends BaseStepService {
//获取上下文扫/读信息:主条码
List<MesEquipVariableCollectContext> equipVariableCollectContextList = productionDispatchContextStepService.getScanProductSnContext(reqBean);
//设备写的条码
String productSn = CollectionUtils.isEmpty(equipVariableCollectContextList) ? null : equipVariableCollectContextList.get(0).getEquipVariableValue();
//设备写的条码, rfid条码存在特殊字符, 所以要先取 realEquipVariableValue , 没有再取 equipVariableValue
String productSn = CollectionUtils.isEmpty(equipVariableCollectContextList) ? null :
(!StringUtils.isEmpty(equipVariableCollectContextList.get(0).getRealEquipVariableValue())
? equipVariableCollectContextList.get(0).getRealEquipVariableValue() : equipVariableCollectContextList.get(0).getEquipVariableValue());
if (StringUtils.isEmpty(productSn)) return stepNonCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(), stepResult, "当前未获取到设备写入的主条码信息!");
if (!shippingQueue.getRfidSn().equals(productSn))

@ -99,11 +99,14 @@ public class MesWorkOrderCheckSortStepService extends MesWorkOrderCheckStepServi
List<MesProductionPsOutContext> productionPsOutContextList = new ArrayList<>();
if (!checkWorkOrderValid(reqBean, resultBean, stepResult, productionProcessContext,
equipVariableCollectContextList, productionPartContextList, productionPsInContextList, productionPsOutContextList).isCompleted()) {
//推单场景下是读取的工单, 验证工单无效需要验证是否是连续的重复信息
if (equipVariableCollectContextList.get(0).getMessageSource().compareTo(MesExtEnumUtil.CELL_MESSAGE_SOURCE.READ.getValue()) == 0) resultBean.checkRepeat();
return stepNonCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(), stepResult, stepResult.getMsg());
}
//扫描场景下合并历史产出零件信息/产品条码信息
if (MesExtEnumUtil.CELL_MESSAGE_SOURCE.SCAN.getValue() == equipVariableCollectContextList.get(0).getMessageSource() && !CollectionUtils.isEmpty(cachedProductionPartContextList)) {
if (MesExtEnumUtil.CELL_MESSAGE_SOURCE.SCAN.getValue() == equipVariableCollectContextList.get(0).getMessageSource() &&
!CollectionUtils.isEmpty(cachedProductionPartContextList) && !CollectionUtils.isEmpty(cachedProductionPsInContextList)) {
productionPartContextList.addAll(cachedProductionPartContextList);
productionPsInContextList.addAll(cachedProductionPsInContextList);
productionPsOutContextList.addAll(cachedProductionPsOutContextList);

@ -10,9 +10,12 @@ 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.actor.shipping.dispatch.IFsmCommonService;
import cn.estsh.i3plus.mes.pcn.serviceimpl.fsm.BaseStepService;
import cn.estsh.i3plus.mes.pcn.serviceimpl.fsm.IShippingDispatchService;
import cn.estsh.i3plus.mes.pcn.serviceimpl.fsm.IStepService;
import cn.estsh.i3plus.mes.pcn.util.StringUtil;
import cn.estsh.i3plus.mes.pcn.websocket.StationWebSocket;
import cn.estsh.i3plus.platform.common.tool.TimeTool;
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
import cn.estsh.i3plus.pojo.base.enumutil.MesPcnEnumUtil;
import cn.estsh.i3plus.pojo.mes.bean.MesQueueOrderPush;
import cn.estsh.i3plus.pojo.mes.bean.MesQueueOrderPushCellCfg;
@ -57,6 +60,9 @@ public class MesWorkOrderQueueAcceptStepService extends BaseStepService {
@Autowired
private IFsmCommonService fsmCommonService;
@Autowired
private IShippingDispatchService shippingDispatchService;
private static Map<String, String> lockTimeMap = new HashMap<>();
private static Map<String, ReentrantLock> lockMap = new ConcurrentHashMap<>();
@ -112,10 +118,10 @@ public class MesWorkOrderQueueAcceptStepService extends BaseStepService {
getStepParams(reqBean), MesPcnExtConstWords.READ_FAILURE_SLEEP, MesPcnExtConstWords.READ_FAILURE_SLEEP_DEFAULT_TIME);
}
//搜集需要考虑加锁的推送来源代码
List<String> pushSourceCodeList = queueOrderPushCellCfgList.stream().filter(o -> (null != o && !StringUtils.isEmpty(o.getIsNeedLock()))).map(MesQueueOrderPushCellCfg::getPushSourceCode).collect(Collectors.toList());
//搜集需要加锁的推送来源代码
List<String> pushSourceCodeList2NeedLock = queueOrderPushCellCfgList.stream().filter(o -> (null != o && !StringUtils.isEmpty(o.getIsNeedLock()))).map(MesQueueOrderPushCellCfg::getPushSourceCode).collect(Collectors.toList());
//当前即将执行的接收队列
//当前即将执行的推送队列
List<MesQueueOrderPush> curPushList = null;
try {
@ -123,106 +129,134 @@ public class MesWorkOrderQueueAcceptStepService extends BaseStepService {
for (MesQueueOrderPush queueOrderPush : queueOrderPushList) {
if (null == queueOrderPush || StringUtils.isEmpty(queueOrderPush.getWorkOrderNo())) continue;
//当前遍历中的代码不考虑加锁
if (CollectionUtils.isEmpty(pushSourceCodeList) || !pushSourceCodeList.contains(queueOrderPush.getPushSourceCode())) {
if (CollectionUtils.isEmpty(curPushList)) curPushList = new ArrayList<>();
curPushList.add(queueOrderPush);
//满足腔数的情况下退出循环
if (curPushList.size() >= cellEquipContext.getCavity()) break;
} else {
//当前遍历中的代码考虑加锁; 获取不到锁的情况下退出循环
if (!tryLock(reqBean.getWorkCenterCode(), queueOrderPush.getPushSourceCode())) break;
List<String> queuePushIdList = productionCustomContextStepService.getSortQueuePushLockContext(reqBean.getOrganizeCode(), reqBean.getWorkCenterCode());
if (!CollectionUtils.isEmpty(queuePushIdList) && queuePushIdList.contains(queueOrderPush.getId().toString())) continue;
if (!CollectionUtils.isEmpty(pushSourceCodeList2NeedLock) && pushSourceCodeList2NeedLock.contains(queueOrderPush.getPushSourceCode())) {
//当前遍历中的代码加锁; 获取不到锁的情况下退出循环
if (!tryLock(reqBean, queueOrderPush.getPushSourceCode())) break;
//获取排序线工单队列推送锁数据, 返回的值是工位代码
String lockedCellCode = productionCustomContextStepService.getSortQueuePushLockContext(reqBean, queueOrderPush.getId().toString());
//如果当前推送信息的ID已被其他工位锁定, 验证锁定的工位是否在线, 不在线直接清除当前推送信息的ID的LOCK
if (!StringUtils.isEmpty(lockedCellCode) && !lockedCellCode.equals(reqBean.getWorkCellCode())) {
if (!CollectionUtils.isEmpty(StationWebSocket.getStationWebSocketList(
shippingDispatchService.getActorClientInfo(reqBean.getOrganizeCode(), reqBean.getWorkCenterCode(), lockedCellCode)))) continue;
else productionCustomContextStepService.removeSortQueuePushLockContext(reqBean, queueOrderPush.getId().toString());
}
queueOrderPush.setIsNeedLock(CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValueStr());
}
}
//ADD到当前即将执行的推送队列中
if (CollectionUtils.isEmpty(curPushList)) curPushList = new ArrayList<>();
curPushList.add(queueOrderPush);
//验证是否满足腔数
if (CollectionUtils.isEmpty(curPushList) || curPushList.size() < cellEquipContext.getCavity()) {
return stepDynamicsCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog().checkRepeat(), stepResult,
false, MesPcnEnumUtil.STATION_BUSI_TYPE.GUIDE, MesPcnEnumUtil.STATION_DATA_TYPE.TEXT,
CollectionUtils.isEmpty(curPushList) ? "当前未接收到工位工单队列,持续监听中..." : String.format("当前接收到到工位工单队列个数[%s]不满足腔数[%s],持续监听中...", curPushList.size(), cellEquipContext.getCavity()),
getStepParams(reqBean), MesPcnExtConstWords.READ_FAILURE_SLEEP, MesPcnExtConstWords.READ_FAILURE_SLEEP_DEFAULT_TIME);
//满足腔数的情况下退出循环
if (curPushList.size() >= cellEquipContext.getCavity()) break;
}
//搜集工单号
List<String> workOrderNoList = curPushList.stream().filter(o -> null != o).map(MesQueueOrderPush::getWorkOrderNo).collect(Collectors.toList());
//验证是否满足腔数
if (!CollectionUtils.isEmpty(curPushList) && curPushList.size() == cellEquipContext.getCavity()) {
//发送工步内容
productionCustomContextStepService.sendStepContextMessage(reqBean, workOrderNoList.toString(), MesExtEnumUtil.CELL_MESSAGE_SOURCE.READ);
//搜集工单号
List<String> workOrderNoList = curPushList.stream().filter(o -> null != o).map(MesQueueOrderPush::getWorkOrderNo).collect(Collectors.toList());
List<MesEquipVariableCollectContext> equipVariableCollectContextList = new ArrayList<>();
workOrderNoList.stream().filter(o -> !StringUtils.isEmpty(o)).forEach(o ->
equipVariableCollectContextList.add(new MesEquipVariableCollectContext(reqBean.getOrganizeCode(), o, MesExtEnumUtil.CELL_MESSAGE_SOURCE.READ.getValue())));
//保存上下文扫/读信息:加工单
productionDispatchContextStepService.dispatchScanWorkOrderNoContext(reqBean, equipVariableCollectContextList);
//发送工步内容
productionCustomContextStepService.sendStepContextMessage(reqBean, workOrderNoList.toString(), MesExtEnumUtil.CELL_MESSAGE_SOURCE.READ);
this.sendMessage(reqBean, new StationResultBean().writeDbLog(), String.format("获取到工位工单推送队列%s!", workOrderNoList.toString()), MesPcnEnumUtil.STATION_BUSI_TYPE.RUNNING_INFO, MesPcnEnumUtil.STATION_DATA_TYPE.TEXT);
List<MesEquipVariableCollectContext> equipVariableCollectContextList = new ArrayList<>();
workOrderNoList.stream().filter(o -> !StringUtils.isEmpty(o)).forEach(o ->
equipVariableCollectContextList.add(new MesEquipVariableCollectContext(reqBean.getOrganizeCode(), o, MesExtEnumUtil.CELL_MESSAGE_SOURCE.READ.getValue())));
//保存上下文扫/读信息:加工单
productionDispatchContextStepService.dispatchScanWorkOrderNoContext(reqBean, equipVariableCollectContextList);
log.info("工厂{}生产线{}工位{}:FSM STATE DISPATCHER --- DO STEP --- {} EXEC --- QUEUE_ORDER_PUSH:{}",
reqBean.getOrganizeCode(), reqBean.getWorkCenterCode(), reqBean.getWorkCellCode(), StringUtil.toLowerCaseFirst(this.getClass().getSimpleName()), JSONObject.toJSONString(curPushList));
this.sendMessage(reqBean, new StationResultBean().writeDbLog().checkRepeat(), String.format("获取到工位工单推送队列%s!", workOrderNoList.toString()), MesPcnEnumUtil.STATION_BUSI_TYPE.RUNNING_INFO, MesPcnEnumUtil.STATION_DATA_TYPE.TEXT);
//加工单验证工步 【排序】
stepResult = ((IStepService) SpringContextsUtil.getBean("mesWorkOrderCheckSortStepService")).executeInState(reqBean);
//加工单验证工步 【排序】
stepResult = ((IStepService) SpringContextsUtil.getBean("mesWorkOrderCheckSortStepService")).executeInState(reqBean);
//保存上下文推单信息
if (stepResult.isCompleted()) productionDispatchContextStepService.dispatchSortQueuePushContext(reqBean, curPushList);
if (stepResult.isCompleted()) {
return stepResult;
//保存上下文推单信息
productionDispatchContextStepService.dispatchSortQueuePushContext(reqBean, curPushList);
} finally {
log.info("工厂{}生产线{}工位{}:FSM STATE DISPATCHER --- DO STEP --- {} EXEC --- QUEUE_ORDER_PUSH:{}",
reqBean.getOrganizeCode(), reqBean.getWorkCenterCode(), reqBean.getWorkCellCode(), StringUtil.toLowerCaseFirst(this.getClass().getSimpleName()), JSONObject.toJSONString(curPushList));
//验证是否执行解锁
if (!CollectionUtils.isEmpty(curPushList)) {
for (MesQueueOrderPush queueOrderPush : curPushList) {
if (null == queueOrderPush) continue;
if (CollectionUtils.isEmpty(pushSourceCodeList) || !pushSourceCodeList.contains(queueOrderPush.getPushSourceCode())) continue;
//当需要考虑加锁且满足腔数的情况下, 保存排序线工单队列推送锁数据
if (curPushList.size() >= cellEquipContext.getCavity()) productionCustomContextStepService.dispatchSortQueuePushLockContext(reqBean.getOrganizeCode(), reqBean.getWorkCenterCode(), queueOrderPush.getId().toString());
//解锁
unLock(reqBean.getWorkCenterCode(), queueOrderPush.getPushSourceCode());
return stepResult;
}
}
} finally {
//当需要加锁且满足腔数的情况下, 保存排序线工单队列推送锁数据
Map<String, String> queuePushMap2Locked = CollectionUtils.isEmpty(curPushList) ? null :
curPushList.stream().filter(o -> (null != o && !StringUtils.isEmpty(o.getIsNeedLock()))).collect(Collectors.toMap(o -> o.getId().toString(), MesQueueOrderPush::getPushSourceCode));
if (!CollectionUtils.isEmpty(queuePushMap2Locked) && curPushList.size() >= cellEquipContext.getCavity()) {
//保存排序线工单队列推送锁数据【保存LOCK信息:item=id,value=工位】【保存当前工位锁定的信息:item=工位,value=idList】
productionCustomContextStepService.dispatchSortQueuePushLockContext(reqBean, new ArrayList<>(queuePushMap2Locked.keySet()));
}
//解锁
if (!CollectionUtils.isEmpty(queuePushMap2Locked)) queuePushMap2Locked.values().forEach(o -> unLock(reqBean, o));
}
if (!stepResult.isCompleted()) {
stepThreadSleepAndSendTaskCompleteAndThrowEx(reqBean, stepResult, MesPcnEnumUtil.STATION_DATA_TYPE.EXP_TEXT,
getStepParams(reqBean), MesPcnExtConstWords.READ_FAILURE_SLEEP, MesPcnExtConstWords.READ_FAILURE_SLEEP_DEFAULT_TIME);
}
return stepDynamicsCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog().checkRepeat(), stepResult,
false, MesPcnEnumUtil.STATION_BUSI_TYPE.GUIDE, MesPcnEnumUtil.STATION_DATA_TYPE.TEXT,
CollectionUtils.isEmpty(curPushList) ? "当前未接收到工位工单队列,持续监听中..." : String.format("当前接收到到工位工单队列个数[%s]不满足腔数[%s],持续监听中...", curPushList.size(), cellEquipContext.getCavity()),
getStepParams(reqBean), MesPcnExtConstWords.READ_FAILURE_SLEEP, MesPcnExtConstWords.READ_FAILURE_SLEEP_DEFAULT_TIME);
}
//加锁
private Boolean tryLock(String workCenterCode, String pushSourceCode) {
private Boolean tryLock(StationRequestBean reqBean, String pushSourceCode) {
try {
String key = new StringJoiner(MesPcnExtConstWords.AND).add(workCenterCode).add(pushSourceCode).toString();
String key = new StringJoiner(MesPcnExtConstWords.AND).add(reqBean.getWorkCenterCode()).add(pushSourceCode).toString();
ReentrantLock lock = lockMap.computeIfAbsent(key, item -> new ReentrantLock(true));
//500ms内拿不到锁的情况下监控锁是否已经超时
if (!lock.tryLock(MesPcnExtConstWords.FIVE_HUNDRED, TimeUnit.MILLISECONDS) && checkTimeOut(key, lock)) return false;
if (!lock.tryLock(MesPcnExtConstWords.FIVE_HUNDRED, TimeUnit.MILLISECONDS) && checkTimeOut(reqBean, pushSourceCode, key, lock)) return false;
log.info("工厂{}生产线{}工位{}:FSM STATE DISPATCHER --- DO STEP --- {} EXEC --- TRY_LOCK [{}] SUCCESS",
reqBean.getOrganizeCode(), reqBean.getWorkCenterCode(), reqBean.getWorkCellCode(), StringUtil.toLowerCaseFirst(this.getClass().getSimpleName()), pushSourceCode);
lockTimeMap.put(key, TimeTool.getNowTime(true));
return true;
} catch (InterruptedException e) {
} catch (Exception e) {
log.info("工厂{}生产线{}工位{}:FSM STATE DISPATCHER --- DO STEP --- {} EXEC --- TRY_LOCK [{}] EXCEPTION: {}",
reqBean.getOrganizeCode(), reqBean.getWorkCenterCode(), reqBean.getWorkCellCode(), StringUtil.toLowerCaseFirst(this.getClass().getSimpleName()), pushSourceCode, e.toString());
return false;
}
}
//监控超过10秒的情况下进行自动解锁
private Boolean checkTimeOut(String key, ReentrantLock lock) {
private Boolean checkTimeOut(StationRequestBean reqBean, String pushSourceCode, String key, ReentrantLock lock) {
try {
String lockTime = lockTimeMap.get(key);
if ((StringUtils.isEmpty(lockTime) || TimeTool.getSecoundsBetweenTime(1, lockTime, TimeTool.getNowTime(true)) >= MesPcnExtConstWords.TEN) && lock.isLocked()) lock.unlock();
if ((StringUtils.isEmpty(lockTime) || TimeTool.getSecoundsBetweenTime(1, lockTime, TimeTool.getNowTime(true)) >= MesPcnExtConstWords.TEN) && lock.isLocked()) {
if (lock.isHeldByCurrentThread()) lock.unlock();
else lockMap.remove(key);
}
} catch (Exception e) {
if (lock.isLocked()) lock.unlock();
log.info("工厂{}生产线{}工位{}:FSM STATE DISPATCHER --- DO STEP --- {} EXEC --- CHECK_TIME_OUT [{}] EXCEPTION: {}",
reqBean.getOrganizeCode(), reqBean.getWorkCenterCode(), reqBean.getWorkCellCode(), StringUtil.toLowerCaseFirst(this.getClass().getSimpleName()), pushSourceCode, e.toString());
}
return true;
}
//解锁
private void unLock(String workCenterCode, String pushSourceCode) {
private void unLock(StationRequestBean reqBean, String pushSourceCode) {
try {
String key = new StringJoiner(MesPcnExtConstWords.AND).add(workCenterCode).add(pushSourceCode).toString();
String key = new StringJoiner(MesPcnExtConstWords.AND).add(reqBean.getWorkCenterCode()).add(pushSourceCode).toString();
lockMap.computeIfPresent(key, (k, v) -> {
if (!v.isHeldByCurrentThread() || !v.isLocked()) return v;
v.unlock();
log.info("工厂{}生产线{}工位{}:FSM STATE DISPATCHER --- DO STEP --- {} EXEC --- UNLOCK [{}] SUCCESS",
reqBean.getOrganizeCode(), reqBean.getWorkCenterCode(), reqBean.getWorkCellCode(), StringUtil.toLowerCaseFirst(this.getClass().getSimpleName()), pushSourceCode);
return v;
});
} catch (Exception e) {
log.info("工厂{}生产线{}工位{}:FSM STATE DISPATCHER --- DO STEP --- {} EXEC --- UNLOCK [{}] EXCEPTION: {}",
reqBean.getOrganizeCode(), reqBean.getWorkCenterCode(), reqBean.getWorkCellCode(), StringUtil.toLowerCaseFirst(this.getClass().getSimpleName()), pushSourceCode, e.toString());
}
}

@ -0,0 +1,128 @@
package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.step;
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.IMesQueueOrderPushService;
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.context.MesProductionPsInContext;
import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtConstWords;
import cn.estsh.i3plus.mes.pcn.serviceimpl.fsm.BaseStepService;
import cn.estsh.i3plus.mes.pcn.util.StringUtil;
import cn.estsh.i3plus.platform.common.convert.ConvertBean;
import cn.estsh.i3plus.pojo.base.bean.DdlPackBean;
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.MesQueueOrderPush;
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.MesQueueOrderRepository;
import cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil;
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.CollectionUtils;
import org.springframework.util.StringUtils;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
/**
* @Description :
* @Author : wangjie
**/
@Slf4j
@Service("mesWorkOrderQueueSavePushStepService")
public class MesWorkOrderQueueSavePushStepService extends BaseStepService {
@Autowired
private IMesProductionProcessContextStepService productionProcessContextStepService;
@Autowired
private IMesProductionDispatchContextStepService productionDispatchContextStepService;
@Autowired
private IMesProductionCustomContextStepService productionCustomContextStepService;
@Autowired
private IMesQueueOrderPushService queueOrderPushService;
@Autowired
private MesQueueOrderRepository queueOrderRepository;
@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<MesProductionPartContext> productionPartContextList = productionDispatchContextStepService.getProductionPartContext(reqBean);
if (CollectionUtils.isEmpty(productionPartContextList)) stepExpSendMsgAndThrowEx(reqBean, resultBean.writeDbLog(), "当前不存在产出零件信息,请重置工序解决!");
//获取上下文条码数据信息集合
List<MesProductionPsInContext> productionPsInContextList = productionDispatchContextStepService.getProductionPsInContext(reqBean);
if (CollectionUtils.isEmpty(productionPsInContextList)) stepExpSendMsgAndThrowEx(reqBean, resultBean.writeDbLog(), "当前不存在零件条码信息,请重置工序解决!");
//获取上下文推单队列信息
List<MesQueueOrderPush> queueOrderPushList = productionDispatchContextStepService.getSortQueuePushContext(reqBean);
if (!CollectionUtils.isEmpty(queueOrderPushList)) saveQueueOrderPush(reqBean, queueOrderPushList);
//写入队列信息,默认状态为已完成
productionPsInContextList.stream().filter(o -> null != o).forEach(o -> insertQueueOrder(reqBean, o, productionPartContextList));
//验证是否存在LOCK数据, 存在的情况下赋值 stepAfterState, 当前工步集执行结束后会执行当前工步重写的executeStepAfterState方法
Optional<MesQueueOrderPush> optional = CollectionUtils.isEmpty(queueOrderPushList) ? null : queueOrderPushList.stream().filter(o -> (null != o && !StringUtils.isEmpty(o.getIsNeedLock()))).findFirst();
if (null != optional && optional.isPresent()) stepResult.stepAfterState(StringUtil.toLowerCaseFirst(this.getClass().getSimpleName()));
return stepSuccessCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(MesPcnEnumUtil.WORK_CELL_SCAN_MONITOR_LOG_TYPE.PROCESS.getValue()), stepResult, "保存工位队列成功!");
}
//修改推送队列信息状态为已完成
private void saveQueueOrderPush(StationRequestBean reqBean, List<MesQueueOrderPush> queueOrderPushList) {
List<Long> idList = queueOrderPushList.stream().filter(o -> null != o).map(MesQueueOrderPush::getId).collect(Collectors.toList());
DdlPackBean packBean = DdlPackBean.getDdlPackBean(reqBean.getOrganizeCode());
if (idList.size() == 1) DdlPreparedPack.getNumEqualPack(idList.get(0), MesPcnExtConstWords.ID, packBean);
else DdlPreparedPack.getInPackList(idList, MesPcnExtConstWords.ID, packBean);
queueOrderPushService.saveQueueOrderPushStatusByDdlPackBean(packBean, reqBean.getUserInfo(), MesExtEnumUtil.QUEUE_ORDER_STATUS.FINISH.getValue(), reqBean.getWorkCellCode());
}
//写入队列信息,默认状态为已完成
private void insertQueueOrder(StationRequestBean reqBean, MesProductionPsInContext productionPsInContext, List<MesProductionPartContext> productionPartContextList) {
Optional<MesProductionPartContext> optional = productionPartContextList.stream().filter(o -> (null != o && o.getWorkOrderNo().equals(productionPsInContext.getWorkOrderNo()))).findFirst();
MesQueueOrder queueOrder = new MesQueueOrder();
if (null != optional && optional.isPresent()) BeanUtils.copyProperties(optional.get(), queueOrder, MesPcnExtConstWords.BASE_BEAN_FIELDS);
BeanUtils.copyProperties(productionPsInContext, queueOrder, MesPcnExtConstWords.BASE_BEAN_FIELDS);
queueOrder.setWorkCellCode(reqBean.getWorkCellCode());
queueOrder.setStatus(MesExtEnumUtil.QUEUE_ORDER_STATUS.FINISH.getValue());
ConvertBean.serviceModelInitialize(queueOrder, reqBean.getUserInfo());
queueOrderRepository.insert(queueOrder);
}
//当前工步集完成之后执行当前方法
@Override
public void executeStepAfterState(StationRequestBean reqBean, StepResult stepResult) {
if (!stepResult.isCompleted()) return;
//获取排序线工单队列推送锁数据, 返回的值是工单队列ID集合
List<String> queuePushIdList = productionCustomContextStepService.getSortQueuePushLockContext(reqBean);
if (CollectionUtils.isEmpty(queuePushIdList)) return;
//删除排序线工单队列推送锁数据
queuePushIdList.stream().filter(o -> !StringUtils.isEmpty(o)).forEach(o -> productionCustomContextStepService.removeSortQueuePushLockContext(reqBean, o));
}
}

@ -0,0 +1,77 @@
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.context.MesProductionPsInContext;
import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtConstWords;
import cn.estsh.i3plus.mes.pcn.serviceimpl.fsm.BaseStepService;
import cn.estsh.i3plus.platform.common.tool.TimeTool;
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
import cn.estsh.i3plus.pojo.base.enumutil.MesPcnEnumUtil;
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.MesQueueOrderRepository;
import cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil;
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;
/**
* @Description :
* @Author : wangjie
**/
@Slf4j
@Service("mesWorkOrderQueueSaveStatusStepService")
public class MesWorkOrderQueueSaveStatusStepService extends BaseStepService {
@Autowired
private IMesProductionProcessContextStepService productionProcessContextStepService;
@Autowired
private IMesProductionDispatchContextStepService productionDispatchContextStepService;
@Autowired
private MesQueueOrderRepository queueOrderRepository;
@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<MesProductionPsInContext> productionPsInContextList = productionDispatchContextStepService.getProductionPsInContext(reqBean);
if (CollectionUtils.isEmpty(productionPsInContextList)) stepExpSendMsgAndThrowEx(reqBean, resultBean.writeDbLog(), "当前不存在零件条码信息,请重置工序解决!");
productionPsInContextList.stream().filter(o -> null != o).forEach(o -> saveWorkOrderQueue(reqBean, o));
return stepSuccessCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(MesPcnEnumUtil.WORK_CELL_SCAN_MONITOR_LOG_TYPE.PROCESS.getValue()), stepResult, "保存工位队列成功!");
}
private void saveWorkOrderQueue(StationRequestBean reqBean, MesProductionPsInContext productionPsInContext) {
if (StringUtils.isEmpty(productionPsInContext.getRelateId())) return;
queueOrderRepository.updateByPropertiesNoSync(
new String[]{MesPcnExtConstWords.ID, MesPcnExtConstWords.ORGANIZE_CODE},
new Object[]{productionPsInContext.getRelateId(), reqBean.getOrganizeCode()},
new String[]{MesPcnExtConstWords.STATUS, MesPcnExtConstWords.MODIFY_USER, MesPcnExtConstWords.MODIFY_DATE_TIME, MesPcnExtConstWords.SYSTEM_SYNC_STATUS, MesPcnExtConstWords.SYSTEM_SYNC_DATE_TIME},
new Object[]{MesExtEnumUtil.QUEUE_ORDER_STATUS.FINISH.getValue(), reqBean.getUserInfo(), TimeTool.getNowTime(true), CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue(), MesPcnExtConstWords.EMPTY});
}
}

@ -3,25 +3,20 @@ 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.context.MesProductionPsInContext;
import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtConstWords;
import cn.estsh.i3plus.mes.pcn.serviceimpl.fsm.BaseStepService;
import cn.estsh.i3plus.platform.common.tool.TimeTool;
import cn.estsh.i3plus.mes.pcn.serviceimpl.fsm.IStepService;
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
import cn.estsh.i3plus.pojo.base.enumutil.MesPcnEnumUtil;
import cn.estsh.i3plus.pojo.mes.bean.MesWorkCenter;
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.MesQueueOrderRepository;
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.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import java.util.List;
/**
* @Description :
* @Author : wangjie
@ -44,8 +39,6 @@ public class MesWorkOrderQueueSaveStepService extends BaseStepService {
StationResultBean resultBean = new StationResultBean();
StepResult stepResult = StepResult.getSuccessComplete();
//获取上下文信息
MesProductionProcessContext productionProcessContext = productionProcessContextStepService.dispatchCurCellEquipment(reqBean);
@ -55,24 +48,16 @@ public class MesWorkOrderQueueSaveStepService extends BaseStepService {
//存储生产过程上下文对象
productionProcessContextStepService.dispatchProductionProcessContext(reqBean, productionProcessContext);
//获取上下文条码数据信息集合
List<MesProductionPsInContext> productionPsInContextList = productionDispatchContextStepService.getProductionPsInContext(reqBean);
if (CollectionUtils.isEmpty(productionPsInContextList)) stepExpSendMsgAndThrowEx(reqBean, resultBean.writeDbLog(), "当前不存在零件条码信息,请重置工序解决!");
//获取生产线信息
MesWorkCenter workCenter = productionProcessContext.getWorkCenter();
productionPsInContextList.stream().filter(o -> null != o).forEach(o -> saveWorkOrderQueue(reqBean, o));
//排序线 保存工位队列信息工步 非推送工位
if (StringUtils.isEmpty(workCenter.getIsPushQueue()) || workCenter.getIsPushQueue().compareTo(CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue()) != 0)
return ((IStepService) SpringContextsUtil.getBean("mesWorkOrderQueueSaveStatusStepService")).executeInState(reqBean);
return stepSuccessCompleteAndSendMsgReturn(reqBean, resultBean.writeDbLog(MesPcnEnumUtil.WORK_CELL_SCAN_MONITOR_LOG_TYPE.PROCESS.getValue()), stepResult, "保存工位队列成功!");
}
//排序线 保存工位队列信息工步 推送工位
return ((IStepService) SpringContextsUtil.getBean("mesWorkOrderQueueSavePushStepService")).executeInState(reqBean);
private void saveWorkOrderQueue(StationRequestBean reqBean, MesProductionPsInContext productionPsInContext) {
if (StringUtils.isEmpty(productionPsInContext.getRelateId())) return;
queueOrderRepository.updateByPropertiesNoSync(
new String[]{MesPcnExtConstWords.ID, MesPcnExtConstWords.ORGANIZE_CODE},
new Object[]{productionPsInContext.getRelateId(), reqBean.getOrganizeCode()},
new String[]{MesPcnExtConstWords.STATUS, MesPcnExtConstWords.MODIFY_USER, MesPcnExtConstWords.MODIFY_DATE_TIME, MesPcnExtConstWords.SYSTEM_SYNC_STATUS, MesPcnExtConstWords.SYSTEM_SYNC_DATE_TIME},
new Object[]{MesExtEnumUtil.QUEUE_ORDER_STATUS.FINISH.getValue(), reqBean.getUserInfo(), TimeTool.getNowTime(true), CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue(), MesPcnExtConstWords.EMPTY});
}
}

@ -217,7 +217,6 @@ public class MesProductionCustomContextStepService extends BaseStepService imple
@Override
public String getRepeatAssemblySn(String organizeCode, String workCenterCode, String workCellCode, String repeatKey) {
String repeatAssemblySnJson = getFsmBusiData(organizeCode, getRepeatAssemblySnContextKey(organizeCode, workCenterCode, workCellCode), repeatKey);
//MesProductionAssemblyContext productionAssemblyContext = !StringUtils.isEmpty(repeatAssemblySnJson) ? JSONObject.parseObject(repeatAssemblySnJson, MesProductionAssemblyContext.class) : null;
return repeatAssemblySnJson;
}
@ -297,25 +296,35 @@ public class MesProductionCustomContextStepService extends BaseStepService imple
}
//排序线工单队列推送锁数据KEY 【PS:生产线级别】
private String getSortQueuePushLockContextKey(String orgainzeCode, String workCenterCode) { return new StringJoiner(MesPcnExtConstWords.COLON).add(orgainzeCode).add(MesPcnExtConstWords.QUEUE_PUSH_LOCK_CONTEXT).add(workCenterCode).toString(); }
private String getSortQueuePushLockContextKey(StationRequestBean reqBean) { return new StringJoiner(MesPcnExtConstWords.COLON).add(reqBean.getOrganizeCode()).add(reqBean.getWorkCenterCode()).add(MesPcnExtConstWords.QUEUE_PUSH_LOCK_CONTEXT).toString(); }
//获取排序线工单队列推送锁数据
//获取排序线工单队列推送锁数据, 返回的值是工位代码
@Override
public List<String> getSortQueuePushLockContext(String orgainzeCode, String workCenterCode) {
return getFsmBusiList(orgainzeCode, getSortQueuePushLockContextKey(orgainzeCode, workCenterCode));
public String getSortQueuePushLockContext(StationRequestBean reqBean, String queuePushId) {
if (StringUtils.isEmpty(queuePushId)) return null;
return getFsmBusiData(reqBean.getOrganizeCode(), getSortQueuePushLockContextKey(reqBean), queuePushId);
}
//保存排序线工单队列推送锁数据
//获取排序线工单队列推送锁数据, 返回的值是工单队列ID集合
@Override
public Boolean dispatchSortQueuePushLockContext(String organizeCode, String workCenterCode, String queuePushId) {
if (StringUtils.isEmpty(organizeCode) || StringUtils.isEmpty(workCenterCode) || StringUtils.isEmpty(queuePushId)) return false;
return dispatchFsmBusiList(organizeCode, getSortQueuePushLockContextKey(organizeCode, workCenterCode), queuePushId);
public List<String> getSortQueuePushLockContext(StationRequestBean reqBean) {
String queuePushIdListJson = getFsmBusiData(reqBean.getOrganizeCode(), getSortQueuePushLockContextKey(reqBean), reqBean.getWorkCellCode());
return StringUtils.isEmpty(queuePushIdListJson) ? null : JSONObject.parseArray(queuePushIdListJson, String.class);
}
//保存排序线工单队列推送锁数据【保存LOCK信息:item=id,value=工位】【保存当前工位锁定的信息:item=工位,value=idList】
@Override
public Boolean dispatchSortQueuePushLockContext(StationRequestBean reqBean, List<String> queuePushIdList) {
if (CollectionUtils.isEmpty(queuePushIdList)) return false;
queuePushIdList.forEach(o -> dispatchFsmBusiData(reqBean.getOrganizeCode(), getSortQueuePushLockContextKey(reqBean), o, reqBean.getWorkCellCode()));
return dispatchFsmBusiData(reqBean.getOrganizeCode(), getSortQueuePushLockContextKey(reqBean), reqBean.getWorkCellCode(), JSONObject.toJSONString(queuePushIdList));
}
//删除排序线工单队列推送锁数据
@Override
public void removeSortQueuePushLockContext(String orgainzeCode, String workCenterCode, String queuePushId) {
removeFsmBusiList(orgainzeCode, getSortQueuePushLockContextKey(orgainzeCode, workCenterCode), queuePushId);
public void removeSortQueuePushLockContext(StationRequestBean reqBean, String queuePushId) {
if (!StringUtils.isEmpty(queuePushId)) return;
removeFsmBusiData(reqBean.getOrganizeCode(), getSortQueuePushLockContextKey(reqBean), queuePushId);
}
}

@ -698,4 +698,15 @@ public class MesProductionProcessContextStepService extends BaseStepService impl
return filterList;
}
@Override
public List<MesWorkCellPartPrinterCfg> disPatchWorkCellPartPrinterCfg(StationRequestBean reqBean, Boolean pcNosortPrinterCfg) {
if (!pcNosortPrinterCfg) return null;
String context = getFsmBusiData(reqBean.getOrganizeCode(), getContextKey(reqBean), MesPcnExtConstWords.CELL_PART_PRINTER_CONTEXT);
if (!StringUtils.isEmpty(context)) return context.equals(CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValueStr()) ? null : JSONObject.parseArray(context, MesWorkCellPartPrinterCfg.class);
List<MesWorkCellPartPrinterCfg> workCellPartPrinterCfgList = prodOrgExtService.getWorkCellPartPrinterCfgList(reqBean.getOrganizeCode(), reqBean.getWorkCenterCode(), reqBean.getWorkCellCode());
dispatchFsmBusiData(reqBean.getOrganizeCode(), getContextKey(reqBean), MesPcnExtConstWords.CELL_PART_PRINTER_CONTEXT,
!CollectionUtils.isEmpty(workCellPartPrinterCfgList) ? JSONObject.toJSONString(workCellPartPrinterCfgList) : CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValueStr());
return workCellPartPrinterCfgList;
}
}

@ -9,6 +9,7 @@ import com.google.zxing.client.j2se.MatrixToImageWriter;
import com.google.zxing.common.BitMatrix;
import com.google.zxing.datamatrix.encoder.SymbolShapeHint;
import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;
import org.apache.commons.lang3.StringUtils;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
@ -110,4 +111,9 @@ public class BarCodeUtils {
MatrixToImageWriter.writeToStream(bitMatrix, "png", os);
return os;
}
public static String removePatternSpecialCharacter(String barCode) {
if (StringUtils.isEmpty(barCode)) return MesPcnExtConstWords.EMPTY;
return StringUtils.removePattern(barCode, "[^A-Z^a-z0-9_^\\s^\\-^/^\\.^\\[^\\)^\\>^\\:]");
}
}

@ -32,5 +32,7 @@ public class MesCommonConstant {
//报工条码规则
public static final String REPORT_SN = "REPORT_SN";
//PDA发运校验-排序字段参数配置
public static final String SHIPPING_BUSI_SOFT_CFG = "SHIPPING_BUSI_SOFT_CFG";
}

@ -85,6 +85,12 @@ public class MesProductionPartContext implements Serializable {
@ApiParam("零件生产组代码")
private String partProdGroupCode;
@ApiParam("零件生产组名称")
private String partProdGroupName;
@ApiParam("工单标识")
private String orderFlag;
@ApiParam("车型大类")
private String carModelCode;

@ -54,6 +54,9 @@ public class MesSortShippingCheckModel {
@ApiParam("提示引导信息")
private String msg;
@ApiParam("料架条码")
private String volvoRackNo;
public void setDetailList(List<MesShippingOrderManagementDetail> detailList) {
this.detailList = detailList;
this.isScanCount = (int) detailList.stream().filter(k -> Objects.equals(k.getIsScanFlg(), MesCommonConstant.TRUE_INTEGER)).count();

@ -0,0 +1,125 @@
package cn.estsh.i3plus.ext.mes.pcn.pojo.model;
import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtConstWords;
import io.swagger.annotations.ApiParam;
import lombok.Data;
import org.springframework.util.CollectionUtils;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
/**
* @Description : MODEL
**/
@Data
public class MesSortShippingPrintForCqLxModel implements Serializable {
private static final long serialVersionUID = -4576439891171509409L;
@ApiParam("是否重打印")
private String isRePrint = MesPcnExtConstWords.EMPTY;
@ApiParam("重打印操作人")
private String rePrintUser = MesPcnExtConstWords.EMPTY;
@ApiParam("重打印时间")
private String rePrintDatetime = MesPcnExtConstWords.EMPTY;
@ApiParam("发运单号")
private String shippingCode;
@ApiParam("流水线")
private String flowLine;
@ApiParam("二维码")
private String docNo;
@ApiParam("拉动单号后四位")
private String carsNo;
@ApiParam("拉动单号除后四位")
private String docNoOther;
@ApiParam("零件类")
private String partClassCode;
@ApiParam("零件类名称")
private String partClassName;
@ApiParam("供应商代码")
private String jisProviderCode;
@ApiParam("线边库位")
private String lineLocation;
@ApiParam("DOCK")
private String dock;
@ApiParam("开始车号")
private String beginNumber;
@ApiParam("结束车号")
private String endNumber;
@ApiParam("单据生成时间")
private String jisCreationtime;
@ApiParam("挑选完成时间")
private String pickingOverTime;
@ApiParam("预计出发时间")
private String goOutTime;
@ApiParam("预计到达时间")
private String goToTime;
@ApiParam("第一个表格")
private List<MesSortShippingPrintForCqLxModel> jisDetailList;
@ApiParam("序号")
private Integer xh;
@ApiParam("物料编码")
private String materielCode;
@ApiParam("车型颜色")
private String modelColor;
@ApiParam("用量")
private Double useQty;
@ApiParam("流水号")
private String serialNumber;
@ApiParam("VIN码")
private String vin;
@ApiParam("厂家代码")
private String factoryCode;
@ApiParam("第二个表格")
private List<MesSortShippingPrintForCqLxModel> amountList;
@ApiParam("零件号")
private String partNo;
@ApiParam("数量")
private Double amountQty;
@ApiParam("单元格")
private String appendRows;
@ApiParam("物料名称")
private String materielNames;
public void addJisDetail(MesSortShippingPrintForCqLxModel jisDetail) {
if (CollectionUtils.isEmpty(jisDetailList)) jisDetailList = new ArrayList<>();
jisDetailList.add(jisDetail);
}
public void addAmount(MesSortShippingPrintForCqLxModel amount) {
if (CollectionUtils.isEmpty(amountList)) amountList = new ArrayList<>();
amountList.add(amount);
}
}

@ -355,12 +355,22 @@ public class MesPcnExtConstWords {
public static final String SPOT_CHECK_USER = "spotCheckUser";
//发运组代码
public static final String SHIPPING_GROUP_CODE = "shippingGroupCode";
//发运单代码
public static final String SHIPPING_CODE = "shippingCode";
//最后打印时间
public static final String LAST_PRINT_TIME = "lastPrintTime";
//发运组名称
public static final String SHIPPING_GROUP_NAME = "shippingGroupName";
//队列状态
public static final String QUEUE_STATUS = "queueStatus";
//目标工位
public static final String TARGET_WORK_CELL_CODE = "targetWorkCellCode";
//工艺顺序号
public static final String PROCESS_SEQ = "processSeq";
//工艺顺序号(上面)
public static final String PROCESS_SEQ_UP = "processSeqUp";
//工艺顺序号(下面)
public static final String PROCESS_SEQ_DOWN = "processSeqDown";
//推送来源代码
public static final String PUSH_SOURCE_CODE = "pushSourceCode";
//业务类型
@ -652,6 +662,8 @@ public class MesPcnExtConstWords {
public static final String QUEUE_PUSH_LOCK_CONTEXT = "QUEUE_PUSH_LOCK_CONTEXT";
// 推送队列上下文
public static final String QUEUE_PUSH_CONTEXT = "QUEUE_PUSH_CONTEXT";
// 工位零件打印机上下文
public static final String CELL_PART_PRINTER_CONTEXT = "CELL_PART_PRINTER_CONTEXT";
// 上下文: 展示组件数据
public static final String MODULE_CONTENT_CONTEXT = "MODULE_CONTENT_CONTEXT";
@ -843,6 +855,8 @@ public class MesPcnExtConstWords {
// 车型名称
public static final String CAR_MODEL_NAME = "carModelName";
// VIN
public static final String VIN = "vin";
// VIN_CODE
public static final String VIN_CODE = "vinCode";
// VIN_CODE 后四位
@ -886,5 +900,24 @@ public class MesPcnExtConstWords {
//螺钉包保存生产版本标记
public static final String SAVE_PRODUCT_VERSION_FLAG = "ZFBT";
//发运组配置后写入mes_shipping_queue
public static final String MES_SHIPPING_QUEUE_SAVE_CFG = "MES_SHIPPING_QUEUE_SAVE_CFG";
//SPS拉动单打印模版全局配置
public static final String PART_PULL_PRINT_TEMPLATE = "PART_PULL_PRINT_TEMPLATE";
//排序发运全局打印配置
public static final String SORT_SHIPPING_PRINT_TEMPLATE = "SORT_SHIPPING_PRINT_TEMPLATE";
//由前端直接渲染模版的标志
public static final String TEMPLATE_CUSTOM_HTML = "TEMPLATE_CUSTOM_HTML";
//生产过程控制非排序打印机配置【物料级别=1, 默认打印机=2】
public static final String PRODUCTION_CONTROL_NOSORT_PRINTER_CFG = "PRODUCTION_CONTROL_NOSORT_PRINTER_CFG";
// volvo零件打印
public static final String VOLVO_CONSIGNMENT_REFERENCE = "consignmentReference";
public static final String VOLVO_FYON = "fyon";
public static final String VOLVO_SEQUENCENUMBER = "sequenceNumber";
public static final String VOLVO_RACKID = "rackId";
public static final String VOLVO_POSITION = "position";
public static final String SAP_TRANS_JOB_LOCK_TAG = "MES:JOB:MES_NC_PROCESSING_LOCK_TAG:";
}

@ -34,7 +34,7 @@
<impp.framework.version>1.0.1-YZ</impp.framework.version>
<i3plus.pojo.version>1.0.0-yfai</i3plus.pojo.version>
<i3plus.platform.version>1.0.0.1-patch</i3plus.platform.version>
<i3plus.mes.pcn.version>1.0.2-yfai</i3plus.mes.pcn.version>
<i3plus.mes.pcn.version>1.0.3-yfai</i3plus.mes.pcn.version>
<log4j2.version>2.17.1</log4j2.version>
</properties>

Loading…
Cancel
Save