问题修改

This commit is contained in:
jiang 2025-12-17 16:16:45 +08:00
parent e0e8e1c836
commit a551af86dd
19 changed files with 161 additions and 58 deletions

View File

@ -62,15 +62,13 @@ public class EquipmentTypeController {
//添加
@PostMapping("/add")
public AjaxResult addEquipmentType(@Validated @RequestBody EquipmentType equipmentType) {
equipmentTypeService.addEquipmentType(equipmentType);
return AjaxResult.success();
return equipmentTypeService.addEquipmentType(equipmentType);
}
//更新
@PutMapping("/update")
public AjaxResult updateEquipmentType(@Validated @RequestBody EquipmentType equipmentType) {
equipmentTypeService.updateEquipmentType(equipmentType);
return AjaxResult.success();
return equipmentTypeService.updateEquipmentType(equipmentType);
}
//删除

View File

@ -61,4 +61,8 @@ public interface EquipmentTypeMapper {
Long countChildrenByParentId(@Param("parentId") Long parentId);
void deleteTypePropertiesByTypeId(@Param("typeId") Long typeId);
int getToolByTypeIdAndTypeName(EquipmentType equipmentType);
int countSameNameInSameLevel(EquipmentType equipmentType);
}

View File

@ -3,6 +3,7 @@ package com.bonus.material.devConfig.service;
// EquipmentTypeService.java
import com.bonus.common.core.web.domain.AjaxResult;
import com.bonus.material.devConfig.domain.PageResult;
import com.bonus.material.devConfig.domain.EquipmentTypeDTO;
import com.bonus.material.devConfig.domain.EquipmentType;
@ -23,9 +24,9 @@ public interface EquipmentTypeService {
EquipmentType getEquipmentTypeDetail(Long id);
void addEquipmentType(EquipmentType equipmentType);
AjaxResult addEquipmentType(EquipmentType equipmentType);
void updateEquipmentType(EquipmentType equipmentType);
AjaxResult updateEquipmentType(EquipmentType equipmentType);
void deleteEquipmentType(Long id);
}

View File

@ -1,6 +1,7 @@
package com.bonus.material.devConfig.service.impl;
import com.bonus.common.core.utils.StringUtils;
import com.bonus.common.core.web.domain.AjaxResult;
import com.bonus.material.devConfig.domain.PageResult;
import com.bonus.material.devConfig.domain.EquipmentTypeDTO;
import com.bonus.material.devConfig.domain.EquipmentType;
@ -56,35 +57,39 @@ public class EquipmentTypeServiceImpl implements EquipmentTypeService {
@Override
@Transactional
public void addEquipmentType(EquipmentType equipmentType) {
public AjaxResult addEquipmentType(EquipmentType equipmentType) {
// 设置默认值
// 设置层级如果没有设置则默认为1
if (equipmentType.getLevel() == null) {
equipmentType.setLevel(1);
}
equipmentType.setCreateTime(new Date());
equipmentType.setUpdateTime(new Date());
// 4. 校验同层级下名称是否重复避免重复新增
int sameNameCount = equipmentTypeMapper.getToolByTypeIdAndTypeName(equipmentType);
if (sameNameCount > 0) {
return AjaxResult.error("当前分类下已存在同名类型,新增失败");
}
equipmentTypeMapper.insertEquipmentType(equipmentType);
return AjaxResult.success();
}
@Override
@Transactional
public void updateEquipmentType(EquipmentType equipmentType) {
public AjaxResult updateEquipmentType(EquipmentType equipmentType) {
// 1. 校验父ID是否与自身ID相同
if (equipmentType.getParentId() != null && equipmentType.getParentId().equals(equipmentType.getTypeId())) {
// 抛出异常阻止更新并回滚事务
throw new IllegalArgumentException("父分类ID不能与自身ID相同更新失败。");
}
int sameNameCount = equipmentTypeMapper.countSameNameInSameLevel(equipmentType);
if (sameNameCount > 0) {
return AjaxResult.error("当前分类下已存在同名类型,修改失败");
}
// 4. 执行正常的更新逻辑
equipmentType.setUpdateTime(new Date());
equipmentTypeMapper.updateEquipmentType(equipmentType);
return AjaxResult.success();
}
@Override

View File

@ -103,8 +103,6 @@ public class CsDeviceDetails {
@ApiModelProperty(value = "下次维保日期yyyy-MM-dd")
private Date nextMaintenanceDate;
@Excel(name = "剩余使用年限", width = 25, sort = 9)
private Integer remainingYears;
private String remainingYears;
}

View File

@ -239,14 +239,14 @@ public class MaDevInfo {
* 最小资产原值
* 说明装备的原始采购价值以元为单位
*/
private BigDecimal minBuyPrice;
private BigDecimal minOriginalValue;
/**
* 最大资产原值
* 说明装备的原始采购价值以元为单位
*/
private BigDecimal maxBuyPrice;
private BigDecimal maxOriginalValue;
/**
* 最大使用年限

View File

@ -450,6 +450,7 @@ public class DevChangeServiceImpl implements DevChangeService {
csDeviceDetails.setManageType(StringUtils.isNotBlank(devDetails.getManageType()) ? devDetails.getManageType() : "");
csDeviceDetails.setDevCode(StringUtils.isNotBlank(devDetails.getDevCode()) ? devDetails.getDevCode() : "");
csDeviceDetails.setStorageNum(devDetails.getStorageNum());
csDeviceDetails.setRemainingYears(StringUtils.isNotBlank(devDetails.getRemainingYears()) ? devDetails.getRemainingYears() : "-");
// 用于编辑显示数据是否选中前端根据typeId和id结合判断
csDeviceDetails.setId(devDetails.getId());
}

View File

@ -199,4 +199,7 @@ public class DevInfoVo extends DevInfo {
private String manageMode;
private String maType;
private String toolType;
}

View File

@ -49,6 +49,19 @@ public class MaTypeInfoController extends BaseController {
return AjaxResult.success(list);
}
/**
* 装备共享页面之一级设备类型
* @param typeInfo
* @return
*/
@ApiOperation("装备共享页面之一级设备类型")
@GetMapping("/getToolTypeList")
public AjaxResult getToolTypeList(TypeInfo typeInfo) {
List<TypeInfo> list = maTypeInfoSevice.getToolTypeList(typeInfo);
return AjaxResult.success(list);
}
/**
* 首页搜索热搜装备
* @param devInfoVo

View File

@ -50,4 +50,6 @@ public interface MaTypeInfoMapper {
* @return
*/
TypeInfo getTypeId(TypeInfo typeInfo);
List<TypeInfo> getToolTypeList(TypeInfo typeInfo);
}

View File

@ -38,4 +38,5 @@ public interface MaTypeInfoSevice {
*/
List<AreaVo> getArea(AreaVo areaVo);
List<TypeInfo> getToolTypeList(TypeInfo typeInfo);
}

View File

@ -17,10 +17,7 @@ import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.stream.Collectors;
@Service
@ -138,4 +135,13 @@ public class MaTypeInfoServiceImpl implements MaTypeInfoSevice {
return maTypeInfoMapper.getArea(areaVo);
}
/**
* @param typeInfo
* @return
*/
@Override
public List<TypeInfo> getToolTypeList(TypeInfo typeInfo) {
return maTypeInfoMapper.getToolTypeList(typeInfo);
}
}

View File

@ -103,4 +103,19 @@
SELECT COUNT(*) FROM ma_type WHERE parent_id = #{parentId} and level != '7'
</select>
<select id="getToolByTypeIdAndTypeName" resultType="java.lang.Integer">
SELECT count(1)
FROM ma_type
WHERE parent_id = #{parentId} -- 传入的主键ID
AND type_name = #{typeName}
AND del_flag = '0' -- 只查询未删除的记录(逻辑删除校验)
</select>
<select id="countSameNameInSameLevel" resultType="java.lang.Integer">
SELECT COUNT(*) FROM ma_type
WHERE del_flag = '0'
AND parent_id = #{parentId}
AND type_name = #{typeName}
AND type_id != #{typeId} <!-- 排除自身 -->
</select>
</mapper>

View File

@ -291,7 +291,6 @@
SELECT t.type_id FROM tool_type t
INNER JOIN tool_category_tree tct ON t.parent_id = tct.type_id
)
-- 装备表查询(原有逻辑不变)
SELECT
CASE
@ -314,10 +313,18 @@
mdi.type_id AS typeId,
mdi.ma_id AS id,
mdq.next_check_time AS nextMaintenanceDate,
IF(DATEDIFF(STR_TO_DATE(DATE_ADD(mdi.production_date, INTERVAL mdi.max_working_hours YEAR), '%Y-%m-%d'),
CURDATE()) &lt; 0,'已超过最大使用年限',CONCAT(IF(STR_TO_DATE(DATE_ADD(mdi.production_date, INTERVAL
mdi.max_working_hours YEAR), '%Y-%m-%d') IS NOT
NULL
AND STR_TO_DATE(DATE_ADD(mdi.production_date, INTERVAL mdi.max_working_hours YEAR), '%Y-%m-%d') >= CURDATE(),
DATEDIFF(STR_TO_DATE(DATE_ADD(mdi.production_date, INTERVAL mdi.max_working_hours YEAR), '%Y-%m-%d'),
CURDATE()), 0), '天(',
IF(STR_TO_DATE(DATE_ADD(mdi.production_date, INTERVAL mdi.max_working_hours YEAR), '%Y-%m-%d') IS NOT NULL
AND STR_TO_DATE(DATE_ADD(mdi.production_date, INTERVAL mdi.max_working_hours YEAR), '%Y-%m-%d') >= CURDATE(),
TIMESTAMPDIFF(YEAR, CURDATE(),
STR_TO_DATE(DATE_ADD(mdi.production_date, INTERVAL mdi.max_working_hours YEAR), '%Y-%m-%d')), 0) AS
STR_TO_DATE(DATE_ADD(mdi.production_date, INTERVAL mdi.max_working_hours YEAR), '%Y-%m-%d')), 0), '年)'
)) AS
remainingYears
FROM ma_dev_info mdi
LEFT JOIN (SELECT max( next_check_time) next_check_time,ma_id from ma_dev_qc GROUP BY ma_id ) mdq on
@ -365,10 +372,9 @@
2 AS devType,
tl.type_id AS typeId,
tl.id AS id,
'-' AS nextMaintenanceDate,
null AS nextMaintenanceDate,
'-' AS remainingYears
FROM tool_ledger tl
LEFT JOIN tool_type tt ON tl.type_id = tt.type_id
LEFT JOIN tool_type tt1 ON tt.parent_id = tt1.type_id
LEFT JOIN tool_type tt2 ON tt1.parent_id = tt2.type_id
@ -540,15 +546,28 @@
WHEN mt.level = 6 THEN CONCAT(mt5.type_name, '>', mt4.type_name, '>', mt3.type_name, '>',
mt2.type_name,'>', mt1.type_name, '>', mt.type_name)
ELSE mt.type_name
END AS category,
mdi.device_name AS typeName,
END AS category,
mdi.device_name AS typeName,
mdi.item_type_model AS typeModelName,
mdi.manage_type AS manageType,
mdi.code AS devCode,
SUM(CASE WHEN mdi.ma_status = 1 THEN 1 ELSE 0 END) AS storageNum,
1 AS devType,
mdi.type_id AS typeId,
mdi.ma_id AS id
mdi.manage_type AS manageType,
mdi.code AS devCode,
SUM(CASE WHEN mdi.ma_status = 1 THEN 1 ELSE 0 END) AS storageNum,
1 AS devType,
mdi.type_id AS typeId,
mdi.ma_id AS id,
IF(DATEDIFF(STR_TO_DATE(DATE_ADD(mdi.production_date, INTERVAL mdi.max_working_hours YEAR), '%Y-%m-%d'),
CURDATE()) &lt; 0,'已超过最大使用年限',CONCAT(IF(STR_TO_DATE(DATE_ADD(mdi.production_date, INTERVAL
mdi.max_working_hours YEAR), '%Y-%m-%d') IS NOT
NULL
AND STR_TO_DATE(DATE_ADD(mdi.production_date, INTERVAL mdi.max_working_hours YEAR), '%Y-%m-%d') >= CURDATE(),
DATEDIFF(STR_TO_DATE(DATE_ADD(mdi.production_date, INTERVAL mdi.max_working_hours YEAR), '%Y-%m-%d'),
CURDATE()), 0), '天(',
IF(STR_TO_DATE(DATE_ADD(mdi.production_date, INTERVAL mdi.max_working_hours YEAR), '%Y-%m-%d') IS NOT NULL
AND STR_TO_DATE(DATE_ADD(mdi.production_date, INTERVAL mdi.max_working_hours YEAR), '%Y-%m-%d') >= CURDATE(),
TIMESTAMPDIFF(YEAR, CURDATE(),
STR_TO_DATE(DATE_ADD(mdi.production_date, INTERVAL mdi.max_working_hours YEAR), '%Y-%m-%d')), 0), '年)'
)) AS
remainingYears
FROM ma_dev_info mdi
LEFT JOIN ma_type mt ON mdi.type_id = mt.type_id
LEFT JOIN ma_type mt1 ON mt.parent_id = mt1.type_id
@ -557,7 +576,7 @@
LEFT JOIN ma_type mt4 ON mt3.parent_id = mt4.type_id
LEFT JOIN ma_type mt5 ON mt4.parent_id = mt5.type_id
where
mdi.is_active = '1' and mdi.type_id = #{typeId}
mdi.is_active = '1' and mdi.type_id = #{typeId}
<if test="devCode != null and devCode != ''">
and mdi.code = #{devCode}
</if>

