diff --git a/anomaly/src/main/java/com/foreverwin/mesnac/anomaly/controller/ReportController.java b/anomaly/src/main/java/com/foreverwin/mesnac/anomaly/controller/ReportController.java index 841ecc55..66993910 100644 --- a/anomaly/src/main/java/com/foreverwin/mesnac/anomaly/controller/ReportController.java +++ b/anomaly/src/main/java/com/foreverwin/mesnac/anomaly/controller/ReportController.java @@ -13,6 +13,8 @@ import com.foreverwin.modular.core.util.R; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; +import java.util.Map; + @RestController @RequestMapping("/REPORT") public class ReportController { @@ -46,4 +48,18 @@ public class ReportController { return R.failed(e.getMessage()); } } + + /** + * 设备维修记录报表 + * @param map + * @return + */ + @PostMapping("/resourceRepair") + public R resourceRepair(@RequestBody(required = false)Map map){ + try{ + return R.ok(reportService.resourceRepair(map)); + }catch (Exception e){ + return R.failed(e.getMessage()); + } + } } diff --git a/anomaly/src/main/java/com/foreverwin/mesnac/anomaly/mapper/ReportMapper.java b/anomaly/src/main/java/com/foreverwin/mesnac/anomaly/mapper/ReportMapper.java index 059c60ee..67fb7a77 100644 --- a/anomaly/src/main/java/com/foreverwin/mesnac/anomaly/mapper/ReportMapper.java +++ b/anomaly/src/main/java/com/foreverwin/mesnac/anomaly/mapper/ReportMapper.java @@ -23,4 +23,7 @@ public interface ReportMapper { List> surplusReturnTable(@Param("site")String site, @Param("locale")String locale, @Param("item")String item, @Param("itemDescription")String itemDescription); + List> resourceRepair(@Param("site")String site, @Param("locale")String locale, + @Param("param")Map map); + } diff --git a/anomaly/src/main/java/com/foreverwin/mesnac/anomaly/service/ReportService.java b/anomaly/src/main/java/com/foreverwin/mesnac/anomaly/service/ReportService.java index d59d2103..021575d1 100644 --- a/anomaly/src/main/java/com/foreverwin/mesnac/anomaly/service/ReportService.java +++ b/anomaly/src/main/java/com/foreverwin/mesnac/anomaly/service/ReportService.java @@ -17,4 +17,6 @@ public interface ReportService { List> partsManufacturing(PartsManufacturing partsManufacturing); List> surplusReturnTable(String item, String itemDescription); + + List> resourceRepair(Map map); } diff --git a/anomaly/src/main/java/com/foreverwin/mesnac/anomaly/service/impl/ReportServiceImpl.java b/anomaly/src/main/java/com/foreverwin/mesnac/anomaly/service/impl/ReportServiceImpl.java index d463cc23..1e8800f6 100644 --- a/anomaly/src/main/java/com/foreverwin/mesnac/anomaly/service/impl/ReportServiceImpl.java +++ b/anomaly/src/main/java/com/foreverwin/mesnac/anomaly/service/impl/ReportServiceImpl.java @@ -4,14 +4,21 @@ import com.foreverwin.mesnac.anomaly.dto.PartsManufacturing; import com.foreverwin.mesnac.anomaly.mapper.ReportMapper; import com.foreverwin.mesnac.anomaly.service.ReportService; import com.foreverwin.mesnac.integration.model.IntegrationLog; +import com.foreverwin.mesnac.meapi.model.NcCode; +import com.foreverwin.mesnac.meapi.model.NwaUser; +import com.foreverwin.mesnac.meapi.service.NcCodeService; +import com.foreverwin.mesnac.meapi.service.NwaUserService; +import com.foreverwin.mesnac.meapi.util.StringUtils; import com.foreverwin.modular.core.util.CommonMethods; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.i18n.LocaleContextHolder; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.stream.Collectors; /** * @Description TODO @@ -22,8 +29,12 @@ import java.util.Map; @Transactional(rollbackFor = Exception.class) public class ReportServiceImpl implements ReportService { + @Autowired + private NcCodeService ncCodeService; @Autowired private ReportMapper reportMapper; + @Autowired + private NwaUserService nwaUserService; /** * 接口日志表 @@ -55,4 +66,68 @@ public class ReportServiceImpl implements ReportService { String site = CommonMethods.getSite(); return reportMapper.surplusReturnTable(site,locale,item,itemDescription); } + + @Override + public List> resourceRepair(Map map) { + String locale = LocaleContextHolder.getLocale().getLanguage(); + String site = CommonMethods.getSite(); + + + + Map> ncCodeMap = new HashMap<>(); + NcCode ncCode = new NcCode(); + ncCode.setSite(site); + List ncCodeList = ncCodeService.selectList(ncCode); + if (ncCodeList != null && ncCodeList.size() > 0) { + ncCodeMap = ncCodeList.stream().collect(Collectors.groupingBy(NcCode::getNcCode)); + } + + Map> userMap = new HashMap<>(); + NwaUser nwaUser = new NwaUser(); + nwaUser.setSite(site); + List nwaUserList = nwaUserService.selectList(nwaUser); + if(nwaUserList != null && nwaUserList.size() > 0) { + userMap = nwaUserList.stream().collect(Collectors.groupingBy(NwaUser::getUserName)); + } + + + List> maps = reportMapper.resourceRepair(site, locale, map); + + + for (int i = 0; i < maps.size(); i++) { + Map temporaryMap = maps.get(i); + String ncCodes = (String)temporaryMap.get("NC_CODE_NO"); + if(StringUtils.isBlank(ncCodes)){ + maps.get(i).put("NC_CODE_DESCRIPTION", ""); + continue; + } + String []ncCodeArray = ncCodes.split(","); + String ncCodeDesc = ""; + for (int j = 0; j < ncCodeArray.length; j++) { + ncCodeDesc += ncCodeMap.get(ncCodeArray[j]).get(0).getDescription()+";"; + } + maps.get(i).put("NC_CODE_DESCRIPTION", ncCodeDesc); + } + + + for (int i = 0; i < maps.size(); i++) { + Map temporaryMap = maps.get(i); + String repairUser = (String)temporaryMap.get("REPAIR_USERS"); + if(StringUtils.isBlank(repairUser)){ + maps.get(i).put("REPAIR_USERS_DESCRIPTION", ""); + continue; + } + String []repairUserArray = repairUser.split(","); + String repairUserDescription = ""; + for (int j = 0; j < repairUserArray.length; j++) { + repairUserDescription += userMap.get(repairUserArray[j]).get(0).getFullName()+";"; + } + maps.get(i).put("REPAIR_USERS_DESCRIPTION", repairUserDescription); + } + + + + + return maps; + } } diff --git a/anomaly/src/main/resources/mapper/ReportMapper.xml b/anomaly/src/main/resources/mapper/ReportMapper.xml index d020e5ec..056453af 100644 --- a/anomaly/src/main/resources/mapper/ReportMapper.xml +++ b/anomaly/src/main/resources/mapper/ReportMapper.xml @@ -88,4 +88,54 @@ + + \ No newline at end of file diff --git a/common/src/main/java/com/foreverwin/mesnac/common/constant/Constants.java b/common/src/main/java/com/foreverwin/mesnac/common/constant/Constants.java index 6e0c84f9..468d8fb6 100644 --- a/common/src/main/java/com/foreverwin/mesnac/common/constant/Constants.java +++ b/common/src/main/java/com/foreverwin/mesnac/common/constant/Constants.java @@ -177,6 +177,8 @@ public interface Constants { // 余料标签 String PRINT_TYPE_EXM = "EXM"; + // 成品标签 + String PRINT_TYPE_PRODUCT = "PRODUCT"; /** * 刀具状态,Y-使用,N-报废/删除 */ diff --git a/common/src/main/java/com/foreverwin/mesnac/common/dto/LabelPrintDto.java b/common/src/main/java/com/foreverwin/mesnac/common/dto/LabelPrintDto.java index 4c084ac3..9a63900e 100644 --- a/common/src/main/java/com/foreverwin/mesnac/common/dto/LabelPrintDto.java +++ b/common/src/main/java/com/foreverwin/mesnac/common/dto/LabelPrintDto.java @@ -29,6 +29,7 @@ public class LabelPrintDto implements Serializable { private String label; //在制品标签参数 + private String shopOrder; //工作指令 private String workOrder; //图纸版本号 @@ -44,6 +45,14 @@ public class LabelPrintDto implements Serializable { //打印张数 private Integer printNum; + public String getShopOrder() { + return shopOrder; + } + + public void setShopOrder(String shopOrder) { + this.shopOrder = shopOrder; + } + public String getSite() { return site; } diff --git a/common/src/main/java/com/foreverwin/mesnac/common/service/impl/InspectionTaskServiceImpl.java b/common/src/main/java/com/foreverwin/mesnac/common/service/impl/InspectionTaskServiceImpl.java index 0bbf7397..91ecd55f 100644 --- a/common/src/main/java/com/foreverwin/mesnac/common/service/impl/InspectionTaskServiceImpl.java +++ b/common/src/main/java/com/foreverwin/mesnac/common/service/impl/InspectionTaskServiceImpl.java @@ -287,8 +287,8 @@ public class InspectionTaskServiceImpl extends ServiceImpl @@ -68,6 +68,7 @@ public class ProdReadyTaskServiceImpl extends ServiceImpl printLogList = printLogService.list(queryWrapper); if (printLogList.isEmpty()) { //打印参数 LabelPrintDto labelPrintDto = new LabelPrintDto(); labelPrintDto.setPrinter(printName); - labelPrintDto.setPrintTemplate(Constants.PRINT_TYPE_SFC); + labelPrintDto.setPrintTemplate(type); + labelPrintDto.setShopOrder(shopOrder); labelPrintDto.setItem(selectCurrent.getItem()); labelPrintDto.setItemDescription(selectCurrent.getDescription()); labelPrintDto.setSfc(prodReadyTask.getSfc()); @@ -482,16 +490,15 @@ public class ProdReadyTaskServiceImpl extends ServiceImpl frontPage, SfcDispatch sfcDispatch){ + IPage result; + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.setEntity(sfcDispatch); + sfcDispatch.setSite(CommonMethods.getSite()); + if (frontPage.getGlobalQuery() != null && !"".equals(frontPage.getGlobalQuery().trim())) { + //TODO modify global query + queryWrapper.lambda().and(wrapper -> wrapper + .or().like(SfcDispatch::getShopOrder, frontPage.getGlobalQuery()) + .or().like(SfcDispatch::getSfc, frontPage.getGlobalQuery()) + .or().like(SfcDispatch::getDispatchNo, frontPage.getGlobalQuery()) + .or().like(SfcDispatch::getDispatchStatus, frontPage.getGlobalQuery()) + ); + } + result = sfcDispatchService.page(frontPage.getPagePlus(), queryWrapper); + return R.ok(result); + } @PostMapping("/gantt-list") public R ganttList(@RequestBody SfcDispatchDto sfcDispatchDto) { Map result = new HashMap<>(); diff --git a/production/src/main/java/com/foreverwin/mesnac/production/controller/SfcScrapController.java b/production/src/main/java/com/foreverwin/mesnac/production/controller/SfcScrapController.java index 907a4fda..eb582857 100644 --- a/production/src/main/java/com/foreverwin/mesnac/production/controller/SfcScrapController.java +++ b/production/src/main/java/com/foreverwin/mesnac/production/controller/SfcScrapController.java @@ -139,7 +139,12 @@ public class SfcScrapController { */ @GetMapping("/getScrapDtoBysfc") public R getScrapDtoBysfc(String site,String sfc){ - return R.ok(anomalyService.getScrapDtoBysfc(site,sfc)); + try{ + return R.ok(anomalyService.getScrapDtoBysfc(site,sfc)); + }catch (Exception e){ + return R.failed("产品报废检索报错"+e.getMessage()); + } + } /** diff --git a/production/src/main/java/com/foreverwin/mesnac/production/service/impl/SplitSfcServiceImpl.java b/production/src/main/java/com/foreverwin/mesnac/production/service/impl/SplitSfcServiceImpl.java index 77191d48..f9a4ab44 100644 --- a/production/src/main/java/com/foreverwin/mesnac/production/service/impl/SplitSfcServiceImpl.java +++ b/production/src/main/java/com/foreverwin/mesnac/production/service/impl/SplitSfcServiceImpl.java @@ -10,7 +10,6 @@ import com.foreverwin.mesnac.common.util.StringUtil; import com.foreverwin.mesnac.meapi.dto.RouterStepDto; import com.foreverwin.mesnac.meapi.dto.SfcDto; import com.foreverwin.mesnac.meapi.model.Router; -import com.foreverwin.mesnac.meapi.model.WorkCenter; import com.foreverwin.mesnac.meapi.service.RouterService; import com.foreverwin.mesnac.meapi.service.RouterStepService; import com.foreverwin.mesnac.meapi.service.ShopOrderService; @@ -22,7 +21,6 @@ import com.foreverwin.mesnac.production.model.SplitSfc; import com.foreverwin.mesnac.production.model.StepOperation; import com.foreverwin.mesnac.production.service.SplitSfcService; import com.foreverwin.modular.core.exception.BaseException; -import com.foreverwin.modular.core.exception.BusinessException; import com.foreverwin.modular.core.meext.MEServices; import com.foreverwin.modular.core.util.CommonMethods; import com.foreverwin.modular.core.util.FrontPage; @@ -159,19 +157,8 @@ public class SplitSfcServiceImpl extends ServiceImpl i splitSfc.setCreateUser(CommonMethods.getUser()); splitSfc.setCreatedDateTime(LocalDateTime.now()); save(splitSfc); - String workCenter = null; - if (operation.contains("_")) { - workCenter = operation.split("_")[0]; - } else { - workCenter = operation; - } - String workCenterBo = HandleEnum.WORK_CENTER.getHandle(site, workCenter); - WorkCenter workCenterModel = workCenterService.getById(workCenterBo); - if (workCenterModel == null) { - throw BusinessException.build("生产车间【" +workCenter+ "】不存在"); - } Router routerBySfcBo = routerService.getRouterBySfcBo(HandleEnum.SFC.getHandle(site, sfc)); - sfcDispatchCommonService.saveSfcDispatch(site,CommonMethods.getUser(),workCenter,newSfc, sfcData.getShopOrder(),routerBySfcBo.getHandle()); + sfcDispatchCommonService.saveSfcDispatch(site,CommonMethods.getUser(),null,newSfc, sfcData.getShopOrder(),routerBySfcBo.getHandle()); return splitSfc; } catch (Exception e) { ExceptionUtil.throwException(e); @@ -257,23 +244,11 @@ public class SplitSfcServiceImpl extends ServiceImpl i dispositionSfcsRequest.setDispositionSelection(dispositionSelection); dispositionSfcsRequest.setProdCtx(new ProductionContext()); ncProductionService.dispositionMultipleSfcs(dispositionSfcsRequest); - String workCenter; - List routerOperationByRouterBo = routerStepService.findRouterOperationByRouterBo(site, routerBo); + List routerOperationByRouterBo = routerStepService.findRouterOperationByRouterBo(site, maxRevisionRouter.getHandle()); if (routerOperationByRouterBo.isEmpty()){ throw new BaseException("处置工艺路线没有步骤"); } - String routerOperation = routerOperationByRouterBo.get(0).getOperation(); - if (routerOperation.contains("_")) { - workCenter = routerOperation.split("_")[0]; - } else { - workCenter = routerOperation; - } - String workCenterBo = HandleEnum.WORK_CENTER.getHandle(site, workCenter); - WorkCenter workCenterModel = workCenterService.getById(workCenterBo); - if (workCenterModel == null) { - throw BusinessException.build("生产车间【" +workCenter+ "】不存在"); - } - sfcDispatchCommonService.saveSfcDispatch(site,CommonMethods.getUser(),workCenter,newSfc, sfcData.getShopOrder(),maxRevisionRouter.getHandle()); + sfcDispatchCommonService.saveSfcDispatch(site,CommonMethods.getUser(),null,newSfc, sfcData.getShopOrder(),maxRevisionRouter.getHandle()); } SplitSfc splitSfc=new SplitSfc(); splitSfc.setHandle(HandleEnum.SPLIT_SFC.getHandle(site,newSfc)); diff --git a/quality/src/main/java/com/foreverwin/mesnac/quality/service/impl/InspectionTaskManageServiceImpl.java b/quality/src/main/java/com/foreverwin/mesnac/quality/service/impl/InspectionTaskManageServiceImpl.java index 2bfdee69..bf7588fa 100644 --- a/quality/src/main/java/com/foreverwin/mesnac/quality/service/impl/InspectionTaskManageServiceImpl.java +++ b/quality/src/main/java/com/foreverwin/mesnac/quality/service/impl/InspectionTaskManageServiceImpl.java @@ -116,7 +116,7 @@ public class InspectionTaskManageServiceImpl implements InspectionTaskManageServ } List inspectionItemDetailList = this.getInspectionTaskDetail(HandleEnum.INSPECTION_TASK.getHandle(taskNo)); - if (inspectionItemDetailList != null || inspectionItemDetailList.size() > 0) { + if (inspectionItemDetailList != null && inspectionItemDetailList.size() > 0) { throw BusinessException.build("检验任务:"+taskNo+"有检验项目,不允许执行合格操作"); }