diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/controller/MaterialMachineController.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/controller/MaterialMachineController.java index 93881ac9..a42bfb5c 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/controller/MaterialMachineController.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/controller/MaterialMachineController.java @@ -219,10 +219,31 @@ public class MaterialMachineController extends BaseController { @ApiOperation(value = "安全工器具预警页面查询") @GetMapping("/getSafeDetailsList") public AjaxResult getSafeDetailsList(MaterialRetainedEquipmentInfo bean) { - Integer pageIndex = Convert.toInt(ServletUtils.getParameter("pageNum"), 1); - Integer pageSize = Convert.toInt(ServletUtils.getParameter("pageSize"), 10); + startPage(); List list = materialMachineService.getSafeDetailsList(bean); - return AjaxResult.success(ListPagingUtil.paging(pageIndex, pageSize, list)); + return AjaxResult.success(getDataTable(list)); + } + + /** + * 安全工器具预警页面查询获取协议id + * @param bean + * @return + */ + @ApiOperation(value = "安全工器具预警页面查询获取协议id") + @GetMapping("/getAgreementId") + public AjaxResult getAgreementId(MaterialRetainedEquipmentInfo bean) { + return materialMachineService.getAgreementId(bean); + } + + /** + * 安全工器具预警数量查询 + * @param bean + * @return + */ + @ApiOperation(value = "安全工器具预警数量查询") + @GetMapping("/getSafeNumList") + public AjaxResult getSafeNumList(MaterialRetainedEquipmentInfo bean) { + return AjaxResult.success(materialMachineService.getSafeNumList(bean)); } /** diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/domain/machine/MaterialUseStorageInfo.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/domain/machine/MaterialUseStorageInfo.java index 65a8a23b..82941bda 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/domain/machine/MaterialUseStorageInfo.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/domain/machine/MaterialUseStorageInfo.java @@ -65,6 +65,10 @@ public class MaterialUseStorageInfo { @Excel(name = "班组") private String teamName; + @ApiModelProperty(value="工程名称") + @Excel(name = "工程名称") + private String proName; + @ApiModelProperty(value = "关键字") private String keyWord; 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 fabaf6e9..ed2cdbb0 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 @@ -173,11 +173,15 @@ public class MaterialRetainedEquipmentInfo { /** 本次检验日期 */ @ApiModelProperty(value = "本次检验日期") - private String thisCheckTime; + @DateTimeFormat(pattern="yyyy-MM-dd") + @JsonFormat(pattern = "yyyy-MM-dd") + private Date thisCheckTime; /** 下次检验日期 */ @ApiModelProperty(value = "下次检验日期") - private String nextCheckTime; + @DateTimeFormat(pattern="yyyy-MM-dd") + @JsonFormat(pattern = "yyyy-MM-dd") + private Date nextCheckTime; /** * 状态(0 =正常,1= 3个月检测到期,2= 1个月检测到期,3= 已过期) @@ -225,7 +229,7 @@ public class MaterialRetainedEquipmentInfo { private int jiJuType; @ApiModelProperty(value = "协议id集合") - private Set agreementIdList; + private List agreementIdList; private Long maId; @@ -237,4 +241,6 @@ public class MaterialRetainedEquipmentInfo { @ApiModelProperty(value = "协议id") private Long agreementId; + + private Long deptId; } \ No newline at end of file diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/domain/vo/MaterialRetainedVo.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/domain/vo/MaterialRetainedVo.java new file mode 100644 index 00000000..bb1f4c59 --- /dev/null +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/domain/vo/MaterialRetainedVo.java @@ -0,0 +1,21 @@ + +package com.bonus.material.clz.domain.vo; + +import io.swagger.annotations.ApiModel; +import lombok.Data; + +import java.util.List; + +/** +* @description 综合查询--保有设备总量查询 +* @author ma_sh +* @date 2024/2/26 14:51 +*/ +@ApiModel(description = "保有设备总量查询") +@Data +public class MaterialRetainedVo { + + private MaterialRetainedEquipmentInfo bean; + + private List modelList; +} \ No newline at end of file diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/service/MaterialMachineService.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/service/MaterialMachineService.java index 53d8f773..e0dcc8b6 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/service/MaterialMachineService.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/service/MaterialMachineService.java @@ -1,5 +1,6 @@ package com.bonus.material.clz.service; +import com.bonus.common.core.web.domain.AjaxResult; import com.bonus.material.clz.domain.machine.MaterialUseStorageInfo; import com.bonus.material.clz.domain.vo.MaterialRetainedTeamTotalVo; import com.bonus.material.clz.domain.vo.MaterialRetainedTeamVo; @@ -105,4 +106,18 @@ public interface MaterialMachineService { * @return */ List getTeamNumThirdList(MaterialRetainedEquipmentInfo bean); + + /** + * 安全工器具预警数量查询 + * @param bean + * @return + */ + MaterialRetainedEquipmentInfo getSafeNumList(MaterialRetainedEquipmentInfo bean); + + /** + * 安全工器具预警页面查询获取协议id + * @param bean + * @return + */ + AjaxResult getAgreementId(MaterialRetainedEquipmentInfo bean); } 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 c7b16a8f..5209d5af 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 @@ -1507,12 +1507,13 @@ public class MaterialLeaseInfoServiceImpl implements MaterialLeaseInfoService { } } List detailsList = materialLeaseInfoMapper.getList(leaseApplyInfo.getId(), details.get(0).getTypeId()); + LeaseOutSign leaseOutSign = new LeaseOutSign(0, null); if (CollectionUtil.isNotEmpty(detailsList)) { //获取maCodeVoList第一个对象 - LeaseOutSign leaseOutSign = new LeaseOutSign(detailsList.get(0).getSignType(), + leaseOutSign = new LeaseOutSign(detailsList.get(0).getSignType(), "data:image/png;base64," + detailsList.get(0).getSignUrl()); - leaseApplyRequestVo.setLeaseOutSign(leaseOutSign); } + leaseApplyRequestVo.setLeaseOutSign(leaseOutSign); } AjaxResult ajaxResult = AjaxResult.success(); ajaxResult.put("data", leaseApplyRequestVo); @@ -1538,7 +1539,7 @@ public class MaterialLeaseInfoServiceImpl implements MaterialLeaseInfoService { details.setCreateTime(DateUtils.getNowDate()); details.setCreateBy(createBy); LeaseOutDetails record = new LeaseOutDetails(); - record.setCreateBy(createBy); + record.setCreateBy(SecurityUtils.getLoginUser().getUserid().toString()); record.setIsFinished(isOut == 1 ? 1 : 0); // 领料出库 if (isOut == 1) { @@ -1577,13 +1578,6 @@ public class MaterialLeaseInfoServiceImpl implements MaterialLeaseInfoService { if (res == 0) { throw new RuntimeException("插入lease_out_details表数据失败"); } - /*if (res > 0) { - // 普通机具减少 (ma_type 设备规格表)的库存数量 - res = typeMapper.updateMaTypeStockNum(record); - if (res == 0) { - return AjaxResult.error("更新ma_type表数据失败"); - } - }*/ res = insSltInfo(taskId, record); if (res == 0) { throw new RuntimeException("出库失败,插入结算记录失败"); 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 b527d997..6fe7843f 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 @@ -3,6 +3,7 @@ package com.bonus.material.clz.service.impl; import cn.hutool.core.collection.CollectionUtil; import com.alibaba.nacos.common.utils.CollectionUtils; import com.alibaba.nacos.common.utils.StringUtils; +import com.bonus.common.core.web.domain.AjaxResult; import com.bonus.common.security.utils.SecurityUtils; import com.bonus.material.basic.domain.BmProject; import com.bonus.material.clz.domain.lease.MaterialLeaseApplyInfo; @@ -71,41 +72,15 @@ public class MaterialMachineServiceImpl implements MaterialMachineService { } } // 查询slt_agreement_info数据 - List primaryList = materialMachineMapper.getMachineInfo(machine); - - // 如果主列表为空,直接返回空列表 - if (CollectionUtils.isEmpty(primaryList)) { - return Collections.emptyList(); - } - - // 查询clz_slt_agreement_info数据 - List secondaryList = materialMachineMapper.getSltAgreementInfo(machine); - - // 合并两个列表,优先保留secondaryList中的数据 - List mergedList = new ArrayList<>(primaryList); - if (CollectionUtils.isNotEmpty(secondaryList)) { - // 从primaryList中移除secondaryList中已存在的元素 - mergedList.removeIf(primary -> secondaryList.stream() - .anyMatch(secondary -> Objects.equals(primary.getMaId(), secondary.getMaId()))); - - // 添加secondaryList中的所有元素 - mergedList.addAll(secondaryList); - } - Long deptId = SecurityUtils.getLoginUser().getSysUser().getDeptId(); - if (!CollectionUtils.isEmpty(mergedList) && deptId != null) { - // 删除元素 - mergedList.removeIf(m -> !deptId.toString().equals(m.getImpUnit())); - } - if (!org.springframework.util.CollectionUtils.isEmpty(mergedList)) { + machine.setImpUnit(SecurityUtils.getLoginUser().getSysUser().getDeptId().toString()); + List mergedList = materialMachineMapper.getMachineInfo(machine); + if (!CollectionUtils.isEmpty(mergedList)) { // 班组权限 if (teamData != null) { // 将sortedList中班组身份证号与username相同的元素过滤处理 mergedList = mergedList.stream() .filter(item -> StringUtils.isBlank(item.getIdCard()) || username.equals(item.getIdCard())) .collect(Collectors.toList()); - } else { - // 材料员权限 - mergedList = filterInfoMachine(mergedList, username); } } if (!StringUtils.isBlank(machine.getKeyWord())) { @@ -113,19 +88,6 @@ public class MaterialMachineServiceImpl implements MaterialMachineService { .filter(item -> containsKeywordMachine(item, machine.getKeyWord())) .collect(Collectors.toList()); } - if (CollectionUtils.isNotEmpty(mergedList)) { - // 根据maId去协议表查询设备设备状态,赋值maStatus - for (Machine machine1 : mergedList) { - if (machine1.getMaId() != null) { - List sltAgreementInfo = materialMachineMapper.selectStatusById(machine1); - if (CollectionUtils.isNotEmpty(sltAgreementInfo)) { - machine1.setMaStatus("在用"); - } else { - machine1.setMaStatus("在库"); - } - } - } - } return mergedList; } @@ -391,24 +353,6 @@ public class MaterialMachineServiceImpl implements MaterialMachineService { return new ArrayList<>(); } if (!CollectionUtil.isEmpty(list)) { - list = getMaterialRetainedEquipmentInfos(list); - for (MaterialRetainedEquipmentInfo info : list) { - // 处理thisCheckTime - if (StringUtils.isNotBlank(info.getThisCheckTime())) { - // 提取日期部分(假设格式为"yyyy-MM-dd HH:mm:ss") - String[] parts = info.getThisCheckTime().split(" "); - if (parts.length > 0) { - info.setThisCheckTime(parts[0]); - } - } - // 处理nextCheckTime - if (StringUtils.isNotBlank(info.getNextCheckTime())) { - String[] parts = info.getNextCheckTime().split(" "); - if (parts.length > 0) { - info.setNextCheckTime(parts[0]); - } - } - } if (StringUtils.isNotBlank(bean.getStatus())) { return list.stream().filter(item -> { return item.getStatus().equals(bean.getStatus()); @@ -418,50 +362,6 @@ public class MaterialMachineServiceImpl implements MaterialMachineService { return list; } - /** - * 工具库存查询 - * @param list - * @return - */ - private List getMaterialRetainedEquipmentInfos(List list) { - // 将list中manageType为0的数据过滤出来 - list = list.stream().filter(item -> "0".equals(item.getManageType())).collect(Collectors.toList()); - for (MaterialRetainedEquipmentInfo retainedEquipmentInfo : list) { - if (StringUtils.isNotBlank(retainedEquipmentInfo.getNextCheckTime())) { - String nextCheckTime = retainedEquipmentInfo.getNextCheckTime(); - // 解析字符串日期(格式:yyyy-MM-dd) - DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); - LocalDateTime dateTime = LocalDateTime.parse(nextCheckTime, formatter); - LocalDate targetDate = dateTime.toLocalDate(); - // 当前日期 - LocalDate currentDate = LocalDate.now(); - boolean isFuture = targetDate.isAfter(currentDate); - if (!isFuture) { - // 已过期 - retainedEquipmentInfo.setStatus("3"); - continue; - } - Period period = Period.between(currentDate, targetDate); - int years = period.getYears(); - int months = period.getMonths(); - int days = period.getDays(); - // 计算累计月份差(向上取整) - int totalMonths = years * 12 + months; - if (days > 0 || targetDate.getDayOfMonth() > currentDate.getDayOfMonth()) { - totalMonths++; - } - if (totalMonths <= 1) { - retainedEquipmentInfo.setStatus("2"); - } else if (totalMonths <= 3) { - retainedEquipmentInfo.setStatus("1"); - } else { - retainedEquipmentInfo.setStatus("0"); - } - } - } - return list; - } - /** * 工器具台账查询 * @param bean @@ -579,7 +479,7 @@ public class MaterialMachineServiceImpl implements MaterialMachineService { if (CollectionUtils.isEmpty(primaryList)) { return new MaterialRetainedEquipmentInfo(); } - if (!org.springframework.util.CollectionUtils.isEmpty(list)) { + if (!CollectionUtils.isEmpty(list)) { if (teamData != null) { // 将sortedList中班组身份证号与username相同的元素过滤处理 list = list.stream() @@ -588,11 +488,9 @@ public class MaterialMachineServiceImpl implements MaterialMachineService { if (CollectionUtils.isNotEmpty(list)) { return getMaterialRetainedEquipmentInfo(list); } - } /*else { - primaryList = filterInfo(primaryList, username); - }*/ + } } - if (!CollectionUtil.isEmpty(primaryList)) { + if (!CollectionUtil.isEmpty(primaryList)) { return getMaterialRetainedEquipmentInfo(primaryList); } } catch (Exception e){ @@ -607,40 +505,7 @@ public class MaterialMachineServiceImpl implements MaterialMachineService { * @return */ private MaterialRetainedEquipmentInfo getMaterialRetainedEquipmentInfo(List list) { - for (MaterialRetainedEquipmentInfo retainedEquipmentInfo : list) { - if (StringUtils.isNotBlank(retainedEquipmentInfo.getNextCheckTime())) { - String nextCheckTime = retainedEquipmentInfo.getNextCheckTime(); - // 解析字符串日期(格式:yyyy-MM-dd) - DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); - LocalDateTime dateTime = LocalDateTime.parse(nextCheckTime, formatter); - LocalDate targetDate = dateTime.toLocalDate(); - // 当前日期 - LocalDate currentDate = LocalDate.now(); - boolean isFuture = targetDate.isAfter(currentDate); - if (!isFuture) { - // 已过期 - retainedEquipmentInfo.setStatus("3"); - continue; - } - Period period = Period.between(currentDate, targetDate); - int years = period.getYears(); - int months = period.getMonths(); - int days = period.getDays(); - // 计算累计月份差(向上取整) - int totalMonths = years * 12 + months; - if (days > 0 || targetDate.getDayOfMonth() > currentDate.getDayOfMonth()) { - totalMonths++; - } - if (totalMonths <= 1) { - retainedEquipmentInfo.setStatus("2"); - } else if (totalMonths <= 3) { - retainedEquipmentInfo.setStatus("1"); - } else { - retainedEquipmentInfo.setStatus("0"); - } - } - } - // 获取list集合中状态为0的元素的总数 + // 获取list集合中状态的元素的总数 MaterialRetainedEquipmentInfo retainedEquipmentInfo = new MaterialRetainedEquipmentInfo(); long normalNum = list.stream().filter(item -> "0".equals(item.getStatus())).count(); retainedEquipmentInfo.setNormalNum(normalNum); @@ -664,54 +529,6 @@ public class MaterialMachineServiceImpl implements MaterialMachineService { //没有班组,则查全部 List list = materialMachineMapper.getToolsDetailsList(bean); if (!CollectionUtil.isEmpty(list)) { - for (MaterialRetainedEquipmentInfo retainedEquipmentInfo : list) { - if (StringUtils.isNotBlank(retainedEquipmentInfo.getNextCheckTime())) { - String nextCheckTime = retainedEquipmentInfo.getNextCheckTime(); - // 解析字符串日期(格式:yyyy-MM-dd) - DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); - LocalDateTime dateTime = LocalDateTime.parse(nextCheckTime, formatter); - LocalDate targetDate = dateTime.toLocalDate(); - // 当前日期 - LocalDate currentDate = LocalDate.now(); - boolean isFuture = targetDate.isAfter(currentDate); - if (!isFuture) { - // 已过期 - retainedEquipmentInfo.setStatus("3"); - continue; - } - Period period = Period.between(currentDate, targetDate); - int years = period.getYears(); - int months = period.getMonths(); - int days = period.getDays(); - // 计算累计月份差(向上取整) - int totalMonths = years * 12 + months; - if (days > 0 || targetDate.getDayOfMonth() > currentDate.getDayOfMonth()) { - totalMonths++; - } - if (totalMonths <= 1) { - retainedEquipmentInfo.setStatus("2"); - } else if (totalMonths <= 3) { - retainedEquipmentInfo.setStatus("1"); - } else { - retainedEquipmentInfo.setStatus("0"); - } - } - // 处理thisCheckTime - if (StringUtils.isNotBlank(retainedEquipmentInfo.getThisCheckTime())) { - // 提取日期部分(假设格式为"yyyy-MM-dd HH:mm:ss") - String[] parts = retainedEquipmentInfo.getThisCheckTime().split(" "); - if (parts.length > 0) { - retainedEquipmentInfo.setThisCheckTime(parts[0]); - } - } - // 处理nextCheckTime - if (StringUtils.isNotBlank(retainedEquipmentInfo.getNextCheckTime())) { - String[] parts = retainedEquipmentInfo.getNextCheckTime().split(" "); - if (parts.length > 0) { - retainedEquipmentInfo.setNextCheckTime(parts[0]); - } - } - } if (StringUtils.isNotBlank(bean.getStatus())) { return list.stream().filter(item -> { return StringUtils.isNotBlank(item.getStatus()) && item.getStatus().equals(bean.getStatus()); @@ -768,85 +585,8 @@ public class MaterialMachineServiceImpl implements MaterialMachineService { */ @Override public List getSafeDetailsList(MaterialRetainedEquipmentInfo bean) { - String username = SecurityUtils.getLoginUser().getUsername(); - // 根据用户名查询项目部信息 - String departId = mapper.getDepartId(username); - // 根据项目部id查询工程信息 - List projectIdList = mapper.getProjectId(departId); - List list = mapper.getProjectInfo(new BmProject()); - Set agreementIdList = new HashSet<>(); - if (CollectionUtils.isNotEmpty(list)) { - if (CollectionUtils.isNotEmpty(projectIdList)) { - // 找出list中projectId与projectIdList中相同的数据 - list = list.stream().filter(info -> projectIdList.contains(info.getProjectId())).collect(Collectors.toList()); - } - if (CollectionUtils.isNotEmpty(list)) { - for (BmProject project : list) { - SelectDto selectDto = new SelectDto(); - selectDto.setProId(project.getProId()); - List agreementList = mapper.getAgreementInfoBy(selectDto); - if (CollectionUtils.isNotEmpty(agreementList)) { - for (AgreementVo agreement : agreementList) { - agreementIdList.add(agreement.getAgreementId()); - } - } - } - } - } - // 根据agreementIdList查询工器具台账信息 - bean.setAgreementIdList(agreementIdList); - List totalList = materialMachineMapper.getTotalList(bean); - if (CollectionUtils.isNotEmpty(totalList)) { - for (MaterialRetainedEquipmentInfo materialRetainedEquipmentInfo : totalList) { - MaterialRetainedEquipmentInfo materialRetainedEquipmentInfo1 = new MaterialRetainedEquipmentInfo(); - materialRetainedEquipmentInfo1.setMaId(materialRetainedEquipmentInfo.getMaId()); - List clzList = materialMachineMapper.getTeamUseNumDetailsList(materialRetainedEquipmentInfo1); - if (CollectionUtils.isNotEmpty(clzList)) { - materialRetainedEquipmentInfo.setTeamName(clzList.get(0).getTeamName()); - materialRetainedEquipmentInfo.setProName(clzList.get(0).getProName()); - } - } - } - Long deptId = SecurityUtils.getLoginUser().getSysUser().getDeptId(); - if (!CollectionUtils.isEmpty(totalList) && deptId != null) { - // 删除元素 - totalList.removeIf(m -> !deptId.toString().equals(m.getImpUnit())); - } - if (CollectionUtils.isEmpty(totalList)) { - return new ArrayList<>(); - } - if (!CollectionUtil.isEmpty(totalList)) { - totalList = getMaterialRetainedEquipmentInfos(totalList); - for (MaterialRetainedEquipmentInfo info : totalList) { - // 处理thisCheckTime - if (StringUtils.isNotBlank(info.getThisCheckTime())) { - // 提取日期部分(假设格式为"yyyy-MM-dd HH:mm:ss") - String[] parts = info.getThisCheckTime().split(" "); - if (parts.length > 0) { - info.setThisCheckTime(parts[0]); - } - } - // 处理nextCheckTime - if (StringUtils.isNotBlank(info.getNextCheckTime())) { - String[] parts = info.getNextCheckTime().split(" "); - if (parts.length > 0) { - info.setNextCheckTime(parts[0]); - } - } - } - if (StringUtils.isNotBlank(bean.getStatus())) { - return totalList.stream().filter(item -> { - return StringUtils.isNotBlank(item.getStatus()) && item.getStatus().equals(bean.getStatus()); - }).collect(Collectors.toList()); - } - // 如果关键字不为空,进行过滤 - if (StringUtils.isNotBlank(bean.getKeyWord())) { - totalList = totalList.stream() - .filter(item -> containsNumKeyword(item, bean.getKeyWord())) - .collect(Collectors.toList()); - } - } - return totalList; + bean.setDeptId(SecurityUtils.getLoginUser().getSysUser().getDeptId()); + return materialMachineMapper.getTotalList(bean); } /** @@ -919,6 +659,76 @@ public class MaterialMachineServiceImpl implements MaterialMachineService { return materialMachineMapper.getTeamNumThirdList(bean); } + /** + * 安全工器具预警数量查询 + * @param bean + * @return + */ + @Override + public MaterialRetainedEquipmentInfo getSafeNumList(MaterialRetainedEquipmentInfo bean) { + MaterialRetainedEquipmentInfo retainedEquipmentInfo = new MaterialRetainedEquipmentInfo(); + bean.setDeptId(SecurityUtils.getLoginUser().getSysUser().getDeptId()); + List totalList = materialMachineMapper.getTotalList(bean); + if (!CollectionUtil.isEmpty(totalList)) { + if (StringUtils.isNotBlank(bean.getStatus())) { + totalList = totalList.stream().filter(item -> StringUtils.isNotBlank(item.getStatus()) && item.getStatus().equals(bean.getStatus())).collect(Collectors.toList()); + } + // 如果关键字不为空,进行过滤 + if (StringUtils.isNotBlank(bean.getKeyWord())) { + totalList = totalList.stream() + .filter(item -> containsNumKeyword(item, bean.getKeyWord())) + .collect(Collectors.toList()); + } + if (CollectionUtils.isNotEmpty(totalList)) { + // 收集totalList中各种状态的总数量 + long normalNum = totalList.stream().filter(item -> "0".equals(item.getStatus())).count(); + retainedEquipmentInfo.setNormalNum(normalNum); + long threeMonthNum = totalList.stream().filter(item -> "1".equals(item.getStatus())).count(); + retainedEquipmentInfo.setThreeMonthNum(threeMonthNum); + long oneMonthNum = totalList.stream().filter(item -> "2".equals(item.getStatus())).count(); + retainedEquipmentInfo.setOneMonthNum(oneMonthNum); + long expiredNum = totalList.stream().filter(item -> "3".equals(item.getStatus())).count(); + retainedEquipmentInfo.setExpiredNum(expiredNum); + } + } + return retainedEquipmentInfo; + } + + /** + * 安全工器具预警页面查询获取协议id + * @param bean + * @return + */ + @Override + public AjaxResult getAgreementId(MaterialRetainedEquipmentInfo bean) { + String username = SecurityUtils.getLoginUser().getUsername(); + // 根据用户名查询项目部信息 + String departId = mapper.getDepartId(username); + // 根据项目部id查询工程信息 + List projectIdList = mapper.getProjectId(departId); + List list = mapper.getProjectInfo(new BmProject()); + Set agreementIdList = new HashSet<>(); + if (CollectionUtils.isNotEmpty(list)) { + if (CollectionUtils.isNotEmpty(projectIdList)) { + // 找出list中projectId与projectIdList中相同的数据 + list = list.stream().filter(info -> projectIdList.contains(info.getProjectId())).collect(Collectors.toList()); + } + if (CollectionUtils.isNotEmpty(list)) { + for (BmProject project : list) { + SelectDto selectDto = new SelectDto(); + selectDto.setProId(project.getProId()); + List agreementList = mapper.getAgreementInfoBy(selectDto); + if (CollectionUtils.isNotEmpty(agreementList)) { + for (AgreementVo agreement : agreementList) { + agreementIdList.add(agreement.getAgreementId()); + } + } + } + } + } + return AjaxResult.success(agreementIdList); + } + /** * 在用设备模糊匹配 * @param item 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 1f9050b9..8cd1a4f5 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 @@ -1185,20 +1185,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" \ No newline at end of file diff --git a/bonus-modules/bonus-material/src/main/resources/mapper/material/clz/MaterialMachineMapper.xml b/bonus-modules/bonus-material/src/main/resources/mapper/material/clz/MaterialMachineMapper.xml index ddad5c23..996175d2 100644 --- a/bonus-modules/bonus-material/src/main/resources/mapper/material/clz/MaterialMachineMapper.xml +++ b/bonus-modules/bonus-material/src/main/resources/mapper/material/clz/MaterialMachineMapper.xml @@ -38,6 +38,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and mt.type_name like concat('%', #{maModel}, '%') + + and bp.imp_unit = #{impUnit} + and bp.external_id in @@ -286,7 +289,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" mt.manage_type AS manageType, bp.imp_unit AS impUnit, bt.bzz_idcard AS idCard, - bp.pro_name AS proName + bp.pro_name AS proName, + CASE + WHEN mm.next_check_time < CURDATE() THEN 3 -- 已超过当前时间 + WHEN DATEDIFF(mm.next_check_time, CURDATE()) <= 30 THEN 2 -- 相差不足1个月 + WHEN DATEDIFF(mm.next_check_time, CURDATE()) <= 90 THEN 1 -- 相差不足3个月 + ELSE 0 -- 相差3个月以上 + END AS status FROM clz_slt_agreement_info sai LEFT JOIN clz_bm_agreement_info bai ON sai.agreement_id = bai.agreement_id @@ -319,7 +328,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" OR mm.ma_code LIKE concat('%',#{keyWord},'%') ) - + and mt.jiju_type = #{jiJuType} GROUP BY @@ -456,7 +465,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" mt.manage_type AS manageType, bp.external_id as externalId, bp.imp_unit AS impUnit, - bt.bzz_idcard AS idCard + bt.bzz_idcard AS idCard, + CASE + WHEN mm.next_check_time < CURDATE() THEN 3 -- 已超过当前时间 + WHEN DATEDIFF(mm.next_check_time, CURDATE()) <= 30 THEN 2 -- 相差不足1个月 + WHEN DATEDIFF(mm.next_check_time, CURDATE()) <= 90 THEN 1 -- 相差不足3个月 + ELSE 0 -- 相差3个月以上 + END AS status FROM slt_agreement_info sai LEFT JOIN bm_agreement_info bai ON sai.agreement_id = bai.agreement_id @@ -548,7 +563,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" mm.ma_code AS maCode, mm.this_check_time AS thisCheckTime, mm.next_check_time AS nextCheckTime, - mt.manage_type AS manageType + mt.manage_type AS manageType, + CASE + WHEN mm.next_check_time < CURDATE() THEN 3 -- 已超过当前时间 + WHEN DATEDIFF(mm.next_check_time, CURDATE()) <= 30 THEN 2 -- 相差不足1个月 + WHEN DATEDIFF(mm.next_check_time, CURDATE()) <= 90 THEN 1 -- 相差不足3个月 + ELSE 0 -- 相差3个月以上 + END AS status FROM slt_agreement_info sai LEFT JOIN bm_agreement_info bai ON sai.agreement_id = bai.agreement_id @@ -639,7 +660,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" sai.lease_id AS leaseId, sai.type_id AS typeId, lai.code AS code, - sai.ma_id AS maId + sai.ma_id AS maId, + bp.pro_name AS proName FROM clz_slt_agreement_info sai LEFT JOIN ma_type mt ON mt.type_id = sai.type_id @@ -663,42 +685,84 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"