问题修改

This commit is contained in:
jiang 2025-11-27 16:28:28 +08:00
parent 0635c72f1f
commit c4c2d764a4
13 changed files with 431 additions and 40 deletions

View File

@ -60,7 +60,7 @@ public class BackCsDeviceDetails {
private BigDecimal num = BigDecimal.ZERO;
@ApiModelProperty(value = "使用到期日期")
private Date useTime;
private LocalDate useTime;
@ApiModelProperty(value = "使用到期日期开始")
private LocalDate useStartTime;

View File

@ -326,7 +326,6 @@ public class MaDevInfoController extends BaseController {
headerMap.put("featureItem" + i, "特征项" + i); // 如featureItem1"特征项1"
headerMap.put("featureValue" + i, "特征值" + i); // 如featureValue1"特征值1"
}
return headerMap;
}

View File

@ -0,0 +1,126 @@
package com.bonus.material.devchange.domain;
import com.bonus.common.core.annotation.Excel;
import lombok.Data;
@Data
public class CsDeviceChange {
/**
* 地市权限id
*/
private String deptId;
private Integer pageNum;
private Integer pageSize;
/**
* 退役原因
*/
private String reasonId;
/**
* 退役原因
*/
private String reasonVal;
/**
* 主键
*/
private String id;
/**
* 变更状前状态
*/
//@Excel(name = "流转前状态", width = 20, sort = 4)
private String changeStatusName;
private String changeStatus;
/**
* 类型
* 变更类型 1入库 2出库 3 退役 4 维修
*/
@Excel(name = "操作类型", width = 25, sort = 2)
private String typeName;
private String type;
/**
* 变更状态 0自用 1共享
*/
private String status;
private String lease_type;
/**
* 工程编码
*/
private String proCode;
/**
* 工程名称
*/
private String proName;
/**
* 工程类型
*/
private String proType;
/**
* 设备数量
*/
@Excel(name = "设备数量", width = 25, sort = 9)
private String devNum;
/**
* 电压等级
*/
private String voltageLevel;
/**
* 使用单位
*/
private String useUint;
/**
*
*/
private String proProvince;
/**
*
*/
private String proCity;
/**
*
*/
private String proCounty;
/**
* 详细地址
*/
private String proLocation;
/**
* 创建时间
*/
@Excel(name = "操作时间", width = 25, sort = 2)
private String createTime;
/**
* 创建人
*/
@Excel(name = "操作人", width = 20, sort = 1)
private String createUser;
/**
* 使用人
*/
private String userName;
/**
* 联系方式
*/
private String userPhone;
private String jsonData;
private String devId;
/**
* 变更前单位
*/
private String changeUnit;
private String keyWord;
private String startTime;
private String endTime;
private String useTime;
}

View File

