This commit is contained in:
mashuai 2025-08-06 17:50:48 +08:00
parent d8e5d565e0
commit 487bc5047a
9 changed files with 250 additions and 322 deletions

View File

@ -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<MaterialRetainedEquipmentInfo> 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));
}
/**

View File

@ -65,6 +65,10 @@ public class MaterialUseStorageInfo {
@Excel(name = "班组")
private String teamName;
@ApiModelProperty(value="工程名称")
@Excel(name = "工程名称")
private String proName;
@ApiModelProperty(value = "关键字")
private String keyWord;

View File

@ -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<Integer> agreementIdList;
private List<Integer> agreementIdList;
private Long maId;
@ -237,4 +241,6 @@ public class MaterialRetainedEquipmentInfo {
@ApiModelProperty(value = "协议id")
private Long agreementId;
private Long deptId;
}

View File

@ -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<MaterialRetainedEquipmentInfo> modelList;
}

View File

@ -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<MaterialRetainedEquipmentInfo> getTeamNumThirdList(MaterialRetainedEquipmentInfo bean);
/**
* 安全工器具预警数量查询
* @param bean
* @return
*/
MaterialRetainedEquipmentInfo getSafeNumList(MaterialRetainedEquipmentInfo bean);
/**
* 安全工器具预警页面查询获取协议id
* @param bean
* @return
*/
AjaxResult getAgreementId(MaterialRetainedEquipmentInfo bean);
}

View File

@ -1507,12 +1507,13 @@ public class MaterialLeaseInfoServiceImpl implements MaterialLeaseInfoService {
}
}
List<MaterialLeaseMaCodeDto> 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("出库失败,插入结算记录失败");

View File