View File

@ -71,8 +71,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
d.brand AS brand, -- 第17列
d.production_date AS productionDate, -- 第18列
d.working_hours AS workingHours, -- 第19列
d.person AS person, -- 第20列
d.person_phone AS personPhone, -- 第21列
sd.leader AS person, -- 20. 对应 person
sd.phone AS personPhone, -- 21. 对应 personPhone
d.create_time AS createTime, -- 第22列
d.update_time AS updateTime, -- 第23列
d.on_company AS companyId, -- 第24列
@ -131,6 +131,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
or locate(#{keyWord},d.identify_code) > 0
)
</if>
<if test="maType != null and maType != ''">
and mtv.maxTypeId = #{maType}
</if>
and d.is_active='1'
and d.up_down_status ='1'
</where>
@ -180,6 +183,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
LEFT JOIN sys_dept sd ON tl.company_id = sd.dept_id
INNER JOIN tool_type tt ON tt.type_id = tl.type_id
INNER JOIN tool_type tt1 ON tt.parent_id = tt1.type_id -- 确保 tt 有 parent_id否则可能查不到数据
INNER JOIN tool_type tt2 ON tt1.parent_id = tt2.type_id -- 确保 tt 有 parent_id否则可能查不到数据
INNER JOIN tool_type tt3 ON tt2.parent_id = tt3.type_id -- 确保 tt 有 parent_id否则可能查不到数据
INNER JOIN tool_type tt4 ON tt3.parent_id = tt4.type_id -- 确保 tt 有 parent_id否则可能查不到数据
LEFT JOIN bm_company_info c ON sd.dept_id = c.company_id
WHERE
tl.up_down_status = '1'
@ -195,6 +201,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
or locate(#{keyWord}, sd.dept_name) > 0
)
</if>
<if test="toolType != null and toolType != ''">
and tt4.type_id = #{toolType}
</if>
-- 子查询加 limit 避免 order by 问题(如果工具表也需要排序,可在这里加)
LIMIT 1000000
)
@ -271,8 +280,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
d.brand as brand,
d.production_date as productionDate,
d.max_working_hours as workingHours,
d.person as person,
d.person_phone as personPhone,
sd.leader as person,
sd.phone as personPhone,
d.on_company as companyId,
sd.dept_name as companyName,
c.operate_address as operateAddress,

