| | |
| | | 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{ |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | @SuppressWarnings("rawtypes") |
| | | @Override |
| | | public List<Map> getPlanListData(HttpServletRequest request) { |
| | |
| | | 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 "); |
| | |
| | | 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; |
| | |
| | | @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()); |
| | |
| | | baseDao.executeBatch(sql,params); |
| | | } |
| | | } |
| | | |
| | | |
| | | @SuppressWarnings("unused") |
| | | private List<String> getDates(String statrDate,Integer cycleType){ |
| | | List<String> dates = new ArrayList<String>(); |
| | |
| | | } |
| | | cal.add(Calendar.DAY_OF_YEAR, 1);//加一天 |
| | | } |
| | | |
| | | |
| | | return dates; |
| | | } |
| | | |
| | |
| | | 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); |
| | |
| | | for(Map lv1 :lv1s){ |
| | | lv1SetMap.put(lv1.get("ID").toString(),lv1); |
| | | } |
| | | |
| | | |
| | | //将用户放入二级部门下 |
| | | for(Map user :users){ |
| | | String deptId = user.get("DEPT_ID").toString(); |
| | |
| | | } |
| | | } |
| | | System.out.println("-----------"+JsonUtil.list2Json(lv1s)); |
| | | |
| | | |
| | | return lv1s; |
| | | } |
| | | |
| | |
| | | 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) { |
| | |
| | | }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); |
| | |
| | | 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){ |
| | |
| | | @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); |
| | | } |
| | | |
| | |
| | | public void doChangePerson(Map param) { |
| | | String sql="update duty_people set user_id=:userId,user_name=:userName where id=:planId"; |
| | | baseDao.execute(sql, param); |
| | | |
| | | |
| | | } |
| | | } |
| | | } |