Browse Source

添加历史表的实体和dao

weijinhao 3 years ago
parent
commit
dbfb4d6794
19 changed files with 1086 additions and 23 deletions
  1. 41 4
      fm-sop/src/main/java/com/persagy/fm/sop/controller/GroupSopController.java
  2. 21 0
      fm-sop/src/main/java/com/persagy/fm/sop/controller/SopHisController.java
  3. 21 0
      fm-sop/src/main/java/com/persagy/fm/sop/controller/SopReviseMsgController.java
  4. 16 0
      fm-sop/src/main/java/com/persagy/fm/sop/dao/SopHisMapper.java
  5. 39 0
      fm-sop/src/main/java/com/persagy/fm/sop/dao/SopHisMapper.xml
  6. 16 0
      fm-sop/src/main/java/com/persagy/fm/sop/dao/SopReviseMsgMapper.java
  7. 23 0
      fm-sop/src/main/java/com/persagy/fm/sop/dao/SopReviseMsgMapper.xml
  8. 29 0
      fm-sop/src/main/java/com/persagy/fm/sop/mapper/SopMapper.java
  9. 500 0
      fm-sop/src/main/java/com/persagy/fm/sop/model/dto/SopHis.java
  10. 143 0
      fm-sop/src/main/java/com/persagy/fm/sop/model/dto/SopReviseMsg.java
  11. 13 0
      fm-sop/src/main/java/com/persagy/fm/sop/model/vo/SaveDraftSopVo.java
  12. 35 0
      fm-sop/src/main/java/com/persagy/fm/sop/model/vo/VerifySopNameForAddVo.java
  13. 19 4
      fm-sop/src/main/java/com/persagy/fm/sop/service/GroupSopService.java
  14. 16 0
      fm-sop/src/main/java/com/persagy/fm/sop/service/SopHisService.java
  15. 16 0
      fm-sop/src/main/java/com/persagy/fm/sop/service/SopReviseMsgService.java
  16. 97 14
      fm-sop/src/main/java/com/persagy/fm/sop/service/impl/GroupSopServiceImpl.java
  17. 20 0
      fm-sop/src/main/java/com/persagy/fm/sop/service/impl/SopHisServiceImpl.java
  18. 20 0
      fm-sop/src/main/java/com/persagy/fm/sop/service/impl/SopReviseMsgServiceImpl.java
  19. 1 1
      fm-sop/src/main/test/CodeGenerator.java

+ 41 - 4
fm-sop/src/main/java/com/persagy/fm/sop/controller/GroupSopController.java

@@ -4,10 +4,7 @@ import com.alibaba.fastjson.JSONObject;
 import com.persagy.fm.common.response.FmResponseMsg;
 import com.persagy.fm.common.response.FmResponseUtil;
 import com.persagy.fm.sop.model.dto.RefSopInfo;
-import com.persagy.fm.sop.model.vo.QuerySopReferenceVo;
-import com.persagy.fm.sop.model.vo.SaveSopEditVo;
-import com.persagy.fm.sop.model.vo.SaveSopVo;
-import com.persagy.fm.sop.model.vo.VerifySopNameVo;
+import com.persagy.fm.sop.model.vo.*;
 import com.persagy.fm.sop.service.GroupSopService;
 import com.persagy.old.common.CommonConst;
 import com.persagy.old.common.ToolsUtil;
@@ -107,5 +104,45 @@ public class GroupSopController {
        return ToolsUtil.successJsonMsg(refSopInfos);
     }
 
+    /**
+     * 新增页:查询可供选择的sop,复制、引用时用
+     * @param jsonStr
+     * @return
+     * @throws Exception
+     */
+    @PostMapping("/verifySopNameForAdd")
+    public String verifySopNameForAdd(@RequestBody VerifySopNameVo verifySopNameVo) throws Exception{
+        boolean isCan = groupSopService.verifySopBeforePublish(verifySopNameVo);
+        return ToolsUtil.successJsonMsg(JSONObject.parseObject("{\"can_use\":"+isCan+"}"));
+
+    }
+
+
+    /**
+     * 集团sop-编辑页-保存草稿状态sop
+     * @param saveSopVo
+     * @return
+     * @throws Exception
+     */
+    @PostMapping("/saveDraftSop")
+    public String saveDraftSop(@RequestBody SaveDraftSopVo saveSopVo) throws Exception{
+        saveSopVo.setProject_id(CommonConst.group_sop_id);
+        return ToolsUtil.successJsonMsg("");
+    }
+
+
+
+
+    /**
+     * 集团sop-编辑页-发布sop
+     * @param saveSopVo
+     * @return
+     * @throws Exception
+     */
+    @PostMapping("/publishSop")
+    public String publishSop(@RequestBody SaveSopVo saveSopVo) throws Exception{
+        saveSopVo.setProject_id(CommonConst.group_sop_id);
+        return null;
+    }
 
 }

