问题修改

This commit is contained in:
jiang 2025-12-30 23:29:41 +08:00
parent ca933e56e0
commit 2d5acdce92
11 changed files with 76 additions and 107 deletions

View File

@ -205,4 +205,7 @@ public class OrderInfoDto {
@ApiModelProperty(value = "买方所属公司")
private Long buyerCompanyId;
private String pageType;
}

View File

@ -541,7 +541,11 @@ public class OrderServiceImpl implements OrderService {
if (userId != null && deptId != null
&& !userId.equals(ADMIN_ID)
&& !deptId.equals(PROVINCE_COMPANY_DEPT_ID)) {
devInfo.setBuyerCompany(deptId.intValue());
if ("1".equals(devInfo.getPageType())) {
devInfo.setBuyerCompany(deptId.intValue());
} else {
devInfo.setSellerCompany(deptId.intValue());
}
}
List<OrderInfoDto> orderInfoDtos = orderMapper.getOrderDetails(devInfo);
@ -568,18 +572,18 @@ public class OrderServiceImpl implements OrderService {
list.removeIf(Objects::isNull);
dto.setDetailsList(list);
if (!list.isEmpty()) {
Optional<OrderDetailDto> minOrderStatus = list.stream().min(Comparator.comparingInt(p -> Integer.parseInt(p.getOrderStatus())));
minOrderStatus.ifPresent(orderDetailDto -> dto.setOrderStatus(orderDetailDto.getOrderStatus()));
//根据订单id去lease_repair_record表中查询是否已填写退租检修信息
int count = leaseRepairRecordMapper.selectLeaseContent(String.valueOf(dto.getOrderId()));
if (count > 0) {
dto.setIsLeaseContent(1);
} else {
dto.setIsLeaseContent(0);
}
dto.setPartBacked(list.stream().anyMatch(o -> OrderStatusEnum.ORDER_UNDER_LEASE.getStatus().toString().equals(o.getOrderStatus())));
LeaseRepair leaseRepair = new LeaseRepair();
leaseRepair.setOrderId(String.valueOf(dto.getOrderId()));
Optional<OrderDetailDto> minOrderStatus = list.stream().min(Comparator.comparingInt(p -> Integer.parseInt(p.getOrderStatus())));
minOrderStatus.ifPresent(orderDetailDto -> dto.setOrderStatus(orderDetailDto.getOrderStatus()));
//根据订单id去lease_repair_record表中查询是否已填写退租检修信息
int count = leaseRepairRecordMapper.selectLeaseContent(String.valueOf(dto.getOrderId()));
if (count > 0) {
dto.setIsLeaseContent(1);
} else {
dto.setIsLeaseContent(0);
}
dto.setPartBacked(list.stream().anyMatch(o -> OrderStatusEnum.ORDER_UNDER_LEASE.getStatus().toString().equals(o.getOrderStatus())));
LeaseRepair leaseRepair = new LeaseRepair();
leaseRepair.setOrderId(String.valueOf(dto.getOrderId()));
// 将符合条件的订单加入结果集
resultList.add(dto);
}

View File

@ -213,4 +213,6 @@ public class ToolLedgerAllEntity implements Serializable {
private List<DevInfoPropertyVo> propertyVoList = new ArrayList<>();
private String proName;
private String companyName;
}

View File

@ -20,7 +20,7 @@ import java.util.List;
public class ToolLedgerEntity implements Serializable {
//用于excel导出的序号一列,不需要业务逻辑处理
@Excel(name = "序号", isSequence = true, type = Excel.Type.EXPORT , sort = 0)
@Excel(name = "序号", isSequence = true, type = Excel.Type.EXPORT, sort = 0)
int sequence;
@ -231,4 +231,6 @@ public class ToolLedgerEntity implements Serializable {
* 说明装备采购发票的URL列表存储发票扫描件或照片
*/
private List<MaDevFile> purchaseInvoices;
private String companyName;
}

View File

@ -41,7 +41,9 @@ public class ToolLedgerServiceImpl implements ToolLedgerService {
Long deptId = SecurityUtils.getLoginUser().getSysUser().getDeptId();
Long userId = SecurityUtils.getLoginUser().getUserid();
// 管理员和省公司可查看所有数据
if (!userId.equals(ADMIN_ID) || !deptId.equals(PROVINCE_COMPANY_DEPT_ID)) {
if (userId != null && deptId != null
&& !userId.equals(ADMIN_ID)
&& !deptId.equals(PROVINCE_COMPANY_DEPT_ID)) {
entity.setCompanyId(deptId);
}
return mapper.list(entity);

View File

@ -85,4 +85,6 @@ public class WarehousingEntity implements Serializable {
private Long companyId;
private Long userId;
private String isStatus;
}

View File

@ -97,7 +97,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
d.device_name AS deviceName,
d.device_count AS deviceCount,
d.type_id AS typeId,
d.ma_status AS maStatus,
'1' AS maStatus,
d.brand AS brand,
d.production_date AS productionDate,
d.working_hours AS workingHours,
@ -114,7 +114,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
d.province_id AS provinceId,
d.city_id AS cityId,
d.area_id AS areaId,
mtv.maxTypeId AS maType,
null AS toolType,
c.company_name AS companyNameOrigin,
@ -148,14 +147,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
'' AS devSubcategory,
tt.type_name AS devName,
'1' AS devType,
tl.manage_mode AS manageMode,
tt.manage_type AS manageMode,
tl.id AS maId,
tl.tool_code AS `code`,
tl.identify_code AS identifyCode,
tt1.type_name AS deviceName,
tl.available_num AS deviceCount,
tl.type_id AS typeId,
tl.STATUS AS maStatus,
'1' AS maStatus,
'' AS brand,
tl.production_date AS productionDate,
0 AS workingHours,
@ -195,124 +194,67 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
)
) t
-- 外层筛选条件:所有动态和固定筛选条件集中在这里
WHERE
-- 1. 基础筛选条件
<if test="maId != null ">
t.maId = #{maId}
</if>
WHERE 1=1
<if test="code != null and code != ''">
<if test="maId != null ">AND</if>
t.code = #{code}
AND t.code = #{code}
</if>
<if test="deviceName != null and deviceName != ''">
<if test="maId != null or code != null and code != ''">AND</if>
t.deviceName LIKE CONCAT('%', #{deviceName}, '%')
</if>
<if test="maStatus != null">
<if test="maId != null or code != null and code != '' or deviceName != null and deviceName != ''">AND</if>
t.maStatus IN (1, 2, 3)
AND t.deviceName LIKE CONCAT('%', #{deviceName}, '%')
</if>
<if test="leaseScope != null ">
<if test="maId != null or code != null and code != '' or deviceName != null and deviceName != '' or maStatus != null">
AND
</if>
t.leaseScope = #{leaseScope}
AND t.leaseScope = #{leaseScope}
</if>
<if test="location != null and location != ''">
<if test="maId != null or code != null and code != '' or deviceName != null and deviceName != '' or maStatus != null or leaseScope != null">
AND
</if>
t.location = #{location}
AND t.location = #{location}
</if>
<if test="provinceId != null and provinceId != ''">
<if test="maId != null or code != null and code != '' or deviceName != null and deviceName != '' or maStatus != null or leaseScope != null or location != null and location != ''">
AND
</if>
t.provinceId = #{provinceId}
AND t.provinceId = #{provinceId}
</if>
<if test="cityId != null and cityId != ''">
<if test="maId != null or code != null and code != '' or deviceName != null and deviceName != '' or maStatus != null or leaseScope != null or location != null and location != '' or provinceId != null and provinceId != ''">
AND
</if>
t.cityId = #{cityId}
AND t.cityId = #{cityId}
</if>
<if test="areaId != null and areaId != ''">
<if test="maId != null or code != null and code != '' or deviceName != null and deviceName != '' or maStatus != null or leaseScope != null or location != null and location != '' or provinceId != null and provinceId != '' or cityId != null and cityId != ''">
AND
</if>
t.areaId = #{areaId}
AND t.areaId = #{areaId}
</if>
<if test="brand != null and brand != ''">
<if test="maId != null or code != null and code != '' or deviceName != null and deviceName != '' or maStatus != null or leaseScope != null or location != null and location != '' or provinceId != null and provinceId != '' or cityId != null and cityId != '' or areaId != null and areaId != ''">
AND
</if>
t.brand = #{brand}
AND t.brand = #{brand}
</if>
-- 2. 设备年龄筛选(工具表无生产时间则自动过滤,不影响)
<if test="ageMin != null and ageMax != null">
<if test="maId != null or code != null and code != '' or deviceName != null and deviceName != '' or maStatus != null or leaseScope != null or location != null and location != '' or provinceId != null and provinceId != '' or cityId != null and cityId != '' or areaId != null and areaId != '' or brand != null and brand != ''">
AND
</if>
TIMESTAMPDIFF(YEAR, t.productionDateOrigin, NOW()) >= #{ageMin}
AND TIMESTAMPDIFF(YEAR, t.productionDateOrigin, NOW()) >= #{ageMin}
AND TIMESTAMPDIFF(YEAR, t.productionDateOrigin, NOW()) &lt;= #{ageMax}
</if>
<if test="ageMin == null and ageMax != null">
<if test="maId != null or code != null and code != '' or deviceName != null and deviceName != '' or maStatus != null or leaseScope != null or location != null and location != '' or provinceId != null and provinceId != '' or cityId != null and cityId != '' or areaId != null and areaId != '' or brand != null and brand != '' or (ageMin != null and ageMax != null)">
AND
</if>
TIMESTAMPDIFF(YEAR, t.productionDateOrigin, NOW()) &lt;= #{ageMax}
AND TIMESTAMPDIFF(YEAR, t.productionDateOrigin, NOW()) &lt;= #{ageMax}
</if>
-- 3. 工时筛选工具表工时为0可根据需求调整
<if test="workingHoursMin != null and workingHoursMin != '' and workingHoursMax != null and workingHoursMax != ''">
<if test="maId != null or code != null and code != '' or deviceName != null and deviceName != '' or maStatus != null or leaseScope != null or location != null and location != '' or provinceId != null and provinceId != '' or cityId != null and cityId != '' or areaId != null and areaId != '' or brand != null and brand != '' or (ageMin != null or ageMax != null)">
AND
</if>
t.workingHoursOrigin >= #{workingHoursMin}
AND t.workingHoursOrigin >= #{workingHoursMin}
AND t.workingHoursOrigin &lt;= #{workingHoursMax}
</if>
-- 4. 其他基础筛选
<if test="description != null and description != ''">
<if test="maId != null or code != null and code != '' or deviceName != null and deviceName != '' or maStatus != null or leaseScope != null or location != null and location != '' or provinceId != null and provinceId != '' or cityId != null and cityId != '' or areaId != null and areaId != '' or brand != null and brand != '' or (ageMin != null or ageMax != null) or (workingHoursMin != null and workingHoursMin != '' and workingHoursMax != null and workingHoursMax != '')">
AND
</if>
t.description = #{description}
AND t.description = #{description}
</if>
<if test="gpsCode != null and gpsCode != ''">
<if test="maId != null or code != null and code != '' or deviceName != null and deviceName != '' or maStatus != null or leaseScope != null or location != null and location != '' or provinceId != null and provinceId != '' or cityId != null and cityId != '' or areaId != null and areaId != '' or brand != null and brand != '' or (ageMin != null or ageMax != null) or (workingHoursMin != null and workingHoursMin != '' and workingHoursMax != null and workingHoursMax != '') or description != null and description != ''">
AND
</if>
t.gpsCode = #{gpsCode}
AND t.gpsCode = #{gpsCode}
</if>
<if test="companyId != null and companyId != ''">
<if test="maId != null or code != null and code != '' or deviceName != null and deviceName != '' or maStatus != null or leaseScope != null or location != null and location != '' or provinceId != null and provinceId != '' or cityId != null and cityId != '' or areaId != null and areaId != '' or brand != null and brand != '' or (ageMin != null or ageMax != null) or (workingHoursMin != null and workingHoursMin != '' and workingHoursMax != null and workingHoursMax != '') or description != null and description != '' or gpsCode != null and gpsCode != ''">
AND
</if>
t.companyId = #{companyId}
AND t.companyId = #{companyId}
</if>
<if test="specification != null ">
<if test="maId != null or code != null and code != '' or deviceName != null and deviceName != '' or maStatus != null or leaseScope != null or location != null and location != '' or provinceId != null and provinceId != '' or cityId != null and cityId != '' or areaId != null and areaId != '' or brand != null and brand != '' or (ageMin != null or ageMax != null) or (workingHoursMin != null and workingHoursMin != '' and workingHoursMax != null and workingHoursMax != '') or description != null and description != '' or gpsCode != null and gpsCode != '' or companyId != null and companyId != ''">
AND
</if>
t.specification = #{specification}
AND t.specification = #{specification}
</if>
<if test="deposit != null ">
<if test="maId != null or code != null and code != '' or deviceName != null and deviceName != '' or maStatus != null or leaseScope != null or location != null and location != '' or provinceId != null and provinceId != '' or cityId != null and cityId != '' or areaId != null and areaId != '' or brand != null and brand != '' or (ageMin != null or ageMax != null) or (workingHoursMin != null and workingHoursMin != '' and workingHoursMax != null and workingHoursMax != '') or description != null and description != '' or gpsCode != null and gpsCode != '' or companyId != null and companyId != '' or specification != null">
AND
</if>
t.deposit = #{deposit}
AND t.deposit = #{deposit}
</if>
-- 5. 时间范围筛选
<if test="startTime != null and endTime != null">
<if test="maId != null or code != null and code != '' or deviceName != null and deviceName != '' or maStatus != null or leaseScope != null or location != null and location != '' or provinceId != null and provinceId != '' or cityId != null and cityId != '' or areaId != null and areaId != '' or brand != null and brand != '' or (ageMin != null or ageMax != null) or (workingHoursMin != null and workingHoursMin != '' and workingHoursMax != null and workingHoursMax != '') or description != null and description != '' or gpsCode != null and gpsCode != '' or companyId != null and companyId != '' or specification != null or deposit != null">
AND
</if>
t.updateTimeOrigin BETWEEN #{startTime} AND #{endTime}
AND t.updateTimeOrigin BETWEEN #{startTime} AND #{endTime}
</if>
-- 6. 关键字模糊筛选(覆盖设备和工具的所有关键字段)
<if test="keyWord != null and keyWord != ''">
<if test="maId != null or code != null and code != '' or deviceName != null and deviceName != '' or maStatus != null or leaseScope != null or location != null and location != '' or provinceId != null and provinceId != '' or cityId != null and cityId != '' or areaId != null and areaId != '' or brand != null and brand != '' or (ageMin != null or ageMax != null) or (workingHoursMin != null and workingHoursMin != '' and workingHoursMax != null and workingHoursMax != '') or description != null and description != '' or gpsCode != null and gpsCode != '' or companyId != null and companyId != '' or specification != null or deposit != null or (startTime != null and endTime != null)">
AND
</if>
AND
(
-- 设备表关键字段
LOCATE(#{keyWord}, t.mainGx) > 0

View File

@ -138,7 +138,7 @@
<!-- 默认值:即使实体类无该属性,也插入'1' -->
'1',
'0',
'0'
'1'
)
</insert>

View File

@ -108,7 +108,7 @@
ORDER BY t.applyTime DESC;
</select>
<select id="getDeviceByDept" resultType="java.util.Map">
SELECT sd.dept_abbreviation AS companyName, -- 公司名称
SELECT sd.dept_abbreviation AS companyName, -- 公司名称
-- 工具数量无数据则为0取整
ROUND(IFNULL(SUM(temp.toolNum), 0)) AS toolNum,
-- 设备数量无数据则为0取整
@ -165,7 +165,7 @@
GROUP BY on_company) t
-- 按公司ID合并数据避免同一公司多条记录
GROUP BY company_id) temp ON sd.dept_id = temp.company_id -- 公司ID关联
WHERE sd.dept_abbreviation is NOT null
WHERE sd.is_show = '1'
-- 按公司ID分组确保每个公司只显示一行
GROUP BY sd.dept_id,
sd.dept_name

View File

@ -28,7 +28,7 @@
<if test="lastCheckDate != null">last_check_date,</if>
<if test="nextCheckDate != null">next_check_date,</if>
<if test="status != null and status != ''">status,</if>
<if test="upDownStatus != null and upDownStatus != ''">up_down_status,</if>
'1',
<if test="companyId != null">company_id,</if>
<if test="remark != null and remark != ''">remark,</if>
@ -63,10 +63,11 @@
<select id="list" resultType="com.bonus.material.toolLedger.domain.ToolLedgerAllEntity">
SELECT
tt.type_id AS typeId,
tl.type_id AS typeId,
tt.type_name AS typeName,
tt.unit_name AS unitName,
tt.manage_type AS manageMode,
sd.dept_abbreviation AS companyName,
tl.manage_mode AS manageMode,
tt1.type_name AS parentTypeName, -- 1级父节点名称
tt2.type_name AS grandparentTypeName, -- 2级父节点名称
tt3.type_name AS greatGrandparentName, -- 3级父节点名称
@ -80,6 +81,7 @@
FROM
tool_type tt
LEFT JOIN tool_ledger tl ON tl.type_id = tt.type_id
LEFT JOIN sys_dept sd ON sd.dept_id = tl.company_id
-- 关联1级父节点直接父节点
INNER JOIN tool_type tt1 ON tt.parent_id = tt1.type_id
-- 关联2级父节点祖父节点
@ -103,12 +105,18 @@
</if>
<if test="companyId != null">
AND (tl.company_id = #{companyId} OR tl.company_id IS NULL)
AND tl.company_id = #{companyId}
</if>
<if test="typeName != null and typeName != ''">
AND tt.type_name LIKE CONCAT('%', #{typeName}, '%')
</if>
GROUP BY tl.type_id,tl.company_id
GROUP BY
tl.manage_mode,
tl.type_id
<if test="companyId != null">
,tl.company_id
</if>
ORDER BY
tl.create_time DESC
</select>
@ -154,10 +162,8 @@
</select>
<select id="listCode" resultType="com.bonus.material.toolLedger.domain.ToolLedgerEntity">
SELECT
tt.type_id AS typeId,
tt.type_name AS typeName,
tt.unit_name AS unitName,
tt.manage_type AS manageMode,
tt1.type_name AS parentTypeName, -- 1级父节点名称
tt2.type_name AS grandparentTypeName, -- 2级父节点名称
tt3.type_name AS greatGrandparentName, -- 3级父节点名称
@ -180,7 +186,7 @@
tl.next_check_date AS nextCheckDate,
tl.status AS status,
tl.up_down_status AS upDownStatus,
tl.company_id AS companyId,
sd.dept_abbreviation AS companyName,
tl.remark AS remark,
tl.fileList AS fileList,
tl.create_time AS createTime,
@ -188,6 +194,7 @@
FROM
tool_type tt
LEFT JOIN tool_ledger tl ON tl.type_id = tt.type_id
LEFT JOIN sys_dept sd ON sd.dept_id = tl.company_id
LEFT JOIN ma_supplier ms ON ms.supplier_id = tl.supplier_id
-- 关联1级父节点直接父节点
INNER JOIN tool_type tt1 ON tt.parent_id = tt1.type_id
@ -288,6 +295,7 @@
INNER JOIN tool_type tt1 ON tt1.type_id = tt.parent_id
WHERE tl.status = #{status}
AND tl.type_id = #{typeId}
AND tl.manage_mode = #{manageMode}
<if test="companyId != null">
AND (tl.company_id = #{companyId} OR tl.company_id IS NULL)
@ -350,6 +358,7 @@
<where>
od.devType=#{status}
AND tl.type_id = #{typeId}
AND tl.manage_mode = #{manageMode}
and od.real_num is NOT null
<if test="keyWord != null and keyWord != ''">
AND (

View File

@ -150,6 +150,9 @@
<if test="status != null and status != ''">
AND bw.status = #{status}
</if>
<if test="isStatus != null and isStatus != ''">
AND bw.status != #{isStatus}
</if>
<if test="companyId != null and companyId != ''">
AND su.dept_id = #{companyId}
</if>
@ -209,7 +212,7 @@
LEFT JOIN tool_type tt2 on tt1.parent_id = tt2.type_id
LEFT JOIN tool_type tt3 on tt2.parent_id = tt3.type_id
LEFT JOIN tool_type tt4 on tt3.parent_id = tt4.type_id AND tt.del_flag = '0'
WHERE bw.id = #{id}
WHERE bw.id = #{id} and dc.apply_num is not null
</select>
<select id="getMaIds" resultType="java.lang.String">
SELECT dev_id AS `key`