问题修改

This commit is contained in:
jiang 2025-10-16 19:27:09 +08:00
parent 87f37c20b9
commit 67b0771294
22 changed files with 537 additions and 56 deletions

View File

@ -19,6 +19,7 @@ public class EquipmentProperty {
private String propertyName;
private String propertyValue;
private Date createTime;
private String value;
@Override
public String toString() {

View File

@ -24,81 +24,81 @@ public class CsDeviceChangeVo {
/**
* 主键
*/
private String id;
private String id;
/**
* 变更状前状态
*/
@Excel(name = "流转前状态",width = 20,sort = 4)
private String changeStatusName;
@Excel(name = "流转前状态", width = 20, sort = 4)
private String changeStatusName;
private String changeStatus;
private String changeStatus;
/**
* 类型
* 变更类型 1入库 2出库 3 退役 4 维修
*/
@Excel(name = "操作类型",width = 25 ,sort = 2)
@Excel(name = "操作类型", width = 25, sort = 2)
private String typeName;
private String type;
private String type;
/**
* 变更状态 0自用 1共享
*/
private String status;
private String status;
/**
* 工程编码
*/
private String proCode;
private String proCode;
/**
* 工程名称
*/
@Excel(name = "使用项目",width = 25,sort = 7)
private String proName;
@Excel(name = "使用项目", width = 25, sort = 7)
private String proName;
/**
* 工程类型
*/
private String proType;
private String proType;
/**
* 设备数量
*/
@Excel(name = "设备数量",width = 25,sort = 9)
private String devNum;
@Excel(name = "设备数量", width = 25, sort = 9)
private String devNum;
/**
* 电压等级
*/
private String voltageLevel;
private String voltageLevel;
/**
* 使用单位
*/
@Excel(name = "使用单位",width = 25,sort = 6)
private String useUint;
@Excel(name = "使用单位", width = 25, sort = 6)
private String useUint;
/**
*
*/
private String proProvince;
private String proProvince;
/**
*
*/
private String proCity;
private String proCity;
/**
*
*/
private String proCounty;
private String proCounty;
/**
* 详细地址
*/
@Excel(name = "使用地址",width = 25,sort = 8)
private String proLocation;
@Excel(name = "使用地址", width = 25, sort = 8)
private String proLocation;
/**
* 创建时间
*/
@Excel(name = "操作时间",width = 25,sort = 2)
private String createTime;
@Excel(name = "操作时间", width = 25, sort = 2)
private String createTime;
/**
* 创建人
*/
@Excel(name = "操作人",width = 20,sort = 1)
private String createUser;
@Excel(name = "操作人", width = 20, sort = 1)
private String createUser;
/**
* 使用人
*/
@ -122,7 +122,7 @@ public class CsDeviceChangeVo {
private String endTime;
private String useTime;
}

View File

@ -68,7 +68,7 @@ public class MaDevInfo {
* 子工序id
* 说明装备参与的具体子工序
*/
private String subProcessId;
private Integer subProcessId;
/**
* 子工序
* 说明装备参与的具体子工序
@ -79,7 +79,7 @@ public class MaDevInfo {
* 装备大类目id
* 说明装备所属的一级分类如工程机械仪器仪表等
*/
private String mainCategoryId;
private Integer mainCategoryId;
/**
* 装备大类目
* 说明装备所属的一级分类如工程机械仪器仪表等
@ -99,7 +99,7 @@ public class MaDevInfo {
* 装备分支id
* 说明小类目下的更细分类代表具体的装备类型分支
*/
private String branchId;
private Integer branchId;
/**
* 装备分支
* 说明小类目下的更细分类代表具体的装备类型分支
@ -181,7 +181,7 @@ public class MaDevInfo {
* 生产厂家id
* 说明装备的生产制造厂商名称
*/
private String manufacturerId;
private Integer manufacturerId;
/**
* 生产厂家
* 说明装备的生产制造厂商名称
@ -336,4 +336,6 @@ public class MaDevInfo {
private String isWarn;
private String entryStatus;
private String upDownStatus;
}

View File

@ -16,6 +16,7 @@ public interface DevChangeMapper {
/**
* 查询设备列表集合
*
* @param devInfo
* @return
*/
@ -23,6 +24,7 @@ public interface DevChangeMapper {
/**
* 查询设备集合
*
* @param vo
* @return
*/
@ -30,12 +32,14 @@ public interface DevChangeMapper {
/**
* 更新数据
*
* @param vo
*/
void updateJson(DevChangeVo vo);
/**
* 查询工程下拉选集合
*
* @param vo
* @return
*/
@ -43,6 +47,7 @@ public interface DevChangeMapper {
/**
* xinz
*
* @param vo
* @return
*/
@ -50,18 +55,21 @@ public interface DevChangeMapper {
/**
* 新增设备变更记录数据
*
* @param deviceChangeDetailsVo
*/
int addDetailsInfo(CsDeviceChangeDetailsVo deviceChangeDetailsVo);
/**
*
* @param vo
*/
void updateDevInfo(CsDeviceChangeVo vo);
void updateDevInfoData(CsDeviceChangeVo vo);
/**
* 查询设备变更前状态
*
* @param devId
* @return
*/
@ -69,6 +77,7 @@ public interface DevChangeMapper {
/**
* 查询 设备变更记录
*
* @param vo
* @return
*/
@ -76,6 +85,7 @@ public interface DevChangeMapper {
/**
* 获取变更前设备
*
* @param devId
* @return
*/
@ -83,6 +93,7 @@ public interface DevChangeMapper {
/**
* 查询 设备单位
*
* @param devId
* @return
*/
@ -90,13 +101,15 @@ public interface DevChangeMapper {
/**
* 查询出库单
*
* @param vo
* @return
*/
List<DevChangeVo> getDevDetails(CsDeviceChangeDetailsVo vo);
List<DevChangeVo> getDevDetails(CsDeviceChangeDetailsVo vo);
/**
* 电压等级
*
* @param vo
* @return
*/
@ -104,25 +117,27 @@ public interface DevChangeMapper {
/**
* 修改详情
*
* @param deviceChangeDetailsVo
*/
void addDevChangeDetails(DevChangeDetailsVo deviceChangeDetailsVo);
/**
* 查询数据
*
* @param vo
* @return
*/
List<DevChangeDetailsVo> getDevChangeDetailsList(DevChangeDetailsVo vo);
/**
*
* @param voo
*/
void deleteDevChangeDetails(DevChangeDetailsVo voo);
/**
* 修改数量
*
* @param newNum
*/
void updateChangeDetailsNum(DevChangeDetailsVo voo);

View File

@ -45,5 +45,6 @@ public interface MaDevInfoMapper {
MaDevInfo getDevice(Integer maId);
List<MaDevInfo> getDeviceByMaIds(String[] maIdArray);
}

View File

@ -114,9 +114,10 @@ public class DevChangeServiceImpl implements DevChangeService {
for (CsDeviceChangeDetailsVo deviceChangeDetailsVo : list) {
if ("1".equals(vo.getStatus())) {
updateDevDetails(deviceChangeDetailsVo.getDevId(), null, "1", deviceChangeDetailsVo.getNum());
deviceChangeDetailsVo.setStatus("1");
} else {
updateDevDetails(deviceChangeDetailsVo.getDevId(), null, "5", deviceChangeDetailsVo.getNum());
deviceChangeDetailsVo.setStatus("5");
}
//新增设备列表数据
deviceChangeDetailsVo.setChangeId(vo.getId());
@ -176,6 +177,7 @@ public class DevChangeServiceImpl implements DevChangeService {
deviceChangeDetailsVo.setChangeId(vo.getId());
deviceChangeDetailsVo.setReasonVal(vo.getReasonVal());
deviceChangeDetailsVo.setReasonId(vo.getReasonId());
deviceChangeDetailsVo.setStatus("4");
//新增设备详情
int isSuccess = mapper.addDetailsInfo(deviceChangeDetailsVo);
if (isSuccess > 0) {
@ -233,8 +235,10 @@ public class DevChangeServiceImpl implements DevChangeService {
entity.setUseUint(usUnit);
entity.setChangeUnit(usUnit);
if ("1".equals(deviceChangeDetailsVo.getStatus())) {
deviceChangeDetailsVo.setStatus("1");
updateDevDetails2(deviceChangeDetailsVo.getDevId(), proId, "1", deviceChangeDetailsVo.getNum());
} else {
deviceChangeDetailsVo.setStatus("4");
updateDevDetails2(deviceChangeDetailsVo.getDevId(), proId, "4", deviceChangeDetailsVo.getNum());
}
//新增设备列表数据

View File

@ -144,6 +144,15 @@ public class DevMergeController extends BaseController {
return service.interDevice(maDevInfo);
}
/**
* 获取台账中设备信息详细信息
*/
@ApiOperation(value = "装备台账-新增单个设备草稿")
@PostMapping("/updateDevice")
public AjaxResult updateDevice(@RequestBody MaDevInfo maDevInfo) {
return service.updateDevice(maDevInfo);
}
/**
* 获取台账中设备信息详细信息
*/

View File

@ -47,8 +47,8 @@ public class MaDevQc extends BaseEntity implements Serializable {
private String qcUser;
@ApiModelProperty(value = "质检日期")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
@DateTimeFormat(pattern = "yyyy-MM-dd")
private Date qcTime;
@ApiModelProperty(value = "质检开始日期")

View File

@ -1,17 +1,26 @@
package com.bonus.material.device.domain.vo;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.models.auth.In;
import lombok.Data;
@Data
public class DevInfoPropertyVo {
/** 属性名称 */
private Integer id;
/**
* 属性名称
*/
@ApiModelProperty(value = "属性名称")
private String propertyName;
/** 属性值 */
/**
* 属性值
*/
@ApiModelProperty(value = "属性值")
private String propertyValue;
private String value;
private String inputType;
}

View File

@ -79,5 +79,9 @@ public interface DevMergeMapper {
List<MaDevInfo> getDeviceByOrderId(MaDevInfo o);
void interFile(MaDevFile item);
Integer updateDeviceByMaId(MaDevInfo maDevInfo);
void delFile(Integer maId);
}

View File

@ -68,4 +68,5 @@ public interface DevMergeService {
List<MaDevInfo> getDeviceByOrderId(MaDevInfo o);
AjaxResult updateDevice(MaDevInfo maDevInfo);
}

View File

@ -82,6 +82,9 @@ public class DevMergeServiceImpl implements DevMergeService {
@Autowired
private MaDevInfoMapper mapper;
@Autowired
private MaDevQcMapper qcMapper;
@Override
public List<DevMergeVo> list(DevMergeVo devInfo) {
return devMergeMapper.list(devInfo);
@ -234,6 +237,17 @@ public class DevMergeServiceImpl implements DevMergeService {
maDevInfo.setCode(getString());
Integer i = devMergeMapper.interDevice(maDevInfo);
if (i > 0) {
devInfoMapper.deleteDevInfoProperties(Long.valueOf(maDevInfo.getMaId()));
MaDevQc maDevQc = new MaDevQc();
maDevQc.setMaId(maDevInfo.getMaId());
maDevQc.setQcCode(maDevInfo.getCode());
maDevQc.setCreateBy(String.valueOf(SecurityUtils.getUserId()));
maDevQc.setCreateTime(DateUtils.getNowDate());
maDevQc.setQcCom(Optional.ofNullable(SecurityUtils.getLoginUser().getSysUser().getCompanyId()).orElse(SecurityUtils.getLoginUser().getSysUser().getDeptId()).toString());
maDevQc.setNextCheckTime(maDevInfo.getNextMaintenanceDate());
qcMapper.insertDevQc(maDevQc);
devInfoMapper.insertDevInfoProperties(Long.valueOf(maDevInfo.getMaId()), maDevInfo.getPropertyVoList());
devMergeMapper.insertOrderDevReal(String.valueOf(maDevInfo.getOrderId()), Long.valueOf(maDevInfo.getMaId()));
maDevInfo.getAppearanceImages().forEach(item -> {
// 这里编写对每个 image 的处理逻辑比如打印处理等
@ -338,6 +352,66 @@ public class DevMergeServiceImpl implements DevMergeService {
return list;
}
/**
* @param maDevInfo
* @return
*/
@Override
public AjaxResult updateDevice(MaDevInfo maDevInfo) {
try {
Integer i = devMergeMapper.updateDeviceByMaId(maDevInfo);
if (i > 0) {
devInfoMapper.deleteDevInfoProperties(Long.valueOf(maDevInfo.getMaId()));
devMergeMapper.delFile(maDevInfo.getMaId());
devInfoMapper.insertDevInfoProperties(Long.valueOf(maDevInfo.getMaId()), maDevInfo.getPropertyVoList());
MaDevQc maDevQc = new MaDevQc();
maDevQc.setMaId(maDevInfo.getMaId());
maDevQc.setQcCode(maDevInfo.getCode());
maDevQc.setCreateBy(String.valueOf(SecurityUtils.getUserId()));
maDevQc.setCreateTime(DateUtils.getNowDate());
maDevQc.setQcCom(Optional.ofNullable(SecurityUtils.getLoginUser().getSysUser().getCompanyId()).orElse(SecurityUtils.getLoginUser().getSysUser().getDeptId()).toString());
maDevQc.setNextCheckTime(maDevInfo.getNextMaintenanceDate());
qcMapper.insertDevQc(maDevQc);
maDevInfo.getAppearanceImages().forEach(item -> {
// 这里编写对每个 image 的处理逻辑比如打印处理等
item.setFileType(1);
item.setMaId(maDevInfo.getMaId());
item.setCreator(Math.toIntExact(SecurityUtils.getLoginUser().getUserid()));
devMergeMapper.interFile(item);
});
maDevInfo.getCertificates().forEach(item -> {
// 这里编写对每个 image 的处理逻辑比如打印处理等
item.setFileType(2);
item.setMaId(maDevInfo.getMaId());
item.setCreator(Math.toIntExact(SecurityUtils.getLoginUser().getUserid()));
devMergeMapper.interFile(item);
});
maDevInfo.getInspectionReports().forEach(item -> {
// 这里编写对每个 image 的处理逻辑比如打印处理等
item.setFileType(3);
item.setMaId(maDevInfo.getMaId());
item.setCreator(Math.toIntExact(SecurityUtils.getLoginUser().getUserid()));
devMergeMapper.interFile(item);
});
maDevInfo.getPurchaseInvoices().forEach(item -> {
// 这里编写对每个 image 的处理逻辑比如打印处理等
item.setFileType(4);
item.setMaId(maDevInfo.getMaId());
item.setCreator(Math.toIntExact(SecurityUtils.getLoginUser().getUserid()));
devMergeMapper.interFile(item);
});
}
return i > 0 ? AjaxResult.success("修改成功") : AjaxResult.error("修改失败");
} catch (Exception e) {
log.error(e.getMessage());
return AjaxResult.error();
}
}
private static final DateTimeFormatter DATE_FORMATTER = DateTimeFormatter.ofPattern("yyMMdd");
private static final String SEPARATOR = "-";

View File

@ -647,7 +647,7 @@ public class LargeScreenController extends BaseController {
}
@GetMapping("/getMaType")
public AjaxResult getMaType(@RequestParam Long firstLevelId ) {
public AjaxResult getMaType(@RequestParam Long firstLevelId) {
try {
List<Map<String, Object>> maType = leaseInfoMapper.getMaType(firstLevelId);
return !maType.isEmpty() ? AjaxResult.success(maType) : AjaxResult.error();
@ -665,4 +665,80 @@ public class LargeScreenController extends BaseController {
return AjaxResult.error();
}
}
@GetMapping("/statByTypeAndAgeDetails")
public AjaxResult statByTypeAndAgeDetails(@RequestParam String type) {
try {
List<Map<String, Object>> maType = leaseInfoMapper.statByTypeAndAgeDetails(type);
return AjaxResult.success(maType);
} catch (Exception e) {
return AjaxResult.error();
}
}
@GetMapping("/statByTypeAndAgeByEquipment")
public AjaxResult statByTypeAndAgeByEquipment(@RequestParam String type) {
try {
List<Map<String, Object>> maType = leaseInfoMapper.statByTypeAndAgeByEquipment(type);
return AjaxResult.success(maType);
} catch (Exception e) {
System.err.println(e.getMessage());
return AjaxResult.error();
}
}
@GetMapping("/statByTypeAndAgeByCity")
public AjaxResult statByTypeAndAgeByCity(@RequestParam String type) {
try {
List<Map<String, Object>> maType = leaseInfoMapper.statByTypeAndAgeByCity(type);
return AjaxResult.success(maType);
} catch (Exception e) {
System.err.println(e.getMessage());
return AjaxResult.error();
}
}
@GetMapping("/statByTypeAndAgeByConfiguration")
public AjaxResult statByTypeAndAgeByConfiguration() {
try {
List<Map<String, Object>> maType = leaseInfoMapper.statByTypeAndAgeByConfiguration();
return AjaxResult.success(maType);
} catch (Exception e) {
System.err.println(e.getMessage());
return AjaxResult.error();
}
}
@GetMapping("/statByTypeAndAgeByTurnoverRate")
public AjaxResult statByTypeAndAgeByTurnoverRate() {
try {
List<Map<String, Object>> maType = leaseInfoMapper.statByTypeAndAgeByTurnoverRate();
return AjaxResult.success(maType);
} catch (Exception e) {
System.err.println(e.getMessage());
return AjaxResult.error();
}
}
@GetMapping("/statByTypeAndAgeByUsageRate")
public AjaxResult statByTypeAndAgeByUsageRate() {
try {
List<Map<String, Object>> maType = leaseInfoMapper.statByTypeAndAgeByUsageRate();
return AjaxResult.success(maType);
} catch (Exception e) {
System.err.println(e.getMessage());
return AjaxResult.error();
}
}
}

View File

@ -302,6 +302,7 @@ public class ProvinceScreenServiceImpl implements ProvinceScreenService {
res.put("annualTotal", "140.6");
//在建工程数 TODO e基建2.0获取
res.put("projectNUm", 50);
//在用装备数
//自用--2
int inUse = devInfoMapper.getEquipmentStatus("2");

View File

@ -239,4 +239,16 @@ public interface MaLeaseInfoMapper {
@MapKey("targetType")
List<Map<String, Object>> statByTypeAndAge();
List<Map<String, Object>> statByTypeAndAgeDetails(String type);
List<Map<String, Object>> statByTypeAndAgeByEquipment(String type);
List<Map<String, Object>> statByTypeAndAgeByCity(String type);
List<Map<String, Object>> statByTypeAndAgeByConfiguration();
List<Map<String, Object>> statByTypeAndAgeByTurnoverRate();
List<Map<String, Object>> statByTypeAndAgeByUsageRate();
}

View File

@ -10,6 +10,7 @@
<result property="inputType" column="input_type"/>
<result property="propertyName" column="property_name"/>
<result property="propertyValue" column="property_value"/>
<result property="value" column="value"/>
<result property="createTime" column="create_time"/>
</resultMap>
@ -83,14 +84,27 @@
<!-- 根据ID查询特征值 -->
<select id="selectById" resultMap="EquipmentPropertyResult">
SELECT id, type_id, must_have, input_type, property_name, property_value, create_time
SELECT id,
type_id,
must_have,
input_type,
property_name,
property_value,
create_time
FROM ma_type_properties
WHERE id = #{id}
</select>
<!-- 根据类型ID查询特征值 -->
<select id="selectByTypeId" resultMap="EquipmentPropertyResult">
SELECT id, type_id, must_have, input_type, property_name, property_value, create_time
SELECT id,
type_id,
must_have,
input_type,
property_name,
property_value AS value,
create_time
FROM ma_type_properties
WHERE type_id = #{typeId}
ORDER BY create_time DESC

View File

@ -16,9 +16,9 @@
<insert id="addDetailsInfo">
insert into cs_device_change_details(change_id, dev_id, use_time, reason_id,
reason_val, remark,
repairman, repair_time, repair_content, del_flag)
repairman, repair_time, repair_content, del_flag, num, status)
values (#{changeId}, #{devId}, #{useTime}, #{reasonId}, #{reasonVal}, #{remark}, #{repairman}, #{repairTime},
#{repairContent}, 0)
#{repairContent}, 0, #{num}, #{status})
</insert>
<insert id="addDevChangeDetails">
@ -38,6 +38,11 @@
ma_status = #{changeStatus}
where ma_id = #{devId}
</update>
<update id="updateDevInfoData">
update ma_dev_info
set expiration_time = #{useTime}
where ma_id = #{devId}
</update>
<delete id="deleteDevChangeDetails">
delete
from cs_device_detials
@ -155,6 +160,8 @@
<if test="startTime!=null and startTime!='' and endTime!=null and endTime!='' ">
and cds.create_time between #{startTime} and #{endTime}
</if>
ORDER BY cds.create_time DESC
</select>
<select id="getChangeUnit" resultType="java.lang.String">
select bci.company_name compName

View File

@ -270,8 +270,13 @@
</select>
<select id="getProperties" resultType="com.bonus.material.device.domain.vo.DevInfoPropertyVo">
select property_name propertyName, property_value propertyValue
from ma_dev_info_properties
select mtp.id AS id,
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 ma_id = #{maId}
</select>
@ -314,6 +319,7 @@
mdi.device_name AS name,
mdi.item_type_model As specificationModel,
mdi.code AS code,
mdi.up_down_status AS upDownStatus,
mdi.change_status AS status,
TIMESTAMPDIFF(YEAR, mdi.production_date, CURDATE()) AS serviceLife,
jsp.pro_code AS usingProjectId,
@ -329,16 +335,38 @@
mdi.unit AS unit,
mdq.next_check_time AS nextMaintenanceDate,
mdi.max_working_hours AS maxServiceLifeYears,
( SELECT COUNT(*) FROM cs_device_change_details WHERE dev_id = mdi.ma_id AND repair_time IS NOT NULL ) AS
repairCount,
(
SELECT
COUNT(*)
FROM
cs_device_change_details
WHERE
dev_id = mdi.ma_id
AND `status` IN ( 2, 3 )) AS usageCount,
sc.name AS province
from ma_dev_info mdi
LEFT JOIN ma_type_view mtv ON mtv.typeId = mdi.type_id
LEFT JOIN jj_sing_project jsp ON mdi.on_project = jsp.pro_code
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
LEFT JOIN (SELECT max( next_check_time) next_check_time,ma_id from ma_dev_qc GROUP BY ma_id ) mdq on
mdi.ma_id=mdq.ma_id
LEFT JOIN ma_supplier ms ON ms.supplier_id = mdi.supplier_id
LEFT JOIN sys_cnarea sc ON sc.area_code = mdi.province_id
<where>
mdi.is_active = '1'
mdi.is_active = '1' and mdi.entry_status = '1'
<if test="typeId != null">
and (
mtv.mainGxId = #{typeId}
or mtv.childGxId = #{typeId}
or mtv.devCategoryId = #{typeId}
or mtv.devSubcategoryId = #{typeId}
or mtv.devNameId = #{typeId}
or mtv.devModelId = #{typeId}
or mtv.maxTypeId = #{typeId}
)
</if>
<if test="name != null and name != ''">
and mdi.device_name like concat('%', #{name}, '%')
</if>
@ -451,7 +479,8 @@
LEFT JOIN ma_type_view mtv ON mtv.typeId = mdi.type_id
LEFT JOIN jj_sing_project jsp ON mdi.on_project = jsp.pro_code
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
LEFT JOIN (SELECT max( next_check_time) next_check_time,ma_id from ma_dev_qc GROUP BY ma_id ) mdq on
mdi.ma_id=mdq.ma_id
LEFT JOIN ma_supplier ms ON ms.supplier_id = mdi.supplier_id
<where>
mdi.is_active = '1' AND mdi.ma_id =#{maId}

View File

@ -543,11 +543,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<insert id="insertDevInfoProperties">
insert into
ma_dev_info_properties(ma_id, property_name, property_value, create_time)
ma_dev_info_properties(ma_id,property_id, property_name, property_value, create_time)
values
<foreach collection="list" item="item" index="index" separator=",">
(
#{maId},
#{item.id},
#{item.propertyName},
#{item.propertyValue},
now()

View File

@ -30,7 +30,7 @@
</if>
GROUP BY
aaa.id
ORDER BY aaa.status DESC
ORDER BY aaa.status DESC ,aaa.create_time DESC
</select>
<select id="devList" resultType="com.bonus.material.device.domain.vo.DevInfoVo">
@ -174,6 +174,11 @@
set is_active = 0
where id = #{id}
</delete>
<delete id="delFile">
DELETE
FROM ma_dev_file
WHERE ma_id = #{maId}
</delete>
<update id="updateDevice">
<foreach collection="list" item="data" separator=";">
@ -183,10 +188,50 @@
<update id="updateChangeStatus">
<foreach collection="list" item="data" separator=";">
UPDATE ma_dev_info SET change_status ='1' WHERE ma_id = #{data.key}
UPDATE ma_dev_info SET change_status ='1',ma_status = '1' WHERE ma_id = #{data.key}
</foreach>
</update>
<update id="updateDeviceByMaId">
UPDATE ma_dev_info
SET
device_name = #{name},
device_count = #{count},
item_type_model = #{specificationModel},
manage_type = #{manageType},
<!-- 非必填字段:有值才更新 -->
<if test="originalCode != null and originalCode != ''">
identify_code = #{originalCode},
</if>
<if test="typeId != null">
type_id = #{typeId},
</if>
<if test="manufacturerId != null and manufacturerId != ''">
supplier_id = #{manufacturerId},
</if>
<if test="productionDate != null">
production_date = #{productionDate},
</if>
<if test="maxServiceLifeYears != null">
max_working_hours = #{maxServiceLifeYears},
</if>
<if test="expirationTime != null">
expiration_time = #{expirationTime},
</if>
<if test="originalValue != null">
buy_price = #{originalValue},
</if>
<if test="purchaseDate != null">
purchase_date = #{purchaseDate},
</if>
<if test="unit != null">
unit = #{unit}
</if>
WHERE
<!-- 注意:此处需要替换为实际的主键字段,例如 id -->
ma_id = #{maId}
</update>
<select id="getDevNoCheck" resultType="int">
select count(1)
from ma_dev_info
@ -337,7 +382,8 @@
LEFT JOIN ma_type_view mtv ON mtv.typeId = mdi.type_id
LEFT JOIN jj_sing_project jsp ON mdi.on_project = jsp.pro_code
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
LEFT JOIN (SELECT max( next_check_time) next_check_time,ma_id from ma_dev_qc GROUP BY ma_id ) mdq on
mdi.ma_id=mdq.ma_id
LEFT JOIN ma_supplier ms ON ms.supplier_id = mdi.supplier_id
LEFT JOIN sys_cnarea sc ON sc.area_code = mdi.province_id
<where>
@ -435,7 +481,8 @@
LEFT JOIN ma_type_view mtv ON mtv.typeId = mdi.type_id
LEFT JOIN jj_sing_project jsp ON mdi.on_project = jsp.pro_code
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
LEFT JOIN (SELECT max( next_check_time) next_check_time,ma_id from ma_dev_qc GROUP BY ma_id ) mdq on
mdi.ma_id=mdq.ma_id
LEFT JOIN ma_supplier ms ON ms.supplier_id = mdi.supplier_id
LEFT JOIN sys_cnarea sc ON sc.area_code = mdi.province_id
<where>

View File

@ -67,7 +67,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select>
<select id="getMaTypeInfoList" resultType="com.bonus.common.biz.domain.TreeNode">
select type_id as id, parent_id as parentId, type_name as name, `level` as level, manage_type as manageType,lease_price as leasePrice,
select type_id as id, parent_id as parentId, type_name as name, `level` as level, manage_type as manageType,
unit_name as unitName,maintenance_alarm_day as maintenanceAlarmDay
from ma_type
where del_flag = '0'

View File

@ -785,10 +785,12 @@
END) AS fiveOrTen
FROM
ma_dev_info mdi
LEFT JOIN ma_type_view mtv ON mtv.devModelId = mdi.type_id
LEFT JOIN ma_type_view mtv ON mtv.typeId = mdi.type_id
WHERE
-- 过滤目标proType只处理需要的三类
mtv.proType IN ('变电施工类', '架空输电线路工程', '电缆(海缆)工程')
and mdi.change_status != '4'
and mdi.is_active = '1'
AND mdi.production_date IS NOT NULL -- 排除无效出厂日期
GROUP BY
-- 按映射后的目标类型分组确保结果按line/substation/cable聚合
@ -800,4 +802,176 @@
ORDER BY
targetType;
</select>
<select id="statByTypeAndAgeDetails" resultType="java.util.Map">
-- 直接在MySQL中处理proType映射并统计返回目标格式所需数据
SELECT
-- 统计各指标
SUM(mdi.buy_price) AS price,
COUNT(1) AS num,
-- 10年及以上数量11年+
SUM(CASE
WHEN TIMESTAMPDIFF(YEAR, mdi.production_date, CURDATE()) >= 11
THEN 1
ELSE 0
END) AS ten,
-- 0-5年数量
SUM(CASE
WHEN TIMESTAMPDIFF(YEAR, mdi.production_date, CURDATE()) BETWEEN 0 AND 5
THEN 1
ELSE 0
END) AS five,
-- 5-10年数量6-10年
SUM(CASE
WHEN TIMESTAMPDIFF(YEAR, mdi.production_date, CURDATE()) BETWEEN 6 AND 10
THEN 1
ELSE 0
END) AS fiveOrTen
FROM ma_dev_info mdi
LEFT JOIN ma_type_view mtv ON mtv.typeId = mdi.type_id
WHERE mdi.change_status != '4'
and mdi.is_active = '1'
and
-- 过滤目标proType只处理需要的三类
mtv.maxTypeId IN (#{type})
</select>
<select id="statByTypeAndAgeByEquipment" resultType="java.util.Map">
-- 直接在MySQL中处理proType映射并统计返回目标格式所需数据
SELECT
-- 统计各指标
sum(mdi.buy_price) AS price,
mtv.devSubcategory AS name
FROM ma_dev_info mdi
LEFT JOIN ma_type_view mtv ON mtv.typeId = mdi.type_id and mdi.change_status != '4' and mdi.is_active ='1'
WHERE
-- 过滤目标proType只处理需要的三类
mtv.maxTypeId IN (#{type})
GROUP BY mtv.devSubcategory
ORDER BY
price DESC
</select>
<select id="statByTypeAndAgeByCity" resultType="java.util.Map">
SELECT sd.dept_name AS name,
-- 统计关联了mdi且mtv.maxTypeId=5080的总数量
SUM(CASE
WHEN mtv.maxTypeId = #{type} THEN 1 -- 仅当类型符合时计数
ELSE 0
END) AS count,
-- 统计状态为2/3且类型符合的数量
SUM(CASE
WHEN mtv.maxTypeId = #{type} AND mdi.change_status IN (2, 3)
THEN 1
ELSE 0
END) AS useCount
FROM sys_dept sd
-- 左连接设备表(过滤有效数据)
LEFT JOIN ma_dev_info mdi
ON mdi.on_company = sd.dept_id
AND mdi.change_status != '4'
AND mdi.is_active = '1'
-- 左连接类型表不在这里加maxTypeId条件避免过滤主表
LEFT JOIN ma_type_view mtv
ON mtv.typeId = mdi.type_id
GROUP BY sd.dept_id, sd.dept_name -- 按部门分组,确保所有部门都被列出
ORDER BY count DESC
</select>
<select id="statByTypeAndAgeByConfiguration" resultType="java.util.Map">
SELECT sd.dept_name AS name,
-- 统计关联了mdi且mtv.maxTypeId=5080的总数量
sum(mdi.buy_price) AS price,
SUM(CASE
WHEN sd.dept_id = mdi.on_company THEN 1 -- 仅当类型符合时计数
ELSE 0
END) AS count,
SUM(CASE
WHEN mtv.maxTypeId = 5080 THEN 1 -- 仅当类型符合时计数
ELSE 0
END) AS cableCount,
SUM(CASE
WHEN mtv.maxTypeId = 5010 THEN 1 -- 仅当类型符合时计数
ELSE 0
END) AS substationCount,
SUM(CASE
WHEN mtv.maxTypeId = 5474 THEN 1 -- 仅当类型符合时计数
ELSE 0
END) AS lineCount
FROM sys_dept sd
-- 左连接设备表(过滤有效数据)
LEFT JOIN ma_dev_info mdi
ON mdi.on_company = sd.dept_id
AND mdi.change_status != '4'
AND mdi.is_active = '1'
-- 左连接类型表不在这里加maxTypeId条件避免过滤主表
LEFT JOIN ma_type_view mtv
ON mtv.typeId = mdi.type_id
GROUP BY sd.dept_id, sd.dept_name -- 按部门分组,确保所有部门都被列出
ORDER BY count DESC
</select>
<select id="statByTypeAndAgeByTurnoverRate" resultType="java.util.Map">
SELECT DATE_FORMAT(cdcd.use_time, '%Y/%m') AS month,-- 月份
-- 统计不同类型设备的有效使用次数status为2/3
SUM(CASE WHEN mtv.maxTypeId = 5080 AND cdcd.`status` IN (2, 3) THEN 1 ELSE 0 END) AS cableCount,
SUM(CASE WHEN mtv.maxTypeId = 5010 AND cdcd.`status` IN (2, 3) THEN 1 ELSE 0 END) AS substationCount,
SUM(CASE WHEN mtv.maxTypeId = 5474 AND cdcd.`status` IN (2, 3) THEN 1 ELSE 0 END) AS lineCount
FROM cs_device_change_details cdcd -- 左连接设备表(过滤有效设备)
LEFT JOIN ma_dev_info mdi ON cdcd.dev_id = mdi.ma_id -- 关联设备ID
AND mdi.change_status != '4'
AND mdi.is_active = '1' -- 左连接类型表(获取设备类型)
LEFT JOIN ma_type_view mtv ON mtv.typeId = mdi.type_id -- 过滤无效的使用时间可选避免NULL的月份
WHERE cdcd.use_time IS NOT NULL
AND mdi.ma_id IS NOT NULL -- 按「设备ID+月份」分组(核心修正)
GROUP BY DATE_FORMAT(cdcd.use_time, '%Y/%m') -- 按月份和设备ID排序结果更清晰
ORDER BY month;
</select>
<select id="statByTypeAndAgeByUsageRate" resultType="java.util.Map">
SELECT DATE_FORMAT(cdcd.use_time, '%Y/%m') AS month,
-- 计算各类型的使用比例(有效使用次数 / 该类型总设备数)
SUM(CASE WHEN mtv.maxTypeId = 5080 AND cdcd.`status` IN (2, 3) THEN 1 ELSE 0 END)
/ total.cable_total AS cableCount,
SUM(CASE WHEN mtv.maxTypeId = 5010 AND cdcd.`status` IN (2, 3) THEN 1 ELSE 0 END)
/ total.substation_total AS substationCount,
SUM(CASE WHEN mtv.maxTypeId = 5474 AND cdcd.`status` IN (2, 3) THEN 1 ELSE 0 END)
/ total.line_total AS lineCount
FROM cs_device_change_details cdcd
-- 左连接设备表(过滤有效设备)
LEFT JOIN ma_dev_info mdi
ON cdcd.dev_id = mdi.ma_id
AND mdi.change_status != '4'
AND mdi.is_active = '1'
-- 左连接类型表(获取设备类型)
LEFT JOIN ma_type_view mtv
ON mtv.typeId = mdi.type_id
-- 一次性计算所有类型的总设备数(复用结果)
CROSS JOIN (SELECT
-- 计算5080类型的总设备数
COUNT(DISTINCT CASE WHEN mtv.maxTypeId = 5080 THEN mdi.ma_id END) AS cable_total,
-- 计算5010类型的总设备数
COUNT(DISTINCT CASE WHEN mtv.maxTypeId = 5010 THEN mdi.ma_id END) AS substation_total,
-- 计算5474类型的总设备数
COUNT(DISTINCT CASE WHEN mtv.maxTypeId = 5474 THEN mdi.ma_id END) AS line_total
FROM ma_dev_info mdi
-- 这里用INNER JOIN更合适因为需要mtv.maxTypeId匹配
INNER JOIN ma_type_view mtv
ON mtv.typeId = mdi.type_id
WHERE mdi.change_status != '4'
AND mdi.is_active = '1') total
-- 过滤条件(确保使用时间有效,且设备存在)
WHERE cdcd.use_time IS NOT NULL
AND mdi.ma_id IS NOT NULL
-- 按月份分组
GROUP BY DATE_FORMAT(cdcd.use_time, '%Y/%m'),
total.cable_total, -- 子查询结果是常量,分组时带上不影响结果,避免某些数据库报错
total.substation_total,
total.line_total,
cdcd.dev_id
ORDER BY month;
</select>
</mapper>