@ -0,0 +1,216 @@
package com.bonus.material.devchange.domain;
import com.bonus.common.core.annotation.Excel;
import com.bonus.material.device.domain.vo.DevInfoPropertyVo;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
/**
* 装备实体类
* 存储装备的详细信息包括基本属性状态使用情况文档资料等
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class MaDevInfoXlsx {
/**
* 设备id不导出无注解
*/
private Integer maId;
/**
* 所属省份
*/
@Excel(name = "所属省份") // 对应headerMap的key=province
private String province;
/**
* 专业
*/
@Excel(name = "专业") // 对应headerMap的key=major
private String major;
/**
* 工序用子工序映射可根据实际调整
*/
@Excel(name = "工序") // 对应headerMap的key=process
private String subProcess;
/**
* 装备类目用小类目映射
*/
@Excel(name = "装备类目") // 对应headerMap的key=devType
private String subCategory;
/**
* 类型分支用装备分支映射
*/
@Excel(name = "类型分支") // 对应headerMap的key=name
private String branch;
/**
* 规格型号
*/
@Excel(name = "规格型号") // 对应headerMap的key=specificationModel
private String specificationModel;
/**
* 装备编码
*/
@Excel(name = "装备编码") // 对应headerMap的key=code
private String code;
/**
* 装备状态
*/
@Excel(name = "装备状态") // 对应headerMap的key=status
private String status;
/**
* 上下架状态
*/
@Excel(name = "上下架状态") // 对应headerMap的key=upDownStatus
private String upDownStatus;
/**
* 使用年限
*/
@Excel(name = "使用年限") // 对应headerMap的key=serviceLife
private String serviceLife;
private String usingProjectId;
/**
* 使用项目
*/
@Excel(name = "使用项目") // 对应headerMap的key=usingProject
private String usingProject;
/**
* 使用到期时间Hutool会自动格式化日期
*/
@Excel(name = "使用到期时间") // 对应headerMap的key=expirationTime
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
private Date expirationTime;
/**
* 使用次数
*/
@Excel(name = "使用次数") // 对应headerMap的key=usageCount
private Integer usageCount;
/**
* 维修次数
*/
@Excel(name = "维修次数") // 对应headerMap的key=repairCount
private Integer repairCount;
/**
* 装备原始编码
*/
@Excel(name = "装备原始编码") // 对应headerMap的key=originalCode
private String originalCode;
/**
* 计量单位
*/
@Excel(name = "计量单位") // 对应headerMap的key=unit
private String unit;
private Integer manufacturerId;
/**
* 生产厂家
*/
@Excel(name = "生产厂家") // 对应headerMap的key=manufacturer
private String manufacturer;
/**
* 出厂日期
*/
@Excel(name = "出厂日期") // 对应headerMap的key=productionDate
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
private Date productionDate;
/**
* 采购日期
*/
@Excel(name = "采购日期") // 对应headerMap的key=purchaseDate
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
private Date purchaseDate;
/**
* 资产原值
*/
@Excel(name = "资产原值(元)") // 对应headerMap的key=originalValue
private BigDecimal originalValue;
/**
* 最大使用年限
*/
@Excel(name = "最大使用年限(年)") // 对应headerMap的key=maxServiceLifeYears
private Integer maxServiceLifeYears;
/**
* 下次维保日期
*/
@Excel(name = "下次维保日期") // 对应headerMap的key=nextMaintenanceDate
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
private Date nextMaintenanceDate;
/**
* 产权单位
*/
@Excel(name = "产权单位") // 对应headerMap的key=propertyUnit
private String propertyUnit;
@Excel(name = "特征项1")
private String propertyName1;
/**
* 属性值
*/
@Excel(name = "特征值1")
private String propertyValue1;
@Excel(name = "特征项2")
private String propertyName2;
/**
* 属性值
*/
@Excel(name = "特征值2")
private String propertyValue2;
@Excel(name = "特征项3")
private String propertyName3;
/**
* 属性值
*/
@Excel(name = "特征值3")
private String propertyValue3;
@Excel(name = "特征项4")
private String propertyName4;
/**
* 属性值
*/
@Excel(name = "特征值4")
private String propertyValue4;
@Excel(name = "特征项5")
private String propertyName5;
/**
* 属性值
*/
@Excel(name = "特征值5")
private String propertyValue5;
@Excel(name = "特征项6")
private String propertyName6;
/**
* 属性值
*/
@Excel(name = "特征值6")
private String propertyValue6;
@Excel(name = "特征项7")
private String propertyName7;
/**
* 属性值
*/
@Excel(name = "特征值7")
private String propertyValue7;
@Excel(name = "特征项8")
private String propertyName8;
/**
* 属性值
*/
@Excel(name = "特征值8")
private String propertyValue8;
@Excel(name = "特征项9")
private String propertyName9;
/**
* 属性值
*/
@Excel(name = "特征值9")
private String propertyValue9;
}

View File

@ -48,5 +48,7 @@ public interface MaDevInfoMapper {
//查询装备总数
Integer selectTotalDeviceCount();
List<DevInfoPropertyVo> batchGetProperties( @Param("mainIds") List<Integer> mainIds);
}

View File

@ -152,4 +152,6 @@ public interface DevChangeService {
AjaxResult outCancelAll(CsDeviceDetails entity);
AjaxResult outAll(CsDeviceDetails entity);
List<CsDeviceChange> getDevChangeRList(CsDeviceChange csDeviceChange);
}

View File

