1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018 |
- package com.sinosoft.em.alert.report.manage.service;
- import java.io.UnsupportedEncodingException;
- import java.sql.SQLException;
- import java.text.ParseException;
- import java.text.SimpleDateFormat;
- import java.util.ArrayList;
- import java.util.Calendar;
- import java.util.Date;
- import java.util.HashMap;
- import java.util.List;
- import java.util.Map;
- import javax.servlet.http.HttpServletRequest;
- import javax.ws.rs.POST;
- import javax.ws.rs.Path;
- import javax.ws.rs.ProduceMime;
- import org.apache.log4j.Logger;
- import org.jfree.data.KeyedValue;
- import org.jfree.util.Log;
- import org.quartz.Job;
- import org.quartz.JobExecutionContext;
- import org.quartz.JobExecutionException;
- import org.springframework.web.context.request.RequestContextHolder;
- import org.springframework.web.context.request.ServletRequestAttributes;
- import com.formaction.Utils;
- import com.persistence.service.PersistenceFactory;
- import com.persistence.service.SysPersistence;
- import com.persistence.service.exception.PersistenceException;
- import com.sinosoft.am.org.jdbcUtil.ORGTemplate;
- import com.sinosoft.em.alert.report.manage.dao.QueryReportProgrammeDao;
- import com.sinosoft.em.alert.report.manage.dao.QueryReportProgrammeDaoImpl;
- import com.sinosoft.em.alert.report.manage.vo.ReportKV;
- import com.sinosoft.em.alert.report.manage.vo.ReportProgress;
- import com.sinosoft.em.alert.report.manage.vo.reportDept;
- import com.sinosoft.em.alert.report.manage.vo.reportPlan;
- import com.sinosoft.em.alert.report.reportInputPlan.vo.KeyValue;
- import com.sinosoft.em.baobiao.xianlutingyun.dao.ReportPlanDao;
- import com.sinosoft.lz.system.sms.dao.SmsDao;
- import com.sinosoft.lz.system.userFriend.dao.SendMsgDao;
- import com.sinosoft.lz.system.userFriend.vo.MsgInfo;
- import com.sysmodel.datamodel.xmlmodel.ModelFactory;
- import com.sysmodel.datamodel.xmlmodel.able.SysModel;
- import net.sf.json.JSONArray;
- import net.sf.json.JSONObject;
- @Path("/QueryReportProgrammeService/")
- public class QueryReportProgrammeServiceImpl implements QueryReportProgrammeService,Job {
- private final static Logger log = Logger.getLogger(QueryReportProgrammeServiceImpl.class);
-
-
-
- /**
- * 功能:查询该用户所在单位所有有关的未完成的填报要求
- */
- @POST
- @ProduceMime("application/json")
- @Path("/loadReportPlan/")
- public String loadReportPlan(String params) {
- String deptId = Utils.getParameter("deptId", params) == null ? "" : Utils
- .getParameter("deptId", params);
- String isAlert = Utils.getParameter("is_alert", params) == null ? "" : Utils
- .getParameter("is_alert", params);
- QueryReportProgrammeDao dao = new QueryReportProgrammeDaoImpl();
- try {
- List<Map<String, String>> list = dao.loadReportPlan(deptId,isAlert);
- return JSONArray.fromObject(list).toString();
- } catch (Exception e) {
- e.printStackTrace();
- }
- return null;
- }
-
- /**
- * 功能:查询该用户所在单位所有有关的未完成的填报要求
- */
- @POST
- @ProduceMime("application/json")
- @Path("/getEventByPlanId/")
- public String getEventByPlanId(String params) {
- String planId = Utils.getParameter("planId", params) == null ? "" : Utils
- .getParameter("planId", params);
- QueryReportProgrammeDaoImpl dao = new QueryReportProgrammeDaoImpl();
- String result = "";
- try {
- result = dao.getEventByPlanId(planId);
- } catch (Exception e) {
- e.printStackTrace();
- }
- return result;
- }
-
- /**
- * 查询报告详细
- */
- @SuppressWarnings({ "rawtypes", "unchecked" })
- @POST
- @ProduceMime("application/json")
- @Path("/loadReportInputDetail/")
- public String loadReportInputDetail(String params) {
- String tbzt = Utils.getParameter("tbzt", params) == null ? "" : Utils
- .getParameter("tbzt", params);//填报状态,已填报、未填报
- String planId = Utils.getParameter("planId", params) == null ? "" : Utils
- .getParameter("planId", params);//填报要求id
- String EARLY_WARNING_ID = Utils.getParameter("EARLY_WARNING_ID", params) == null ? "" : Utils
- .getParameter("EARLY_WARNING_ID", params);//预警编号
- String START_TIME = Utils.getParameter("START_TIME", params) == null ? "" : Utils
- .getParameter("START_TIME", params);//开始日期
- String CIRCLE_TIME = Utils.getParameter("CIRCLE_TIME", params) == null ? "" : Utils
- .getParameter("CIRCLE_TIME", params);//截止日期
- String WRITE_DATE_TYPE = Utils.getParameter("WRITE_DATE_TYPE", params) == null ? "" : Utils
- .getParameter("WRITE_DATE_TYPE", params);//填报类型
- String TEMPORARY_TIME = Utils.getParameter("TEMPORARY_TIME", params) == null ? "" : Utils
- .getParameter("TEMPORARY_TIME", params);//临时性
- String WRITE_DEPT_ID = Utils.getParameter("WRITE_DEPT_ID", params) == null ? "" : Utils
- .getParameter("WRITE_DEPT_ID", params);//周期性
- String REPORT_TYPE = Utils.getParameter("REPORT_TYPE", params) == null ? "" : Utils
- .getParameter("REPORT_TYPE", params);//报告类别
- String UPDATEDATE = Utils.getParameter("UPDATEDATE", params) == null ? "" : Utils
- .getParameter("UPDATEDATE", params);//更新时间---发布时间
- String INPUT_UNIT_ID = Utils.getParameter("INPUT_UNIT_ID", params) == null ? "" : Utils
- .getParameter("INPUT_UNIT_ID", params);//填报角色/单位
- String UNIT = Utils.getParameter("UNIT", params) == null ? "" : Utils
- .getParameter("UNIT", params);//本单位
- String ROLES = Utils.getParameter("ROLES", params) == null ? "" : Utils
- .getParameter("ROLES", params);//填报角色
- String selectDate = Utils.getParameter("selectDate", params) == null ? "" : Utils
- .getParameter("selectDate", params);//填报角色
- if(!"tbzt=".equals(tbzt)){
- tbzt = tbzt.split("[=]")[1];
- }else{
- tbzt = "";
- }
- String data = getBaoGaoDetail(WRITE_DATE_TYPE, CIRCLE_TIME, TEMPORARY_TIME, UPDATEDATE, selectDate, REPORT_TYPE, WRITE_DEPT_ID, INPUT_UNIT_ID, ROLES, UNIT, planId, tbzt);
-
- return data;
- }
-
-
- public String getBaoGaoDetail(String WRITE_DATE_TYPE, String CIRCLE_TIME, String TEMPORARY_TIME, String UPDATEDATE,
- String selectDate, String REPORT_TYPE, String WRITE_DEPT_ID, String INPUT_UNIT_ID, String ROLES, String UNIT,
- String planId, String tbzt){
- QueryReportProgrammeDaoImpl dao = new QueryReportProgrammeDaoImpl();
- String data = "";
- log.info(111);
- try {
- log.info(222);
- String progressTime = getProgressTime(WRITE_DATE_TYPE, CIRCLE_TIME, TEMPORARY_TIME,UPDATEDATE,selectDate);//获取计划时间
- log.info("progressTime==="+progressTime);
-
- ArrayList<ReportKV>reportTypes = new ArrayList<ReportKV>();
- reportTypes = dao.loadReportTypeName(REPORT_TYPE);//通过reportType的常量编号查询响应的报告类别名称
- log.info(333);
- String[] currProArr = progressTime.split("[|]");
- log.info("WRITE_DEPT_ID===="+WRITE_DEPT_ID);
- String[] deptIdArr = WRITE_DEPT_ID.split(",");//填报单位id
-
- SimpleDateFormat dateformat = new SimpleDateFormat("yyyy-MM-dd HH:mm");
- ArrayList<ReportProgress> datalist = new ArrayList<ReportProgress>();
- log.info("REPORT_TYPE===="+REPORT_TYPE);
- List<ReportProgress> deptList = dao.loadDeptById(deptIdArr,REPORT_TYPE,INPUT_UNIT_ID,UNIT,ROLES);//通过单位id获取单位名称和id的集合
-
- for (int h = 0; h < deptList.size(); h++) {//循环单位
- String deptId = deptList.get(h).getDeptId();
- String deptName = deptList.get(h).getDeptName();
- for (int j = 0; j < currProArr.length; j++) {//循环周期性或临时性时间
- String times = currProArr[j];
- //计划中要求有填报哪个报告类别就生成几条数据
- for (int i = 0; i < reportTypes.size(); i++) {//循环报告类别
- String proid = reportTypes.get(i).getId();
- List<ReportProgress> proList= dao.loadReportProgramme(deptId,planId,proid,times,REPORT_TYPE,INPUT_UNIT_ID,UNIT,WRITE_DATE_TYPE,selectDate);
- //判断是否填报了
- if(proList.size() < 1){
- //未填报
- ReportProgress pro = new ReportProgress();
- pro = new ReportProgress();
- pro.setDeptId(deptId);
- pro.setDeptName(deptName);
- //pro.setIconClass("icon_list");
- pro.setRESPONSIBLE_NAME_322(reportTypes.get(i).getName());
- pro.setPROGRAMME_TIME_322(times);
- //判断是否超时。
- /*Date curr = new Date();
- if(curr.after(dateformat.parse(pro.getPROGRAMME_TIME_322()))){
- //如果修改时间在计划时间之后则超时
- pro.setIS_OVERTIME_322("是");
- }else{
- pro.setIS_OVERTIME_322("否");
- }*/
- pro.setWRITER_STATE_322("未填报");
- if("".equals(tbzt)){//未筛选填报状态时,两者数据(未填报和已填报)都添加到datalist
- datalist.add(pro);
- }else if(!"".equals(tbzt) && tbzt.contains("1")){//若其中选择了未填报,则添加
- datalist.add(pro);
- }
- }else{
- //填报状态
- ReportProgress pro = proList.get(0);
- pro.setDeptId(deptId);
- pro.setDeptName(deptName);
- pro.setWRITER_STATE_322("已填报");
- pro.setRESPONSIBLE_NAME_322(reportTypes.get(i).getName());
- //设置计划时间
- pro.setPROGRAMME_TIME_322(times);
- /*//判断是否超时。
- if(pro.getUpdateTime()!=null &&
- dateformat.parse(pro.getUpdateTime()).after(dateformat.parse(pro.getPROGRAMME_TIME_322()))){
- //如果修改时间在计划时间之后则超时
- pro.setIS_OVERTIME_322("是");
- }else{
- pro.setIS_OVERTIME_322("否");
- }*/
- if("".equals(tbzt)){//未筛选填报状态时,两者数据(未填报和已填报)都添加到datalist
- datalist.add(pro);
- }else if(!"".equals(tbzt) && tbzt.contains("0")){//若选择了已填报,则添加
- datalist.add(pro);
- }
- }
- }
-
- }
- }
- StringBuffer tem = new StringBuffer();
- tem.append("{\"rows\":");
- tem.append(JSONArray.fromObject(datalist));
- tem.append("}");
- data = tem.toString();
- log.info(data);
- } catch (Exception e) {
- e.printStackTrace();
- }
- return data;
- }
-
- /**
- * 根据单位id,任务id,查询当前时段是否有上报的报告
- */
- @SuppressWarnings({ "rawtypes", "unchecked" })
- @POST
- @ProduceMime("html/text")
- @Path("/loadReportInputByDeptAndTaskId/")
- public String loadReportInputByDeptAndTaskId(String params) {
- String planId = Utils.getParameter("planId", params) == null ? "" : Utils
- .getParameter("planId", params);//填报要求id
- String deptId = Utils.getParameter("deptId", params) == null ? "" : Utils
- .getParameter("deptId", params);//填报要求id
- String reportType = Utils.getParameter("reportType", params) == null ? "" : Utils
- .getParameter("reportType", params);//填报要求id
- String roleId = Utils.getParameter("roleId", params) == null ? "" : Utils
- .getParameter("roleId", params);//填报要求id
- QueryReportProgrammeDaoImpl dao = new QueryReportProgrammeDaoImpl();
- SimpleDateFormat dateformat = new SimpleDateFormat("yyyy-MM-dd");
- List<Map<String, String>> list = dao.loadReportPlanById(planId);//根据计划id查询计划记录
- try {
- Map<String, String> map = list.get(0);
- Date exp = map.get("EXPIRATION_DATE")==null?null:dateformat.parse(map.get("EXPIRATION_DATE"));
- String progressTime = dao.judgeTime(dateformat.parse(map.get("START_TIME")),exp,map.get("WRITE_DATE_TYPE"),map.get("CIRCLE_TIME"),map.get("TEMPORARY_TIME"),map.get("UPDATEDATE"));
- String preTime = getETime(progressTime.split(",")[1],-1);// progressTime.split(",")[0];
- String aftTime = getETime(progressTime.split(",")[1],1);//progressTime.split(",")[2];
- List<String[]> list1 = dao.loadReportPlanByDeptId(preTime,aftTime,planId,deptId,reportType,roleId);
- if(list1.size()>0){
- return "true";
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- return "false";
- }
-
- /**
- * 获取dept_level
- */
- public String getDeptLevel(String corpId) {
- String sql = "select dept_level from SYS_DEPARTMENT where dept_id='"+corpId+"' ";
- List<Map<String, String>> list = null;
- String dept_level = "";
- try {
- list = new ORGTemplate().query(sql);
- if(list.size()==1){
- dept_level = list.get(0).get("DEPT_LEVEL");
- }
- } catch (SQLException e) {
-
- e.printStackTrace();
- }
- return dept_level;
- }
-
- /**
- * 查询工作动态对应角色表的角色信息
- */
- @POST
- @ProduceMime("application/json")
- @Path("/loadJBRole/")
- public String loadJBRole(String params) {
- String corpId = Utils.getParameter("corpId", params) == null ? "" : Utils
- .getParameter("corpId", params);//填报要求id
- String dept_level = getDeptLevel(corpId);
- String condition = " ";
- if("2".equals(dept_level)){
- condition += " where gongsi=1 ";
- }else if("3".equals(dept_level)){
- condition += " where geju=1 ";
- }
- String sql = "select ROLE_ID,ROLE_NAME from ECM_EM_GZJB_ROLE"+condition;
- try {
- List<Map<String, String>> list = new ORGTemplate().query(sql);
- return JSONArray.fromObject(list).toString();
- } catch (SQLException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- return null;
- }
-
- /**
- * 查询专业管理角色id-name
- * 加了应急办
- *
- */
- @POST
- @ProduceMime("application/json")
- @Path("/loadJBRole1/")
- public String loadJBRole1(String params) {
- String corpId = Utils.getParameter("corpId", params) == null ? "" : Utils
- .getParameter("corpId", params);//填报要求id
- String dept_level = getDeptLevel(corpId);
- String condition = " ";
- if("2".equals(dept_level)){
- condition += " where gongsi=1 ";
- }else if("3".equals(dept_level)){
- condition += " where geju=1 ";
- }
- String sql = "select ROLE_ID,ROLE_NAME from ECM_EM_GZJB_ROLE"+condition;
- try {
- List<Map<String, String>> list = new ORGTemplate().query(sql);
- Map<String, String> map = new HashMap<String, String>();
- for (int i = 0; i < list.size(); i++) {
- Map<String, String> map1 = list.get(i);
- map.put(map1.get("ROLE_ID"),map1.get("ROLE_NAME"));
- }
- return JSONArray.fromObject(map).toString();
- } catch (SQLException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- return null;
- }
-
-
- /**
- * 通过通知单编号和单位id查询各部门报表填报情况
- */
- @POST
- @ProduceMime("application/json")
- @Path("/loadBaoBiaoDetail/")
- public String loadBaoBiaoDetail(String params) {
- String earlyWarningId = Utils.getParameter("earlyWarningId", params) == null ? "" : Utils
- .getParameter("earlyWarningId", params);//预警编号
- String comp_id = Utils.getParameter("comp_id", params) == null ? "" : Utils
- .getParameter("comp_id", params);//单位id
- String parent_id = Utils.getParameter("parent_id", params) == null ? "" : Utils
- .getParameter("parent_id", params);//父单位id
- String sql = "select b.FD_OBJECTID , b.FILL_IN_SCHEDULE, b.ROUND_TIME , b.TEMPORARY_TIME , b.REPORT_DEPT,b.START_TIME from "
- + "ecm_em_publish_alert_notice a, report_schedule b where a.is_del ='0' and a.RELEASE_UNIT =? "
- + " and a.IS_SEND ='5' and a.CHECK_STATUS <>'43' and a.plan_type_id = ( "
- + "select plan_type_id from ecm_em_publish_alert_notice where is_del ='0' and (RELEASE_UNIT =? or RELEASE_UNIT =? ) and "
- + "EARLY_WARNING_ID=? and IS_SEND ='5' and CHECK_STATUS <>'43' ) and b.role_id ='R002105430205' and "
- + "b.COMP_ID =? and b.is_del ='0' and b.send_stat ='1' order by b.updatedate desc ";
- try {
- List<Map<String, String>> list = new ORGTemplate().query(sql,comp_id,parent_id,comp_id,earlyWarningId,comp_id);
- //先从报表填报要求表查询出相关数据
- String FILL_IN_SCHEDULE = "";
- String ROUND_TIME = "";
- String TEMPORARY_TIME = "";
- String REPORT_DEPT = "";
- String plan_id = "";
- String result = "";
- String START_TIME = "";
- if(list!=null && list.size()>0){
- Map<String, String> map = list.get(0);
- FILL_IN_SCHEDULE = map.get("FILL_IN_SCHEDULE");
- ROUND_TIME = map.get("ROUND_TIME");
- TEMPORARY_TIME = map.get("TEMPORARY_TIME");
- START_TIME = map.get("START_TIME");
- REPORT_DEPT = map.get("REPORT_DEPT");
- plan_id = map.get("FD_OBJECTID");
- String params1 = "CIRCLE_TIME="+ROUND_TIME+"&WRITE_DATE_TYPE="+FILL_IN_SCHEDULE+"&TEMPORARY_TIME="+TEMPORARY_TIME+"&WRITE_DEPT_ID="+REPORT_DEPT+"&role_id=R002105430205&planId="+plan_id+"&tbzt=tbzt=&is_zhuanbao=0&corp_id="+comp_id+"&START_TIME="+START_TIME;
- com.sinosoft.em.baobiao.xianlutingyun.service.QueryReportProgrammeServiceImpl quer = new com.sinosoft.em.baobiao.xianlutingyun.service.QueryReportProgrammeServiceImpl();
- result = quer.loadReportInputDetail(params1);
- }
-
-
- return result;
- } catch (SQLException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- return null;
- }
-
-
- /**
- * 查询部门下报告信息
- */
- /*@POST
- @ProduceMime("application/json")
- @Path("/queryReportPra/")
- public String queryReportPro() throws UnsupportedEncodingException {
-
- QueryReportProgrammeDao dao = new QueryReportProgrammeDaoImpl();
- HttpServletRequest request = ((ServletRequestAttributes)RequestContextHolder.getRequestAttributes()).getRequest();
- String params = request.getParameter("params");
- //参数顺序:部门ID,预警编号,计划时间,报告类别
- //打桩
- byte b[] =params.getBytes("ISO8859-1");
- params=new String(b);
- log.info("queryReportPra__params:"+params);
- String[] paramsArr = params.split(",");
- //填报部门id
- String deptId = paramsArr[0];
- //计划id
- String planId = paramsArr[1];
- //上一个时间
- //String preproTime = paramsArr[2];
- //当前计划时间
- String currprogressTime = paramsArr[2];
- //后一个时间
- //String aftProTime = paramsArr[4];
- //报告类别
- String reportType = "";
- String tbzt = "";
- if(paramsArr.length>0 && paramsArr.length==5){
- reportType = paramsArr[3];
- tbzt = paramsArr[4];
- }else if(paramsArr.length>0 && paramsArr.length==6){
- reportType = ""+paramsArr[3]+","+paramsArr[4];
- tbzt = paramsArr[5];
- }
- if(!"tbzt=".equals(tbzt)){
- tbzt = tbzt.split("[=]")[1];
- }else{
- tbzt = "";
- }
- String[] currProArr = currprogressTime.split("[|]");
- ArrayList<String> timeList = new ArrayList<String>();
- for (int i = 0; i < currProArr.length; i++) {
- String preproTime = getETime(currProArr[i],-1);
- String aftProTime = getETime(currProArr[i],1);
- timeList.add(preproTime+","+currProArr[i]+","+aftProTime);
- }
- try {
-
-
- ArrayList<ReportKV>reportTypes = new ArrayList<ReportKV>();
- //通过reportType的常量编号查询响应的报告类别名称
- reportTypes = dao.loadReportTypeName(reportType);
- SimpleDateFormat dateformat = new SimpleDateFormat("yyyy-MM-dd HH:mm");
- SimpleDateFormat dateformat1 = new SimpleDateFormat("yyyy-MM-dd");
- ArrayList<ReportProgress> datalist = new ArrayList<ReportProgress>();
- for (int j = 0; j < timeList.size(); j++) {
- String[] times = timeList.get(j).split(",");
- //计划中要求有填报哪个报告类别就生成几条数据
- for (int i = 0; i < reportTypes.size(); i++) {
- String proid = reportTypes.get(i).getId();
- //List<ReportProgress> proList= dao.loadReportProgramme(deptId,planId,proid,preproTime,currprogressTime,aftProTime);
- List<ReportProgress> proList= dao.loadReportProgramme(deptId,planId,proid,times[0],times[1],times[2], reportType,INPUT_UNIT_ID);
- //判断是否填报了
- if(proList.size() < 1){
- //未填报
- ReportProgress pro = new ReportProgress();
- pro = new ReportProgress();
- //pro.setIconClass("icon_list");
- pro.setRESPONSIBLE_NAME_322(reportTypes.get(i).getName());
- pro.setPROGRAMME_TIME_322(times[1]);
- //判断是否超时。
- Date curr = new Date();
- if(curr.after(dateformat.parse(pro.getPROGRAMME_TIME_322()))){
- //如果修改时间在计划时间之后则超时
- pro.setIS_OVERTIME_322("是");
- }else{
- pro.setIS_OVERTIME_322("否");
- }
- pro.setWRITER_STATE_322("未填报");
- if("".equals(tbzt)){
- datalist.add(pro);
- }else if(!"".equals(tbzt) && tbzt.contains("1")){
- datalist.add(pro);
- }
- }else{
- //填报状态
- ReportProgress pro = proList.get(0);
- pro.setWRITER_STATE_322("已填报");
- pro.setRESPONSIBLE_NAME_322(reportTypes.get(i).getName());
- //设置计划时间
- pro.setPROGRAMME_TIME_322(times[1]);
- //判断是否超时。
- if(pro.getUpdateTime()!=null &&
- dateformat.parse(pro.getUpdateTime()).after(dateformat.parse(pro.getPROGRAMME_TIME_322()))){
- //如果修改时间在计划时间之后则超时
- pro.setIS_OVERTIME_322("是");
- }else{
- pro.setIS_OVERTIME_322("否");
- }
- if("".equals(tbzt)){
- datalist.add(pro);
- }else if(!"".equals(tbzt) && tbzt.contains("0")){
- datalist.add(pro);
- }
- }
- }
-
- }
-
-
-
-
-
- StringBuffer tem = new StringBuffer();
- tem.append("{\"rows\":");
- tem.append(JSONArray.fromObject(datalist));
- tem.append("}");
- String data = tem.toString();
- log.info(data);
- return data;
- } catch (Exception e) {
- e.printStackTrace();
- }
- return null;
-
- }*/
-
- /**
- * 查询计划下部门信息
- */
- @SuppressWarnings({ "rawtypes", "unchecked" })
- @POST
- @ProduceMime("application/json")
- @Path("/queryReportDept/")
- public String queryReportDept(String params) {
- String planId = Utils.getParameter("planId", params) == null ? "" : Utils
- .getParameter("planId", params);
- String tbzt = Utils.getParameter("tbzt", params) == null ? "" : Utils
- .getParameter("tbzt", params);
- if("".equals(planId)){
- return null;
- }
- planId = planId.substring(0, planId.length()-1);
- Log.info("planId:"+planId);
- QueryReportProgrammeDao dao = new QueryReportProgrammeDaoImpl();
- try {
- List<reportDept> list = dao.loadReportDept(planId,tbzt);
- Map map = new HashMap();
- map.put("rows", list);
- JSONObject jsonData = JSONObject.fromObject(map);
- String tem = jsonData.toString();
- log.info("deptList:"+tem);
- return tem;
- } catch (Exception e) {
- e.printStackTrace();
- }
- return null;
- }
- /**
- * 功能:查询该用户所在单位所有未完成的填报计划
- */
- /*@POST
- @ProduceMime("application/json")
- @Path("/queryReportPlan/")
- public String queryReportPlan(String params) {
- String deptId = Utils.getParameter("deptId", params) == null ? "" : Utils
- .getParameter("deptId", params);
- String isAlert = Utils.getParameter("is_alert", params) == null ? "" : Utils
- .getParameter("is_alert", params);
- QueryReportProgrammeDao dao = new QueryReportProgrammeDaoImpl();
- try {
- List<reportPlan> list = dao.loadReportPlan(deptId,isAlert);
- return JSONArray.fromObject(list).toString();
- } catch (Exception e) {
- e.printStackTrace();
- }
- return null;
- }*/
-
- /**
- * 功能:计划发布后,查询该计划的所有填报部门应急办成员,并向这些成员发送短信提醒
- */
- @POST
- @ProduceMime("application/json")
- @Path("/reportPlanSendMsg/")
- public String sendMsg(String params) {
- /*String fd_id = Utils.getParameter("fd_id", params) == null ? "" : Utils
- .getParameter("fd_id", params);
- String userId = Utils.getParameter("userId", params) == null ? "" : Utils
- .getParameter("userId", params);*/
- String comp_id = Utils.getParameter("comp_id", params) == null ? "" : Utils
- .getParameter("comp_id", params);
- String reportType = Utils.getParameter("reportType", params) == null ? "" : Utils
- .getParameter("reportType", params);
- String input_dept = Utils.getParameter("input_dept", params) == null ? "" : Utils
- .getParameter("input_dept", params);
- comp_id = toFormat(comp_id);
- QueryReportProgrammeDao dao = new QueryReportProgrammeDaoImpl();
- String result = "";
- try {
- result = dao.send(/* fd_id, userId,*/ comp_id,reportType,input_dept);
-
- } catch (Exception e) {
- e.printStackTrace();
- }
- return result;
- }
- private String toFormat(String comp_id) {
- String[] arr = comp_id.split(",");
- StringBuffer sb = new StringBuffer();
- for (int i = 0; i < arr.length; i++) {
- sb.append("'"+arr[i]+"'");
- if(i!=arr.length-1){
- sb.append("");
- }
- }
- return sb.toString();
- }
-
-
- public void getBGList(){
- SysModel sysmodel = ModelFactory.getSysmodel();
- SysPersistence persistence = PersistenceFactory.getInstance(sysmodel);
- List<String>List=new ArrayList<String>();
- QueryReportProgrammeDaoImpl rpd=new QueryReportProgrammeDaoImpl();
- try {
- String sql = "select FD_OBJECTID ,PROGRAMME_NAME,START_TIME , EXPIRATION_DATE,REPORT_TYPE,"
- + "WRITE_DATE_TYPE,CIRCLE_TIME,TEMPORARY_TIME,IS_ALERT,WRITER,WRITE_DEPT_ID,UPDATEDATE from "
- + "ECM_EM_ALERT_REPORT_PLAN where IS_DEL=0 and IS_RELEASE=1 ";
- List<String[]> tempList;
- tempList = persistence.getSearchResult(99, sql.toString());
-
- log.info("tempList.size===="+tempList.size());
- for(int i=0;i<tempList.size();i++){
- String[] arr = tempList.get(i);
- String plan_id = arr[0];
- String plan_name = arr[1];
- String starttime = arr[2];
- String endtime = arr[3];
- String report_type = arr[4];
- String fill_in_schedule = arr[5];
- String round_time = arr[6];
- String temporary_time = arr[7];
- String is_alert = arr[8];
- String real_name = arr[9];
- String dept_ids = arr[10];
- String updatedate = arr[11];
- SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
- Date start_time=formatter.parse(starttime);
- Date end_time=formatter.parse(("".equals(endtime)||endtime==null)?formatter.format(new Date()):endtime);
- List<String>deptList=new ArrayList<String>();
- List<String[]>tabList=new ArrayList<String[]>();
- String[] deptsArr = dept_ids.split(",");
- for (String str : deptsArr) {
- deptList.add(str);
- }
- for (int j = 0; j < deptList.size(); j++) {
- if("周期性".equals(fill_in_schedule)){
- if(report_type.length()>1){
- String[] types = report_type.split(",");
- for (int k = 0; k < types.length; k++) {
- Date data=new Date();
- SimpleDateFormat sdf=new SimpleDateFormat("HH:mm");
- String curDate=sdf.format(data);
- if("".equals(round_time) || "NULL".equals(round_time)){
- continue;
- }
- int curTime=Integer.parseInt(curDate.split(":")[0])*60+Integer.parseInt(curDate.split(":")[1]);
- log.info("round_time==="+round_time);
- round_time = round_time.replace(",,", ",");
- int kkk = round_time.lastIndexOf(",");
- int ddd = round_time.length()-1;
- if(round_time.lastIndexOf(",")==round_time.length()-1){
- round_time = round_time.substring(0,round_time.length()-1);
- }
- String[] timeArr=round_time.split(";");
- for(int l=0;l<timeArr.length;l++){
- int time=Integer.parseInt(timeArr[l].split(":")[0])*60+Integer.parseInt(timeArr[l].split(":")[1]);
- String progressTime = rpd.judgeTime(start_time,end_time, fill_in_schedule, round_time, temporary_time,updatedate);
- String preproTime=progressTime.split(";")[0];
- SimpleDateFormat sdf1=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- String currprogressTimeE=sdf1.format(new Date());
- SmsDao sd=new SmsDao();
- SendMsgDao smd = new SendMsgDao();
- List<String> telList = new ArrayList<String>();
- List<String> idList = new ArrayList<String>();
- List<String[]> list= getMsg(report_type, deptList.get(j));
- if(list==null||list.size()==0){}else{
- for(int r=0;r<list.size();r++){
- telList.add(list.get(r)[0]);
- idList.add(list.get(r)[1]);
- }
- }
- MsgInfo msg = new MsgInfo();
- msg.setRecivedUser(idList);
- msg.setSendUser("zkradmin");
- if(curTime-time>0&&curTime-time<=60){
- if(checkBG(deptList.get(j), preproTime, currprogressTimeE, types[k], plan_id)){
- msg.setSendMsg(plan_name+"的"+getreportTypeById(types[k])+"报告填报时间已超时,请尽快填报");
-
- //sd.saveSms("", telList, time, "", "");
- //saveSms(String title,List<String> recList,String time,String content,String sendId)
- sd.saveSms("", telList, sdf1.format(new Date()), plan_name+"的"+getreportTypeById(types[k])+"报告填报时间已超时,请尽快填报", "zkradmin");
- smd.saveMsg(msg);
- log.info("超时一个小时催报--"+plan_name+"--"+deptList.get(j)+"--"+getreportTypeById(types[k]));
- }
- }else if(curTime-time<0&&curTime-time>=-60){
- if(checkBG(deptList.get(j), preproTime, currprogressTimeE, report_type,plan_id)){
- sd.saveSms("", telList, sdf1.format(new Date()), plan_name+"的"+getreportTypeById(types[k])+"报告离填报时间还有一个小时,请尽快填报", "zkradmin");
- msg.setSendMsg(plan_name+"的"+getreportTypeById(types[k])+"报告离填报时间还有一个小时,请尽快填报");
- smd.saveMsg(msg);
- log.info("超时一个小时催报--"+plan_name+deptList.get(j)+"--"+"--"+getreportTypeById(types[k]));
- }
- }
- }
- }
- }else if(report_type.length()==1){
- Date data=new Date();
- SimpleDateFormat sdf=new SimpleDateFormat("HH:mm");
- String curDate=sdf.format(data);
- int curTime=Integer.parseInt(curDate.split(":")[0])*60+Integer.parseInt(curDate.split(":")[1]);
- String[] timeArr=round_time.split(";");
- for(int l=0;l<timeArr.length;l++){
- int time=Integer.parseInt(timeArr[l].split(":")[0])*60+Integer.parseInt(timeArr[l].split(":")[1]);
- String progressTime = rpd.judgeTime(start_time,end_time, fill_in_schedule, round_time, temporary_time,updatedate);
- String preproTime=progressTime.split(",")[0];
- SimpleDateFormat sdf1=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- String currprogressTimeE=sdf1.format(new Date());
- SmsDao sd=new SmsDao();
- SendMsgDao smd = new SendMsgDao();
- List<String> telList = new ArrayList<String>();
- List<String> idList = new ArrayList<String>();
- List<String[]> list= getMsg(report_type, deptList.get(j));
- if(list==null||list.size()==0){}else{
-
- for(int r=0;r<list.size();r++){
- telList.add(list.get(r)[0]);
- idList.add(list.get(r)[1]);
- }
- }
- MsgInfo msg = new MsgInfo();
- msg.setRecivedUser(idList);
- msg.setSendUser("zkradmin");
- if(curTime-time>0&&curTime-time<=60){
- if(checkBG(deptList.get(j), preproTime, currprogressTimeE, report_type, plan_id)){
- msg.setSendMsg(plan_name+"的"+getreportTypeById(report_type)+"报告填报时间已超时,请尽快填报");
-
- //sd.saveSms("", telList, time, "", "");
- //saveSms(String title,List<String> recList,String time,String content,String sendId)
- sd.saveSms("", telList, sdf1.format(new Date()), plan_name+"的"+getreportTypeById(report_type)+"报告填报时间已超时,请尽快填报", "zkradmin");
- smd.saveMsg(msg);
- log.info("超时一个小时催报--"+plan_name+"--"+deptList.get(j)+"--"+getreportTypeById(report_type));
- }
- }else if(curTime-time<0&&curTime-time>=-60){
- if(checkBG(deptList.get(j), preproTime, currprogressTimeE, report_type,plan_id)){
- sd.saveSms("", telList, sdf1.format(new Date()), plan_name+"的"+getreportTypeById(report_type)+"报告离填报时间还有一个小时,请尽快填报", "zkradmin");
- msg.setSendMsg(plan_name+"的"+getreportTypeById(report_type)+"报告离填报时间还有一个小时,请尽快填报");
- smd.saveMsg(msg);
- log.info("超时一个小时催报--"+plan_name+deptList.get(j)+"--"+"--"+getreportTypeById(report_type));
- }
- }
- }
- }
- }else{
- if(report_type.length()>1){
- String[] types = report_type.split(",");
- for (int k = 0; k < types.length; k++) {
- Date data=new Date();
- SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- SimpleDateFormat sdf2=new SimpleDateFormat("yyyy-MM-dd");
- String curDate=sdf.format(data);
- String curDate1=sdf2.format(data);
- int curTime=Integer.parseInt(curDate.split(" ")[1].split(":")[0])*60+Integer.parseInt(curDate.split(" ")[1].split(":")[1]);
- String[] timeArr=temporary_time.split(";");
- for(int l=0;l<timeArr.length;l++){
- if(curDate1.equals(timeArr[l].split(" ")[0])){
- String trueTime=timeArr[l].split(" ")[1];
- int time=Integer.parseInt(trueTime.split(":")[0])*60+Integer.parseInt(trueTime.split(":")[1]);
- String progressTime = rpd.judgeTime(start_time,end_time, fill_in_schedule, round_time, temporary_time,updatedate);
- String preproTime=progressTime.split(",")[0];
- SimpleDateFormat sdf1=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- String currprogressTimeE=sdf1.format(new Date());
- SmsDao sd=new SmsDao();
- SendMsgDao smd = new SendMsgDao();
- List<String> telList = new ArrayList<String>();
- List<String> idList = new ArrayList<String>();
- List<String[]> list= getMsg(report_type, deptList.get(j));
- if(list==null||list.size()==0){}else{
-
- for(int r=0;r<list.size();r++){
- telList.add(list.get(r)[0]);
- idList.add(list.get(r)[1]);
- }
- }
- MsgInfo msg = new MsgInfo();
- msg.setRecivedUser(idList);
- msg.setSendUser("zkradmin");
- if(curTime-time>0&&curTime-time<60){
- if(checkBG(deptList.get(j), preproTime, currprogressTimeE, report_type,plan_id)){
- msg.setSendMsg(plan_name+"的"+getreportTypeById(types[k])+"报告填报时间已超时,请尽快填报");
-
- sd.saveSms("", telList, sdf1.format(new Date()), plan_name+"的"+getreportTypeById(types[k])+"报告填报时间已超时,请尽快填报", "zkradmin");
- smd.saveMsg(msg);
- log.info("提前一个小时催报--"+plan_name+"--"+getreportTypeById(types[k]));
- }
- }else if(curTime-time<0&&curTime-time>-60){
- if(checkBG(deptList.get(j), preproTime, currprogressTimeE, report_type,plan_id)){
- sd.saveSms("", telList, sdf1.format(new Date()), plan_name+"的"+getreportTypeById(types[k])+"报告离填报时间还有一个小时,请尽快填报", "zkradmin");
- msg.setSendMsg(plan_name+"的"+getreportTypeById(types[k])+"报告离填报时间超时还有一个小时,请尽快填报");
- smd.saveMsg(msg);
- log.info("超时一个小时催报--"+plan_name+"--"+getreportTypeById(types[k]));
- }
- }
-
- }
-
- }
- }
- }else if(report_type.length()==1){
-
- }
- }
-
- }
- SmsDao sd=new SmsDao();
- List<String>l=new ArrayList<String>();
- //l.add(mobile);
- //String content=name+",您好!你指定的应急演练计划:"+drill_name+"将于"+plan_time+"到达计划完成时间,特此提醒!";
- //sd.saveSms("应急演练计划执行提醒", l, new Date()+"", content, "zkradmin");
-
- }
- }catch(Exception e){
- this.log.error(e.getMessage(), e);
- }
- }
-
- private String getreportTypeById(String string) {
- String result="";
- SysModel sysmodel = ModelFactory.getSysmodel();
- SysPersistence persistence = PersistenceFactory.getInstance(sysmodel);
- String sql="select FD_DESCRIPTION from BM_MAPVALUECANST where fd_type='BM_AlertRespReportInputState' and fd_code='"+string+"'";
- try {
- List<String[]>tempList= persistence.getSearchResult(99, sql.toString());
- if(tempList==null||tempList.size()==0){
- }else{
- result=tempList.get(0)[0];
- log.info("report_type===="+result);
- }
- } catch (PersistenceException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- return result;
- }
- return result;
- }
- public List<String[]> getMsg(String report_type,String comp_id){
- List<String[]>tempList=new ArrayList<String[]>();
- SysModel sysmodel = ModelFactory.getSysmodel();
- // List<String[]>tempList=new ArrayList<String[]>();
- SysPersistence persistence = PersistenceFactory.getInstance(sysmodel);
- String sql = "select a.mobile ,a.user_id,a.real_name from sys_user_info a , sys_dept_user b where "
- + " a.user_id = b.user_id and a.user_id in (select user_id from sys_user_role_rel where role_id in (select role_id from bm_mapforreport where"
- + " report_type='"+report_type+"')) and (b.dept_id ='"+comp_id+"' or b.dept_id in(select dept_id from sys_department where CORP_ID='"+comp_id+"' and dept_type='DEPT'))";
- log.info(sql+"===========getMsgsql");
- // List<String[]> telList = new ArrayList<String[]>();
- try {
- tempList= persistence.getSearchResult(99, sql.toString());
- if(tempList==null||tempList.size()==0){
- }else{
- return tempList;
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- return tempList;
- }
-
- /**
- * 解析字符串,返回相差n小时的时间
- * n==-1则是前一个小时,若为正数,则为后n小时
- * 解析16:30字符串,返回15:30字符串
- * @param time
- * @return
- */
- private String getETime(String time,int n){
- String time1 = time;
- time = time.split(" ")[1];
- String hour = time.substring(0,time.indexOf(":"));
- String minit = time.substring(time.indexOf(":"),time.length());
- Integer prehour = null;
- if("23".equals(hour) && n==1){
- prehour = 23;
- minit = ":59:59";
- }else{
- prehour = Integer.parseInt(hour)+n;
- }
- if("00".equals(hour) && n==-1){
- prehour = 0;
- minit = ":00:00";
- }
- String prehourstr = prehour<10 && prehour>=0?"0"+prehour:""+prehour;
- return time1.split(" ")[0] +" "+prehourstr+""+minit;
- }
-
- private boolean checkBG(String company_id, String preproTime,
- String currprogressTimeE, String report_type, String plan_id) {
- boolean flag=false;
- String sql = "select FD_OBJECTID from ECM_EM_ALERT_REPORT_INPUT where PLAN_ID='"+plan_id+"' and "
- + "INPUT_UNIT='"+company_id+"' and report_type='"+report_type+"' and IS_DEL=0 and OPR_STATE=1 AND UPDATEDATE BETWEEN '"+preproTime+"' AND '"+currprogressTimeE+"' ";
- log.info("checkBG_sql:"+sql);
- try {
- List<Map<String, String>> list1 = PersistenceFactory.getInstance(ModelFactory.getSysmodel())
- .getSearchResultToMap(99, sql);
- if(list1==null||list1.size()==0){
- flag=true;
- }else{
- log.info("");
- flag= false;
- }
- } catch (PersistenceException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- return flag;
- }
- @Override
- public void execute(JobExecutionContext arg0) throws JobExecutionException {
- getBGList();
- }
-
- /***
- * 获取计划时间
- * @param writeDataType
- * @param circleTime
- * @param temporaryTime
- * @param updatedate
- * @param selectDate
- * @return
- * @throws ParseException
- */
- private String getProgressTime(String writeDataType, String circleTime, String temporaryTime, String updatedate, String selectDate) throws ParseException {
- //计划时间
- String prograssTime = "";
- if("周期性".equals(writeDataType)){
- String[] cirTimeArr1 = circleTime.split(";");
- for (int i = 0; i < cirTimeArr1.length; i++) {
- if(!"".equals(cirTimeArr1[i].trim())){
- String timea = cirTimeArr1[i].trim();
- prograssTime += timea;
- if(i<cirTimeArr1.length-1){
- prograssTime += "|";
- }
- //}
- }
- }
- }else if("临时性".equals(writeDataType)){
- String[] temArr = temporaryTime.split(";");
- for (int i = 0; i < temArr.length; i++) {
- prograssTime += temArr[i];
- if(i<temArr.length-1){
- prograssTime += "|";
- }
- }
- }
-
- return prograssTime;
- }
- /**
- * 查询计划下部门信息
- */
- @SuppressWarnings({ "rawtypes", "unchecked" })
- @POST
- @ProduceMime("application/json")
- @Path("/queryReportSubByReportId/")
- public String queryReportSubByReportId(String params) {
- String reportId = Utils.getParameter("reportId", params) == null ? "" : Utils
- .getParameter("reportId", params);
- String sql = "select FD_OBJECTID FD_OBJECTID323,FD_OBJECTID FD_OBJECTID_323,TQZW TQZW_323,YJDT YJDT_323,REPORT_ID REPORT_ID_323 from ECM_EM_ALERT_REPORT_INPUT_SUB1 where report_id=? ";
- try {
- List<Map<String, String>> list = new ORGTemplate().query(sql, reportId);
- String tem = JSONArray.fromObject(list).toString();
- log.info("deptList:"+tem);
- return tem;
- } catch (Exception e) {
- e.printStackTrace();
- }
- return null;
- }
- }
|