| | |
| | | package cn.ksource.web.facade.customerconfig.slacustomer; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import cn.ksource.beans.CI_DAILY_PATROL_ITEM; |
| | | import cn.ksource.beans.CMDB_CI_CATEGORY; |
| | | import cn.ksource.core.dao.BaseDao; |
| | |
| | | import cn.ksource.core.util.ConvertUtil; |
| | | import cn.ksource.core.util.JsonUtil; |
| | | import cn.ksource.core.util.StringUtil; |
| | | import cn.ksource.core.web.WebUtil; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | @Service("slaCustomerFacade") |
| | | public class SlaCustomerFacadeImpl implements SlaCustomerFacade{ |
| | | @Autowired |
| | |
| | | param.put("itemName", "%"+itemName+"%"); |
| | | param.put("itemType", itemType); |
| | | param.put("state", state); |
| | | |
| | | |
| | | |
| | | |
| | | return baseDao.queryforSplitPageInfo(pageInfo, selectSql.toString(), param); |
| | | } |
| | | /** |
| | |
| | | */ |
| | | @Override |
| | | public List<Map> getCiCategoryTree(String pid) { |
| | | String sql = " SELECT ID as id,PID as pid,NAME as name,LV as jb FROM CMDB_CI_CATEGORY WHERE STATE=1 AND CATE_TYPE=1 "; |
| | | String sql = " SELECT ID as \"id\",PID as \"pid\",NAME as \"name\",LV as \"jb\" FROM CMDB_CI_CATEGORY WHERE STATE=1 AND CATE_TYPE=1 "; |
| | | SqlParameter param = new SqlParameter(); |
| | | if(StringUtil.isNotBlank(pid)){ |
| | | sql += " AND PID=:pid "; |
| | |
| | | String thirdCateId = param.get("business_id"); |
| | | String thirdCateName = param.get("business_name"); |
| | | String p_id = param.get("p_id"); |
| | | |
| | | |
| | | item.setId(id).setState(1).setItem_type(2).setBusiness_id(thirdCateId).setBusiness_name(thirdCateName) |
| | | .setP_id(p_id).setCustomer_id(customerId).insert(); |
| | | |
| | | |
| | | String insertSql = "INSERT INTO CI_DAILY_PATROL_CUSTOMER_ITEM(ID,CUSTOMER_ID,ITEM_ID,USING_STATE) VALUES (:id,:customerId,:itemId,1)"; |
| | | param.put("id", StringUtil.getUUID()); |
| | | param.put("itemId", id); |
| | |
| | | baseDao.execute(updateSql, param); |
| | | return true; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 查询项目可以增加的指标项 |
| | | */ |
| | |
| | | param.put("itemName", "%"+itemName+"%"); |
| | | return baseDao.queryForInteger(selectSql.toString(),param); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 保存选择的指标项 |
| | | */ |
| | |
| | | builder.append(" AND A.SUB_CUSTOMER_ID = :subCustomerId "); |
| | | paramMap.put("subCustomerId", subCustomerId); |
| | | } |
| | | |
| | | |
| | | if(StringUtil.notEmpty(categoryId)) { |
| | | builder.append(" AND B.LV3_ID = :categoryId "); |
| | | paramMap.put("categoryId", categoryId); |
| | | } |
| | | |
| | | |
| | | if(StringUtil.notEmpty(ciName)) { |
| | | builder.append(" AND B.CINAME LIKE :ciName "); |
| | | paramMap.put("ciName", "%"+ciName+"%"); |
| | | } |
| | | |
| | | |
| | | builder.append(" ORDER BY B.CREATE_TIME DESC "); |
| | | |
| | | |
| | | PageInfo info = baseDao.queryforSplitPageInfo(pageInfo, builder.toString(), paramMap); |
| | | return info; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 日常巡检设备数量 |
| | | */ |
| | | @Override |
| | | public int queryDailyDeviceCount(String customerId,String subCustomerId,String categoryId,String ciName) { |
| | | StringBuilder builder = new StringBuilder("SELECT COUNT(A.ID) FROM CI_DAILY_PATROL_CI A,CMDB_CI_BASE B WHERE A.CI_ID = B.ID AND B.STATE = 1 AND A.CUSTOMER_ID = :customerId"); |
| | | |
| | | |
| | | Map paramMap = new HashMap(); |
| | | paramMap.put("customerId", customerId); |
| | | if(StringUtil.notEmpty(subCustomerId)) { |
| | |
| | | builder.append(" AND B.LV3_ID = :categoryId "); |
| | | paramMap.put("categoryId", categoryId); |
| | | } |
| | | |
| | | |
| | | if(StringUtil.notEmpty(ciName)) { |
| | | builder.append(" AND B.CINAME LIKE :ciName "); |
| | | paramMap.put("ciName", "%"+ciName+"%"); |
| | | } |
| | | |
| | | |
| | | int count = baseDao.queryForInteger(builder.toString(),paramMap); |
| | | return count; |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public List queryAddDailyDevice(String customerId,String subCustomerId,String ciName,String cateId,String sub_customer_id) { |
| | | StringBuilder builder = new StringBuilder("SELECT A.ID,A.SEARCHCODE,A.CINAME,A.LV3_NAME,A.POSITION,A.CUS_ID,A.SUB_CUS_ID,A.SUB_CUS_NAME " + |
| | |
| | | builder.append(" AND A.LV3_ID = :cateId "); |
| | | paramMap.put("cateId", cateId); |
| | | } |
| | | |
| | | |
| | | builder.append(" AND NOT EXISTS (SELECT B.ID FROM CI_DAILY_PATROL_CI B WHERE A.ID = B.CI_ID AND B.CUSTOMER_ID = :customerId ) ORDER BY A.CREATE_TIME DESC "); |
| | | List devices = baseDao.queryForList(builder.toString(),paramMap); |
| | | return devices; |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public Integer queryAddDailyDeviceCount(String customerId, |
| | | String subCustomerId, String ciName, String cateId, |
| | |
| | | builder.append(" AND A.LV3_ID = :cateId "); |
| | | paramMap.put("cateId", cateId); |
| | | } |
| | | |
| | | |
| | | builder.append(" AND NOT EXISTS (SELECT B.ID FROM CI_DAILY_PATROL_CI B WHERE A.ID = B.CI_ID AND B.CUSTOMER_ID = :customerId ) ORDER BY A.CREATE_TIME DESC "); |
| | | Integer i = baseDao.queryForInteger(builder.toString(),paramMap); |
| | | return i; |
| | | } |
| | | } |
| | | /** |
| | | * 添加项目需巡检设备 |
| | | * @param request |
| | |
| | | baseDao.execute(deleteSql, new SqlParameter("id",id)); |
| | | return true; |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * 查询健康检查指标项配置 |
| | | * @param request |
| | |
| | | String steps=param.get("steps"); |
| | | String expect_value=param.get("expect_value"); |
| | | String order_num = param.get("order_num"); |
| | | |
| | | |
| | | String[] cateIds = param.get("full_cate_id").split("-"); |
| | | String[] cateNames = param.get("full_cate_name").split("-"); |
| | | if (cateIds.length == 3) { |
| | |
| | | param.put("business_name", cateNames[1]); |
| | | param.put("p_id", cateIds[0]); |
| | | } |
| | | |
| | | |
| | | String id = StringUtil.getUUID(); |
| | | |
| | | |
| | | String insertSql = "INSERT INTO CI_HEALTH_ITEM(ID,ITEM_NAME,PRIORITY_LEVEL_ID,PRIORITY_LEVEL_NAME,ITEM_NOTE,ORDER_NUM,STATE,BUSINESS_ID,BUSINESS_NAME,ITEM_TYPE,CUSTOMER_ID,STEPS,EXPECT_VALUE,P_ID,FULL_CATE_ID,FULL_CATE_NAME) VALUES " + |
| | | "(:id,:item_name,:priority_level_id,:priority_level_name,:item_note,:order_num,1,:business_id,:business_name,2,:customerId,:steps,:expect_value,:pId,:full_cate_id,:full_cate_name)"; |
| | | param.put("id", id); |
| | |
| | | param.put("steps", steps); |
| | | param.put("expect_value", expect_value); |
| | | param.put("pId", param.get("p_id")); |
| | | |
| | | |
| | | baseDao.execute(insertSql, param); |
| | | |
| | | |
| | | String saveProjectItemSql = "INSERT INTO CI_HEALTH_CUSTOMER_ITEM(ID,CUSTOMER_ID,ITEM_ID,USING_STATE) VALUES (:id,:customerId,:item_id,1)"; |
| | | Map params = new HashMap(); |
| | | String projectItemId = StringUtil.getUUID(); |
| | |
| | | baseDao.execute(updateSql, param); |
| | | return true; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 查询通用巡检项分类 |
| | | */ |
| | |
| | | baseDao.execute(updateSql, param); |
| | | return true; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 启用或者禁用通用巡检项分类 |
| | | */ |
| | |
| | | baseDao.execute(updateSql, param); |
| | | return true; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 启用或者禁用通用巡检项 |
| | | */ |
| | |
| | | baseDao.execute(updateSql, param); |
| | | return true; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取设备分类树 |
| | | */ |
| | | @Override |
| | | public List<Map> getCiCategoryTree(String pid,String type) { |
| | | String sql = " SELECT ID as id,PID as pid,NAME as name,LV as jb FROM CMDB_CI_CATEGORY WHERE STATE=1 "; |
| | | String sql = " SELECT ID as \"id\",PID as \"pid\",NAME as \"name\",LV as \"jb\",STATE,SERIAL FROM CMDB_CI_CATEGORY WHERE STATE=1 "; |
| | | SqlParameter param = new SqlParameter(); |
| | | if(StringUtil.notEmpty(type)){ |
| | | sql+=" and cate_type=:type"; |
| | |
| | | } |
| | | if(StringUtil.isBlank(pid) && type.equals("2")){ |
| | | sql=""; |
| | | sql="select DISTINCT LV1_ID as id,\"0\" as pid ,LV1_name as name,\"1\" as lv from CMDB_CI_CATEGORY where STATE=1 and lv=3 and CATE_TYPE=2 "; |
| | | sql="select DISTINCT LV1_ID AS \"id\"," + |
| | | " '0' AS \"pid\" ,\n" + |
| | | " LV1_name AS \"name\",\n" + |
| | | " '1' AS \"lv\",STATE,SERIAL from CMDB_CI_CATEGORY where STATE=1 and lv=3 and CATE_TYPE=2 "; |
| | | }else if(StringUtil.isNotBlank(pid) && type.equals("2")){ |
| | | CMDB_CI_CATEGORY cmdb_ci_category=new CMDB_CI_CATEGORY(pid).getInstanceById(); |
| | | Integer lv=cmdb_ci_category.getLv(); |
| | | if(lv==1){ |
| | | sql=""; |
| | | sql="select DISTINCT LV2_ID as id,LV1_ID as pid ,LV2_name as name,\"2\" as lv from CMDB_CI_CATEGORY where STATE=1 and lv=3 and CATE_TYPE=2 and LV1_ID=:pid "; |
| | | sql="select DISTINCT id AS \"id\",'" + |
| | | pid+ |
| | | "' AS \"pid\" ," + |
| | | " name AS \"name\"," + |
| | | " '2' AS \"lv\",STATE,SERIAL from CMDB_CI_CATEGORY where STATE=1 and lv=:lv and CATE_TYPE=2 and LV1_ID=:pid "; |
| | | param.addValue("lv", lv+1); |
| | | param.addValue("pid", pid); |
| | | } |
| | | |
| | | |
| | | } |
| | | sql += " ORDER BY STATE,SERIAL "; |
| | | List<Map> list = baseDao.queryForList(sql,param); |