diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/controller/MaterialBackApplyInfoController.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/controller/MaterialBackApplyInfoController.java index 8e175d42..4f622370 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/controller/MaterialBackApplyInfoController.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/controller/MaterialBackApplyInfoController.java @@ -252,4 +252,15 @@ public class MaterialBackApplyInfoController extends BaseController { return error("系统错误, " + e.getMessage()); } } + + /** + * app编码检索 + * @param dto + * @return + */ + @ApiOperation(value = "app编码检索") + @GetMapping("/getMachine") + public AjaxResult getMachine(MaterialBackApplyInfo dto) { + return materialBackApplyInfoService.getMachine(dto); + } } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/domain/back/MaterialBackApplyInfo.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/domain/back/MaterialBackApplyInfo.java index df986cc9..328c8a17 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/domain/back/MaterialBackApplyInfo.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/domain/back/MaterialBackApplyInfo.java @@ -186,4 +186,7 @@ public class MaterialBackApplyInfo implements Serializable { @ApiModelProperty(value = "i8工程id") private String externalId; + + @ApiModelProperty(value = "实施单位id") + private String impUnit; } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/domain/back/MaterialBackApplyTotalInfo.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/domain/back/MaterialBackApplyTotalInfo.java index fe446e2c..9133babe 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/domain/back/MaterialBackApplyTotalInfo.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/domain/back/MaterialBackApplyTotalInfo.java @@ -150,4 +150,10 @@ public class MaterialBackApplyTotalInfo implements Serializable { @ApiModelProperty(value = "i8工程id") private String externalId; + @ApiModelProperty(value = "身份证号码") + private String idCard; + + @ApiModelProperty(value = "实施单位id") + private String impUnit; + } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/domain/lease/LeaseApplyDetailsInfo.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/domain/lease/LeaseApplyDetailsInfo.java index 1a18b765..668a5c28 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/domain/lease/LeaseApplyDetailsInfo.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/domain/lease/LeaseApplyDetailsInfo.java @@ -149,4 +149,13 @@ public class LeaseApplyDetailsInfo extends BaseEntity { @ApiModelProperty(value = "结束时间") private String endTime; + + @ApiModelProperty(value = "身份证号码") + private String idCard; + + @ApiModelProperty(value = "i8工程id") + private String externalId; + + @ApiModelProperty(value = "实施单位id") + private String impUnit; } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/domain/lease/MaterialLeaseApplyInfo.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/domain/lease/MaterialLeaseApplyInfo.java index 4b4059b8..ef51b4fb 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/domain/lease/MaterialLeaseApplyInfo.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/domain/lease/MaterialLeaseApplyInfo.java @@ -287,4 +287,7 @@ public class MaterialLeaseApplyInfo extends BaseEntity { @ApiModelProperty(value = "项目部id") private Long departId; + + @ApiModelProperty(value = "实施单位id") + private String impUnit; } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/domain/vo/MaterialRetainedEquipmentInfo.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/domain/vo/MaterialRetainedEquipmentInfo.java index 7b063e58..164e916e 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/domain/vo/MaterialRetainedEquipmentInfo.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/domain/vo/MaterialRetainedEquipmentInfo.java @@ -208,4 +208,10 @@ public class MaterialRetainedEquipmentInfo { @ApiModelProperty(value = "i8工程id") private String externalId; + + @ApiModelProperty(value = "身份证号码") + private String idCard; + + @ApiModelProperty(value = "实施单位id") + private String impUnit; } \ No newline at end of file diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/domain/vo/lease/LeaseTotalInfo.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/domain/vo/lease/LeaseTotalInfo.java index 6a70ec92..230da7af 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/domain/vo/lease/LeaseTotalInfo.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/domain/vo/lease/LeaseTotalInfo.java @@ -90,4 +90,10 @@ public class LeaseTotalInfo { @ApiModelProperty(value = "i8工程id") private String externalId; + + @ApiModelProperty(value = "实施单位id") + private String impUnit; + + @ApiModelProperty(value = "身份证号码") + private String idCard; } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/mapper/MaterialBackInfoMapper.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/mapper/MaterialBackInfoMapper.java index 114af807..90a2ef43 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/mapper/MaterialBackInfoMapper.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/mapper/MaterialBackInfoMapper.java @@ -235,4 +235,11 @@ public interface MaterialBackInfoMapper { * @return */ MaterialBackApplyInfo selectByAgreementIdAndTypeId(MaCodeVo maCodeVo); + + /** + * 查询退料任务审核详情 + * @param dto + * @return + */ + List getMachine(MaterialBackApplyInfo dto); } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/mapper/MaterialMachineMapper.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/mapper/MaterialMachineMapper.java index 2809c9a4..b8bf16ab 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/mapper/MaterialMachineMapper.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/mapper/MaterialMachineMapper.java @@ -65,13 +65,6 @@ public interface MaterialMachineMapper { */ BmTeam getTeamData(String username); - /** - * 工器具台账查询 - * @param bmTeam - * @return - */ - List getToolsLedgerListByTeam(BmTeam bmTeam); - /** * 工器具台账查询 * @param bean diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/service/MaterialBackApplyInfoService.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/service/MaterialBackApplyInfoService.java index 98d7a67a..4e88c080 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/service/MaterialBackApplyInfoService.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/service/MaterialBackApplyInfoService.java @@ -113,4 +113,11 @@ public interface MaterialBackApplyInfoService { * @return */ AjaxResult submitBackApply(MaterialBackApplyInfo backApplyInfo); + + /** + * app编码检索 + * @param dto + * @return + */ + AjaxResult getMachine(MaterialBackApplyInfo dto); } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/service/impl/MaterialBackApplyInfoServiceImpl.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/service/impl/MaterialBackApplyInfoServiceImpl.java index 90b5961e..fc133ca8 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/service/impl/MaterialBackApplyInfoServiceImpl.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/service/impl/MaterialBackApplyInfoServiceImpl.java @@ -19,7 +19,8 @@ import com.bonus.material.back.domain.BackApplyInfo; import com.bonus.material.back.domain.MaCodeDto; import com.bonus.material.back.domain.vo.MaCodeVo; import com.bonus.material.basic.mapper.BmFileInfoMapper; -import com.bonus.material.clz.domain.lease.MaterialLeaseApplyInfo; +import com.bonus.material.clz.domain.BmTeam; +import com.bonus.material.clz.mapper.MaterialMachineMapper; import com.bonus.material.common.mapper.SelectMapper; import com.bonus.material.ma.mapper.MachineMapper; import com.bonus.material.clz.domain.back.MaterialBackApplyDetails; @@ -70,6 +71,8 @@ public class MaterialBackApplyInfoServiceImpl implements MaterialBackApplyInfoSe @Resource private SelectMapper mapper; + @Resource + private MaterialMachineMapper materialMachineMapper; /** * 查询退料申请列表 * @param backApplyInfo @@ -83,7 +86,7 @@ public class MaterialBackApplyInfoServiceImpl implements MaterialBackApplyInfoSe return new ArrayList<>(); } String username = SecurityUtils.getLoginUser().getUsername(); - list.removeIf(info -> { + /*list.removeIf(info -> { if (StringUtils.isBlank(info.getExternalId())) { return true; } @@ -93,7 +96,22 @@ public class MaterialBackApplyInfoServiceImpl implements MaterialBackApplyInfoSe } List userNameList = mapper.getUserNameList(i8ProjectInfo); return CollectionUtils.isEmpty(userNameList) || !userNameList.contains(username); - }); + });*/ + Long deptId = SecurityUtils.getLoginUser().getSysUser().getDeptId(); + if (!org.springframework.util.CollectionUtils.isEmpty(list) && deptId != null) { + // 删除元素 + list.removeIf(info -> !deptId.toString().equals(info.getImpUnit())); + } + // 根据用户名判断用户是否为班组长 + BmTeam teamData = materialMachineMapper.getTeamData(username); + if (!org.springframework.util.CollectionUtils.isEmpty(list)) { + if (teamData != null) { + // 将sortedList中班组身份证号与username相同的元素过滤处理 + list = list.stream() + .filter(item -> username.equals(item.getIdCard())) + .collect(Collectors.toList()); + } + } if (!CollectionUtils.isEmpty(list)) { // 提取关键字 String keyWord = backApplyInfo.getKeyWord(); @@ -133,9 +151,10 @@ public class MaterialBackApplyInfoServiceImpl implements MaterialBackApplyInfoSe */ @Override public List getTotalList(MaterialBackApplyInfo backApplyInfo) { + String username = SecurityUtils.getLoginUser().getUsername(); List list = materialBackInfoMapper.getTotalList(backApplyInfo); // 安全过滤数据权限 - if (!CollectionUtils.isEmpty(list)) { + /*if (!CollectionUtils.isEmpty(list)) { String username = SecurityUtils.getLoginUser().getUsername(); list.removeIf(leaseTotalInfo -> { if (StringUtils.isBlank(leaseTotalInfo.getExternalId())) { @@ -148,6 +167,21 @@ public class MaterialBackApplyInfoServiceImpl implements MaterialBackApplyInfoSe List userNameList = mapper.getUserNameList(i8ProjectInfo); return org.springframework.util.CollectionUtils.isEmpty(userNameList) || !userNameList.contains(username); }); + }*/ + Long deptId = SecurityUtils.getLoginUser().getSysUser().getDeptId(); + if (!org.springframework.util.CollectionUtils.isEmpty(list) && deptId != null) { + // 删除元素 + list.removeIf(info -> !deptId.toString().equals(info.getImpUnit())); + } + // 根据用户名判断用户是否为班组长 + BmTeam teamData = materialMachineMapper.getTeamData(username); + if (!org.springframework.util.CollectionUtils.isEmpty(list)) { + if (teamData != null) { + // 将sortedList中班组身份证号与username相同的元素过滤处理 + list = list.stream() + .filter(item -> username.equals(item.getIdCard())) + .collect(Collectors.toList()); + } } if (!CollectionUtils.isEmpty(list)) { // 如果关键字不为空,进行过滤 @@ -472,9 +506,25 @@ public class MaterialBackApplyInfoServiceImpl implements MaterialBackApplyInfoSe */ @Override public List getBackInfoDetails(MaterialBackApplyTotalInfo info) { + String username = SecurityUtils.getLoginUser().getUsername(); BigDecimal backNum = BigDecimal.ZERO.setScale(3, RoundingMode.HALF_UP); List list = materialBackInfoMapper.getBackInfoDetails(info); - if (CollectionUtils.isNotEmpty(list)) { + Long deptId = SecurityUtils.getLoginUser().getSysUser().getDeptId(); + if (!CollectionUtils.isEmpty(list) && deptId != null) { + // 删除元素 + list.removeIf(m -> !deptId.toString().equals(m.getImpUnit())); + } + // 根据用户名判断用户是否为班组长 + BmTeam teamData = materialMachineMapper.getTeamData(username); + if (!org.springframework.util.CollectionUtils.isEmpty(list)) { + if (teamData != null) { + // 将sortedList中班组身份证号与username相同的元素过滤处理 + list = list.stream() + .filter(item -> username.equals(item.getIdCard())) + .collect(Collectors.toList()); + } + } + /*if (CollectionUtils.isNotEmpty(list)) { String username = SecurityUtils.getLoginUser().getUsername(); list.removeIf(b -> { if (StringUtils.isBlank(b.getExternalId())) { @@ -487,7 +537,7 @@ public class MaterialBackApplyInfoServiceImpl implements MaterialBackApplyInfoSe List userNameList = mapper.getUserNameList(i8ProjectInfo); return CollectionUtils.isEmpty(userNameList) || !userNameList.contains(username); }); - } + }*/ if (CollectionUtils.isNotEmpty(list)) { for (MaterialBackApplyTotalInfo backApplyTotalInfo : list) { backNum = backNum.add(backApplyTotalInfo.getBackNum()); @@ -652,6 +702,24 @@ public class MaterialBackApplyInfoServiceImpl implements MaterialBackApplyInfoSe return AjaxResult.error(HttpCodeEnum.FAIL.getCode(), HttpCodeEnum.FAIL.getMsg()); } + /** + * app编码检索 + * @param dto + * @return + */ + @Override + public AjaxResult getMachine(MaterialBackApplyInfo dto) { + //判断输入或者编码识别或者二维码识别是否为领料工程和单位对应 + List list = new ArrayList<>(); + if (dto.getMaCode() != null ||dto.getQrCode() != null) { + list = materialBackInfoMapper.getMachine(dto); + } + if (CollectionUtils.isNotEmpty(list)) { + return AjaxResult.success(list); + } + return AjaxResult.error(HttpCodeEnum.SYSTEM_ERROR.getCode(), "该编码设备非该班组和工程所领"); + } + /** * 完成退料 * @param backApplyInfo diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/service/impl/MaterialLeaseInfoServiceImpl.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/service/impl/MaterialLeaseInfoServiceImpl.java index f8b95212..4f075ca0 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/service/impl/MaterialLeaseInfoServiceImpl.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/service/impl/MaterialLeaseInfoServiceImpl.java @@ -5,12 +5,10 @@ import com.bonus.common.biz.constant.MaterialConstants; import com.bonus.common.biz.domain.BmFileInfo; import com.bonus.common.biz.domain.TypeTreeBuild; import com.bonus.common.biz.domain.TypeTreeNode; -import com.bonus.common.biz.domain.lease.LeaseApplyInfo; import com.bonus.common.biz.domain.lease.LeaseOutDetails; import com.bonus.common.biz.domain.lease.MaterialLeaseMaCodeDto; import com.bonus.common.biz.enums.HttpCodeEnum; import com.bonus.common.biz.enums.LeaseTaskStatusEnum; -import com.bonus.common.biz.enums.MaMachineStatusEnum; import com.bonus.common.biz.enums.TmTaskTypeEnum; import com.bonus.common.core.exception.ServiceException; import com.bonus.common.core.utils.DateUtils; @@ -23,10 +21,11 @@ import com.bonus.material.basic.domain.BmAgreementInfo; import com.bonus.material.basic.domain.BmQrcodeInfo; import com.bonus.material.basic.mapper.BmAgreementInfoMapper; import com.bonus.material.basic.mapper.BmFileInfoMapper; +import com.bonus.material.clz.domain.BmTeam; import com.bonus.material.clz.domain.vo.MaterialMaCodeVo; +import com.bonus.material.clz.mapper.MaterialMachineMapper; import com.bonus.material.common.mapper.SelectMapper; import com.bonus.material.ma.domain.Type; -import com.bonus.material.ma.mapper.MachineMapper; import com.bonus.material.ma.mapper.TypeMapper; import com.bonus.material.clz.domain.lease.LeaseApplyDetailsInfo; import com.bonus.material.clz.domain.lease.LeaseOutDetailsInfo; @@ -82,6 +81,9 @@ public class MaterialLeaseInfoServiceImpl implements MaterialLeaseInfoService { @Resource(name = "SelectMapper") private SelectMapper mapper; + @Resource + private MaterialMachineMapper materialMachineMapper; + /** * 查询领料任务列表 * @@ -90,6 +92,7 @@ public class MaterialLeaseInfoServiceImpl implements MaterialLeaseInfoService { */ @Override public List selectLeaseApplyInfoList(MaterialLeaseApplyInfo leaseApplyInfo) { + String username = SecurityUtils.getLoginUser().getUsername(); List list = materialLeaseInfoMapper.selectLeaseApplyInfoList(leaseApplyInfo); // 利用Stream API进行降序排序 List sortedList = list.stream() @@ -97,7 +100,23 @@ public class MaterialLeaseInfoServiceImpl implements MaterialLeaseInfoService { .collect(Collectors.toList()); // 数据权限划分 - sortedList = filterByDataPermission(sortedList); + //sortedList = filterByDataPermission(sortedList); + // 获取当前用户的deptId + Long deptId = SecurityUtils.getLoginUser().getSysUser().getDeptId(); + if (!CollectionUtils.isEmpty(sortedList) && deptId != null) { + // 删除元素 + sortedList.removeIf(info -> !deptId.toString().equals(info.getImpUnit())); + } + // 根据用户名判断用户是否为班组长 + BmTeam teamData = materialMachineMapper.getTeamData(username); + if (!CollectionUtils.isEmpty(sortedList)) { + if (teamData != null) { + // 将sortedList中班组身份证号与username相同的元素过滤处理 + sortedList = sortedList.stream() + .filter(item -> username.equals(item.getIdCard())) + .collect(Collectors.toList()); + } + } // 处理剩余数据 if (!CollectionUtils.isEmpty(sortedList)) { processLeaseApplyInfo(sortedList); @@ -195,6 +214,7 @@ public class MaterialLeaseInfoServiceImpl implements MaterialLeaseInfoService { */ @Override public List getTotalList(MaterialLeaseApplyInfo leaseApplyInfo) { + String username = SecurityUtils.getLoginUser().getUsername(); // 领料数据 List list = materialLeaseInfoMapper.getTotalList(leaseApplyInfo); // 查询领用数据 @@ -216,9 +236,8 @@ public class MaterialLeaseInfoServiceImpl implements MaterialLeaseInfoService { .sorted(Comparator.comparing(MaterialLeaseApplyInfo::getCreateTime, Comparator.nullsLast(Comparator.naturalOrder())).reversed()) .collect(Collectors.toList()); - // 安全过滤数据权限 - if (!CollectionUtils.isEmpty(sortedList)) { - String username = SecurityUtils.getLoginUser().getUsername(); + // 材料员安全过滤数据权限 + /*if (!CollectionUtils.isEmpty(sortedList)) { sortedList.removeIf(leaseTotalInfo -> { if (StringUtils.isBlank(leaseTotalInfo.getExternalId())) { return true; @@ -230,6 +249,21 @@ public class MaterialLeaseInfoServiceImpl implements MaterialLeaseInfoService { List userNameList = mapper.getUserNameList(i8ProjectInfo); return CollectionUtils.isEmpty(userNameList) || !userNameList.contains(username); }); + }*/ + Long deptId = SecurityUtils.getLoginUser().getSysUser().getDeptId(); + if (!CollectionUtils.isEmpty(sortedList) && deptId != null) { + // 删除元素 + sortedList.removeIf(info -> !deptId.toString().equals(info.getImpUnit())); + } + // 根据用户名判断用户是否为班组长 + BmTeam teamData = materialMachineMapper.getTeamData(username); + if (!CollectionUtils.isEmpty(sortedList)) { + if (teamData != null) { + // 将sortedList中班组身份证号与username相同的元素过滤处理 + sortedList = sortedList.stream() + .filter(item -> username.equals(item.getIdCard())) + .collect(Collectors.toList()); + } } if (!CollectionUtils.isEmpty(sortedList)) { // 如果关键字不为空,进行过滤 @@ -473,10 +507,26 @@ public class MaterialLeaseInfoServiceImpl implements MaterialLeaseInfoService { */ @Override public List getLeaseInfo(LeaseApplyDetailsInfo dto) { + String username = SecurityUtils.getLoginUser().getUsername(); BigDecimal preNum = BigDecimal.ZERO.setScale(3, RoundingMode.HALF_UP); BigDecimal alNum = BigDecimal.ZERO.setScale(3, RoundingMode.HALF_UP); BigDecimal outNum = BigDecimal.ZERO.setScale(3, RoundingMode.HALF_UP); List list = materialLeaseInfoMapper.getLeaseInfo(dto); + Long deptId = SecurityUtils.getLoginUser().getSysUser().getDeptId(); + if (!CollectionUtils.isEmpty(list) && deptId != null) { + // 删除元素 + list.removeIf(info -> !deptId.toString().equals(info.getImpUnit())); + } + // 根据用户名判断用户是否为班组长 + BmTeam teamData = materialMachineMapper.getTeamData(username); + if (!CollectionUtils.isEmpty(list)) { + if (teamData != null) { + // 将list中班组身份证号与username相同的元素过滤处理 + list = list.stream() + .filter(item -> username.equals(item.getIdCard())) + .collect(Collectors.toList()); + } + } if (!CollectionUtils.isEmpty(list)) { String keyWord = dto.getKeyWord(); // 如果关键字不为空,进行过滤 @@ -734,12 +784,7 @@ public class MaterialLeaseInfoServiceImpl implements MaterialLeaseInfoService { List recordList = materialLeaseInfoMapper.getInfoByQrcode(bmQrcodeInfo); String msg = ""; if (CollectionUtil.isNotEmpty(recordList)) { - recordList = recordList.stream().filter(item -> item.getMaStatus().equals(MaMachineStatusEnum.IN_STORE.getStatus().toString())).collect(Collectors.toList()); - if (recordList.size() > 0) { - msg = "监测到" + bmQrcodeInfo.getQrCode() + "符合出库条件,请确认是否出库!"; - } else { - msg = "监测到" + bmQrcodeInfo.getQrCode() + "编码不符合出库条件,请检查后重新提交!"; - } + msg = "监测到" + bmQrcodeInfo.getQrCode() + "符合出库条件,请确认是否出库!"; } else { msg = "监测到" + bmQrcodeInfo.getQrCode() + "编码不符合出库条件,请检查后重新提交!"; } @@ -818,13 +863,13 @@ public class MaterialLeaseInfoServiceImpl implements MaterialLeaseInfoService { */ @Override public List getLeaseInfoDetails(LeaseTotalInfo info) { + String username = SecurityUtils.getLoginUser().getUsername(); BigDecimal preNum = BigDecimal.ZERO.setScale(3, RoundingMode.HALF_UP); BigDecimal outNum = BigDecimal.ZERO.setScale(3, RoundingMode.HALF_UP); BigDecimal pendingNum = BigDecimal.ZERO.setScale(3, RoundingMode.HALF_UP); List list = materialLeaseInfoMapper.getLeaseInfoDetails(info); // 安全过滤数据权限 - if (!CollectionUtils.isEmpty(list)) { - String username = SecurityUtils.getLoginUser().getUsername(); + /*if (!CollectionUtils.isEmpty(list)) { list.removeIf(leaseTotalInfo -> { if (StringUtils.isBlank(leaseTotalInfo.getExternalId())) { return true; @@ -836,6 +881,21 @@ public class MaterialLeaseInfoServiceImpl implements MaterialLeaseInfoService { List userNameList = mapper.getUserNameList(i8ProjectInfo); return CollectionUtils.isEmpty(userNameList) || !userNameList.contains(username); }); + }*/ + Long deptId = SecurityUtils.getLoginUser().getSysUser().getDeptId(); + if (!CollectionUtils.isEmpty(list) && deptId != null) { + // 删除元素 + list.removeIf(m -> !deptId.toString().equals(m.getImpUnit())); + } + // 根据用户名判断用户是否为班组长 + BmTeam teamData = materialMachineMapper.getTeamData(username); + if (!CollectionUtils.isEmpty(list)) { + if (teamData != null) { + // 将list中班组身份证号与username相同的元素过滤处理 + list = list.stream() + .filter(item -> username.equals(item.getIdCard())) + .collect(Collectors.toList()); + } } // 处理数据并计算总和 if (!CollectionUtils.isEmpty(list)) { diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/service/impl/MaterialMachineServiceImpl.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/service/impl/MaterialMachineServiceImpl.java index 6e2c434e..0c860cab 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/service/impl/MaterialMachineServiceImpl.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/service/impl/MaterialMachineServiceImpl.java @@ -96,6 +96,7 @@ public class MaterialMachineServiceImpl implements MaterialMachineService { */ @Override public List getRetainedEquipmentList(MaterialRetainedEquipmentInfo bean) { + String username = SecurityUtils.getLoginUser().getUsername(); BigDecimal totalPrice = BigDecimal.ZERO.setScale(2, RoundingMode.HALF_UP); BigDecimal totalStoreNum = BigDecimal.ZERO.setScale(3, RoundingMode.HALF_UP); BigDecimal totalUsNum = BigDecimal.ZERO.setScale(3, RoundingMode.HALF_UP); @@ -104,7 +105,7 @@ public class MaterialMachineServiceImpl implements MaterialMachineService { BigDecimal totalRepairInputNum = BigDecimal.ZERO.setScale(3, RoundingMode.HALF_UP); BigDecimal totalAllNum = BigDecimal.ZERO.setScale(3, RoundingMode.HALF_UP); List recordList = materialMachineMapper.getRetainedEquipmentList(bean); - if (CollectionUtils.isNotEmpty(recordList)) { + /*if (CollectionUtils.isNotEmpty(recordList)) { String username = SecurityUtils.getLoginUser().getUsername(); recordList.removeIf(info -> { if (com.bonus.common.core.utils.StringUtils.isBlank(info.getExternalId())) { @@ -117,6 +118,21 @@ public class MaterialMachineServiceImpl implements MaterialMachineService { List userNameList = mapper.getUserNameList(i8ProjectInfo); return CollectionUtils.isEmpty(userNameList) || !userNameList.contains(username); }); + }*/ + Long deptId = SecurityUtils.getLoginUser().getSysUser().getDeptId(); + if (!CollectionUtils.isEmpty(recordList) && deptId != null) { + // 删除元素 + recordList.removeIf(m -> !deptId.toString().equals(m.getImpUnit())); + } + // 根据用户名判断用户是否为班组长 + BmTeam teamData = materialMachineMapper.getTeamData(username); + if (!org.springframework.util.CollectionUtils.isEmpty(recordList)) { + if (teamData != null) { + // 将sortedList中班组身份证号与username相同的元素过滤处理 + recordList = recordList.stream() + .filter(item -> username.equals(item.getIdCard())) + .collect(Collectors.toList()); + } } if (CollectionUtils.isNotEmpty(recordList)) { for (MaterialRetainedEquipmentInfo retainedEquipmentInfo : recordList) { @@ -204,7 +220,23 @@ public class MaterialMachineServiceImpl implements MaterialMachineService { */ @Override public List getTeamUseNumList(MaterialRetainedEquipmentInfo bean) { + String username = SecurityUtils.getLoginUser().getUsername(); List list = materialMachineMapper.getTeamUseNumList(bean); + Long deptId = SecurityUtils.getLoginUser().getSysUser().getDeptId(); + if (!CollectionUtils.isEmpty(list) && deptId != null) { + // 删除元素 + list.removeIf(m -> !deptId.toString().equals(m.getImpUnit())); + } + // 根据用户名判断用户是否为班组长 + BmTeam teamData = materialMachineMapper.getTeamData(username); + if (!org.springframework.util.CollectionUtils.isEmpty(list)) { + if (teamData != null) { + // 将sortedList中班组身份证号与username相同的元素过滤处理 + list = list.stream() + .filter(item -> bean.getTeamLeaderIdCard().equals(item.getIdCard())) + .collect(Collectors.toList()); + } + } if (CollectionUtils.isNotEmpty(list)) { for (MaterialRetainedEquipmentInfo retainedEquipmentInfo : list) { MaterialRetainedEquipmentInfo info = new MaterialRetainedEquipmentInfo(); @@ -225,7 +257,23 @@ public class MaterialMachineServiceImpl implements MaterialMachineService { */ @Override public List getTeamWarnDetailsList(MaterialRetainedEquipmentInfo bean) { + String username = SecurityUtils.getLoginUser().getUsername(); List list = materialMachineMapper.getTeamUseNumDetailsList(bean); + Long deptId = SecurityUtils.getLoginUser().getSysUser().getDeptId(); + if (!CollectionUtils.isEmpty(list) && deptId != null) { + // 删除元素 + list.removeIf(m -> !deptId.toString().equals(m.getImpUnit())); + } + // 根据用户名判断用户是否为班组长 + BmTeam teamData = materialMachineMapper.getTeamData(username); + if (!org.springframework.util.CollectionUtils.isEmpty(list)) { + if (teamData != null) { + // 将sortedList中班组身份证号与username相同的元素过滤处理 + list = list.stream() + .filter(item -> bean.getTeamLeaderIdCard().equals(item.getIdCard())) + .collect(Collectors.toList()); + } + } if (!CollectionUtil.isEmpty(list)) { // 将list中manageType为0的数据过滤出来 list = list.stream().filter(item -> "0".equals(item.getManageType())).collect(Collectors.toList()); @@ -277,22 +325,27 @@ public class MaterialMachineServiceImpl implements MaterialMachineService { */ @Override public List getToolsLedgerList(MaterialRetainedEquipmentInfo bean) { + //1、获取当前用户名 + String userName = SecurityUtils.getLoginUser().getUsername(); List list1 =new ArrayList<>(); try { - //1、获取当前用户名 - String userName = SecurityUtils.getLoginUser().getUsername(); - //2、判断用户是否为班组长,且对应的是否有班组 - BmTeam bmTeam = materialMachineMapper.getTeamData(userName); - List list = new ArrayList<>(); - if (bmTeam != null) { - //不为空,则 是班组长且对应的有班组 - //查询班组下工器具库存 - list = materialMachineMapper.getToolsLedgerListByTeam(bmTeam); - } else { - //没有班组,则查全部 - list = materialMachineMapper.getToolsLedgerList(bean); + List list = materialMachineMapper.getToolsLedgerList(bean); + Long deptId = SecurityUtils.getLoginUser().getSysUser().getDeptId(); + if (!CollectionUtils.isEmpty(list) && deptId != null) { + // 删除元素 + list.removeIf(m -> !deptId.toString().equals(m.getImpUnit())); } - if (list.size() > 0) { + // 根据用户名判断用户是否为班组长 + BmTeam teamData = materialMachineMapper.getTeamData(userName); + if (!org.springframework.util.CollectionUtils.isEmpty(list)) { + if (teamData != null) { + // 将sortedList中班组身份证号与username相同的元素过滤处理 + list = list.stream() + .filter(item -> userName.equals(item.getIdCard())) + .collect(Collectors.toList()); + } + } + if (CollectionUtils.isNotEmpty(list)) { list1 = groupByThirdTypeId(list); } return list1; @@ -309,18 +362,23 @@ public class MaterialMachineServiceImpl implements MaterialMachineService { */ @Override public MaterialRetainedEquipmentInfo getToolsLedgerDetailsList(MaterialRetainedEquipmentInfo bean) { - List list = new ArrayList<>(); try { - // 先根据用户名去查班组信息 + List list = materialMachineMapper.getTeamUseNumDetailsList(bean); String username = SecurityUtils.getLoginUser().getUsername(); - BmTeam bmTeam = new BmTeam(); - bmTeam.setIdCard(username); - List teamList = bmTeamMapper.queryByPage(bmTeam); - if (CollectionUtil.isNotEmpty(teamList)) { - bean.setTeamLeaderIdCard(username); - list = materialMachineMapper.getTeamUseNumDetailsList(bean); - } else { - list = materialMachineMapper.getToolsLedgerDetailsList(bean); + Long deptId = SecurityUtils.getLoginUser().getSysUser().getDeptId(); + if (!CollectionUtils.isEmpty(list) && deptId != null) { + // 删除元素 + list.removeIf(m -> !deptId.toString().equals(m.getImpUnit())); + } + // 根据用户名判断用户是否为班组长 + BmTeam teamData = materialMachineMapper.getTeamData(username); + if (!org.springframework.util.CollectionUtils.isEmpty(list)) { + if (teamData != null) { + // 将sortedList中班组身份证号与username相同的元素过滤处理 + list = list.stream() + .filter(item -> username.equals(item.getIdCard())) + .collect(Collectors.toList()); + } } if (!CollectionUtil.isEmpty(list)) { for (MaterialRetainedEquipmentInfo retainedEquipmentInfo : list) { diff --git a/bonus-modules/bonus-material/src/main/resources/mapper/material/clz/MaterialBackInfoMapper.xml b/bonus-modules/bonus-material/src/main/resources/mapper/material/clz/MaterialBackInfoMapper.xml index a5436851..ff11658c 100644 --- a/bonus-modules/bonus-material/src/main/resources/mapper/material/clz/MaterialBackInfoMapper.xml +++ b/bonus-modules/bonus-material/src/main/resources/mapper/material/clz/MaterialBackInfoMapper.xml @@ -221,7 +221,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" bai.`status` AS status, bai.print_status as printStatus, SUM(IFNULL(bad.pre_num, 0)) AS backNum, - bp.external_id AS externalId + bp.external_id AS externalId, + bp.imp_unit AS impUnit, + bt.bzz_idcard AS idCard FROM clz_back_apply_info bai LEFT JOIN clz_back_apply_details bad on bad.parent_id = bai.id @@ -282,7 +284,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" GROUP_CONCAT(DISTINCT mt2.type_id) as typeId, GROUP_CONCAT(DISTINCT mt2.type_name) AS typeName, bai.`status` AS status, - bai.print_status as printStatus + bai.print_status as printStatus, + bp.external_id AS externalId, + bp.imp_unit AS impUnit, + bu.bzz_idcard AS idCard FROM back_apply_info bai LEFT JOIN back_apply_details bad on bad.parent_id = bai.id @@ -553,7 +558,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" bai.back_person AS backPerson, bai.create_by AS createBy, bai.`code` AS code, - bp.external_id AS externalId + bp.external_id AS externalId, + bp.imp_unit AS impUnit, + bt.bzz_idcard AS idCard FROM clz_back_check_details bcd LEFT JOIN ma_type mt ON bcd.type_id = mt.type_id @@ -674,7 +681,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" AND mt.type_id = #{typeId} AND ba.unit_id = #{teamId} AND ba.project_id = #{proId} - GROUP BY mm.ma_code + GROUP BY mm.ma_id + + + \ No newline at end of file diff --git a/bonus-modules/bonus-material/src/main/resources/mapper/material/clz/MaterialLeaseInfoMapper.xml b/bonus-modules/bonus-material/src/main/resources/mapper/material/clz/MaterialLeaseInfoMapper.xml index ca8b9bdd..49e8cadd 100644 --- a/bonus-modules/bonus-material/src/main/resources/mapper/material/clz/MaterialLeaseInfoMapper.xml +++ b/bonus-modules/bonus-material/src/main/resources/mapper/material/clz/MaterialLeaseInfoMapper.xml @@ -38,6 +38,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + + @@ -78,7 +80,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" bp.contract_part as contractPart, sd.dept_name as impUnitName, tta.agreement_id, - bp.external_id + bp.external_id, + bp.imp_unit, + bt.bzz_idcard from clz_lease_apply_info lai left join tm_task tt on lai.task_id = tt.task_id @@ -422,7 +426,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" IFNULL(sum(lad.pre_num),0) as preCountNum, IFNULL(sum(lad.al_num),0) as alNum, GROUP_CONCAT(DISTINCT mt1.type_name) as maTypeNames, - tt.task_type as taskType + tt.task_type as taskType, + bp.external_id AS externalId, + bu.bzz_idcard AS idCard from lease_apply_info lai left join tm_task tt on lai.task_id = tt.task_id @@ -673,7 +679,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" GROUP_CONCAT(DISTINCT lod.create_by) as outPerson, lai.`code` as leaseCode, bt.unit_name as teamName, - bp.pro_name as projectName + bp.pro_name as projectName, + bp.external_id AS externalId, + bt.bzz_idcard AS idCard, + bp.imp_unit AS impUnit FROM clz_lease_apply_info lai LEFT JOIN clz_lease_apply_details lad ON lai.id = lad.parent_id @@ -699,17 +708,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" mm.ma_id as maId, mm.ma_code as maCode, mm.type_id as typeId, - mm.ma_status as maStatus, - mm.qr_code as qrCode, - case when mm.ma_status = '1' then '在库' - else '' - end as statusName, + '1' as maStatus, + mm.qr_code as qrCode, + '在库' as statusName, mt.manage_type as manageType FROM ma_machine mm + LEFT JOIN slt_agreement_info sai ON mm.ma_id = sai.ma_id + and mm.type_id = sai.type_id LEFT JOIN ma_type mt ON mm.type_id = mt.type_id AND mt.del_flag = '0' LEFT JOIN ma_type mt1 ON mt.parent_id = mt1.type_id AND mt1.del_flag = '0' where - mm.qr_code = #{qrCode} + sai.`status` = '0' and mm.qr_code = #{qrCode} and mt.type_id = #{typeId} @@ -739,7 +748,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" bp.pro_name as projectName, lai.lease_person as leasePerson, lod.create_by as outPerson, - lai.`code` as code + lai.`code` as code, + bp.imp_unit as impUnit, + bt.bzz_idcard as idCard FROM clz_lease_out_details lod LEFT JOIN ma_type mt ON lod.type_id = mt.type_id @@ -947,11 +958,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and sai.ma_id = lod.ma_id LEFT JOIN clz_bm_agreement_info ba ON sai.agreement_id = ba.agreement_id WHERE - sai.status = '0' - AND mt.type_id = #{typeId} + mt.type_id = #{typeId} AND ba.unit_id = #{teamId} AND ba.project_id = #{proId} - GROUP BY mm.ma_code + GROUP BY mm.ma_id - -