Browse Source

添加实体,并基本实现插入集团数据

weijinhao 3 years ago
parent
commit
d15b0c1492

+ 11 - 0
fm-sop/pom.xml

@@ -28,5 +28,16 @@
             <groupId>com.persagy</groupId>
             <artifactId>integrated-config-client</artifactId>
         </dependency>
+
+        <dependency>
+            <groupId>com.baomidou</groupId>
+            <artifactId>mybatis-plus-generator</artifactId>
+            <version>3.3.1</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.velocity</groupId>
+            <artifactId>velocity-engine-core</artifactId>
+            <version>2.3</version>
+        </dependency>
     </dependencies>
 </project>

+ 147 - 0
fm-sop/src/main/java/com/persagy/fm/sop/constant/CommonConst.java

@@ -0,0 +1,147 @@
+package com.persagy.fm.sop.constant;
+
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+/**
+ * Created by guosongchao on 2017/8/17.
+ */
+@SpringBootApplication
+public class CommonConst {
+    //通用sop的项目ID(默认)
+    public final static String group_sop_id = "group_sop_id";
+    //时间格式-显示
+    public final static String date_format_show = "yyyy-MM-dd HH:mm:ss";
+    //时间格式-存储
+    public final static String date_format_save = "yyyyMMddHHmmss";
+
+    //数据字典类型-专业、系统大类、设备大类
+    public final static String dict_type_object_domain = "domain_require";
+    //数据字典类型-信息点
+    public final static String dict_type_info_point = "info_point";
+
+    //字段名称-数据平台
+    public final static String info_name_datas = "infos";
+    //字段名称-本地名称-项目
+    public final static String info_name_local_name_project = "ProjLocalName";
+    //字段名称-本地名称-项目
+    public final static String info_name_local_id_project = "ProjLocalID";
+    //字段名称-本地名称-建筑
+    public final static String info_name_local_name_build = "BuildLocalName";
+    //字段名称-本地编码-建筑
+    public final static String info_name_local_id_build = "BuildLocalID";
+    //字段名称-本地名称-楼层
+    public final static String info_name_local_name_floor = "FloorLocalName";
+    //字段名称-本地编码-楼层
+    public final static String info_name_local_id_floor = "FloorLocalID";
+    //字段名称-本地编码-竖井
+    public final static String info_name_local_id_shaft = "ShaftLocalID";
+    //字段名称-本地编码-竖井
+    public final static String info_name_local_name_shaft = "ShaftLocalName";
+    //字段名称-本地名称-空间
+    public final static String info_name_local_name_space = "RoomLocalName";
+    //字段名称-本地编码-空间
+    public final static String info_name_local_id_space = "RoomLocalID";
+    //字段名称-本地名称-系统
+    public final static String info_name_local_name_system = "SysLocalName";
+    //字段名称-本地编码-系统
+    public final static String info_name_local_id_system = "SysLocalID";
+    //字段名称-本地名称-设备
+    public final static String info_name_local_name_equip = "EquipLocalName";
+    //字段名称-本地编码-设备
+    public final static String info_name_local_id_equip = "EquipLocalID";
+    //字段名称-信息点-code
+    public final static String info_name_info_point_code = "infoPointCode";
+    //字段名称-信息点-name
+    public final static String info_name_info_point_name = "infoPointName";
+  //字段名称-信息点-输入方式(原始组件)
+    public final static String info_name_info_point_baseCmpt = "inputMode";
+
+    //关系-关联code
+    public final static String relation_from_id = "from_id";
+    //关系-被关联code
+    public final static String relation_to_id = "to_id";
+
+    //图类型-设备所在空间
+    public final static String graph_type_equip_in_space = "EquipinSpace";
+    //图类型-设备服务空间
+    public final static String graph_type_equip_service_space = "EquipforSpace";
+    //图类型-系统包含设备
+    public final static String graph_type_system_contain_equip = "SystemEquip";
+    //竖井关联的建筑
+    public final static String graph_type_shaft_and_building = "ShaftandBuilding";
+    
+    //关系类型-设备所在空间
+    public final static String relation_type_equip_in_space = "1";
+    //关系类型-设备服务空间
+    public final static String relation_type_equip_service_space = "1";
+    //关系类型-系统包含设备
+    public final static String relation_type_system_contain_equip = "1";
+
+    //数据类型-建筑
+    public final static String data_type_build = "build";
+    //数据类型-楼层
+    public final static String data_type_floor = "floor";
+    //数据类型-空间
+    public final static String data_type_space = "space";
+    //数据类型-系统
+    public final static String data_type_system = "system";
+    //数据类型-设备
+    public final static String data_type_equip = "equip";
+    //数据类型-系统大类
+    public final static String data_type_system_class = "system_class";
+    //数据类型-设备大类
+    public final static String data_type_equip_class = "equip_class";
+    //数据类型-空间大类
+    public final static String data_type_space_class = "space_class";
+    //数据类型-建筑功能类型
+    public final static String data_type_build_func_type = "build_func_type";
+    //数据类型-楼层类型
+    public final static String data_type_floor_type = "floor_type";
+    //数据类型-竖井功能类型
+    public final static String data_type_shaft_type = "shaft_type";
+    //数据类型-竖井
+    public final static String data_type_shaft = "shaft";
+    //标识-项目
+    public final static String tag_project = "Pj";
+    //标识-建筑
+    public final static String tag_build = "Bd";
+    //标识-楼层
+    public final static String tag_floor = "Fl";
+    //标识-空间
+    public final static String tag_space = "Sp";
+    //标识-设备
+    public final static String tag_equip = "Eq";
+    //标识-系统
+    public final static String tag_system = "Sy";
+    //标识-设备对象
+    public final static String tag_equip_object = "EqObj";
+    //标识-系统对象
+    public final static String tag_system_object = "SyObj";
+    //标识-设备字典-专业
+    public final static String tag_dict_class = "Clazz";
+    //标识-设备字典-系统
+    public final static String tag_dict_sytstem = "System";
+    //标识-设备字典-设备
+    public final static String tag_dict_equip = "Equip";
+    //系统主键
+    public final static String SYSTEM_ID = "systemId";
+    
+
+    public final static int desc = -1;
+    public final static int asc = 1;
+    
+    //SOP版本描述
+    public final static String version_explain_create = "发布标准操作";
+    //
+    public final static String remind_recovery_failed = "引用的sop已作废,请恢复后再操作";
+
+    public static class JsonToData{
+        //public static final String equipSpaceOptions = "saas_equipSpaceOptions";
+        //public static final String EquipUploadValidate = "saas_EquipUploadValidate";
+        //public static final String InfoPointInputMode = "saas_InfoPointInputMode";
+        //public static final String nounType = "saas_nounType";
+        //public static final String SpaceUploadValidate = "saas_SpaceUploadValidate";
+        public static final String Flooridentity = "saas_FloorIdentity";
+        public static final String SpaceFunction = "saas_H_spaceFunction";
+    }
+}

