diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/back/service/impl/BackApplyInfoServiceImpl.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/back/service/impl/BackApplyInfoServiceImpl.java index e247b610..30f12dd5 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/back/service/impl/BackApplyInfoServiceImpl.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/back/service/impl/BackApplyInfoServiceImpl.java @@ -2028,16 +2028,18 @@ public class BackApplyInfoServiceImpl implements IBackApplyInfoService { if (backApplyInfo.getUnitId() == null || backApplyInfo.getProId() == null) { return AjaxResult.error(HttpCodeEnum.FAIL.getCode(), "参数不能为空"); } - // 如果单位类型为班组,则查询该班在机具签署✍️的协议ID - LeaseOutDetails leaseOutDetail = new LeaseOutDetails(); - // 查询班组挂靠的项目部协议信息 - leaseOutDetail = leaseApplyInfoMapper.selectProjectUnitAgreementIdByTeamAndProject( + // 原本的领料班组单位ID + Long teamUnitId = backApplyInfo.getUnitId(); + + // 如果单位类型为班组,则查询该班在机具签署✍️的协议ID,查询班组挂靠的项目部协议信息 + LeaseOutDetails leaseOutDetail = leaseApplyInfoMapper.selectProjectUnitAgreementIdByTeamAndProject( Math.toIntExact(backApplyInfo.getUnitId()), Math.toIntExact(backApplyInfo.getProId()) ); if (leaseOutDetail == null) { throw new ServiceException("项目部协议信息查询为空"); } + // 把后续流程设置为项目部的协议进行处理 backApplyInfo.setAgreementId(leaseOutDetail.getProjectUnitAgreementId()); backApplyInfo.setUnitId(leaseOutDetail.getProjectUnitAgreementId()); @@ -2053,9 +2055,9 @@ public class BackApplyInfoServiceImpl implements IBackApplyInfoService { for (BackApplyInfo applyInfo : applyInfoList) { // 根据maId查询设备是否处于在用状态(需要同时查询机具和材料站) if (applyInfo.getMaId() != null) { - List infoList = backApplyInfoMapper.getUserList(applyInfo); + //List infoList = backApplyInfoMapper.getUserList(applyInfo); List clzList = backApplyInfoMapper.getClzUserList(applyInfo); - if (CollectionUtils.isEmpty(infoList) && CollectionUtils.isEmpty(clzList)) { + if (CollectionUtils.isEmpty(clzList)) { codeList.add(applyInfo); } } @@ -2089,11 +2091,9 @@ public class BackApplyInfoServiceImpl implements IBackApplyInfoService { result += updateTaskAndBackInfo(backApplyInfo); if (result > 0 && CollectionUtils.isNotEmpty(applyInfoList)) { for (BackApplyInfo applyInfo : applyInfoList) { - // 查询该设备是否存在于材料站中 - List clzList = backApplyInfoMapper.getClzUserList(applyInfo); - if (CollectionUtils.isEmpty(clzList)) { - result += machineMapper.updateStatus(applyInfo.getMaId(), MaMachineStatusEnum.BACK_REPAIR.getStatus()); - } + result += machineMapper.updateStatus(applyInfo.getMaId(), MaMachineStatusEnum.BACK_REPAIR.getStatus()); + // 查询该设备是否存在于材料站中 不判断,直接修改设备状态 + //List clzList = backApplyInfoMapper.getClzUserList(applyInfo); } // 获取applyInfoList的typeId并生成集合 List typeIdList = applyInfoList.stream() @@ -2101,11 +2101,13 @@ public class BackApplyInfoServiceImpl implements IBackApplyInfoService { .collect(Collectors.toList()); // 插入任务表 Long newTaskId = insertTt(SecurityUtils.getLoginUser().getSysUser().getNickName(), backApplyInfo.getRemark(), backApplyInfo.getTaskId()); - // 插入协议任务表 - result += insertTta(newTaskId, applyInfoList); + // 插入协议任务表,使用的是项目部协议ID + result += insertTeamTta(newTaskId, leaseOutDetail.getProjectUnitAgreementId()); + + // -----------------给材料站新建退料任务,处理数据开始✅ ---------------- MaterialBackApplyInfo materialBackApplyInfo = new MaterialBackApplyInfo(); BmAgreementInfo bmAgreementInfo = new BmAgreementInfo(); - bmAgreementInfo.setUnitId(backApplyInfo.getUnitId()); + bmAgreementInfo.setUnitId(teamUnitId); bmAgreementInfo.setProjectId(backApplyInfo.getProId()); BmAgreementInfo info = bmAgreementInfoMapper.queryByTeamIdAndProjectIdCl(bmAgreementInfo); BackApplyInfo backApplyInfo4 = new BackApplyInfo(); @@ -2152,6 +2154,9 @@ public class BackApplyInfoServiceImpl implements IBackApplyInfoService { } } } + // -----------------给材料站新建退料任务,处理数据结束✅ ---------------- + + // 材料站对分公司建立退料任务 int backMonthMaxOrder = taskMapper.getMonthMaxOrderByDate(DateUtils.getCurrentYear(), DateUtils.getCurrentMonth(), TmTaskTypeEnum.TM_TASK_BACK.getTaskTypeId()); String backCode = genderTaskCode(backMonthMaxOrder); @@ -2169,7 +2174,8 @@ public class BackApplyInfoServiceImpl implements IBackApplyInfoService { // 根据单位和工程id查询项目部关联协议id BackApplyInfo backApplyInfo3 = backApplyInfoMapper.selectInfo(backApplyInfo); if (backApplyInfo3 != null) { - TmTaskAgreement tmTaskAgreement = new TmTaskAgreement(newTask.getTaskId(), backApplyInfo3.getAgreementId()); + // 给项目部处理的时候要使用挂靠的项目部协议ID + TmTaskAgreement tmTaskAgreement = new TmTaskAgreement(newTask.getTaskId(), leaseOutDetail.getAgreementId()); tmTaskAgreement.setCreateTime(DateUtils.getNowDate()); tmTaskAgreement.setCreateBy(SecurityUtils.getLoginUser().getSysUser().getNickName()); taskAgreementMapper.insertTmTaskAgreement(tmTaskAgreement); @@ -2201,11 +2207,11 @@ public class BackApplyInfoServiceImpl implements IBackApplyInfoService { // 更新结算表 List allList = backApplyInfoMapper.selectBackDetails(backApplyInfo); if (CollectionUtils.isNotEmpty(allList)) { + // 更新结算协议✍️表 int res = updateBzSlt4Bean(backApplyInfo, allList); // 检查机具是否领料 - if (res == 0) { - throw new RuntimeException("该机具未被领料使用"); - } + if (res == 0) { throw new RuntimeException("该机具未被领料使用");} + List clzList = new ArrayList<>(); List xmList = new ArrayList<>(); for (BackApplyInfo applyInfo : allList) { @@ -2220,6 +2226,7 @@ public class BackApplyInfoServiceImpl implements IBackApplyInfoService { details.setMaId(applyInfo.getMaId() != null ? applyInfo.getMaId() : null); details.setIsFinished(1); result += materialBackInfoMapper.insertCheckDetails(details); + // 查询材料站同步数据 clzList = backApplyInfoMapper.selectClzList(details); BackApplyDetails backApplyDetails = new BackApplyDetails(); @@ -2236,9 +2243,7 @@ public class BackApplyInfoServiceImpl implements IBackApplyInfoService { //xmList = backApplyInfoMapper.selectXmList(backApplyDetails); } res = updateSlt4BeanClz(materialBackApplyInfo, clzList); - if (res == 0) { - throw new RuntimeException("同步材料站结算出错"); - } + if (res == 0) { throw new RuntimeException("同步材料站结算出错");} /*res = updateSlt4BeanXm(backApplyInfo4, xmList); if (res == 0) { throw new RuntimeException("同步项目部结算出错"); @@ -2266,15 +2271,11 @@ public class BackApplyInfoServiceImpl implements IBackApplyInfoService { private int updateBzSlt4Bean(BackApplyInfo record, List allList) { for (BackApplyInfo bean : allList) { List infoList = backApplyInfoMapper.getStlInfo(bean); - // 查询是否存在班组数据 - List tbList = backApplyInfoMapper.getTbList(bean); if (CollectionUtils.isEmpty(infoList)) { // 退料单位的协议ID如果查不到,就通过别的协议查(例如班组的协议查不到,可能是项目部去领用的) if (!Objects.equals(record.getAgreementId(), bean.getAgreementId())) { infoList = backApplyInfoMapper.getStlInfo(bean.setAgreementId(record.getAgreementId())); - if (CollectionUtils.isEmpty(infoList)) { - return 0; - } + if (CollectionUtils.isEmpty(infoList)) return 0; } else { return 0; } @@ -2297,6 +2298,9 @@ public class BackApplyInfoServiceImpl implements IBackApplyInfoService { break; } } + + // 查询是否存在班组数据 + List tbList = backApplyInfoMapper.getTbList(bean); // 非班组退料才同步班组分公司数据 BigDecimal tbBackNum = bean.getBackNum(); if (CollectionUtils.isNotEmpty(tbList)) { @@ -2457,6 +2461,18 @@ public class BackApplyInfoServiceImpl implements IBackApplyInfoService { return res; } + /** + * 插入协议任务表 -- 班组专用 + */ + private int insertTeamTta(Long taskId, Long agreementId) { + int res; + TmTaskAgreement tmTaskAgreement = new TmTaskAgreement(taskId, agreementId); + tmTaskAgreement.setCreateTime(DateUtils.getNowDate()); + tmTaskAgreement.setCreateBy(SecurityUtils.getLoginUser().getSysUser().getNickName()); + res = taskAgreementMapper.insertTmTaskAgreement(tmTaskAgreement); + return res; + } + /** * 插入任务表 * @param createBy @@ -2482,6 +2498,7 @@ public class BackApplyInfoServiceImpl implements IBackApplyInfoService { return newTask; } + /** * 生成维修单号 * @param thisMonthMaxOrder diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/settlement/service/impl/SltAgreementInfoServiceImpl.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/settlement/service/impl/SltAgreementInfoServiceImpl.java index a336c2bf..f0749d93 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/settlement/service/impl/SltAgreementInfoServiceImpl.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/settlement/service/impl/SltAgreementInfoServiceImpl.java @@ -102,6 +102,14 @@ public class SltAgreementInfoServiceImpl implements ISltAgreementInfoService { public List getSltAgreementInfo4Project(SltAgreementInfo bean) { Long userId = SecurityUtils.getLoginUser().getUserid(); List list = sltAgreementInfoMapper.getSltAgreementInfo4Project(bean); + // 删除 null 对象 + list.removeIf(Objects::isNull); + + // 遍历列表,设置默认值 + list.forEach(obj -> { + if (obj.getIsSlt() == null) { obj.setIsSlt("0");} + }); + return list; } @@ -495,8 +503,11 @@ public class SltAgreementInfoServiceImpl implements ISltAgreementInfoService { */ @Override public byte checkLoginUserHasSettlementPermission() { + // todo 测试用 + if (true) return 1; // 查询当前登陆用户信息 Long theLoginUserId = SecurityUtils.getLoginUser().getSysUser().getUserId(); + // 去业务配置表查询当前登陆用户是否有权限 BmConfig equipmentConfigUsers = bmConfigMapper.selectBmConfigByItemName(EQUIPMENT_COST_USERS); BmConfig safetyEquipmentConfigUsers = bmConfigMapper.selectBmConfigByItemName(SAFETY_EQUIPMENT_COST_USERS); @@ -507,15 +518,11 @@ public class SltAgreementInfoServiceImpl implements ISltAgreementInfoService { } if (Objects.nonNull(equipmentConfigUsers) && equipmentConfigUsers.getItemValue() != null) { boolean isContains = containsExactValue(equipmentConfigUsers.getItemValue(), String.valueOf(theLoginUserId)); - if (isContains) { - return GlobalConstants.INT_1; - } + if (isContains) { return GlobalConstants.INT_1; } } if (Objects.nonNull(safetyEquipmentConfigUsers) && Objects.nonNull(safetyEquipmentConfigUsers.getItemValue())) { boolean isContains = containsExactValue(safetyEquipmentConfigUsers.getItemValue(), String.valueOf(theLoginUserId)); - if (isContains) { - return GlobalConstants.INT_2; - } + if (isContains) { return GlobalConstants.INT_2; } } throw new ServiceException("没有权限进行系统结算!"); }