+ 21 - 0
fm-sop/src/main/java/com/persagy/fm/sop/controller/SopHisController.java

@@ -0,0 +1,21 @@
+package com.persagy.fm.sop.controller;
+
+
+import org.springframework.web.bind.annotation.RequestMapping;
+
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * <p>
+ *  前端控制器
+ * </p>
+ *
+ * @author weijinhao
+ * @since 2021-03-18
+ */
+@RestController
+@RequestMapping("/sop-his")
+public class SopHisController {
+
+}
+

+ 21 - 0
fm-sop/src/main/java/com/persagy/fm/sop/controller/SopReviseMsgController.java

@@ -0,0 +1,21 @@
+package com.persagy.fm.sop.controller;
+
+
+import org.springframework.web.bind.annotation.RequestMapping;
+
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * <p>
+ *  前端控制器
+ * </p>
+ *
+ * @author weijinhao
+ * @since 2021-03-18
+ */
+@RestController
+@RequestMapping("/sop-revise-msg")
+public class SopReviseMsgController {
+
+}
+

+ 16 - 0
fm-sop/src/main/java/com/persagy/fm/sop/dao/SopHisMapper.java

@@ -0,0 +1,16 @@
+package com.persagy.fm.sop.dao;
+
+import com.persagy.fm.sop.model.dto.SopHis;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * <p>
+ *  Mapper 接口
+ * </p>
+ *
+ * @author weijinhao
+ * @since 2021-03-18
+ */
+public interface SopHisMapper extends BaseMapper<SopHis> {
+
+}

+ 39 - 0
fm-sop/src/main/java/com/persagy/fm/sop/dao/SopHisMapper.xml

@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.persagy.fm.sop.dao.SopHisMapper">
+
+    <!-- 通用查询映射结果 -->
+    <resultMap id="BaseResultMap" type="com.persagy.fm.sop.model.dto.SopHis">
+        <id column="sop_his_id" property="sopHisId" />
+        <result column="sop_id" property="sopId" />
+        <result column="project_id" property="projectId" />
+        <result column="extend_field" property="extendField" />
+        <result column="operator" property="operator" typeHandler="com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler"/>
+        <result column="sop_type" property="sopType" />
+        <result column="no_obj" property="noObj" />
+        <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" typeHandler="com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler"/>
+        <result column="refed_sops" property="refedSops" 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="create_time" property="createTime" />
+        <result column="update_time" property="updateTime" />
+        <result column="valid" property="valid" />
+    </resultMap>
+
+    <!-- 通用查询结果列 -->
+    <sql id="Base_Column_List">
+        sop_his_id, sop_id, project_id, extend_field, operator, sop_type, no_obj, domains, tools, order_type, fit_objs, equip_model_ids, labels, steps, related_data, sop_status, publish_status, ref_sop_ids, refed_sops, version, version_count, version_explain, create_time, update_time, valid
+    </sql>
+
+</mapper>

+ 16 - 0
fm-sop/src/main/java/com/persagy/fm/sop/dao/SopReviseMsgMapper.java

@@ -0,0 +1,16 @@
+package com.persagy.fm.sop.dao;
+
+import com.persagy.fm.sop.model.dto.SopReviseMsg;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * <p>
+ *  Mapper 接口
+ * </p>
+ *
+ * @author weijinhao
+ * @since 2021-03-18
+ */
+public interface SopReviseMsgMapper extends BaseMapper<SopReviseMsg> {
+
+}

+ 23 - 0
fm-sop/src/main/java/com/persagy/fm/sop/dao/SopReviseMsgMapper.xml

