From b83c40548208609d0d6826be13d742c28a784806 Mon Sep 17 00:00:00 2001
From: cy <1664593601@qq.com>
Date: 星期四, 23 六月 2022 17:10:40 +0800
Subject: [PATCH] fix : MySQL=》DMSQL

---
 src/cn/ksource/web/facade/customerconfig/slacustomer/SlaCustomerFacadeImpl.java |   18 +++++----
 src/cn/ksource/web/facade/duty/DutyFacadeImpl.java                              |   68 +++++++++++++++------------------
 src/cn/ksource/web/service/knowledge/KmServiceImpl.java                         |    2 
 3 files changed, 42 insertions(+), 46 deletions(-)

diff --git a/src/cn/ksource/web/facade/customerconfig/slacustomer/SlaCustomerFacadeImpl.java b/src/cn/ksource/web/facade/customerconfig/slacustomer/SlaCustomerFacadeImpl.java
index aeafa3c..de3f806 100644
--- a/src/cn/ksource/web/facade/customerconfig/slacustomer/SlaCustomerFacadeImpl.java
+++ b/src/cn/ksource/web/facade/customerconfig/slacustomer/SlaCustomerFacadeImpl.java
@@ -795,7 +795,7 @@
 	 */
 	@Override
 	public List<Map> getCiCategoryTree(String pid,String type) {
-		String sql = " SELECT ID as id,PID as pid,NAME as \"name\",LV as jb,STATE,SERIAL  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";
@@ -811,19 +811,21 @@
 		}
 		if(StringUtil.isBlank(pid) && type.equals("2")){
 			sql="";
-			sql="select DISTINCT LV1_ID AS id,\n" +
-					"        '0' AS pid ,\n" +
+			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 ";
+					"        '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 LV1_ID AS id,\n" +
-						"        '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  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);
 			}
 
diff --git a/src/cn/ksource/web/facade/duty/DutyFacadeImpl.java b/src/cn/ksource/web/facade/duty/DutyFacadeImpl.java
index a4e62d5..f4a177f 100644
--- a/src/cn/ksource/web/facade/duty/DutyFacadeImpl.java
+++ b/src/cn/ksource/web/facade/duty/DutyFacadeImpl.java
@@ -1,24 +1,18 @@
 package cn.ksource.web.facade.duty;
 
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.annotation.Resource;
-import javax.servlet.http.HttpServletRequest;
-
-import org.springframework.stereotype.Service;
-
 import cn.ksource.beans.DUTY_PLAN;
 import cn.ksource.core.dao.BaseDao;
 import cn.ksource.core.dao.SqlParameter;
 import cn.ksource.core.util.DateUtil;
 import cn.ksource.core.util.JsonUtil;
 import cn.ksource.core.util.StringUtil;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.*;
 
 @Service
 public class DutyFacadeImpl implements DutyFacade{
@@ -68,8 +62,8 @@
 			}
 		}
 	}
-	
-	
+
+
 	@SuppressWarnings("rawtypes")
 	@Override
 	public List<Map> getPlanListData(HttpServletRequest request) {
@@ -85,32 +79,32 @@
 		String sql = "select count(*) from ( " + supportMap.get("sql").toString() + " ) t";
 		return baseDao.queryForInteger(sql,(Map)supportMap.get("param"));
 	}
-	
+
 	@SuppressWarnings({ "rawtypes", "unchecked" })
 	private Map getPlanListSupportMap(HttpServletRequest request){
 		Map supportMap = new HashMap();
 		SqlParameter param = new SqlParameter();
 		StringBuilder sql = new StringBuilder();
 		sql.append(" SELECT * FROM DUTY_PLAN WHERE 1=1 ");
-		
+
 		String proId = request.getParameter("proId");
 		if(StringUtil.isNotBlank(proId)){
 			sql.append(" AND PROJECT_ID = :proId ");
 			param.addValue("proId", proId);
 		}
-		
+
 		String cusId = request.getParameter("cusId");
 		if(StringUtil.isNotBlank(cusId)){
 			sql.append(" AND CUSTOMER_ID = :cusId ");
 			param.addValue("cusId", cusId);
 		}
-		
+
 		String subCusId = request.getParameter("subCusId");
 		if(StringUtil.isNotBlank(subCusId)){
 			sql.append(" AND SUB_CUSTOMER_ID = :subCusId ");
 			param.addValue("subCusId", subCusId);
 		}
-		
+
 		String state = request.getParameter("state");
 		if(StringUtil.isNotBlank(state)){
 			sql.append(" AND STATE = :state ");
@@ -121,7 +115,7 @@
 			sql.append(" AND DUTY_PLAN_NAME like :plan_name ");
 			param.addValue("plan_name", "%"+plan_name+"%");
 		}
-		
+
 		supportMap.put("sql", sql.toString());
 		supportMap.put("param", param);
 		return supportMap;
@@ -131,12 +125,12 @@
 	@Override
 	public void doConfigDutyPlan(DUTY_PLAN dutyPlan) {
 		dutyPlan.insertOrUpdate();
-		
+
 		String sql = "DELETE FROM DUTY_PEOPLE  WHERE DUTY_DATE_ID IN (SELECT ID FROM DUTY_TABLE WHERE DUTY_PLAN_ID = :planId)";
 		baseDao.execute(sql, new SqlParameter().addValue("planId", dutyPlan.getId()));
 		sql = " DELETE FROM DUTY_TABLE  WHERE DUTY_PLAN_ID = :planId ";
 		baseDao.execute(sql, new SqlParameter().addValue("planId", dutyPlan.getId()));
-		
+
 		String planId = dutyPlan.getId();
 		Integer cycleType = dutyPlan.getCycle_type();
 		List<String> dates = getDates(String.valueOf(dutyPlan.getStart_date()),dutyPlan.getCycle_type());
@@ -153,7 +147,7 @@
 			baseDao.executeBatch(sql,params);
 		}
 	}