@ -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<Machine> primaryList = materialMachineMapper.getMachineInfo(machine);
// 如果主列表为空直接返回空列表
if (CollectionUtils.isEmpty(primaryList)) {
return Collections.emptyList();
}
// 查询clz_slt_agreement_info数据
List<Machine> secondaryList = materialMachineMapper.getSltAgreementInfo(machine);
// 合并两个列表优先保留secondaryList中的数据
List<Machine> 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<Machine> 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<MaterialSltAgreementInfo> 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<MaterialRetainedEquipmentInfo> getMaterialRetainedEquipmentInfos(List<MaterialRetainedEquipmentInfo> 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<MaterialRetainedEquipmentInfo> 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<MaterialRetainedEquipmentInfo> 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<MaterialRetainedEquipmentInfo> getSafeDetailsList(MaterialRetainedEquipmentInfo bean) {
String username = SecurityUtils.getLoginUser().getUsername();
// 根据用户名查询项目部信息
String departId = mapper.getDepartId(username);
// 根据项目部id查询工程信息
List<String> projectIdList = mapper.getProjectId(departId);
List<BmProject> list = mapper.getProjectInfo(new BmProject());
Set<Integer> 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<AgreementVo> agreementList = mapper.getAgreementInfoBy(selectDto);
if (CollectionUtils.isNotEmpty(agreementList)) {
for (AgreementVo agreement : agreementList) {
agreementIdList.add(agreement.getAgreementId());
}
}
}
}
}
// 根据agreementIdList查询工器具台账信息
bean.setAgreementIdList(agreementIdList);
List<MaterialRetainedEquipmentInfo> totalList = materialMachineMapper.getTotalList(bean);
if (CollectionUtils.isNotEmpty(totalList)) {
for (MaterialRetainedEquipmentInfo materialRetainedEquipmentInfo : totalList) {
MaterialRetainedEquipmentInfo materialRetainedEquipmentInfo1 = new MaterialRetainedEquipmentInfo();
materialRetainedEquipmentInfo1.setMaId(materialRetainedEquipmentInfo.getMaId());
List<MaterialRetainedEquipmentInfo> 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<MaterialRetainedEquipmentInfo> 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<String> projectIdList = mapper.getProjectId(departId);
List<BmProject> list = mapper.getProjectInfo(new BmProject());
Set<Integer> 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<AgreementVo> agreementList = mapper.getAgreementInfoBy(selectDto);
if (CollectionUtils.isNotEmpty(agreementList)) {
for (AgreementVo agreement : agreementList) {
agreementIdList.add(agreement.getAgreementId());
}
}
}
}
}
return AjaxResult.success(agreementIdList);
}
/**
* 在用设备模糊匹配
* @param item

View File

@ -1185,20 +1185,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select>
<select id="getList" resultType="com.bonus.common.biz.domain.lease.MaterialLeaseMaCodeDto">
SELECT
mt.type_id AS typeId,
mt1.type_name AS materialName,
mt.type_name AS materialModel,
su.sign_type AS signType,
su.sign_url AS signUrl
FROM
clz_lease_out_details lod
LEFT JOIN ma_type mt ON lod.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'
LEFT JOIN sys_user su ON lod.create_by = su.nick_name
sys_user su
LEFT JOIN clz_lease_out_details lod ON lod.create_by = su.user_id
WHERE
lod.parent_id = #{id}
AND mt.type_id = #{typeId}
AND lod.type_id = #{typeId}
</select>
</mapper>

View File

@ -38,6 +38,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="maModel != null and maModel != ''">
and mt.type_name like concat('%', #{maModel}, '%')
</if>
<if test="impUnit != null and impUnit != ''">
and bp.imp_unit = #{impUnit}
</if>
<if test="projectIdList != null and projectIdList.size() > 0">
and bp.external_id in
<foreach item="item" collection="projectIdList" open="(" separator="," close=")">
@ -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 &lt; CURDATE() THEN 3 -- 已超过当前时间
WHEN DATEDIFF(mm.next_check_time, CURDATE()) &lt;= 30 THEN 2 -- 相差不足1个月
WHEN DATEDIFF(mm.next_check_time, CURDATE()) &lt;= 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},'%')
)
</if>
<if test="jiJuType != null">
<if test="jiJuType != null and jiJuType != 0">
and mt.jiju_type = #{jiJuType}
</if>
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 &lt; CURDATE() THEN 3 -- 已超过当前时间
WHEN DATEDIFF(mm.next_check_time, CURDATE()) &lt;= 30 THEN 2 -- 相差不足1个月
WHEN DATEDIFF(mm.next_check_time, CURDATE()) &lt;= 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 &lt; CURDATE() THEN 3 -- 已超过当前时间
WHEN DATEDIFF(mm.next_check_time, CURDATE()) &lt;= 30 THEN 2 -- 相差不足1个月
WHEN DATEDIFF(mm.next_check_time, CURDATE()) &lt;= 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"
<select id="selectUseInFo" resultType="com.bonus.material.clz.domain.machine.MaterialUseStorageInfo">
SELECT
create_time as outTime,
GROUP_CONCAT( DISTINCT create_by ) AS creator
cld.create_time as outTime,
GROUP_CONCAT( DISTINCT su.nick_name ) AS creator
FROM
clz_lease_out_details
clz_lease_out_details cld
left join sys_user su ON su.user_id = cld.create_by
WHERE parent_id = #{leaseId}
GROUP BY parent_id
LIMIT 1
</select>
<select id="getTotalList" resultType="com.bonus.material.clz.domain.vo.MaterialRetainedEquipmentInfo">
SELECT * FROM (
-- 原查询包含status计算
SELECT
mt2.type_name AS typeName,
mt.type_name AS typeModelName,
sai.ma_id AS maId,
mm.ma_code AS maCode,
mm.this_check_time AS thisCheckTime,
mm.next_check_time AS nextCheckTime,
bp.imp_unit AS impUnit,
mt.manage_type AS manageType
mt2.type_name AS typeName,
mt.type_name AS typeModelName,
sai.ma_id AS maId,
mm.ma_code AS maCode,
mm.this_check_time AS thisCheckTime,
mm.next_check_time AS nextCheckTime,
bp.imp_unit AS impUnit,
mt.manage_type AS manageType,
-- 计算status的CASE表达式
CASE
WHEN mm.next_check_time &lt; CURDATE() THEN 3 -- 已超过当前时间
WHEN DATEDIFF(mm.next_check_time, CURDATE()) &lt;= 30 THEN 2 -- 相差不足1个月
WHEN DATEDIFF(mm.next_check_time, CURDATE()) &lt;= 90 THEN 1 -- 相差不足3个月
ELSE 0 -- 相差3个月以上
END AS status,
bp.pro_name AS proName,
bu.unit_name AS teamName
FROM
slt_agreement_info sai
slt_agreement_info sai
LEFT JOIN bm_agreement_info bai ON sai.agreement_id = bai.agreement_id
LEFT JOIN bm_project bp ON bai.project_id = bp.pro_id
LEFT JOIN ma_type mt ON mt.type_id = sai.type_id
LEFT JOIN ma_type mt2 ON mt.parent_id = mt2.type_id
LEFT JOIN ma_machine mm ON mm.ma_id = sai.ma_id
LEFT JOIN clz_slt_agreement_info csi ON mm.ma_id = csi.ma_id
LEFT JOIN clz_bm_agreement_info cba ON csi.agreement_id = cba.agreement_id
LEFT JOIN bm_unit bu ON cba.unit_id = bu.unit_id
WHERE
sai.`status` = '0'
AND mt.jiju_type = 2
AND sai.ma_id IS NOT NULL
<if test="agreementIdList != null and agreementIdList.size >0">
AND sai.agreement_id IN
<foreach item="item" collection="agreementIdList" open="(" separator="," close=")">
#{item}
</foreach>
</if>
sai.`status` = '0'
AND mt.jiju_type = 2
AND sai.ma_id IS NOT NULL
<if test="agreementIdList != null and agreementIdList.size >0">
AND sai.agreement_id IN
<foreach item="item" collection="agreementIdList" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="deptId != null">
AND bp.imp_unit = #{deptId}
</if>
<if test="keyWord != null and keyWord != ''">
and (
bu.unit_name like concat('%',#{keyWord},'%') or
bp.pro_name like concat('%',#{keyWord},'%') or
mt2.type_name like concat('%',#{keyWord},'%') or
mt.type_name like concat('%',#{keyWord},'%') or
mm.ma_code like concat('%',#{keyWord},'%')
)
</if>
) AS temp -- 子查询别名
-- 对计算出的status进行筛选
<if test="status != null and status != ''">
WHERE temp.status = #{status}
</if>
-- 排序proName和teamName都不为空的排在最前面
ORDER BY
-- 核心排序逻辑:两个字段都不为空的记录优先级最高
CASE
WHEN temp.proName IS NOT NULL AND temp.proName != ''
AND temp.teamName IS NOT NULL AND temp.teamName != '' THEN 0 -- 优先排在前面
ELSE 1 -- 其他情况排在后面
END ASC,
-- 可根据需要添加其他排序字段(如原顺序或时间)
temp.maId ASC -- 示例按maId升序排列可选
</select>
<select id="getTeamNumList" resultType="com.bonus.material.clz.domain.vo.MaterialRetainedTeamTotalVo">