@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.persagy.fm.sop.dao.SopReviseMsgMapper">
+
+    <!-- 通用查询映射结果 -->
+    <resultMap id="BaseResultMap" type="com.persagy.fm.sop.model.dto.SopReviseMsg">
+        <id column="msg_id" property="msgId" />
+        <result column="sop_id" property="sopId" />
+        <result column="obj_id" property="objId" />
+        <result column="obj_name" property="objName" />
+        <result column="obj_type" property="objType" />
+        <result column="content" property="content" />
+        <result column="status" property="status" />
+        <result column="create_time" property="createTime" />
+        <result column="update_time" property="updateTime" />
+    </resultMap>
+
+    <!-- 通用查询结果列 -->
+    <sql id="Base_Column_List">
+        msg_id, sop_id, obj_id, obj_name, obj_type, content, status, create_time, update_time
+    </sql>
+
+</mapper>

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

@@ -69,6 +69,35 @@ public interface SopMapper {
     SopEdit SaveSopEditVoToSopEdit(SaveSopEditVo saveSopEditVo);
 
 
+    @Mapping(target = "sop_edit_id" ,source ="sopEditId" )
+    @Mapping(target = "sop_id" ,source ="sopId" )
+    @Mapping(target = "project_id" ,source ="projectId" )
+    @Mapping(target = "extend_field" ,source ="extendField" )
+    @Mapping(target = "operator" ,source ="operator" )
+    @Mapping(target = "sop_name" ,source ="sopName" )
+    //@Mapping(source = "sop_type" ,source ="sopType" )
+    @Mapping(target = "no_obj" ,source ="noObj" )
+    @Mapping(target = "domains" ,source ="domains" )
+    @Mapping(target = "order_type" ,source ="orderType" )
+    @Mapping(target = "tools" ,source ="tools" )
+    @Mapping(target = "fit_objs" ,source ="fitObjs" )
+    @Mapping(target = "equip_model_ids" ,source ="equipModelIds" )
+    @Mapping(target = "labels" ,source ="labels" )
+    //@Mapping(target = "steps_version" ,source ="stepsVersion" )
+    @Mapping(target = "steps" ,source ="steps" )
+    @Mapping(target = "related_data" ,source ="relatedData" )
+        //@Mapping(source = "sop_status" ,source ="sopStatus" )
+        //@Mapping(source = "publish_status" ,source ="publishStatus" )
+        //@Mapping(source = "ref_sop_ids" ,source ="refSopIds" )
+        //@Mapping(source = "version" ,source ="version" )
+        //@Mapping(source = "version_count" ,source ="versionCount" )
+        //@Mapping(source = "version_explain" ,source ="versionExplain" )
+        //@Mapping(source = "version_exp" ,source ="versionExp" )
+        //@Mapping(source = "valid" ,source ="valid" )
+        //@Mapping(source = "update_time" ,source ="updateTime" )
+    SaveSopEditVo  SopEditToSaveSopEditVo(SopEdit sopEdit);
+
+
 
 
 }

+ 500 - 0
fm-sop/src/main/java/com/persagy/fm/sop/model/dto/SopHis.java

