From b5a63b29313463d1c2fd1b5678a2d6b2bb8a7044 Mon Sep 17 00:00:00 2001 From: jiaosong <jiaosong6760@dingtalk.com> Date: 星期五, 18 八月 2023 19:33:49 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/master' --- server/src/main/java/doumeemes/service/ext/impl/WorkorderRecordStandardServiceImpl.java | 55 +++++++++++++++++++++++++++++++++++++++++++++---------- 1 files changed, 45 insertions(+), 10 deletions(-) diff --git a/server/src/main/java/doumeemes/service/ext/impl/WorkorderRecordStandardServiceImpl.java b/server/src/main/java/doumeemes/service/ext/impl/WorkorderRecordStandardServiceImpl.java index 78f12c7..f408243 100644 --- a/server/src/main/java/doumeemes/service/ext/impl/WorkorderRecordStandardServiceImpl.java +++ b/server/src/main/java/doumeemes/service/ext/impl/WorkorderRecordStandardServiceImpl.java @@ -87,6 +87,8 @@ private DeviceExtMapper deviceExtMapper; @Autowired private UnqualifiedRecordMapper unqualifiedRecordMapper; + @Autowired + private CompanyUserExtMapper companyUserExtMapper; @Transactional(rollbackFor = {BusinessException.class,Exception.class}) @Override @@ -185,6 +187,7 @@ } if(!Constants.equalsInteger(mp.getStatus(),Constants.WORKORDER_STATUS.create) && !Constants.equalsInteger(mp.getStatus(),Constants.WORKORDER_STATUS.material) + && !Constants.equalsInteger(mp.getStatus(),Constants.WORKORDER_STATUS.producing) && !Constants.equalsInteger(mp.getStatus(),Constants.WORKORDER_STATUS.check) && !Constants.equalsInteger(mp.getStatus(),Constants.WORKORDER_STATUS.done)){ throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "瀵逛笉璧凤紝璇ュ伐鍗曠姸鎬佸凡娴佽浆锛屼笉鑳借繘琛岃鎿嶄綔锛�"); @@ -300,7 +303,7 @@ wrModel.setType(Constants.WORKORDER_RECORD_TYPE.materail); wrModel.setFactoryId(mp.getFactoryId()); wrModel.setProcedureId(mp.getProcedureId()); - wrModel.setBatch(mp.getBatch()); + wrModel.setBatch(wStock.getBatch()); wrModel.setUnitId(mp.getUnitId()); wrModel.setPlanId(mp.getPlanId()); //TODO 鐩墠浣跨敤宸ヨ涓婚敭瀛樺偍璐т綅涓婚敭 @@ -519,10 +522,27 @@ if(mp== null){ throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(), "瀵逛笉璧凤紝璇ヨ褰曚笉瀛樺湪锛�"); } - + Plans plans = plansExtMapper.selectById(mp.getPlanId()); + if(Objects.isNull(plans)){ + throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(), "瀵逛笉璧凤紝宸ュ簭璁″垝璁板綍涓嶅瓨鍦紒"); + } + //鏌ヨ宸ュ簭璁″垝涓� 鎵�鏈夊伐鍗曞凡鎶ュ伐鏁伴噺 + QueryWorkorderExtDTO dto = new QueryWorkorderExtDTO(); + dto.setPlanId(mp.getPlanId()); + dto.setDeleted(Constants.ZERO); + dto.setStatus(Constants.WORKORDER_STATUS.baogong); + List<WorkorderExtListVO> workorderList = workorderExtMapper.selectList(dto); + Integer plansQualifiedNum = 0 , plansUnQualifiedNum = 0; + plansQualifiedNum = workorderList.stream().map( workorderExtListVO -> workorderExtListVO.getQualifiedNum()).reduce(Constants.ZERO, Integer::sum); + plansUnQualifiedNum = workorderList.stream().map( workorderExtListVO -> workorderExtListVO.getUnqualifiedNum()).reduce(Constants.ZERO, Integer::sum); + if((BigDecimal.valueOf(plansQualifiedNum).add(BigDecimal.valueOf(plansUnQualifiedNum).add(autoWorkReportDTO.getCreateWorkorderRecordDTO().getUnQualifiedNum()) + .add(autoWorkReportDTO.getCreateWorkorderRecordDTO().getQualifiedNum()))).compareTo(BigDecimal.valueOf(plans.getNum()))>Constants.ZERO){ + throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "瀵逛笉璧凤紝鎶ュ伐鏁伴噺瓒呭嚭宸ュ簭璁″垝鎬绘暟锛�"); + } Workorder param = new Workorder(); param.setPlanId(mp.getPlanId()); + param.setId(autoWorkReportDTO.getCreateWorkorderRecordDTO().getWorkorderId()); if(Constants.equalsInteger(mp.getPaused(),Constants.ONE)){ throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "瀵逛笉璧凤紝宸ュ崟宸叉殏鍋滐紒"); } @@ -541,13 +561,13 @@ List<Appliances> updateApplianceProList = new ArrayList<>(); //寰呮洿鏂板簱瀛橀泦鍚� List<WStock> stockList = new ArrayList<>(); + //澶勭悊浜у嚭鏁版嵁 + WorkorderRecord workorderRecord = this.createWorkorderRecord(autoWorkReportDTO.getCreateWorkorderRecordDTO(),user,null); //鏌ヨ鎶曟枡鍜屾姤宸ヨ褰曞垪琛� List<WorkorderRecordExtListVO> allRecordList = workorderRecordExtMapper.selectAllList(getQueryRecordParam(param)); if(Objects.isNull(allRecordList)||allRecordList.size()==Constants.ZERO){ throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"鏈煡璇㈡姇鏂欏拰鎶ュ伐璁板綍!"); } - //澶勭悊浜у嚭鏁版嵁 - WorkorderRecord workorderRecord = this.createWorkorderRecord(autoWorkReportDTO.getCreateWorkorderRecordDTO(),user); //妫�鏌ユ暟鎹俊鎭� // caculateCheckRecord(user, mp,allRecordList); QueryBomDetailExtDTO bdparam = initBomParam(user,mp); @@ -572,6 +592,8 @@ } } //鏇存柊宸ュ崟鐘舵�佷负宸叉姤宸� + mp.setUnqualifiedNum(autoWorkReportDTO.getCreateWorkorderRecordDTO().getUnQualifiedNum().intValue()); + mp.setQualifiedNum(autoWorkReportDTO.getCreateWorkorderRecordDTO().getQualifiedNum().intValue()); updateOrderInfo(user,mp,Constants.WORKORDER_HISTORY_STATUS.baogong); //鎵归噺鎻掑叆鍑哄叆搴撴槑缁嗚褰� @@ -1120,7 +1142,7 @@ //濡傛灉鏄骇鍑� mp.setHasProduceNum(Constants.formatBigdecimal(tModel.getNum()).intValue()+Constants.formatIntegerNum(mp.getHasProduceNum())); //浜у嚭鍚堟牸 - this.createOutDetail(user,outbound,mp,tModel,Constants.ZERO,detailList,stockList); + this.createOutDetail(user,outbound,mp,tModel,Constants.ZERO,detailList,stockList); //浜у嚭涓嶈壇 this.createOutDetail(user,outbound,mp,tModel,Constants.ONE,detailList,stockList); } @@ -1154,6 +1176,9 @@ detail.setWarehouseId(outbound.getWarehouseId()); detail.setLocationId(mp.getFinishWarehouseLocationId()); detail.setNum(BigDecimal.valueOf(doneType.equals(Constants.ZERO)?tModel.getQualifiedNum():tModel.getUnqualifiedNum())); + if(detail.getNum().compareTo(BigDecimal.ZERO)==Constants.ZERO){ + return; + } detail.setStatus(Constants.ONE); detail.setDoneNum(detail.getNum()); detail.setDoneDate(new Date()); @@ -1472,7 +1497,7 @@ @Override @Transactional(rollbackFor = {BusinessException.class,Exception.class}) - public WorkorderRecord createWorkorderRecord(CreateWorkorderRecordDTO createWorkorderRecordDTO, LoginUserInfo loginUserInfo){ + public WorkorderRecord createWorkorderRecord(CreateWorkorderRecordDTO createWorkorderRecordDTO, LoginUserInfo loginUserInfo ,Integer userId){ Workorder workorder = workorderExtMapper.selectById(createWorkorderRecordDTO.getWorkorderId()); if(Objects.isNull(workorder)){ throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "瀵逛笉璧凤紝鏈煡璇㈠埌璇ュ伐鍗曚俊鎭紒"); @@ -1501,11 +1526,21 @@ //鏁版嵁瀛樺偍 workorderRecord = new WorkorderRecord(); workorderRecord.setDeleted(Constants.ZERO); - workorderRecord.setCreateUser(loginUserInfo.getId()); + if(!Objects.isNull(userId)){ + CompanyUser companyUser = companyUserExtMapper.selectById(userId); + if(Objects.isNull(companyUser)){ + throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "瀵逛笉璧凤紝鏈煡璇㈠埌鐢熶骇浜哄憳瀵瑰簲浼佷笟鐢ㄦ埛淇℃伅锛�"); + } + workorderRecord.setCreateUser(companyUser.getUserId()); + workorderRecord.setRootDepartId(companyUser.getRootDepartId()); + workorderRecord.setDepartId(companyUser.getComDepartId()); + }else{ + workorderRecord.setCreateUser(loginUserInfo.getId()); + workorderRecord.setRootDepartId(loginUserInfo.getRootDepartment().getId()); + workorderRecord.setDepartId(loginUserInfo.getCurComDepartment().getId()); + } workorderRecord.setCreateTime(new Date()); workorderRecord.setNum(num); - workorderRecord.setRootDepartId(loginUserInfo.getRootDepartment().getId()); - workorderRecord.setDepartId(loginUserInfo.getCurComDepartment().getId()); workorderRecord.setPlanId(workorder.getPlanId()); workorderRecord.setWorkorderId(createWorkorderRecordDTO.getWorkorderId()); workorderRecord.setBatch(workorder.getBatch()); @@ -1521,7 +1556,7 @@ //璁$畻宸ヨ祫淇℃伅 SalaryParam salaryParam = salaryParamMapper.selectOne(new QueryWrapper<SalaryParam>().eq("DELETED",Constants.ZERO).eq("MATERIAL_ID",workorderRecord.getMaterialId()) .eq("DEPART_ID",workorderRecord.getFactoryId()).eq("PROCEDURE_ID",workorderRecord.getProcedureId()).last(" limit 1 ")); - if(!Objects.isNull(salaryParam)){ + if(!Objects.isNull(salaryParam)&&!Objects.isNull(createWorkorderRecordDTO.getDuration())){ workorderRecord.setSalaryPrice(salaryParam.getSalary()); workorderRecord.setSalaryType(salaryParam.getType()); workorderRecord.setSalaryUnqualified(salaryParam.getUnqualified()); -- Gitblit v1.9.3