代码提交
This commit is contained in:
parent
0c0bf6426c
commit
883ee948e5
|
|
@ -0,0 +1,96 @@
|
||||||
|
package com.bonus.material.push.controller;
|
||||||
|
|
||||||
|
import com.bonus.common.core.exception.ServiceException;
|
||||||
|
import com.bonus.common.core.web.controller.BaseController;
|
||||||
|
import com.bonus.common.core.web.page.TableDataInfo;
|
||||||
|
import com.bonus.material.push.domain.CostPushBean;
|
||||||
|
import com.bonus.material.push.domain.MachineInfoBean;
|
||||||
|
import com.bonus.material.push.domain.ProIdsBean;
|
||||||
|
import com.bonus.material.push.domain.StaticsNumsBean;
|
||||||
|
import com.bonus.material.push.service.ProDataUseInfoService;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author:liang.chao
|
||||||
|
* @Date:2025/8/23 - 14:28
|
||||||
|
*/
|
||||||
|
|
||||||
|
@RequestMapping("/dataUseInfo")
|
||||||
|
@RestController
|
||||||
|
public class PushProDataUseInfoController extends BaseController {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private ProDataUseInfoService service;
|
||||||
|
/**
|
||||||
|
* 查询推送数据使用信息
|
||||||
|
*
|
||||||
|
* @param bean
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping(value = "getProDataUseInfo")
|
||||||
|
public TableDataInfo getProDataUseInfo(ProIdsBean bean) {
|
||||||
|
try {
|
||||||
|
List<ProIdsBean> results = service.getProDataUseInfo(bean);
|
||||||
|
return getDataTable(results);
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error(e.toString(), e);
|
||||||
|
throw new ServiceException("数据查询异常,请联系运维人员查询日志处理");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 查询每个分类机具详情
|
||||||
|
*
|
||||||
|
* @param bean
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping(value = "getMachineDetails")
|
||||||
|
public TableDataInfo getMachineDetails(ProIdsBean bean) {
|
||||||
|
try {
|
||||||
|
List<MachineInfoBean> results = service.getMachineDetails(bean);
|
||||||
|
return getDataTable(results);
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error(e.toString(), e);
|
||||||
|
throw new ServiceException("数据查询异常,请联系运维人员查询日志处理");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 查询七大类设备保有量、在用量、再修量、库存量
|
||||||
|
@GetMapping(value = "getNumsByStatics")
|
||||||
|
public TableDataInfo getNumsByStatics(ProIdsBean bean) {
|
||||||
|
try {
|
||||||
|
List<StaticsNumsBean> results = service.getNumsByStatics(bean);
|
||||||
|
return getDataTable(results);
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error(e.toString(), e);
|
||||||
|
throw new ServiceException("数据查询异常,请联系运维人员查询日志处理");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 检验临期和检验超期数量
|
||||||
|
@GetMapping(value = "getApproachingAndTimeout")
|
||||||
|
public TableDataInfo getApproachingAndTimeout(ProIdsBean bean) {
|
||||||
|
try {
|
||||||
|
List<StaticsNumsBean> results = service.getApproachingAndTimeout(bean);
|
||||||
|
return getDataTable(results);
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error(e.toString(), e);
|
||||||
|
throw new ServiceException("数据查询异常,请联系运维人员查询日志处理");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 临期、超期设备详情
|
||||||
|
@GetMapping(value = "getApproachingDetails")
|
||||||
|
public TableDataInfo getApproachingDetails(ProIdsBean bean) {
|
||||||
|
try {
|
||||||
|
List<MachineInfoBean> results = service.getApproachingDetails(bean);
|
||||||
|
return getDataTable(results);
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error(e.toString(), e);
|
||||||
|
throw new ServiceException("数据查询异常,请联系运维人员查询日志处理");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,44 @@
|
||||||
|
package com.bonus.material.push.domain;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author:liang.chao
|
||||||
|
* @Date:2025/8/23 - 14:35
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class MachineInfoBean {
|
||||||
|
// 设备名称
|
||||||
|
private String typeName;
|
||||||
|
// 规格型号
|
||||||
|
private String typeModelName;
|
||||||
|
// 计量单位
|
||||||
|
private String unit;
|
||||||
|
// 数量
|
||||||
|
private Integer num;
|
||||||
|
// 固定资产编号
|
||||||
|
private String assetsCode;
|
||||||
|
//租赁价格
|
||||||
|
private String rentPrice;
|
||||||
|
//库管员
|
||||||
|
private String typeKeeperName;
|
||||||
|
// 状态
|
||||||
|
private String status;
|
||||||
|
// 实施组织
|
||||||
|
private String deptName;
|
||||||
|
// 工程名称
|
||||||
|
private String proName;
|
||||||
|
// 项目管理部
|
||||||
|
private String proCemter;
|
||||||
|
// 领用时间
|
||||||
|
private String leaseTime;
|
||||||
|
// 到期时间
|
||||||
|
private String expireTime;
|
||||||
|
// 机具编码
|
||||||
|
private String maCode;
|
||||||
|
// 剩余到期天数
|
||||||
|
private Integer daysDiff;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,24 @@
|
||||||
|
package com.bonus.material.push.domain;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author:liang.chao
|
||||||
|
* @Date:2025/8/23 - 14:35
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class ProIdsBean {
|
||||||
|
private List<String> proIds;
|
||||||
|
private Integer proId;
|
||||||
|
private String proName;
|
||||||
|
private Integer typeId;
|
||||||
|
private String typeName;
|
||||||
|
private Integer typeNum;
|
||||||
|
// 1 牵张设备 2 抱杆 3动力设备 4 变电专业设备 5安全工器具 6自主创新设备 7其他
|
||||||
|
private Integer isStatics;
|
||||||
|
|
||||||
|
// 0 检验临期 1 检验超期
|
||||||
|
private Integer type;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
package com.bonus.material.push.domain;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author:liang.chao
|
||||||
|
* @Date:2025/8/23 - 16:29
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class StaticsNumsBean {
|
||||||
|
private Integer inventoryNum;
|
||||||
|
private Integer useNum;
|
||||||
|
private Integer repairNum;
|
||||||
|
private Integer num;
|
||||||
|
// 检验临期数量
|
||||||
|
private Integer ApproachingNum;
|
||||||
|
// 检验超期数量
|
||||||
|
private Integer TimeoutNum;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,32 @@
|
||||||
|
package com.bonus.material.push.mapper;
|
||||||
|
|
||||||
|
import com.bonus.material.push.domain.*;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author : 阮世耀
|
||||||
|
* @version : 1.0
|
||||||
|
* @PackagePath: com.bonus.material.push.mapper
|
||||||
|
* @CreateTime: 2025-01-23 14:40
|
||||||
|
* @Description: i皖送费用推送mapper
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface ProDataUseInfoMapper {
|
||||||
|
|
||||||
|
List<ProIdsBean> getProDataUseInfo(@Param("typeIds") List<Integer> typeIds, @Param("proId") String proId);
|
||||||
|
|
||||||
|
List<Integer> getTypeId();
|
||||||
|
|
||||||
|
List<MachineInfoBean> getMachineDetails(ProIdsBean bean);
|
||||||
|
|
||||||
|
String getTypeKeeperName(MachineInfoBean machineDetail);
|
||||||
|
|
||||||
|
List<StaticsNumsBean> getNumsByStatics(ProIdsBean bean);
|
||||||
|
|
||||||
|
List<StaticsNumsBean> getApproachingAndTimeout(ProIdsBean bean);
|
||||||
|
|
||||||
|
List<MachineInfoBean> getApproachingDetails(ProIdsBean bean);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,23 @@
|
||||||
|
package com.bonus.material.push.service;
|
||||||
|
|
||||||
|
import com.bonus.material.push.domain.ProIdsBean;
|
||||||
|
import com.bonus.material.push.domain.MachineInfoBean;
|
||||||
|
import com.bonus.material.push.domain.StaticsNumsBean;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author:liang.chao
|
||||||
|
* @Date:2025/8/23 - 14:29
|
||||||
|
*/
|
||||||
|
public interface ProDataUseInfoService {
|
||||||
|
List<ProIdsBean> getProDataUseInfo(ProIdsBean bean);
|
||||||
|
|
||||||
|
List<MachineInfoBean> getMachineDetails(ProIdsBean bean);
|
||||||
|
|
||||||
|
List<StaticsNumsBean> getNumsByStatics(ProIdsBean bean);
|
||||||
|
|
||||||
|
List<StaticsNumsBean> getApproachingAndTimeout(ProIdsBean bean);
|
||||||
|
|
||||||
|
List<MachineInfoBean> getApproachingDetails(ProIdsBean bean);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,61 @@
|
||||||
|
package com.bonus.material.push.service.impl;
|
||||||
|
|
||||||
|
import com.bonus.material.push.domain.MachineInfoBean;
|
||||||
|
import com.bonus.material.push.domain.ProIdsBean;
|
||||||
|
|
||||||
|
import com.bonus.material.push.domain.StaticsNumsBean;
|
||||||
|
import com.bonus.material.push.mapper.ProDataUseInfoMapper;
|
||||||
|
import com.bonus.material.push.service.ProDataUseInfoService;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author:liang.chao
|
||||||
|
* @Date:2025/8/23 - 14:30
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class ProDataUseInfoImpl implements ProDataUseInfoService {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private ProDataUseInfoMapper proDataUseInfoMapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<ProIdsBean> getProDataUseInfo(ProIdsBean bean) {
|
||||||
|
List<Integer> typeIds = proDataUseInfoMapper.getTypeId();
|
||||||
|
List<ProIdsBean> results = new ArrayList<>();
|
||||||
|
for (String proId : bean.getProIds()) {
|
||||||
|
List<ProIdsBean> proDataUseInfo = proDataUseInfoMapper.getProDataUseInfo(typeIds, proId);
|
||||||
|
results.addAll(proDataUseInfo);
|
||||||
|
}
|
||||||
|
return results;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<MachineInfoBean> getMachineDetails(ProIdsBean bean) {
|
||||||
|
// 入参 proId /isStatics
|
||||||
|
List<MachineInfoBean> machineDetails = proDataUseInfoMapper.getMachineDetails(bean);
|
||||||
|
for (MachineInfoBean machineDetail : machineDetails) {
|
||||||
|
String typeKeeperName = proDataUseInfoMapper.getTypeKeeperName(machineDetail);
|
||||||
|
machineDetail.setTypeKeeperName(typeKeeperName);
|
||||||
|
}
|
||||||
|
return machineDetails;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<StaticsNumsBean> getNumsByStatics(ProIdsBean bean) {
|
||||||
|
return proDataUseInfoMapper.getNumsByStatics(bean);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<StaticsNumsBean> getApproachingAndTimeout(ProIdsBean bean) {
|
||||||
|
return proDataUseInfoMapper.getApproachingAndTimeout(bean);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<MachineInfoBean> getApproachingDetails(ProIdsBean bean) {
|
||||||
|
return proDataUseInfoMapper.getApproachingDetails(bean);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,135 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<!DOCTYPE mapper
|
||||||
|
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.bonus.material.push.mapper.ProDataUseInfoMapper">
|
||||||
|
|
||||||
|
<select id="getProDataUseInfo" resultType="com.bonus.material.push.domain.ProIdsBean">
|
||||||
|
select
|
||||||
|
bp.pro_name as proName,
|
||||||
|
sum(sai.num) typeNum,
|
||||||
|
mt2.type_id as typeId,
|
||||||
|
bp.pro_id as proId
|
||||||
|
from 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 sai.type_id = mt.type_id
|
||||||
|
left join ma_type mt2 on mt.parent_id = mt2.type_id
|
||||||
|
where sai.is_slt = 0 and sai.end_time is null
|
||||||
|
AND bp.pro_id = #{proId}
|
||||||
|
AND mt2.type_id in
|
||||||
|
<foreach collection="typeIds" item="id" open="(" separator="," close=")">
|
||||||
|
#{id}
|
||||||
|
</foreach>
|
||||||
|
GROUP BY bp.pro_id,mt2.is_statics
|
||||||
|
</select>
|
||||||
|
<select id="getTypeId" resultType="java.lang.Integer">
|
||||||
|
select type_id from ma_type where is_statics in (1,2,3,4,5,6,7)
|
||||||
|
</select>
|
||||||
|
<select id="getMachineDetails" resultType="com.bonus.material.push.domain.MachineInfoBean">
|
||||||
|
select
|
||||||
|
mt.type_id as typeId,
|
||||||
|
mt2.type_name as typeName,
|
||||||
|
mt.type_name as typeModelName,
|
||||||
|
mt.unit_name as unit,
|
||||||
|
sai.num as num,
|
||||||
|
mm.assets_code as assetsCode,
|
||||||
|
mt.rent_price as rentPrice,
|
||||||
|
mm.keeper_name as typeKeeperName,
|
||||||
|
'在用' as status
|
||||||
|
from 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 sai.type_id = mt.type_id
|
||||||
|
left join ma_type mt2 on mt.parent_id = mt2.type_id
|
||||||
|
left join ma_machine mm on mt.type_id = mm.type_id
|
||||||
|
where sai.is_slt = 0 and sai.end_time is null
|
||||||
|
AND bp.pro_id = #{proId}
|
||||||
|
AND mt2.is_statics = #{isStatics}
|
||||||
|
<if test="typeName != null and typeName !=''">
|
||||||
|
AND mt2.type_name = #{typeName}
|
||||||
|
</if>
|
||||||
|
<if test="typeModelName != null and typeModelName !=''">
|
||||||
|
AND mt.type_name = #{typeModelName}
|
||||||
|
</if>
|
||||||
|
GROUP BY bp.pro_id
|
||||||
|
</select>
|
||||||
|
<select id="getTypeKeeperName" resultType="java.lang.String">
|
||||||
|
select su.nick_name from ma_type_keeper mtk
|
||||||
|
left join sys_user su on mtk.user_id = su.user_id
|
||||||
|
where mtk.type_id = #{typeId}
|
||||||
|
</select>
|
||||||
|
<select id="getNumsByStatics" resultType="com.bonus.material.push.domain.StaticsNumsBean">
|
||||||
|
select
|
||||||
|
</select>
|
||||||
|
<select id="getApproachingAndTimeout" resultType="com.bonus.material.push.domain.StaticsNumsBean">
|
||||||
|
SELECT
|
||||||
|
COUNT(CASE
|
||||||
|
WHEN mm.next_check_time BETWEEN NOW() AND DATE_ADD(NOW(), INTERVAL 30 DAY)
|
||||||
|
THEN 1
|
||||||
|
ELSE NULL
|
||||||
|
END) AS ApproachingNum,
|
||||||
|
COUNT(CASE
|
||||||
|
WHEN mm.next_check_time < NOW()
|
||||||
|
THEN 1
|
||||||
|
ELSE NULL
|
||||||
|
END) AS TimeoutNum
|
||||||
|
FROM ma_machine mm
|
||||||
|
LEFT JOIN slt_agreement_info sai on sai.ma_id = mm.ma_id and mm.type_id = sai.type_id and sai.`status`='0' and sai.end_time is null
|
||||||
|
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 sai.type_id = mt.type_id
|
||||||
|
LEFT JOIN ma_type mt2 ON mt.parent_id = mt2.type_id
|
||||||
|
WHERE bp.pro_id = #{proId}
|
||||||
|
AND mm.next_check_time IS NOT NULL
|
||||||
|
GROUP BY bp.pro_id
|
||||||
|
</select>
|
||||||
|
<select id="getApproachingDetails" resultType="com.bonus.material.push.domain.MachineInfoBean">
|
||||||
|
SELECT
|
||||||
|
sd.dept_name,
|
||||||
|
bp.pro_center,
|
||||||
|
bp.pro_name,
|
||||||
|
mt2.type_name as typeName,
|
||||||
|
mt.type_name as typeModelName,
|
||||||
|
mt.unit_name as unit,
|
||||||
|
mm.ma_code as maCode,
|
||||||
|
sai.start_time as leaseTime,
|
||||||
|
mm.next_check_time as expireTime,
|
||||||
|
CASE
|
||||||
|
WHEN #{type} = 0 THEN DATEDIFF(mm.next_check_time, NOW())
|
||||||
|
WHEN #{type} = 1 THEN DATEDIFF(NOW(), mm.next_check_time)
|
||||||
|
ELSE NULL
|
||||||
|
END AS daysDiff
|
||||||
|
FROM ma_machine mm
|
||||||
|
LEFT JOIN slt_agreement_info sai on sai.ma_id = mm.ma_id and mm.type_id = sai.type_id and sai.`status`='0' and sai.end_time is null
|
||||||
|
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 sys_dept sd on bp.imp_unit = sd.dept_id
|
||||||
|
LEFT JOIN ma_type mt ON sai.type_id = mt.type_id
|
||||||
|
LEFT JOIN ma_type mt2 ON mt.parent_id = mt2.type_id
|
||||||
|
WHERE bp.pro_id = #{proId}
|
||||||
|
AND mm.next_check_time IS NOT NULL
|
||||||
|
<if test="type != null and type == 0">
|
||||||
|
AND mm.next_check_time BETWEEN NOW() AND DATE_ADD(NOW(), INTERVAL 30 DAY)
|
||||||
|
</if>
|
||||||
|
<if test="type != null and type == 1">
|
||||||
|
AND mm.next_check_time < NOW()
|
||||||
|
</if>
|
||||||
|
<if test="deptName != null and deptName !=''">
|
||||||
|
AND sd.dept_name like concat ('%', #{deptName}, '%')
|
||||||
|
</if>
|
||||||
|
<if test="proCenter != null and proCenter !=''">
|
||||||
|
AND bp.pro_center like concat ('%', #{proCenter}, '%')
|
||||||
|
</if>
|
||||||
|
<if test="proName != null and proName !=''">
|
||||||
|
AND bp.pro_name like concat ('%', #{proName}, '%')
|
||||||
|
</if>
|
||||||
|
<if test="typeName != null and typeName !=''">
|
||||||
|
AND mt2.type_name = #{typeName}
|
||||||
|
</if>
|
||||||
|
<if test="typeModelName != null and typeModelName !=''">
|
||||||
|
AND mt.type_name = #{typeModelName}
|
||||||
|
</if>
|
||||||
|
GROUP BY bp.pro_id
|
||||||
|
</select>
|
||||||
|
</mapper>
|
||||||
Loading…
Reference in New Issue