@@ -0,0 +1,500 @@
+package com.persagy.fm.sop.model.dto;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+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;
+
+/**
+ * sop表 落库协议
+ * v1.0
+ */
+public class SopHis extends Model<SopHis> {
+    @TableId(value = "sop_his_id", type = IdType.ASSIGN_UUID)
+    private String sopHisId;
+
+    private String sopId;
+
+    private String projectId;
+    private String extendField;
+    @TableField(typeHandler = FastjsonTypeHandler.class)
+    private OperatorBean operator;
+
+    private String sopName;
+    private String sopType;
+
+    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<@Valid 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;
+
+    /**
+     * 1-已发布、2-已作废
+     */
+    private String sopStatus;
+
+    /**
+     * 1-正常、2-待修订、3-修订中
+     */
+    private String publishStatus;
+
+    /**
+     * id的数组[sop_id,sop_id]
+     */
+    @TableField(typeHandler = FastjsonTypeHandler.class)
+    private List<String> refSopIds;
+
+    @TableField(typeHandler = FastjsonTypeHandler.class)
+    private List<RefedSopBean> refedSops;
+
+    private String version;
+
+    private Integer versionCount;
+
+    private String versionExplain;
+
+    /**
+     * 是否有效
+     */
+    private Boolean valid;
+    private String createTime;
+
+
+    public List<RefedSopBean> getRefedSops() {
+        return refedSops;
+    }
+
+    public void setRefedSops(List<RefedSopBean> refedSops) {
+        this.refedSops = refedSops;
+    }
+
+    private String updateTime;
+
+    public String getSopHisId() {
+        return sopHisId;
+    }
+
+    public void setSopHisId(String sopHisId) {
+        this.sopHisId = sopHisId;
+    }
+
+    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;
+    }
+
+    public void setSopId(String sopId) {
+        this.sopId = sopId;
+    }
+
+    public String getProjectId() {
+        return projectId;
+    }
+
+    public void setProjectId(String projectId) {
+        this.projectId = projectId;
+    }
+
+    public String getExtendField() {
+        return extendField;
+    }
+
+    public void setExtendField(String extendField) {
+        this.extendField = extendField;
+    }
+
+    public OperatorBean getOperator() {
+        return operator;
+    }
+
+    public void setOperator(OperatorBean operator) {
+        this.operator = operator;
+    }
+
+    public String getSopName() {
+        return sopName;
+    }
+
+    public void setSopName(String sopName) {
+        this.sopName = sopName;
+    }
+
+    public String getSopType() {
+        return sopType;
+    }
+
+    public void setSopType(String sopType) {
+        this.sopType = sopType;
+    }
+
+    public String getNoObj() {
+        return noObj;
+    }
+
+    public void setNoObj(String noObj) {
+        this.noObj = noObj;
+    }
+
+    public List<String> getDomains() {
+        return domains;
+    }
+
+    public void setDomains(List<String> domains) {
+        this.domains = domains;
+    }
+
+    public List<String> getOrderType() {
+        return orderType;
+    }
+
+    public void setOrderType(List<String> orderType) {
+        this.orderType = orderType;
+    }
+
+    public List<ToolsBean> getTools() {
+        return tools;
+    }
+
+    public void setTools(List<ToolsBean> tools) {
+        this.tools = tools;
+    }
+
+    public List<FitObjsBean> getFitObjs() {
+        return fitObjs;
+    }
+
+    public void setFitObjs(List<FitObjsBean> fitObjs) {
+        this.fitObjs = fitObjs;
+    }
+
+    public List<String> getEquipModelIds() {
+        return equipModelIds;
+    }
+
+    public void setEquipModelIds(List<String> equipModelIds) {
+        this.equipModelIds = equipModelIds;
+    }
+
+    public List<String> getLabels() {
+        return labels;
+    }
+
+    public void setLabels(List<String> labels) {
+        this.labels = labels;
+    }
+
+    public String getStepsVersion() {
+        return stepsVersion;
+    }
+
+    public void setStepsVersion(String stepsVersion) {
+        this.stepsVersion = stepsVersion;
+    }
+
+    public List<SopStepsBean> getSteps() {
+        return steps;
+    }
+
+    public void setSteps(List<SopStepsBean> steps) {
+        this.steps = steps;
+    }
+
+    public List<RelatedDataBean> getRelatedData() {
+        return relatedData;
+    }
+
+    public void setRelatedData(List<RelatedDataBean> relatedData) {
+        this.relatedData = relatedData;
+    }
+
+    public String getSopStatus() {
+        return sopStatus;
+    }
+
+    public void setSopStatus(String sopStatus) {
+        this.sopStatus = sopStatus;
+    }
+
+    public String getPublishStatus() {
+        return publishStatus;
+    }
+
+    public void setPublishStatus(String publishStatus) {
+        this.publishStatus = publishStatus;
+    }
+
+    public List<String> getRefSopIds() {
+        return refSopIds;
+    }
+
+    public void setRefSopIds(List<String> refSopIds) {
+        this.refSopIds = refSopIds;
+    }
+
+    public String getVersion() {
+        return version;
+    }
+
+    public void setVersion(String version) {
+        this.version = version;
+    }
+
+    public Integer getVersionCount() {
+        return versionCount;
+    }
+
+    public void setVersionCount(Integer versionCount) {
+        this.versionCount = versionCount;
+    }
+
+    public String getVersionExplain() {
+        return versionExplain;
+    }
+
+    public void setVersionExplain(String versionExplain) {
+        this.versionExplain = versionExplain;
+    }
+
+    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 Boolean isFrom_step() {
+            return from_step;
+        }
+
+        public void setFrom_step(Boolean from_step) {
+            this.from_step = from_step;
+        }
+    }
+
+    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 getObj_id() {
+            return obj_id;
+        }
+
+        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;
+        }
+    }
+
+    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;
+        }
+    }
+
+
+    private class RefedSopBean {
+
+
+        /**
+         * ref_sop_id : ***
+         * ref_sop_name : ***
+         * version : V0.3
+         * stauts_explain : 已发布,修订中
+         * update_time : 20170620093000
+         */
+
+        private String ref_sop_id;
+        private String ref_sop_name;
+        private String version;
+        private String stauts_explain;
+        private String update_time;
+
+        public String getRef_sop_id() {
+            return ref_sop_id;
+        }
+
+        public void setRef_sop_id(String ref_sop_id) {
+            this.ref_sop_id = ref_sop_id;
+        }
+
+        public String getRef_sop_name() {
+            return ref_sop_name;
+        }
+
+        public void setRef_sop_name(String ref_sop_name) {
+            this.ref_sop_name = ref_sop_name;
+        }
+
+        public String getVersion() {
+            return version;
+        }
+
+        public void setVersion(String version) {
+            this.version = version;
+        }
+
+        public String getStauts_explain() {
+            return stauts_explain;
+        }
+
+        public void setStauts_explain(String stauts_explain) {
+            this.stauts_explain = stauts_explain;
+        }
+
+        public String getUpdate_time() {
+            return update_time;
+        }
+
+        public void setUpdate_time(String update_time) {
+            this.update_time = update_time;
+        }
+    }
+}

