问题修改

This commit is contained in:
jiang 2025-10-13 21:54:40 +08:00
parent 01a103ab71
commit 057da98918
7 changed files with 128 additions and 103 deletions

View File

@ -310,4 +310,22 @@ public class MaDevInfo {
*/
private String orderStatus;
private String daysDiff;
private String remainingDays;
private String remainingYears;
private String yearsDiff;
private String expirationYears;
private String actualStartYear;
private String remainingStartYear;
private String isWarn;
private String entryStatus;
}

View File

@ -121,6 +121,19 @@ public class DevMergeController extends BaseController {
}
}
@ApiOperation(value = "设备台账")
@GetMapping("/getDeviceByOrderId")
public AjaxResult getDeviceByOrderId(MaDevInfo o) {
try {
startPage();
List<MaDevInfo> list = service.getDeviceByOrderId(o);
return AjaxResult.success(getDataTable(list));
} catch (Exception e) {
logger.error("报错啦", e);
return AjaxResult.error("调用异常,请联系管理员");
}
}
/**
* 获取台账中设备信息详细信息
@ -186,9 +199,6 @@ public class DevMergeController extends BaseController {
}
/**
* 获取台账中设备信息详细信息
*/
@ -209,11 +219,6 @@ public class DevMergeController extends BaseController {
}
/**
* 查询所有一级类型顶级类型
*

View File

@ -65,4 +65,7 @@ public interface DevMergeService {
AjaxResult interDevice(MaDevInfo maDevInfo);
List<MaDevInfo> getDevice(MaDevInfo o);
List<MaDevInfo> getDeviceByOrderId(MaDevInfo o);
}

View File

@ -224,6 +224,9 @@ public class DevMergeServiceImpl implements DevMergeService {
public AjaxResult interDevice(MaDevInfo maDevInfo) {
try {
Integer i = devMergeMapper.interDevice(maDevInfo);
if (i > 0) {
devMergeMapper.insertOrderDevReal(String.valueOf(maDevInfo.getOrderId()), Long.valueOf(maDevInfo.getMaId()));
}
return i > 0 ? AjaxResult.success() : AjaxResult.error();
} catch (Exception e) {
log.error(e.getMessage());
@ -254,6 +257,27 @@ public class DevMergeServiceImpl implements DevMergeService {
}
/**
* @param o
* @return
*/
@Override
public List<MaDevInfo> getDeviceByOrderId(MaDevInfo o) {
List<MaDevInfo> list = devMergeMapper.getDeviceByOrderId(o);
list.forEach(item -> {
List<DevInfoPropertyVo> propertiiesList = mapper.getProperties(item);
if (propertiiesList != null && !propertiiesList.isEmpty()) {
item.setPropertyVoList(propertiiesList);
}
item.setAppearanceImages(mapper.getFileList(item.getMaId(), 1));
item.setCertificates(mapper.getFileList(item.getMaId(), 2));
item.setInspectionReports(mapper.getFileList(item.getMaId(), 3));
item.setPurchaseInvoices(mapper.getFileList(item.getMaId(), 4));
});
return list;
}
private static final DateTimeFormatter DATE_FORMATTER = DateTimeFormatter.ofPattern("yyMMdd");
private static final String SEPARATOR = "-";

View File

@ -423,7 +423,7 @@
LEFT JOIN sys_dept sd ON sd.dept_id = mdi.on_company
LEFT JOIN ma_dev_qc mdq ON mdq.ma_id = mdi.ma_id
<where>
mdi.is_active = '0' AND mdi.ma_id =#{maId}
mdi.is_active = '1' AND mdi.ma_id =#{maId}
</where>
</select>
</mapper>

View File

