소스 검색

解决vo到dto直接的实体映射问题,并将数据库定位协议,使用对象落库数据库,不在使用string

weijinhao 3 년 전
부모
커밋
8c0beedc06

+ 9 - 0
fm-sop/src/main/java/com/persagy/fm/sop/controller/GroupSopController.java

@@ -32,6 +32,8 @@ public class GroupSopController {
 
     /**
      * 集团sop-新增页-添加发布状态sop
+     *
+     * 重构完成
      * @param saveSopVo
      * @return
      * @throws Exception
@@ -47,6 +49,8 @@ public class GroupSopController {
 
     /**
      * 集团sop-新增页-验证sop
+     *
+     * 重构完成
      * @param saveSopVo
      * @return
      * @throws Exception
@@ -60,12 +64,15 @@ public class GroupSopController {
 
     /**
      * 集团sop-新增页-添加草稿状态sop
+     *
+     * 重构完成
      * @param
      * @return
      * @throws Exception
      */
     @PostMapping("/addDraftSop")
     public String addDraftSop(@RequestBody SaveSopEditVo saveSopEditVo) throws Exception{
+        saveSopEditVo.setProject_id(CommonConst.group_sop_id);
         String sopId = groupSopService.addDraftSop(saveSopEditVo);
         Map<String, Object> ret = new HashMap<>();
         ret.put("sop_id",sopId);
@@ -74,6 +81,7 @@ public class GroupSopController {
 
     /**
      * 集团sop-编辑页-编辑sop时验证sop名称
+     * 重构完成
      * @param verifySopNameVo
      * @return
      * @throws Exception
@@ -87,6 +95,7 @@ public class GroupSopController {
 
     /**
      * 详细页-查询当前sop被引用的sop列表
+     * 重构完成
      * @param querySopReferenceVo
      * @return
      * @throws Exception

+ 10 - 10
fm-sop/src/main/java/com/persagy/fm/sop/dao/SopEditMapper.xml

@@ -8,21 +8,21 @@
         <result column="sop_id" property="sopId" />
         <result column="project_id" property="projectId" />
         <result column="extend_field" property="extendField" />
-        <result column="operator" property="operator" />
+        <result column="operator" property="operator" typeHandler="com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler"/>
         <result column="sop_name" property="sopName" />
         <result column="sop_type" property="sopType" />
         <result column="no_obj" property="noObj" />
-        <result column="domains" property="domains" />
-        <result column="tools" property="tools" />
-        <result column="order_type" property="orderType" />
-        <result column="fit_objs" property="fitObjs" />
-        <result column="equip_model_ids" property="equipModelIds" />
-        <result column="labels" property="labels" />
-        <result column="steps" property="steps" />
-        <result column="related_data" property="relatedData" />
+        <result column="domains" property="domains" typeHandler="com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler"/>
+        <result column="tools" property="tools" typeHandler="com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler"/>
+        <result column="order_type" property="orderType" typeHandler="com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler"/>
+        <result column="fit_objs" property="fitObjs" typeHandler="com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler"/>
+        <result column="equip_model_ids" property="equipModelIds" typeHandler="com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler"/>
+        <result column="labels" property="labels" typeHandler="com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler"/>
+        <result column="steps" property="steps" typeHandler="com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler"/>
+        <result column="related_data" property="relatedData" typeHandler="com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler"/>
         <result column="sop_status" property="sopStatus" />
         <result column="publish_status" property="publishStatus" />
-        <result column="ref_sop_ids" property="refSopIds" />
+        <result column="ref_sop_ids" property="refSopIds" typeHandler="com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler"/>
         <result column="version" property="version" />
         <result column="version_count" property="versionCount" />
         <result column="version_explain" property="versionExplain" />

+ 11 - 11
fm-sop/src/main/java/com/persagy/fm/sop/dao/SopMapper.xml

@@ -7,26 +7,26 @@
         <id column="sop_id" property="sopId" />
         <result column="project_id" property="projectId" />
         <result column="extend_field" property="extendField" />
-        <result column="operator" property="operator" />
+        <result column="operator" property="operator" typeHandler="com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler"/>
         <result column="sop_name" property="sopName" />
         <result column="sop_type" property="sopType" />
         <result column="no_obj" property="noObj" />
-        <result column="domains" property="domains" />
-        <result column="order_type" property="orderType" />
-        <result column="tools" property="tools" />
-        <result column="fit_objs" property="fitObjs" />
-        <result column="equip_model_ids" property="equipModelIds" />
-        <result column="labels" property="labels" />
+        <result column="domains" property="domains" typeHandler="com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler"/>
+        <result column="order_type" property="orderType" typeHandler="com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler"/>
+        <result column="tools" property="tools" typeHandler="com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler"/>
+        <result column="fit_objs" property="fitObjs" typeHandler="com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler"/>
+        <result column="equip_model_ids" property="equipModelIds" typeHandler="com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler"/>
+        <result column="labels" property="labels" typeHandler="com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler"/>
         <result column="steps_version" property="stepsVersion" />
-        <result column="steps" property="steps" />
-        <result column="related_data" property="relatedData" />
+        <result column="steps" property="steps" typeHandler="com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler"/>
+        <result column="related_data" property="relatedData" typeHandler="com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler"/>
         <result column="sop_status" property="sopStatus" />
         <result column="publish_status" property="publishStatus" />
-        <result column="ref_sop_ids" property="refSopIds" />
+        <result column="ref_sop_ids" property="refSopIds" typeHandler="com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler"/>
         <result column="version" property="version" />
         <result column="version_count" property="versionCount" />
         <result column="version_explain" property="versionExplain" />
-        <result column="version_exp" property="versionExp" />
+        <result column="version_exp" property="versionExp" typeHandler="com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler"/>
         <result column="valid" property="valid" />
         <result column="update_time" property="updateTime" />
     </resultMap>

+ 74 - 0
fm-sop/src/main/java/com/persagy/fm/sop/mapper/SopMapper.java

@@ -0,0 +1,74 @@
+package com.persagy.fm.sop.mapper;
+
+import com.persagy.fm.sop.model.dto.Sop;
+import com.persagy.fm.sop.model.dto.SopEdit;
+import com.persagy.fm.sop.model.vo.SaveSopEditVo;
+import com.persagy.fm.sop.model.vo.SaveSopVo;
+import org.mapstruct.Mapper;
+import org.mapstruct.Mapping;
+import org.mapstruct.factory.Mappers;
+
+@Mapper
+public interface SopMapper {
+
+    SopMapper INSTANCE = Mappers.getMapper(SopMapper.class );
+
+    @Mapping(source = "sop_id" ,target ="sopId" )
+    @Mapping(source = "project_id" ,target ="projectId" )
+    @Mapping(source = "extend_field" ,target ="extendField" )
+    @Mapping(source = "operator" ,target ="operator" )
+    @Mapping(source = "sop_name" ,target ="sopName" )
+    //@Mapping(source = "sop_type" ,target ="sopType" )
+    @Mapping(source = "no_obj" ,target ="noObj" )
+    @Mapping(source = "domains" ,target ="domains" )
+    @Mapping(source = "order_type" ,target ="orderType" )
+    @Mapping(source = "tools" ,target ="tools" )
+    @Mapping(source = "fit_objs" ,target ="fitObjs" )
+    @Mapping(source = "equip_model_ids" ,target ="equipModelIds" )
+    @Mapping(source = "labels" ,target ="labels" )
+    //@Mapping(source = "steps_version" ,target ="stepsVersion" )
+    @Mapping(source = "steps" ,target ="steps" )
+    @Mapping(source = "related_data" ,target ="relatedData" )
+    //@Mapping(source = "sop_status" ,target ="sopStatus" )
+    //@Mapping(source = "publish_status" ,target ="publishStatus" )
+    //@Mapping(source = "ref_sop_ids" ,target ="refSopIds" )
+    //@Mapping(source = "version" ,target ="version" )
+    //@Mapping(source = "version_count" ,target ="versionCount" )
+    //@Mapping(source = "version_explain" ,target ="versionExplain" )
+    //@Mapping(source = "version_exp" ,target ="versionExp" )
+    //@Mapping(source = "valid" ,target ="valid" )
+    //@Mapping(source = "update_time" ,target ="updateTime" )
+    Sop SaveSopVoToSop(SaveSopVo saveSopVo);
+
+    @Mapping(source = "sop_edit_id" ,target ="sopEditId" )
+    @Mapping(source = "sop_id" ,target ="sopId" )
+    @Mapping(source = "project_id" ,target ="projectId" )
+    @Mapping(source = "extend_field" ,target ="extendField" )
+    @Mapping(source = "operator" ,target ="operator" )
+    @Mapping(source = "sop_name" ,target ="sopName" )
+    //@Mapping(source = "sop_type" ,target ="sopType" )
+    @Mapping(source = "no_obj" ,target ="noObj" )
+    @Mapping(source = "domains" ,target ="domains" )
+    @Mapping(source = "order_type" ,target ="orderType" )
+    @Mapping(source = "tools" ,target ="tools" )
+    @Mapping(source = "fit_objs" ,target ="fitObjs" )
+    @Mapping(source = "equip_model_ids" ,target ="equipModelIds" )
+    @Mapping(source = "labels" ,target ="labels" )
+    //@Mapping(source = "steps_version" ,target ="stepsVersion" )
+    @Mapping(source = "steps" ,target ="steps" )
+    @Mapping(source = "related_data" ,target ="relatedData" )
+        //@Mapping(source = "sop_status" ,target ="sopStatus" )
+        //@Mapping(source = "publish_status" ,target ="publishStatus" )
+        //@Mapping(source = "ref_sop_ids" ,target ="refSopIds" )
+        //@Mapping(source = "version" ,target ="version" )
+        //@Mapping(source = "version_count" ,target ="versionCount" )
+        //@Mapping(source = "version_explain" ,target ="versionExplain" )
+        //@Mapping(source = "version_exp" ,target ="versionExp" )
+        //@Mapping(source = "valid" ,target ="valid" )
+        //@Mapping(source = "update_time" ,target ="updateTime" )
+    SopEdit SaveSopEditVoToSopEdit(SaveSopEditVo saveSopEditVo);
+
+
+
+
+}

+ 207 - 159
fm-sop/src/main/java/com/persagy/fm/sop/model/dto/Sop.java

@@ -1,108 +1,50 @@
 package com.persagy.fm.sop.model.dto;
 
 import com.baomidou.mybatisplus.annotation.IdType;
-import com.baomidou.mybatisplus.extension.activerecord.Model;
+import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableId;
-import java.io.Serializable;
+import com.baomidou.mybatisplus.extension.activerecord.Model;
+import com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler;
+
+import javax.validation.Valid;
+import javax.validation.constraints.NotEmpty;
+import javax.validation.constraints.NotNull;
+import java.util.List;
 
 /**
- * <p>
- * 
- * </p>
- *
- * @author weijinhao
- * @since 2021-03-17
+ * sop表 落库协议
+ * v1.0
  */
 public class Sop extends Model<Sop> {
-
-    private static final long serialVersionUID=1L;
-
-    /**
-     * sopid SOP+uuid
-     */
     @TableId(value = "sop_id", type = IdType.ASSIGN_UUID)
     private String sopId;
 
-    /**
-     * sop所属的项目 集团sop的项目Id默认为"group_sop_id"
-     */
     private String projectId;
-
-    /**
-     * 项目类型:同一级建筑功能类型 ,字段使用原有的extend_field保存
-     */
     private String extendField;
+    @TableField(typeHandler = FastjsonTypeHandler.class)
+    private OperatorBean operator;
 
-    /**
-     * 表示sop的发布者、更新者
-     */
-    private String operator;
-
-    /**
-     * 名称,项目下唯一
-     */
     private String sopName;
-
-    /**
-     * 1-集团,2-项目专用
-     */
     private String sopType;
 
-    /**
-     * 0-否 1-是
-     */
     private String noObj;
-
-    /**
-     * 数组[code,code],
-子项:SE-强电,WE-弱电,AC-空调,WS-给排水,FF-消防,SP-安防
-     */
-    private String domains;
-
-    /**
-     * 数组[code,code]
-     */
-    private String orderType;
-
-    /**
-     * 数组[{"tool":“……”,"from_step":true}]
-     */
-    private String tools;
-
-    /**
-     * [{
-      "obj_id:"***", //对象id
-      "obj_name:"对象名称1", //对象名称
-      "obj_type":"equip",  //对象类型,子项见后边
-}]
-obj_tye:build-建筑、floor-楼层、space-空间、system-系统实例、equip-设备实例,system_class-系统类、equip_class-设备类
-     */
-    private String fitObjs;
-
-    /**
-     * [equip_model_id,equip_model_id]
-     */
-    private String equipModelIds;
-
-    /**
-     * [name,name]
-     */
-    private String labels;
-
-    /**
-     * 步骤的版本
-     */
+    @TableField(typeHandler = FastjsonTypeHandler.class)
+    private List<String> domains;
+    @TableField(typeHandler = FastjsonTypeHandler.class)
+    private List<String> orderType;
+    @TableField(typeHandler = FastjsonTypeHandler.class)
+    private List<ToolsBean> tools;
+    @TableField(typeHandler = FastjsonTypeHandler.class)
+    private List<@Valid FitObjsBean> fitObjs;
+    @TableField(typeHandler = FastjsonTypeHandler.class)
+    private List<String> equipModelIds;
+    @TableField(typeHandler = FastjsonTypeHandler.class)
+    private List<String> labels;
     private String stepsVersion;
-
-    /**
-     * 步骤
-     */
-    private String steps;
-
-    /**
-     * [{"name":"***',“url”:“***”},{}]
-     */
-    private String relatedData;
+    @TableField(typeHandler = FastjsonTypeHandler.class)
+    private List<SopStepsBean> steps;
+    @TableField(typeHandler = FastjsonTypeHandler.class)
+    private List<RelatedDataBean> relatedData;
 
     /**
      * 1-已发布、2-已作废
@@ -117,18 +59,19 @@ obj_tye:build-建筑、floor-楼层、space-空间、system-系统实例、equip
     /**
      * id的数组[sop_id,sop_id]
      */
-    private String refSopIds;
+    @TableField(typeHandler = FastjsonTypeHandler.class)
+    private List<String> refSopIds;
 
     private String version;
 
     private Integer versionCount;
 
     private String versionExplain;
-
     /**
      * 数组[“描述”,“描述”]
      */
-    private String versionExp;
+    @TableField(typeHandler = FastjsonTypeHandler.class)
+    private List<String> versionExp;
 
     /**
      * 是否有效
@@ -137,6 +80,29 @@ obj_tye:build-建筑、floor-楼层、space-空间、system-系统实例、equip
 
     private String updateTime;
 
+    public List<String> getVersionExp() {
+        return versionExp;
+    }
+
+    public void setVersionExp(List<String> versionExp) {
+        this.versionExp = versionExp;
+    }
+
+    public Boolean getValid() {
+        return valid;
+    }
+
+    public void setValid(Boolean valid) {
+        this.valid = valid;
+    }
+
+    public String getUpdateTime() {
+        return updateTime;
+    }
+
+    public void setUpdateTime(String updateTime) {
+        this.updateTime = updateTime;
+    }
 
     public String getSopId() {
         return sopId;
@@ -162,11 +128,11 @@ obj_tye:build-建筑、floor-楼层、space-空间、system-系统实例、equip
         this.extendField = extendField;
     }
 
-    public String getOperator() {
+    public OperatorBean getOperator() {
         return operator;
     }
 
-    public void setOperator(String operator) {
+    public void setOperator(OperatorBean operator) {
         this.operator = operator;
     }
 
@@ -194,51 +160,51 @@ obj_tye:build-建筑、floor-楼层、space-空间、system-系统实例、equip
         this.noObj = noObj;
     }
 
-    public String getDomains() {
+    public List<String> getDomains() {
         return domains;
     }
 
-    public void setDomains(String domains) {
+    public void setDomains(List<String> domains) {
         this.domains = domains;
     }
 
-    public String getOrderType() {
+    public List<String> getOrderType() {
         return orderType;
     }
 
-    public void setOrderType(String orderType) {
+    public void setOrderType(List<String> orderType) {
         this.orderType = orderType;
     }
 
-    public String getTools() {
+    public List<ToolsBean> getTools() {
         return tools;
     }
 
-    public void setTools(String tools) {
+    public void setTools(List<ToolsBean> tools) {
         this.tools = tools;
     }
 
-    public String getFitObjs() {
+    public List<FitObjsBean> getFitObjs() {
         return fitObjs;
     }
 
-    public void setFitObjs(String fitObjs) {
+    public void setFitObjs(List<FitObjsBean> fitObjs) {
         this.fitObjs = fitObjs;
     }
 
-    public String getEquipModelIds() {
+    public List<String> getEquipModelIds() {
         return equipModelIds;
     }
 
-    public void setEquipModelIds(String equipModelIds) {
+    public void setEquipModelIds(List<String> equipModelIds) {
         this.equipModelIds = equipModelIds;
     }
 
-    public String getLabels() {
+    public List<String> getLabels() {
         return labels;
     }
 
-    public void setLabels(String labels) {
+    public void setLabels(List<String> labels) {
         this.labels = labels;
     }
 
@@ -250,19 +216,19 @@ obj_tye:build-建筑、floor-楼层、space-空间、system-系统实例、equip
         this.stepsVersion = stepsVersion;
     }
 
-    public String getSteps() {
+    public List<SopStepsBean> getSteps() {
         return steps;
     }
 
-    public void setSteps(String steps) {
+    public void setSteps(List<SopStepsBean> steps) {
         this.steps = steps;
     }
 
-    public String getRelatedData() {
+    public List<RelatedDataBean> getRelatedData() {
         return relatedData;
     }
 
-    public void setRelatedData(String relatedData) {
+    public void setRelatedData(List<RelatedDataBean> relatedData) {
         this.relatedData = relatedData;
     }
 
@@ -282,11 +248,11 @@ obj_tye:build-建筑、floor-楼层、space-空间、system-系统实例、equip
         this.publishStatus = publishStatus;
     }
 
-    public String getRefSopIds() {
+    public List<String> getRefSopIds() {
         return refSopIds;
     }
 
-    public void setRefSopIds(String refSopIds) {
+    public void setRefSopIds(List<String> refSopIds) {
         this.refSopIds = refSopIds;
     }
 
@@ -314,63 +280,145 @@ obj_tye:build-建筑、floor-楼层、space-空间、system-系统实例、equip
         this.versionExplain = versionExplain;
     }
 
-    public String getVersionExp() {
-        return versionExp;
-    }
+    public static class OperatorBean {
+        /**
+         * id : ***
+         * name : 燕小六
+         */
+
+        private String id;
+        private String name;
+
+        public String getId() {
+            return id;
+        }
+
+        public void setId(String id) {
+            this.id = id;
+        }
+
+        public String getName() {
+            return name;
+        }
+
+        public void setName(String name) {
+            this.name = name;
+        }
+    }
+
+    public static class ToolsBean {
+        /**
+         * tool : name
+         * from_step : true
+         */
+
+        private String tool;
+        private Boolean from_step;
+
+        public String getTool() {
+            return tool;
+        }
+
+        public void setTool(String tool) {
+            this.tool = tool;
+        }
 
-    public void setVersionExp(String versionExp) {
-        this.versionExp = versionExp;
-    }
+        public Boolean isFrom_step() {
+            return from_step;
+        }
 
-    public Boolean getValid() {
-        return valid;
+        public void setFrom_step(Boolean from_step) {
+            this.from_step = from_step;
+        }
     }
 
-    public void setValid(Boolean valid) {
-        this.valid = valid;
-    }
+    public static class FitObjsBean {
+        /**
+         * obj_id : ***
+         * obj_name : 对象名称1
+         * obj_code : XXX
+         * obj_type : system
+         * obj_source : content_obj
+         */
+        //"obj_id", "obj_name", "obj_type"
+        @NotEmpty
+        @NotNull
+        private String obj_id;
+        @NotEmpty
+        @NotNull
+        private String obj_name;
+        @NotEmpty
+        @NotNull
+        private String obj_type;
+        private String obj_source;
+        private String obj_code;
 
-    public String getUpdateTime() {
-        return updateTime;
-    }
+        public String getObj_id() {
+            return obj_id;
+        }
 
-    public void setUpdateTime(String updateTime) {
-        this.updateTime = updateTime;
+        public void setObj_id(String obj_id) {
+            this.obj_id = obj_id;
+        }
+
+        public String getObj_name() {
+            return obj_name;
+        }
+
+        public void setObj_name(String obj_name) {
+            this.obj_name = obj_name;
+        }
+
+        public String getObj_code() {
+            return obj_code;
+        }
+
+        public void setObj_code(String obj_code) {
+            this.obj_code = obj_code;
+        }
+
+        public String getObj_type() {
+            return obj_type;
+        }
+
+        public void setObj_type(String obj_type) {
+            this.obj_type = obj_type;
+        }
+
+        public String getObj_source() {
+            return obj_source;
+        }
+
+        public void setObj_source(String obj_source) {
+            this.obj_source = obj_source;
+        }
     }
 
-    @Override
-    protected Serializable pkVal() {
-        return this.sopId;
-    }
-
-    @Override
-    public String toString() {
-        return "Sop{" +
-        "sopId=" + sopId +
-        ", projectId=" + projectId +
-        ", extendField=" + extendField +
-        ", operator=" + operator +
-        ", sopName=" + sopName +
-        ", sopType=" + sopType +
-        ", noObj=" + noObj +
-        ", domains=" + domains +
-        ", orderType=" + orderType +
-        ", tools=" + tools +
-        ", fitObjs=" + fitObjs +
-        ", equipModelIds=" + equipModelIds +
-        ", labels=" + labels +
-        ", stepsVersion=" + stepsVersion +
-        ", steps=" + steps +
-        ", relatedData=" + relatedData +
-        ", sopStatus=" + sopStatus +
-        ", publishStatus=" + publishStatus +
-        ", refSopIds=" + refSopIds +
-        ", version=" + version +
-        ", versionCount=" + versionCount +
-        ", versionExplain=" + versionExplain +
-        ", versionExp=" + versionExp +
-        ", valid=" + valid +
-        ", updateTime=" + updateTime +
-        "}";
+    public static class RelatedDataBean {
+        /**
+         * name : ***
+         * url : ***
+         */
+
+        private String name;
+        private String url;
+
+        public String getName() {
+            return name;
+        }
+
+        public void setName(String name) {
+            this.name = name;
+        }
+
+        public String getUrl() {
+            return url;
+        }
+
+        public void setUrl(String url) {
+            this.url = url;
+        }
     }
+
+
 }

+ 225 - 161
fm-sop/src/main/java/com/persagy/fm/sop/model/dto/SopEdit.java

@@ -1,9 +1,14 @@
 package com.persagy.fm.sop.model.dto;
 
 import com.baomidou.mybatisplus.annotation.IdType;
-import com.baomidou.mybatisplus.extension.activerecord.Model;
+import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableId;
-import java.io.Serializable;
+import com.baomidou.mybatisplus.extension.activerecord.Model;
+import com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler;
+
+import javax.validation.constraints.NotEmpty;
+import javax.validation.constraints.NotNull;
+import java.util.List;
 
 /**
  * <p>
@@ -14,9 +19,6 @@ import java.io.Serializable;
  * @since 2021-03-17
  */
 public class SopEdit extends Model<SopEdit> {
-
-    private static final long serialVersionUID=1L;
-
     /**
      * 主键
      */
@@ -25,115 +27,62 @@ public class SopEdit extends Model<SopEdit> {
 
     private String sopId;
 
-    /**
-     * 通用sop的项目Id默认为"group_sop_id"
-     */
     private String projectId;
-
-    /**
-     * 项目类型:同一级建筑功能类型 ,字段使用原有的extend_field保存
-     */
     private String extendField;
-
-    /**
-     * 表示sop的发布者、更新者
-     */
-    private String operator;
-
-    /**
-     * 名称项目下唯一
-     */
+    @TableField(typeHandler = FastjsonTypeHandler.class)
+    private OperatorBean operator;
     private String sopName;
-
-    /**
-     * 1-通用,2-项目专用
-     */
     private String sopType;
 
-    /**
-     * 0-否 1-是
-     */
     private String noObj;
+    @TableField(typeHandler = FastjsonTypeHandler.class)
+    private List<String> domains;
+    @TableField(typeHandler = FastjsonTypeHandler.class)
+    private List<String> orderType;
+    @TableField(typeHandler = FastjsonTypeHandler.class)
+    private List<ToolsBean> tools;
+    @TableField(typeHandler = FastjsonTypeHandler.class)
+    private List<FitObjsBean> fitObjs;
+    @TableField(typeHandler = FastjsonTypeHandler.class)
+    private List<String> equipModelIds;
+    @TableField(typeHandler = FastjsonTypeHandler.class)
+    private List<String> labels;
+    private String stepsVersion;
+    @TableField(typeHandler = FastjsonTypeHandler.class)
+    private List<SopStepsBean> steps;
+    @TableField(typeHandler = FastjsonTypeHandler.class)
+    private List<RelatedDataBean> relatedData;
 
     /**
-     * 数组[code,code],
-子项:SE-强电,WE-弱电,AC-空调,WS-给排水,FF-消防,SP-安防
-     */
-    private String domains;
-
-    /**
-     * 数组[{"tool":“……”,"from_step":true}]
+     * 1-已发布、2-已作废
      */
-    private String tools;
-
-    /**
-     * 数组[code,code],
-子项:1-保养、2-维修、3-巡检、4-运行、5-安防、
-     */
-    private String orderType;
-
-    /**
-     * [{
-      "obj_id:"***", //对象id
-      "obj_name:"对象名称1", //对象名称
-      "obj_type":"equip",  //对象类型,子项见后边
-}]
-     */
-    private String fitObjs;
-
-    /**
-     * [name,name]
-     */
-    private String equipModelIds;
-
-    /**
-     * 见 sop表
-     */
-    private String labels;
-
-    /**
-     * [{"name":"***',“url”:“***”},{}]
-     */
-    private String steps;
-
-    /**
-     * 0-草稿、1-已发布
-     */
-    private String relatedData;
+    private String sopStatus;
 
     /**
-     * 3-修订中
+     * 1-正常、2-待修订、3-修订中
      */
-    private String sopStatus;
+    private String publishStatus;
 
     /**
      * id的数组[sop_id,sop_id]
+     *
      */
-    private String publishStatus;
-
-    private String refSopIds;
+    @TableField(typeHandler = FastjsonTypeHandler.class)
+    private List<String> refSopIds;
 
     private String version;
 
     private Integer versionCount;
 
-    /**
-     * 数组[“描述”,“描述”]
-     */
     private String versionExplain;
-
     /**
-     * yyyyMMddhhmmss
+     * 是否有效
      */
-    private String createTime;
+    private Boolean valid;
 
-    /**
-     * yyyyMMddhhmmss
-     */
     private String updateTime;
 
-    private Boolean valid;
-
+    private String createTime;
 
     public String getSopEditId() {
         return sopEditId;
@@ -143,6 +92,31 @@ public class SopEdit extends Model<SopEdit> {
         this.sopEditId = sopEditId;
     }
 
+    public String getCreateTime() {
+        return createTime;
+    }
+
+    public void setCreateTime(String createTime) {
+        this.createTime = createTime;
+    }
+
+
+    public Boolean getValid() {
+        return valid;
+    }
+
+    public void setValid(Boolean valid) {
+        this.valid = valid;
+    }
+
+    public String getUpdateTime() {
+        return updateTime;
+    }
+
+    public void setUpdateTime(String updateTime) {
+        this.updateTime = updateTime;
+    }
+
     public String getSopId() {
         return sopId;
     }
@@ -167,11 +141,11 @@ public class SopEdit extends Model<SopEdit> {
         this.extendField = extendField;
     }
 
-    public String getOperator() {
+    public OperatorBean getOperator() {
         return operator;
     }
 
-    public void setOperator(String operator) {
+    public void setOperator(OperatorBean operator) {
         this.operator = operator;
     }
 
@@ -199,67 +173,75 @@ public class SopEdit extends Model<SopEdit> {
         this.noObj = noObj;
     }
 
-    public String getDomains() {
+    public List<String> getDomains() {
         return domains;
     }
 
-    public void setDomains(String domains) {
+    public void setDomains(List<String> domains) {
         this.domains = domains;
     }
 
-    public String getTools() {
-        return tools;
+    public List<String> getOrderType() {
+        return orderType;
     }
 
-    public void setTools(String tools) {
-        this.tools = tools;
+    public void setOrderType(List<String> orderType) {
+        this.orderType = orderType;
     }
 
-    public String getOrderType() {
-        return orderType;
+    public List<ToolsBean> getTools() {
+        return tools;
     }
 
-    public void setOrderType(String orderType) {
-        this.orderType = orderType;
+    public void setTools(List<ToolsBean> tools) {
+        this.tools = tools;
     }
 
-    public String getFitObjs() {
+    public List<FitObjsBean> getFitObjs() {
         return fitObjs;
     }
 
-    public void setFitObjs(String fitObjs) {
+    public void setFitObjs(List<FitObjsBean> fitObjs) {
         this.fitObjs = fitObjs;
     }
 
-    public String getEquipModelIds() {
+    public List<String> getEquipModelIds() {
         return equipModelIds;
     }
 
-    public void setEquipModelIds(String equipModelIds) {
+    public void setEquipModelIds(List<String> equipModelIds) {
         this.equipModelIds = equipModelIds;
     }
 
-    public String getLabels() {
+    public List<String> getLabels() {
         return labels;
     }
 
-    public void setLabels(String labels) {
+    public void setLabels(List<String> labels) {
         this.labels = labels;
     }
 
-    public String getSteps() {
+    public String getStepsVersion() {
+        return stepsVersion;
+    }
+
+    public void setStepsVersion(String stepsVersion) {
+        this.stepsVersion = stepsVersion;
+    }
+
+    public List<SopStepsBean> getSteps() {
         return steps;
     }
 
-    public void setSteps(String steps) {
+    public void setSteps(List<SopStepsBean> steps) {
         this.steps = steps;
     }
 
-    public String getRelatedData() {
+    public List<RelatedDataBean> getRelatedData() {
         return relatedData;
     }
 
-    public void setRelatedData(String relatedData) {
+    public void setRelatedData(List<RelatedDataBean> relatedData) {
         this.relatedData = relatedData;
     }
 
@@ -279,11 +261,11 @@ public class SopEdit extends Model<SopEdit> {
         this.publishStatus = publishStatus;
     }
 
-    public String getRefSopIds() {
+    public List<String> getRefSopIds() {
         return refSopIds;
     }
 
-    public void setRefSopIds(String refSopIds) {
+    public void setRefSopIds(List<String> refSopIds) {
         this.refSopIds = refSopIds;
     }
 
@@ -311,63 +293,145 @@ public class SopEdit extends Model<SopEdit> {
         this.versionExplain = versionExplain;
     }
 
-    public String getCreateTime() {
-        return createTime;
-    }
+    public static class OperatorBean {
+        /**
+         * id : ***
+         * name : 燕小六
+         */
+
+        private String id;
+        private String name;
+
+        public String getId() {
+            return id;
+        }
+
+        public void setId(String id) {
+            this.id = id;
+        }
+
+        public String getName() {
+            return name;
+        }
+
+        public void setName(String name) {
+            this.name = name;
+        }
+    }
+
+    public static class ToolsBean {
+        /**
+         * tool : name
+         * from_step : true
+         */
+
+        private String tool;
+        private Boolean from_step;
+
+        public String getTool() {
+            return tool;
+        }
+
+        public void setTool(String tool) {
+            this.tool = tool;
+        }
 
-    public void setCreateTime(String createTime) {
-        this.createTime = createTime;
-    }
+        public Boolean isFrom_step() {
+            return from_step;
+        }
 
-    public String getUpdateTime() {
-        return updateTime;
+        public void setFrom_step(Boolean from_step) {
+            this.from_step = from_step;
+        }
     }
 
-    public void setUpdateTime(String updateTime) {
-        this.updateTime = updateTime;
-    }
+    public static class FitObjsBean {
+        /**
+         * obj_id : ***
+         * obj_name : 对象名称1
+         * obj_code : XXX
+         * obj_type : system
+         * obj_source : content_obj
+         */
+        //"obj_id", "obj_name", "obj_type"
+        @NotEmpty
+        @NotNull
+        private String obj_id;
+        @NotEmpty
+        @NotNull
+        private String obj_name;
+        @NotEmpty
+        @NotNull
+        private String obj_type;
+        private String obj_source;
+        private String obj_code;
 
-    public Boolean getValid() {
-        return valid;
-    }
+        public String getObj_id() {
+            return obj_id;
+        }
 
-    public void setValid(Boolean valid) {
-        this.valid = valid;
+        public void setObj_id(String obj_id) {
+            this.obj_id = obj_id;
+        }
+
+        public String getObj_name() {
+            return obj_name;
+        }
+
+        public void setObj_name(String obj_name) {
+            this.obj_name = obj_name;
+        }
+
+        public String getObj_code() {
+            return obj_code;
+        }
+
+        public void setObj_code(String obj_code) {
+            this.obj_code = obj_code;
+        }
+
+        public String getObj_type() {
+            return obj_type;
+        }
+
+        public void setObj_type(String obj_type) {
+            this.obj_type = obj_type;
+        }
+
+        public String getObj_source() {
+            return obj_source;
+        }
+
+        public void setObj_source(String obj_source) {
+            this.obj_source = obj_source;
+        }
     }
 
-    @Override
-    protected Serializable pkVal() {
-        return this.sopEditId;
-    }
-
-    @Override
-    public String toString() {
-        return "SopEdit{" +
-        "sopEditId=" + sopEditId +
-        ", sopId=" + sopId +
-        ", projectId=" + projectId +
-        ", extendField=" + extendField +
-        ", operator=" + operator +
-        ", sopName=" + sopName +
-        ", sopType=" + sopType +
-        ", noObj=" + noObj +
-        ", domains=" + domains +
-        ", tools=" + tools +
-        ", orderType=" + orderType +
-        ", fitObjs=" + fitObjs +
-        ", equipModelIds=" + equipModelIds +
-        ", labels=" + labels +
-        ", steps=" + steps +
-        ", relatedData=" + relatedData +
-        ", sopStatus=" + sopStatus +
-        ", publishStatus=" + publishStatus +
-        ", refSopIds=" + refSopIds +
-        ", version=" + version +
-        ", versionCount=" + versionCount +
-        ", versionExplain=" + versionExplain +
-        ", createTime=" + createTime +
-        ", updateTime=" + updateTime +
-        ", valid=" + valid +
-        "}";
+    public static class RelatedDataBean {
+        /**
+         * name : ***
+         * url : ***
+         */
+
+        private String name;
+        private String url;
+
+        public String getName() {
+            return name;
+        }
+
+        public void setName(String name) {
+            this.name = name;
+        }
+
+        public String getUrl() {
+            return url;
+        }
+
+        public void setUrl(String url) {
+            this.url = url;
+        }
     }
+
+
 }

+ 10 - 24
fm-sop/src/main/java/com/persagy/fm/sop/service/impl/GroupSopServiceImpl.java

@@ -3,6 +3,7 @@ package com.persagy.fm.sop.service.impl;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.persagy.fm.common.exception.BusinessValidatorException;
+import com.persagy.fm.sop.mapper.SopMapper;
 import com.persagy.fm.sop.model.dto.*;
 import com.persagy.fm.sop.model.vo.QuerySopReferenceVo;
 import com.persagy.fm.sop.model.vo.SaveSopEditVo;
@@ -19,7 +20,6 @@ import com.persagy.old.service.ObjectServiceI;
 import org.apache.commons.beanutils.BeanUtils;
 import org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.lang.BooleanUtils;
-import org.apache.commons.lang.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -47,26 +47,19 @@ public class GroupSopServiceImpl implements GroupSopService {
     @Transactional
     public boolean addPublishedSop(SaveSopVo saveSopVo) throws Exception {
 
-        saveSopVo.setSop_id(ToolsUtil.getRecordId(DBConst.TABLE_SOP_ID_TAG));
         //找到sop 与与对象、设备型号、工单类型、自定义标签、sop关系 并插入数据库中
         addSopRelation(saveSopVo);
         //落库本条sop*/
         //填充必要字段
-        Sop sop = new Sop();
-        //将 请求体中的参数拷贝到我们里面
-        //BeanUtils.copyProperties(sop,saveSopVo);
-        String s = JSONObject.toJSONString(saveSopVo);
-        JSONObject jsonObject = JSONObject.parseObject(s);
-        jsonObject = JSONUtil.prossesParamToJsonString(jsonObject, CommonMessage.tranfer_json_string_sop);
-        Sop sop1 = JSONObject.parseObject(jsonObject.toJSONString(), Sop.class);
-        BeanUtils.copyProperties(sop,sop1);
 
+        //将 请求体中的参数拷贝到我们里面
+        //将对象映射到数据库实体上面去
+        Sop sop = SopMapper.INSTANCE.SaveSopVoToSop(saveSopVo);
         sop.setSopStatus(SopConst.SOP_STATUS_PUBLISH);
         sop.setPublishStatus(SopConst.PUBLISH_STATUS_NORMAL);
         sop.setVersionCount(1);
         sop.setVersion("V0.1");
         sop.setVersionExplain("[\""+ CommonConst.version_explain_create+"\"]");
-
         //将参数转化为指定的字段后进行存储
         sop.insert();
         return true;
@@ -301,24 +294,17 @@ public class GroupSopServiceImpl implements GroupSopService {
 
     @Override
     public String addDraftSop(SaveSopEditVo saveSopEditVo) throws Exception {
-
-        saveSopEditVo.setProject_id(CommonConst.group_sop_id);
         Set<String> sopRefSops = this.getSopRefSops(saveSopEditVo);
         saveSopEditVo.setSop_id(UUID.randomUUID().toString().replaceAll("-",""));
 
-        SopEdit sopEdit = new SopEdit();
+        //将表单提交的值拷贝过来
+        SopEdit sopEdit = SopMapper.INSTANCE.SaveSopEditVoToSopEdit(saveSopEditVo);
+
         //sop类型 1 通用    2 项目专用
         sopEdit.setSopType("1");
         //sop状态 0 草稿  1 已发布   2 已作废
         sopEdit.setSopStatus("0");
-
-        String s = JSONObject.toJSONString(saveSopEditVo);
-        JSONObject jsonObject = JSONObject.parseObject(s);
-        jsonObject = JSONUtil.prossesParamToJsonString(jsonObject, CommonMessage.tranfer_json_string_sop);
-        SopEdit sopEditTmp = JSONObject.parseObject(jsonObject.toJSONString(), SopEdit.class);
-
-        BeanUtils.copyProperties(sopEdit,sopEditTmp);
-
+        sopEdit.setRefSopIds(new ArrayList<>(sopRefSops));
         sopEdit.insert();
         return sopEdit.getSopId();
     }
@@ -388,8 +374,8 @@ public class GroupSopServiceImpl implements GroupSopService {
 						}
                  */
 
-                if(StringUtils.isNotBlank(sop.getOperator())) {
-                    refSopInfo.setOperator(sop.getOperator());
+                if(sop.getOperator() != null) {
+                    refSopInfo.setOperator(JSONObject.toJSONString(sop.getOperator()));
                 }
                 refSopInfo.setUpdate_time(DateUtil.transferDateFormat(sop.getUpdateTime(), CommonConst.date_format_save, CommonConst.date_format_show));
                 refSopInfos.add(refSopInfo);