Merge remote-tracking branch 'origin/dev' into dev

tags/yfai-pcn-ext-v1.0
微笑着面对明天 12 months ago
commit a9bc92b2cf

@ -18,16 +18,14 @@ import java.util.List;
public interface IMesInputDefectRecordService {
@ApiOperation(value = "扫描产品条码")
@ApiOperation(value = "查询页面信息")
public MesPartInspectionViewModel queryPartInspection(MesPartInspectionInputModel model, String org);
// @ApiOperation(value = "批次录入")
// public MesPartInspectionViewModel queryPartAndLot(String partNo, String lot, Integer frontBack, Integer qty, String org);
@ApiOperation(value = "零件类型缺陷类型对应关系信息")
public List<MesPartTypeDefect> queryPartTypeDefect(String serialNumber, String defectLocation, boolean flg, Integer frontBack, String org);
@ApiOperation(value = "零件类型缺陷类型对应关系信息")
@ApiOperation(value = "完成质检")
public void savePartInspection(MesPartInspectionInputModel model, String org);

@ -5,10 +5,9 @@ import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesNcProcessingModel;
import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesNcProcessingPartAndLotModel;
import cn.estsh.i3plus.pojo.base.bean.ListPager;
import cn.estsh.i3plus.pojo.base.common.Pager;
import cn.estsh.i3plus.pojo.mes.bean.nc.MesPartInspection;
import io.swagger.annotations.ApiOperation;
import java.util.List;
/**
* @Description :
* @Reference :
@ -19,8 +18,11 @@ import java.util.List;
public interface IMesNcProcessingService {
@ApiOperation(value = "扫描产品条码")
public MesNcProcessingModel queryProduceSn(String serialNumber, String partNo, String lot, String org);
@ApiOperation(value = "查询NC-零件检测-单据")
public ListPager<MesPartInspection> queryPartInspectionByPager(MesPartInspection partInspection, Pager pager);
@ApiOperation(value = "查询NC-零件检测-单据")
public MesNcProcessingModel queryPartInspection(MesPartInspection partInspection);
@ApiOperation(value = "查询标记不良的物料及批次")
public ListPager<MesNcProcessingPartAndLotModel> queryPartLot(String partNo, String lot, String org, Pager pager);

@ -7,6 +7,7 @@ import cn.estsh.i3plus.pojo.mes.bean.MesEquipmentVariableCfg;
import cn.estsh.i3plus.pojo.mes.bean.MesProdRouteOptParam;
import cn.estsh.i3plus.pojo.mes.model.StationKvBean;
import cn.estsh.i3plus.pojo.mes.model.StationRequestBean;
import cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil;
import io.swagger.annotations.ApiOperation;
import java.util.List;
@ -15,15 +16,6 @@ import java.util.Optional;
public interface IMesProductionProcessContextStepService {
@ApiOperation(value = "存储上下文对象")
Boolean doCacheContext(StationRequestBean reqBean, String item, Object o);
@ApiOperation(value = "获取上下文对象")
String getCachedContext(StationRequestBean reqBean, String item);
@ApiOperation(value = "获取展示组件MODULE_CONTENT内容")
List<List<StationKvBean>> getCachedModuleContext(StationRequestBean reqBean);
@ApiOperation(value = "存储生产过程上下文对象【工步根据业务实际情况执行,配置错误等情况无需执行】")
Boolean doCacheProductionProcessContext(StationRequestBean reqBean, MesProductionProcessContext productionProcessContext);
@ -90,4 +82,29 @@ public interface IMesProductionProcessContextStepService {
@ApiOperation(value = "发送设备质量信息")
void sendEquipQualityMessage(StationRequestBean reqBean, MesCellEquipContext cellEquipContext);
@ApiOperation(value = "存储展示组件MODULE_CONTENT内容")
Boolean doCacheModuleContext(StationRequestBean reqBean, List<List<StationKvBean>> dataList);
@ApiOperation(value = "获取展示组件MODULE_CONTENT内容")
List<List<StationKvBean>> getCachedModuleContext(StationRequestBean reqBean);
@ApiOperation(value = "存储上个扫描/读取信息")
Boolean doCacheLastScanContext(StationRequestBean reqBean, List<StationKvBean> dataList);
@ApiOperation(value = "获取上个扫描/读取信息")
List<StationKvBean> getCachedLastScanContext(StationRequestBean reqBean);
@ApiOperation(value = "发送工步内容")
void doSendStepContextMessage(StationRequestBean reqBean);
@ApiOperation(value = "发送工步内容")
void doSendStepContextMessage(StationRequestBean reqBean, String scanInfo, MesExtEnumUtil.CELL_MESSAGE_SOURCE source);
@ApiOperation(value = "发送工步内容")
void sendStepContextMessage(StationRequestBean reqBean, List<StationKvBean> resultList);
}

@ -2,6 +2,7 @@ package cn.estsh.i3plus.ext.mes.pcn.api.busi;
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.MesWorkOrder;
import io.swagger.annotations.ApiOperation;
@ -26,5 +27,7 @@ public interface IMesWorkOrderService {
@ApiOperation(value = "查询工单")
public ListPager<MesWorkOrder> queryMesWorkOrderListByPager(MesWorkOrder workOrder, Pager pager);
void doProductReport(List<MesProduceSn> mesProduceSnList);
}

@ -33,7 +33,8 @@ public class MesInputDefectRecordController {
try {
return ResultBean.success("查询成功").setResultObject(inputDefectRecordService.queryPartInspection(model, AuthUtil.getOrganizeCode()));
return ResultBean.success("查询成功").setResultObject(inputDefectRecordService.queryPartInspection(model, "CK01"));
// return ResultBean.success("查询成功").setResultObject(inputDefectRecordService.queryPartInspection(model, AuthUtil.getOrganizeCode()));
} catch (ImppBusiException imppException) {
return ResultBean.fail(imppException);
} catch (Exception e) {
@ -61,17 +62,18 @@ public class MesInputDefectRecordController {
}
@PostMapping("/save-defect-record")
@ApiOperation(value = "完成质检-保存不良记录")
public ResultBean saveDefectRecord(@RequestBody MesPartInspectionInputModel model) {
@ApiOperation(value = "完成质检")
public ResultBean savePartInspection(@RequestBody MesPartInspectionInputModel model) {
try {
if (StringUtils.isEmpty(model.getSerialNumber()) &&
if (StringUtils.isEmpty(model.getSn()) &&
(StringUtils.isEmpty(model.getPartNo()) || StringUtils.isEmpty(model.getLot()) || StringUtils.isEmpty(model.getQty()))) {
throw new ImppBusiException("条码为空或零件号+批次+数量为空");
}
// inputDefectRecordService.savePartInspection(model, "CK01");
inputDefectRecordService.savePartInspection(model, AuthUtil.getOrganizeCode());
return ResultBean.success("质检已完成,请继续");
} catch (ImppBusiException imppException) {

@ -4,9 +4,9 @@ package cn.estsh.i3plus.ext.mes.pcn.apiservice.controller.busi;
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesNcProcessingService;
import cn.estsh.i3plus.ext.mes.pcn.pojo.constant.MesCommonConstant;
import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesNcProcessingInputModel;
import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesNcProcessingPartAndLotModel;
import cn.estsh.i3plus.pojo.base.bean.ListPager;
import cn.estsh.i3plus.pojo.base.common.Pager;
import cn.estsh.i3plus.pojo.mes.bean.nc.MesPartInspection;
import cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil;
import cn.estsh.impp.framework.boot.auth.AuthUtil;
import cn.estsh.impp.framework.boot.exception.ImppBusiException;
@ -30,17 +30,15 @@ public class MesNcProcessingController {
private IMesNcProcessingService ncProcessingService;
@GetMapping("/query")
@ApiOperation(value = "查询产品条码或零件号+批次")
public ResultBean queryProduceSn(String serialNumber, String partNo, String lot) {
@GetMapping("/query-part-inspection-pager")
@ApiOperation(value = "查询NC-零件检测-单据")
public ResultBean queryPartInspectionByPager(MesPartInspection partInspection, Pager pager) {
try {
// 数据校验
if (StringUtils.isEmpty(serialNumber) && (StringUtils.isEmpty(partNo) || StringUtils.isEmpty(lot))) {
throw new ImppBusiException("产品条码为空或零件号+批次为空");
}
return ResultBean.success("查询成功").setResultObject(ncProcessingService.queryProduceSn(serialNumber, partNo, lot, AuthUtil.getOrganizeCode()));
partInspection.setOrganizeCode(AuthUtil.getOrganizeCode());
ListPager<MesPartInspection> partInspectionListPager = ncProcessingService.queryPartInspectionByPager(partInspection, pager);
return ResultBean.success("查询成功").setListPager(partInspectionListPager);
} catch (ImppBusiException imppException) {
return ResultBean.fail(imppException);
} catch (Exception e) {
@ -48,17 +46,14 @@ public class MesNcProcessingController {
}
}
@GetMapping("/query-part-lot")
@ApiOperation(value = "查询零件批次")
public ResultBean queryPartLot(String partNo, String lot, Pager pager) {
@GetMapping("/query-part-inspection")
@ApiOperation(value = "查询NC-零件检测-单据")
public ResultBean queryPartInspection(MesPartInspection partInspection) {
try {
// 数据校验
// ValidatorBean.checkNotNull(partNo, "零件号不能为空");
// ValidatorBean.checkNotNull(lot, "不能为空");
ListPager<MesNcProcessingPartAndLotModel> modelList = ncProcessingService.queryPartLot(partNo, lot, AuthUtil.getOrganizeCode(), pager);
return ResultBean.success("查询成功").setListPager(modelList);
partInspection.setOrganizeCode(AuthUtil.getOrganizeCode());
return ResultBean.success("查询成功").setResultObject(ncProcessingService.queryPartInspection(partInspection));
} catch (ImppBusiException imppException) {
return ResultBean.fail(imppException);
} catch (Exception e) {
@ -66,16 +61,19 @@ public class MesNcProcessingController {
}
}
@PostMapping("/save-nc")
@ApiOperation(value = "NC处理")
public ResultBean saveNc(@RequestBody MesNcProcessingInputModel model) {
try {
// 数据校验
ValidatorBean.checkNotNull(model.getType(), "类型不能为空");
if (StringUtils.isEmpty(model.getSerialNumber()) && (StringUtils.isEmpty(model.getPartNo()) || StringUtils.isEmpty(model.getLot()))) {
throw new ImppBusiException("产品条码为空或零件号+批次为空");
}
ValidatorBean.checkNotNull(model.getPartInspection(), "单据不能为空");
ValidatorBean.checkNotNull(model.getPartInspectionDetailList(), "单据明细不能为空");
ValidatorBean.checkNotNull(model.getPerson(), "责任人不能为空");
// if (StringUtils.isEmpty(model.getSn()) && (StringUtils.isEmpty(model.getPartNo()) || StringUtils.isEmpty(model.getLot()))) {
// throw new ImppBusiException("产品条码为空或零件号+批次为空");
// }
String description = MesExtEnumUtil.NC_TYPE.valueOfDescription(model.getType());
if (StringUtils.isEmpty(description)) {

@ -3,6 +3,8 @@ package cn.estsh.i3plus.ext.mes.pcn.apiservice.controller.busi;
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesWorkOrderService;
import cn.estsh.i3plus.ext.mes.pcn.pojo.constant.MesCommonConstant;
import cn.estsh.i3plus.pojo.base.common.Pager;
import cn.estsh.i3plus.pojo.base.enumutil.ResourceEnumUtil;
import cn.estsh.i3plus.pojo.mes.bean.MesProduceSn;
import cn.estsh.i3plus.pojo.mes.bean.MesWorkOrder;
import cn.estsh.impp.framework.boot.exception.ImppBusiException;
import cn.estsh.impp.framework.boot.exception.ImppExceptionBuilder;
@ -11,9 +13,9 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* @Description :
@ -58,4 +60,18 @@ public class MesWorkOrderController {
return ImppExceptionBuilder.newInstance().buildExceptionResult(e);
}
}
@PostMapping(value = "/doProductReport")
@ApiOperation(value = "生产报工")
public ResultBean doProductReport(@RequestBody List<MesProduceSn> mesProduceSnList) {
try {
workOrderService.doProductReport(mesProduceSnList);
return ResultBean.success("操作成功")
.setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode());
} catch (ImppBusiException e) {
return ResultBean.fail(e).build();
} catch (Exception e) {
return ResultBean.fail(e);
}
}
}

@ -88,11 +88,11 @@ public class MesInputDefectRecordService implements IMesInputDefectRecordService
//获取NC-零件检测-单据
MesPartInspection partInspection;
Integer sourceType = null;
if (!StringUtils.isEmpty(inputModel.getSerialNumber())) {
if (!StringUtils.isEmpty(inputModel.getSn())) {
// 数据校验
ValidatorBean.checkNotNull(inputModel.getFrontBack(), "正反面不能为空");
//检查条码
MesProduceSn produceSn = checkProduceSn(inputModel.getSerialNumber(), org);
MesProduceSn produceSn = checkProduceSn(inputModel.getSn(), org);
//获取NC-零件检测-单据
partInspection = getPartInspection(inputModel, org);
@ -100,6 +100,7 @@ public class MesInputDefectRecordService implements IMesInputDefectRecordService
//检查物料
part = checkPart(produceSn, org);
sourceType = MesExtEnumUtil.PART_INSPECTION_SOURCE_TYPE.SINGLE.getValue();
} else {
// 数据校验
@ -121,7 +122,7 @@ public class MesInputDefectRecordService implements IMesInputDefectRecordService
MesPartTypePicture partTypePicture = checkPartTypePicture(part, org);
//构造返回信息
MesPartInspectionViewModel model = getModel(partInspection, part, partTypePicture, inputModel.getFrontBack(), org);
MesPartInspectionViewModel model = getModel(partInspection, part, partTypePicture, inputModel.getFrontBack(), sourceType, org);
model.setSourceType(sourceType);
model.setTransferFlg(inputModel.isTransferFlg());
@ -205,9 +206,17 @@ public class MesInputDefectRecordService implements IMesInputDefectRecordService
//若检验单为空,则生成新的单据并合格
if (StringUtils.isEmpty(model.getPartInspection())) {
partInspection = createPartInspection(model, MesExtEnumUtil.PART_INSPECTION_STATUS.FAIL.getValue(), org);
partInspection = createPartInspection(model, MesExtEnumUtil.PART_INSPECTION_STATUS.QUALIFIED.getValue(), org);
partInspectionRepository.save(partInspection);
if (model.getSourceType() == MesExtEnumUtil.PART_INSPECTION_SOURCE_TYPE.SINGLE.getValue()) {
MesProduceSn produceSn = checkProduceSn(model.getSn(), org);
produceSn.setQcStatus(MesExtEnumUtil.PRODUCE_QC_STATUS.QUALIFIED.getValue());
ConvertBean.serviceModelInitialize(produceSn, AuthUtil.getSessionUser().getUserName());
produceSnRepository.save(produceSn);
}
} else {
//原单据不合格 现合格
@ -228,6 +237,13 @@ public class MesInputDefectRecordService implements IMesInputDefectRecordService
partInspectionDetailRepository.saveAll(resultDetailList);
partInspectionDetailRepository.saveAll(model.getPartInspectionDetailList());
if (model.getSourceType() == MesExtEnumUtil.PART_INSPECTION_SOURCE_TYPE.SINGLE.getValue()) {
MesProduceSn produceSn = checkProduceSn(model.getSn(), org);
produceSn.setQcStatus(MesExtEnumUtil.PRODUCE_QC_STATUS.QUALIFIED.getValue());
ConvertBean.serviceModelInitialize(produceSn, AuthUtil.getSessionUser().getUserName());
produceSnRepository.save(produceSn);
}
//移库
MesMove move = createMove(model, configService.getCfgValue(org, "UMLGO"), configService.getCfgValue(org, "LGORT"), org);
moveRepository.save(move);
@ -252,6 +268,13 @@ public class MesInputDefectRecordService implements IMesInputDefectRecordService
partInspectionDetailRepository.saveAll(model.getPartInspectionDetailList());
if (model.getSourceType() == MesExtEnumUtil.PART_INSPECTION_SOURCE_TYPE.SINGLE.getValue()) {
MesProduceSn produceSn = checkProduceSn(model.getSn(), org);
produceSn.setQcStatus(MesExtEnumUtil.PRODUCE_QC_STATUS.SUSPICIOUS.getValue());
ConvertBean.serviceModelInitialize(produceSn, AuthUtil.getSessionUser().getUserName());
produceSnRepository.save(produceSn);
}
//移库
MesMove move = createMove(model, configService.getCfgValue(org, "LGORT"), configService.getCfgValue(org, "UMLGO"), org);
moveRepository.save(move);
@ -272,6 +295,13 @@ public class MesInputDefectRecordService implements IMesInputDefectRecordService
ConvertBean.serviceModelInitialize(k, AuthUtil.getSessionUser().getUserName());
});
if (model.getSourceType() == MesExtEnumUtil.PART_INSPECTION_SOURCE_TYPE.SINGLE.getValue()) {
MesProduceSn produceSn = checkProduceSn(model.getSn(), org);
produceSn.setQcStatus(MesExtEnumUtil.PRODUCE_QC_STATUS.SUSPICIOUS.getValue());
ConvertBean.serviceModelInitialize(produceSn, AuthUtil.getSessionUser().getUserName());
produceSnRepository.save(produceSn);
}
partInspectionDetailRepository.saveAll(resultDetailList);
partInspectionDetailRepository.saveAll(model.getPartInspectionDetailList());
@ -296,7 +326,7 @@ public class MesInputDefectRecordService implements IMesInputDefectRecordService
//根据条码找最近一条单据
DdlPackBean packBean = DdlPackBean.getDdlPackBean(org);
DdlPreparedPack.getStringEqualPack(inputModel.getSerialNumber(), "sn", packBean);
DdlPreparedPack.getStringEqualPack(inputModel.getSn(), "sn", packBean);
DdlPreparedPack.getOrderByPack(new Object[]{CommonEnumUtil.ASC_OR_DESC.DESC.getValue()}, new String[]{"createDatetime"}, packBean);
MesPartInspection partInspection = partInspectionRepository.getByProperty(packBean);
@ -431,11 +461,11 @@ public class MesInputDefectRecordService implements IMesInputDefectRecordService
MesExtEnumUtil.PRODUCE_SN_STATUS.OFFLINE.getDescription()));
}
//是否需要判断条码质量状态
if (produceSn.getQcStatus() != MesExtEnumUtil.PRODUCE_QC_STATUS.QUALIFIED.getValue()) {
throw new ImppBusiException(String.format("【%s】此条码质量状态为【%s】,请选择【%s】状态的条码", serialNumber, MesExtEnumUtil.PRODUCE_QC_STATUS.valueOfDescription(produceSn.getQcStatus()),
MesExtEnumUtil.PRODUCE_QC_STATUS.QUALIFIED.getDescription()));
}
// //是否需要判断条码质量状态
// if (produceSn.getQcStatus() != MesExtEnumUtil.PRODUCE_QC_STATUS.QUALIFIED.getValue()) {
// throw new ImppBusiException(String.format("【%s】此条码质量状态为【%s】,请选择【%s】状态的条码", serialNumber, MesExtEnumUtil.PRODUCE_QC_STATUS.valueOfDescription(produceSn.getQcStatus()),
// MesExtEnumUtil.PRODUCE_QC_STATUS.QUALIFIED.getDescription()));
// }
return produceSn;
}
@ -455,7 +485,7 @@ public class MesInputDefectRecordService implements IMesInputDefectRecordService
partInspection.setInspectionDate(TimeTool.getToday());
partInspection.setInspectionStatus(inspectionStatus);
partInspection.setNcStatus(MesExtEnumUtil.PART_INSPECTION_NC_STATUS.CREATE.getValue());
partInspection.setSn(model.getSerialNumber());
partInspection.setSn(model.getSn());
partInspection.setLot(model.getLot());
partInspection.setQty(model.getQty());
partInspection.setWorkCenterCode(model.getWorkCenterCode());
@ -505,12 +535,12 @@ public class MesInputDefectRecordService implements IMesInputDefectRecordService
//若不存在则提示物料信息不存在
if (StringUtils.isEmpty(part)) {
throw new ImppBusiException(String.format("【%s】此条码对应【%s】物料号不存在请检查数据", produceSn.getSerialNumber(), produceSn.getPartNo()));
throw new ImppBusiException(String.format("【%s】此条码对应【%s】物料号不存在请检查数据", produceSn.getProductSn(), produceSn.getPartNo()));
}
//根据条码查询零件类型partType
if (StringUtils.isEmpty(part.getPartTypeCode())) {
throw new ImppBusiException(String.format("【%s】此条码对应【%s】物料号未维护零件类型请检查数据", produceSn.getSerialNumber(), produceSn.getPartNo()));
throw new ImppBusiException(String.format("【%s】此条码对应【%s】物料号未维护零件类型请检查数据", produceSn.getProductSn(), produceSn.getPartNo()));
}
@ -606,7 +636,8 @@ public class MesInputDefectRecordService implements IMesInputDefectRecordService
return alarmConfigList;
}
private MesPartInspectionViewModel getModel(MesPartInspection partInspection, MesPart part, MesPartTypePicture partTypePicture, Integer frontBack, String org) {
private MesPartInspectionViewModel getModel(MesPartInspection partInspection, MesPart part, MesPartTypePicture partTypePicture, Integer frontBack,
Integer sourceType, String org) {
List<MesPartInspectionDetail> detailList = new ArrayList<>();
@ -615,6 +646,16 @@ public class MesInputDefectRecordService implements IMesInputDefectRecordService
detailList = checkPartInspectionDetail(partInspection, org);
}
// if (sourceType == MesExtEnumUtil.PART_INSPECTION_SOURCE_TYPE.SINGLE.getValue()) {
//
// partInspection.getSn();
// DdlPackBean packBean = DdlPackBean.getDdlPackBean(org);
// DdlPreparedPack.getStringEqualPack(partInspection.getSn(), "sn", packBean);
// List<MesPartInspection> partInspectionList = partInspectionRepository.findByHqlWhere(packBean);
//
// for()
//
// }
//位置
List<MesLocationConfig> locationConfigList = checkLocationConfig(org);
List<String> locationCodeList = locationConfigList.stream().map(k -> k.getDefectLocation()).collect(Collectors.toList());
@ -630,6 +671,7 @@ public class MesInputDefectRecordService implements IMesInputDefectRecordService
Map<String, MesDefectWarnConfig> alarmConfigMap = alarmConfigList.stream().collect(Collectors.toMap(k -> k.getDefectLocation(), k -> k));
locationConfigList.forEach(k -> {
k.setFrontBack(frontBack);
if (alarmConfigMap.containsKey(k.getDefectLocation())) {
k.setIsflg(true);
}

@ -6,7 +6,6 @@ import cn.estsh.i3plus.ext.mes.pcn.apiservice.dao.IMesNcProcessingDao;
import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesNcProcessingInputModel;
import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesNcProcessingModel;
import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesNcProcessingPartAndLotModel;
import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesNcProcessingViewModel;
import cn.estsh.i3plus.mes.pcn.api.iservice.busi.ISyncFuncService;
import cn.estsh.i3plus.platform.common.convert.ConvertBean;
import cn.estsh.i3plus.platform.common.tool.TimeTool;
@ -17,6 +16,9 @@ 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.*;
import cn.estsh.i3plus.pojo.mes.bean.nc.MesPartInspection;
import cn.estsh.i3plus.pojo.mes.bean.nc.MesPartInspectionDetail;
import cn.estsh.i3plus.pojo.mes.bean.rework.MesReworkTask;
import cn.estsh.i3plus.pojo.mes.model.GenSerialNoModel;
import cn.estsh.i3plus.pojo.mes.repository.*;
import cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil;
@ -29,7 +31,6 @@ 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.stream.Collectors;
@ -74,40 +75,60 @@ public class MesNcProcessingService implements IMesNcProcessingService {
@Autowired
private MesProduceSnRepository produceSnRepository;
/***
*
* @param serialNumber
* @param partNo
* @param lot
* @param org
* @return
*/
@Autowired
private MesPartInspectionRepository partInspectionRepository;
@Autowired
private MesPartInspectionDetailRepository partInspectionDetailRepository;
@Autowired
private MesReworkTaskRepository reworkTaskRepository;
@Override
public MesNcProcessingModel queryProduceSn(String serialNumber, String partNo, String lot, String org) {
public ListPager<MesPartInspection> queryPartInspectionByPager(MesPartInspection partInspection, Pager pager) {
DdlPackBean packBean = DdlPackBean.getDdlPackBean(partInspection.getOrganizeCode());
DdlPreparedPack.getStringEqualPack(partInspection.getSn(), "sn", packBean);
DdlPreparedPack.getStringEqualPack(partInspection.getPartNo(), "partNo", packBean);
DdlPreparedPack.getStringLikerPack(partInspection.getPartName(), "partName", packBean);
DdlPreparedPack.getStringEqualPack(partInspection.getLot(), "lot", packBean);
DdlPreparedPack.getNumEqualPack(partInspection.getQty(), "qty", packBean);
DdlPreparedPack.getNumEqualPack(MesExtEnumUtil.PART_INSPECTION_STATUS.FAIL.getValue(), "inspectionStatus", packBean);
DdlPreparedPack.getOrderByPack(new Object[]{CommonEnumUtil.ASC_OR_DESC.DESC.getValue()}, new String[]{"createDatetime"}, packBean);
pager = PagerHelper.getPager(pager, partInspectionRepository.findByHqlWhereCount(packBean));
List<MesPartInspection> resultList = partInspectionRepository.findByHqlWherePage(packBean, pager);
if (!StringUtils.isEmpty(serialNumber)) {
//检查不良条码
List<MesDefectRecord> defectRecordList = queryDefectRecordBySerialNumber(serialNumber, org);
return new ListPager<>(resultList, pager);
}
//检查物料
MesPart part = checkPart(defectRecordList, org);
@Override
public MesNcProcessingModel queryPartInspection(MesPartInspection partInspection) {
//构造返回结果
MesNcProcessingModel model = getModel(part, defectRecordList, org);
return model;
} else {
DdlPackBean packBean = DdlPackBean.getDdlPackBean(partInspection.getOrganizeCode());
DdlPreparedPack.getNumEqualPack(partInspection.getId(), "pid", packBean);
List<MesPartInspectionDetail> detailList = partInspectionDetailRepository.findByHqlWhere(packBean);
//检查不良条码
List<MesDefectRecord> defectRecordList = queryDefectRecordByPartAndLot(partNo, lot, org);
//检查物料
MesPart part = null;
if (partInspection.getSourceType() == MesExtEnumUtil.PART_INSPECTION_SOURCE_TYPE.SINGLE.getValue()) {
//检查条码
MesProduceSn produceSn = checkProduceSn(partInspection.getSn(), partInspection.getOrganizeCode());
//检查物料
MesPart part = checkPartByPartNo(partNo, org);
part = checkPart(produceSn, partInspection.getOrganizeCode());
//构造返回结果
MesNcProcessingModel model = getModel(part, defectRecordList, org);
return model;
} else {
//检查物料
part = checkPartByPartNo(partInspection.getPartNo(), partInspection.getOrganizeCode());
}
//构造返回结果
MesNcProcessingModel model = getModel(part, detailList, partInspection.getOrganizeCode());
return model;
}
@Override
@ -123,58 +144,52 @@ public class MesNcProcessingService implements IMesNcProcessingService {
@Override
public void saveNc(MesNcProcessingInputModel model, String org) {
if (!StringUtils.isEmpty(model.getSerialNumber())) {
String serialNumber = model.getSerialNumber();
if (model.getPartInspection().getSourceType() == MesExtEnumUtil.PART_INSPECTION_SOURCE_TYPE.SINGLE.getValue()) {
String serialNumber = model.getPartInspection().getSn();
Integer type = model.getType();
Integer person = model.getPerson();
//检查不良条码
List<MesDefectRecord> defectRecordList = queryDefectRecordBySerialNumber(serialNumber, org);
//检查物料
MesPart part = checkPartByPartNo(defectRecordList.get(0).getPartNo(), org);
MesPart part = checkPartByPartNo(model.getPartInspection().getPartNo(), org);
//保存数据
saveDate(part, defectRecordList, type, person, org);
saveDate(model, part, type, person, org);
} else {
String partNo = model.getPartNo();
String lot = model.getLot();
String partNo = model.getPartInspection().getPartNo();
String lot = model.getPartInspection().getLot();
Integer type = model.getType();
Integer person = model.getPerson();
//检查不良条码
List<MesDefectRecord> defectRecordList = queryDefectRecordByPartAndLot(partNo, lot, org);
//检查物料
MesPart part = checkPartByPartNo(partNo, org);
//保存数据
saveDate(part, defectRecordList, type, person, org);
saveDate(model, part, type, person, org);
}
}
/**
*
*
* @param defectRecordList
* @param produceSn
* @param org
* @return
*/
private MesPart checkPart(List<MesDefectRecord> defectRecordList, String org) {
private MesPart checkPart(MesProduceSn produceSn, String org) {
DdlPackBean packBean = DdlPackBean.getDdlPackBean(org);
DdlPreparedPack.getStringEqualPack(defectRecordList.get(0).getPartNo(), "partNo", packBean);
DdlPreparedPack.getStringEqualPack(produceSn.getPartNo(), "partNo", packBean);
MesPart part = partRepository.getByProperty(packBean);
//若不存在则提示物料信息不存在
if (StringUtils.isEmpty(part)) {
throw new ImppBusiException(String.format("【%s】此条码对应【%s】物料号不存在请检查数据", defectRecordList.get(0).getSerialNumber(), defectRecordList.get(0).getPartNo()));
throw new ImppBusiException(String.format("【%s】此条码对应【%s】物料号不存在请检查数据", produceSn.getProductSn(), produceSn.getPartNo()));
}
//根据条码查询零件类型partType
if (StringUtils.isEmpty(part.getPartTypeCode())) {
throw new ImppBusiException(String.format("【%s】此条码对应【%s】物料号未维护零件类型请检查数据", defectRecordList.get(0).getSerialNumber(), defectRecordList.get(0).getPartNo()));
throw new ImppBusiException(String.format("【%s】此条码对应【%s】物料号未维护零件类型请检查数据", produceSn.getProductSn(), produceSn.getPartNo()));
}
@ -301,11 +316,11 @@ public class MesNcProcessingService implements IMesNcProcessingService {
*
*
* @param part
* @param defectRecordList
* @param detailList
* @param org
* @return
*/
private MesNcProcessingModel getModel(MesPart part, List<MesDefectRecord> defectRecordList, String org) {
private MesNcProcessingModel getModel(MesPart part, List<MesPartInspectionDetail> detailList, String org) {
//todo 图片暂时放空
//检查零件类型与图片对应关系
MesPartTypePicture partTypePicture = checkPartTypePicture(part, org);
@ -313,10 +328,10 @@ public class MesNcProcessingService implements IMesNcProcessingService {
//位置
List<MesLocationConfig> locationConfigList = checkLocationConfig(org);
Map<String, List<MesDefectRecord>> defectRecordMap = defectRecordList.stream().collect(Collectors.groupingBy(k -> k.getDefectLocation()));
Map<String, List<MesPartInspectionDetail>> defectRecordMap = detailList.stream().collect(Collectors.groupingBy(k -> k.getDefectLocation()));
Map<String, List<MesDefectRecord>> defectMap = defectRecordList.stream().collect(Collectors.groupingBy(k -> k.getDefectTypeCode()));
// Map<String, List<MesPartInspectionDetail>> defectMap = detailList.stream().collect(Collectors.groupingBy(k -> k.getDefectTypeCode()));
//位置是否标黄Map,key位置value标黄标识
locationConfigList.forEach(k -> {
@ -325,17 +340,17 @@ public class MesNcProcessingService implements IMesNcProcessingService {
}
});
List<MesNcProcessingViewModel> defectModelList = new ArrayList<>();
defectMap.forEach((k, v) -> {
MesNcProcessingViewModel model = new MesNcProcessingViewModel();
model.setDefectTypeCode(k);
model.setQty(v.size());
model.setDefectTypeName(v.get(0).getDefectTypeName());
defectModelList.add(model);
});
// List<MesNcProcessingViewModel> defectModelList = new ArrayList<>();
// defectMap.forEach((k, v) -> {
// MesNcProcessingViewModel model = new MesNcProcessingViewModel();
// model.setDefectTypeCode(k);
// model.setQty(v.size());
// model.setDefectTypeName(v.get(0).getDefectTypeName());
// defectModelList.add(model);
// });
MesNcProcessingModel model = new MesNcProcessingModel();
model.setDefectModelList(defectModelList);
model.setDetailList(detailList);
model.setPartTypePicture(partTypePicture);
model.setLocationConfigList(locationConfigList);
return model;
@ -345,37 +360,130 @@ public class MesNcProcessingService implements IMesNcProcessingService {
*
*
* @param part
* @param defectRecordList
* @param model
* @param type
* @param person
* @param org
*/
private void saveDate(MesPart part, List<MesDefectRecord> defectRecordList, Integer type, Integer person, String org) {
GenSerialNoModel serialNoModel = new GenSerialNoModel("NC_DEFECT_ZRSUM");
serialNoModel.setPartNo(part.getPartNo());
ResultBean rb = syncFuncService.syncSerialNo(serialNoModel, AuthUtil.getSessionUser().getUserName(), org, 1);
String zrsum = "";
if (null != rb && !CollectionUtils.isEmpty(rb.getResultList())) {
zrsum = (rb.getResultList().get(0)).toString();
}
private void saveDate(MesNcProcessingInputModel model, MesPart part, Integer type, Integer person, String org) {
if (type == MesExtEnumUtil.NC_TYPE.NORMAL.getValue()) {
MesProduceSn sn = checkProduceSn(model.getSn(), org);
sn.setQcStatus(MesExtEnumUtil.PRODUCE_QC_STATUS.QUALIFIED.getValue());
ConvertBean.serviceModelUpdate(sn, AuthUtil.getSessionUser().getUserName());
produceSnRepository.save(sn);
model.getPartInspection().setInspectionStatus(MesExtEnumUtil.PART_INSPECTION_STATUS.QUALIFIED.getValue());
model.getPartInspection().setNcStatus(MesExtEnumUtil.PART_INSPECTION_NC_STATUS.NORMAL.getValue());
ConvertBean.serviceModelUpdate(sn, AuthUtil.getSessionUser().getUserName());
partInspectionRepository.save(model.getPartInspection());
GenSerialNoModel serialNoModel = new GenSerialNoModel("NC_DEFECT_ZRSUM");
serialNoModel.setPartNo(part.getPartNo());
ResultBean rb = syncFuncService.syncSerialNo(serialNoModel, AuthUtil.getSessionUser().getUserName(), org, 1);
String zrsum = "";
if (null != rb && !CollectionUtils.isEmpty(rb.getResultList())) {
zrsum = (rb.getResultList().get(0)).toString();
}
MesMove move = new MesMove();
move.setMatnr(part.getPartNo());
move.setOrganizeCode(org);
move.setFactoryCode(org);
move.setLgort(configService.getCfgValue(org, "UMLGO"));
move.setUmlgo(configService.getCfgValue(org, "LGORT"));
move.setMenge(model.getPartInspection().getQty().intValue());
move.setMeins(part.getUnit());
move.setZrsum(zrsum);
move.setPostDate(TimeTool.getToday());
move.setPostTime(TimeTool.getTimeShortWithColon());
ConvertBean.serviceModelInitialize(move, AuthUtil.getSessionUser().getUserName());
moveRepository.save(move);
} else if (type == MesExtEnumUtil.NC_TYPE.REWORK.getValue()) {
GenSerialNoModel serialNoModel1 = new GenSerialNoModel("NC_REWORK");
serialNoModel1.setPartNo(part.getPartNo());
ResultBean rb1 = syncFuncService.syncSerialNo(serialNoModel1, AuthUtil.getSessionUser().getUserName(), org, 1);
String rework = "";
if (null != rb1 && !CollectionUtils.isEmpty(rb1.getResultList())) {
rework = (rb1.getResultList().get(0)).toString();
}
if (type == MesExtEnumUtil.NC_TYPE.NORMAL.getValue() || type == MesExtEnumUtil.NC_TYPE.RELEASE.getValue()) {
MesReworkTask reworkTask = new MesReworkTask();
reworkTask.setReworkedQty(model.getPartInspection().getQty());
reworkTask.setSn(model.getPartInspection().getSn());
reworkTask.setReworkOrder(rework);
reworkTask.setPartNo(model.getPartInspection().getPartNo());
reworkTask.setPartInspectionId(model.getPartInspection().getId());
reworkTask.setOrganizeCode(org);
reworkTask.setType(model.getPartInspection().getSourceType());
ConvertBean.serviceModelInitialize(reworkTask, AuthUtil.getSessionUser().getUserName());
reworkTaskRepository.save(reworkTask);
model.getPartInspection().setNcStatus(MesExtEnumUtil.PART_INSPECTION_NC_STATUS.REWORK.getValue());
model.getPartInspection().setDefectTypeId(reworkTask.getId());
partInspectionRepository.save(model.getPartInspection());
} else if (type == MesExtEnumUtil.NC_TYPE.SCRAP.getValue()) {
MesProduceSn sn = checkProduceSn(model.getSn(), org);
sn.setQcStatus(MesExtEnumUtil.PRODUCE_QC_STATUS.SCRAP.getValue());
ConvertBean.serviceModelUpdate(sn, AuthUtil.getSessionUser().getUserName());
produceSnRepository.save(sn);
String serialNumber = defectRecordList.get(0).getSerialNumber();
model.getPartInspection().setNcStatus(MesExtEnumUtil.PART_INSPECTION_NC_STATUS.SCRAP.getValue());
model.getPartInspection().setRejectQty(model.getPartInspection().getQty());
ConvertBean.serviceModelUpdate(sn, AuthUtil.getSessionUser().getUserName());
partInspectionRepository.save(model.getPartInspection());
GenSerialNoModel serialNoModel = new GenSerialNoModel("NC_DEFECT_ZRSUM");
serialNoModel.setPartNo(part.getPartNo());
ResultBean rb = syncFuncService.syncSerialNo(serialNoModel, AuthUtil.getSessionUser().getUserName(), org, 1);
String zrsum = "";
if (null != rb && !CollectionUtils.isEmpty(rb.getResultList())) {
zrsum = (rb.getResultList().get(0)).toString();
}
MesProduceSn sn = checkProduceSn(serialNumber, org);
MesMove move = new MesMove();
move.setMatnr(part.getPartNo());
move.setOrganizeCode(org);
move.setFactoryCode(org);
move.setLgort(configService.getCfgValue(org, "UMLGO"));
move.setUmlgo(configService.getCfgValue(org, "LGORT"));
move.setMenge(model.getPartInspection().getQty().intValue());
move.setMeins(part.getUnit());
move.setZrsum(zrsum);
move.setPostDate(TimeTool.getToday());
move.setPostTime(TimeTool.getTimeShortWithColon());
ConvertBean.serviceModelInitialize(move, AuthUtil.getSessionUser().getUserName());
moveRepository.save(move);
} else if (type == MesExtEnumUtil.NC_TYPE.RELEASE.getValue()) {
MesProduceSn sn = checkProduceSn(model.getSn(), org);
sn.setQcStatus(MesExtEnumUtil.PRODUCE_QC_STATUS.QUALIFIED.getValue());
sn.setSnStatus(MesExtEnumUtil.PRODUCE_SN_STATUS.OFFLINE.getValue());
ConvertBean.serviceModelUpdate(sn, AuthUtil.getSessionUser().getUserName());
produceSnRepository.save(sn);
model.getPartInspection().setInspectionStatus(MesExtEnumUtil.PART_INSPECTION_STATUS.QUALIFIED.getValue());
model.getPartInspection().setNcStatus(MesExtEnumUtil.PART_INSPECTION_NC_STATUS.RELEASE.getValue());
ConvertBean.serviceModelUpdate(sn, AuthUtil.getSessionUser().getUserName());
partInspectionRepository.save(model.getPartInspection());
GenSerialNoModel serialNoModel = new GenSerialNoModel("NC_DEFECT_ZRSUM");
serialNoModel.setPartNo(part.getPartNo());
ResultBean rb = syncFuncService.syncSerialNo(serialNoModel, AuthUtil.getSessionUser().getUserName(), org, 1);
String zrsum = "";
if (null != rb && !CollectionUtils.isEmpty(rb.getResultList())) {
zrsum = (rb.getResultList().get(0)).toString();
}
MesMove move = new MesMove();
move.setMatnr(part.getPartNo());
move.setOrganizeCode(org);
move.setFactoryCode(org);
move.setLgort(configService.getCfgValue(org, "UMLGO"));
move.setUmlgo(configService.getCfgValue(org, "LGORT"));
move.setMenge(defectRecordList.get(0).getQty().intValue());
move.setMenge(model.getPartInspection().getQty().intValue());
move.setMeins(part.getUnit());
move.setZrsum(zrsum);
move.setPostDate(TimeTool.getToday());
@ -384,13 +492,6 @@ public class MesNcProcessingService implements IMesNcProcessingService {
moveRepository.save(move);
}
defectRecordList.forEach(k -> {
k.setNcType(type);
k.setPerson(person);
ConvertBean.serviceModelUpdate(k, AuthUtil.getSessionUser().getUserName());
});
defectRecordRepository.saveAll(defectRecordList);
}
private MesProduceSn checkProduceSn(String serialNumber, String org) {

@ -61,7 +61,7 @@ public class MesShippingLoadingCheckService implements IMesShippingLoadingCheckS
//若生成装车单,则一定有装车单明细
DdlPackBean orderDetailPackBean = DdlPackBean.getDdlPackBean(loadingList.organizeCode);
DdlPreparedPack.getNumEqualPack(loadingListResult.getId(), "pid", orderDetailPackBean);
DdlPreparedPack.getOrderByPack(new Object[]{CommonEnumUtil.ASC_OR_DESC.ASC.getValue()}, new String[]{"seq"}, orderDetailPackBean);
// DdlPreparedPack.getOrderByPack(new Object[]{CommonEnumUtil.ASC_OR_DESC.ASC.getValue()}, new String[]{"seq"}, orderDetailPackBean);
List<MesLoadingListDetail> detailList = vehiclesOrderDetailRepository.findByHqlWhere(orderDetailPackBean);
//是否逆转
@ -115,7 +115,7 @@ public class MesShippingLoadingCheckService implements IMesShippingLoadingCheckS
//校验发运单是否存在
DdlPackBean orderDetailPackBean = DdlPackBean.getDdlPackBean(org);
DdlPreparedPack.getNumEqualPack(model.getShippingCode(), "shippingCode", orderDetailPackBean);
DdlPreparedPack.getNumEqualPack(loadingList.getId(), "pid", orderDetailPackBean);
DdlPreparedPack.getStringEqualPack(model.getShippingCode(), "shippingCode", orderDetailPackBean);
MesLoadingListDetail vehiclesOrderDetail = vehiclesOrderDetailRepository.getByProperty(orderDetailPackBean);
if (StringUtils.isEmpty(vehiclesOrderDetail)) {
@ -197,7 +197,7 @@ public class MesShippingLoadingCheckService implements IMesShippingLoadingCheckS
//校验装车单是否存在
DdlPackBean orderPackBean = DdlPackBean.getDdlPackBean(org);
DdlPreparedPack.getStringEqualPack(orderCode, "loadingOrderNo", orderPackBean);
DdlPreparedPack.getStringEqualPack(orderCode, "orderCode", orderPackBean);
MesLoadingList loadingList = vehiclesOrderRepository.getByProperty(orderPackBean);
if (StringUtils.isEmpty(loadingList)) {
throw new ImppBusiException(String.format("【%s】此装车单不存在请检查数据", orderCode));

@ -85,7 +85,7 @@ public class MesSortShippingCheckService implements IMesSortShippingCheckService
}
DdlPackBean orderDetailPackBean = DdlPackBean.getDdlPackBean(shippingOrderManagement.organizeCode);
DdlPreparedPack.getStringEqualPack(shippingOrderManagement.getOrderCode(), "orderCode", orderDetailPackBean);
DdlPreparedPack.getStringEqualPack(orderManagement.getOrderCode(), "orderCode", orderDetailPackBean);
MesLoadingList loadingList = ListRepository.getByProperty(orderDetailPackBean);
if (StringUtils.isEmpty(loadingList)) {
throw new ImppBusiException(String.format("【%s】此发运单配置是否装车为是,但没生成装车单,请检查数据!", shippingOrderManagement.getShippingCode()));
@ -109,7 +109,7 @@ public class MesSortShippingCheckService implements IMesSortShippingCheckService
DdlPackBean orderDetailPackBean = DdlPackBean.getDdlPackBean(shippingOrderManagement.organizeCode);
DdlPreparedPack.getNumEqualPack(shippingOrderManagement.getId(), "shippingId", orderDetailPackBean);
DdlPreparedPack.getNumEqualPack(orderManagement.getId(), "pid", orderDetailPackBean);
List<MesShippingOrderManagementDetail> detailList = shippingOrderManagementDetailRepository.findByHqlWhere(orderDetailPackBean);
@ -283,7 +283,7 @@ public class MesSortShippingCheckService implements IMesSortShippingCheckService
//发运单明细状态修改为校验完成
DdlPackBean orderManagementDetailPackBean = DdlPackBean.getDdlPackBean(org);
DdlPreparedPack.getNumEqualPack(orderManagement.getId(), "shippingId", orderManagementDetailPackBean);
DdlPreparedPack.getNumEqualPack(orderManagement.getId(), "pid", orderManagementDetailPackBean);
List<MesShippingOrderManagementDetail> orderManagementDetailList = shippingOrderManagementDetailRepository.findByHqlWhere(orderManagementDetailPackBean);
List<MesProduceSn> produceSnList = new ArrayList<>();
@ -298,6 +298,7 @@ public class MesSortShippingCheckService implements IMesSortShippingCheckService
MesProduceSn produceSn = produceSnRepository.getByProperty(packBean);
produceSn.setSnStatus(MesExtEnumUtil.PRODUCE_SN_STATUS.SHIPPED.getValue());
detail.setActualQty(1);
ConvertBean.serviceModelUpdate(detail, AuthUtil.getSessionUser().getUserName());
produceSnList.add(produceSn);

@ -1,20 +1,27 @@
package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.busi;
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesWorkOrderService;
import cn.estsh.i3plus.platform.common.convert.ConvertBean;
import cn.estsh.i3plus.platform.common.tool.MathOperation;
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.tool.DdlPreparedPack;
import cn.estsh.i3plus.pojo.mes.bean.MesWorkOrder;
import cn.estsh.i3plus.pojo.mes.repository.MesWorkOrderRepository;
import cn.estsh.i3plus.pojo.base.util.StringUtil;
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.auth.AuthUtil;
import cn.estsh.impp.framework.boot.exception.ImppBusiException;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import java.util.List;
import java.util.*;
import java.util.stream.Collectors;
/**
* @Description :
@ -30,7 +37,18 @@ public class MesWorkOrderService implements IMesWorkOrderService {
@Autowired
private MesWorkOrderRepository workOrderRepository;
@Autowired
private MesProductVersionRepository mesProductVersionRDao;
@Autowired
private MesBomRepository mesBomRDao;
@Autowired
private MesWorkCenterRepository mesWorkCenterRDao;
@Autowired
private MesPartRepository mesPartRDao;
@Autowired
private MesProductPlanRepository mesProductPlanRDao;
@Autowired
private MesProductOffLineRepository mesProductOffLineRDao;
@Override
public MesWorkOrder queryMesWorkOrder(MesWorkOrder workOrder) {
@ -76,4 +94,180 @@ public class MesWorkOrderService implements IMesWorkOrderService {
return packBean;
}
@Override
public void doProductReport(List<MesProduceSn> mesProduceSnList) {
//新增初始化
String organizeCode = AuthUtil.getOrganizeCode();
String userName = AuthUtil.getSessionUser().getUserName();
Map<String, List<MesProduceSn>> mesWorkOrderMap = mesProduceSnList.stream().collect(Collectors.groupingBy(MesProduceSn::getPartNo));
Map<String,MesPart> mesPartMap = new HashMap<>();
MesPart mesPart = null;
//查询工单状态
Integer[] orderStatus =new Integer[]{MesExtEnumUtil.ORDER_STATUS.RELEASE.getValue(),MesExtEnumUtil.ORDER_STATUS.process.getValue()};
for (Map.Entry<String, List<MesProduceSn>> mesProduceSn : mesWorkOrderMap.entrySet()) {
List<MesProduceSn> mesWorkOrderList = mesProduceSn.getValue();
//获取物料信息
if(mesPartMap.containsKey(mesProduceSn.getKey())){
mesPart = mesPartMap.get(mesProduceSn.getKey());
}else{
//查询物料信息
DdlPackBean ddlPackBean = DdlPackBean.getDdlPackBean(organizeCode);
DdlPreparedPack.getStringEqualPack(mesProduceSn.getKey(), "partNo", ddlPackBean);
mesPart = mesPartRDao.getByProperty(ddlPackBean);
if(Objects.isNull(mesPart)){
throw new ImppBusiException(String.format("物料【%s】信息不存在", mesProduceSn.getKey()));
}
mesPartMap.put(mesProduceSn.getKey(),mesPart);
}
//根据物料获取已发布的工单
DdlPackBean ddlPackBean = DdlPackBean.getDdlPackBean(organizeCode);
DdlPreparedPack.getStringEqualPack(mesPart.getPartNo(), "partNo", ddlPackBean);
DdlPreparedPack.getInPackArray(orderStatus, "workOrderStatus", ddlPackBean);
MesWorkOrder oldMesWorkOrder = workOrderRepository.getByProperty(ddlPackBean);
if(Objects.isNull(oldMesWorkOrder)){
throw new ImppBusiException(String.format("物料【%s】状态未已发布的工单信息不存在", mesPart.getPartNo()));
}
//查询工作中心
ddlPackBean = DdlPackBean.getDdlPackBean(organizeCode);
DdlPreparedPack.getStringEqualPack(oldMesWorkOrder.getWorkCenterCode(), "workCenterCode", ddlPackBean);
MesWorkCenter mesWorkCenter = mesWorkCenterRDao.getByProperty(ddlPackBean);
if (Objects.isNull(mesWorkCenter)) {
throw new ImppBusiException(String.format("产线【%s】不存在", oldMesWorkOrder.getWorkCenterCode()));
}
//获取生产版本
ddlPackBean = DdlPackBean.getDdlPackBean(organizeCode);
DdlPreparedPack.getStringEqualPack(mesPart.getPartNo(), "partNo", ddlPackBean);
DdlPreparedPack.getStringEqualPack(mesWorkCenter.getErpWorkCenter(), "workCenterCode", ddlPackBean);
DdlPreparedPack.getStringEqualPack(oldMesWorkOrder.getProductVersion(), "productVersion", ddlPackBean);
MesProductVersion mesProductVersion = mesProductVersionRDao.getByProperty(ddlPackBean);
if (null == mesProductVersion) {
throw new ImppBusiException(String.format("物料【%s】生产版本信息不存在", mesPart.getPartNo()));
}
//物料+生产版本获取bom信息
ddlPackBean = DdlPackBean.getDdlPackBean(organizeCode);
DdlPreparedPack.getStringEqualPack(mesPart.getPartNo(), "partNo", ddlPackBean);
DdlPreparedPack.getStringEqualPack(mesProductVersion.getAlternativePartList(), "bomVersion", ddlPackBean);
List<MesBom> mesBoms = mesBomRDao.findByHqlWhere(ddlPackBean);
if (CollectionUtils.isEmpty(mesBoms)) {
throw new ImppBusiException(String.format("物料【%s】生产版本【%s】对应bom信息不存在",
mesPart.getPartNo(), mesProductVersion.getProductVersion()));
}
oldMesWorkOrder.setNum(mesWorkOrderList.size());
oldMesWorkOrder.setReportedQty(MathOperation.add(oldMesWorkOrder.getNum(), oldMesWorkOrder.getReportedQty()));
//更新SAP计划完成数量
saveMesProductPlan(oldMesWorkOrder, false, true);
//更新工单状态
double unCompleteQty = MathOperation.sub(oldMesWorkOrder.getQty(), oldMesWorkOrder.getReportedQty());
oldMesWorkOrder.setUnCompleteQty(unCompleteQty > 0 ? unCompleteQty : 0);
if (oldMesWorkOrder.getReportedQty() > oldMesWorkOrder.getQty()) {
throw new ImppBusiException(String.format("工单报工数量【%s】大于工单数量【%s】,不允许报工",
oldMesWorkOrder.getReportedQty(), oldMesWorkOrder.getQty()));
} else if (Objects.equals(oldMesWorkOrder.getReportedQty(), oldMesWorkOrder.getQty())) {
oldMesWorkOrder.setWorkOrderStatus(MesExtEnumUtil.ORDER_STATUS.COMPLETE.getValue());
} else {
oldMesWorkOrder.setWorkOrderStatus(MesExtEnumUtil.ORDER_STATUS.process.getValue());
}
ConvertBean.serviceModelUpdate(oldMesWorkOrder,userName);
workOrderRepository.update(oldMesWorkOrder);
//保存数据
List<MesProductOffLine> mesProductOffLineList = new ArrayList<>();
MesProductOffLine newMesProductOffLine;
for (MesProduceSn produceSn : mesWorkOrderList) {
for (MesBom mesBom : mesBoms) {
newMesProductOffLine = new MesProductOffLine();
newMesProductOffLine.setReportPartNo(oldMesWorkOrder.getPartNo());
newMesProductOffLine.setReportPartNameRdd(oldMesWorkOrder.getPartNameRdd());
newMesProductOffLine.setItemPartNo(mesBom.getItemPartNo());
newMesProductOffLine.setItemPartNameRdd(mesBom.getItemPartName());
newMesProductOffLine.setItemQty(mesBom.getItemQty());
newMesProductOffLine.setAlort(mesProductVersion.getReceiveInventoryPoint());
newMesProductOffLine.setStgeLoc(mesProductVersion.getShipInventoryPoint());
newMesProductOffLine.setQty(1d);
newMesProductOffLine.setReportSn(produceSn.getProductSn());
newMesProductOffLine.setBomVersion(oldMesWorkOrder.getProductVersion());
newMesProductOffLine.setSerialNumber(produceSn.getProductSn());
newMesProductOffLine.setUnit(mesBom.getUnit());
newMesProductOffLine.setItemUnit(mesBom.getItemUnit());
newMesProductOffLine.setWorkOrderNo(oldMesWorkOrder.getWorkOrderNo());
newMesProductOffLine.setWorkCenterCode(oldMesWorkOrder.getWorkCenterCode());
newMesProductOffLine.setWorkCellCode(oldMesWorkOrder.getWorkCellCode());
newMesProductOffLine.setReportType(oldMesWorkOrder.getReportType());
newMesProductOffLine.setSapWorkCenter(oldMesWorkOrder.getErpWorkCenter());
newMesProductOffLine.setOrganizeCode(oldMesWorkOrder.getOrganizeCode());
ConvertBean.serviceModelInitialize(newMesProductOffLine, userName);
mesProductOffLineList.add(newMesProductOffLine);
}
}
mesProductOffLineRDao.saveAll(mesProductOffLineList);
}
}
private void saveMesProductPlan(MesWorkOrder bean, boolean isInsert, boolean isReport) {
if (StringUtil.isEmpty(bean.getPlanOrderNo())) {
DdlPackBean ddlPackBean = DdlPackBean.getDdlPackBean(bean.getOrganizeCode());
DdlPreparedPack.getStringEqualPack(bean.getPartNo(), "planPartNo", ddlPackBean);
DdlPreparedPack.getStringEqualPack(bean.getPlanStartTime(), "planStartDate", ddlPackBean);
DdlPreparedPack.getStringEqualPack(bean.getPlanEndTime(), "planEndDate", ddlPackBean);
MesProductPlan mesProductPlan = mesProductPlanRDao.getByProperty(ddlPackBean);
if (null == mesProductPlan) {
MesProductPlan mesPlanOrder = new MesProductPlan();
mesPlanOrder.setPlanOrderNo("");
mesPlanOrder.setPlanQty(bean.getQty());
mesPlanOrder.setPlanPartNo(bean.getPartNo());
mesPlanOrder.setCompleteQty(0d);
mesPlanOrder.setUncompleteQty(bean.getQty());
mesPlanOrder.setUnit(bean.getUnit());
mesPlanOrder.setPlanStartDate(bean.getPlanStartTime());
mesPlanOrder.setPlanEndDate(bean.getPlanEndTime());
mesPlanOrder.setPartMappingWorkCenterCode(bean.getErpWorkCenter());
mesPlanOrder.setPlanOrganizeCode(bean.getOrganizeCode());
mesPlanOrder.setOrganizeCode(bean.getOrganizeCode());
ConvertBean.serviceModelInitialize(mesPlanOrder, bean.getCreateUser());
mesProductPlanRDao.insert(mesPlanOrder);
} else {
if (isInsert) {
mesProductPlan.setPlanQty(MathOperation.add(mesProductPlan.getPlanQty(), bean.getQty()));
} else {
//报工
if (isReport) {
mesProductPlan.setCompleteQty(MathOperation.add(mesProductPlan.getCompleteQty(), bean.getNum()));
//报工调整
} else {
mesProductPlan.setCompleteQty(MathOperation.sub(mesProductPlan.getCompleteQty(), bean.getNum()));
}
}
mesProductPlan.setUncompleteQty(MathOperation.sub(mesProductPlan.getPlanQty(), mesProductPlan.getCompleteQty()));
ConvertBean.serviceModelUpdate(mesProductPlan, bean.getCreateUser());
mesProductPlanRDao.update(mesProductPlan);
}
} else {
DdlPackBean ddlPackBean = DdlPackBean.getDdlPackBean(bean.getOrganizeCode());
DdlPreparedPack.getStringEqualPack(bean.getPlanOrderNo(), "planOrderNo", ddlPackBean);
DdlPreparedPack.getStringEqualPack(bean.getPartNo(), "planPartNo", ddlPackBean);
MesProductPlan mesProductPlan = mesProductPlanRDao.getByProperty(ddlPackBean);
if (null == mesProductPlan) {
throw new ImppBusiException(String.format("SAP计划单号【%s】物料【%s】,不存在", bean.getPlanOrderNo(), bean.getPartNo()));
}
if (!isInsert) {
if (Objects.isNull(mesProductPlan.getCompleteQty())) {
mesProductPlan.setCompleteQty(0d);
}
//报工
if (isReport) {
mesProductPlan.setCompleteQty(MathOperation.add(mesProductPlan.getCompleteQty(), bean.getNum()));
//报工调整
} else {
mesProductPlan.setCompleteQty(MathOperation.sub(mesProductPlan.getCompleteQty(), bean.getNum()));
}
mesProductPlan.setUncompleteQty(MathOperation.sub(mesProductPlan.getPlanQty(), mesProductPlan.getCompleteQty()));
ConvertBean.serviceModelUpdate(mesProductPlan, bean.getCreateUser());
mesProductPlanRDao.update(mesProductPlan);
}
}
}
}

@ -1,203 +0,0 @@
/*
package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.busi.step;
import cn.estsh.i3plus.mes.pcn.serviceimpl.base.BaseStepService;
import cn.estsh.i3plus.platform.common.exception.ImppExceptionEnum;
import cn.estsh.i3plus.platform.common.util.MesConstWords;
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
import cn.estsh.i3plus.pojo.mes.bean.MesEquipment;
import cn.estsh.i3plus.pojo.mes.bean.MesEquipmentInterfaceInfo;
import cn.estsh.i3plus.pojo.mes.bean.MesEquipmentParam;
import cn.estsh.i3plus.pojo.mes.bean.MesWcEquipment;
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.MesEquipmentInterfaceInfoRepository;
import cn.estsh.i3plus.pojo.mes.repository.MesEquipmentParamRepository;
import cn.estsh.i3plus.pojo.mes.repository.MesEquipmentRepository;
import cn.estsh.i3plus.pojo.mes.repository.MesWcEquipmentRepository;
import cn.estsh.impp.framework.boot.auth.AuthUtil;
import cn.estsh.impp.framework.boot.exception.ImppExceptionBuilder;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
*/
/**
* @Description :
* @Reference :
* @Author : xiangwei.zhang
* @CreateDate : 2024-04-22
* @Modify:
**//*
@Slf4j
@Service("jxSnLineOnCheckMcOrPsStepService")
public class ReadWorkResultStepService extends BaseStepService {
@Autowired
private MesWcEquipmentRepository wcEquipmentRepository;
@Autowired
private MesEquipmentRepository equipmentRepository;
@Autowired
private MesEquipmentParamRepository equipmentParamRepository;
@Autowired
private MesEquipmentInterfaceInfoRepository mesEquipmentInterfaceInfoRepository;
@Override
public StepResult init(StationRequestBean reqBean) {
reqBean.setSerialNumber(null);
reqBean.setProductSn(null);
reqBean.setTray(null);
clearStepContent(reqBean);
return super.init(reqBean);
}
*/
/**
* , : ---> equParamList
* equParamList : , :
* equParamList : , :
* :, , ,
* , ,
* ++
* IDDB, : +
* , 0 (0)
* ,
* ,
* , , , ,
* , //, ,
*
* 1(1)
* @param reqBean
* @return
*//*
@Override
public StepResult execute(StationRequestBean reqBean) {
// 1 获取工位信息
String workCell = reqBean.getWorkCellCode();
// 2 根据工位在组织模型中获取设备信息编号
MesWcEquipment mesWcEquipment = wcEquipmentRepository.getByProperty(
new String[]{MesConstWords.ORGANIZE_CODE, MesConstWords.IS_DELETED, MesConstWords.IS_VALID, "workCellCode"},
new Object[]{AuthUtil.getOrganizeCode(), CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue(),
CommonEnumUtil.IS_VAILD.VAILD.getValue(), workCell});
if (null == mesWcEquipment) {
throw ImppExceptionBuilder.newInstance()
.setSystemID(CommonEnumUtil.SOFT_TYPE.MES.getCode())
.setErrorCode(ImppExceptionEnum.VARIFY_EXCEPTION.getCode())
.setErrorDetail("工位代码【%s】无效", workCell)
.build();
}
// 3 查询设备信息
MesEquipment mesEquipmentDb = equipmentRepository.getByProperty(
new String[]{MesConstWords.ORGANIZE_CODE, MesConstWords.IS_DELETED, MesConstWords.IS_VALID, "equipmentCode"},
new Object[]{mesWcEquipment.getOrganizeCode(), CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue(),
CommonEnumUtil.IS_VAILD.VAILD.getValue(), mesWcEquipment.getEquipmentCode()});
if (null == mesEquipmentDb) {
throw ImppExceptionBuilder.newInstance()
.setSystemID(CommonEnumUtil.SOFT_TYPE.MES.getCode())
.setErrorCode(ImppExceptionEnum.VARIFY_EXCEPTION.getCode())
.setErrorDetail("设备代码【%s】无效", mesWcEquipment.getEquipmentCode())
.build();
}
//4 查询设备参数信息
List<MesEquipmentParam> mesEquipmentParamList = equipmentParamRepository.findByProperty(
new String[]{MesConstWords.ORGANIZE_CODE, MesConstWords.IS_DELETED, MesConstWords.IS_VALID, "equipmentCode"},
new Object[]{mesWcEquipment.getOrganizeCode(), CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue(),
CommonEnumUtil.IS_VAILD.VAILD.getValue(), mesWcEquipment.getEquipmentCode()});
if (CollectionUtils.isEmpty(mesEquipmentParamList)) {
throw ImppExceptionBuilder.newInstance()
.setSystemID(CommonEnumUtil.SOFT_TYPE.MES.getCode())
.setErrorCode(ImppExceptionEnum.VARIFY_EXCEPTION.getCode())
.setErrorDetail("设备代码【%s】无效", mesWcEquipment.getEquipmentCode())
.build();
}
//
List<MesEquipmentParam> mesEquipmentParams = mesEquipmentParamList.stream().filter(mesEquipParam -> Objects.equals(mesEquipParam.getVariableType(), cn.estsh.i3plus.ext.mes.pojo.util.MesPcnExtEnumUtil.EQUIPMENT_VARIABLE_TYPE.PRODUCTION_PARAM.getValue())).collect(Collectors.toList());
if (CollectionUtils.isEmpty(mesEquipmentParams)) {
throw ImppExceptionBuilder.newInstance()
.setSystemID(CommonEnumUtil.SOFT_TYPE.MES.getCode())
.setErrorCode(ImppExceptionEnum.VARIFY_EXCEPTION.getCode())
.setErrorDetail("未配置加工结果", mesWcEquipment.getEquipmentCode())
.build();
}
// 从equParamList中筛选 一个点位: 加工模式, 条件: 二级类别。
List<MesEquipmentParam> mesEquipmentParamsModel = mesEquipmentParamList.stream().filter(mesEquipParam -> Objects.equals(mesEquipParam.getVariableType(), cn.estsh.i3plus.ext.mes.pojo.util.MesPcnExtEnumUtil.EQUIPMENT_VARIABLE_TYPE.PRODUCTION_PARAM.getValue())).collect(Collectors.toList());
if (CollectionUtils.isEmpty(mesEquipmentParams)) {
throw ImppExceptionBuilder.newInstance()
.setSystemID(CommonEnumUtil.SOFT_TYPE.MES.getCode())
.setErrorCode(ImppExceptionEnum.VARIFY_EXCEPTION.getCode())
.setErrorDetail("未配置加工模式", mesWcEquipment.getEquipmentCode())
.build();
}
// 从equParamList中筛选 多个点位: 加工结果, 条件: 二级类别。
List<MesEquipmentParam> mesEquipmentParamsResult = mesEquipmentParamList.stream().filter(mesEquipParam -> Objects.equals(mesEquipParam.getVariableType(), cn.estsh.i3plus.ext.mes.pojo.util.MesPcnExtEnumUtil.EQUIPMENT_VARIABLE_TYPE.PRODUCTION_PARAM.getValue())).collect(Collectors.toList());
if (CollectionUtils.isEmpty(mesEquipmentParams)) {
throw ImppExceptionBuilder.newInstance()
.setSystemID(CommonEnumUtil.SOFT_TYPE.MES.getCode())
.setErrorCode(ImppExceptionEnum.VARIFY_EXCEPTION.getCode())
.setErrorDetail("未配置加工结果", mesWcEquipment.getEquipmentCode())
.build();
}
for (MesEquipmentParam mesEquipmentParam : mesEquipmentParamsModel) {
// 查询设备接口逻辑维护(可以拿到 查询的值以及对应的参考值) 有4个点位 成功 失败 报废 可疑
List<MesEquipmentInterfaceInfo> mesEquipmentInterfaceInfoList = mesEquipmentInterfaceInfoRepository.findByProperty(
new String[]{MesConstWords.ORGANIZE_CODE, MesConstWords.IS_DELETED, MesConstWords.IS_VALID, "variableConfigType", "secondCategory"},
new Object[]{mesWcEquipment.getOrganizeCode(), CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue(),
CommonEnumUtil.IS_VAILD.VAILD.getValue(), mesEquipmentDb.getVariableConfigType(), mesEquipmentParam.getSecondCategory()});
if (CollectionUtils.isEmpty(mesEquipmentInterfaceInfoList)) {
throw ImppExceptionBuilder.newInstance()
.setSystemID(CommonEnumUtil.SOFT_TYPE.MES.getCode())
.setErrorCode(ImppExceptionEnum.VARIFY_EXCEPTION.getCode())
.setErrorDetail("设备接口逻辑维护信息缺失", mesWcEquipment.getEquipmentCode())
.build();
}
MesEquipmentInterfaceInfo mesEquipmentInterfaceInfo = mesEquipmentInterfaceInfoList.get(0);
// 查询设备数据采集表
boolean flag = Objects.equals(mesEquipmentInterfaceInfo.getIsOftenChangeValue(), 1);
Integer status = 1;
if (flag) {
status = 0;
}
//根据加工模式点位读取数据,判断值是否匹配接口逻辑的参考值 需要带条件 状态=0
// readEquipmentInfo();
String res = "";
//res = readEquipmentInfo();
if (StringUtils.isEmpty(res)) {
// 无结果
} else if (Objects.equals(res, mesEquipmentInterfaceInfo.getReferValue())) {
// 手动
// todo 修改状态为1 进入下一个工步
return StepResult.getSuccessComplete("");
} else {
// 自动/半自动
// todo 修改状态为1
}
}
// todo 查询数据库看设备的返回信息 与 逻辑维护的数据进行匹配,匹配成功则直接
//todo 根据设备id找到分表然后查询
return stepResult;
}
private
}
*/

@ -31,7 +31,7 @@ public class MesEvcRuleMatchBackValueService implements IMesEquipVariableCfgRule
for (MesEquipVariableCollectContext equipVariableCollectContext : collectContext.getEquipVariableCollectContextList()) {
if (null == equipVariableCollectContext || StringUtils.isEmpty(equipVariableCollectContext.getEquipVariableValue())) continue;
if (null == equipVariableCollectContext || StringUtils.isEmpty(equipVariableCollectContext.getEquipVariableValue())) continue;
if (CollectionUtils.isEmpty(backList)) backList = new ArrayList<>();

@ -28,6 +28,7 @@ import org.springframework.util.StringUtils;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.stream.Collectors;
/**
* @Description :
@ -50,6 +51,15 @@ public class MesAssemblyReadStepService extends BaseStepService {
private IMesMouldMultiCavityService mouldMultiCavityService;
@Override
public StepResult init(StationRequestBean reqBean) {
productionProcessContextStepService.doSendStepContextMessage(reqBean);
return super.init(reqBean);
}
@Override
public StepResult execute(StationRequestBean reqBean) {
StationResultBean resultBean = new StationResultBean();
@ -115,9 +125,11 @@ public class MesAssemblyReadStepService extends BaseStepService {
//保存设备当前一轮工序待验证的装配件条码信息
productionProcessContext.assemblySnJson(equipVariableCollectContextList);
productionProcessContextStepService.doSendStepContextMessage(reqBean,
equipVariableCollectContextList.stream().filter(o -> null != o).map(MesEquipVariableCollectContext::getEquipVariableValue).collect(Collectors.joining(MesPcnExtConstWords.SEMICOLON)), MesExtEnumUtil.CELL_MESSAGE_SOURCE.READ);
return stepResult;
}
}

@ -8,6 +8,7 @@ import cn.estsh.i3plus.platform.common.tool.TimeTool;
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;
@ -29,7 +30,11 @@ public class MesAssemblyScanStepService extends BaseStepService {
@Override
public StepResult guide(StationRequestBean reqBean) {
productionProcessContextStepService.doSendStepContextMessage(reqBean);
return execSuccessCompleteAndSendGuideReturn(reqBean, new StationResultBean(), "请扫描装配件条码!");
}
@Override
@ -46,6 +51,8 @@ public class MesAssemblyScanStepService extends BaseStepService {
//保存设备当前一轮工序待验证的装配件条码信息
productionProcessContext.assemblySnJson(getAssemblySnJson(reqBean));
productionProcessContextStepService.doSendStepContextMessage(reqBean, reqBean.getScanInfo(), MesExtEnumUtil.CELL_MESSAGE_SOURCE.SCAN);
return stepResult;
}

@ -57,6 +57,15 @@ public class MesFirstMouldNoReadStepService extends BaseStepService {
private IPartService partService;
@Override
public StepResult init(StationRequestBean reqBean) {
productionProcessContextStepService.doSendStepContextMessage(reqBean);
return super.init(reqBean);
}
@Override
public StepResult execute(StationRequestBean reqBean) {
StationResultBean resultBean = new StationResultBean();
@ -121,13 +130,15 @@ public class MesFirstMouldNoReadStepService extends BaseStepService {
String firstMouldNo = equipVariableCollectContextList.get(0).getEquipVariableValue();
productionProcessContextStepService.doSendStepContextMessage(reqBean, firstMouldNo, MesExtEnumUtil.CELL_MESSAGE_SOURCE.READ);
//验证一模多腔信息
List<MesMouldMultiCavity> mouldMultiCavityList = getMouldMultiCavityList(reqBean, resultBean, productionProcessContext, cellEquipContext.getEquipmentCode(), firstMouldNo, true);
//获取物料信息
//获取零件信息
Map<String, MesPart> partDataMap = getPartDataMap(reqBean, resultBean, productionProcessContext, mouldMultiCavityList);
//保存设备当前一轮工序的头道模具号,一模多腔信息,物料信息
//保存设备当前一轮工序的头道模具号,一模多腔信息,零件信息
productionProcessContext.firstMouldNo(equipVariableCollectContextList.get(0)).mouldCavityJson(mouldMultiCavityList).partDataJson(partDataMap);
//更新展示组件MODULE_CONTENT内容
@ -164,24 +175,24 @@ public class MesFirstMouldNoReadStepService extends BaseStepService {
Map<String, MesPart> finalPartDataMap = partService.getPartMap(reqBean.getOrganizeCode(), partNoList);
//物料信息缺失 抛出异常
//零件信息缺失 抛出异常
List<String> filterList = CollectionUtils.isEmpty(finalPartDataMap) ? null : partNoList.stream().filter(o -> (null != o && !finalPartDataMap.containsKey(o))).collect(Collectors.toList());
if (CollectionUtils.isEmpty(partDataMap) || !CollectionUtils.isEmpty(filterList)) execExpSendMsgAndThrowEx(reqBean, resultBean, String.format("请检查物料信息,物料编码%s信息不存在!", CollectionUtils.isEmpty(finalPartDataMap) ? partNoList.toString() : filterList.toString()));
if (CollectionUtils.isEmpty(partDataMap) || !CollectionUtils.isEmpty(filterList)) execExpSendMsgAndThrowEx(reqBean, resultBean, String.format("请检查零件信息,零件编码%s信息不存在!", CollectionUtils.isEmpty(finalPartDataMap) ? partNoList.toString() : filterList.toString()));
return finalPartDataMap;
}
public void doCacheMoudleContext(StationRequestBean reqBean, List<MesMouldMultiCavity> mouldMultiCavityList, Boolean isFirstMouldNo) {
productionProcessContextStepService.doCacheContext(reqBean, MesPcnEnumUtil.STATION_BUSI_TYPE.MODULE_CONTENT.getValue(), getModuleContextData(reqBean, mouldMultiCavityList, isFirstMouldNo));
productionProcessContextStepService.doCacheModuleContext(reqBean, getModuleContextData(reqBean, mouldMultiCavityList, isFirstMouldNo));
}
private List<List<StationKvBean>> getModuleContextData(StationRequestBean reqBean, List<MesMouldMultiCavity> mouldMultiCavityList, Boolean isFirstMouldNo) {
List<List<StationKvBean>> moduleContextData = new ArrayList<>();
mouldMultiCavityList.forEach(o -> StationKvBeanUtil.addStationKvBeanList(moduleContextData,
new ArrayList<>(), new StationKvBean(MesPcnExtConstWords.MOULD_NO, isFirstMouldNo ? "头道模具号" : "模具号", o.getMouldNo()), new StationKvBean(MesPcnConstWords.PART_NO, "物料编码", o.getPartNo()), new StationKvBean(MesPcnConstWords.PART_NAME, "物料名称", o.getPartName())));
return moduleContextData;
List<List<StationKvBean>> dataList = new ArrayList<>();
mouldMultiCavityList.forEach(o -> StationKvBeanUtil.addStationKvBeanList(dataList,
new ArrayList<>(), new StationKvBean(MesPcnExtConstWords.MOULD_NO, isFirstMouldNo ? "头道模具号" : "模具号", o.getMouldNo()), new StationKvBean(MesPcnConstWords.PART_NO, "零件编码", o.getPartNo()), new StationKvBean(MesPcnConstWords.PART_NAME, "零件名称", o.getPartName())));
return dataList;
}

@ -51,6 +51,15 @@ public class MesMouldNoReadStepService extends BaseStepService {
private MesFirstMouldNoReadStepService firstMouldNoReadStepService;
@Override
public StepResult init(StationRequestBean reqBean) {
productionProcessContextStepService.doSendStepContextMessage(reqBean);
return super.init(reqBean);
}
@Override
public StepResult execute(StationRequestBean reqBean) {
StationResultBean resultBean = new StationResultBean();
@ -118,6 +127,8 @@ public class MesMouldNoReadStepService extends BaseStepService {
String mouldNo = equipVariableCollectContextList.get(0).getEquipVariableValue();
productionProcessContextStepService.doSendStepContextMessage(reqBean, mouldNo, MesExtEnumUtil.CELL_MESSAGE_SOURCE.READ);
stepResult.obj(equipVariableCollectContextList.get(0));
if (!StringUtils.isEmpty(productionProcessContext.getFirstMouldNo()) || !StringUtils.isEmpty(productionProcessContext.getWorkOrderDataJson())) return stepResult;
@ -125,10 +136,10 @@ public class MesMouldNoReadStepService extends BaseStepService {
//磨具号当头道模具号的使用
List<MesMouldMultiCavity> mouldMultiCavityList = firstMouldNoReadStepService.getMouldMultiCavityList(reqBean, resultBean, productionProcessContext, cellEquipContext.getEquipmentCode(), mouldNo, false);
//获取物料信息
//获取零件信息
Map<String, MesPart> partDataMap = firstMouldNoReadStepService.getPartDataMap(reqBean, resultBean, productionProcessContext, mouldMultiCavityList);
//保存设备当前一轮工序的一模多腔信息,物料信息
//保存设备当前一轮工序的一模多腔信息,零件信息
productionProcessContext.mouldCavityJson(mouldMultiCavityList).partDataJson(partDataMap);
//更新展示组件MODULE_CONTENT内容

@ -46,6 +46,15 @@ public class MesProductResultReadStepService extends BaseStepService {
private IMesEquipVariableCfgRuleMatchDispatchService equipVariableCfgRuleMatchService;
@Override
public StepResult init(StationRequestBean reqBean) {
productionProcessContextStepService.doSendStepContextMessage(reqBean);
return super.init(reqBean);
}
@Override
public StepResult execute(StationRequestBean reqBean) {
StationResultBean resultBean = new StationResultBean();
@ -91,7 +100,7 @@ public class MesProductResultReadStepService extends BaseStepService {
execDynamicsCompleteAndSendMsg(reqBean, resultBean, stepResult, false,
MesPcnEnumUtil.STATION_BUSI_TYPE.MESSAGE, MesPcnEnumUtil.STATION_DATA_TYPE.EXP_TEXT, String.format("请检查设备的质量状态,读取到设备[%s]的数据变量质量值为[%s]!", cellEquipContext.getEquipmentCode(), cellEquipContext.getQuality()));
if (stepResult.isCompleted()) matchProductResult(reqBean, resultBean, stepResult, productionProcessContext, cellEquipContext, collectContextList);
matchProductResult(reqBean, resultBean, stepResult, productionProcessContext, cellEquipContext, collectContextList);
productionProcessContextStepService.doCacheProductionProcessContext(reqBean, productionProcessContext);
@ -120,6 +129,9 @@ public class MesProductResultReadStepService extends BaseStepService {
for (Map.Entry<String, List<MesEquipVariableCfgCollectContext>> entry : variableCategoryMap.entrySet()) {
if (null == entry) continue;
if (!(Boolean) equipVariableCfgRuleMatchService.matchEquipVariableCfgCollectContext(reqBean, productionProcessContext, entry.getKey(), entry.getValue())) continue;
productionProcessContextStepService.doSendStepContextMessage(reqBean, MesExtEnumUtil.EQUIP_VARIABLE_CFG_CATEGORY.valueOfDescription(entry.getKey()), MesExtEnumUtil.CELL_MESSAGE_SOURCE.READ);
if (MesExtEnumUtil.EQUIP_VARIABLE_CFG_CATEGORY.PRODUCT_NOK.getValue().equals(entry.getKey()))
return execNonCompleteAndSendMsgReturn(reqBean, resultBean, stepResult, String.format("%s!", MesExtEnumUtil.EQUIP_VARIABLE_CFG_CATEGORY.PRODUCT_NOK.getDescription()));
return execDynamicsCompleteAndSendMsgReturn(reqBean, resultBean, stepResult.obj(entry.getKey()), true, MesPcnEnumUtil.STATION_BUSI_TYPE.MESSAGE,

@ -28,6 +28,7 @@ import org.springframework.util.StringUtils;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.stream.Collectors;
/**
* @Description :
@ -50,6 +51,15 @@ public class MesProductSnReadStepService extends BaseStepService {
private IMesMouldMultiCavityService mouldMultiCavityService;
@Override
public StepResult init(StationRequestBean reqBean) {
productionProcessContextStepService.doSendStepContextMessage(reqBean);
return super.init(reqBean);
}
@Override
public StepResult execute(StationRequestBean reqBean) {
StationResultBean resultBean = new StationResultBean();
@ -115,6 +125,9 @@ public class MesProductSnReadStepService extends BaseStepService {
//保存设备当前一轮工序的待验证的主条码信息
productionProcessContext.productSnJson(equipVariableCollectContextList);
productionProcessContextStepService.doSendStepContextMessage(reqBean,
equipVariableCollectContextList.stream().filter(o -> null != o).map(MesEquipVariableCollectContext::getEquipVariableValue).collect(Collectors.joining(MesPcnExtConstWords.SEMICOLON)), MesExtEnumUtil.CELL_MESSAGE_SOURCE.READ);
return stepResult;
}

@ -8,6 +8,7 @@ import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProductionProcessContext;
import cn.estsh.i3plus.ext.mes.pcn.pojo.util.MesPcnExtConstWords;
import cn.estsh.i3plus.mes.pcn.actor.shipping.dispatch.IFsmRouteDataService;
import cn.estsh.i3plus.mes.pcn.serviceimpl.fsm.BaseStepService;
import cn.estsh.i3plus.mes.pcn.util.StationKvBeanUtil;
import cn.estsh.i3plus.pojo.base.enumutil.MesPcnEnumUtil;
import cn.estsh.i3plus.pojo.mes.bean.*;
import cn.estsh.i3plus.pojo.mes.model.StationKvBean;
@ -22,10 +23,7 @@ import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.*;
import java.util.stream.Collectors;
/**
@ -48,22 +46,6 @@ public class MesProductionProcessContextStepService extends BaseStepService impl
private String getContextKey(StationRequestBean reqBean) { return getFsmBusikey(reqBean, MesPcnExtConstWords.PRODUCTION_PROCESS_CONTEXT); }
@Override
public Boolean doCacheContext(StationRequestBean reqBean, String item, Object o) {
return saveFsmBusiData(reqBean.getOrganizeCode(), getContextKey(reqBean), item, JSONObject.toJSONString(o));
}
@Override
public String getCachedContext(StationRequestBean reqBean, String item) {
return getFsmBusiData(reqBean.getOrganizeCode(), getContextKey(reqBean), item);
}
@Override
public List<List<StationKvBean>> getCachedModuleContext(StationRequestBean reqBean) {
String moduleContent = getFsmBusiData(reqBean.getOrganizeCode(), getContextKey(reqBean), MesPcnEnumUtil.STATION_BUSI_TYPE.MODULE_CONTENT.getValue());
return StringUtils.isEmpty(moduleContent) ? null : JSONObject.parseObject(moduleContent, new TypeReference<List<List<StationKvBean>>>() {});
}
@Override
public Boolean doCacheProductionProcessContext(StationRequestBean reqBean, MesProductionProcessContext productionProcessContext) {
return saveFsmBusiData(reqBean.getOrganizeCode(), getContextKey(reqBean), MesProductionProcessContext.class.getSimpleName(), JSONObject.toJSONString(productionProcessContext));
}
@ -299,4 +281,57 @@ public class MesProductionProcessContextStepService extends BaseStepService impl
this.sendMessage(reqBean, resultBean);
}
@Override
public Boolean doCacheModuleContext(StationRequestBean reqBean, List<List<StationKvBean>> dataList) {
return saveFsmBusiData(reqBean.getOrganizeCode(), getContextKey(reqBean), MesPcnEnumUtil.STATION_BUSI_TYPE.MODULE_CONTENT.getValue(), JSONObject.toJSONString(dataList));
}
@Override
public List<List<StationKvBean>> getCachedModuleContext(StationRequestBean reqBean) {
String moduleContent = getFsmBusiData(reqBean.getOrganizeCode(), getContextKey(reqBean), MesPcnEnumUtil.STATION_BUSI_TYPE.MODULE_CONTENT.getValue());
return StringUtils.isEmpty(moduleContent) ? null : JSONObject.parseObject(moduleContent, new TypeReference<List<List<StationKvBean>>>() {});
}
@Override
public Boolean doCacheLastScanContext(StationRequestBean reqBean, List<StationKvBean> dataList) {
return saveFsmBusiData(reqBean.getOrganizeCode(), getContextKey(reqBean), MesPcnExtConstWords.LAST_SCAN_INFO, JSONObject.toJSONString(dataList));
}
@Override
public List<StationKvBean> getCachedLastScanContext(StationRequestBean reqBean) {
String lastScanContent = getFsmBusiData(reqBean.getOrganizeCode(), getContextKey(reqBean), MesPcnExtConstWords.LAST_SCAN_INFO);
return StringUtils.isEmpty(lastScanContent) ? new ArrayList<>() : JSONObject.parseArray(lastScanContent, StationKvBean.class);
}
@Override
public void doSendStepContextMessage(StationRequestBean reqBean) {
sendStepContextMessage(reqBean, getCachedLastScanContext(reqBean));
}
@Override
public void doSendStepContextMessage(StationRequestBean reqBean, String scanInfo, MesExtEnumUtil.CELL_MESSAGE_SOURCE source) {
List<StationKvBean> lastScanContext = getCachedLastScanContext(reqBean);
StationKvBeanUtil.addStationKvBeanLimix100ThenHalf(lastScanContext, new StationKvBean().name(source.getDescription()).value(scanInfo));
doCacheLastScanContext(reqBean, lastScanContext);
sendStepContextMessage(reqBean, lastScanContext);
}
@Override
public void sendStepContextMessage(StationRequestBean reqBean, List<StationKvBean> lastScanContext) {
StationResultBean resultBean = new StationResultBean();
resultBean.setResultList(StationKvBeanUtil.addStationKvBeanList(new ArrayList<>(),
lastScanContext.size() > 1 ? lastScanContext.get(1).name("上次" + lastScanContext.get(1).getName()).key(MesPcnExtConstWords.LAST_SCAN_INFO) : null,
lastScanContext.size() > 0 ? lastScanContext.get(0).name("当前" + lastScanContext.get(0).getName()).key(MesPcnExtConstWords.SCAN_INFO) : null));
resultBean.setBusiType(MesPcnEnumUtil.STATION_BUSI_TYPE.STEP_CONTENT.getValue());
resultBean.setDataType(MesPcnEnumUtil.STATION_DATA_TYPE.KEY_VALUE.getValue());
this.sendMessage(reqBean, resultBean);
}
}

@ -44,7 +44,7 @@ public class MesProductionProcessContext {
@ApiParam("工艺代码")
private String craftCode;
@ApiParam("工艺代码")
@ApiParam("工艺名称")
private String craftName;
@ApiParam("当前工位设备对象([Json]MesCellEquipContext)")
@ -74,7 +74,7 @@ public class MesProductionProcessContext {
@ApiParam("模具号")
private String mouldNo;
@ApiParam("一模多腔信息")
@ApiParam("一模多腔信息JSON LIST")
private String mouldCavityJson;
@ApiParam("零件信息")

@ -1,8 +1,12 @@
package cn.estsh.i3plus.ext.mes.pcn.pojo.model;
import cn.estsh.i3plus.pojo.mes.bean.nc.MesPartInspection;
import cn.estsh.i3plus.pojo.mes.bean.nc.MesPartInspectionDetail;
import io.swagger.annotations.ApiParam;
import lombok.Data;
import java.util.List;
/**
* @Description :
* @Reference :
@ -13,22 +17,20 @@ import lombok.Data;
@Data
public class MesNcProcessingInputModel {
@ApiParam("类型")
private Integer type;
@ApiParam("条码")
private String serialNumber;
private String sn;
@ApiParam("责任人")
private Integer person;
@ApiParam("类型")
private Integer type;
@ApiParam("物料号")
private String partNo;
@ApiParam("批次")
private String lot;
@ApiParam("NC-零件检测详情")
private List<MesPartInspectionDetail> partInspectionDetailList;
@ApiParam("NC-零件检测-单据")
private MesPartInspection partInspection;
}

@ -3,6 +3,8 @@ package cn.estsh.i3plus.ext.mes.pcn.pojo.model;
import cn.estsh.i3plus.pojo.mes.bean.MesLocationConfig;
import cn.estsh.i3plus.pojo.mes.bean.MesPart;
import cn.estsh.i3plus.pojo.mes.bean.MesPartTypePicture;
import cn.estsh.i3plus.pojo.mes.bean.nc.MesPartInspection;
import cn.estsh.i3plus.pojo.mes.bean.nc.MesPartInspectionDetail;
import io.swagger.annotations.ApiParam;
import lombok.Data;
@ -19,15 +21,24 @@ import java.util.List;
public class MesNcProcessingModel {
@ApiParam("位置")
@ApiParam("正面位置")
List<MesLocationConfig> frontLocationConfigList;
@ApiParam("背面位置")
List<MesLocationConfig> BackLocationConfigList;
@ApiParam("背面位置")
List<MesLocationConfig> locationConfigList;
@ApiParam("图片")
private MesPartTypePicture partTypePicture;
@ApiParam("缺陷列表")
private List<MesNcProcessingViewModel> defectModelList;
@ApiParam("NC-零件检测详情")
private List<MesPartInspectionDetail> detailList;
@ApiParam("NC-零件检测-单据")
private MesPartInspection partInspection;
@ApiParam("物料")
private MesPart part;

@ -3,7 +3,6 @@ package cn.estsh.i3plus.ext.mes.pcn.pojo.model;
import cn.estsh.i3plus.pojo.mes.bean.MesPart;
import cn.estsh.i3plus.pojo.mes.bean.nc.MesPartInspection;
import cn.estsh.i3plus.pojo.mes.bean.nc.MesPartInspectionDetail;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiParam;
import lombok.Data;
@ -30,7 +29,7 @@ public class MesPartInspectionInputModel {
private String partNo;
@ApiParam("条码")
private String serialNumber;
private String sn;
@ApiParam("正反面")
private Integer frontBack;

@ -22,8 +22,11 @@ import java.util.Map;
public class MesPartInspectionViewModel {
@ApiParam("位置")
@ApiParam("正面位置")
private List<MesLocationConfig> locationConfigList;
//
// @ApiParam("反面位置")
// private List<MesLocationConfig> locationConfigList;
@ApiParam("NC-零件检测详情")
private List<MesPartInspectionDetail> partInspectionDetailList;

@ -83,10 +83,18 @@ public class MesPcnExtConstWords {
public static final String AND = "&";
// 空
public static final String EMPTY = "";
// ;
public static final String SEMICOLON = ";";
//生产过程控制上下文
// 生产过程控制上下文
public static final String PRODUCTION_PROCESS_CONTEXT = "PRODUCTION_PROCESS_CONTEXT";
//定制页面名称(默认)
// 定制页面名称(默认)
public static final String CUSTOM_PAGE_NAME_DEFAULT = "CUSTOM_PAGE_NAME_DEFAULT";
// 上个扫描信息
public static final String LAST_SCAN_INFO = "lastScanInfo";
// 当前扫描信息
public static final String SCAN_INFO = "scanInfo";
}

Loading…
Cancel
Save