+ 113 - 0
fm-sop/src/main/java/com/persagy/fm/sop/constant/DBConst.java

@@ -0,0 +1,113 @@
+package com.persagy.fm.sop.constant;
+
+/**
+ * 
+ * 功能描述: 数据库操作常量
+ * @类型名称 DBConst
+ * @创建者 wanghailong
+ * @邮箱 wanghailong@persagy.com  
+ * @修改描述
+ */
+public class DBConst {
+	public static String DATABASE_NAME = "";
+	
+	public static String DATABASE_SAAS_NAME = "";
+
+	public static String DATABASE_WORLD_NAME = "";
+	
+	public static String DATABASE_WORK_ORDER = "";
+	
+	public final static String TABLE_WO_PLAN = "wo_plan";
+	
+	//ID标识-自定义信息点
+	public final static String ID_TAG_CTM_INFO_POINT ="ctm";
+	/****** 表名   ******/
+	//工单-流转方案表
+	public final static String TABLE_WO_FLOW_PLAN_PERSAGY = "wo_flow_plan_persagy";
+
+	//SOP已发布表
+	public final static String TABLE_SOP = "sop";
+	//SOP与对象关系表
+	public final static String TABLE_SOP_OBJ_REL = "sop_obj_rel";
+/*	//SOP与品牌关系表    废弃
+	public final static String TABLE_SOP_BRAND_REL = "sop_brand_rel";*/
+	//sop与设备型号关系表  新增
+	public final static String TABLE_SOP_EPUIP_MODEL_REL = "sop_equip_model_rel";
+	//SOP适用于工单类型表
+	public final static String TABLE_SOP_ORDER_TYPE_REL = "sop_order_type_rel";
+	//SOP与自定义标签关系表
+	public final static String TABLE_SOP_LABEL_REL = "sop_label_rel";
+	//SOP与SOP关系表
+	public final static String TABLE_SOP_SOP_REL = "sop_sop_rel";
+/*	//SOP分享表  废弃
+	public final static String TABLE_SOP_SHARE = "sop_share";
+	//SOP分享使用表  废弃
+	public final static String TABLE_SOP_SHARE_USE = "sop_share_use";*/
+	//SOP编辑表sop_status
+	public final static String TABLE_SOP_EDIT = "sop_edit";
+	//SOP历史表
+	public final static String TABLE_SOP_HIS = "sop_his";
+	//SOP引用关系作废消息表
+	public final static String TABLE_SOP_DESTORY_MSG = "sop_destroy_msg";
+	//SOP待修订消息表
+	public final static String TABLE_SOP_REVISE_MSG = "sop_revise_msg";
+	//日志表
+	public final static String TABLE_OPERATE_LOG = "operate_log";
+	//saas平台-组件关系表
+	public final static String TABLE_COMPONENT_RELATION = "component_relation";
+    //自定义信息点控件表
+    public final static String TABLE_CUSTOM_INFO_POINT = "custom_info_point";
+    //JSON转DATA表 初始化表
+    public static final String TABLE_INIT_DATA = "init_data";
+
+	//saas平台-数据字典表
+	public final static String TABLE_GENERAL_DICTIONARY = "general_dictionary";
+	//saas平台-对象表
+	public final static String TABLE_TEMP_OBJECT = "temp_object";
+	//saas平台-信息点组件表
+	public final static String TABLE_INFO_COMPONENT = "info_component";
+	//数据平台-项目表
+	public final static String TABLE_PROJECT = "projects";
+	//设备通讯录表
+	public final static String TABLE_EQUIP_COMPANY_BOOK= "equip_company_book";
+	//设备型号表
+	public final static String TABLE_EQUIP_MODEL= "equip_model";
+
+	/******  字典类型    *******/
+	//工单类型数据字典
+	//public final static String DICT_WORK_ORDER_TYPE = "work_order_type";
+	public final static String DICT_WORK_TYPE = "work_type";
+	//专业数据字典
+	public final static String DICT_DOMAINS = "domain_require";
+
+	/****** 表字段-通用  ******/
+	//创建时间,格式yyyyMMddHHmmss
+	public final static String TABLE_FIELD_CTEATE_TIME = "create_time";
+	//更新时间,格式yyyyMMddHHmmss
+	public final static String TABLE_FIELD_UPDATE_TIME = "update_time";
+		
+	//数据有效状态,true-有效,false-无效
+	public final static String TABLE_FIELD_VALID = "valid";
+	
+	/****** 表字段-id开头  ******/
+	//日志表
+	public final static String TABLE_LOG_ID_TAG = "RZ";
+	//sop
+	public final static String TABLE_SOP_ID_TAG = "SOP";
+
+	public static class Result {
+		public final static String RESULT = "Result";
+		public final static String CONTENT = "Content";
+		public final static String ITEM = "Item";
+		public final static String COUNT = "Count";
+		public final static String SUCCESS = "success";
+		public final static String FAILURE = "failure";
+		
+		public final static String RESULTMSG = "ResultMsg";
+		//persagy
+		public final static String PERSAGY_RESULT = "result";
+		public final static String PERSAGY_REASON = "reason";
+		public final static String PERSAGY_CONTENT = "content";
+	}
+	
+}

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

