chenshudong 1 mēnesi atpakaļ
vecāks
revīzija
4ef155ffa1

+ 2 - 1
airport-common/src/main/java/com/sundot/airport/common/enums/BaseAttachmentSourceTypeEnum.java

@@ -14,7 +14,8 @@ public enum BaseAttachmentSourceTypeEnum {
14 14
     CHECK_CORRECTION("CHECK_CORRECTION", "问题整改表"),
15 15
     CHECK_CORRECTION_RECORD("CHECK_CORRECTION_RECORD", "问题整改表中检查记录"),
16 16
     CHECK_PROJECT_ITEM("CHECK_PROJECT_ITEM", "检查项明细表"),
17
-    ITEM_SEIZURE_ITEMS("ITEM_SEIZURE_ITEMS", "查获物品明细表");
17
+    ITEM_SEIZURE_ITEMS("ITEM_SEIZURE_ITEMS", "查获物品明细表"),
18
+    EQUIPMENT_LEDGER("EQUIPMENT_LEDGER", "设备台账表");
18 19
 
19 20
     private final String code;
20 21
     private final String info;

+ 29 - 0
airport-equipment/src/main/java/com/sundot/airport/equipment/domain/EquipmentLedger.java

@@ -1,11 +1,14 @@
1 1
 package com.sundot.airport.equipment.domain;
2 2
 
3 3
 import java.util.Date;
4
+import java.util.List;
4 5
 
5 6
 import com.baomidou.mybatisplus.annotation.IdType;
7
+import com.baomidou.mybatisplus.annotation.TableField;
6 8
 import com.baomidou.mybatisplus.annotation.TableId;
7 9
 import com.baomidou.mybatisplus.annotation.TableName;
8 10
 import com.fasterxml.jackson.annotation.JsonFormat;
11
+import com.sundot.airport.common.domain.BaseAttachment;
9 12
 import org.apache.commons.lang3.builder.ToStringBuilder;
10 13
 import org.apache.commons.lang3.builder.ToStringStyle;
11 14
 import com.sundot.airport.common.annotation.Excel;
@@ -140,6 +143,14 @@ public class EquipmentLedger extends BaseEntity {
140 143
     @Excel(name = "定/自检小组组员2名称")
141 144
     private String inspectionTeamMember2Name;
142 145
 
146
+    /** 设备定检记录列表*/
147
+    @TableField(exist = false)
148
+    private List<EquipmentInspectionRecord> equipmentInspectionRecordList;
149
+
150
+    /** 设备照片列表*/
151
+    @TableField(exist = false)
152
+    private List<BaseAttachment> baseAttachmentList;
153
+
143 154
     public void setTenantId(String tenantId) {
144 155
         this.tenantId = tenantId;
145 156
     }
@@ -356,6 +367,22 @@ public class EquipmentLedger extends BaseEntity {
356 367
         return inspectionTeamMember2Name;
357 368
     }
358 369
 
370
+    public List<EquipmentInspectionRecord> getEquipmentInspectionRecordList() {
371
+        return equipmentInspectionRecordList;
372
+    }
373
+
374
+    public void setEquipmentInspectionRecordList(List<EquipmentInspectionRecord> equipmentInspectionRecordList) {
375
+        this.equipmentInspectionRecordList = equipmentInspectionRecordList;
376
+    }
377
+
378
+    public List<BaseAttachment> getBaseAttachmentList() {
379
+        return baseAttachmentList;
380
+    }
381
+
382
+    public void setBaseAttachmentList(List<BaseAttachment> baseAttachmentList) {
383
+        this.baseAttachmentList = baseAttachmentList;
384
+    }
385
+
359 386
     @Override
360 387
     public String toString() {
361 388
         return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
@@ -391,6 +418,8 @@ public class EquipmentLedger extends BaseEntity {
391 418
                 .append("inspectionTeamMember1Name", getInspectionTeamMember1Name())
392 419
                 .append("inspectionTeamMember2Id", getInspectionTeamMember2Id())
393 420
                 .append("inspectionTeamMember2Name", getInspectionTeamMember2Name())
421
+                .append("equipmentInspectionRecordList", getEquipmentInspectionRecordList())
422
+                .append("baseAttachmentList", getBaseAttachmentList())
394 423
                 .toString();
395 424
     }
396 425
 }

+ 131 - 5
airport-equipment/src/main/java/com/sundot/airport/equipment/service/impl/EquipmentLedgerServiceImpl.java

@@ -2,13 +2,23 @@ package com.sundot.airport.equipment.service.impl;
2 2
 
3 3
 import java.util.List;
4 4
 
5
+import cn.hutool.core.collection.CollUtil;
6
+import cn.hutool.core.util.ObjUtil;
7
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
5 8
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
9
+import com.sundot.airport.common.domain.BaseAttachment;
10
+import com.sundot.airport.common.enums.BaseAttachmentSourceTypeEnum;
11
+import com.sundot.airport.common.exception.ServiceException;
12
+import com.sundot.airport.common.service.IBaseAttachmentService;
6 13
 import com.sundot.airport.common.utils.DateUtils;
14
+import com.sundot.airport.equipment.domain.EquipmentInspectionRecord;
15
+import com.sundot.airport.equipment.service.IEquipmentInspectionRecordService;
7 16
 import org.springframework.beans.factory.annotation.Autowired;
8 17
 import org.springframework.stereotype.Service;
9 18
 import com.sundot.airport.equipment.mapper.EquipmentLedgerMapper;
10 19
 import com.sundot.airport.equipment.domain.EquipmentLedger;
11 20
 import com.sundot.airport.equipment.service.IEquipmentLedgerService;
21
+import org.springframework.transaction.annotation.Transactional;
12 22
 
13 23
 /**
14 24
  * 设备台账Service业务层处理
@@ -20,6 +30,10 @@ import com.sundot.airport.equipment.service.IEquipmentLedgerService;
20 30
 public class EquipmentLedgerServiceImpl extends ServiceImpl<EquipmentLedgerMapper, EquipmentLedger> implements IEquipmentLedgerService {
21 31
     @Autowired
22 32
     private EquipmentLedgerMapper equipmentLedgerMapper;
33
+    @Autowired
34
+    private IEquipmentInspectionRecordService equipmentInspectionRecordService;
35
+    @Autowired
36
+    private IBaseAttachmentService baseAttachmentService;
23 37
 
24 38
     /**
25 39
      * 查询设备台账
@@ -29,7 +43,20 @@ public class EquipmentLedgerServiceImpl extends ServiceImpl<EquipmentLedgerMappe
29 43
      */
30 44
     @Override
31 45
     public EquipmentLedger selectEquipmentLedgerById(Long id) {
32
-        return equipmentLedgerMapper.selectEquipmentLedgerById(id);
46
+        EquipmentLedger result = equipmentLedgerMapper.selectEquipmentLedgerById(id);
47
+        if (ObjUtil.isNull(result)) {
48
+            return result;
49
+        }
50
+        LambdaQueryWrapper<EquipmentInspectionRecord> recordQueryWrapper = new LambdaQueryWrapper<>();
51
+        recordQueryWrapper.eq(EquipmentInspectionRecord::getSourceId, result.getId());
52
+        List<EquipmentInspectionRecord> equipmentInspectionRecordList = equipmentInspectionRecordService.getBaseMapper().selectList(recordQueryWrapper);
53
+        result.setEquipmentInspectionRecordList(equipmentInspectionRecordList);
54
+        LambdaQueryWrapper<BaseAttachment> attachmentQueryWrapper = new LambdaQueryWrapper<>();
55
+        attachmentQueryWrapper.eq(BaseAttachment::getSourceType, BaseAttachmentSourceTypeEnum.EQUIPMENT_LEDGER.getCode());
56
+        attachmentQueryWrapper.eq(BaseAttachment::getSourceId, result.getId());
57
+        List<BaseAttachment> baseAttachmentList = baseAttachmentService.getBaseMapper().selectList(attachmentQueryWrapper);
58
+        result.setBaseAttachmentList(baseAttachmentList);
59
+        return result;
33 60
     }
34 61
 
35 62
     /**
@@ -49,10 +76,36 @@ public class EquipmentLedgerServiceImpl extends ServiceImpl<EquipmentLedgerMappe
49 76
      * @param equipmentLedger 设备台账
50 77
      * @return 结果
51 78
      */
79
+    @Transactional(rollbackFor = Exception.class)
52 80
     @Override
53 81
     public int insertEquipmentLedger(EquipmentLedger equipmentLedger) {
82
+        EquipmentLedger temp = new EquipmentLedger();
83
+        temp.setEquipmentSerialNumber(equipmentLedger.getEquipmentSerialNumber());
84
+        List<EquipmentLedger> tempList = equipmentLedgerMapper.selectEquipmentLedgerList(temp);
85
+        if (CollUtil.isNotEmpty(tempList)) {
86
+            throw new ServiceException("该设备序列号已存在");
87
+        }
54 88
         equipmentLedger.setCreateTime(DateUtils.getNowDate());
55
-        return equipmentLedgerMapper.insertEquipmentLedger(equipmentLedger);
89
+        int result = equipmentLedgerMapper.insertEquipmentLedger(equipmentLedger);
90
+        if (CollUtil.isNotEmpty(equipmentLedger.getEquipmentInspectionRecordList())) {
91
+            equipmentLedger.getEquipmentInspectionRecordList().forEach(equipmentInspectionRecord -> {
92
+                equipmentInspectionRecord.setSourceId(equipmentLedger.getId());
93
+                equipmentInspectionRecord.setCreateBy(equipmentLedger.getCreateBy());
94
+                equipmentInspectionRecord.setCreateTime(DateUtils.getNowDate());
95
+                equipmentInspectionRecordService.insertEquipmentInspectionRecord(equipmentInspectionRecord);
96
+            });
97
+        }
98
+        if (CollUtil.isNotEmpty(equipmentLedger.getBaseAttachmentList())) {
99
+            equipmentLedger.getBaseAttachmentList().forEach(baseAttachment -> {
100
+                baseAttachment.setSourceType(BaseAttachmentSourceTypeEnum.EQUIPMENT_LEDGER.getCode());
101
+                baseAttachment.setSourceTypeName(BaseAttachmentSourceTypeEnum.EQUIPMENT_LEDGER.getInfo());
102
+                baseAttachment.setSourceId(equipmentLedger.getId());
103
+                baseAttachment.setCreateBy(equipmentLedger.getCreateBy());
104
+                baseAttachment.setCreateTime(DateUtils.getNowDate());
105
+                baseAttachmentService.insertBaseAttachment(baseAttachment);
106
+            });
107
+        }
108
+        return result;
56 109
     }
57 110
 
58 111
     /**
@@ -61,10 +114,51 @@ public class EquipmentLedgerServiceImpl extends ServiceImpl<EquipmentLedgerMappe
61 114
      * @param equipmentLedger 设备台账
62 115
      * @return 结果
63 116
      */
117
+    @Transactional(rollbackFor = Exception.class)
64 118
     @Override
65 119
     public int updateEquipmentLedger(EquipmentLedger equipmentLedger) {
66 120
         equipmentLedger.setUpdateTime(DateUtils.getNowDate());
67
-        return equipmentLedgerMapper.updateEquipmentLedger(equipmentLedger);
121
+        int result = equipmentLedgerMapper.updateEquipmentLedger(equipmentLedger);
122
+        // 删除旧数据
123
+        LambdaQueryWrapper<EquipmentInspectionRecord> recordOldQueryWrapper = new LambdaQueryWrapper<>();
124
+        recordOldQueryWrapper.eq(EquipmentInspectionRecord::getSourceId, equipmentLedger.getId());
125
+        List<EquipmentInspectionRecord> equipmentInspectionRecordOldList = equipmentInspectionRecordService.getBaseMapper().selectList(recordOldQueryWrapper);
126
+        if (CollUtil.isNotEmpty(equipmentInspectionRecordOldList)) {
127
+            equipmentInspectionRecordService.removeBatchByIds(equipmentInspectionRecordOldList);
128
+        }
129
+        LambdaQueryWrapper<BaseAttachment> attachmentOldQueryWrapper = new LambdaQueryWrapper<>();
130
+        attachmentOldQueryWrapper.eq(BaseAttachment::getSourceType, BaseAttachmentSourceTypeEnum.EQUIPMENT_LEDGER.getCode());
131
+        attachmentOldQueryWrapper.eq(BaseAttachment::getSourceId, equipmentLedger.getId());
132
+        List<BaseAttachment> baseAttachmentOldList = baseAttachmentService.getBaseMapper().selectList(attachmentOldQueryWrapper);
133
+        if (CollUtil.isNotEmpty(baseAttachmentOldList)) {
134
+            baseAttachmentService.removeBatchByIds(baseAttachmentOldList);
135
+        }
136
+        // 新增新数据
137
+        if (CollUtil.isNotEmpty(equipmentLedger.getEquipmentInspectionRecordList())) {
138
+            equipmentLedger.getEquipmentInspectionRecordList().forEach(equipmentInspectionRecord -> {
139
+                equipmentInspectionRecord.setId(null);
140
+                equipmentInspectionRecord.setSourceId(equipmentLedger.getId());
141
+                equipmentInspectionRecord.setCreateBy(equipmentLedger.getCreateBy());
142
+                equipmentInspectionRecord.setCreateTime(DateUtils.getNowDate());
143
+                equipmentInspectionRecord.setUpdateBy(equipmentLedger.getCreateBy());
144
+                equipmentInspectionRecord.setUpdateTime(DateUtils.getNowDate());
145
+                equipmentInspectionRecordService.insertEquipmentInspectionRecord(equipmentInspectionRecord);
146
+            });
147
+        }
148
+        if (CollUtil.isNotEmpty(equipmentLedger.getBaseAttachmentList())) {
149
+            equipmentLedger.getBaseAttachmentList().forEach(baseAttachment -> {
150
+                baseAttachment.setId(null);
151
+                baseAttachment.setSourceType(BaseAttachmentSourceTypeEnum.EQUIPMENT_LEDGER.getCode());
152
+                baseAttachment.setSourceTypeName(BaseAttachmentSourceTypeEnum.EQUIPMENT_LEDGER.getInfo());
153
+                baseAttachment.setSourceId(equipmentLedger.getId());
154
+                baseAttachment.setCreateBy(equipmentLedger.getCreateBy());
155
+                baseAttachment.setCreateTime(DateUtils.getNowDate());
156
+                baseAttachment.setUpdateBy(equipmentLedger.getCreateBy());
157
+                baseAttachment.setUpdateTime(DateUtils.getNowDate());
158
+                baseAttachmentService.insertBaseAttachment(baseAttachment);
159
+            });
160
+        }
161
+        return result;
68 162
     }
69 163
 
70 164
     /**
@@ -73,9 +167,26 @@ public class EquipmentLedgerServiceImpl extends ServiceImpl<EquipmentLedgerMappe
73 167
      * @param ids 需要删除的设备台账主键
74 168
      * @return 结果
75 169
      */
170
+    @Transactional(rollbackFor = Exception.class)
76 171
     @Override
77 172
     public int deleteEquipmentLedgerByIds(Long[] ids) {
78
-        return equipmentLedgerMapper.deleteEquipmentLedgerByIds(ids);
173
+        int result = equipmentLedgerMapper.deleteEquipmentLedgerByIds(ids);
174
+        for (Long id : ids) {
175
+            LambdaQueryWrapper<EquipmentInspectionRecord> detailQueryWrapper = new LambdaQueryWrapper<>();
176
+            detailQueryWrapper.eq(EquipmentInspectionRecord::getSourceId, id);
177
+            List<EquipmentInspectionRecord> equipmentInspectionRecordList = equipmentInspectionRecordService.getBaseMapper().selectList(detailQueryWrapper);
178
+            if (CollUtil.isNotEmpty(equipmentInspectionRecordList)) {
179
+                equipmentInspectionRecordService.removeBatchByIds(equipmentInspectionRecordList);
180
+            }
181
+            LambdaQueryWrapper<BaseAttachment> attachmentQueryWrapper = new LambdaQueryWrapper<>();
182
+            attachmentQueryWrapper.eq(BaseAttachment::getSourceType, BaseAttachmentSourceTypeEnum.EQUIPMENT_LEDGER.getCode());
183
+            attachmentQueryWrapper.eq(BaseAttachment::getSourceId, id);
184
+            List<BaseAttachment> baseAttachmentList = baseAttachmentService.getBaseMapper().selectList(attachmentQueryWrapper);
185
+            if (CollUtil.isNotEmpty(baseAttachmentList)) {
186
+                baseAttachmentService.removeBatchByIds(baseAttachmentList);
187
+            }
188
+        }
189
+        return result;
79 190
     }
80 191
 
81 192
     /**
@@ -84,8 +195,23 @@ public class EquipmentLedgerServiceImpl extends ServiceImpl<EquipmentLedgerMappe
84 195
      * @param id 设备台账主键
85 196
      * @return 结果
86 197
      */
198
+    @Transactional(rollbackFor = Exception.class)
87 199
     @Override
88 200
     public int deleteEquipmentLedgerById(Long id) {
89
-        return equipmentLedgerMapper.deleteEquipmentLedgerById(id);
201
+        int result = equipmentLedgerMapper.deleteEquipmentLedgerById(id);
202
+        LambdaQueryWrapper<EquipmentInspectionRecord> detailQueryWrapper = new LambdaQueryWrapper<>();
203
+        detailQueryWrapper.eq(EquipmentInspectionRecord::getSourceId, id);
204
+        List<EquipmentInspectionRecord> equipmentInspectionRecordList = equipmentInspectionRecordService.getBaseMapper().selectList(detailQueryWrapper);
205
+        if (CollUtil.isNotEmpty(equipmentInspectionRecordList)) {
206
+            equipmentInspectionRecordService.removeBatchByIds(equipmentInspectionRecordList);
207
+        }
208
+        LambdaQueryWrapper<BaseAttachment> attachmentQueryWrapper = new LambdaQueryWrapper<>();
209
+        attachmentQueryWrapper.eq(BaseAttachment::getSourceType, BaseAttachmentSourceTypeEnum.EQUIPMENT_LEDGER.getCode());
210
+        attachmentQueryWrapper.eq(BaseAttachment::getSourceId, id);
211
+        List<BaseAttachment> baseAttachmentList = baseAttachmentService.getBaseMapper().selectList(attachmentQueryWrapper);
212
+        if (CollUtil.isNotEmpty(baseAttachmentList)) {
213
+            baseAttachmentService.removeBatchByIds(baseAttachmentList);
214
+        }
215
+        return result;
90 216
     }
91 217
 }

+ 1 - 0
airport-equipment/src/main/resources/mapper/equipment/EquipmentInspectionRecordMapper.xml

@@ -60,6 +60,7 @@
60 60
                 #{inspectionNature}
61 61
             </if>
62 62
         </where>
63
+        order by create_time desc
63 64
     </select>
64 65
 
65 66
     <select id="selectEquipmentInspectionRecordById" parameterType="Long" resultMap="EquipmentInspectionRecordResult">

+ 1 - 0
airport-equipment/src/main/resources/mapper/equipment/EquipmentLedgerMapper.xml

@@ -122,6 +122,7 @@
122 122
                 inspection_team_member2_name like concat('%', #{inspectionTeamMember2Name}, '%')
123 123
             </if>
124 124
         </where>
125
+        order by create_time desc
125 126
     </select>
126 127
 
127 128
     <select id="selectEquipmentLedgerById" parameterType="Long" resultMap="EquipmentLedgerResult">