+ 143 - 0
fm-sop/src/main/java/com/persagy/fm/sop/model/dto/SopReviseMsg.java

@@ -0,0 +1,143 @@
+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.TableId;
+import java.io.Serializable;
+
+/**
+ * <p>
+ * 
+ * </p>
+ *
+ * @author weijinhao
+ * @since 2021-03-18
+ */
+public class SopReviseMsg extends Model<SopReviseMsg> {
+
+    private static final long serialVersionUID=1L;
+
+    @TableId(value = "msg_id", type = IdType.ASSIGN_UUID)
+    private String msgId;
+
+    private String sopId;
+
+    private String objId;
+
+    private String objName;
+
+    /**
+     * 1-对象模型、2-对象实例、3-信息点
+     */
+    private String objType;
+
+    private String content;
+
+    /**
+     * 1-未处理、2-已忽略、3-已自动处理
+     */
+    private String status;
+
+    /**
+     * yyyyMMddhhmmss
+     */
+    private String createTime;
+
+    /**
+     * yyyyMMddhhmmss
+     */
+    private String updateTime;
+
+
+    public String getMsgId() {
+        return msgId;
+    }
+
+    public void setMsgId(String msgId) {
+        this.msgId = msgId;
+    }
+
+    public String getSopId() {
+        return sopId;
+    }
+
+    public void setSopId(String sopId) {
+        this.sopId = sopId;
+    }
+
+    public String getObjId() {
+        return objId;
+    }
+
+    public void setObjId(String objId) {
+        this.objId = objId;
+    }
+
+    public String getObjName() {
+        return objName;
+    }
+
+    public void setObjName(String objName) {
+        this.objName = objName;
+    }
+
+    public String getObjType() {
+        return objType;
+    }
+
+    public void setObjType(String objType) {
+        this.objType = objType;
+    }
+
+    public String getContent() {
+        return content;
+    }
+
+    public void setContent(String content) {
+        this.content = content;
+    }
+
+    public String getStatus() {
+        return status;
+    }
+
+    public void setStatus(String status) {
+        this.status = status;
+    }
+
+    public String getCreateTime() {
+        return createTime;
+    }
+
+    public void setCreateTime(String createTime) {
+        this.createTime = createTime;
+    }
+
+    public String getUpdateTime() {
+        return updateTime;
+    }
+
+    public void setUpdateTime(String updateTime) {
+        this.updateTime = updateTime;
+    }
+
+    @Override
+    protected Serializable pkVal() {
+        return this.msgId;
+    }
+
+    @Override
+    public String toString() {
+        return "SopReviseMsg{" +
+        "msgId=" + msgId +
+        ", sopId=" + sopId +
+        ", objId=" + objId +
+        ", objName=" + objName +
+        ", objType=" + objType +
+        ", content=" + content +
+        ", status=" + status +
+        ", createTime=" + createTime +
+        ", updateTime=" + updateTime +
+        "}";
+    }
+}