@@ -0,0 +1,186 @@
+package com.persagy.fm.sop.controller;
+
+import com.persagy.fm.common.response.FmResponseMsg;
+import com.persagy.fm.common.response.FmResponseUtil;
+import com.persagy.fm.sop.constant.CommonConst;
+import com.persagy.fm.sop.constant.DBConst;
+import com.persagy.fm.sop.model.dto.*;
+import com.persagy.fm.sop.model.vo.SaveSopVo;
+import com.persagy.fm.sop.utils.ToolsUtil;
+import org.apache.commons.beanutils.BeanUtils;
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.lang.BooleanUtils;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.*;
+
+@RestController
+@RequestMapping("restGroupSopService")
+public class GroupSopController {
+    //添加参数逻辑校验工作
+    @PostMapping("addPublishedSop")
+    public FmResponseMsg addPublishedSop(@RequestBody  SaveSopVo saveSopVo) throws Exception {
+
+        //设置查询的项目类型为集团类型的
+        saveSopVo.setProject_id(CommonConst.group_sop_id);
+        saveSopVo.setSop_id(ToolsUtil.getRecordId(DBConst.TABLE_SOP_ID_TAG));
+        //找到sop 与与对象、设备型号、工单类型、自定义标签、sop关系 并插入数据库中
+        addSopRelation(saveSopVo);
+        //落库本条sop*/
+
+        return FmResponseUtil.successMsg("保存成功");
+    }
+
+
+    @Transactional
+    public boolean addSopRelation(SaveSopVo saveSopVo) throws Exception{
+
+        //添加sop与对象关系-sop_obj_rel
+        List<SaveSopVo.FitObjsBean> sopRelObjs = getSopRelObjs(saveSopVo);
+        if(CollectionUtils.isNotEmpty(sopRelObjs)) {
+            for (SaveSopVo.FitObjsBean sopRelObj : sopRelObjs) {
+                SopObjRel build = SopObjRel.builder()
+                        .sopId(saveSopVo.getSop_id())
+                        .objId(sopRelObj.getObj_id())
+                        .objType(sopRelObj.getObj_type())
+                        .valid(true)
+                        .build();
+
+                build.insert();
+            }
+        }
+
+        //添加sop与设备型号关系-sop_equip_model_rel
+        List<String> equip_model_ids = saveSopVo.getEquip_model_ids();
+        distinctCollection(equip_model_ids);
+        if(CollectionUtils.isNotEmpty(equip_model_ids)) {
+            for (String equip_model_id : equip_model_ids) {
+                SopEquipModelRel sopEquipModelRel = new SopEquipModelRel();
+                sopEquipModelRel.setEquipModelId(equip_model_id);
+                sopEquipModelRel.setSopId(saveSopVo.getSop_id());
+                sopEquipModelRel.setValid(true);
+                sopEquipModelRel.insert();
+            }
+        }
+
+        //添加sop与工单类型关系-sop_order_type_rel
+        List<String> order_types = saveSopVo.getOrder_type();
+        distinctCollection(order_types);
+        if(CollectionUtils.isNotEmpty(order_types)) {
+            for (String order_type : order_types) {
+                SopOrderTypeRel sopOrderTypeRel = new SopOrderTypeRel();
+                sopOrderTypeRel.setOrderType(order_type);
+                sopOrderTypeRel.setProjectId(saveSopVo.getProject_id());
+                sopOrderTypeRel.setValid(true);
+                sopOrderTypeRel.setSopId(saveSopVo.getSop_id());
+                sopOrderTypeRel.insert();
+            }
+        }
+        //添加sop与自定义标签关系-sop_label_rel
+        List<String> labels = saveSopVo.getLabels();
+        distinctCollection(labels);
+        if(CollectionUtils.isNotEmpty(labels)) {
+            for (String label : labels) {
+                SopLabelRel sopLabelRel = new SopLabelRel();
+                sopLabelRel.setLabel(label);
+                sopLabelRel.setSopId(saveSopVo.getSop_id());
+                sopLabelRel.setValid(true);
+                sopLabelRel.insert();
+            }
+        }
+        //添加sop与sop关系-sop_sop_rel
+        Set<String> sopRefSops = getSopRefSops(saveSopVo);
+        if(CollectionUtils.isNotEmpty(sopRefSops)) {
+            for (String sopRefSop : sopRefSops) {
+                SopSopRel sopSopRel = new SopSopRel();
+                sopSopRel.setProjectId(saveSopVo.getProject_id());
+                sopSopRel.setRelSopId(sopRefSop);
+                sopSopRel.setSopId(saveSopVo.getSop_id());
+                sopSopRel.setValid(true);
+            }
+        }
+
+        return true;
+
+    }
+
+    public void distinctCollection(List<String> list) {
+        HashSet set = new HashSet(list);
+        list.clear();
+        list.addAll(set);
+    }
+
+    public  List<SaveSopVo.FitObjsBean> getSopRelObjs(SaveSopVo sop) throws InvocationTargetException, IllegalAccessException {
+        List<SaveSopVo.FitObjsBean> sopRelObjs = new ArrayList<>();
+        Map<String,SaveSopVo.FitObjsBean> objectId_Object = new HashMap<>();
+
+        if(sop != null) {
+            //查询适用的对象
+            List<SaveSopVo.FitObjsBean> fit_objs = sop.getFit_objs();
+            if(CollectionUtils.isNotEmpty(fit_objs)) {
+                for (SaveSopVo.FitObjsBean fit_obj : fit_objs) {
+                    objectId_Object.put(fit_obj.getObj_id(),fit_obj);
+                }
+            }
+            List<SaveSopVo.StepsBean> steps = sop.getSteps();
+            if(CollectionUtils.isNotEmpty(steps)) {
+                for (SaveSopVo.StepsBean step : steps) {
+                    //如果不是来自引用的对象
+                    if(BooleanUtils.isFalse(step.isFrom_sop())) {
+                        List<SaveSopVo.StepsBean.StepContentBean> step_content = step.getStep_content();
+                        if(CollectionUtils.isNotEmpty(step_content)) {
+                            for (SaveSopVo.StepsBean.StepContentBean stepContentBean : step_content) {
+                                List<SaveSopVo.StepsBean.StepContentBean.ContentObjsBean> content_objs = stepContentBean.getContent_objs();
+                                if(CollectionUtils.isNotEmpty(content_objs)) {
+                                    for (SaveSopVo.StepsBean.StepContentBean.ContentObjsBean content_obj : content_objs) {
+                                        //进行数值拷贝到一个对象中去
+                                        SaveSopVo.FitObjsBean fitObjsBean = new SaveSopVo.FitObjsBean();
+                                        BeanUtils.copyProperties(fitObjsBean,content_obj);
+                                        objectId_Object.put(content_obj.getObj_id(),fitObjsBean);
+                                    }
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+        }
+
+        //sop中 适用对象和步骤中的对象
+        for (SaveSopVo.FitObjsBean value : objectId_Object.values()) {
+            sopRelObjs.add(value);
+        }
+        return sopRelObjs;
+    }
+
+    public Set<String> getSopRefSops(SaveSopVo sop){
+        LinkedHashSet<String> sopIds = new LinkedHashSet<>();
+        if(sop != null) {
+
+            List<SaveSopVo.StepsBean> steps = sop.getSteps();
+            if(CollectionUtils.isNotEmpty(steps)) {
+                for (SaveSopVo.StepsBean step : steps) {
+                    if (BooleanUtils.isTrue(step.isFrom_sop())) {
+                        sopIds.add(step.getSop_id());
+                    } else {
+                        List<SaveSopVo.StepsBean.StepContentBean> step_content = step.getStep_content();
+                        if(CollectionUtils.isNotEmpty(step_content)) {
+                            for (SaveSopVo.StepsBean.StepContentBean stepContentBean : step_content) {
+                                if (BooleanUtils.isTrue(stepContentBean.isFrom_sop())) {
+                                    sopIds.add(stepContentBean.getSop_id());
+                                }
+
+                            }
+                        }
+                    }
+                }
+            }
+        }
+        return sopIds;
+    }
+}

+ 10 - 28
fm-sop/src/main/java/com/persagy/fm/sop/controller/SopController.java

@@ -1,39 +1,21 @@
 package com.persagy.fm.sop.controller;
 
-import com.persagy.common.exception.BusinessException;
-import com.persagy.fm.sop.model.SopDTO;
-import com.persagy.fm.sop.service.ISopService;
-import lombok.extern.slf4j.Slf4j;
-import org.apache.commons.lang3.StringUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
+
 import org.springframework.web.bind.annotation.RequestMapping;
+
 import org.springframework.web.bind.annotation.RestController;
 
 /**
- * sop api
- * @author Charlie Yu
- * @date 2021-03-05
+ * <p>
+ *  前端控制器
+ * </p>
+ *
+ * @author weijinhao
+ * @since 2021-03-16
  */
 @RestController
-@Slf4j
-@RequestMapping("/sop/")
+@RequestMapping("/sop")
 public class SopController {
 
-    @Autowired
-    private ISopService sopService;
-
-    /**
-     * 保存草稿
-     * @param dto
-     * @return
-     */
-    @PostMapping("/saveDraftSop")
-    public SopDTO saveDraftSop(@RequestBody SopDTO dto){
-        if(StringUtils.isAnyBlank(dto.getSopName())) {
-            throw new BusinessException("名称不能为空");
-        }
-        return sopService.insert(dto);
-    }
 }
+

File diff suppressed because it is too large
+ 1099 - 0
fm-sop/src/main/java/com/persagy/fm/sop/model/vo/SaveSopVo.java


+ 11 - 15
fm-sop/src/main/java/com/persagy/fm/sop/service/impl/SopServiceImpl.java

@@ -1,24 +1,20 @@
 package com.persagy.fm.sop.service.impl;
 
-import com.persagy.fm.sop.model.SopDTO;
-import com.persagy.fm.sop.service.ISopService;
-import lombok.extern.slf4j.Slf4j;
+import com.persagy.fm.sop.model.dto.Sop;
+import com.persagy.fm.sop.dao.SopMapper;
+import com.persagy.fm.sop.service.SopService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Transactional;
 
 /**
- * sop服务实现
- * @author Charlie Yu
- * @date 2021-03-05
+ * <p>
+ *  服务实现类
+ * </p>
+ *
+ * @author weijinhao
+ * @since 2021-03-16
  */
 @Service
-@Transactional
-@Slf4j
-public class SopServiceImpl implements ISopService {
+public class SopServiceImpl extends ServiceImpl<SopMapper, Sop> implements SopService {
 
-    @Override
-    public SopDTO insert(SopDTO dto) {
-        log.error("here----");
-        return dto;
-    }
 }

+ 43 - 0
fm-sop/src/main/java/com/persagy/fm/sop/utils/ToolsUtil.java

@@ -0,0 +1,43 @@
+/**
+ * @包名称 com.sagacloud.common
+ * @文件名 ToolsUtil.java
+ * @创建者 wanghailong
+ * @邮箱 wanghailong@persagy.com  
+ * @修改描述 
+ */
+
+package com.persagy.fm.sop.utils;
+
+import org.apache.commons.lang.StringUtils;
+
+import java.util.UUID;
+
+
+/** 
+ * 功能描述: 常用工具方法
+ * @类型名称 ToolsUtil
+ * @创建者 wanghailong
+ * @邮箱 wanghailong@persagy.com  
+ * @修改描述 
+ */
+public class ToolsUtil {
+
+    public static String getUuid() {
+    	String uuid = UUID.randomUUID().toString().replace("-","");
+    	return uuid;
+    }
+
+    /**
+     * 生成前缀+uuid的字符串
+     * @param prefix  --前缀字符串
+     * @return recordId --prefix+uuid(去除-)
+     */
+	public static String getRecordId(String prefix) {
+		String recordId = "";
+		if (!StringUtils.isNotBlank(prefix)) {
+			recordId = prefix;
+		}
+		recordId = recordId + UUID.randomUUID().toString().replace("-", "");
+		return recordId;
+	}
+ }

+ 8 - 2
fm-sop/src/main/resources/bootstrap.yml

@@ -1,9 +1,15 @@
 server:
-  port: ${SERVER_PORT:9937}
-
+  port: 9937
 spring: 
   application:
     name: sop
+  datasource:
+    driver-class-name: com.mysql.cj.jdbc.Driver
+    url: jdbc:mysql://192.168.100.94:9934/fm_sop?useUnicode=true&characterEncoding=utf-8&mysqlEncoding=utf8&useSSL=false&serverTimezone=GMT%2B8
+    username: root
+    password: persagy@2020
+    type: com.alibaba.druid.pool.DruidDataSource
+
 
 mybatis-plus:
   mapper-locations: classpath:/mapper/*.xml

+ 67 - 0
fm-sop/src/main/test/CodeGenerator.java

@@ -0,0 +1,67 @@
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.generator.AutoGenerator;
+import com.baomidou.mybatisplus.generator.config.DataSourceConfig;
+import com.baomidou.mybatisplus.generator.config.GlobalConfig;
+import com.baomidou.mybatisplus.generator.config.PackageConfig;
+import com.baomidou.mybatisplus.generator.config.StrategyConfig;
+import com.baomidou.mybatisplus.generator.config.rules.NamingStrategy;
+
+
+public class CodeGenerator {
+
+
+
+    public static void main(String[] args) {
+        // 代码生成器
+        AutoGenerator mpg = new AutoGenerator();
+
+        // 全局配置
+        GlobalConfig gc = new GlobalConfig();
+        gc.setOutputDir("E:\\fmNew\\fm-business\\fm-sop\\src\\main\\java")
+            .setAuthor("weijinhao").setIdType(IdType.ASSIGN_UUID)
+            .setActiveRecord(true)
+            .setFileOverride(true)
+            .setServiceName("%sService")
+            .setBaseResultMap(true).setBaseColumnList(true)
+            .setOpen(false);
+        // gc.setSwagger2(true); 实体属性 Swagger2 注解
+        mpg.setGlobalConfig(gc);
+
+        // 数据源配置
+        DataSourceConfig dsc = new DataSourceConfig();
+        dsc.setUrl("jdbc:mysql://192.168.100.94:9934/fm_sop?useUnicode=true&useSSL=false&characterEncoding=utf8");
+        // dsc.setSchemaName("public");
+        dsc.setDriverName("com.mysql.cj.jdbc.Driver");
+        dsc.setUsername("root");
+        dsc.setPassword("persagy@2020");
+
+        mpg.setDataSource(dsc);
+
+        // 包配置
+        PackageConfig pc = new PackageConfig();
+        pc.setParent("com.persagy.fm.sop");
+        pc.setMapper("dao");
+        pc.setXml("dao");
+        //pc.setController();
+        pc.setService("service");
+        pc.setServiceImpl("service.impl");
+        pc.setEntity("model.dto");
+        mpg.setPackageInfo(pc);
+
+
+
+        // 策略配置
+        StrategyConfig strategy = new StrategyConfig();
+        strategy.setCapitalMode(true);
+        strategy.setNaming(NamingStrategy.underline_to_camel);
+        strategy.setColumnNaming(NamingStrategy.underline_to_camel);
+        strategy.setEntityLombokModel(true);
+        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.setTablePrefix(pc.getModuleName() + "_");
+        mpg.setStrategy(strategy);
+        //mpg.setTemplateEngine(new FreemarkerTemplateEngine());
+        mpg.execute();
+    }
+}