Ver código fonte

重构新增页:查询可供选择的sop,复制、引用时用

weijinhao 3 anos atrás
pai
commit
9a3497acfe

+ 11 - 352
fm-sop/src/main/java/com/persagy/fm/sop/controller/GroupSopController.java

@@ -1,16 +1,13 @@
 package com.persagy.fm.sop.controller;
 
-import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.persagy.fm.common.response.FmResponseMsg;
 import com.persagy.fm.common.response.FmResponseUtil;
-import com.persagy.fm.sop.model.dto.*;
+import com.persagy.fm.sop.model.dto.RefSopInfo;
 import com.persagy.fm.sop.model.vo.*;
-import com.persagy.fm.sop.service.*;
-import com.persagy.old.common.*;
-import org.apache.commons.collections.CollectionUtils;
-import org.apache.commons.lang.BooleanUtils;
+import com.persagy.fm.sop.service.GroupSopService;
+import com.persagy.old.common.CommonConst;
+import com.persagy.old.common.ToolsUtil;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.PostMapping;
@@ -18,7 +15,9 @@ import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
-import java.util.*;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
 
 @RestController
 @RequestMapping("restGroupSopService")
@@ -113,7 +112,7 @@ public class GroupSopController {
     /**
      * 新增页:查询可供选择的sop,复制、引用时用
      *
-     * @param jsonStr
+     * @param verifySopNameVo
      * @return
      * @throws Exception
      */
@@ -140,362 +139,22 @@ public class GroupSopController {
 
     /**
      * 新增页:查询可供选择的sop,复制、引用时用
-     * @param jsonStr
+     * @param sopListForSelVo
      * @return
      * @throws Exception
      */
     @PostMapping("/querySopListForSel")
     public String querySopListForSel(@RequestBody QuerySopListForSelVo sopListForSelVo) throws Exception{
-
-        String sopId = sopListForSelVo.getSop_id();
-        String projectId = CommonConst.group_sop_id;
-        String sop_name = sopListForSelVo.getSop_name();
-        //是否返回包含大类对象的sop  true:返回   false:不返回 (默认返回)
-        Boolean flag = true;
-        if(BooleanUtils.isFalse(sopListForSelVo.isIs_contains_classObj())) {
-            flag = false;
-        }
-        //1.根据update和项目id查询
-        List<Sop> sops = queryPublishedSopsByProjectIdAndUpdatetime(sopListForSelVo, projectId);
-        //2筛选sop
-
-        /*
-        removeReviseSop(sops);//已经直接放到sql 语句中查询了
-        if (!jsonObject.getString("project_id").equals(CommonConst.group_sop_id)) {
-			String rootProjFuncType = objectService.queryRootProjFuncTypeById(jsonObject.getString("project_id"));
-			removeWithoutProJFuncType(sops, rootProjFuncType);
-		}
-         */
-        removeRelSop(sops,projectId,sopId);
-
-        if (!flag) {
-            Iterator<Sop> iterator = sops.iterator();
-            while (iterator.hasNext()) {
-                Sop sopItem = iterator.next();
-                if (isContainsClassObj(sopItem)) {
-                    iterator.remove();
-                }
-            }
-        }
-
-        //sops = filterSopByName(sop_name, sops); 直接在sql 中解决
-        sops = filterSopByFitScope(sopListForSelVo, sops);
-
-        //=========3设置返回字段======
-        sops = additionalSopDetail(sops,jsonObject.getString("project_id"),"2");
-
-        //------------设置过滤项-----
-        if (sopListForSelVo.isNeed_return_criteria()) {
-            JSONObject criteria = getSopListCriteria(sops);
-            item.put("criteria", criteria);
-        }
-        JSONArray content = new JSONArray();
-        for (Object object : sops) {
-            content.add(JSONUtil.getJsonObjectWithKeys((JSONObject)object, querySopListForSel_keys));
-        }
-        item.put("content", content);
-        item.put("count", content.size());
+        sopListForSelVo.setProjectId(CommonConst.group_sop_id);
+        JSONObject item = groupSopService.querySopListForSel(sopListForSelVo);
         return ToolsUtil.successJsonMsg(item);
-
-
-
-
-
-        return groupSopService.querySopListForSel(jsonObject.toJSONString());
     }
 
 
-    private JSONObject getSopListCriteria(JSONArray content) throws Exception {
-        // 遍历结果过滤字段、组合返回查询参数
-        JSONObject sopItem,  equipModel;
-        JSONObject criteria = new JSONObject();
-
-        if (content != null) {
 
-            HashMap<String, String> equipModelMap = collectEquipModeFromSops(content);
-            JSONArray equipModels = new JSONArray();
-            for (String equipModelId : equipModelMap.keySet()) {
-                equipModel = new JSONObject();
-                equipModel.put("equip_model_id", equipModelId);
-                equipModel.put("equip_model_name", equipModelMap.get(equipModelId));
-                equipModels.add(equipModel);
-            }
-
-            HashMap<String, Object> fitObjMap = collectFitObjsFromSops(content);
-            JSONArray fitObjs = new JSONArray();
-            for (String fitObjId : fitObjMap.keySet()) {
-                fitObjs.add(fitObjMap.get(fitObjId));
-            }
 
-            HashMap<String, Object> OrderTypeMap = collectOrderTypeFromSops(content);
-            JSONArray orderTypes = new JSONArray();
-            for (String OrderTypeId : OrderTypeMap.keySet()) {
-                orderTypes.add(OrderTypeMap.get(OrderTypeId));
-            }
 
-            JSONArray labels = new JSONArray();
-            for (int i = 0; i < content.size(); i++) {
-                sopItem = content.getJSONObject(i);
-                JSONArray labelsItem = sopItem.getJSONArray("labels");
-                if (labelsItem == null) {
-                    continue;
-                }
-                for (int j = 0; j < labelsItem.size(); j++) {
-                    if (!labels.contains(labelsItem.getString(j))) {
-                        labels.add(labelsItem.getString(j));
-                    }
-                }
-            }
 
-            HashMap<String, Object> signMap = getBathchMergeRecordBySign(content);
-            JSONArray signs = new JSONArray();
-//			signs.addAll(signMap.values());
-            for (String signCode : signMap.keySet()) {
-                signs.add(signMap.get(signCode));
-            }
-            criteria.put("equip_models", equipModels);
-            criteria.put("labels", labels);
-            criteria.put("order_type", orderTypes);
-            criteria.put("fit_objs", fitObjs);
-            criteria.put("signs", signs);
-        }
-
-        return criteria;
-    }
-
-
-    @Autowired
-    private SopLabelRelService sopLabelRelService;
-    @Autowired
-    private SopObjRelService sopObjRelService;
-    @Autowired
-    private SopOrderTypeRelService sopOrderTypeRelService;
-    @Autowired
-    private SopEquipModelRelService sopEquipModelRelService;
-
-
-
-
-    private List<Sop> filterSopByFitScope(QuerySopListForSelVo sopListForSelVo, List<Sop> sops) throws Exception {
-        JSONObject param = JSONObject.parseObject(JSONObject.toJSONString(sopListForSelVo));
-
-        param.remove("project_id");
-        JSONObject epuipModelsResJson = null, labelsResJson = null, orderTypeResJson = null, fitObjResJson = null;
-        if (StringUtil.isEmptyList(param, "equip_model_ids")
-                && StringUtil.isEmptyList(param, "labels")
-                && StringUtil.isEmptyList(param, "order_type")
-                && StringUtil.isEmptyList(param, "fit_obj_ids")) {
-            return sops;
-        }else {
-            //查询条件后的交集
-            Set<String> sopId = new HashSet<>();
-            Map<String, Sop> sopMap = getSopMap(sops);
-            //1.根据适用返回查询sopid
-            //1.1根据设备型号查询
-            if(!StringUtil.isEmptyList(param, "equip_model_ids")){
-                QueryWrapper<SopEquipModelRel> sopEquipModelRelQueryWrapper = new QueryWrapper<>();
-                sopEquipModelRelQueryWrapper.in("equip_model_id",sopListForSelVo.getEquip_model_ids());
-                List<SopEquipModelRel> list = sopEquipModelRelService.list(sopEquipModelRelQueryWrapper);
-
-                Set<String> tmp = new HashSet<>();
-                for (SopEquipModelRel sopEquipModelRel : list) {
-                    tmp.add(sopEquipModelRel.getSopId());
-                }
-                sopId.addAll(tmp);
-            }
-            //1.2根据自定义标签查询
-            if( !StringUtil.isEmptyList(param, "labels")){
-                QueryWrapper<SopLabelRel> query = new QueryWrapper<>();
-                query.in("label",sopListForSelVo.getLabels());
-                List<SopLabelRel> list = sopLabelRelService.list(query);
-                Set<String> tmp = new HashSet<>();
-                for (SopLabelRel sopLabelRel : list) {
-                    tmp.add(sopLabelRel.getSopId());
-                }
-                sopId.retainAll(tmp);
-            }
-            //1.3根据工单类型查询
-            if(!StringUtil.isEmptyList(param, "order_type")){
-                QueryWrapper<SopOrderTypeRel> query = new QueryWrapper<>();
-                query.in("order_type",sopListForSelVo.getOrder_type());
-                List<SopOrderTypeRel> list = sopOrderTypeRelService.list(query);
-                Set<String> tmp = new HashSet<>();
-                for (SopOrderTypeRel sopOrderTypeRel : list) {
-                    tmp.add(sopOrderTypeRel.getSopId());
-                }
-                sopId.retainAll(tmp);
-            }
-            //1.4根据适用对象查询
-            if( !StringUtil.isEmptyList(param, "fit_obj_ids")){
-                QueryWrapper<SopObjRel> query = new QueryWrapper<>();
-                query.in("obj_id",sopListForSelVo.getFit_obj_ids());
-                List<SopObjRel> list = sopObjRelService.list(query);
-                Set<String> tmp = new HashSet<>();
-                for (SopObjRel sopObjRel : list) {
-                    tmp.add(sopObjRel.getSopId());
-                }
-                sopId.retainAll(tmp);
-            }
-
-            //查询出每张表中的id 然后求出一个交集来
-
-            List<Sop> resultSops = new ArrayList<>();
-            for (String s : sopId) {
-                if (sopMap.containsKey(s)) {
-                    resultSops.add(sopMap.get(sopId));
-                }
-            }
-            return resultSops;
-        }
-
-    }
-
-    /**
-     *
-     * Description:
-     * @param sops
-     * @return HashMap<String,Sop>    key:sop_id ; value: sop
-     * @author yuecaipu
-     * @since 2018年7月10日: 下午5:50:41
-     * Update By yuecaipu 2018年7月10日: 下午5:50:41
-     */
-    private Map<String, Sop> getSopMap(List<Sop> sops) {
-        Map<String, Sop> resultMap = new HashMap<>();
-        for (Sop sop : sops) {
-            resultMap.put(sop.getSopId(),sop);
-        }
-        return resultMap;
-    }
-
-
-
-    @Autowired
-    private SopService sopService;
-    @Autowired
-    private SopSopRelService sopSopRelService;
-
-    public boolean isContainsClassObj(Sop sop) throws Exception {
-        List<SopStepsBean> steps = sop.getSteps();
-        for (SopStepsBean step : steps) {
-            Boolean from_sop = step.isFrom_sop();
-            //非引用
-            if(!from_sop) {
-                List<SopStepsBean.StepContentBean> step_content = step.getStep_content();
-                for (SopStepsBean.StepContentBean stepContentBean : step_content) {
-                    Boolean from_sop1 = stepContentBean.isFrom_sop();
-                    //非引用
-                    if(!from_sop1) {
-                        List<SopStepsBean.StepContentBean.ContentObjsBean> content_objs = stepContentBean.getContent_objs();
-                        for (SopStepsBean.StepContentBean.ContentObjsBean content_obj : content_objs) {
-                            String obj_type = content_obj.getObj_type();
-                            if (obj_type.contains("_")) {
-                               return true;
-                            }
-                        }
-                    }else {
-                        //如果是引用的haul
-                        String sop_id = stepContentBean.getSop_id();
-                        Sop sop1 = new Sop();
-                        Sop query = sop1.selectById(sop_id);
-                        if(query != null) {
-                            return isContainsClassObj(query);
-                        }
-
-                    }
-                }
-
-
-            }else {
-                //如果是引用的haul
-                String sop_id = step.getSop_id();
-                Sop sop1 = new Sop();
-                Sop query = sop1.selectById(sop_id);
-                if(query != null) {
-                    return isContainsClassObj(query);
-                }
-
-            }
-        }
-        return false;
-
-    }
-
-
-    private void removeRelSop( List<Sop>  sops, String projectId, String sopId) {
-        Set<String> relSopIds = querySopRel(projectId, sopId);
-        relSopIds.add(sopId);
-        Iterator<Sop> iterator = sops.iterator();
-        while (iterator.hasNext()) {
-            Sop next = iterator.next();
-            String nodeId = next.getSopId();
-            if (relSopIds.contains(nodeId)) {
-                iterator.remove();
-            }
-        }
-    }
-
-    public Set<String> querySopRel(String projectId,String sopId) {
-        //key:被引用SOP的主键id  value:引用该SOP的SOP主键id
-        Map<String, Set<String>> relSopId2sopId = new HashMap<>();
-
-        QueryWrapper<SopSopRel> query = new QueryWrapper();
-        query.eq("'",projectId).eq("",sopId).eq("valid",true);
-
-        List<SopSopRel> list = sopSopRelService.list(query);
-        for (SopSopRel sopSopRel : list) {
-            String rel_sop_id = sopSopRel.getRelSopId();
-            String sop_id = sopSopRel.getSopId();
-            Set<String> sopIds = relSopId2sopId.getOrDefault(rel_sop_id, new HashSet<String>());
-            sopIds.add(sop_id);
-            relSopId2sopId.put(rel_sop_id, sopIds);
-        }
-        return getRelSopRecursively(relSopId2sopId,sopId);
-    }
-
-
-    private Set<String> getRelSopRecursively(Map<String, Set<String>> relSopId2sopId, String sopId) {
-        Set<String> relSopIds = new HashSet<>();
-        if (CollectionUtils.isEmpty(relSopId2sopId.get(sopId))) {
-            return relSopIds;
-        }
-        Set<String> set = relSopId2sopId.get(sopId);
-        relSopIds.addAll(set);
-        for (String string : set) {
-            relSopIds.addAll(getRelSopRecursively(relSopId2sopId, string));
-        }
-        return relSopIds;
-    }
-
-
-
-    private List<Sop> queryPublishedSopsByProjectIdAndUpdatetime(QuerySopListForSelVo sopListForSelVo,String projectId) throws Exception {
-        String sop_name = sopListForSelVo.getSop_name();
-        /*
-        //如果项目id 不是集团特有的id的话进入
-		if (!CommonConst.group_sop_id.equals(requestJson.getString("project_id"))) {
-			//如果sign_codes 数时空的话 或者sign_codes 码中包含public 的话
-			if (StringUtil.isEmptyList(requestJson, "sign_codes") || requestJson.getJSONArray("sign_codes").contains("public")) {
-				//设置为group_sop_id
-				projectIds.add(CommonConst.group_sop_id);
-			}
-		}
-
-         */
-        //查询条件为 projectIds valid sop_status SOP_STATUS_PUBLISH,
-        // 大于等于  小于等于   不包含待修订
-
-        QueryWrapper<Sop> query = new QueryWrapper();
-        query.eq("project_id",projectId)
-                .eq("valid",true)
-                .eq("sop_status", SopConst.SOP_STATUS_PUBLISH)
-                .ge("update_time",sopListForSelVo.getUpdate_time_from())
-                .le("update_time",sopListForSelVo.getUpdate_time_to())
-                .ne("publish_status",SopConst.PUBLISH_STATUS_REVISE)
-                .like("sop_name",sop_name);
-
-
-        return  sopService.list(query);
-    }
 
 
 

+ 31 - 0
fm-sop/src/main/java/com/persagy/fm/sop/model/vo/QuerySopListForSelResponse.java

@@ -0,0 +1,31 @@
+package com.persagy.fm.sop.model.vo;
+
+public class QuerySopListForSelResponse {
+    private String criteria;
+    private String content;
+    private Integer count;
+
+    public String getCriteria() {
+        return criteria;
+    }
+
+    public void setCriteria(String criteria) {
+        this.criteria = criteria;
+    }
+
+    public String getContent() {
+        return content;
+    }
+
+    public void setContent(String content) {
+        this.content = content;
+    }
+
+    public Integer getCount() {
+        return count;
+    }
+
+    public void setCount(Integer count) {
+        this.count = count;
+    }
+}

+ 19 - 0
fm-sop/src/main/java/com/persagy/fm/sop/model/vo/QuerySopListForSelVo.java

@@ -25,10 +25,29 @@ public class QuerySopListForSelVo {
     private List<String> labels;
     private List<String> order_type;
     private List<String> fit_obj_ids;
+    private String projectId;
+    private List<String> sign_codes;
 
     private String update_time_from;
     private String update_time_to;
 
+    public String getProjectId() {
+        return projectId;
+    }
+
+    public void setProjectId(String projectId) {
+        this.projectId = projectId;
+    }
+
+    public List<String> getSign_codes() {
+        return sign_codes;
+    }
+
+
+
+    public void setSign_codes(List<String> sign_codes) {
+        this.sign_codes = sign_codes;
+    }
 
     public Boolean getNeed_return_criteria() {
         return need_return_criteria;

+ 37 - 0
fm-sop/src/main/java/com/persagy/fm/sop/model/vo/SopInfoVo.java

@@ -0,0 +1,37 @@
+package com.persagy.fm.sop.model.vo;
+
+import com.persagy.fm.sop.model.dto.Sop;
+
+import java.util.Map;
+
+public class SopInfoVo extends Sop {
+
+    private Integer step_count;
+    private Map<String,String> sign;
+    private String status;
+
+
+    public String getStatus() {
+        return status;
+    }
+
+    public void setStatus(String status) {
+        this.status = status;
+    }
+
+    public Map<String, String> getSign() {
+        return sign;
+    }
+
+    public void setSign(Map<String, String> sign) {
+        this.sign = sign;
+    }
+
+    public Integer getStep_count() {
+        return step_count;
+    }
+
+    public void setStep_count(Integer step_count) {
+        this.step_count = step_count;
+    }
+}

+ 12 - 2
fm-sop/src/main/java/com/persagy/fm/sop/service/GroupSopService.java

@@ -1,5 +1,6 @@
 package com.persagy.fm.sop.service;
 
+import com.alibaba.fastjson.JSONObject;
 import com.persagy.fm.sop.model.dto.RefSopInfo;
 import com.persagy.fm.sop.model.dto.SopEdit;
 import com.persagy.fm.sop.model.vo.*;
@@ -46,7 +47,7 @@ public interface GroupSopService {
 
     /**
      * 添加数据
-     * @param jsonStr
+     * @param sopEdit
      * @return
      * @throws Exception
      */
@@ -55,9 +56,18 @@ public interface GroupSopService {
 
     /**
      * 集团sop-编辑页-保存草稿状态sop
-     * @param jsonStr
+     * @param saveDraftSopVo
      * @return
      * @throws Exception
      */
     public boolean saveDraftSop(SaveDraftSopVo saveDraftSopVo) throws Exception;
+
+    /**
+     * 新增页:查询可供选择的sop,复制、引用时用
+     * @param sopListForSelVo
+     * @return
+     * @throws Exception
+     */
+    public JSONObject querySopListForSel(QuerySopListForSelVo sopListForSelVo)throws Exception;
+
 }

+ 618 - 0
fm-sop/src/main/java/com/persagy/fm/sop/service/impl/GroupSopServiceImpl.java

@@ -1,5 +1,6 @@
 package com.persagy.fm.sop.service.impl;
 
+import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.persagy.fm.common.exception.BusinessValidatorException;
@@ -7,11 +8,14 @@ import com.persagy.fm.sop.mapper.SopMapper;
 import com.persagy.fm.sop.model.dto.*;
 import com.persagy.fm.sop.model.vo.*;
 import com.persagy.fm.sop.service.*;
+import com.persagy.old.cache.OrderTypeCache;
 import com.persagy.old.common.CommonConst;
 import com.persagy.old.common.DateUtil;
 import com.persagy.old.common.SopConst;
+import com.persagy.old.common.StringUtil;
 import com.persagy.old.dao.DBConst;
 import com.persagy.old.dao.DBConst.Result;
+import com.persagy.old.service.EquipModelServiceI;
 import com.persagy.old.service.ObjectServiceI;
 import org.apache.commons.beanutils.BeanUtils;
 import org.apache.commons.collections.CollectionUtils;
@@ -41,6 +45,19 @@ public class GroupSopServiceImpl implements GroupSopService {
     @Autowired
     private SopReviseMsgService sopReviseMsgService;
 
+    //@Autowired
+    private EquipModelServiceI equipModelService;
+    //@Autowired
+    private OrderTypeCache orderTypeCache;
+    @Autowired
+    private SopLabelRelService sopLabelRelService;
+    @Autowired
+    private SopObjRelService sopObjRelService;
+    @Autowired
+    private SopOrderTypeRelService sopOrderTypeRelService;
+    @Autowired
+    private SopEquipModelRelService sopEquipModelRelService;
+
 
 
 
@@ -393,6 +410,607 @@ public class GroupSopServiceImpl implements GroupSopService {
     }
 
     @Override
+    public JSONObject querySopListForSel(QuerySopListForSelVo sopListForSelVo) throws Exception {
+        String projectId = sopListForSelVo.getProjectId();
+        String sopId = sopListForSelVo.getSop_id();
+        String sop_name = sopListForSelVo.getSop_name();
+        //是否返回包含大类对象的sop  true:返回   false:不返回 (默认返回)
+        Boolean flag = true;
+        if(BooleanUtils.isFalse(sopListForSelVo.isIs_contains_classObj())) {
+            flag = false;
+        }
+        //1.根据update和项目id查询
+        List<Sop> sops = queryPublishedSopsByProjectIdAndUpdatetime(sopListForSelVo, projectId);
+        //2筛选sop
+
+        /*
+        removeReviseSop(sops);//已经直接放到sql 语句中查询了
+        if (!jsonObject.getString("project_id").equals(CommonConst.group_sop_id)) {
+			String rootProjFuncType = objectService.queryRootProjFuncTypeById(jsonObject.getString("project_id"));
+			removeWithoutProJFuncType(sops, rootProjFuncType);
+		}
+         */
+        removeRelSop(sops,projectId,sopId);
+
+        if (!flag) {
+            Iterator<Sop> iterator = sops.iterator();
+            while (iterator.hasNext()) {
+                Sop sopItem = iterator.next();
+                if (isContainsClassObj(sopItem)) {
+                    iterator.remove();
+                }
+            }
+        }
+        //=========3.筛选SOP========
+        //根据 sign_codes 进行筛选
+        sops = filterSopBySignCodes(sopListForSelVo.getSign_codes(), sops, projectId);
+
+
+        //sops = filterSopByName(sop_name, sops); 直接在sql 中解决
+        sops = filterSopByFitScope(sopListForSelVo, sops);
+
+
+        //=========3设置返回字段======
+
+        List<SopInfoVo> sopInfoVos = additionalSopDetail(sops,projectId,"2");
+        JSONObject item = new JSONObject();
+        //------------设置过滤项-----
+        if (sopListForSelVo.isNeed_return_criteria()) {
+            Map<String, Object> criteria = getSopListCriteria(sops, sopInfoVos);
+            item.put("criteria", criteria);
+        }
+        //JSONArray content = new JSONArray();
+       /* for (Object object : sops) {
+            content.add(JSONUtil.getJsonObjectWithKeys((JSONObject)object, querySopListForSel_keys));
+            content.add(sopInfoVos
+        }*/
+        item.put("content", sopInfoVos);
+        item.put("count", sopInfoVos.size());
+        return item;
+    }
+
+
+    private Map<String, Object> getSopListCriteria(List<Sop> sops, List<SopInfoVo> sopInfoVos) throws Exception {
+        //根据业务数据抽取条件
+        Map<String,Object> criteria = getSopListCriteria(sops);
+
+        //根据视图数据抽取条件
+        //这个的我们使用视图对象进行抽取criteria.put("signs", signs);
+        Map<String, Map<String,String>> signMap = getBathchMergeRecordBySign(sopInfoVos);
+        List<Object> signs = new JSONArray();
+//			signs.addAll(signMap.values());
+        for (String signCode : signMap.keySet()) {
+            signs.add(signMap.get(signCode));
+        }
+        criteria.put("signs", signs);
+        return criteria;
+    }
+
+    private List<Sop> filterSopByFitScope(QuerySopListForSelVo sopListForSelVo, List<Sop> sops) throws Exception {
+        JSONObject param = JSONObject.parseObject(JSONObject.toJSONString(sopListForSelVo));
+
+        param.remove("project_id");
+        JSONObject epuipModelsResJson = null, labelsResJson = null, orderTypeResJson = null, fitObjResJson = null;
+        if (StringUtil.isEmptyList(param, "equip_model_ids")
+                && StringUtil.isEmptyList(param, "labels")
+                && StringUtil.isEmptyList(param, "order_type")
+                && StringUtil.isEmptyList(param, "fit_obj_ids")) {
+            return sops;
+        }else {
+            //查询条件后的交集
+            Set<String> sopId = new HashSet<>();
+            Map<String, Sop> sopMap = getSopMap(sops);
+            //1.根据适用返回查询sopid
+            //1.1根据设备型号查询
+            if(!StringUtil.isEmptyList(param, "equip_model_ids")){
+                QueryWrapper<SopEquipModelRel> sopEquipModelRelQueryWrapper = new QueryWrapper<>();
+                sopEquipModelRelQueryWrapper.in("equip_model_id",sopListForSelVo.getEquip_model_ids());
+                List<SopEquipModelRel> list = sopEquipModelRelService.list(sopEquipModelRelQueryWrapper);
+
+                Set<String> tmp = new HashSet<>();
+                for (SopEquipModelRel sopEquipModelRel : list) {
+                    tmp.add(sopEquipModelRel.getSopId());
+                }
+                sopId.addAll(tmp);
+            }
+            //1.2根据自定义标签查询
+            if( !StringUtil.isEmptyList(param, "labels")){
+                QueryWrapper<SopLabelRel> query = new QueryWrapper<>();
+                query.in("label",sopListForSelVo.getLabels());
+                List<SopLabelRel> list = sopLabelRelService.list(query);
+                Set<String> tmp = new HashSet<>();
+                for (SopLabelRel sopLabelRel : list) {
+                    tmp.add(sopLabelRel.getSopId());
+                }
+                sopId.retainAll(tmp);
+            }
+            //1.3根据工单类型查询
+            if(!StringUtil.isEmptyList(param, "order_type")){
+                QueryWrapper<SopOrderTypeRel> query = new QueryWrapper<>();
+                query.in("order_type",sopListForSelVo.getOrder_type());
+                List<SopOrderTypeRel> list = sopOrderTypeRelService.list(query);
+                Set<String> tmp = new HashSet<>();
+                for (SopOrderTypeRel sopOrderTypeRel : list) {
+                    tmp.add(sopOrderTypeRel.getSopId());
+                }
+                sopId.retainAll(tmp);
+            }
+            //1.4根据适用对象查询
+            if( !StringUtil.isEmptyList(param, "fit_obj_ids")){
+                QueryWrapper<SopObjRel> query = new QueryWrapper<>();
+                query.in("obj_id",sopListForSelVo.getFit_obj_ids());
+                List<SopObjRel> list = sopObjRelService.list(query);
+                Set<String> tmp = new HashSet<>();
+                for (SopObjRel sopObjRel : list) {
+                    tmp.add(sopObjRel.getSopId());
+                }
+                sopId.retainAll(tmp);
+            }
+
+            //查询出每张表中的id 然后求出一个交集来
+
+            List<Sop> resultSops = new ArrayList<>();
+            for (String s : sopId) {
+                if (sopMap.containsKey(s)) {
+                    resultSops.add(sopMap.get(sopId));
+                }
+            }
+            return resultSops;
+        }
+
+    }
+
+    /**
+     *
+     * Description:
+     * @param sops
+     * @return HashMap<String,Sop>    key:sop_id ; value: sop
+     * @author yuecaipu
+     * @since 2018年7月10日: 下午5:50:41
+     * Update By yuecaipu 2018年7月10日: 下午5:50:41
+     */
+    private Map<String, Sop> getSopMap(List<Sop> sops) {
+        Map<String, Sop> resultMap = new HashMap<>();
+        for (Sop sop : sops) {
+            resultMap.put(sop.getSopId(),sop);
+        }
+        return resultMap;
+    }
+
+
+
+
+    private JSONObject getSopListCriteria(List<Sop> content) throws Exception {
+        // 遍历结果过滤字段、组合返回查询参数
+        JSONObject sopItem,  equipModel;
+        JSONObject criteria = new JSONObject();
+
+        if (content != null) {
+
+            HashMap<String, String> equipModelMap = collectEquipModeFromSops(content);
+            JSONArray equipModels = new JSONArray();
+            for (String equipModelId : equipModelMap.keySet()) {
+                equipModel = new JSONObject();
+                equipModel.put("equip_model_id", equipModelId);
+                equipModel.put("equip_model_name", equipModelMap.get(equipModelId));
+                equipModels.add(equipModel);
+            }
+
+            HashMap<String, Object> fitObjMap = collectFitObjsFromSops(content);
+            JSONArray fitObjs = new JSONArray();
+            for (String fitObjId : fitObjMap.keySet()) {
+                fitObjs.add(fitObjMap.get(fitObjId));
+            }
+
+            HashMap<String, Object> OrderTypeMap = collectOrderTypeFromSops(content);
+            JSONArray orderTypes = new JSONArray();
+            for (String OrderTypeId : OrderTypeMap.keySet()) {
+                orderTypes.add(OrderTypeMap.get(OrderTypeId));
+            }
+
+            JSONArray labels = new JSONArray();
+            for (Sop sop : content) {
+                List<String> labelsItem = sop.getLabels();
+                if(CollectionUtils.isNotEmpty(labelsItem)) {
+                    for (String s : labelsItem) {
+                        if (!labels.contains(s)) {
+                            labels.add(s);
+                        }
+                    }
+                }
+            }
+
+            //HashMap<String, Object> signMap = getBathchMergeRecordBySign(content);
+           // JSONArray signs = new JSONArray();
+//			signs.addAll(signMap.values());
+           // for (String signCode : signMap.keySet()) {
+           //     signs.add(signMap.get(signCode));
+            //}
+            criteria.put("equip_models", equipModels);
+            criteria.put("labels", labels);
+            criteria.put("order_type", orderTypes);
+            criteria.put("fit_objs", fitObjs);
+           // criteria.put("signs", signs);
+        }
+
+        return criteria;
+    }
+
+
+    private Map<String, Map<String,String>> getBathchMergeRecordBySign(List<SopInfoVo> sops) {
+        Map<String, Map<String,String>> signMap = new HashMap<>();
+        if(CollectionUtils.isNotEmpty(sops)) {
+            for (SopInfoVo sop : sops) {
+                Map<String, String> sign = sop.getSign();
+                if (sign != null) {
+                    String signCode = sign.get("code");
+                    if (!signMap.containsKey(signCode)) {
+                        Map<String, String> signTemp = new HashMap<>();
+                        signTemp.put("code", signCode);
+                        signTemp.put("name", sign.get("name"));
+                        signMap.put(signCode, signTemp);
+                    }
+                }
+            }
+        }
+        return signMap;
+    }
+
+    private HashMap<String, Object> collectFitObjsFromSops(List<Sop> sops) {
+        HashMap<String, Object> map = new HashMap<>();
+        if(CollectionUtils.isNotEmpty(sops)) {
+            for (Sop sop : sops) {
+
+                List<Sop.FitObjsBean> fitObjs = sop.getFitObjs();
+                if(CollectionUtils.isNotEmpty(fitObjs)) {
+                    for (Sop.FitObjsBean fitObj : fitObjs) {
+                        Map<String, String> fitObjTemp = new HashMap<>();
+                        fitObjTemp.put("obj_id", fitObj.getObj_id());
+                        fitObjTemp.put("obj_name", fitObj.getObj_name());
+                        map.put(fitObj.getObj_id(), fitObjTemp);
+                    }
+                }
+            }
+        }
+        return map;
+    }
+    private HashMap<String, Object> collectOrderTypeFromSops(List<Sop> sops) throws Exception {
+        HashMap<String, Object > map = new HashMap<>();
+        if(CollectionUtils.isNotEmpty(sops)) {
+            for (Sop sop : sops) {
+                List<String> orderTypes = sop.getOrderType();
+                if(CollectionUtils.isNotEmpty(orderTypes)) {
+                    for (String orderTypeId : orderTypes) {
+                        Map<String,String> orderTypeMap = new HashMap<>();
+                        orderTypeMap.put("code", orderTypeId);
+                        orderTypeMap.put("name", orderTypeCache.getOrderTypeNameById(orderTypeId));
+                        map.put(orderTypeId, orderTypeMap);
+                    }
+                }
+            }
+        }
+        return map;
+    }
+
+
+    /**
+     *
+     * Description: 获取到sop中所有设备型号
+     * @param sops  集合中的对象中包含equip_model_ids
+     * @return HashMap<String,String>    key:equip_model_id ; value:equip_model_name
+     * @throws Exception
+     * @author yuecaipu
+     * @since 2018年7月12日: 上午11:11:17
+     * Update By yuecaipu 2018年7月12日: 上午11:11:17
+     */
+    private HashMap<String, String> collectEquipModeFromSops(List<Sop> sops) throws Exception {
+
+        HashMap<String, String> equipModelMap= new HashMap<>();
+        if(CollectionUtils.isNotEmpty(sops)) {
+            Set<String> equipModelIds = new HashSet<>();
+            for (Sop sop : sops) {
+                List<String> equipModelId = sop.getEquipModelIds();
+                if(CollectionUtils.isNotEmpty(equipModelIds)) {
+                    equipModelIds.addAll(equipModelId);
+                }
+            }
+            if(CollectionUtils.isNotEmpty(equipModelIds)) {
+                JSONObject param = new JSONObject();
+                param.put("equip_model_ids", equipModelIds);
+                String equipModelStrs = equipModelService.queryBathchMergeRecordByequipModelIds(param.toJSONString(),
+                        "equip_model_ids", "equip_model_id");
+                JSONObject equipModelObjs = JSONObject.parseObject(equipModelStrs);
+                JSONArray equipModels = equipModelObjs.getJSONArray(DBConst.Result.CONTENT);
+                for (int j = 0, length = equipModels.size(); j < length; j++) {
+                    JSONObject equipModel = equipModels.getJSONObject(j);
+                    equipModelMap.put(equipModel.getString("equip_model_id"), equipModel.getString("equip_model_name"));
+                }
+            }
+        }
+        return equipModelMap;
+    }
+
+
+
+    /**
+     *
+     * Description: 补全sop详情信息
+     * @param sops
+     * @param projectId
+     * @param queryType  1-查询发布  2-查询可复制引用
+     * @author yuecaipu
+     * @throws Exception
+     * @since 2018年7月12日: 下午12:23:55
+     * Update By yuecaipu 2018年7月12日: 下午12:23:55
+     */
+    private List<SopInfoVo> additionalSopDetail(List<Sop> sops, String projectId, String queryType) throws Exception {
+        List<SopInfoVo> sopInfoVos = new ArrayList<>();
+        if(CollectionUtils.isNotEmpty(sops)) {
+
+            HashMap<String, String> equipModelMap = collectEquipModeFromSops(sops);
+            for (Sop sop : sops) {
+                SopInfoVo sopInfoVo = new SopInfoVo();
+                org.springframework.beans.BeanUtils.copyProperties(sop,sopInfoVo);
+                if ("2".equals(queryType)) {
+                    sopInfoVo.setStep_count(sop.getSteps().size());
+                }
+
+                /* if ("1".equals(queryType)) {
+                    sop.put("sign", getSopSign(sop, projectId));
+                    sop.put("status",projectId.equals(sop.getString("project_id")) ? sop.getString("publish_status") : "0");
+                    JSONArray scopes = new JSONArray();
+                    JSONArray fitObjs = sop.getJSONArray("fit_objs");
+                    for (int j = 0, len = fitObjs.size(); j < len; j++) {
+                        scopes.add(fitObjs.getJSONObject(j).getString("obj_name"));
+                    }
+
+                    JSONArray equipModelIds = sop.getJSONArray("equip_model_ids");
+                    if (equipModelIds != null && equipModelIds.size() > 0) {
+                        for (Object equipModelId : equipModelIds) {
+                            scopes.add(equipModelMap.get((String) equipModelId));
+                        }
+                    }
+                    JSONArray orderTypes = sop.getJSONArray("order_type");
+                    String orderTypeName ;
+                    for (Object orderTypeId : orderTypes) {
+                        orderTypeName = orderTypeCache.getOrderTypeNameById((String)orderTypeId);
+                        scopes.add(orderTypeName);
+                    }
+                    sop.put("scopes", scopes);
+                }*/
+
+                if ("1".equals(queryType)) {
+                    sopInfoVo.setSign(getSopSign(sop,projectId));
+                }
+
+                sopInfoVos.add(sopInfoVo);
+            }
+        }
+        return sopInfoVos;
+    }
+
+    /**
+     *
+     * @param sop
+     * @param projectId
+     * @return   code  string
+     *           name string
+     * @throws Exception
+     */
+    public Map<String, String> getSopSign(Sop sop, String projectId) throws Exception{
+        Map<String,String> sign = null;
+        if (CommonConst.group_sop_id.equals(projectId)) {
+            String publishStatus = sop.getPublishStatus();
+            if (SopConst.PUBLISH_STATUS_REVISE.equals(publishStatus)) {
+                sign.put("code", "revise");
+                sign.put("name", "待修订");
+            } else if (SopConst.PUBLISH_STATUS_REVISEING.equals(publishStatus)) {
+                sign.put("code", "revising");
+                sign.put("name", "编辑中");
+            }
+        }else {
+            if(SopConst.SOP_TYPE_GROUP.equals(sop.getSopType())){//sop_type:1 集团sop  2项目专用sop
+                sign.put("code", "public");
+                sign.put("name", "集团");
+            }else{
+                // String sopProjectId = sop.getString("project_id");
+                //  if(projectId.equals(sopProjectId)){
+                String publishStatus = sop.getPublishStatus();
+                if (SopConst.PUBLISH_STATUS_REVISE.equals(publishStatus)) {
+                    sign.put("code", "revise");
+                    sign.put("name", "待修订");
+                } else if (SopConst.PUBLISH_STATUS_REVISEING.equals(publishStatus)) {
+                    sign.put("code", "revising");
+                    sign.put("name", "编辑中");
+                }
+                //}
+				/*else{
+                sign = new JSONObject();
+                sign.put("code", projectId);
+                sign.put("name", projectCache.getProjectNameById(projectId));
+            }*/
+            }
+        }
+        return sign;
+    }
+
+
+
+    /**
+     *
+     * Description: 根据signCodes筛选sop(交集)
+     * @param signCodes
+     * @param sops
+     * @return JSONArray
+     * @author yuecaipu
+     * @since 2018年7月10日: 下午12:09:41
+     * Update By yuecaipu 2018年7月10日: 下午12:09:41
+     */
+    private List<Sop> filterSopBySignCodes(List<String> signCodes, List<Sop> sops, String projectId) {
+        List<Sop> resultSops = new ArrayList<>();
+        if(CollectionUtils.isEmpty(signCodes)) {
+            return sops;
+        }
+//		if (signCodes.size() > 1) {
+//			return sops;
+//		}
+        if (signCodes.contains("public")) {
+            for (Sop object : sops) {
+                if (SopConst.SOP_TYPE_GROUP.equals(object.getSopType())) {
+                    resultSops.add(object);
+                }
+            }
+        }
+
+        if (signCodes.contains("revise")) {
+            for (Sop object : sops) {
+                if (projectId.equals(object.getProjectId()) && SopConst.PUBLISH_STATUS_REVISE.equals(object.getPublishStatus())) {
+                    resultSops.add(object);
+                }
+            }
+        }
+
+        if (signCodes.contains("revising")) {
+            for (Sop object : sops) {
+                if (projectId.equals(object.getProjectId()) && SopConst.PUBLISH_STATUS_REVISEING.equals(object.getPublishStatus())) {
+                    resultSops.add(object);
+                }
+            }
+        }
+        return resultSops;
+    }
+
+
+
+
+    public boolean isContainsClassObj(Sop sop) throws Exception {
+        List<SopStepsBean> steps = sop.getSteps();
+        for (SopStepsBean step : steps) {
+            Boolean from_sop = step.isFrom_sop();
+            //非引用
+            if(!from_sop) {
+                List<SopStepsBean.StepContentBean> step_content = step.getStep_content();
+                for (SopStepsBean.StepContentBean stepContentBean : step_content) {
+                    Boolean from_sop1 = stepContentBean.isFrom_sop();
+                    //非引用
+                    if(!from_sop1) {
+                        List<SopStepsBean.StepContentBean.ContentObjsBean> content_objs = stepContentBean.getContent_objs();
+                        for (SopStepsBean.StepContentBean.ContentObjsBean content_obj : content_objs) {
+                            String obj_type = content_obj.getObj_type();
+                            if (obj_type.contains("_")) {
+                                return true;
+                            }
+                        }
+                    }else {
+                        //如果是引用的haul
+                        String sop_id = stepContentBean.getSop_id();
+                        Sop sop1 = new Sop();
+                        Sop query = sop1.selectById(sop_id);
+                        if(query != null) {
+                            return isContainsClassObj(query);
+                        }
+
+                    }
+                }
+
+
+            }else {
+                //如果是引用的haul
+                String sop_id = step.getSop_id();
+                Sop sop1 = new Sop();
+                Sop query = sop1.selectById(sop_id);
+                if(query != null) {
+                    return isContainsClassObj(query);
+                }
+
+            }
+        }
+        return false;
+
+    }
+
+    private void removeRelSop( List<Sop>  sops, String projectId, String sopId) {
+        Set<String> relSopIds = querySopRel(projectId, sopId);
+        relSopIds.add(sopId);
+        Iterator<Sop> iterator = sops.iterator();
+        while (iterator.hasNext()) {
+            Sop next = iterator.next();
+            String nodeId = next.getSopId();
+            if (relSopIds.contains(nodeId)) {
+                iterator.remove();
+            }
+        }
+    }
+
+    private Set<String> querySopRel(String projectId,String sopId) {
+        //key:被引用SOP的主键id  value:引用该SOP的SOP主键id
+        Map<String, Set<String>> relSopId2sopId = new HashMap<>();
+
+        QueryWrapper<SopSopRel> query = new QueryWrapper();
+        query.eq("'",projectId).eq("",sopId).eq("valid",true);
+
+        List<SopSopRel> list = sopSopRelService.list(query);
+        for (SopSopRel sopSopRel : list) {
+            String rel_sop_id = sopSopRel.getRelSopId();
+            String sop_id = sopSopRel.getSopId();
+            Set<String> sopIds = relSopId2sopId.getOrDefault(rel_sop_id, new HashSet<String>());
+            sopIds.add(sop_id);
+            relSopId2sopId.put(rel_sop_id, sopIds);
+        }
+        return getRelSopRecursively(relSopId2sopId,sopId);
+    }
+
+    private Set<String> getRelSopRecursively(Map<String, Set<String>> relSopId2sopId, String sopId) {
+        Set<String> relSopIds = new HashSet<>();
+        if (CollectionUtils.isEmpty(relSopId2sopId.get(sopId))) {
+            return relSopIds;
+        }
+        Set<String> set = relSopId2sopId.get(sopId);
+        relSopIds.addAll(set);
+        for (String string : set) {
+            relSopIds.addAll(getRelSopRecursively(relSopId2sopId, string));
+        }
+        return relSopIds;
+    }
+
+
+
+
+    private List<Sop> queryPublishedSopsByProjectIdAndUpdatetime(QuerySopListForSelVo sopListForSelVo,String projectId) throws Exception {
+        String sop_name = sopListForSelVo.getSop_name();
+        /*
+        //如果项目id 不是集团特有的id的话进入
+		if (!CommonConst.group_sop_id.equals(requestJson.getString("project_id"))) {
+			//如果sign_codes 数时空的话 或者sign_codes 码中包含public 的话
+			if (StringUtil.isEmptyList(requestJson, "sign_codes") || requestJson.getJSONArray("sign_codes").contains("public")) {
+				//设置为group_sop_id
+				projectIds.add(CommonConst.group_sop_id);
+			}
+		}
+
+         */
+        //查询条件为 projectIds valid sop_status SOP_STATUS_PUBLISH,
+        // 大于等于  小于等于   不包含待修订
+
+        QueryWrapper<Sop> query = new QueryWrapper();
+        query.eq("project_id",projectId)
+                .eq("valid",true)
+                .eq("sop_status", SopConst.SOP_STATUS_PUBLISH)
+                .ge("update_time",sopListForSelVo.getUpdate_time_from())
+                .le("update_time",sopListForSelVo.getUpdate_time_to())
+                .ne("publish_status",SopConst.PUBLISH_STATUS_REVISE)
+                .like("sop_name",sop_name).orderByDesc("update_time");
+
+
+        return  sopService.list(query);
+    }
+
+
+
+
+
+
+    @Override
     public boolean verifySopBeforePublish(VerifySopNameVo verifySopNameVo) throws Exception {
         //查询sop 表中是否存在CommonConst.group_sop_id  sop_name  sopId 的数据
         QueryWrapper<Sop> sopQueryWrapper = new QueryWrapper<>();

+ 39 - 0
fm-sop/src/main/java/com/persagy/old/service/EquipModelServiceI.java

@@ -0,0 +1,39 @@
+package com.persagy.old.service;
+
+public interface EquipModelServiceI {
+	/**
+	 * 根据条件查询设备型号表
+	 * @param jsonStr
+	 * @return
+	 * @throws Exception
+	 */
+	String queryRecordByCondition(String jsonStr) throws Exception;
+	/**
+	 * 根据条件批量查询设备型号表
+	 * @param jsonStr
+	 * @return
+	 * @throws Exception
+	 */
+	String queryBathchMergeRecordByCondition(String jsonStr, String arrayInfo, String infoName) throws Exception;
+	/**
+	 * 根据设备型号ids批量查询设备型号表
+	 * @param jsonStr
+	 * @return
+	 * @throws Exception
+	 */
+	String queryBathchMergeRecordByequipModelIds(String jsonStr, String arrayInfo, String infoName) throws Exception;
+	/**
+	 * 根据设备型号id查询设备型号表
+	 * @param jsonStr
+	 * @return
+	 * @throws Exception
+	 */
+	String queryRecordByEquipModelId(String jsonStr) throws Exception;
+	/**
+	 * 根据设备型号名称查询所有设备型号(有效和无效)
+	 * @param jsonStr
+	 * @return
+	 * @throws Exception
+	 */
+	String queryRecordByEquipModelName(String jsonStr) throws Exception;
+}

+ 52 - 0
fm-sop/src/main/java/com/persagy/old/service/impl/EquipModelServiceImpl.java

@@ -0,0 +1,52 @@
+package com.persagy.old.service.impl;
+
+import com.alibaba.fastjson.JSONObject;
+import com.persagy.old.common.JSONUtil;
+import com.persagy.old.dao.DBCommonMethods;
+import com.persagy.old.dao.DBConst;
+import com.persagy.old.service.BaseService;
+import com.persagy.old.service.EquipModelServiceI;
+import org.springframework.stereotype.Service;
+
+@Service("equipModelService")
+public class EquipModelServiceImpl extends BaseService implements EquipModelServiceI {
+
+    @Override
+    public String queryRecordByCondition(String jsonStr) throws Exception {
+        JSONObject jsonObject = JSONObject.parseObject(jsonStr);
+        jsonObject.put(DBConst.TABLE_FIELD_VALID, true);
+        String paramStr = JSONUtil.getCriteriaWithMajors(jsonObject, "company_id", "equip_model_id", "equip_model_name", "valid").toJSONString();
+        String resultStr = DBCommonMethods.queryRecordByCriteria(DBConst.DATABASE_SAAS_NAME,DBConst.TABLE_EQUIP_MODEL, paramStr);
+        return resultStr;
+    }
+    @Override
+    public String queryRecordByEquipModelName(String jsonStr) throws Exception {
+    	JSONObject jsonObject = JSONObject.parseObject(jsonStr);
+    	String paramStr = JSONUtil.getCriteriaWithMajors(jsonObject, "equip_model_name").toJSONString();
+    	String resultStr = DBCommonMethods.queryRecordByCriteria(DBConst.DATABASE_SAAS_NAME,DBConst.TABLE_EQUIP_MODEL, paramStr);
+    	return resultStr;
+    }
+    @Override
+    public String queryRecordByEquipModelId(String jsonStr) throws Exception {
+    	JSONObject jsonObject = JSONObject.parseObject(jsonStr);
+    	String paramStr = JSONUtil.getCriteriaWithMajors(jsonObject,"equip_model_id").toJSONString();
+    	String resultStr = DBCommonMethods.queryRecordByCriteria(DBConst.DATABASE_SAAS_NAME,DBConst.TABLE_EQUIP_MODEL, paramStr);
+    	return resultStr;
+    }
+    @Override
+    public String queryBathchMergeRecordByCondition(String jsonStr, String arrayInfo, String infoName) throws Exception {
+        JSONObject jsonObject = JSONObject.parseObject(jsonStr);
+        jsonObject.put(DBConst.TABLE_FIELD_VALID, true);
+        String paramStr = JSONUtil.getCriteriasWithMajors(jsonObject, arrayInfo, infoName,"valid").toJSONString();
+        String resultStr = DBCommonMethods.queryBathchMergeRecordByCriterias(DBConst.DATABASE_SAAS_NAME,DBConst.TABLE_EQUIP_MODEL, paramStr);
+        return resultStr;
+    }
+    @Override
+    public String queryBathchMergeRecordByequipModelIds(String jsonStr, String arrayInfo, String infoName) throws Exception {
+		JSONObject jsonObject = JSONObject.parseObject(jsonStr);
+		String paramStr = JSONUtil.getCriteriasWithMajors(jsonObject, arrayInfo, infoName, infoName).toJSONString();
+		String resultStr = DBCommonMethods.queryBathchMergeRecordByCriterias(DBConst.DATABASE_SAAS_NAME,
+				DBConst.TABLE_EQUIP_MODEL, paramStr);
+		return resultStr;
+    }
+}