@ -1,86 +1,72 @@
<?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.devchange.mapper.MaDevRetireWarningMapper">
<resultMap id="BaseResultMap" type="com.bonus.material.devchange.domain.MaDevInfo">
<result column="brand" property="brand"/>
<result column="code" property="code"/>
<result column="company_name" property="companyName"/>
<result column="days_diff" property="daysDiff"/>
<result column="device_name" property="deviceName"/>
<result column="device_status" property="deviceStatus"/>
<result column="expiration_time" property="expirationTime"/>
<result column="ma_id" property="maId"/>
<result column="production_date" property="productionDate"/>
<result column="remaining_days" property="remainingDays"/>
<result column="remaining_years" property="remainingYears"/>
<result column="years_diff" property="yearsDiff"/>
<result column="expiration_years" property="expirationYears"/>
</resultMap>
<select id="list" resultMap="BaseResultMap">
select * from (
SELECT
c.company_name,
mdi.ma_id,
mdi.device_name,
mdi.`code`,
mdi.brand,
mdi.production_date,
mdi.expiration_time,
IF(STR_TO_DATE(production_date, '%Y-%m-%d') IS NOT NULL AND STR_TO_DATE(expiration_time, '%Y-%m-%d') IS NOT NULL, TIMESTAMPDIFF(YEAR, STR_TO_DATE(production_date,
'%Y-%m-%d'), expiration_time), 0) AS expiration_years,
IF(STR_TO_DATE(production_date, '%Y-%m-%d') IS NOT NULL, DATEDIFF(CURDATE(), STR_TO_DATE(production_date,
'%Y-%m-%d')), 0) AS days_diff,
IF(STR_TO_DATE(production_date, '%Y-%m-%d') IS NOT NULL, TIMESTAMPDIFF(YEAR, STR_TO_DATE(production_date,
'%Y-%m-%d'), CURDATE()), 0) AS years_diff,
IF(STR_TO_DATE(expiration_time, '%Y-%m-%d') IS NOT NULL
AND STR_TO_DATE(expiration_time, '%Y-%m-%d') >= CURDATE(), DATEDIFF(STR_TO_DATE(expiration_time, '%Y-%m-%d'),
CURDATE()), 0) AS remaining_days,
IF(STR_TO_DATE(expiration_time, '%Y-%m-%d') IS NOT NULL
AND STR_TO_DATE(expiration_time, '%Y-%m-%d') >= CURDATE(), TIMESTAMPDIFF(YEAR, CURDATE(),
STR_TO_DATE(expiration_time, '%Y-%m-%d')), 0) AS remaining_years,
CASE
WHEN STR_TO_DATE(expiration_time, '%Y-%m-%d') IS NOT NULL
<select id="list" resultType="com.bonus.material.devchange.domain.MaDevInfo">
select * from (
SELECT
c.company_name AS propertyUnit,
mdi.ma_id AS maId,
mdi.device_name AS name,
mdi.`code` AS code,
mdi.brand AS manufacturer,
mdi.production_date AS productionDate,
mdi.expiration_time AS expirationTime,
IF(STR_TO_DATE(production_date, '%Y-%m-%d') IS NOT NULL AND STR_TO_DATE(expiration_time, '%Y-%m-%d') IS NOT
NULL,
TIMESTAMPDIFF(YEAR, STR_TO_DATE(production_date,
'%Y-%m-%d'), expiration_time), 0) AS expirationYears,
IF(STR_TO_DATE(production_date, '%Y-%m-%d') IS NOT NULL, DATEDIFF(CURDATE(), STR_TO_DATE(production_date,
'%Y-%m-%d')), 0) AS daysDiff,
IF(STR_TO_DATE(production_date, '%Y-%m-%d') IS NOT NULL, TIMESTAMPDIFF(YEAR, STR_TO_DATE(production_date,
'%Y-%m-%d'), CURDATE()), 0) AS yearsDiff,
IF(STR_TO_DATE(expiration_time, '%Y-%m-%d') IS NOT NULL
AND STR_TO_DATE(expiration_time, '%Y-%m-%d') >= CURDATE(), DATEDIFF(STR_TO_DATE(expiration_time, '%Y-%m-%d'),
CURDATE()), 0) AS remainingDays,
IF(STR_TO_DATE(expiration_time, '%Y-%m-%d') IS NOT NULL
AND STR_TO_DATE(expiration_time, '%Y-%m-%d') >= CURDATE(), TIMESTAMPDIFF(YEAR, CURDATE(),
STR_TO_DATE(expiration_time, '%Y-%m-%d')), 0) AS remainingYears,
CASE
WHEN STR_TO_DATE(expiration_time, '%Y-%m-%d') IS NOT NULL
AND DATEDIFF(STR_TO_DATE(expiration_time, '%Y-%m-%d'), CURDATE()) > 365
THEN '正常使用'
WHEN STR_TO_DATE(expiration_time, '%Y-%m-%d') IS NOT NULL
WHEN STR_TO_DATE(expiration_time, '%Y-%m-%d') IS NOT NULL
AND DATEDIFF(STR_TO_DATE(expiration_time, '%Y-%m-%d'), CURDATE()) > 0
AND DATEDIFF(STR_TO_DATE(expiration_time, '%Y-%m-%d'), CURDATE()) &lt;= 365
THEN CONCAT('临近', DATEDIFF(STR_TO_DATE(expiration_time, '%Y-%m-%d'), CURDATE()), '天退役')
WHEN STR_TO_DATE(expiration_time, '%Y-%m-%d') IS NOT NULL
AND STR_TO_DATE(expiration_time, '%Y-%m-%d') &lt;= CURDATE()
THEN '已过期'
ELSE '日期无效'
END AS device_status
FROM
ma_dev_info mdi
LEFT JOIN sys_dept sd ON sd.dept_id = mdi.on_company
LEFT JOIN bm_company_info c ON sd.dept_id = c.company_id
WHERE mdi.is_active = 1 and mdi.entry_status = '1' and mdi.change_status in (1,5)
<if test="deviceName != null and deviceName != ''">
AND mdi.device_name like concat('%',#{deviceName},'%')
</if>
<if test="brand != null and brand != ''">
AND mdi.brand like concat('%',#{brand},'%')
</if>
) a
<where>
<if test="actualStartYear != null and actualStartYear != ''">
and years_diff between #{actualStartYear} and #{actualStopYear}
</if>
<if test="remainingStartYear != null and remainingStartYear != ''">
and remaining_years between #{remainingStartYear} and #{remainingStopYear}
</if>
<if test="isWarn != null and isWarn != ''">
<if test="isWarn == 1">
AND device_status != '正常使用'
THEN CONCAT('临近', DATEDIFF(STR_TO_DATE(expiration_time, '%Y-%m-%d'), CURDATE()), '天退役')
WHEN STR_TO_DATE(expiration_time, '%Y-%m-%d') IS NOT NULL
AND STR_TO_DATE(expiration_time, '%Y-%m-%d') &lt;= CURDATE()
THEN '已过期'
ELSE '日期无效'
END AS status
FROM
ma_dev_info mdi
LEFT JOIN sys_dept sd ON sd.dept_id = mdi.on_company
LEFT JOIN bm_company_info c ON sd.dept_id = c.company_id
WHERE mdi.is_active = 1 and mdi.entry_status = '1' and mdi.change_status in (1,5)
<if test="name != null and name != ''">
AND mdi.device_name like concat('%',#{deviceName},'%')
</if>
<if test="isWarn == 0">
AND device_status = '正常使用'
<if test="manufacturer != null and manufacturer != ''">
AND mdi.manufacturer like concat('%',#{manufacturer},'%')
</if>
</if>
</where>
</select>
) a
<where>
<if test="actualStartYear != null and actualStartYear != ''">
and years_diff between #{actualStartYear} and #{actualStopYear}
</if>
<if test="remainingStartYear != null and remainingStartYear != ''">
and remaining_years between #{remainingStartYear} and #{remainingStopYear}
</if>
<if test="isWarn != null and isWarn != ''">
<if test="isWarn == 1">
AND device_status != '正常使用'
</if>
<if test="isWarn == 0">
AND device_status = '正常使用'
</if>
</if>
</where>
</select>
</mapper>

View File

@ -80,10 +80,8 @@
INSERT INTO cs_device_real_dev (cs_id, dev_id)
VALUES (#{orderId}, #{maId})
</insert>
<insert id="interDevice">
<insert parameterType="com.bonus.material.devchange.domain.MaDevInfo" id="interDevice" useGeneratedKeys="true" keyProperty="maId">
INSERT INTO ma_dev_info (
<!-- 主键ma_id自增若手动传值可保留否则删除 -->
<if test="maId != null">ma_id,</if>
<!-- 必选字段若业务要求必须传值可去掉if判断 -->
device_name,
device_count,
@ -93,24 +91,18 @@
<!-- 非必填字段:有值才插入 -->
<if test="originalCode != null and originalCode != ''">identify_code,</if>
<if test="typeId != null">type_id,</if>
<if test="status != null and status != ''">ma_status,</if>
<if test="manufacturerId != null and manufacturerId != ''">brand,</if>
<if test="productionDate != null">production_date,</if>
<if test="maxServiceLifeYears != null">max_working_hours,</if>
<if test="expirationTime != null">expiration_time,</if>
<if test="originalValue != null">buy_price,</if>
<if test="deviceType != null and deviceType != ''">device_type,</if>
<if test="purchaseDate != null">purchase_date,</if>
<if test="createTime != null and createTime != ''">create_time,</if>
<if test="creator != null">creator,</if>
<if test="updateTime != null">update_time,</if>
<if test="updateBy != null">update_by,</if>
<!-- 默认值字段:无值时插入默认值'1'(未删除) -->
is_active
is_active,
change_status,
up_down_status
)
VALUES (
<if test="maId != null">#{maId},</if>
<!-- 必选字段对应值 -->
#{name},
#{count},
#{specificationModel},
@ -122,17 +114,13 @@
<if test="manufacturerId != null and manufacturerId != ''">#{manufacturerId},</if>
<if test="productionDate != null">#{productionDate},</if>
<if test="maxServiceLifeYears != null">#{maxServiceLifeYears},</if>
<if test="changeStatus != null and changeStatus != ''">#{changeStatus},</if>
<if test="expirationTime != null">#{expirationTime},</if>
<if test="originalValue != null">#{originalValue},</if>
<if test="deviceType != null and deviceType != ''">#{deviceType},</if>
<if test="purchaseDate != null">#{purchaseDate},</if>
<if test="createTime != null and createTime != ''">#{createTime},</if>
<if test="creator != null">#{creator},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<!-- 默认值:即使实体类无该属性,也插入'1' -->
#{isActive,jdbcType=VARCHAR,defaultValue='1'}
'1',
'3',
'0'
)
</insert>
@ -290,6 +278,7 @@
mdi.item_type_model As specificationModel,
mdi.code AS code,
mdi.change_status AS status,
mdi.entry_status AS entryStatus,
TIMESTAMPDIFF(YEAR, mdi.production_date, CURDATE()) AS serviceLife,
jsp.pro_code AS usingProjectId,
jsp.pro_name AS usingProject,
@ -397,7 +386,7 @@
LEFT JOIN ma_dev_qc mdq ON mdq.ma_id = mdi.ma_id
LEFT JOIN ma_supplier ms ON ms.supplier_id = mdi.brand
<where>
mdi.is_active = '0' and cds.id = #{orderId}
mdi.is_active = '1' and cds.id = #{orderId}
<if test="name != null and name != ''">
and mdi.device_name like concat('%', #{name}, '%')
</if>