dcs 5 månader sedan
förälder
incheckning
96ab1adb98

+ 16 - 2
virgo.api/src/main/java/com/bosshand/virgo/api/operate/controller/OperateDeviceController.java

@@ -1,6 +1,8 @@
 package com.bosshand.virgo.api.operate.controller;
 
+import com.bosshand.virgo.api.operate.model.Godown;
 import com.bosshand.virgo.api.operate.model.OperateDevice;
+import com.bosshand.virgo.api.operate.service.GodownService;
 import com.bosshand.virgo.api.operate.service.OperateDeviceService;
 import com.bosshand.virgo.core.response.Response;
 import io.swagger.annotations.Api;
@@ -20,10 +22,18 @@ public class OperateDeviceController {
     @Autowired
     OperateDeviceService operateDeviceService;
 
+    @Autowired
+    GodownService godownService;
+
     @ApiOperation(value = "获取", notes = "获取")
     @RequestMapping(value = "/{id}", method = RequestMethod.GET)
-    public Response get(@PathVariable long id){
-        return Response.ok(operateDeviceService.get(id));
+    public Response get(@PathVariable long id) {
+        OperateDevice operateDevice = operateDeviceService.get(id);
+        if (operateDevice != null) {
+            Godown godown = godownService.getGodown(operateDevice.getGodownId());
+            operateDevice.setGodownName(godown != null ? godown.getName() : null);
+        }
+        return Response.ok(operateDevice);
     }
 
     @ApiOperation(value = "统计设备状态", notes = "统计设备状态")
@@ -37,6 +47,10 @@ public class OperateDeviceController {
     public Response list(@RequestBody OperateDevice operateDevice, @PathVariable int currPage, @PathVariable int pageSize) {
         int totalCount = operateDeviceService.getTotalCount(operateDevice);
         List<OperateDevice> dataList = operateDeviceService.limit(operateDevice, currPage, pageSize);
+        for (OperateDevice od : dataList) {
+            Godown godown = godownService.getGodown(od.getGodownId());
+            od.setGodownName(godown != null ? godown.getName() : null);
+        }
         Map<String, Integer> map = operateDeviceService.getCount(operateDevice);
         Map<String, Object> result = new HashMap<>();
         result.put("dataList", dataList);

+ 219 - 41
virgo.api/src/main/java/com/bosshand/virgo/api/operate/model/OperateDevice.java

@@ -1,16 +1,12 @@
 package com.bosshand.virgo.api.operate.model;
 
 /**
- *  设备信息
+ * 设备信息
  */
 public class OperateDevice {
 
     private long id;
 
-    private long operateDeviceLevelId;
-
-    private String operateDeviceLevelIds;
-
     private long projectId;
 
     private long projectItemId;
@@ -19,36 +15,138 @@ public class OperateDevice {
 
     private long projectItemTargetRoomId;
 
+    /**
+     * 生成的编码
+     */
+    private String code;
+
+    /**
+     * 层级id
+     */
+    private long operateDeviceLevelId;
+
+    private String operateDeviceLevelIds;
+
+    /**
+     * 名称
+     */
     private String name;
 
+    /**
+     * 类型
+     */
     private int type;
 
+    /**
+     * 设计编码
+     */
     private String designNumber;
 
+    /**
+     * 资产编号
+     */
     private String assetNumber;
 
+    /**
+     * 设备编码
+     */
     private String deviceNumber;
 
+    /**
+     * 设备品牌
+     */
     private String deviceBrand;
 
+    /**
+     * 设备型号
+     */
     private String deviceModel;
 
+    /**
+     * 设备序列号
+     */
     private String deviceSerialNumber;
 
+    /**
+     * 附件
+     */
     private String attachment;
 
+    /**
+     * 备注
+     */
     private String remark;
 
+    /**
+     * 文档
+     */
+    private String document;
+
+    /**
+     * 状态
+     */
+    private int state;
+
+    /**
+     * 仓库Id
+     */
+    private long godownId;
+
+    /**
+     * 仓库名称
+     */
+    private String godownName;
+
+    /**
+     * 模型绑定类型 1.绑定已存在模型,直接存构件ID,2.绑定模型库模型,3.自己上传
+     */
+    private int modelBindType;
+
+    /**
+     * 模型绑定内容
+     */
+    private String modelBindContent;
+
+    /**
+     * 厂家
+     */
+    private String manufacturer;
+
+    /**
+     * 联系人
+     */
+    private String liaison;
+
+    /**
+     * 联系方式
+     */
+    private String liaisonPhone;
+
+    /**
+     * 进场时间
+     */
+    private String entryTime;
+
+    /**
+     * 维保记录
+     */
+    private String maintenanceRecord;
+
+    /**
+     * DTO 变更总数
+     */
     private int changeCount;
 
+    /**
+     * DTO 折旧总数
+     */
     private int depreciationCount;
 
+    /**
+     * DTO 库存总数
+     */
     private int inventoryCount;
 
-    private String document;
-
-    private int state;
-
     public long getId() {
         return id;
     }
@@ -57,22 +155,6 @@ public class OperateDevice {
         this.id = id;
     }
 
-    public long getOperateDeviceLevelId() {
-        return operateDeviceLevelId;
-    }
-
-    public void setOperateDeviceLevelId(long operateDeviceLevelId) {
-        this.operateDeviceLevelId = operateDeviceLevelId;
-    }
-
-    public String getOperateDeviceLevelIds() {
-        return operateDeviceLevelIds;
-    }
-
-    public void setOperateDeviceLevelIds(String operateDeviceLevelIds) {
-        this.operateDeviceLevelIds = operateDeviceLevelIds;
-    }
-
     public long getProjectId() {
         return projectId;
     }
@@ -105,6 +187,30 @@ public class OperateDevice {
         this.projectItemTargetRoomId = projectItemTargetRoomId;
     }
 
+    public String getCode() {
+        return code;
+    }
+
+    public void setCode(String code) {
+        this.code = code;
+    }
+
+    public long getOperateDeviceLevelId() {
+        return operateDeviceLevelId;
+    }
+
+    public void setOperateDeviceLevelId(long operateDeviceLevelId) {
+        this.operateDeviceLevelId = operateDeviceLevelId;
+    }
+
+    public String getOperateDeviceLevelIds() {
+        return operateDeviceLevelIds;
+    }
+
+    public void setOperateDeviceLevelIds(String operateDeviceLevelIds) {
+        this.operateDeviceLevelIds = operateDeviceLevelIds;
+    }
+
     public String getName() {
         return name;
     }
@@ -185,6 +291,94 @@ public class OperateDevice {
         this.remark = remark;
     }
 
+    public String getDocument() {
+        return document;
+    }
+
+    public void setDocument(String document) {
+        this.document = document;
+    }
+
+    public int getState() {
+        return state;
+    }
+
+    public void setState(int state) {
+        this.state = state;
+    }
+
+    public long getGodownId() {
+        return godownId;
+    }
+
+    public void setGodownId(long godownId) {
+        this.godownId = godownId;
+    }
+
+    public String getGodownName() {
+        return godownName;
+    }
+
+    public void setGodownName(String godownName) {
+        this.godownName = godownName;
+    }
+
+    public int getModelBindType() {
+        return modelBindType;
+    }
+
+    public void setModelBindType(int modelBindType) {
+        this.modelBindType = modelBindType;
+    }
+
+    public String getModelBindContent() {
+        return modelBindContent;
+    }
+
+    public void setModelBindContent(String modelBindContent) {
+        this.modelBindContent = modelBindContent;
+    }
+
+    public String getManufacturer() {
+        return manufacturer;
+    }
+
+    public void setManufacturer(String manufacturer) {
+        this.manufacturer = manufacturer;
+    }
+
+    public String getLiaison() {
+        return liaison;
+    }
+
+    public void setLiaison(String liaison) {
+        this.liaison = liaison;
+    }
+
+    public String getLiaisonPhone() {
+        return liaisonPhone;
+    }
+
+    public void setLiaisonPhone(String liaisonPhone) {
+        this.liaisonPhone = liaisonPhone;
+    }
+
+    public String getEntryTime() {
+        return entryTime;
+    }
+
+    public void setEntryTime(String entryTime) {
+        this.entryTime = entryTime;
+    }
+
+    public String getMaintenanceRecord() {
+        return maintenanceRecord;
+    }
+
+    public void setMaintenanceRecord(String maintenanceRecord) {
+        this.maintenanceRecord = maintenanceRecord;
+    }
+
     public int getChangeCount() {
         return changeCount;
     }
@@ -208,20 +402,4 @@ public class OperateDevice {
     public void setInventoryCount(int inventoryCount) {
         this.inventoryCount = inventoryCount;
     }
-
-    public String getDocument() {
-        return document;
-    }
-
-    public void setDocument(String document) {
-        this.document = document;
-    }
-
-    public int getState() {
-        return state;
-    }
-
-    public void setState(int state) {
-        this.state = state;
-    }
 }

+ 15 - 0
virgo.api/src/main/java/com/bosshand/virgo/api/operate/service/GodownService.java

@@ -5,7 +5,9 @@ import com.bosshand.virgo.api.operate.model.Godown;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 @Service
 public class GodownService {
@@ -13,15 +15,28 @@ public class GodownService {
     @Autowired
     GodownDao godownDao;
 
+    public Map<Long, Godown> godownCache = new HashMap<Long, Godown>();
+
+    public Godown getGodown(Long pk) {
+        Godown godown = godownCache.get(pk);
+        if (godown == null) {
+            godown = get(pk);
+            godownCache.put((Long) pk, godown);
+        }
+        return godown;
+    }
+
     public int save(Godown data) {
         return godownDao.save(data);
     }
 
     public int delete(long id) {
+        godownCache.clear();
         return godownDao.delete(id);
     }
 
     public int update(Godown data) {
+        godownCache.clear();
         return godownDao.update(data);
     }
 

+ 53 - 2
virgo.api/src/main/resources/mapper/OperateDeviceMapper.xml

@@ -23,6 +23,16 @@
         <result column="remark" property="remark"/>
         <result column="document" property="document"/>
         <result column="state" property="state"/>
+
+        <result column="code" property="code"/>
+        <result column="godownId" property="godownId"/>
+        <result column="modelBindType" property="modelBindType"/>
+        <result column="modelBindContent" property="modelBindContent"/>
+        <result column="manufacturer" property="manufacturer"/>
+        <result column="liaison" property="liaison"/>
+        <result column="liaisonPhone" property="liaisonPhone"/>
+        <result column="entryTime" property="entryTime"/>
+        <result column="maintenanceRecord" property="maintenanceRecord"/>
     </resultMap>
 
     <select id="get" resultMap="OperateDeviceResult">
@@ -48,6 +58,16 @@
             <if test="deviceModel!=null">and deviceModel=#{deviceModel}</if>
             <if test="deviceSerialNumber!=null">and deviceSerialNumber=#{deviceSerialNumber}</if>
             <if test="state!=0">and state=#{state}</if>
+
+            <if test="code!=null">and code=#{code}</if>
+            <if test="godownId!=0">and godownId=#{godownId}</if>
+            <if test="modelBindType!=0">and modelBindType=#{modelBindType}</if>
+            <if test="modelBindContent!=null">and modelBindContent=#{modelBindContent}</if>
+            <if test="manufacturer!=manufacturer">and manufacturer=#{manufacturer}</if>
+            <if test="liaison!=null">and liaison=#{liaison}</if>
+            <if test="liaisonPhone!=null">and liaisonPhone=#{liaisonPhone}</if>
+            <if test="entryTime!=null">and entryTime=#{entryTime}</if>
+            <if test="maintenanceRecord!=null">and maintenanceRecord=#{maintenanceRecord}</if>
         </where>
     </select>
 
@@ -70,6 +90,16 @@
             <if test="deviceModel!=null">and deviceModel=#{deviceModel}</if>
             <if test="deviceSerialNumber!=null">and deviceSerialNumber=#{deviceSerialNumber}</if>
             <if test="state!=0">and state=#{state}</if>
+
+            <if test="code!=null">and code=#{code}</if>
+            <if test="godownId!=0">and godownId=#{godownId}</if>
+            <if test="modelBindType!=0">and modelBindType=#{modelBindType}</if>
+            <if test="modelBindContent!=null">and modelBindContent=#{modelBindContent}</if>
+            <if test="manufacturer!=null">and manufacturer=#{manufacturer}</if>
+            <if test="liaison!=null">and liaison=#{liaison}</if>
+            <if test="liaisonPhone!=null">and liaisonPhone=#{liaisonPhone}</if>
+            <if test="entryTime!=null">and entryTime=#{entryTime}</if>
+            <if test="maintenanceRecord!=null">and maintenanceRecord=#{maintenanceRecord}</if>
         </where>
     </select>
 
@@ -92,15 +122,27 @@
             <if test="od.deviceModel!=null">and deviceModel=#{od.deviceModel}</if>
             <if test="od.deviceSerialNumber!=null">and deviceSerialNumber=#{od.deviceSerialNumber}</if>
             <if test="od.state!=0">and state=#{od.state}</if>
+
+            <if test="od.code!=null">and code=#{od.code}</if>
+            <if test="od.godownId!=0">and godownId=#{od.godownId}</if>
+            <if test="od.modelBindType!=0">and modelBindType=#{od.modelBindType}</if>
+            <if test="od.modelBindContent!=null">and modelBindContent=#{od.modelBindContent}</if>
+            <if test="od.manufacturer!=null">and manufacturer=#{od.manufacturer}</if>
+            <if test="od.liaison!=null">and liaison=#{od.liaison}</if>
+            <if test="od.liaisonPhone!=null">and liaisonPhone=#{od.liaisonPhone}</if>
+            <if test="od.entryTime!=null">and entryTime=#{od.entryTime}</if>
+            <if test="od.maintenanceRecord!=null">and maintenanceRecord=#{od.maintenanceRecord}</if>
         </where>
         limit #{currIndex} , #{pageSize}
     </select>
 
     <insert id="save" parameterType="com.bosshand.virgo.api.operate.model.OperateDevice" useGeneratedKeys="true" keyProperty="id">
         INSERT into operate_device(operateDeviceLevelId, projectId, projectItemId, projectItemTargetId, projectItemTargetRoomId, name, type, designNumber, assetNumber, deviceNumber,
-                                   deviceBrand, deviceModel, deviceSerialNumber, attachment, remark, document, state)
+                                   deviceBrand, deviceModel, deviceSerialNumber, attachment, remark, document, state,
+                                   code, godownId, modelBindType, modelBindContent, manufacturer, liaison, liaisonPhone, entryTime, maintenanceRecord)
         values(#{operateDeviceLevelId}, #{projectId}, #{projectItemId}, #{projectItemTargetId}, #{projectItemTargetRoomId}, #{name}, #{type}, #{designNumber},
-               #{assetNumber}, #{deviceNumber}, #{deviceBrand}, #{deviceModel}, #{deviceSerialNumber}, #{attachment}, #{remark}, #{document}, #{state})
+               #{assetNumber}, #{deviceNumber}, #{deviceBrand}, #{deviceModel}, #{deviceSerialNumber}, #{attachment}, #{remark}, #{document}, #{state},
+               #{code}, #{godownId}, #{modelBindType}, #{modelBindContent}, #{manufacturer}, #{liaison}, #{liaisonPhone}, #{entryTime}, #{maintenanceRecord})
     </insert>
 
     <update id="update" parameterType="com.bosshand.virgo.api.operate.model.OperateDevice">
@@ -123,6 +165,15 @@
             <if test="remark!=null">remark=#{remark},</if>
             <if test="document!=null">document=#{document},</if>
             <if test="state!=0">state=#{state},</if>
+
+            <if test="godownId!=0">and godownId=#{godownId},</if>
+            <if test="modelBindType!=0">and modelBindType=#{modelBindType},</if>
+            <if test="modelBindContent!=null">and modelBindContent=#{modelBindContent},</if>
+            <if test="manufacturer!=null">and manufacturer=#{manufacturer},</if>
+            <if test="liaison!=null">and liaison=#{liaison},</if>
+            <if test="liaisonPhone!=null">and liaisonPhone=#{liaisonPhone},</if>
+            <if test="entryTime!=null">and entryTime=#{entryTime},</if>
+            <if test="maintenanceRecord!=null">and maintenanceRecord=#{maintenanceRecord},</if>
         </trim>
         WHERE id=#{id}
     </update>