+ 13 - 0
fm-sop/src/main/java/com/persagy/fm/sop/model/vo/SaveDraftSopVo.java

@@ -0,0 +1,13 @@
+package com.persagy.fm.sop.model.vo;
+
+public class SaveDraftSopVo extends SaveSopEditVo {
+    private String sop_status;
+
+    public String getSop_status() {
+        return sop_status;
+    }
+
+    public void setSop_status(String sop_status) {
+        this.sop_status = sop_status;
+    }
+}

+ 35 - 0
fm-sop/src/main/java/com/persagy/fm/sop/model/vo/VerifySopNameForAddVo.java

@@ -0,0 +1,35 @@
+package com.persagy.fm.sop.model.vo;
+
+import javax.validation.constraints.NotEmpty;
+import javax.validation.constraints.NotNull;
+
+public class VerifySopNameForAddVo {
+    /**
+     * user_id : ***
+     * sop_id : ***
+     * sop_name : ***
+     */
+    @NotNull
+    @NotEmpty
+    private String user_id;
+    @NotNull
+    @NotEmpty
+    private String sop_name;
+
+
+    public String getUser_id() {
+        return user_id;
+    }
+
+    public void setUser_id(String user_id) {
+        this.user_id = user_id;
+    }
+
+    public String getSop_name() {
+        return sop_name;
+    }
+
+    public void setSop_name(String sop_name) {
+        this.sop_name = sop_name;
+    }
+}

+ 19 - 4
fm-sop/src/main/java/com/persagy/fm/sop/service/GroupSopService.java

@@ -1,10 +1,8 @@
 package com.persagy.fm.sop.service;
 
 import com.persagy.fm.sop.model.dto.RefSopInfo;
-import com.persagy.fm.sop.model.vo.QuerySopReferenceVo;
-import com.persagy.fm.sop.model.vo.SaveSopEditVo;
-import com.persagy.fm.sop.model.vo.SaveSopVo;
-import com.persagy.fm.sop.model.vo.VerifySopNameVo;
+import com.persagy.fm.sop.model.dto.SopEdit;
+import com.persagy.fm.sop.model.vo.*;
 
 import java.util.List;
 import java.util.Set;
@@ -45,4 +43,21 @@ public interface GroupSopService {
      * @throws Exception
      */
     List<RefSopInfo> queryReferencedSopListById(QuerySopReferenceVo querySopReferenceVo)throws Exception;
+
+    /**
+     * 添加数据
+     * @param jsonStr
+     * @return
+     * @throws Exception
+     */
+
+    public boolean insertRecord(SopEdit sopEdit) throws Exception ;
+
+    /**
+     * 集团sop-编辑页-保存草稿状态sop
+     * @param jsonStr
+     * @return
+     * @throws Exception
+     */
+    public boolean saveDraftSop(SaveDraftSopVo saveDraftSopVo) throws Exception;
 }

+ 16 - 0
fm-sop/src/main/java/com/persagy/fm/sop/service/SopHisService.java

@@ -0,0 +1,16 @@
+package com.persagy.fm.sop.service;
+
+import com.persagy.fm.sop.model.dto.SopHis;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * <p>
+ *  服务类
+ * </p>
+ *
+ * @author weijinhao
+ * @since 2021-03-18
+ */
+public interface SopHisService extends IService<SopHis> {
+
+}

+ 16 - 0
fm-sop/src/main/java/com/persagy/fm/sop/service/SopReviseMsgService.java

@@ -0,0 +1,16 @@
+package com.persagy.fm.sop.service;
+
+import com.persagy.fm.sop.model.dto.SopReviseMsg;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * <p>
+ *  服务类
+ * </p>
+ *
+ * @author weijinhao
+ * @since 2021-03-18
+ */
+public interface SopReviseMsgService extends IService<SopReviseMsg> {
+
+}