@ -128,16 +128,36 @@ public class MaDevInfoServiceImpl implements MaDevInfoService {
public List<MaDevInfo> export(MaDevInfo o) {
/* Long thisLoginUserDeptId = SecurityUtils.getLoginUser().getSysUser().getDeptId();
o.setPropertyUnitId(Math.toIntExact(thisLoginUserDeptId));*/
List<MaDevInfo> list = mapper.list(o);
list.forEach(item -> {
List<DevInfoPropertyVo> propertiiesList = mapper.getProperties(item);
if (propertiiesList != null && !propertiiesList.isEmpty()) {
item.setPropertyVoList(propertiiesList);
}
// 1. 一次性查询所有主表数据1次查询
List<MaDevInfo> mainList = mapper.list(o);
if (mainList.isEmpty()) {
return Collections.emptyList(); // 空数据直接返回避免后续无效操作
}
// 2. 收集所有主表ID用于批量查关联属性
List<Integer> mainIds = mainList.stream()
.map(MaDevInfo::getMaId) // 假设主表主键是idLong类型根据实际字段调整
.filter(Objects::nonNull) // 过滤空ID防止查询异常
.collect(Collectors.toList());
// 3. 一次性批量查询所有关联属性1次查询替代原N次循环查询
List<DevInfoPropertyVo> allProperties = mapper.batchGetProperties(mainIds);
// 4. 用Map分组关联属性key=主表IDvalue=该主表对应的所有属性内存关联核心
Map<Integer, List<DevInfoPropertyVo>> propertyMap = allProperties.stream()
.collect(Collectors.groupingBy(DevInfoPropertyVo::getMaId)); // 按关联字段dev_id分组
// 5. 批量给主表对象设置属性列表无循环查库纯内存操作
mainList.forEach(main -> {
// 若主表ID无对应属性返回空集合避免null
List<DevInfoPropertyVo> properties = propertyMap.getOrDefault(main.getMaId(), Collections.emptyList());
main.setPropertyVoList(properties);
});
return list;
return mainList;
}
/**
* 将扁平列表构建成树并添加一个总的根节点根节点名称包含设备总数
*/

View File

@ -7,6 +7,8 @@ import lombok.Data;
@Data
public class DevInfoPropertyVo {
private Integer id;
private Integer maId;
/**
* 属性名称
*/

View File

@ -91,6 +91,8 @@ public class ToolEntity implements Serializable {
*/
private LocalDateTime updateTime;
private String fileList;
// 子节点列表非数据库字段用于构建树形结构
private List<ToolEntity> children = new ArrayList<>();

View File

@ -130,7 +130,7 @@
cds.pro_province AS proProvince,
cds.pro_city AS proCity,
cds.pro_county AS proCounty,
cds.pro_location AS proLocation,
CONCAT_WS('·', cds.pro_province, cds.pro_city, cds.pro_county) AS proLocation,
cds.create_time AS createTime,
cds.create_user AS createUser,
cds.del_flag,
@ -149,7 +149,7 @@
ELSE '未知'
END AS changeStatusName,
CASE
WHEN cds.type = 1 THEN '库'
WHEN cds.type = 1 THEN '退库'
WHEN cds.type = 2 THEN '出库'
WHEN cds.type = 3 THEN '退役'
WHEN cds.type = 4 THEN '维修'

View File

@ -481,5 +481,19 @@
SELECT COUNT(1)
FROM ma_dev_info WHERE is_active = '1' and entry_status = '1'
</select>
<select id="batchGetProperties" resultType="com.bonus.material.device.domain.vo.DevInfoPropertyVo">
select mtp.id AS id,
mdip.ma_id AS maId,
mdip.property_name propertyName,
mdip.property_value propertyValue,
mtp.property_value AS value,
mtp.input_type AS inputType
from ma_dev_info_properties mdip
LEFT JOIN ma_type_properties mtp ON mtp.id = mdip.property_id
WHERE mdip.ma_id IN
<foreach collection="mainIds" item="id" open="(" separator="," close=")">
#{id}
</foreach>
</select>
</mapper>

View File

@ -146,7 +146,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
UNION ALL
(
SELECT
tl.fileList AS picUrl, -- 1. 对应第一部分 picUrl
SUBSTRING_INDEX(tt.fileList, ',', 1) AS picUrl, -- 1. 对应第一部分 picUrl
'' AS proType, -- 2. 对应 proType
'' AS mainGx, -- 3. 对应 mainGx
'' AS childGx, -- 4. 对应 childGx
@ -1593,33 +1593,33 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
from jj_sing_project
</select>
<select id="selectToolByMaId" resultType="com.bonus.material.device.domain.vo.DevInfoVo">
SELECT tl.fileList AS picUrl, -- 1. 对应第一部分 picUrl
'' AS proType, -- 2. 对应 proType
'' AS mainGx, -- 3. 对应 mainGx
'' AS childGx, -- 4. 对应 childGx
'' AS devCategory, -- 5. 对应 devCategory
'' AS devSubcategory, -- 6. 对应 devSubcategory
tt.type_name AS typeName, -- 7. 对应 devName
'1' AS devType, -- 8. 对应 devType
tl.manage_mode AS manageMode, -- 9. 对应 manageMode与第一部分位置一致
tl.id AS maId, -- 10. 对应 maId
tl.tool_code AS `code`, -- 11. 对应 code
tl.identify_code AS identifyCode, -- 12. 对应 identifyCode
tt1.type_name AS deviceName, -- 13. 对应 deviceName
tl.available_num AS deviceCount, -- 14. 对应 deviceCount
tl.type_id AS typeId, -- 15. 对应 typeId
tl.STATUS AS maStatus, -- 16. 对应 maStatus
'' AS brand, -- 17. 对应 brand
tl.production_date AS productionDate, -- 18. 对应 productionDate
0 AS workingHours, -- 19. 对应 workingHours
sd.leader AS person, -- 20. 对应 person
sd.phone AS personPhone, -- 21. 对应 personPhone
tl.create_time AS createTime, -- 22. 对应 createTime
tl.update_time AS updateTime, -- 23. 对应 updateTime
tl.company_id AS companyId, -- 24. 对应 companyId
sd.dept_name AS companyName, -- 25. 对应 companyName
c.operate_address AS operateAddress, -- 26. 对应 operateAddress列数对齐
tt.create_time AS companyCreateTime
SELECT SUBSTRING_INDEX(tt.fileList, ',', 1) AS picUrl, -- 1. 对应第一部分 picUrl
'' AS proType, -- 2. 对应 proType
'' AS mainGx, -- 3. 对应 mainGx
'' AS childGx, -- 4. 对应 childGx
'' AS devCategory, -- 5. 对应 devCategory
'' AS devSubcategory, -- 6. 对应 devSubcategory
tt.type_name AS typeName, -- 7. 对应 devName
'1' AS devType, -- 8. 对应 devType
tl.manage_mode AS manageMode, -- 9. 对应 manageMode与第一部分位置一致
tl.id AS maId, -- 10. 对应 maId
tl.tool_code AS `code`, -- 11. 对应 code
tl.identify_code AS identifyCode, -- 12. 对应 identifyCode
tt1.type_name AS deviceName, -- 13. 对应 deviceName
tl.available_num AS deviceCount, -- 14. 对应 deviceCount
tl.type_id AS typeId, -- 15. 对应 typeId
tl.STATUS AS maStatus, -- 16. 对应 maStatus
'' AS brand, -- 17. 对应 brand
tl.production_date AS productionDate, -- 18. 对应 productionDate
0 AS workingHours, -- 19. 对应 workingHours
sd.leader AS person, -- 20. 对应 person
sd.phone AS personPhone, -- 21. 对应 personPhone
tl.create_time AS createTime, -- 22. 对应 createTime
tl.update_time AS updateTime, -- 23. 对应 updateTime
tl.company_id AS companyId, -- 24. 对应 companyId
sd.dept_name AS companyName, -- 25. 对应 companyName
c.operate_address AS operateAddress, -- 26. 对应 operateAddress列数对齐
tt.create_time AS companyCreateTime
FROM tool_ledger tl
LEFT JOIN sys_dept sd ON tl.company_id = sd.dept_id

View File

@ -9,6 +9,7 @@
<if test="unitName != null and unitName != ''">unit_name,</if>
<if test="manageType != null and manageType != ''">manage_type,</if>
<if test="level != null and level != ''">level,</if>
<if test="fileList != null and fileList != ''">fileList,</if>
del_flag,
create_by,
create_time,
@ -20,6 +21,7 @@
<if test="unitName != null and unitName != ''">#{unitName},</if>
<if test="manageType != null and manageType != ''">#{manageType},</if>
<if test="level != null and level != ''">#{level},</if>
<if test="fileList != null and fileList != ''">#{fileList},</if>
'0',
#{createBy},
now(),
@ -55,6 +57,10 @@
<if test="level != null and level != ''">
level = #{level},
</if>
<if test="fileList != null and fileList != ''">
fileList = #{fileList},
</if>
<!-- 更新人:非空且非空字符串才更新 -->
<if test="updateBy != null and updateBy != ''">
update_by = #{updateBy},
@ -107,6 +113,7 @@
tt.unit_name AS unitName,
tt.manage_type AS manageType,
tt.level AS level,
tt.fileList AS fileList,
tt1.type_name AS parentTypeName, -- 1级父节点名称
tt2.type_name AS grandparentTypeName, -- 2级父节点名称
tt3.type_name AS greatGrandparentName, -- 3级父节点名称
@ -153,7 +160,8 @@
create_by AS createBy,
create_time AS createTime,
update_by AS updateBy,
update_time AS updateTime
update_time AS updateTime,
fileList AS fileList
FROM tool_type
WHERE type_id = #{typeId} -- 传入的主键ID
AND del_flag = '0' -- 只查询未删除的记录(逻辑删除校验)