diff --git a/modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/busi/IMesInputDefectRecordService.java b/modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/busi/IMesInputDefectRecordService.java index 1f7146d..5f08222 100644 --- a/modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/busi/IMesInputDefectRecordService.java +++ b/modules/i3plus-ext-mes-pcn-api/src/main/java/cn/estsh/i3plus/ext/mes/pcn/api/busi/IMesInputDefectRecordService.java @@ -1,8 +1,9 @@ package cn.estsh.i3plus.ext.mes.pcn.api.busi; -import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesInputDefectRecordModel; -import cn.estsh.i3plus.pojo.mes.bean.MesDefectRecord; +import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesPartInspectionInputModel; +import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesPartInspectionViewModel; import cn.estsh.i3plus.pojo.mes.bean.MesPartTypeDefect; +import cn.estsh.i3plus.pojo.mes.bean.nc.MesPartInspectionDetail; import io.swagger.annotations.ApiOperation; import java.util.List; @@ -18,16 +19,16 @@ public interface IMesInputDefectRecordService { @ApiOperation(value = "扫描产品条码") - public MesInputDefectRecordModel queryProduceSn(String serialNumber, Integer frontBack, String org); + public MesPartInspectionViewModel queryPartInspection(MesPartInspectionInputModel model, String org); - @ApiOperation(value = "批次录入") - public MesInputDefectRecordModel queryPartAndLot(String partNo, String lot, Integer frontBack, String org); +// @ApiOperation(value = "批次录入") +// public MesPartInspectionViewModel queryPartAndLot(String partNo, String lot, Integer frontBack, Integer qty, String org); @ApiOperation(value = "零件类型缺陷类型对应关系信息") public List queryPartTypeDefect(String serialNumber, String defectLocation, boolean flg, Integer frontBack, String org); @ApiOperation(value = "零件类型缺陷类型对应关系信息") - public void saveDefectRecord(List defectRecordList, String org); + public void savePartInspection(MesPartInspectionInputModel model, String org); } diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/controller/busi/MesInputDefectRecordController.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/controller/busi/MesInputDefectRecordController.java index ec1c773..b9b77f7 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/controller/busi/MesInputDefectRecordController.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/controller/busi/MesInputDefectRecordController.java @@ -3,7 +3,7 @@ package cn.estsh.i3plus.ext.mes.pcn.apiservice.controller.busi; import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesInputDefectRecordService; import cn.estsh.i3plus.ext.mes.pcn.pojo.constant.MesCommonConstant; -import cn.estsh.i3plus.pojo.mes.bean.MesDefectRecord; +import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesPartInspectionInputModel; import cn.estsh.impp.framework.boot.auth.AuthUtil; import cn.estsh.impp.framework.boot.exception.ImppBusiException; import cn.estsh.impp.framework.boot.exception.ImppExceptionBuilder; @@ -13,10 +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.util.StringUtils; import org.springframework.web.bind.annotation.*; -import java.util.List; - @RestController @Api(tags = "缺陷记录页面") @RequestMapping(MesCommonConstant.MES_YANFEN + "/defect_record") @@ -27,34 +26,14 @@ public class MesInputDefectRecordController { private IMesInputDefectRecordService inputDefectRecordService; - @GetMapping("/query-loading-order") - @ApiOperation(value = "查询产品条码") - public ResultBean queryProduceSn(String serialNumber, Integer frontBack) { + @PostMapping("/query-part-inspection") + @ApiOperation(value = "查询页面信息") + public ResultBean queryPartInspection(@RequestBody MesPartInspectionInputModel model) { try { - // 数据校验 - ValidatorBean.checkNotNull(serialNumber, "产品条码不能为空"); - ValidatorBean.checkNotNull(frontBack, "正反面不能为空"); - - return ResultBean.success("查询成功").setResultObject(inputDefectRecordService.queryProduceSn(serialNumber, frontBack, AuthUtil.getOrganizeCode())); - } catch (ImppBusiException imppException) { - return ResultBean.fail(imppException); - } catch (Exception e) { - return ImppExceptionBuilder.newInstance().buildExceptionResult(e); - } - } - - @GetMapping("/query-part-lot") - @ApiOperation(value = "查询零件号-批次") - public ResultBean queryProduceSn(String partNo, String lot, Integer frontBack) { - try { - // 数据校验 - ValidatorBean.checkNotNull(partNo, "物料不能为空"); - ValidatorBean.checkNotNull(lot, "批次不能为空"); - ValidatorBean.checkNotNull(frontBack, "正反面不能为空"); - return ResultBean.success("查询成功").setResultObject(inputDefectRecordService.queryPartAndLot(partNo, lot, frontBack, AuthUtil.getOrganizeCode())); + return ResultBean.success("查询成功").setResultObject(inputDefectRecordService.queryPartInspection(model, AuthUtil.getOrganizeCode())); } catch (ImppBusiException imppException) { return ResultBean.fail(imppException); } catch (Exception e) { @@ -83,12 +62,17 @@ public class MesInputDefectRecordController { @PostMapping("/save-defect-record") @ApiOperation(value = "完成质检-保存不良记录") - public ResultBean saveDefectRecord(@RequestBody List defectRecordList) { + public ResultBean saveDefectRecord(@RequestBody MesPartInspectionInputModel model) { try { - // 数据校验 - ValidatorBean.checkNotNull(defectRecordList, "选择不良数据不能为空"); - inputDefectRecordService.saveDefectRecord(defectRecordList, AuthUtil.getOrganizeCode()); + + if (StringUtils.isEmpty(model.getSerialNumber()) && + (StringUtils.isEmpty(model.getPartNo()) || StringUtils.isEmpty(model.getLot()) || StringUtils.isEmpty(model.getQty()))) { + + throw new ImppBusiException("条码为空或零件号+批次+数量为空"); + } + + inputDefectRecordService.savePartInspection(model, AuthUtil.getOrganizeCode()); return ResultBean.success("质检已完成,请继续"); } catch (ImppBusiException imppException) { return ResultBean.fail(imppException); diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesInputDefectRecordService.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesInputDefectRecordService.java index 824f421..83cbdc6 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesInputDefectRecordService.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesInputDefectRecordService.java @@ -2,19 +2,26 @@ package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.busi; import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesConfigService; import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesInputDefectRecordService; -import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesInputDefectRecordModel; +import cn.estsh.i3plus.ext.mes.pcn.pojo.constant.MesCommonConstant; +import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesPartInspectionInputModel; +import cn.estsh.i3plus.ext.mes.pcn.pojo.model.MesPartInspectionViewModel; import cn.estsh.i3plus.mes.pcn.api.iservice.busi.ISyncFuncService; import cn.estsh.i3plus.platform.common.convert.ConvertBean; +import cn.estsh.i3plus.platform.common.exception.ImppExceptionEnum; import cn.estsh.i3plus.platform.common.tool.TimeTool; import cn.estsh.i3plus.pojo.base.bean.DdlPackBean; import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil; import cn.estsh.i3plus.pojo.base.tool.DdlPreparedPack; import cn.estsh.i3plus.pojo.mes.bean.*; +import cn.estsh.i3plus.pojo.mes.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; import cn.estsh.impp.framework.boot.auth.AuthUtil; 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 lombok.extern.slf4j.Slf4j; @@ -23,6 +30,7 @@ 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; @@ -56,13 +64,15 @@ public class MesInputDefectRecordService implements IMesInputDefectRecordService @Autowired private MesPartTypeDefectRepository partTypeDefectRepository; @Autowired - private MesDefectRecordRepository defectRecordRepository; + private MesMoveRepository moveRepository; @Autowired - private MesDefectRecordService defectRecordService; + private MesPartInspectionRepository partInspectionRepository; + @Autowired + private MesPartInspectionDetailRepository partInspectionDetailRepository; @Autowired - private MesMoveRepository moveRepository; + private MesReworkTaskRepository reworkTaskRepository; @Autowired private IMesConfigService configService; @@ -71,38 +81,63 @@ public class MesInputDefectRecordService implements IMesInputDefectRecordService private ISyncFuncService syncFuncService; @Override - public MesInputDefectRecordModel queryProduceSn(String serialNumber, Integer frontBack, String org) { - - //检查条码 - MesProduceSn produceSn = checkProduceSn(serialNumber, org); + public MesPartInspectionViewModel queryPartInspection(MesPartInspectionInputModel inputModel, String org) { //检查物料 - MesPart part = checkPart(produceSn, org); + MesPart part; + //获取NC-零件检测-单据 + MesPartInspection partInspection; + Integer sourceType = null; + if (!StringUtils.isEmpty(inputModel.getSerialNumber())) { + // 数据校验 + ValidatorBean.checkNotNull(inputModel.getFrontBack(), "正反面不能为空"); + //检查条码 + MesProduceSn produceSn = checkProduceSn(inputModel.getSerialNumber(), org); - //检查零件类型与图片对应关系 - MesPartTypePicture partTypePicture = checkPartTypePicture(part, org); + //获取NC-零件检测-单据 + partInspection = getPartInspection(inputModel, org); - //构造返回信息 - MesInputDefectRecordModel model = getModel(part, partTypePicture, frontBack, org); + //检查物料 + part = checkPart(produceSn, org); - return model; - } - @Override - public MesInputDefectRecordModel queryPartAndLot(String partNo, String lot, Integer frontBack, String org) { + } else { + // 数据校验 + ValidatorBean.checkNotNull(inputModel.getPartNo(), "物料不能为空"); + ValidatorBean.checkNotNull(inputModel.getLot(), "批次不能为空"); + ValidatorBean.checkNotNull(inputModel.getFrontBack(), "正反面不能为空"); + ValidatorBean.checkNotNull(inputModel.getQty(), "数量不能为空"); - //检查物料 - MesPart part = checkPartByPartNo(partNo, org); + //检查物料 + part = checkPartByPartNo(inputModel.getPartNo(), org); + + //获取NC-零件检测-单据 + partInspection = getPartInspectionByPartAndLot(inputModel, org); + + sourceType = MesExtEnumUtil.PART_INSPECTION_SOURCE_TYPE.LOT.getValue(); + } //检查零件类型与图片对应关系 MesPartTypePicture partTypePicture = checkPartTypePicture(part, org); //构造返回信息 - MesInputDefectRecordModel model = getModel(part, partTypePicture, frontBack, org); + MesPartInspectionViewModel model = getModel(partInspection, part, partTypePicture, inputModel.getFrontBack(), org); + model.setSourceType(sourceType); + model.setTransferFlg(inputModel.isTransferFlg()); return model; } + /** + * 查询零件类型缺陷类型对应关系 + * + * @param partNo + * @param defectLocation + * @param flg + * @param frontBack + * @param org + * @return + */ @Override public List queryPartTypeDefect(String partNo, String defectLocation, boolean flg, Integer frontBack, String org) { @@ -143,45 +178,240 @@ public class MesInputDefectRecordService implements IMesInputDefectRecordService return partTypeDefectList; } + /** + * 完成质检-保存不良记录 + * + * @param model + * @param org + */ @Override - public void saveDefectRecord(List defectRecordList, String org) { + public void savePartInspection(MesPartInspectionInputModel model, String org) { - //通过条码判断是单件还是批次, - //扫描条码则是单件 没有条码是批次 - if (!StringUtils.isEmpty(defectRecordList.get(0).getSerialNumber())) { - // 数据校验 - ValidatorBean.checkNotNull(defectRecordList.get(0).getSerialNumber(), "条码不能为空"); - //检查条码 - MesProduceSn produceSn = checkProduceSn(defectRecordList.get(0).getSerialNumber(), org); + //零件检测详情为空,则代表本次校验为合格。 + if (CollectionUtils.isEmpty(model.getPartInspectionDetailList())) { - produceSn.setQcStatus(MesExtEnumUtil.PRODUCE_QC_STATUS.SUSPICIOUS.getValue()); - //检查物料 - MesPart part = checkPartByPartNo(produceSn.getPartNo(), org); + MesPartInspection partInspection; + //返工单返修完成,需可疑品移正常库 + if (model.isTransferFlg()) { + //移库 + MesMove move = createMove(model, configService.getCfgValue(org, "UMLGO"), configService.getCfgValue(org, "LGORT"), org); + moveRepository.save(move); + } - //保存数据 - saveDate(defectRecordList, part, org); + //判断首次合格还是 多次检验最终为合格品 + //若返修单返修完成,则会生成一个新的检验单并合格 + //若检验单为空,则生成新的单据并合格 + if (StringUtils.isEmpty(model.getPartInspection())) { + + partInspection = createPartInspection(model, MesExtEnumUtil.PART_INSPECTION_STATUS.FAIL.getValue(), org); + partInspectionRepository.save(partInspection); + + } else { + + //原单据不合格 现合格 + if (model.getPartInspection().getInspectionStatus() == MesExtEnumUtil.PART_INSPECTION_STATUS.FAIL.getValue()) { + model.getPartInspection().setInspectionStatus(MesExtEnumUtil.PART_INSPECTION_STATUS.QUALIFIED.getValue()); + ConvertBean.serviceModelUpdate(model.getPartInspection(), AuthUtil.getSessionUser().getUserName()); + partInspectionRepository.save(model.getPartInspection()); + + //查询当前单据明细 + List resultDetailList = queryResultDetailList(model, org); + + model.getPartInspectionDetailList().forEach(k -> { + k.setId(null); + k.setOrganizeCode(org); + k.setPid(model.getPartInspection().getId()); + ConvertBean.serviceModelInitialize(k, AuthUtil.getSessionUser().getUserName()); + }); + partInspectionDetailRepository.saveAll(resultDetailList); + partInspectionDetailRepository.saveAll(model.getPartInspectionDetailList()); + + //移库 + MesMove move = createMove(model, configService.getCfgValue(org, "UMLGO"), configService.getCfgValue(org, "LGORT"), org); + moveRepository.save(move); + } + } - //单件需要修改条码状态 批量则不需要 - ConvertBean.serviceModelUpdate(produceSn, AuthUtil.getSessionUser().getUserName()); - produceSnRepository.save(produceSn); } else { + //零件检测详情不为空,则代表本次校验为不合格。 - // 数据校验 - ValidatorBean.checkNotNull(defectRecordList.get(0).getPartNo(), "零件号不能为空"); - ValidatorBean.checkNotNull(defectRecordList.get(0).getLot(), "批次不能为空"); + //零件检测-单据为空,则是首次不合格 + MesPartInspection partInspection; + if (StringUtils.isEmpty(model.getPartInspection())) { - //检查物料 - MesPart part = checkPartByPartNo(defectRecordList.get(0).getPartNo(), org); + partInspection = createPartInspection(model, MesExtEnumUtil.PART_INSPECTION_STATUS.FAIL.getValue(), org); + partInspectionRepository.save(partInspection); + + model.getPartInspectionDetailList().forEach(k -> { + k.setOrganizeCode(org); + k.setPid(partInspection.getId()); + ConvertBean.serviceModelInitialize(k, AuthUtil.getSessionUser().getUserName()); + }); + + partInspectionDetailRepository.saveAll(model.getPartInspectionDetailList()); + + //移库 + MesMove move = createMove(model, configService.getCfgValue(org, "LGORT"), configService.getCfgValue(org, "UMLGO"), org); + moveRepository.save(move); + + } else { + + model.getPartInspection().setInspectionStatus(MesExtEnumUtil.PART_INSPECTION_STATUS.FAIL.getValue()); + ConvertBean.serviceModelUpdate(model.getPartInspection(), AuthUtil.getSessionUser().getUserName()); + partInspectionRepository.save(model.getPartInspection()); + + //查询当前单据明细 + List resultDetailList = queryResultDetailList(model, org); + + model.getPartInspectionDetailList().forEach(k -> { + k.setId(null); + k.setOrganizeCode(org); + k.setPid(model.getPartInspection().getId()); + ConvertBean.serviceModelInitialize(k, AuthUtil.getSessionUser().getUserName()); + }); + + partInspectionDetailRepository.saveAll(resultDetailList); + partInspectionDetailRepository.saveAll(model.getPartInspectionDetailList()); + + //移库 + MesMove move = createMove(model, configService.getCfgValue(org, "LGORT"), configService.getCfgValue(org, "UMLGO"), org); + moveRepository.save(move); + + + } + + } + } + + /** + * 获取NC-零件检测-单据 + * + * @param inputModel + * @param org + * @return + */ + private MesPartInspection getPartInspection(MesPartInspectionInputModel inputModel, String org) { + + //根据条码找最近一条单据 + DdlPackBean packBean = DdlPackBean.getDdlPackBean(org); + DdlPreparedPack.getStringEqualPack(inputModel.getSerialNumber(), "sn", packBean); + DdlPreparedPack.getOrderByPack(new Object[]{CommonEnumUtil.ASC_OR_DESC.DESC.getValue()}, new String[]{"createDatetime"}, packBean); + MesPartInspection partInspection = partInspectionRepository.getByProperty(packBean); + + //若单据经过了NC处理,则返回为空 + partInspection = checkPartInspection(partInspection, inputModel, org); + + return partInspection; + } + + /** + * 获取NC-零件检测-单据 + * + * @param inputModel + * @param org + * @return + */ + private MesPartInspection getPartInspectionByPartAndLot(MesPartInspectionInputModel inputModel, String org) { + //根据扫描的条码查询条码是否存在 + DdlPackBean packBean = DdlPackBean.getDdlPackBean(org); + DdlPreparedPack.getStringEqualPack(inputModel.getPartNo(), "partNo", packBean); + DdlPreparedPack.getStringEqualPack(inputModel.getLot(), "lot", packBean); + DdlPreparedPack.getNumEqualPack(inputModel.getQty(), "qty", packBean); + DdlPreparedPack.getNumEqualPack(MesExtEnumUtil.PART_INSPECTION_SOURCE_TYPE.LOT.getValue(), "sourceType", packBean); + DdlPreparedPack.getOrderByPack(new Object[]{CommonEnumUtil.ASC_OR_DESC.DESC.getValue()}, new String[]{"createDatetime"}, packBean); + MesPartInspection partInspection = partInspectionRepository.getByProperty(packBean); - //保存数据 - saveDate(defectRecordList, part, org); + checkPartInspection(partInspection, inputModel, org); + return partInspection; + } + + /** + * 查询当前单据明细 + * + * @param model + * @param org + * @return + */ + private List queryResultDetailList(MesPartInspectionInputModel model, String org) { + + //根据扫描的条码查询条码是否存在 + DdlPackBean packBean = DdlPackBean.getDdlPackBean(org); + DdlPreparedPack.getNumEqualPack(model.getPartInspection().getId(), "pid", packBean); + List resultDetailList = partInspectionDetailRepository.findByHqlWhere(packBean); + resultDetailList.forEach(k -> { + k.setIsDeleted(MesCommonConstant.TRUE_INTEGER); + ConvertBean.serviceModelUpdate(model.getPartInspection(), AuthUtil.getSessionUser().getUserName()); + }); + + return resultDetailList; + } + + /** + * 校验NC-零件检测-单据 + * + * @param partInspection + * @return + */ + private MesPartInspection checkPartInspection(MesPartInspection partInspection, MesPartInspectionInputModel inputModel, String org) { + + //针对检测单-一次NC处理是一个单据 若单据经过了NC处理,则返回为空 + + if (!StringUtils.isEmpty(partInspection)) { + + //可疑,待NC + if (partInspection.getInspectionStatus() == MesExtEnumUtil.PART_INSPECTION_STATUS.FAIL.getValue() + && partInspection.getNcStatus() == MesExtEnumUtil.PART_INSPECTION_NC_STATUS.CREATE.getValue()) { + + return partInspection; + } else if (partInspection.getInspectionStatus() == MesExtEnumUtil.PART_INSPECTION_STATUS.FAIL.getValue() + && partInspection.getNcStatus() == MesExtEnumUtil.PART_INSPECTION_NC_STATUS.SCRAP.getValue()) { + + //报废 + throw ImppExceptionBuilder.newInstance().setErrorCode(ImppExceptionEnum.BUSINESS_EXCEPTION_DATA_ERROR.getCode()) + .setErrorDetail(String.format("【%s】条码已报废,请检查数据", partInspection.getSn())) + .setSystemID(CommonEnumUtil.SOFT_TYPE.MES.getCode()) + .build(); + + } else if (partInspection.getInspectionStatus() == MesExtEnumUtil.PART_INSPECTION_STATUS.FAIL.getValue() + && partInspection.getNcStatus() == MesExtEnumUtil.PART_INSPECTION_NC_STATUS.REWORK.getValue()) { + + + //已创建返修单 + DdlPackBean packBean = DdlPackBean.getDdlPackBean(org); + DdlPreparedPack.getNumEqualPack(partInspection.getId(), "partInspectionId", packBean); + DdlPreparedPack.getOrderByPack(new Object[]{CommonEnumUtil.ASC_OR_DESC.DESC.getValue()}, new String[]{"createDatetime"}, packBean); + MesReworkTask reworkTask = reworkTaskRepository.getByProperty(packBean); + + if (!StringUtils.isEmpty(reworkTask) && reworkTask.getStatus() == MesExtEnumUtil.REWORK_TASK_STATUS.CREATE.getValue()) { + + //已创建返修单 + throw ImppExceptionBuilder.newInstance().setErrorCode(ImppExceptionEnum.BUSINESS_EXCEPTION_DATA_ERROR.getCode()) + .setErrorDetail(String.format("【%s】已创建返修单,请检查数据", partInspection.getSn())) + .setSystemID(CommonEnumUtil.SOFT_TYPE.MES.getCode()) + .build(); + } else if (!StringUtils.isEmpty(reworkTask) && reworkTask.getStatus() == MesExtEnumUtil.REWORK_TASK_STATUS.FINISH.getValue() && + partInspection.getSourceType() == MesExtEnumUtil.PART_INSPECTION_SOURCE_TYPE.SINGLE.getValue()) { + //返修单 进行返修 + inputModel.setTransferFlg(true); + } + } } + + return null; } + /** + * 检查条码 + * + * @param serialNumber + * @param org + * @return + */ + private MesProduceSn checkProduceSn(String serialNumber, String org) { //根据扫描的条码查询条码是否存在 DdlPackBean packBean = DdlPackBean.getDdlPackBean(org); @@ -209,6 +439,64 @@ public class MesInputDefectRecordService implements IMesInputDefectRecordService return produceSn; } + /** + * 创建单据 + * + * @param model + * @param inspectionStatus + * @param org + * @return + */ + private MesPartInspection createPartInspection(MesPartInspectionInputModel model, Integer inspectionStatus, String org) { + MesPartInspection partInspection = new MesPartInspection(); + partInspection.setOrganizeCode(org); + partInspection.setPartNo(model.getPart().getPartNo()); + partInspection.setPartName(model.getPart().getPartName()); + partInspection.setInspectionDate(TimeTool.getToday()); + partInspection.setInspectionStatus(inspectionStatus); + partInspection.setNcStatus(MesExtEnumUtil.PART_INSPECTION_NC_STATUS.CREATE.getValue()); + partInspection.setSn(model.getSerialNumber()); + partInspection.setLot(model.getLot()); + partInspection.setQty(model.getQty()); + partInspection.setWorkCenterCode(model.getWorkCenterCode()); + partInspection.setSourceType(model.getSourceType()); + ConvertBean.serviceModelInitialize(partInspection, AuthUtil.getSessionUser().getUserName()); + return partInspection; + } + + /** + * 移库 + * + * @param model + * @param source 来源 + * @param target 目标 + * @param org + * @return + */ + private MesMove createMove(MesPartInspectionInputModel model, String source, String target, String org) { + GenSerialNoModel serialNoModel = new GenSerialNoModel("INPUT_DEFECT_ZRSUM"); + serialNoModel.setPartNo(model.getPart().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(model.getPart().getPartNo()); + move.setOrganizeCode(org); + move.setFactoryCode(org); + move.setLgort(source); + move.setUmlgo(target); + move.setMenge(model.getQty()); + move.setMeins(model.getPart().getUnit()); + move.setZrsum(zrsum); + move.setPostDate(TimeTool.getToday()); + move.setPostTime(TimeTool.getTimeShortWithColon()); + ConvertBean.serviceModelInitialize(move, AuthUtil.getSessionUser().getUserName()); + return move; + } + private MesPart checkPart(MesProduceSn produceSn, String org) { DdlPackBean packBean = DdlPackBean.getDdlPackBean(org); @@ -318,7 +606,14 @@ public class MesInputDefectRecordService implements IMesInputDefectRecordService return alarmConfigList; } - private MesInputDefectRecordModel getModel(MesPart part, MesPartTypePicture partTypePicture, Integer frontBack, String org) { + private MesPartInspectionViewModel getModel(MesPartInspection partInspection, MesPart part, MesPartTypePicture partTypePicture, Integer frontBack, String org) { + + + List detailList = new ArrayList<>(); + if (!StringUtils.isEmpty(partInspection) && partInspection.getInspectionStatus() != MesExtEnumUtil.PART_INSPECTION_STATUS.QUALIFIED.getValue()) { + + detailList = checkPartInspectionDetail(partInspection, org); + } //位置 List locationConfigList = checkLocationConfig(org); @@ -340,49 +635,23 @@ public class MesInputDefectRecordService implements IMesInputDefectRecordService } }); - MesInputDefectRecordModel model = new MesInputDefectRecordModel(); + MesPartInspectionViewModel model = new MesPartInspectionViewModel(); model.setPart(part); + model.setPartInspectionDetailList(detailList); model.setPartTypePicture(partTypePicture); model.setLocationConfigList(locationConfigList); + model.setPartInspection(partInspection); return model; } - private void saveDate(List defectRecordList, MesPart part, String org) { - - defectRecordList.forEach(r -> { - r.setId(null); - r.setPartNo(part.getPartNo()); - r.setPartName(part.getPartName()); - r.setOrganizeCode(org); - ConvertBean.serviceModelInitialize(r, AuthUtil.getSessionUser().getUserName()); - }); - - //保存不良数据 - defectRecordService.saveDefect(org, AuthUtil.getSessionUser().getUserName(), defectRecordList); - - GenSerialNoModel serialNoModel = new GenSerialNoModel("INPUT_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, "LGORT")); - move.setUmlgo(configService.getCfgValue(org, "UMLGO")); - move.setMenge(defectRecordList.get(0).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); + private List checkPartInspectionDetail(MesPartInspection partInspection, String org) { + DdlPackBean packBean = DdlPackBean.getDdlPackBean(org); + DdlPreparedPack.getNumEqualPack(partInspection.getId(), "pid", packBean); + List detailList = partInspectionDetailRepository.findByHqlWhere(packBean); + return detailList; } + } diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesNcProcessingService.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesNcProcessingService.java index 6e5feab..19af727 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesNcProcessingService.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesNcProcessingService.java @@ -208,18 +208,18 @@ public class MesNcProcessingService implements IMesNcProcessingService { //查询扫描的条码 DdlPackBean packBean = DdlPackBean.getDdlPackBean(org); DdlPreparedPack.getStringEqualPack(serialNumber, "serialNumber", packBean); -// DdlPreparedPack.getNumEqualPack(0, "ncType", packBean); + DdlPreparedPack.getNumEqualPack(0, "ncType", packBean); List defectRecordList = defectRecordRepository.findByHqlWhere(packBean); if (CollectionUtils.isEmpty(defectRecordList)) { - throw new ImppBusiException(String.format("【%s】此条码不存在可疑品记录,请检查数据", serialNumber)); + throw new ImppBusiException(String.format("【%s】此条码不存在可疑品记录或已经过NC处理,请检查数据", serialNumber)); } - - defectRecordList.forEach(k -> { - if (k.getNcType() != 0) { - throw new ImppBusiException(String.format("【%s】此条码已经过NC处理,请检查数据", serialNumber)); - } - }); +// +// defectRecordList.forEach(k -> { +// if (k.getNcType() != 0) { +// throw new ImppBusiException(String.format("【%s】此条码已经过NC处理,请检查数据", serialNumber)); +// } +// }); return defectRecordList; @@ -405,18 +405,6 @@ public class MesNcProcessingService implements IMesNcProcessingService { throw new ImppBusiException(String.format("【%s】此条码不存在,请检查数据", serialNumber)); } - //根据条码状态判断 是不是已下线条码 - //若不是已下线的条码则提示 条码状态 请选择已下线的条码 - if (produceSn.getSnStatus() != MesExtEnumUtil.PRODUCE_SN_STATUS.OFFLINE.getValue()) { - throw new ImppBusiException(String.format("【%s】此条码状态为【%s】,请选择状态为【%s】状态的条码", serialNumber, MesExtEnumUtil.PRODUCE_SN_STATUS.valueOfDescription(produceSn.getSnStatus()), - 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())); - } return produceSn; } } diff --git a/modules/i3plus-ext-mes-pcn-pojo/src/main/java/cn/estsh/i3plus/ext/mes/pcn/pojo/model/MesPartInspectionInputModel.java b/modules/i3plus-ext-mes-pcn-pojo/src/main/java/cn/estsh/i3plus/ext/mes/pcn/pojo/model/MesPartInspectionInputModel.java new file mode 100644 index 0000000..e696f29 --- /dev/null +++ b/modules/i3plus-ext-mes-pcn-pojo/src/main/java/cn/estsh/i3plus/ext/mes/pcn/pojo/model/MesPartInspectionInputModel.java @@ -0,0 +1,58 @@ +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; + +import java.util.List; + +/** + * @Description : + * @Reference : + * @Author : + * @CreateDate : 2024-05-09 18:08 + * @Modify: + **/ +@Data +public class MesPartInspectionInputModel { + + + @ApiParam("物料") + private MesPart part; + + @ApiParam("产线代码") + private String workCenterCode; + + @ApiParam("物料号") + private String partNo; + + @ApiParam("条码") + private String serialNumber; + + @ApiParam("正反面") + private Integer frontBack; + + @ApiParam("批次") + private String lot; + + @ApiParam("数量") + private Integer qty; + + @ApiParam("来源-单件或批次") + private Integer sourceType; + + @ApiParam("是否返工单完成单据") + private boolean transferFlg = false; + + + @ApiParam("NC-零件检测-单据") + private MesPartInspection partInspection; + + @ApiParam("NC-零件检测详情") + private List partInspectionDetailList; + + +} diff --git a/modules/i3plus-ext-mes-pcn-pojo/src/main/java/cn/estsh/i3plus/ext/mes/pcn/pojo/model/MesInputDefectRecordModel.java b/modules/i3plus-ext-mes-pcn-pojo/src/main/java/cn/estsh/i3plus/ext/mes/pcn/pojo/model/MesPartInspectionViewModel.java similarity index 53% rename from modules/i3plus-ext-mes-pcn-pojo/src/main/java/cn/estsh/i3plus/ext/mes/pcn/pojo/model/MesInputDefectRecordModel.java rename to modules/i3plus-ext-mes-pcn-pojo/src/main/java/cn/estsh/i3plus/ext/mes/pcn/pojo/model/MesPartInspectionViewModel.java index d802dc5..269714c 100644 --- a/modules/i3plus-ext-mes-pcn-pojo/src/main/java/cn/estsh/i3plus/ext/mes/pcn/pojo/model/MesInputDefectRecordModel.java +++ b/modules/i3plus-ext-mes-pcn-pojo/src/main/java/cn/estsh/i3plus/ext/mes/pcn/pojo/model/MesPartInspectionViewModel.java @@ -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; @@ -17,22 +19,34 @@ import java.util.Map; * @Modify: **/ @Data -public class MesInputDefectRecordModel { +public class MesPartInspectionViewModel { @ApiParam("位置") - List locationConfigList; + private List locationConfigList; + + @ApiParam("NC-零件检测详情") + private List partInspectionDetailList; @ApiParam("图片") private MesPartTypePicture partTypePicture; + @ApiParam("NC-零件检测-单据") + private MesPartInspection partInspection; + @ApiParam("物料") private MesPart part; + @ApiParam("是否返工单完成单据") + private boolean transferFlg = false; + @ApiParam("位置是否标黄Map") private Map map; + @ApiParam("来源-单件或批次") + private Integer sourceType; + }