diff --git a/production/src/main/java/com/foreverwin/mesnac/production/controller/PodTemplateController.java b/production/src/main/java/com/foreverwin/mesnac/production/controller/PodTemplateController.java index 04bf6a3b..9f7b5e9f 100644 --- a/production/src/main/java/com/foreverwin/mesnac/production/controller/PodTemplateController.java +++ b/production/src/main/java/com/foreverwin/mesnac/production/controller/PodTemplateController.java @@ -1,14 +1,19 @@ package com.foreverwin.mesnac.production.controller; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.foreverwin.mesnac.common.util.StringUtil; import com.foreverwin.mesnac.meapi.dto.SfcDto; import com.foreverwin.mesnac.meapi.dto.WorkCenterDto; import com.foreverwin.mesnac.meapi.model.Sfc; import com.foreverwin.mesnac.production.service.PodTemplateService; +import com.foreverwin.modular.core.exception.BaseException; import com.foreverwin.modular.core.util.R; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.*; +import java.util.List; import java.util.Map; @Controller @@ -60,7 +65,20 @@ public class PodTemplateController { @ResponseBody @PostMapping("/sfcComplete") public R sfcComplete(@RequestBody Map<String,Object> map) { - podTemplateService.sfcComplete(map); + List<SfcDto> sfcDtoList = (List<SfcDto>) map.get("sfcDtoList"); + ObjectMapper mapper = new ObjectMapper(); + sfcDtoList = mapper.convertValue(sfcDtoList, new TypeReference<List<SfcDto>>() { + }); + String resrce = (String) map.get("resrce"); + if (sfcDtoList == null || sfcDtoList.size() < 1) { + throw new BaseException("作业列表不能为空"); + } + if (StringUtil.isBlank(resrce)) { + throw new BaseException("资源不能为空"); + } + for (SfcDto sfcDto : sfcDtoList) { + podTemplateService.sfcComplete(sfcDto,resrce); + } return R.ok(); } diff --git a/production/src/main/java/com/foreverwin/mesnac/production/service/PodTemplateService.java b/production/src/main/java/com/foreverwin/mesnac/production/service/PodTemplateService.java index 1a41a4a6..14cd85eb 100644 --- a/production/src/main/java/com/foreverwin/mesnac/production/service/PodTemplateService.java +++ b/production/src/main/java/com/foreverwin/mesnac/production/service/PodTemplateService.java @@ -4,7 +4,7 @@ import com.foreverwin.mesnac.meapi.dto.SfcDto; import com.foreverwin.mesnac.meapi.dto.WorkCenterDto; import com.foreverwin.mesnac.meapi.model.Sfc; -import java.util.List; +import java.math.BigDecimal; import java.util.Map; public interface PodTemplateService { @@ -16,9 +16,9 @@ public interface PodTemplateService { void sfcStart(Map<String, Object> map); - void sfcComplete(Map<String, Object> map); + void sfcComplete(SfcDto sfcDto, String resrce); - void sendErp(List<Map<String,Object>> mapList); + void sendErp(String sfc, String stepId, BigDecimal qty, BigDecimal scrapQty, BigDecimal workHour); SfcDto getInfoBySfc(Sfc sfc); diff --git a/production/src/main/java/com/foreverwin/mesnac/production/service/impl/PodTemplateServiceImpl.java b/production/src/main/java/com/foreverwin/mesnac/production/service/impl/PodTemplateServiceImpl.java index 9760fcc7..54df6b0d 100644 --- a/production/src/main/java/com/foreverwin/mesnac/production/service/impl/PodTemplateServiceImpl.java +++ b/production/src/main/java/com/foreverwin/mesnac/production/service/impl/PodTemplateServiceImpl.java @@ -220,10 +220,10 @@ public class PodTemplateServiceImpl implements PodTemplateService { } } //是否完成专检 - QueryWrapper<InspectionTask> queryWrapper=new QueryWrapper<>(); - queryWrapper.eq(InspectionTask.CATEGORY,Constants.INSPECTION_TYPE_P); - queryWrapper.eq(InspectionTask.SFC,sfc); - queryWrapper.ne(InspectionTask.RESULT,Constants.RSESULT_OK); + QueryWrapper<InspectionTask> queryWrapper = new QueryWrapper<>(); + queryWrapper.eq(InspectionTask.CATEGORY, Constants.INSPECTION_TYPE_P); + queryWrapper.eq(InspectionTask.SFC, sfc); + queryWrapper.ne(InspectionTask.RESULT, Constants.RSESULT_OK); List<InspectionTask> list = inspectionTaskService.list(queryWrapper); if (!list.isEmpty()) { throw new BaseException("请完成专检检验任务"); @@ -240,99 +240,79 @@ public class PodTemplateServiceImpl implements PodTemplateService { } @Override - public void sfcComplete(Map<String, Object> map) { - List<SfcDto> sfcDtoList = (List<SfcDto>) map.get("sfcDtoList"); - ObjectMapper mapper = new ObjectMapper(); - sfcDtoList = mapper.convertValue(sfcDtoList, new TypeReference<List<SfcDto>>() {}); - List<Map<String,Object>> postMapList=new ArrayList<>(); - String resrce = (String) map.get("resrce"); - if (sfcDtoList == null || sfcDtoList.size() < 1) { - throw new BaseException("作业列表不能为空"); - } - if (StringUtil.isBlank(resrce)) { - throw new BaseException("资源不能为空"); - } - for (SfcDto sfcDto:sfcDtoList){ - Map<String,Object> postMap=new HashMap<>(); - String site = CommonMethods.getSite(); - String operation = sfcDto.getOperation(); - Operation currentRevisionRef = operationService.getCurrentRevisionRef(site, operation); - String sfc = sfcDto.getSfc(); - String stepId = sfcDto.getStepId(); + public void sfcComplete(SfcDto sfcDto, String resrce) { + String site = CommonMethods.getSite(); + String operation = sfcDto.getOperation(); + Operation currentRevisionRef = operationService.getCurrentRevisionRef(site, operation); + String sfc = sfcDto.getSfc(); + String stepId = sfcDto.getStepId(); - String dispatchNo = sfcDto.getDispatchNo(); - Sfc sfcServiceById = sfcService.getById(HandleEnum.SFC.getHandle(site, sfc)); - BigDecimal qty = new BigDecimal(sfcServiceById.getQty().toString()); - //是否有自检检验项目 - List<InspectionItemDetail> inspectionItemDetails = inspectionItemService.selectQualityInspection(sfc, operation, stepId, Constants.INSPECTION_TYPE_Z); - if (inspectionItemDetails.size() > 0 && inspectionItemDetails.get(0) != null) { - //是否有自检检验任务 - InspectionTask createTask = inspectionTaskService.isCreateTask(site, Constants.INSPECTION_TYPE_Z, sfc, operation, stepId); - if (createTask == null || !createTask.getStatus().equals(Constants.INSPECTION_TASK_STATUS_COMPLETE)) { - throw new BaseException("请完成自检检验任务"); - } - if (!createTask.getResult().equals(Constants.RSESULT_OK)) { - throw new BaseException("自检任务不合格,不能完成请检查"); - } + String dispatchNo = sfcDto.getDispatchNo(); + Sfc sfcServiceById = sfcService.getById(HandleEnum.SFC.getHandle(site, sfc)); + BigDecimal qty = new BigDecimal(sfcServiceById.getQty().toString()); + //是否有自检检验项目 + List<InspectionItemDetail> inspectionItemDetails = inspectionItemService.selectQualityInspection(sfc, operation, stepId, Constants.INSPECTION_TYPE_Z); + if (inspectionItemDetails.size() > 0 && inspectionItemDetails.get(0) != null) { + //是否有自检检验任务 + InspectionTask createTask = inspectionTaskService.isCreateTask(site, Constants.INSPECTION_TYPE_Z, sfc, operation, stepId); + if (createTask == null || !createTask.getStatus().equals(Constants.INSPECTION_TASK_STATUS_COMPLETE)) { + throw new BaseException("请完成自检检验任务"); } - //是否装配完成 - List<Map<String, Object>> assembleList = sfcDataAssembleMapper.querySfcAssemble(HandleEnum.SFC_DISPATCH.getHandle(site,dispatchNo)); - if (assembleList!=null&&assembleList.size()>0){ - for (Map<String,Object> objectMap:assembleList){ - String isAssemble= (String) objectMap.get("IS_ASSEMBLE"); - if (!isAssemble.equals("GREEN")){ - throw new BaseException("未装配完成"); - } - } + if (!createTask.getResult().equals(Constants.RSESULT_OK)) { + throw new BaseException("自检任务不合格,不能完成请检查"); } - //物料消耗 - materialConsumption(site, operation, HandleEnum.SFC.getHandle(site, sfc), stepId, resrce); - try { - //专检创建 - Map<String, Object> paramMap=new HashMap<>(); - paramMap.put("SFC",sfc); - paramMap.put("SHOP_ORDER",StringUtil.trimHandle(sfcServiceById.getShopOrderBo())); - paramMap.put("OPERATION",operation); - paramMap.put("STEP_ID",stepId); - String workShopBo = commonService.getWorkShopBo(HandleEnum.RESOURCE.getHandle(site, resrce)); - paramMap.put("WORK_CENTER",StringUtil.trimHandle(workShopBo)); - paramMap.put("RESRCE",resrce); - paramMap.put("SFC_DISPATCH_DETAIL_BO",HandleEnum.SFC_DISPATCH.getHandle(site,dispatchNo)); - - inspectionItemDetails = inspectionItemService.selectQualityInspection(sfc,operation, stepId, Constants.INSPECTION_TYPE_P); - if (inspectionItemDetails.size() > 0 && inspectionItemDetails.get(0) != null) { - paramMap.put("CATEGORY",Constants.INSPECTION_TYPE_P); - inspectionTaskService.createTask(paramMap); - }else { - paramMap.put("CATEGORY",Constants.INSPECTION_TYPE_P); - inspectionTaskService.createCompleteTask(paramMap); - } - //首件创建 - inspectionItemDetails = inspectionItemService.selectQualityInspection(sfc,operation, stepId, Constants.INSPECTION_TYPE_S); - if (inspectionItemDetails.size() > 0 && inspectionItemDetails.get(0) != null) { - paramMap.put("CATEGORY",Constants.INSPECTION_TYPE_S); - inspectionTaskService.createTask(paramMap); + } + //是否装配完成 + List<Map<String, Object>> assembleList = sfcDataAssembleMapper.querySfcAssemble(HandleEnum.SFC_DISPATCH.getHandle(site, dispatchNo)); + if (assembleList != null && assembleList.size() > 0) { + for (Map<String, Object> objectMap : assembleList) { + String isAssemble = (String) objectMap.get("IS_ASSEMBLE"); + if (!isAssemble.equals("GREEN")) { + throw new BaseException("未装配完成"); } - //计算工时 - LocalDateTime startTime = sfcService.getSfcStartTime(HandleEnum.SFC.getHandle(site, sfc)); - long workHourSeconds = Duration.between(startTime, LocalDateTime.now()).getSeconds(); - BigDecimal workHour = new BigDecimal(workHourSeconds).divide(BigDecimal.valueOf(3600), 2, RoundingMode.HALF_UP); - postMap.put("sfc",sfc); - postMap.put("stepId",stepId); - postMap.put("qty",qty); - postMap.put("scrapQty",BigDecimal.ZERO); - postMap.put("workHour",workHour); - postMapList.add(postMap); - sfcCrossService.completeAction(site, currentRevisionRef.getHandle(), resrce, sfcServiceById.getHandle(), qty); - //更改派工单状态 - sfcDispatchCommonService.updateSfcDispatchStatus(site, CommonMethods.getUser(), dispatchNo, DispatchStatusEnum.COMPLETE.getCode()); + } + } + //物料消耗 + materialConsumption(site, operation, HandleEnum.SFC.getHandle(site, sfc), stepId, resrce); + try { + //专检创建 + Map<String, Object> paramMap = new HashMap<>(); + paramMap.put("SFC", sfc); + paramMap.put("SHOP_ORDER", StringUtil.trimHandle(sfcServiceById.getShopOrderBo())); + paramMap.put("OPERATION", operation); + paramMap.put("STEP_ID", stepId); + String workShopBo = commonService.getWorkShopBo(HandleEnum.RESOURCE.getHandle(site, resrce)); + paramMap.put("WORK_CENTER", StringUtil.trimHandle(workShopBo)); + paramMap.put("RESRCE", resrce); + paramMap.put("SFC_DISPATCH_DETAIL_BO", HandleEnum.SFC_DISPATCH.getHandle(site, dispatchNo)); - } catch (Exception e) { - ExceptionUtil.throwException(e); + inspectionItemDetails = inspectionItemService.selectQualityInspection(sfc, operation, stepId, Constants.INSPECTION_TYPE_P); + if (inspectionItemDetails.size() > 0 && inspectionItemDetails.get(0) != null) { + paramMap.put("CATEGORY", Constants.INSPECTION_TYPE_P); + inspectionTaskService.createTask(paramMap); + } else { + paramMap.put("CATEGORY", Constants.INSPECTION_TYPE_P); + inspectionTaskService.createCompleteTask(paramMap); + } + //首件创建 + inspectionItemDetails = inspectionItemService.selectQualityInspection(sfc, operation, stepId, Constants.INSPECTION_TYPE_S); + if (inspectionItemDetails.size() > 0 && inspectionItemDetails.get(0) != null) { + paramMap.put("CATEGORY", Constants.INSPECTION_TYPE_S); + inspectionTaskService.createTask(paramMap); } + //计算工时 + LocalDateTime startTime = sfcService.getSfcStartTime(HandleEnum.SFC.getHandle(site, sfc)); + long workHourSeconds = Duration.between(startTime, LocalDateTime.now()).getSeconds(); + BigDecimal workHour = new BigDecimal(workHourSeconds).divide(BigDecimal.valueOf(3600), 2, RoundingMode.HALF_UP); + sfcCrossService.completeAction(site, currentRevisionRef.getHandle(), resrce, sfcServiceById.getHandle(), qty); + //更改派工单状态 + sfcDispatchCommonService.updateSfcDispatchStatus(site, CommonMethods.getUser(), dispatchNo, DispatchStatusEnum.COMPLETE.getCode()); + //报工 + //sendErp(sfc, stepId, qty, BigDecimal.ZERO, workHour); + } catch (Exception e) { + ExceptionUtil.throwException(e); } - //报工 - sendErp(postMapList); + } public void materialConsumption(String site, String operation, String sfcBo, String stepId, String resource) { @@ -425,40 +405,31 @@ public class PodTemplateServiceImpl implements PodTemplateService { } @Override - public void sendErp(List<Map<String,Object>> postMapList) { + public void sendErp(String sfc, String stepId, BigDecimal qty, BigDecimal scrapQty, BigDecimal workHour) { //请求参数 ZprodordconfStruIn[] ins = new ZprodordconfStruIn[1]; - for (int i=0;i<postMapList.size();i++){ - Map<String, Object> map = postMapList.get(i); - String sfc = (String)map.get("sfc"); - Sfc sfcServiceById = sfcService.getById(HandleEnum.SFC.getHandle(CommonMethods.getSite(),sfc)); - String shopOrderBo = sfcServiceById.getShopOrderBo(); - String shopOrder = StringUtil.trimHandle(shopOrderBo); - String stepId = (String)map.get("stepId"); - BigDecimal qty = (BigDecimal) map.get("qty"); - BigDecimal scrapQty = (BigDecimal)map.get("scrapQty"); - BigDecimal workHour = (BigDecimal)map.get("workHour"); - ZprodordconfStruIn struIn = new ZprodordconfStruIn(); - //生产订单 - struIn.setAufnr(shopOrder); - //步骤标示 - struIn.setVornr(stepId); - struIn.setAueru("1"); - //良品数量 - struIn.setLmnga(qty); - //报废数量 - struIn.setXmnga(scrapQty); - //机器工时 - struIn.setIsm01(workHour); - //人工工时 - struIn.setIsm02(workHour); - struIn.setIsm03(BigDecimal.ZERO); - struIn.setIsm04(BigDecimal.ZERO); - struIn.setIsm05(BigDecimal.ZERO); - struIn.setIsm06(BigDecimal.ZERO); - ins[i] = struIn; - } - + Sfc sfcServiceById = sfcService.getById(HandleEnum.SFC.getHandle(CommonMethods.getSite(), sfc)); + String shopOrderBo = sfcServiceById.getShopOrderBo(); + String shopOrder = StringUtil.trimHandle(shopOrderBo); + ZprodordconfStruIn struIn = new ZprodordconfStruIn(); + //生产订单 + struIn.setAufnr(shopOrder); + //步骤标示 + struIn.setVornr(stepId); + struIn.setAueru("1"); + //良品数量 + struIn.setLmnga(qty); + //报废数量 + struIn.setXmnga(scrapQty); + //机器工时 + struIn.setIsm01(workHour); + //人工工时 + struIn.setIsm02(workHour); + struIn.setIsm03(workHour); + struIn.setIsm04(workHour); + struIn.setIsm05(workHour); + struIn.setIsm06(workHour); + ins[0] = struIn; TableOfZprodordconfStruInHolder inHolder = new TableOfZprodordconfStruInHolder(ins); //返回对象 @@ -477,13 +448,16 @@ public class PodTemplateServiceImpl implements PodTemplateService { //调用WS try { ERPAPI.erpWebService().zmesProdordconf(inHolder, outHolder); + if (outHolder.value.length == 1) { + throw new BaseException("ERP接口返回错误"); + } String status = outHolder.value[1].getRet(); String message = outHolder.value[1].getMsg(); - if (status.equals("E")) { - throw new BaseException("ERP接口返回:状态:" + status + ",消息:" + message); + if (!status.equals("S")) { + throw new BaseException("ERP接口返回错误消息:" + message); } } catch (RemoteException e) { - ExceptionUtil.throwException(e); + throw new BaseException("ERP接口错误: " + e.getMessage()); } finally { //记录接口日志 IntegrationLog log = new IntegrationLog(); @@ -493,7 +467,7 @@ public class PodTemplateServiceImpl implements PodTemplateService { log.setCategory("REQUEST"); log.setIntegrationWay("ERP"); log.setIntegrationMethod("erpWebService.zmesProdordconf"); - log.setParam(inHolder.toString()); + log.setParam(Arrays.toString(ins)); log.setStatus(outHolder.value[1].getRet()); log.setResultMessage(outHolder.value[1].getMsg()); log.setTransactionId(""); diff --git a/quality/src/main/java/com/foreverwin/mesnac/quality/model/SelfReport.java b/quality/src/main/java/com/foreverwin/mesnac/quality/model/SelfReport.java index 98467c1f..1221dc1e 100644 --- a/quality/src/main/java/com/foreverwin/mesnac/quality/model/SelfReport.java +++ b/quality/src/main/java/com/foreverwin/mesnac/quality/model/SelfReport.java @@ -17,105 +17,111 @@ import java.time.LocalDateTime; * </p> * * @author Philip - * @since 2021-06-21 + * @since 2021-08-16 */ @TableName("Z_SELF_REPORT") public class SelfReport extends Model<SelfReport> { - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; - /** - * 主键 - */ + /** + * 主键 + */ @TableId(value = "HANDLE", type = IdType.INPUT) private String handle; - /** - * 站点 - */ + /** + * 站点 + */ @TableField("SITE") private String site; - /** - * 检验任务编号 - */ + /** + * 检验任务编号 + */ @TableField("TASK_NO") private String taskNo; - /** - * 车间 - */ + /** + * 车间 + */ @TableField("WORK_CENTER") private String workCenter; - /** - * 工单 - */ + /** + * 工单 + */ @TableField("SHOP_ORDER") private String shopOrder; - /** - * 物料 - */ + /** + * 物料 + */ @TableField("ITEM") private String item; - /** - * 工序/步骤 - */ + /** + * 工序/步骤 + */ @TableField("OP_STEP") private String opStep; - /** - * 资源 - */ + /** + * 资源 + */ @TableField("RESRCE") private String resrce; - /** - * 产品条码 - */ + /** + * 产品条码 + */ @TableField("SFC") private String sfc; - /** - * 不良代码 - */ + /** + * 不良代码 + */ @TableField("NC_CODE") private String ncCode; - /** - * 不良数量 - */ + /** + * 不良数量 + */ @TableField("NC_QTY") private BigDecimal ncQty; - /** - * 设备位置 - */ + /** + * 设备位置 + */ @TableField("LOCATION") private String location; - /** - * 状态:创建|NEW、确认|CONF、驳回|REJ - */ + /** + * 状态:创建|NEW、确认|CONF、驳回|REJ + */ @TableField("STATE") private String state; - /** - * 不良备注 - */ + /** + * 不良备注 + */ @TableField("REMARK") private String remark; - /** - * 创建人 - */ + /** + * 创建人 + */ @TableField("CREATE_USER") private String createUser; - /** - * 创建时间 - */ + /** + * 创建时间 + */ @TableField("CREATED_DATE_TIME") private LocalDateTime createdDateTime; - /** - * 修改人 - */ + /** + * 修改人 + */ @TableField("MODIFY_USER") private String modifyUser; - /** - * 修改时间 - */ + /** + * 修改时间 + */ @TableField("MODIFIED_DATE_TIME") private LocalDateTime modifiedDateTime; + /** + * 不良描述 + */ + @TableField("NC_CODE_DESC") + private String ncCodeDesc; + /** * 开始时间 */ @@ -302,41 +308,51 @@ public class SelfReport extends Model<SelfReport> { this.modifiedDateTime = modifiedDateTime; } - public static final String HANDLE = "HANDLE"; + public String getNcCodeDesc() { + return ncCodeDesc; + } + + public void setNcCodeDesc(String ncCodeDesc) { + this.ncCodeDesc = ncCodeDesc; + } + +public static final String HANDLE = "HANDLE"; + +public static final String SITE = "SITE"; - public static final String SITE = "SITE"; +public static final String TASK_NO = "TASK_NO"; - public static final String TASK_NO = "TASK_NO"; +public static final String WORK_CENTER = "WORK_CENTER"; - public static final String WORK_CENTER = "WORK_CENTER"; +public static final String SHOP_ORDER = "SHOP_ORDER"; - public static final String SHOP_ORDER = "SHOP_ORDER"; +public static final String ITEM = "ITEM"; - public static final String ITEM = "ITEM"; +public static final String OP_STEP = "OP_STEP"; - public static final String OP_STEP = "OP_STEP"; +public static final String RESRCE = "RESRCE"; - public static final String RESRCE = "RESRCE"; +public static final String SFC = "SFC"; - public static final String SFC = "SFC"; +public static final String NC_CODE = "NC_CODE"; - public static final String NC_CODE = "NC_CODE"; +public static final String NC_QTY = "NC_QTY"; - public static final String NC_QTY = "NC_QTY"; +public static final String LOCATION = "LOCATION"; - public static final String LOCATION = "LOCATION"; +public static final String STATE = "STATE"; - public static final String STATE = "STATE"; +public static final String REMARK = "REMARK"; - public static final String REMARK = "REMARK"; +public static final String CREATE_USER = "CREATE_USER"; - public static final String CREATE_USER = "CREATE_USER"; +public static final String CREATED_DATE_TIME = "CREATED_DATE_TIME"; - public static final String CREATED_DATE_TIME = "CREATED_DATE_TIME"; +public static final String MODIFY_USER = "MODIFY_USER"; - public static final String MODIFY_USER = "MODIFY_USER"; +public static final String MODIFIED_DATE_TIME = "MODIFIED_DATE_TIME"; - public static final String MODIFIED_DATE_TIME = "MODIFIED_DATE_TIME"; +public static final String NC_CODE_DESC = "NC_CODE_DESC"; @Override @@ -347,24 +363,25 @@ public class SelfReport extends Model<SelfReport> { @Override public String toString() { return "SelfReport{" + - "handle = " + handle + - ", site = " + site + - ", taskNo = " + taskNo + - ", workCenter = " + workCenter + - ", shopOrder = " + shopOrder + - ", item = " + item + - ", opStep = " + opStep + - ", resrce = " + resrce + - ", sfc = " + sfc + - ", ncCode = " + ncCode + - ", ncQty = " + ncQty + - ", location = " + location + - ", state = " + state + - ", remark = " + remark + - ", createUser = " + createUser + - ", createdDateTime = " + createdDateTime + - ", modifyUser = " + modifyUser + - ", modifiedDateTime = " + modifiedDateTime + - "}"; + "handle = " + handle + + ", site = " + site + + ", taskNo = " + taskNo + + ", workCenter = " + workCenter + + ", shopOrder = " + shopOrder + + ", item = " + item + + ", opStep = " + opStep + + ", resrce = " + resrce + + ", sfc = " + sfc + + ", ncCode = " + ncCode + + ", ncQty = " + ncQty + + ", location = " + location + + ", state = " + state + + ", remark = " + remark + + ", createUser = " + createUser + + ", createdDateTime = " + createdDateTime + + ", modifyUser = " + modifyUser + + ", modifiedDateTime = " + modifiedDateTime + + ", ncCodeDesc = " + ncCodeDesc + + "}"; } } \ No newline at end of file diff --git a/quality/src/main/java/com/foreverwin/mesnac/quality/service/impl/SelfReportServiceImpl.java b/quality/src/main/java/com/foreverwin/mesnac/quality/service/impl/SelfReportServiceImpl.java index 3a65bd63..4c266396 100644 --- a/quality/src/main/java/com/foreverwin/mesnac/quality/service/impl/SelfReportServiceImpl.java +++ b/quality/src/main/java/com/foreverwin/mesnac/quality/service/impl/SelfReportServiceImpl.java @@ -11,7 +11,9 @@ import com.foreverwin.mesnac.common.enums.HandleEnum; import com.foreverwin.mesnac.common.service.AnomalyService; import com.foreverwin.mesnac.common.service.CommonService; import com.foreverwin.mesnac.common.util.StringUtil; +import com.foreverwin.mesnac.meapi.dto.NcCodeDto; import com.foreverwin.mesnac.meapi.dto.SfcDto; +import com.foreverwin.mesnac.meapi.service.NcCodeService; import com.foreverwin.mesnac.production.mapper.SfcCrossMapper; import com.foreverwin.mesnac.quality.dto.SelfReportRequest; import com.foreverwin.mesnac.quality.mapper.SelfReportMapper; @@ -55,6 +57,8 @@ public class SelfReportServiceImpl extends ServiceImpl<SelfReportMapper, SelfRep private AnomalyService anomalyService; @Autowired private CommonService commonService; + @Autowired + private NcCodeService ncCodeService; @Override @@ -131,10 +135,15 @@ public class SelfReportServiceImpl extends ServiceImpl<SelfReportMapper, SelfRep List<SelfReportRequest> selfReportList = list.stream().filter(selfReportRequest -> selfReportRequest.getType().equals("Z")).collect(Collectors.toList()); if (selfReportList.size()>0){ StringBuilder stringBuilder = new StringBuilder(); + StringBuilder description = new StringBuilder(); for (int i=0;i<selfReportList.size();i++){ - stringBuilder.append(selfReportList.get(i).getNcCode()); + String ncCode = selfReportList.get(i).getNcCode(); + stringBuilder.append(ncCode); + List<NcCodeDto> ncCodeDescriptionByNcCode = ncCodeService.findNcCodeDescriptionByNcCode(ncCode); + description.append(ncCodeDescriptionByNcCode.get(0).getNgDescription()); if (i!=selfReportList.size()-1){ stringBuilder.append(","); + description.append(","); } } Date date = new Date(System.currentTimeMillis()); @@ -157,6 +166,7 @@ public class SelfReportServiceImpl extends ServiceImpl<SelfReportMapper, SelfRep selfReport.setResrce(resrce); selfReport.setSfc(sfc); selfReport.setNcCode(stringBuilder.toString()); + selfReport.setNcCodeDesc(description.toString()); selfReport.setNcQty(new BigDecimal(ncQty)); selfReport.setLocation(location); selfReport.setState(Constants.STATUS_NEW); diff --git a/quality/src/main/resources/mapper/SelfReportMapper.xml b/quality/src/main/resources/mapper/SelfReportMapper.xml index 1cb34a29..4cc89cb2 100644 --- a/quality/src/main/resources/mapper/SelfReportMapper.xml +++ b/quality/src/main/resources/mapper/SelfReportMapper.xml @@ -22,11 +22,12 @@ <result column="CREATED_DATE_TIME" property="createdDateTime" /> <result column="MODIFY_USER" property="modifyUser" /> <result column="MODIFIED_DATE_TIME" property="modifiedDateTime" /> + <result column="NC_CODE_DESC" property="ncCodeDesc" /> </resultMap> <!-- 通用查询结果列 --> <sql id="Base_Column_List"> - HANDLE, SITE, TASK_NO, WORK_CENTER, SHOP_ORDER, ITEM, OP_STEP, RESRCE, SFC, NC_CODE, NC_QTY, LOCATION, STATE, REMARK, CREATE_USER, CREATED_DATE_TIME, MODIFY_USER, MODIFIED_DATE_TIME + HANDLE, SITE, TASK_NO, WORK_CENTER, SHOP_ORDER, ITEM, OP_STEP, RESRCE, SFC, NC_CODE, NC_QTY, LOCATION, STATE, REMARK, CREATE_USER, CREATED_DATE_TIME, MODIFY_USER, MODIFIED_DATE_TIME, NC_CODE_DESC </sql> <!-- BaseMapper标准查询/修改/删除 --> @@ -78,6 +79,7 @@ <if test="ew.entity.createdDateTime!=null"> AND CREATED_DATE_TIME=#{ew.entity.createdDateTime}</if> <if test="ew.entity.modifyUser!=null"> AND MODIFY_USER=#{ew.entity.modifyUser}</if> <if test="ew.entity.modifiedDateTime!=null"> AND MODIFIED_DATE_TIME=#{ew.entity.modifiedDateTime}</if> + <if test="ew.entity.ncCodeDesc!=null"> AND NC_CODE_DESC=#{ew.entity.ncCodeDesc}</if> </where> </select> @@ -106,6 +108,7 @@ <if test="ew.entity.createdDateTime!=null"> AND CREATED_DATE_TIME=#{ew.entity.createdDateTime}</if> <if test="ew.entity.modifyUser!=null"> AND MODIFY_USER=#{ew.entity.modifyUser}</if> <if test="ew.entity.modifiedDateTime!=null"> AND MODIFIED_DATE_TIME=#{ew.entity.modifiedDateTime}</if> + <if test="ew.entity.ncCodeDesc!=null"> AND NC_CODE_DESC=#{ew.entity.ncCodeDesc}</if> </if> <if test="ew!=null and ew.sqlSegment!=null and ew.nonEmptyOfWhere"> ${ew.sqlSegment} @@ -142,6 +145,7 @@ <if test="ew.entity.createdDateTime!=null"> AND CREATED_DATE_TIME=#{ew.entity.createdDateTime}</if> <if test="ew.entity.modifyUser!=null"> AND MODIFY_USER=#{ew.entity.modifyUser}</if> <if test="ew.entity.modifiedDateTime!=null"> AND MODIFIED_DATE_TIME=#{ew.entity.modifiedDateTime}</if> + <if test="ew.entity.ncCodeDesc!=null"> AND NC_CODE_DESC=#{ew.entity.ncCodeDesc}</if> </if> <if test="ew!=null and ew.sqlSegment!=null and ew.nonEmptyOfWhere"> ${ew.sqlSegment} @@ -152,46 +156,6 @@ ${ew.sqlSegment} </if> </select> - <select id="selectListByCondition" resultMap="BaseResultMap"> - SELECT ZSR.HANDLE, ZSR.SITE, ZSR.TASK_NO, ZSR.WORK_CENTER, ZSR.SHOP_ORDER, ZSR.ITEM, ZSR.OP_STEP, ZSR.RESRCE, ZSR.SFC, ZSR.NC_CODE, ZSR.NC_QTY, ZSR.LOCATION, ZSR.STATE, ZSR.REMARK, B.FULL_NAME CREATE_USER,ZSR. CREATED_DATE_TIME,IT.DESCRIPTION FROM Z_SELF_REPORT ZSR - JOIN ITEM I ON I.ITEM = ZSR.ITEM AND I.CURRENT_REVISION='true' - LEFT JOIN ITEM_T IT ON I.HANDLE = IT.ITEM_BO AND IT.LOCALE = #{locale} - LEFT JOIN Z_NWA_USER B ON ZSR.SITE = B.SITE AND ZSR.CREATE_USER = B.USER_NAME - <where> - <if test="ew!=null"> - <if test="ew.entity!=null"> - <if test="ew.entity.handle!=null"> - HANDLE=#{ew.entity.handle} - </if> - <if test="ew.entity.site!=null"> AND ZSR.SITE=#{ew.entity.site}</if> - <if test="ew.entity.taskNo!=null"> AND ZSR.TASK_NO=#{ew.entity.taskNo}</if> - <if test="ew.entity.workCenter!=null and ew.entity.workCenter!='' "> AND ZSR.WORK_CENTER=#{ew.entity.workCenter}</if> - <if test="ew.entity.shopOrder!=null and ew.entity.shopOrder!=''"> AND ZSR.SHOP_ORDER=#{ew.entity.shopOrder}</if> - <if test="ew.entity.item!=null and ew.entity.item!=''"> AND ZSR.ITEM=#{ew.entity.item}</if> - <if test="ew.entity.opStep!=null and ew.entity.opStep!=''"> AND ZSR.OP_STEP=#{ew.entity.opStep}</if> - <if test="ew.entity.resrce!=null"> AND ZSR.RESRCE=#{ew.entity.resrce}</if> - <if test="ew.entity.sfc!=null and ew.entity.sfc!='' "> AND ZSR.SFC=#{ew.entity.sfc}</if> - <if test="ew.entity.ncCode!=null"> AND ZSR.NC_CODE=#{ew.entity.ncCode}</if> - <if test="ew.entity.ncQty!=null"> AND ZSR.NC_QTY=#{ew.entity.ncQty}</if> - <if test="ew.entity.location!=null"> AND ZSR.LOCATION=#{ew.entity.location}</if> - <if test="ew.entity.state!=null and ew.entity.state!=''"> AND ZSR.STATE=#{ew.entity.state}</if> - <if test="ew.entity.remark!=null"> AND ZSR.REMARK=#{ew.entity.remark}</if> - <if test="ew.entity.createUser!=null"> AND ZSR.CREATE_USER=#{ew.entity.createUser}</if> - <if test="ew.entity.createdDateTime!=null"> AND ZSR.CREATED_DATE_TIME=#{ew.entity.createdDateTime}</if> - <if test="ew.entity.modifyUser!=null"> AND ZSR.MODIFY_USER=#{ew.entity.modifyUser}</if> - <if test="ew.entity.modifiedDateTime!=null"> AND ZSR.MODIFIED_DATE_TIME=#{ew.entity.modifiedDateTime}</if> - </if> - <if test="startTime!=null"> AND ZSR.CREATED_DATE_TIME >=#{startTime}</if> - <if test="endTime!=null"> AND ZSR.CREATED_DATE_TIME <=#{endTime}</if> - <if test="ew!=null and ew.sqlSegment!=null and ew.nonEmptyOfWhere"> - ${ew.sqlSegment} - </if> - </if> - </where> - <if test="ew!=null and ew.sqlSegment!=null and ew.emptyOfWhere"> - ${ew.sqlSegment} - </if> - </select> <select id="selectMaps" resultType="HashMap"> SELECT <choose><when test="ew != null and ew.sqlSelect != null">${ew.sqlSelect}</when><otherwise><include refid="Base_Column_List"></include></otherwise></choose> FROM Z_SELF_REPORT @@ -218,6 +182,7 @@ <if test="ew.entity.createdDateTime!=null"> AND CREATED_DATE_TIME=#{ew.entity.createdDateTime}</if> <if test="ew.entity.modifyUser!=null"> AND MODIFY_USER=#{ew.entity.modifyUser}</if> <if test="ew.entity.modifiedDateTime!=null"> AND MODIFIED_DATE_TIME=#{ew.entity.modifiedDateTime}</if> + <if test="ew.entity.ncCodeDesc!=null"> AND NC_CODE_DESC=#{ew.entity.ncCodeDesc}</if> </if> <if test="ew!=null and ew.sqlSegment!=null and ew.nonEmptyOfWhere"> ${ew.sqlSegment} @@ -254,6 +219,7 @@ <if test="ew.entity.createdDateTime!=null"> AND CREATED_DATE_TIME=#{ew.entity.createdDateTime}</if> <if test="ew.entity.modifyUser!=null"> AND MODIFY_USER=#{ew.entity.modifyUser}</if> <if test="ew.entity.modifiedDateTime!=null"> AND MODIFIED_DATE_TIME=#{ew.entity.modifiedDateTime}</if> + <if test="ew.entity.ncCodeDesc!=null"> AND NC_CODE_DESC=#{ew.entity.ncCodeDesc}</if> </if> <if test="ew!=null and ew.sqlSegment!=null and ew.nonEmptyOfWhere"> ${ew.sqlSegment} @@ -290,6 +256,7 @@ <if test="ew.entity.createdDateTime!=null"> AND CREATED_DATE_TIME=#{ew.entity.createdDateTime}</if> <if test="ew.entity.modifyUser!=null"> AND MODIFY_USER=#{ew.entity.modifyUser}</if> <if test="ew.entity.modifiedDateTime!=null"> AND MODIFIED_DATE_TIME=#{ew.entity.modifiedDateTime}</if> + <if test="ew.entity.ncCodeDesc!=null"> AND NC_CODE_DESC=#{ew.entity.ncCodeDesc}</if> </if> <if test="ew!=null and ew.sqlSegment!=null and ew.nonEmptyOfWhere"> ${ew.sqlSegment} @@ -326,6 +293,7 @@ <if test="ew.entity.createdDateTime!=null"> AND CREATED_DATE_TIME=#{ew.entity.createdDateTime}</if> <if test="ew.entity.modifyUser!=null"> AND MODIFY_USER=#{ew.entity.modifyUser}</if> <if test="ew.entity.modifiedDateTime!=null"> AND MODIFIED_DATE_TIME=#{ew.entity.modifiedDateTime}</if> + <if test="ew.entity.ncCodeDesc!=null"> AND NC_CODE_DESC=#{ew.entity.ncCodeDesc}</if> </if> <if test="ew!=null and ew.sqlSegment!=null and ew.nonEmptyOfWhere"> ${ew.sqlSegment} @@ -358,6 +326,7 @@ <if test="createdDateTime!=null">CREATED_DATE_TIME,</if> <if test="modifyUser!=null">MODIFY_USER,</if> <if test="modifiedDateTime!=null">MODIFIED_DATE_TIME,</if> + <if test="ncCodeDesc!=null">NC_CODE_DESC,</if> </trim> VALUES <trim prefix="(" suffix=")" suffixOverrides=","> #{handle}, @@ -378,6 +347,7 @@ <if test="createdDateTime!=null">#{createdDateTime},</if> <if test="modifyUser!=null">#{modifyUser},</if> <if test="modifiedDateTime!=null">#{modifiedDateTime},</if> + <if test="ncCodeDesc!=null">#{ncCodeDesc},</if> </trim> </insert> @@ -405,6 +375,7 @@ #{createdDateTime}, #{modifyUser}, #{modifiedDateTime}, + #{ncCodeDesc}, </trim> </insert> @@ -428,6 +399,7 @@ <if test="et.createdDateTime!=null">CREATED_DATE_TIME=#{et.createdDateTime},</if> <if test="et.modifyUser!=null">MODIFY_USER=#{et.modifyUser},</if> <if test="et.modifiedDateTime!=null">MODIFIED_DATE_TIME=#{et.modifiedDateTime},</if> + <if test="et.ncCodeDesc!=null">NC_CODE_DESC=#{et.ncCodeDesc},</if> </trim> WHERE HANDLE=#{et.handle} <if test="et instanceof java.util.Map"><if test="et.MP_OPTLOCK_VERSION_ORIGINAL!=null">and ${et.MP_OPTLOCK_VERSION_COLUMN}=#{et.MP_OPTLOCK_VERSION_ORIGINAL}</if></if> </update> @@ -451,6 +423,7 @@ CREATED_DATE_TIME=#{et.createdDateTime}, MODIFY_USER=#{et.modifyUser}, MODIFIED_DATE_TIME=#{et.modifiedDateTime}, + NC_CODE_DESC=#{et.ncCodeDesc}, </trim> WHERE HANDLE=#{et.handle} <if test="et instanceof java.util.Map"><if test="et.MP_OPTLOCK_VERSION_ORIGINAL!=null">and ${et.MP_OPTLOCK_VERSION_COLUMN}=#{et.MP_OPTLOCK_VERSION_ORIGINAL}</if></if> </update> @@ -474,6 +447,7 @@ <if test="et.createdDateTime!=null">CREATED_DATE_TIME=#{et.createdDateTime},</if> <if test="et.modifyUser!=null">MODIFY_USER=#{et.modifyUser},</if> <if test="et.modifiedDateTime!=null">MODIFIED_DATE_TIME=#{et.modifiedDateTime},</if> + <if test="et.ncCodeDesc!=null">NC_CODE_DESC=#{et.ncCodeDesc},</if> </trim> <where> <if test="ew!=null"> @@ -496,6 +470,7 @@ <if test="ew.entity.createdDateTime!=null"> AND CREATED_DATE_TIME=#{ew.entity.createdDateTime}</if> <if test="ew.entity.modifyUser!=null"> AND MODIFY_USER=#{ew.entity.modifyUser}</if> <if test="ew.entity.modifiedDateTime!=null"> AND MODIFIED_DATE_TIME=#{ew.entity.modifiedDateTime}</if> + <if test="ew.entity.ncCodeDesc!=null"> AND NC_CODE_DESC=#{ew.entity.ncCodeDesc}</if> </if> <if test="ew!=null and ew.sqlSegment!=null and ew.nonEmptyOfWhere"> ${ew.sqlSegment} @@ -549,6 +524,7 @@ <if test="ew.entity.createdDateTime!=null"> AND CREATED_DATE_TIME=#{ew.entity.createdDateTime}</if> <if test="ew.entity.modifyUser!=null"> AND MODIFY_USER=#{ew.entity.modifyUser}</if> <if test="ew.entity.modifiedDateTime!=null"> AND MODIFIED_DATE_TIME=#{ew.entity.modifiedDateTime}</if> + <if test="ew.entity.ncCodeDesc!=null"> AND NC_CODE_DESC=#{ew.entity.ncCodeDesc}</if> </if> <if test="ew!=null and ew.sqlSegment!=null and ew.nonEmptyOfWhere"> ${ew.sqlSegment} @@ -566,5 +542,44 @@ </foreach>) </delete> <!-- BaseMapper标准查询/修改/删除 --> - + <select id="selectListByCondition" resultMap="BaseResultMap"> + SELECT ZSR.HANDLE, ZSR.SITE, ZSR.TASK_NO, ZSR.WORK_CENTER,ZSR.NC_CODE_DESC, ZSR.SHOP_ORDER, ZSR.ITEM, ZSR.OP_STEP, ZSR.RESRCE, ZSR.SFC, ZSR.NC_CODE, ZSR.NC_QTY, ZSR.LOCATION, ZSR.STATE, ZSR.REMARK, B.FULL_NAME CREATE_USER,ZSR. CREATED_DATE_TIME,IT.DESCRIPTION FROM Z_SELF_REPORT ZSR + JOIN ITEM I ON I.ITEM = ZSR.ITEM AND I.CURRENT_REVISION='true' + LEFT JOIN ITEM_T IT ON I.HANDLE = IT.ITEM_BO AND IT.LOCALE = #{locale} + LEFT JOIN Z_NWA_USER B ON ZSR.SITE = B.SITE AND ZSR.CREATE_USER = B.USER_NAME + <where> + <if test="ew!=null"> + <if test="ew.entity!=null"> + <if test="ew.entity.handle!=null"> + HANDLE=#{ew.entity.handle} + </if> + <if test="ew.entity.site!=null"> AND ZSR.SITE=#{ew.entity.site}</if> + <if test="ew.entity.taskNo!=null"> AND ZSR.TASK_NO=#{ew.entity.taskNo}</if> + <if test="ew.entity.workCenter!=null and ew.entity.workCenter!='' "> AND ZSR.WORK_CENTER=#{ew.entity.workCenter}</if> + <if test="ew.entity.shopOrder!=null and ew.entity.shopOrder!=''"> AND ZSR.SHOP_ORDER=#{ew.entity.shopOrder}</if> + <if test="ew.entity.item!=null and ew.entity.item!=''"> AND ZSR.ITEM=#{ew.entity.item}</if> + <if test="ew.entity.opStep!=null and ew.entity.opStep!=''"> AND ZSR.OP_STEP=#{ew.entity.opStep}</if> + <if test="ew.entity.resrce!=null"> AND ZSR.RESRCE=#{ew.entity.resrce}</if> + <if test="ew.entity.sfc!=null and ew.entity.sfc!='' "> AND ZSR.SFC=#{ew.entity.sfc}</if> + <if test="ew.entity.ncCode!=null"> AND ZSR.NC_CODE=#{ew.entity.ncCode}</if> + <if test="ew.entity.ncQty!=null"> AND ZSR.NC_QTY=#{ew.entity.ncQty}</if> + <if test="ew.entity.location!=null"> AND ZSR.LOCATION=#{ew.entity.location}</if> + <if test="ew.entity.state!=null and ew.entity.state!=''"> AND ZSR.STATE=#{ew.entity.state}</if> + <if test="ew.entity.remark!=null"> AND ZSR.REMARK=#{ew.entity.remark}</if> + <if test="ew.entity.createUser!=null"> AND ZSR.CREATE_USER=#{ew.entity.createUser}</if> + <if test="ew.entity.createdDateTime!=null"> AND ZSR.CREATED_DATE_TIME=#{ew.entity.createdDateTime}</if> + <if test="ew.entity.modifyUser!=null"> AND ZSR.MODIFY_USER=#{ew.entity.modifyUser}</if> + <if test="ew.entity.modifiedDateTime!=null"> AND ZSR.MODIFIED_DATE_TIME=#{ew.entity.modifiedDateTime}</if> + </if> + <if test="startTime!=null"> AND ZSR.CREATED_DATE_TIME >=#{startTime}</if> + <if test="endTime!=null"> AND ZSR.CREATED_DATE_TIME <=#{endTime}</if> + <if test="ew!=null and ew.sqlSegment!=null and ew.nonEmptyOfWhere"> + ${ew.sqlSegment} + </if> + </if> + </where> + <if test="ew!=null and ew.sqlSegment!=null and ew.emptyOfWhere"> + ${ew.sqlSegment} + </if> + </select> </mapper>