View File

@ -26,7 +26,8 @@
and aaa.create_user like concat('%', #{createUser}, '%')
</if>
<if test="startCreateTime != null and endCreateTime != null ">
and aaa.create_time between #{startCreateTime} and #{endCreateTime}
and aaa.create_time &gt;= #{startCreateTime}
and aaa.create_time &lt; DATE_ADD(#{endCreateTime}, INTERVAL 1 DAY)
</if>
<if test="companyId != null">
and mdi.on_company = #{companyId}
@ -477,18 +478,25 @@
<if test="minOriginalValue != null and minOriginalValue != '' and maxOriginalValue != null and maxOriginalValue != ''">
and mdi.buy_price &gt;= #{minOriginalValue} and mdi.buy_price &lt;= #{maxOriginalValue}
</if>
<if test="startProductionDate != null and endProductionDate != null ">
and DATE_FORMAT(mdi.production_date,'%Y-%m-%d') between #{startProductionDate} and #{endProductionDate}
<!-- 生产日期范围 -->
<if test="startProductionDate != null and endProductionDate != null ">
and mdi.production_date &gt;= #{startProductionDate}
and mdi.production_date &lt; DATE_ADD(#{endProductionDate}, INTERVAL 1 DAY)
</if>
<if test="startPurchaseDate != null and endPurchaseDate != null ">
and DATE_FORMAT(mdi.purchase_date,'%Y-%m-%d') between #{startPurchaseDate} and #{endPurchaseDate}
<!-- 采购日期范围 -->
<if test="startPurchaseDate != null and endPurchaseDate != null">
and mdi.purchase_date &gt;= #{startPurchaseDate}
and mdi.purchase_date &lt; DATE_ADD(#{endPurchaseDate}, INTERVAL 1 DAY)
</if>
<!-- 订单创建时间范围 -->
<if test="startOrderCreateTime != null and endOrderCreateTime != null ">
and cds.create_time &gt;= #{startOrderCreateTime}
and cds.create_time &lt; DATE_ADD(#{endOrderCreateTime}, INTERVAL 1 DAY)
</if>
<if test="orderCreateUser != null and orderCreateUser != ''">
and cds.create_user like concat('%', #{orderCreateUser}, '%')
</if>
<if test="startOrderCreateTime != null and endOrderCreateTime != null">
and DATE_FORMAT( cds.create_time,'%Y-%m-%d') between #{startOrderCreateTime} and #{endOrderCreateTime}
</if>
</where>
</select>
<select id="getDeviceByOrderId" resultType="com.bonus.material.devchange.domain.MaDevInfo">
@ -572,23 +580,33 @@
<if test="manufacturerId != null and manufacturerId != ''">
and mdi.supplier_id = #{manufacturerId}
</if>
<if test="minBuyPrice != null and maxBuyPrice != null">
and mdi.buy_price &gt;= #{minBuyPrice} and mdi.buy_price &lt;= #{maxBuyPrice}
<if test="minOriginalValue != null and minOriginalValue != '' and maxOriginalValue != null and maxOriginalValue != ''">
and mdi.buy_price &gt;= #{minOriginalValue} and mdi.buy_price &lt;= #{maxOriginalValue}
</if>
<!-- 生产日期范围 -->
<if test="startProductionDate != null and endProductionDate != null ">
and DATE_FORMAT(mdi.production_date,'%Y-%m-%d') between #{startProductionDate} and #{endProductionDate}
and mdi.production_date &gt;= #{startProductionDate}
and mdi.production_date &lt; DATE_ADD(#{endProductionDate}, INTERVAL 1 DAY)
</if>
<!-- 采购日期范围 -->
<if test="startPurchaseDate != null and endPurchaseDate != null">
and DATE_FORMAT(mdi.purchase_date,'%Y-%m-%d') between #{startPurchaseDate} and #{endPurchaseDate}
and mdi.purchase_date &gt;= #{startPurchaseDate}
and mdi.purchase_date &lt; DATE_ADD(#{endPurchaseDate}, INTERVAL 1 DAY)
</if>
<!-- 订单创建时间范围 -->
<if test="startOrderCreateTime != null and endOrderCreateTime != null ">
and DATE_FORMAT( cds.create_time,'%Y-%m-%d') between #{startOrderCreateTime} and #{endOrderCreateTime}
and cds.create_time &gt;= #{startOrderCreateTime}
and cds.create_time &lt; DATE_ADD(#{endOrderCreateTime}, INTERVAL 1 DAY)
</if>
<if test="orderCreateUser != null and orderCreateUser != ''">
and cds.create_user like concat('%', #{orderCreateUser}, '%')
</if>
<if test="status != null ">
and mdi.change_status = #{status}
and mdi.entry_status = #{status}
</if>
<if test="entryStatus != null and entryStatus != ''">
and mdi.entry_status = #{entryStatus}
</if>
</where>
</select>

View File

@ -104,5 +104,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
and type_id = #{typeId}
</if>
</select>
<select id="getToolTypeList" resultType="com.bonus.common.biz.domain.TypeInfo">
SELECT type_id AS typeId,
parent_id AS parentId,
type_name AS typeName,
`level` AS LEVEL,
del_flag AS delFlag,
unit_name AS unitName
FROM tool_type
WHERE del_flag = '0'
and level = '1'
</select>
</mapper>

View File

@ -152,7 +152,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
up.dept_name AS czcompanyName,
mdi.person AS person,
sd.phone AS personPhone,
su.phonenumber AS phoneNumber,
dept.phone AS phoneNumber,
su.nick_name as buyerName,
sd.dept_name as sellerName,
moi.address,

View File

@ -62,7 +62,6 @@
<select id="list" resultType="com.bonus.material.toolLedger.domain.ToolLedgerAllEntity">
SELECT
tt.type_id AS typeId,
tt.type_name AS typeName,
tt.unit_name AS unitName,
@ -76,7 +75,7 @@
SUM(COALESCE ( tl.share_num, 0 )) AS shareNum, -- 共享
SUM(COALESCE ( tl.repair_num, 0 )) AS repairNum, -- 维修
SUM(COALESCE ( tl.scrap_num, 0 )) AS scrapNum, -- 报废
SUM(COALESCE ( tl.total_num, 0 )) AS totalNum -- 总数
SUM(COALESCE ( tl.total_num - tl.scrap_num, 0 )) AS totalNum -- 总数
FROM
tool_type tt
LEFT JOIN tool_ledger tl ON tl.type_id = tt.type_id