cy
2022-06-23 da30b02214ab3a35a3b2ac163afce87e70a39ff4
src/cn/ksource/web/facade/rcxj/RcxjFacadeImpl.java
@@ -1,14 +1,5 @@
package cn.ksource.web.facade.rcxj;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import cn.ksource.beans.CI_DAILY_PATROL;
import cn.ksource.beans.FlowRecord;
import cn.ksource.core.dao.BaseDao;
@@ -20,6 +11,13 @@
import cn.ksource.core.util.StringUtil;
import cn.ksource.web.Constants;
import cn.ksource.web.service.flow.FlowRecordService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Service
@SuppressWarnings({"rawtypes"})
@@ -29,8 +27,8 @@
   private BaseDao baseDao;
   @Resource
   private FlowRecordService flowRecordService;
   @Override
   public PageInfo getRcxjData(PageInfo pageInfo, Map<String, String> params) {
      Map support = getRcxjSupport(params);
@@ -69,18 +67,18 @@
      if(StringUtil.isNotBlank(params.get("curId"))){
         sql.append(" and a.cur_id = :curId ");
      }
      if(StringUtil.isNotBlank(params.get("templateKey"))){
         sql.append(" and exists ( ");
         sql.append(" select r.bus_id from ( ");
         sql.append(" select bus_id from flow_record  where deal_id=:dealId and template_key=:templateKey ");
         sql.append(" group by bus_id ) r where r.bus_id = a.id ) ");
      }
      if(StringUtil.isNotBlank(params.get("fstate"))){
         sql.append(" and a.state = :fstate ");
      }
      if(StringUtil.isNotBlank(params.get("state"))){
         if(params.get("state").equals("3")){
            sql.append(" and a.state > :state ");
@@ -91,7 +89,7 @@
            sql.append(" and a.state = :state ");
         }
      }
      sql.append(" order by a.create_time desc ");
      support.put("sql", sql.toString());
      support.put("param", params);
@@ -105,7 +103,7 @@
         .addValue("orderId", orderId);
      //查询分类
      StringBuilder sql = new StringBuilder();
      sql.append(" select ID,CATEGORY_NAME from CI_DAILY_PATROL_CUSTOMER_COMMONS_CATEGORY ");
      sql.append(" where customer_id = :cusId and USING_state=1 order by ordernum asc ");
      List<Map> categoryList = baseDao.queryForList(sql.toString(),param);
@@ -122,7 +120,7 @@
         sql.append(" ) t left join (select * from CI_DAILY_PATROL_COMMON_RECORD where PATROL_ID = :orderId ) r on t.item_id = r.item_id ");
      }
      List<Map> datalist = baseDao.queryForList(sql.toString(),param);
      //拼装数据
      List<Map> resList = new ArrayList<Map>();
      if(categoryList!=null&&categoryList.size()>0){
@@ -157,7 +155,7 @@
      sql.append(" inner join cmdb_ci_base c on p.ci_id = c.id   ");
      sql.append(" inner join ci_daily_ci_item_re r on r.ci_id = p.ci_id ");
      sql.append(" where c.state =1  and p.customer_id =:cusId ");
      if(StringUtil.isNotBlank(params.get("subCusId"))){
      if(StringUtil.isNotBlank(params.get("subCusId"))){
         sql.append(" and p.sub_customer_id =:subCusId ");
      }
      if(StringUtil.isNotBlank(params.get("errflag"))){//只查巡检询异常配置
@@ -165,9 +163,9 @@
         sql.append("    select ci_id from (select ci_id from ci_daily_patrol_record where result<>1 and patrol_id=:orderId group by ci_id ) t where t.ci_id = c.id ");
         sql.append(" ) ");
      }
      sql.append(" group by c.id ");
      sql.append(" group by c.id,c.lv3_id, c.ciname, c.searchcode,c.position ");
      List<Map> ciList = baseDao.queryForList(sql.toString(),params);
      //查询指标
      sql.setLength(0);
      sql.append(" select b.ci_id,b.id,d.item_name,e.result,e.note from ");
@@ -181,7 +179,7 @@
      }
      sql.append(" where a.customer_id = :cusId ");
      List<Map> itemList = baseDao.queryForList(sql.toString(),params);
      //组装数据
      if(ciList!=null&&ciList.size()>0){
         Map<String, Map> ciSet = new HashMap<String, Map>();
@@ -215,7 +213,7 @@
      //指标数量
      int nitem_num = 0;
      int aitem_num = 0;
      Map<String, String> ciMap = new HashMap<String, String>();
      Map<String, String> aciMap = new HashMap<String, String>();
      if(itemlist!=null&&itemlist.size()>0){
@@ -232,19 +230,19 @@
            ciMap.put(c_ci_id, "1");
         }
      }
      report.setNci_num(ciMap.size()-aciMap.size())
         .setAci_num(aciMap.size())
         .setNitem_num(nitem_num)
         .setAitem_num(aitem_num);
      if (StringUtil.isBlank(params.get("orderId"))) {//新增
         report = report.setCreate_time(DateUtil.getCurrentDate14())
                  .setUser_id(params.get("user_id")).insert();
      } else {
         report = report.setId(params.get("orderId")).update();
      }
      //通用巡检记录
      saveCommonPatrolRecord(report.getId(),commonJsonListStr);
      //设备巡检记录
@@ -253,7 +251,7 @@
      saveLinkOrder(report.getId(),linkOrderId);
      return report;
   }
   /**
    * 保存关联工单信息
    * @param orderId
@@ -278,7 +276,7 @@
         }
      }
   }
   private void saveCommonPatrolRecord(String orderId, String commonJsonListStr){
      List<Map> list = JsonUtil.json2List(commonJsonListStr);
      baseDao.execute("delete from ci_daily_patrol_common_record where patrol_id = :orderId ",
@@ -310,7 +308,7 @@
         baseDao.executeBatch(sql, paramList);
      }
   }
   private void saveCiPatrolRecord(String orderId, Map<String, String> params){
      String ciJsonListStr = params.get("ciJsonList");
      List<Map> list = JsonUtil.json2List(ciJsonListStr);
@@ -374,7 +372,7 @@
         patrolDate = DateUtil.getCurrentDate6().toString();
      }
      StringBuilder sql = new StringBuilder();
      sql.append(" select  concat(',',GROUP_CONCAT(DISTINCT  right(PATROL_DATE,2)),',')  ");
      sql.append(" select  concat(',',GROUP_CONCAT(DISTINCT  right(PATROL_DATE,2)),',')  ");
      sql.append(" from CI_DAILY_PATROL p ");
      sql.append(" where ACI_NUM>0 and PATROL_DATE like :patrolDate  ");
      if(StringUtil.isNotBlank(params.get("userId"))){
@@ -395,7 +393,7 @@
         patrolDate = DateUtil.getCurrentDate6().toString();
      }
      StringBuilder sql = new StringBuilder();
      sql.append(" select  CONVERT(concat(',',GROUP_CONCAT(DISTINCT  right(PATROL_DATE,2)),',')    USING utf8) ");
      sql.append(" select  CONVERT(concat(',',GROUP_CONCAT(DISTINCT  right(PATROL_DATE,2)),',')    USING utf8) ");
      sql.append(" from CI_DAILY_PATROL p  ");
      sql.append(" where PATROL_DATE like :patrolDate ");
      if(StringUtil.isNotBlank(params.get("userId"))){
@@ -450,7 +448,7 @@
      String sql = " select * from flow_record where template_key = :key and bus_id = :orderId order by deal_time desc limit 1 ";
      return baseDao.queryForMap(sql,param);
   }
   @Override
   public List<Map> getLinkOrderList(String orderId) {
      String sql = " select  r.RELATE_FLOW_ID FLOWID,b.*  from ORDER_REF_ORDER r  " +
@@ -458,5 +456,5 @@
            " where r.BUSINESS_ID = :orderId  ";
      return baseDao.queryForList(sql, new SqlParameter("orderId",orderId));
   }
}