+ 97 - 14
fm-sop/src/main/java/com/persagy/fm/sop/service/impl/GroupSopServiceImpl.java

@@ -5,21 +5,18 @@ 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;
-import com.persagy.fm.sop.model.vo.SaveSopVo;
-import com.persagy.fm.sop.model.vo.VerifySopNameVo;
-import com.persagy.fm.sop.service.GroupSopService;
-import com.persagy.fm.sop.service.SopEditService;
-import com.persagy.fm.sop.service.SopService;
-import com.persagy.fm.sop.service.SopSopRelService;
-import com.persagy.old.common.*;
+import com.persagy.fm.sop.model.vo.*;
+import com.persagy.fm.sop.service.*;
+import com.persagy.old.common.CommonConst;
+import com.persagy.old.common.DateUtil;
+import com.persagy.old.common.SopConst;
 import com.persagy.old.dao.DBConst;
 import com.persagy.old.dao.DBConst.Result;
 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;
@@ -41,6 +38,11 @@ public class GroupSopServiceImpl implements GroupSopService {
     @Autowired
     private SopSopRelService sopSopRelService;
 
+    @Autowired
+    private SopReviseMsgService sopReviseMsgService;
+
+
+
 
 
     @Override
@@ -292,6 +294,8 @@ public class GroupSopServiceImpl implements GroupSopService {
         return sopIds;
     }
 
+    //改造该方法使用业务上的数据
+
     @Override
     public String addDraftSop(SaveSopEditVo saveSopEditVo) throws Exception {
         Set<String> sopRefSops = this.getSopRefSops(saveSopEditVo);
@@ -299,14 +303,93 @@ public class GroupSopServiceImpl implements GroupSopService {
 
         //将表单提交的值拷贝过来
         SopEdit sopEdit = SopMapper.INSTANCE.SaveSopEditVoToSopEdit(saveSopEditVo);
+        sopEdit.setRefSopIds(new ArrayList<>(sopRefSops));
+        insertRecord(sopEdit);
+        return sopEdit.getSopId();
+    }
 
+    public boolean insertRecord(SopEdit sopEdit) throws Exception {
+        if (StringUtils.isBlank(sopEdit.getSopId())) {
+            sopEdit.setSopId(UUID.randomUUID().toString().replaceAll("-", ""));
+        }
         //sop类型 1 通用    2 项目专用
         sopEdit.setSopType("1");
-        //sop状态 0 草稿  1 已发布   2 已作废
-        sopEdit.setSopStatus("0");
-        sopEdit.setRefSopIds(new ArrayList<>(sopRefSops));
-        sopEdit.insert();
-        return sopEdit.getSopId();
+
+        if(StringUtils.isBlank(sopEdit.getSopStatus())) {
+            //sop状态 0 草稿  1 已发布   2 已作废
+            sopEdit.setSopStatus("0");
+        }else {
+            sopEdit.setSopStatus("1");
+        }
+        return sopEdit.insert();
+    }
+
+    @Override
+    public boolean saveDraftSop(SaveDraftSopVo saveSopVo) throws Exception {
+        String saveSopVoString = JSONObject.toJSONString(saveSopVo);
+        saveSopVo.setProject_id(CommonConst.group_sop_id);
+        String user_id = saveSopVo.getUser_id();
+        if(StringUtils.isNotBlank(saveSopVo.getSop_id())) {
+            //查询sop 待修订消息表
+            //根据状态和 sop id 进行查询
+            QueryWrapper<SopReviseMsg> queryWrapper = new  QueryWrapper<>();
+            queryWrapper.eq("sop_id",saveSopVo.getSop_id()).eq("status","1");
+            List<SopReviseMsg> list = sopReviseMsgService.list(queryWrapper);
+            if(CollectionUtils.isNotEmpty(list)) {
+                for (SopReviseMsg sopReviseMsg : list) {
+                    String objId = sopReviseMsg.getObjId();
+                    //如果不包含这个对象id
+                    if(!saveSopVoString.contains(objId)) {
+                        //设置为忽略状态
+                        //根据msg_id 和sopid 为条件进行更新
+                        sopReviseMsg.setStatus("2");
+                        sopReviseMsg.updateById();
+                    }
+                }
+            }
+
+            //根据sopid 和 有效性查询编辑表
+            QueryWrapper<SopEdit> queryBySopIdAndVaild = new QueryWrapper<>();
+            queryBySopIdAndVaild.eq("sop_id",saveSopVo.getSop_id()).eq("valid",true);
+            SopEdit sopEdit = sopEditService.getOne(queryBySopIdAndVaild);
+            //数据库对象转化为业务对象
+            SaveSopEditVo saveSopEditVo = SopMapper.INSTANCE.SopEditToSaveSopEditVo(sopEdit);
+            //查询该改编辑表中引用的对象
+            Set<String> sopRefSops = this.getSopRefSops(saveSopEditVo);
+
+
+            SopEdit update = SopMapper.INSTANCE.SaveSopEditVoToSopEdit(saveSopVo);
+
+
+
+            //将引用sop设置为sopRefSops
+            update.setRefSopIds(new ArrayList<>(sopRefSops));
+            if("1".equals(saveSopVo.getSop_status())) {
+                //将状态更新为3  publish_status
+                update.setPublishStatus("3");
+            }
+
+            if(sopEdit != null) {
+                //更新sop  更新条件为sop_id  valid
+                QueryWrapper<SopEdit> sopEditQueryWrapper = new QueryWrapper<>();
+                sopEditQueryWrapper.eq("sop_id",sopEdit.getSopId()).eq("valid",true);
+                sopEditService.update(update,sopEditQueryWrapper);
+
+            }else {
+                //插入编辑状态sop
+                this.insertRecord(sopEdit);
+            }
+        }else {
+
+            SopEdit data = SopMapper.INSTANCE.SaveSopEditVoToSopEdit(saveSopVo);
+            //插入编辑状态sop
+            this.insertRecord(data);
+        }
+        //根据sopid 更新sop的状态为3
+        Sop sop = new Sop();
+        sop.setSopId(saveSopVo.getSop_id());
+        sop.setPublishStatus("3");
+        return sop.updateById();
     }
 
     @Override

+ 20 - 0
fm-sop/src/main/java/com/persagy/fm/sop/service/impl/SopHisServiceImpl.java

@@ -0,0 +1,20 @@
+package com.persagy.fm.sop.service.impl;
+
+import com.persagy.fm.sop.model.dto.SopHis;
+import com.persagy.fm.sop.dao.SopHisMapper;
+import com.persagy.fm.sop.service.SopHisService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+
+/**
+ * <p>
+ *  服务实现类
+ * </p>
+ *
+ * @author weijinhao
+ * @since 2021-03-18
+ */
+@Service
+public class SopHisServiceImpl extends ServiceImpl<SopHisMapper, SopHis> implements SopHisService {
+
+}

+ 20 - 0
fm-sop/src/main/java/com/persagy/fm/sop/service/impl/SopReviseMsgServiceImpl.java

@@ -0,0 +1,20 @@
+package com.persagy.fm.sop.service.impl;
+
+import com.persagy.fm.sop.model.dto.SopReviseMsg;
+import com.persagy.fm.sop.dao.SopReviseMsgMapper;
+import com.persagy.fm.sop.service.SopReviseMsgService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+
+/**
+ * <p>
+ *  服务实现类
+ * </p>
+ *
+ * @author weijinhao
+ * @since 2021-03-18
+ */
+@Service
+public class SopReviseMsgServiceImpl extends ServiceImpl<SopReviseMsgMapper, SopReviseMsg> implements SopReviseMsgService {
+
+}

+ 1 - 1
fm-sop/src/main/test/CodeGenerator.java

@@ -59,7 +59,7 @@ public class CodeGenerator {
         strategy.setRestControllerStyle(true);
         strategy.setControllerMappingHyphenStyle(true);
         //strategy.setInclude("sop","sop_sop_rel","sop_obj_rel","sop_equip_model_rel","sop_order_type_rel","sop_label_rel");
-        strategy.setInclude("sop_edit");
+        strategy.setInclude("sop_his");
         //strategy.setTablePrefix(pc.getModuleName() + "_");
         mpg.setStrategy(strategy);
         //mpg.setTemplateEngine(new FreemarkerTemplateEngine());