-	
+
 	@SuppressWarnings("unused")
 	private List<String> getDates(String statrDate,Integer cycleType){
 		List<String> dates = new ArrayList<String>();
@@ -182,7 +176,7 @@
 				}
 				cal.add(Calendar.DAY_OF_YEAR, 1);//鍔犱竴澶�
 			}
-		
+
 		return dates;
 	}
 
@@ -199,8 +193,8 @@
 			sql+=" AND ZSXM LIKE :name ";
 		}
 		List<Map> users = baseDao.queryForList(sql,param);
-		
-		
+
+
 		//鏌ヨ涓�绾ч儴闂�
 		sql = " select ID ,SJBH PID,JGMC DEPT_NAME from GG_ZZJG where CENGJ=1 AND ZT=1  ";
 		List<Map> lv1s = baseDao.queryForList(sql,param);
@@ -208,7 +202,7 @@
 		for(Map lv1 :lv1s){
 			lv1SetMap.put(lv1.get("ID").toString(),lv1);
 		}
-		
+
 		//灏嗙敤鎴锋斁鍏ヤ簩绾ч儴闂ㄤ笅
 		for(Map user :users){
 			String deptId = user.get("DEPT_ID").toString();
@@ -220,7 +214,7 @@
 			}
 		}
 		System.out.println("-----------"+JsonUtil.list2Json(lv1s));
-		
+
 		return lv1s;
 	}
 
@@ -230,11 +224,11 @@
 		SqlParameter param = new SqlParameter();
 		param.addValue("planId", planId);
 		param.addValue("selMonth", selMonth);
-		
-		
+
+
 		String monthStartDay = selMonth + "01";
 		SimpleDateFormat df = new SimpleDateFormat("yyyyMMdd");
-		Calendar cal = Calendar.getInstance(); 
+		Calendar cal = Calendar.getInstance();
 		try {
 			cal.setTime(df.parse(monthStartDay));
 		} catch (ParseException e) {
@@ -247,7 +241,7 @@
 		}else{
 			cal.add(Calendar.DAY_OF_YEAR, -1);
 		}
-		
+
 		for(int i=0;i<42;i++){
 			Map map = new HashMap();
 			cal.add(Calendar.DAY_OF_YEAR, 1);
@@ -261,7 +255,7 @@
 			map.put("DUTY_DATE",df.format(cal.getTime()));
 			dates.add(map);
 		}
-		
+
 		if(dates!=null&&dates.size()>0){
 			Map<String,Map> dateSetMap = new HashMap<String,Map>();
 			for(Map date:dates){
@@ -287,7 +281,7 @@
 	@SuppressWarnings("rawtypes")
 	@Override
 	public List<Map> getSelectUser(Map param) {
-		String sql=" select * from DUTY_PEOPLE  WHERE DUTY_DATE_ID IN (SELECT ID FROM DUTY_TABLE WHERE DUTY_PLAN_ID = :planId )  group by USER_ID";
+		String sql=" select USER_ID,ID ,USER_NAME, DUTY_DATE_ID, DUTY_NUM from DUTY_PEOPLE  WHERE DUTY_DATE_ID IN (SELECT ID FROM DUTY_TABLE WHERE DUTY_PLAN_ID = :planId )  group by USER_ID,ID, USER_NAME, DUTY_DATE_ID, DUTY_NUM";
 		return baseDao.queryForList(sql, param);
 	}
 
@@ -302,6 +296,6 @@
 	public void doChangePerson(Map param) {
 		String sql="update duty_people set user_id=:userId,user_name=:userName where id=:planId";
 		baseDao.execute(sql, param);
-		
+
 	}
-}	
+}
diff --git a/src/cn/ksource/web/service/knowledge/KmServiceImpl.java b/src/cn/ksource/web/service/knowledge/KmServiceImpl.java
index 7f01b32..4f4e4c7 100644
--- a/src/cn/ksource/web/service/knowledge/KmServiceImpl.java
+++ b/src/cn/ksource/web/service/knowledge/KmServiceImpl.java
@@ -295,7 +295,7 @@
 		}
 		StringBuilder sql = new StringBuilder();
 		sql.append("select t.ID,t.TITLE,t.TAG,t.SUMMARY,t.CREATE_TIME,t.CREATE_USER_NAME,t.IS_EDITOR,t.STATE from ( ");
-		sql.append("select DISTINCT k.ID,k.TITLE,k.TAG,k.SUMMARY,k.CREATE_TIME,k.CREATE_USER_NAME,k.IS_EDITOR,p.STATE ");
+		sql.append("select k.ID,k.TITLE,k.TAG,k.SUMMARY,k.CREATE_TIME,k.CREATE_USER_NAME,k.IS_EDITOR,p.STATE ");
 
 		if(StringUtil.isEmpty(cusId)){
 			sql.append("from km_library k   ");

--
Gitblit v1.9.1