package cn.com.usky.iot.xjeventprocessing.service; import java.text.SimpleDateFormat; import java.util.Date; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; import cn.com.usky.iot.entity.YtiotXjEventProcessing; import cn.com.usky.iot.xjeventprocessing.dao.YtiotXjEventProcessingDao; import cn.com.usky.iot.entity.YtiotXjToExamine1; import cn.com.usky.iot.xjtoexamine1.dao.YtiotXjToExamine1Dao; import cn.com.usky.iot.entity.YtiotXjSpotOperationRecord; import cn.com.usky.iot.xjspotoperationrecord.dao.YtiotXjSpotOperationRecordDao; import cn.com.usky.iot.entity.YtiotXjInspectors; import cn.com.usky.iot.xjinspectors.dao.YtiotXjInspectorsDao; import cn.com.usky.iot.entity.YtiotXjOperationRecordPhotos; import cn.com.usky.iot.xjoperationrecordphotos.dao.YtiotXjOperationRecordPhotosDao; import cn.com.usky.iot.entity.YtiotXjInspectionPoints; import cn.com.usky.iot.xjinspectionpoints.dao.YtiotXjInspectionPointsDao; //import cn.com.usky.iot.entity.YtiotVUsercompany; //import cn.com.usky.iot.entity.YtiotVUsercompanyId; //import cn.com.usky.iot.admin.dao.YtiotVUserCompanyDao; import cn.com.usky.utils.DaoResult; import net.sf.json.JSONArray; import net.sf.json.JSONObject; public class YtiotXjEventProcessingServicesImpl implements YtiotXjEventProcessingService { private YtiotXjEventProcessingDao ytiotXjEventProcessingDao; private YtiotXjToExamine1Dao ytiotXjToExamine1Dao; private YtiotXjSpotOperationRecordDao ytiotXjSpotOperationRecordDao; private YtiotXjOperationRecordPhotosDao ytiotXjOperationRecordPhotosDao; private YtiotXjInspectorsDao ytiotXjInspectorsDao; private YtiotXjInspectionPointsDao ytiotXjInspectionPointsDao; // private YtiotVUserCompanyDao ytiotVUserCompanyDao; public YtiotXjEventProcessingDao getYtiotXjEventProcessingDao() { return ytiotXjEventProcessingDao; } public void setYtiotXjEventProcessingDao(YtiotXjEventProcessingDao ytiotXjEventProcessingDao) { this.ytiotXjEventProcessingDao = ytiotXjEventProcessingDao; } public YtiotXjToExamine1Dao getYtiotXjToExamine1Dao() { return ytiotXjToExamine1Dao; } public void setYtiotXjToExamine1Dao(YtiotXjToExamine1Dao ytiotXjToExamine1Dao) { this.ytiotXjToExamine1Dao = ytiotXjToExamine1Dao; } public YtiotXjSpotOperationRecordDao getYtiotXjSpotOperationRecordDao() { return ytiotXjSpotOperationRecordDao; } public void setYtiotXjSpotOperationRecordDao(YtiotXjSpotOperationRecordDao ytiotXjSpotOperationRecordDao) { this.ytiotXjSpotOperationRecordDao = ytiotXjSpotOperationRecordDao; } public YtiotXjOperationRecordPhotosDao getYtiotXjOperationRecordPhotosDao() { return ytiotXjOperationRecordPhotosDao; } public void setYtiotXjOperationRecordPhotosDao(YtiotXjOperationRecordPhotosDao ytiotXjOperationRecordPhotosDao) { this.ytiotXjOperationRecordPhotosDao = ytiotXjOperationRecordPhotosDao; } public YtiotXjInspectorsDao getYtiotXjInspectorsDao() { return ytiotXjInspectorsDao; } public void setYtiotXjInspectorsDao(YtiotXjInspectorsDao ytiotXjInspectorsDao) { this.ytiotXjInspectorsDao = ytiotXjInspectorsDao; } public YtiotXjInspectionPointsDao getYtiotXjInspectionPointsDao() { return ytiotXjInspectionPointsDao; } public void setYtiotXjInspectionPointsDao(YtiotXjInspectionPointsDao ytiotXjInspectionPointsDao) { this.ytiotXjInspectionPointsDao = ytiotXjInspectionPointsDao; } // public YtiotVUserCompanyDao getYtiotVUserCompanyDao() { // return ytiotVUserCompanyDao; // } // // public void setYtiotVUserCompanyDao(YtiotVUserCompanyDao ytiotVUserCompanyDao) { // this.ytiotVUserCompanyDao = ytiotVUserCompanyDao; // } public boolean chk_string_param(String param) { if(param==null) return true; if(param.indexOf("=")>=0) return false; if(param.indexOf("\'")>=0) return false; if(param.indexOf("\"")>=0) return false; return true; } public String chkhw(String hqlwhere){ if(hqlwhere==null) return " where "; else return hqlwhere+" and "; } public String fieldname(String field){ if(field.equals("cl_type")) return "clType"; if(field.equals("cl_time")) return "clTime"; if(field.equals("user_name")) return "userName"; if(field.equals("zn")) return "zn"; if(field.equals("id")) return "id"; if(field.equals("dwjl_id")) return "dwjlId"; if(field.equals("sj_type")) return "sjType"; if(field.equals("y_complete_time")) return "YCompleteTime"; if(field.equals("p_remarks")) return "pRemarks"; if(field.equals("user_name`")) return "userName`"; if(field.equals("data1")) return "data1"; if(field.equals("data1")) return "data1"; if(field.equals("data2")) return "data2"; if(field.equals("data3")) return "data3"; if(field.equals("team_id")) return "teamId"; if(field.equals("people_id")) return "peopleId"; if(field.equals("person_liable_id")) return "personLiableId"; if(field.equals("person_liable")) return "personLiable"; if(field.equals("event_processing_id")) return "eventProcessingId"; return null; } @Override public String updateEventProcessingzp(String queryJson) throws Exception { // TODO Auto-generated method stub SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String id = null; String sj_type = null; String person_liable = null; String y_complete_time = null; String zp_remarks = null; String V_LOGINNAME = null; JSONObject q_json = null; JSONArray jSONArray = new JSONArray(); JSONObject json = new JSONObject(); json.put("action", "updateEventProcessingzp"); if(queryJson!=null) { q_json = JSONObject.fromObject(queryJson); id = q_json.has("id")?q_json.getString("id"):null; sj_type = q_json.has("sj_type")?q_json.getString("sj_type"):null; person_liable = q_json.has("person_liable")?q_json.getString("person_liable"):null; y_complete_time = q_json.has("y_complete_time")?q_json.getString("y_complete_time"):null; zp_remarks = q_json.has("zp_remarks")?q_json.getString("zp_remarks"):null; V_LOGINNAME = q_json.has("V_LOGINNAME")?q_json.getString("V_LOGINNAME"):null; // System.out.println(q_json); json.put("query", queryJson); } if(chk_string_param(id)&&chk_string_param(sj_type)&&chk_string_param(person_liable) &&chk_string_param(y_complete_time)&&chk_string_param(zp_remarks)&&chk_string_param(V_LOGINNAME)) { if(id!=null) { List list = ytiotXjEventProcessingDao.query(" where u."+fieldname("id")+" ='"+id+"' ", null, null, null, null); if(list.size()>0) { YtiotXjEventProcessing o = (YtiotXjEventProcessing) list.get(0); if(sj_type!=null) o.setSjType(Integer.parseInt(sj_type)); if(person_liable!=null) o.setPersonLiable(Integer.parseInt(person_liable)); if(y_complete_time!=null) o.setYCompleteTime(formatter.parse(y_complete_time)); if(zp_remarks!=null) o.setZpRemarks(zp_remarks); o.setClType(1); // System.out.println("测试000000"+o.getWxName()); // System.out.println("测试000000"+o.getShTime()); o.setShTime(formatter.parse("1970-01-01 08:00:00.00")); o.setClTime(formatter.parse("1970-01-01 08:00:00.00")); o.setData1("0"); if(V_LOGINNAME!=null) o.setUserName(V_LOGINNAME); DaoResult ret = ytiotXjEventProcessingDao.update(o); System.out.println("测试000001"+ret.isSuccess()); System.out.println("测试000002"+ret.getResult()); json.put("success", ret.isSuccess()); json.put("MSG", ret.getResult()); }else { json.put("success", false); json.put("MSG", "需要编辑的权限记录不存在"); } }else { json.put("success", false); json.put("MSG", "记录ID不能为空"); } }else { json.put("success", false); json.put("MSG", "参数验证错误"); } return json.toString(); } @Override public String updateEventProcessingsh(String queryJson) throws Exception { // TODO Auto-generated method stub SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String id = null; String cl_type = null; String sh_remarks = null; String sh_time = null; String V_LOGINNAME = null; JSONObject q_json = null; JSONArray jSONArray = new JSONArray(); JSONObject json = new JSONObject(); json.put("action", "updateEventProcessingsh"); if(queryJson!=null) { q_json = JSONObject.fromObject(queryJson); id = q_json.has("id")?q_json.getString("id"):null; cl_type = q_json.has("cl_type")?q_json.getString("cl_type"):null; sh_remarks = q_json.has("sh_remarks")?q_json.getString("sh_remarks"):null; V_LOGINNAME = q_json.has("V_LOGINNAME")?q_json.getString("V_LOGINNAME"):null; json.put("query", queryJson); } if(chk_string_param(id)&&chk_string_param(cl_type)&&chk_string_param(sh_remarks)&&chk_string_param(V_LOGINNAME)) { if(id!=null) { List list = ytiotXjEventProcessingDao.query(" where u."+fieldname("id")+" ="+id, null, null, null, null); if(list.size()>0) { YtiotXjEventProcessing o = (YtiotXjEventProcessing) list.get(0); if(cl_type!=null) o.setClType(Integer.parseInt(cl_type)); if(sh_remarks!=null) o.setShRemarks(sh_remarks); if(V_LOGINNAME!=null) o.setUserName(V_LOGINNAME); // if(sh_time!=null) o.setShTime(new Date()); if(Integer.parseInt(cl_type)==3) { o.setData1("0"); } DaoResult ret = ytiotXjEventProcessingDao.updatesh(o); json.put("success", ret.isSuccess()); json.put("MSG", ret.getResult()); }else { json.put("success", false); json.put("MSG", "需要编辑的权限记录不存在"); } }else { json.put("success", false); json.put("MSG", "记录ID不能为空"); } }else { json.put("success", false); json.put("MSG", "参数验证错误"); } return json.toString(); } @Override public String getEventProcessingList(String queryJson, String page, String start, String limit, String sort) throws Exception { // TODO Auto-generated method stub SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd"); SimpleDateFormat formatter1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String id = null; String dwjl_id = null; String sj_type = null; String y_complete_time = null; String V_LOGINNAME = null; String V_PASSWORD = null; String person_liable = null; String zp_remarks = null; String user_name = null; String data1 = null; String data2 = null; String data3 = null; String cl_type = null; String cl_time = null; String wx_name = null; int xh = 0; String dwsb_remarks = null; String cl_time_k = null; String cl_time_k1 = null; String cl_time_j = null; String cl_time_j1 = null; String event_processing_id_list = null; String event_processing_id_list1 = null; String dwjl_id_list = null; String hehe = "1970-01-01 08:00:00"; String hehe00 = "0000-00-00 00:00:00"; String dqsj = formatter.format(new Date()); String cl_sql=null; String sql=null; String cl_sql1=null; String dwjl_sql = null; String dwjl_sql1 = null; String hqlwhere = null; String hqlwhere1 = null; String clsj_sql = null; String zrr_sql = null; String zsl_hqlwhere = null; String jrrw_hqlwhere = null; String csrw_hqlwhere = null; String jrjj_hqlwhere = null; String dz_sql = null; String Page = null; String Start = null; JSONArray Sort = null; String Limit = null; String order = null; String dir = null; String order_str = null; JSONObject q_json = null; JSONArray jSONArray = new JSONArray(); JSONArray jSONArray1 = new JSONArray(); JSONArray jSONArray3 = new JSONArray(); JSONObject json = new JSONObject(); json.put("action", "getEventProcessingList"); if(queryJson!=null) { q_json = JSONObject.fromObject(queryJson); id = q_json.has("id")?q_json.getString("id"):null; sj_type = q_json.has("sj_type")?q_json.getString("sj_type"):null; cl_type = q_json.has("cl_type")?q_json.getString("cl_type"):null; cl_time_k = q_json.has("cl_time_k")?q_json.getString("cl_time_k"):null; cl_time_j = q_json.has("cl_time_j")?q_json.getString("cl_time_j"):null; person_liable = q_json.has("person_liable")?q_json.getString("person_liable"):null; wx_name = q_json.has("wx_name")?q_json.getString("wx_name"):null; V_LOGINNAME = q_json.has("V_LOGINNAME")?q_json.getString("V_LOGINNAME"):null; V_PASSWORD = q_json.has("V_PASSWORD")?q_json.getString("V_PASSWORD"):null; order = q_json.has("order")?q_json.getString("order"):null; dir = q_json.has("dir")?q_json.getString("dir"):null; Start = q_json.has("start")?q_json.getString("start"):(start!=null)?start:"0"; Limit = q_json.has("limit")?q_json.getString("limit"):(limit!=null)?limit:null; Page = q_json.has("page")?q_json.getString("page"):(page!=null)?page:"0"; json.put("query", queryJson); } // System.out.println(); if(sort!=null) { Sort = JSONArray.fromObject(sort); if((Sort.isArray())&&(Sort.size()>0)) { JSONObject s_json = Sort.getJSONObject(0); order = s_json.has("property")?s_json.getString("property"):order; dir = s_json.has("direction")?s_json.getString("direction"):dir; } json.put("sort", sort); } Start = start; Limit = limit; Page = page; hqlwhere = chkhw(hqlwhere) + "u.userName='"+V_LOGINNAME+"'"; if(sj_type!=null&&Integer.parseInt(sj_type)!=0) hqlwhere = chkhw(hqlwhere) + "u.sjType = "+sj_type; if(person_liable!=null&&person_liable.length()>0&&Integer.parseInt(person_liable)!=0) hqlwhere = chkhw(hqlwhere) + "u."+fieldname("person_liable")+" = "+person_liable; if(cl_type!=null&&Integer.parseInt(cl_type)!=0) hqlwhere = chkhw(hqlwhere) + "u."+fieldname("cl_type")+"="+cl_type; if(cl_time_k!=null) { cl_time_k1=cl_time_k+" 00:01:00"; hqlwhere = chkhw(hqlwhere) + "u.clTime >='"+cl_time_k1+"'"; } if(cl_time_j!=null) { cl_time_j1 = cl_time_j+" 23:59:00"; hqlwhere = chkhw(hqlwhere) + "u.clTime <='"+cl_time_j1+"'"; } if(wx_name!=null) hqlwhere = chkhw(hqlwhere) + "u.wxName like '%"+wx_name+"%'"; if(order!=null) order_str = " order by u."+fieldname(order); else order_str = " order by u."+fieldname("id"); int totalCount = ytiotXjEventProcessingDao.getCount(hqlwhere); json.put("totalCount", totalCount); if(Start!=null){ if(Integer.parseInt(Start)>totalCount){ Start = "0"; Page = "0"; } if(page==null) Page="0"; }else{ Start = "0"; Page = "0"; } json.put("page", Page); json.put("start", Start); json.put("limit", Limit); hqlwhere1 = chkhw(hqlwhere1) + "u.zn in ('4','5','6','7')"; if(V_LOGINNAME!=null) hqlwhere1 = chkhw(hqlwhere1) + "u.data2='"+V_LOGINNAME+"'"; sql=""; List list_zrrxlk = ytiotXjInspectorsDao.query(hqlwhere1, null, null, null, null); if(list_zrrxlk.size()>0) { for(int i=0;i0) { List list = ytiotXjEventProcessingDao.query(hqlwhere, order_str, dir, Start, Limit); if(list.size()>0) { for(int i=0;i0) { YtiotXjSpotOperationRecord dwjl_o1 = (YtiotXjSpotOperationRecord)dwjl_list1.get(0); if(String.valueOf(dwjl_o1.getSpotId())!=null) { dz_sql=" where u.id="+dwjl_o1.getSpotId(); List dz_list = ytiotXjInspectionPointsDao.query(dz_sql, null, null, null, null); if( dz_list.size()>0) { YtiotXjInspectionPoints dz_o = (YtiotXjInspectionPoints)dz_list.get(0); map.put("spot_address", dz_o.getSpotAddress()); } } } } // System.out.println("测试000666故障"+o.getSjType()); if(o.getSjType()==1) { map.put("sj_type_name", "故障"); // System.out.println("测试000666故障"); }else if(o.getSjType()==2) { map.put("sj_type_name", "隐患"); // System.out.println("测试000666四大"); }else if(o.getSjType()==3) { map.put("sj_type_name", "其他"); // System.out.println("测试000666发鬼地方"); }else{ // System.out.println("测试000666打算"); map.put("sj_type_name", "--"); } if(o.getYCompleteTime()!=null) { if(formatter1.format(o.getYCompleteTime()).equals(hehe)||formatter1.format(o.getYCompleteTime()).equals(hehe00)) { map.put("y_complete_time", "--"); }else { map.put("y_complete_time", formatter1.format(o.getYCompleteTime())); } }else { map.put("y_complete_time", "--"); } if(o.getClType()==2) { // map.put("cl_type_name", "< a href='javascript:void(0)' onclick=\"modifywin1(0," + o.getId() + ")\" style='color:#59c24a'>未审核"); map.put("cl_type_name", ""+"未审核"+""); map.put("cl_time", "--"); }else if(o.getClType()==3) { // map.put("cl_type_name", "< a href='javascript:void(0)' onclick=\"modifywin1(0," + o.getId() + ")\" style='color:#ff9254'>审核未通过"); map.put("cl_type_name", ""+"审核未通过"+""); map.put("cl_time", "--"); }else if(o.getClType()==4) { // map.put("cl_type_name", "< a href='javascript:void(0)' onclick=\"modifywin1(0," + o.getId() + ")\" style='color:#0082ff'>已完成"); map.put("cl_type_name", ""+"已完成 "+""); map.put("cl_time", formatter1.format(o.getClTime())); }else if(o.getClType()==5) { // map.put("cl_type_name", "< a href='javascript:void(0)' onclick=\"modifywin1(0," + o.getId() + ")\" style='color:#ff9254'>超时完成 "); map.put("cl_type_name", ""+"超时完成 "+""); map.put("cl_time", formatter1.format(o.getClTime())); }else if(o.getClType()==1) { map.put("cl_type_name", ""+"未处理"+""); map.put("cl_time", "--"); }else if(o.getClType()==0) { map.put("cl_type_name", ""+"未处理"+""); map.put("cl_time", "--"); } // System.out.println("测试000"+o.getPersonLiable()); if(o.getPersonLiable()!=null) { // map.put("dqzt", "< a href='javascript:void(0)' onclick=\"modifywin1(0," + o.getId() + ")\" style='color:#0082ff'>已指派"); map.put("dqzt", ""+"已指派"+""); }else { // map.put("dqzt", "< a href='javascript:void(0)' onclick=\"modifywin1(0," + o.getId() + ")\" style='color:#ff0000'>未指派"); map.put("dqzt", ""+"未指派"+""); } if(o.getPersonLiable()!=null) { zrr_sql = " where u.id="+o.getPersonLiable(); List zrr_list = ytiotXjInspectorsDao.query(zrr_sql, null, null, null, null); if(zrr_list .size()>0) { YtiotXjInspectors zrr_o = (YtiotXjInspectors)zrr_list.get(0); map.put("person_liable_name", zrr_o.getName()); map.put("phone", zrr_o.getPhone()); } }else { map.put("person_liable_name", "--"); map.put("phone", "--"); } JSONObject jSONObject = JSONObject.fromObject(map); jSONArray.add(jSONObject); } json.put("RESULT", jSONArray); } } Map map3 = new HashMap(); //人员总数量 if(V_LOGINNAME!=null) { zsl_hqlwhere = " where u."+fieldname("data2")+"='"+V_LOGINNAME+"' and u."+fieldname("zn")+" in (4,5,6,7)"; // System.out.println(xjrysl_hqlwhere); int zrs = ytiotXjInspectorsDao.getCount(zsl_hqlwhere); // System.out.println(xjrysl); map3.put("zrs", zrs); // System.out.println("测试0"+zrs); } //今日事件 if(dqsj!=null) { jrrw_hqlwhere = " where u."+fieldname("y_complete_time")+" like '%"+dqsj+"%' and u."+fieldname("user_name")+"='"+V_LOGINNAME+"'"; // System.out.println(jrrw_hqlwhere); int jrsj = ytiotXjEventProcessingDao.getCount(jrrw_hqlwhere); // System.out.println("总数"+jrsj); map3.put("jrsj", jrsj); }else { map3.put("jrsj", 0); } //超时事件 if(V_LOGINNAME!=null) { csrw_hqlwhere = " where u."+fieldname("user_name")+"='"+V_LOGINNAME+"' and u.clType=5"; // System.out.println(jrrw_hqlwhere); int cssj = ytiotXjEventProcessingDao.getCount(csrw_hqlwhere); map3.put("cssj", cssj); }else { map3.put("cssj", 0); } //今日解决 if(V_LOGINNAME!=null&&dqsj!=null) { jrjj_hqlwhere = " where u."+fieldname("user_name")+"='"+V_LOGINNAME+"' and u.clType=4 and u.shTime like '%"+dqsj+"%'"; // System.out.println(jrrw_hqlwhere); int jrjj = ytiotXjEventProcessingDao.getCount(jrjj_hqlwhere); map3.put("jrjj", jrjj); }else { map3.put("jrjj", 0); } JSONObject jSONObject3 = JSONObject.fromObject(map3); jSONArray3.add(jSONObject3); json.put("RESULT2", jSONArray3); return json.toString(); } @Override public String getReportDetailsList(String queryJson) throws Exception { // TODO Auto-generated method stub SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String id = null; String hehe = "0002-11-30 00:00:00"; String V_LOGINNAME = null; String V_PASSWORD = null; String name_sql=null; String hqlwhere = null; String dwjl_sql = null; String tp_sql = null; // String Page = null; // String Start = null; // JSONArray Sort = null; // String Limit = null; String order = null; String dir = null; String order_str = null; JSONObject q_json = null; JSONArray jSONArray = new JSONArray(); JSONObject json = new JSONObject(); json.put("action", "getReportDetailsList"); if(queryJson!=null) { q_json = JSONObject.fromObject(queryJson); id = q_json.has("id")?q_json.getString("id"):null; V_LOGINNAME = q_json.has("V_LOGINNAME")?q_json.getString("V_LOGINNAME"):null; V_PASSWORD = q_json.has("V_PASSWORD")?q_json.getString("V_PASSWORD"):null; order = q_json.has("order")?q_json.getString("order"):null; dir = q_json.has("dir")?q_json.getString("dir"):null; json.put("query", queryJson); } // System.out.println(); if(id!=null) hqlwhere = chkhw(hqlwhere) + "u."+fieldname("id")+"="+id; if(order!=null) order_str = " order by u."+fieldname(order); else order_str = " order by u."+fieldname("id"); int totalCount = ytiotXjEventProcessingDao.getCount(hqlwhere); json.put("totalCount", totalCount); if(totalCount>0) { List list = ytiotXjEventProcessingDao.query(hqlwhere, null, null, null, null); if(list.size()>0) { YtiotXjEventProcessing o = (YtiotXjEventProcessing)list.get(0); Map map = new HashMap(); map.put("id", o.getId()); if(String.valueOf(o.getDwjlId())!=null) { dwjl_sql = " where u.id="+o.getDwjlId(); List dwjl_list = ytiotXjSpotOperationRecordDao.query(dwjl_sql, null, null, null, null); if(dwjl_list.size()>0) { YtiotXjSpotOperationRecord dwjl_o = (YtiotXjSpotOperationRecord)dwjl_list.get(0); if(dwjl_o.getWbrId()!=null) { name_sql=" where u.id="+dwjl_o.getWbrId(); List name_list = ytiotXjInspectorsDao.query(name_sql, null, null, null, null); if(name_list.size()>0) { YtiotXjInspectors name_o = (YtiotXjInspectors)name_list.get(0); map.put("name", name_o.getName()); // map.put("phone", name_o.getPhone()); } } if(formatter.format(dwjl_o.getWcTime()).equals(hehe)) { map.put("sbsj", "--"); }else { map.put("sbsj", formatter.format(dwjl_o.getWcTime())); } map.put("dwsb_remarks", dwjl_o.getDwsbRemarks()); if(dwjl_o.getId()!=null) { tp_sql=" where u.dwczjlId="+dwjl_o.getId(); List tp_list = ytiotXjOperationRecordPhotosDao.query(tp_sql, null, null, null, null); if(tp_list.size()>0) { YtiotXjOperationRecordPhotos tp_o = (YtiotXjOperationRecordPhotos)tp_list.get(0); map.put("report_photos", tp_o.getReportPhotos()); } } } } JSONObject jSONObject = JSONObject.fromObject(map); jSONArray.add(jSONObject); json.put("RESULT", jSONArray); } } return json.toString(); } @Override public String getAssignJlList(String queryJson) throws Exception { // TODO Auto-generated method stub SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String id = null; String hehe = "0000-00-00 00:00:00"; String hehe00 = "1970-01-01 08:00:00"; String hehe1 = "0002-11-30 00:00:00"; String V_LOGINNAME = null; String V_PASSWORD = null; String name_sql=null; String name_sql2=null; String hqlwhere = null; String dwjl_sql = null; String tp_sql = null; // String Page = null; // String Start = null; // JSONArray Sort = null; // String Limit = null; String order = null; String dir = null; String order_str = null; JSONObject q_json = null; JSONArray jSONArray = new JSONArray(); JSONObject json = new JSONObject(); json.put("action", "getAssignJlList"); if(queryJson!=null) { q_json = JSONObject.fromObject(queryJson); id = q_json.has("id")?q_json.getString("id"):null; V_LOGINNAME = q_json.has("V_LOGINNAME")?q_json.getString("V_LOGINNAME"):null; V_PASSWORD = q_json.has("V_PASSWORD")?q_json.getString("V_PASSWORD"):null; order = q_json.has("order")?q_json.getString("order"):null; dir = q_json.has("dir")?q_json.getString("dir"):null; json.put("query", queryJson); } // System.out.println(); if(id!=null) hqlwhere = chkhw(hqlwhere) + "u."+fieldname("id")+"="+id; if(order!=null) order_str = " order by u."+fieldname(order); else order_str = " order by u."+fieldname("id"); int totalCount = ytiotXjEventProcessingDao.getCount(hqlwhere); json.put("totalCount", totalCount); if(totalCount>0) { List list = ytiotXjEventProcessingDao.query(hqlwhere, null, null, null, null); if(list.size()>0) { YtiotXjEventProcessing o = (YtiotXjEventProcessing)list.get(0); Map map = new HashMap(); map.put("id", o.getId()); if(o.getSjType()==1) { map.put("sj_tytpe_name", "故障"); }else if(o.getSjType()==2) { map.put("sj_tytpe_name", "隐患"); }else if(o.getSjType()==3) { map.put("sj_tytpe_name", "其他"); } if(o.getPersonLiable()!=null) { name_sql2=" where u.id="+o.getPersonLiable(); List name_list2 = ytiotXjInspectorsDao.query(name_sql2, null, null, null, null); if(name_list2.size()>0) { YtiotXjInspectors name_o2 = (YtiotXjInspectors)name_list2.get(0); map.put("name", name_o2.getName()); } } if(String.valueOf(o.getDwjlId())!=null) { dwjl_sql = " where u.id="+o.getDwjlId(); List dwjl_list = ytiotXjSpotOperationRecordDao.query(dwjl_sql, null, null, null, null); if(dwjl_list.size()>0) { YtiotXjSpotOperationRecord dwjl_o = (YtiotXjSpotOperationRecord)dwjl_list.get(0); if(dwjl_o.getWbrId()!=null) { name_sql=" where u.id="+dwjl_o.getWbrId(); List name_list = ytiotXjInspectorsDao.query(name_sql, null, null, null, null); if(name_list.size()>0) { YtiotXjInspectors name_o = (YtiotXjInspectors)name_list.get(0); map.put("phone", name_o.getPhone()); } } if(formatter.format(dwjl_o.getWcTime()).equals(hehe1)) { map.put("sbsj", "--"); }else { map.put("sbsj", formatter.format(dwjl_o.getWcTime())); } } } if(o.getYCompleteTime()!=null) { if(formatter.format(o.getYCompleteTime()).equals(hehe)||formatter.format(o.getYCompleteTime()).equals(hehe00)) { map.put("y_complete_time", ""); }else { map.put("y_complete_time", formatter.format(o.getYCompleteTime())); } }else { map.put("y_complete_time", ""); } // System.out.println("测试00"+formatter.format(o.getYCompleteTime())); map.put("zp_remarks", o.getZpRemarks()); JSONObject jSONObject = JSONObject.fromObject(map); jSONArray.add(jSONObject); json.put("RESULT", jSONArray); } } return json.toString(); } @Override public String getNotAudited(String queryJson) throws Exception { // TODO Auto-generated method stub SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String id = null; String hehe = "0000-00-00 00:00:00"; String hehe1 = "0002-11-30 00:00:00"; String V_LOGINNAME = null; String hehe00 = "1970-01-01 08:00:00"; String V_PASSWORD = null; String name_sql=null; String name_sql2=null; String hqlwhere = null; String dwjl_sql = null; String tp_sql = null; String zt_sql = null; // String Page = null; // String Start = null; // JSONArray Sort = null; // String Limit = null; String order = null; String dir = null; String order_str = null; JSONObject q_json = null; JSONArray jSONArray = new JSONArray(); JSONObject json = new JSONObject(); json.put("action", "getNotAudited"); if(queryJson!=null) { q_json = JSONObject.fromObject(queryJson); id = q_json.has("id")?q_json.getString("id"):null; V_LOGINNAME = q_json.has("V_LOGINNAME")?q_json.getString("V_LOGINNAME"):null; V_PASSWORD = q_json.has("V_PASSWORD")?q_json.getString("V_PASSWORD"):null; order = q_json.has("order")?q_json.getString("order"):null; dir = q_json.has("dir")?q_json.getString("dir"):null; json.put("query", queryJson); } // System.out.println(); if(id!=null) hqlwhere = chkhw(hqlwhere) + "u."+fieldname("id")+"="+id; if(order!=null) order_str = " order by u."+fieldname(order); else order_str = " order by u."+fieldname("id"); int totalCount = ytiotXjEventProcessingDao.getCount(hqlwhere); json.put("totalCount", totalCount); if(totalCount>0) { List list = ytiotXjEventProcessingDao.query(hqlwhere, null, null, null, null); if(list.size()>0) { YtiotXjEventProcessing o = (YtiotXjEventProcessing)list.get(0); Map map = new HashMap(); map.put("id", o.getId()); if( o.getId()!=null) { // zt_sql=" where u.eventProcessingId="+ o.getId()+" order by u.clTime desc"; // List zt_list = ytiotXjToExamineDao.query(zt_sql, null, null, null, null); // if(zt_list.size()>0) { // YtiotXjToExamine zt_o = (YtiotXjToExamine)zt_list.get(0); map.put("cl_type", o.getClType()); if(o.getClType()==2) { map.put("cl_type_name", ""+"未审核"+""); map.put("sh_time", "无"); }else if(o.getClType()==3) { map.put("cl_type_name", ""+"审核未通过"+""); map.put("sh_time", formatter.format(o.getShTime())); }else if(o.getClType()==4) { map.put("cl_type_name", ""+"已完成"+""); map.put("sh_time", formatter.format(o.getShTime())); }else if(o.getClType()==5) { map.put("cl_type_name", ""+"超时完成"+""); map.put("sh_time", formatter.format(o.getShTime())); }else if(o.getClType()==1) { map.put("cl_type_name", ""+"未处理"+""); } map.put("picture_path", o.getPicturePath()); map.put("cl_time", formatter.format(o.getClTime())); map.put("jg_remarks", o.getJgRemarks()); map.put("data1", o.getData1()); // if(formatter.format(o.getShTime()).equals(hehe)) { // map.put("sh_time", "无"); // }else { // map.put("sh_time", formatter.format(o.getShTime())); // } if(o.getShRemarks()!=null) { map.put("sh_remarks", o.getShRemarks()); }else { map.put("sh_remarks", "无"); } // } } if(o.getYCompleteTime()!=null) { if(formatter.format(o.getYCompleteTime()).equals(hehe)||formatter.format(o.getYCompleteTime()).equals(hehe00)) { map.put("y_complete_time", ""); }else { map.put("y_complete_time", formatter.format(o.getYCompleteTime())); } }else { map.put("y_complete_time", ""); } if(o.getPersonLiable()!=null) { name_sql2=" where u.id="+o.getPersonLiable(); List name_list2 = ytiotXjInspectorsDao.query(name_sql2, null, null, null, null); if(name_list2.size()>0) { YtiotXjInspectors name_o2 = (YtiotXjInspectors)name_list2.get(0); map.put("person_liable_name", name_o2.getName()); } } if(String.valueOf(o.getDwjlId())!=null) { dwjl_sql = " where u.id="+o.getDwjlId(); List dwjl_list = ytiotXjSpotOperationRecordDao.query(dwjl_sql, null, null, null, null); if(dwjl_list.size()>0) { YtiotXjSpotOperationRecord dwjl_o = (YtiotXjSpotOperationRecord)dwjl_list.get(0); if(dwjl_o.getWbrId()!=null) { name_sql=" where u.id="+dwjl_o.getWbrId(); List name_list = ytiotXjInspectorsDao.query(name_sql, null, null, null, null); if(name_list.size()>0) { YtiotXjInspectors name_o = (YtiotXjInspectors)name_list.get(0); map.put("phone", name_o.getPhone()); } } if(formatter.format(dwjl_o.getWcTime()).equals(hehe1)) { map.put("sbsj", "--"); }else { map.put("sbsj", formatter.format(dwjl_o.getWcTime())); } } } JSONObject jSONObject = JSONObject.fromObject(map); jSONArray.add(jSONObject); json.put("RESULT", jSONArray); } } return json.toString(); } @Override public String getFeedback(String queryJson) throws Exception { // TODO Auto-generated method stub SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String id = null; String event_processing_id = null; String hehe = "0000-00-00 00:00:00"; String hehe1 = "0002-11-30 00:00:00"; String hehe00 = "1970-01-01 08:00:00"; String V_LOGINNAME = null; String V_PASSWORD = null; String name_sql=null; String name_sql2=null; String hqlwhere = null; String dwjl_sql = null; String tp_sql = null; String zt_sql = null; // String Page = null; // String Start = null; // JSONArray Sort = null; // String Limit = null; String order = null; String dir = null; String order_str = null; JSONObject q_json = null; JSONArray jSONArray = new JSONArray(); JSONObject json = new JSONObject(); json.put("action", "getFeedback"); if(queryJson!=null) { q_json = JSONObject.fromObject(queryJson); event_processing_id = q_json.has("event_processing_id")?q_json.getString("event_processing_id"):null; V_LOGINNAME = q_json.has("V_LOGINNAME")?q_json.getString("V_LOGINNAME"):null; V_PASSWORD = q_json.has("V_PASSWORD")?q_json.getString("V_PASSWORD"):null; order = q_json.has("order")?q_json.getString("order"):null; dir = q_json.has("dir")?q_json.getString("dir"):null; json.put("query", queryJson); } // System.out.println(); if(event_processing_id!=null) hqlwhere = chkhw(hqlwhere) + "u."+fieldname("event_processing_id")+"="+event_processing_id+" order by u.clTime asc"; // if(order!=null) // order_str = " order by u."+fieldname(order); // else // order_str = " order by u."+fieldname("id"); // System.out.println("测试666666"+hqlwhere); int totalCount = ytiotXjToExamine1Dao.getCount(hqlwhere); json.put("totalCount", totalCount); if(totalCount>0) { List list = ytiotXjToExamine1Dao.query(hqlwhere, null, null, null, null); if(list.size()>0) { for(int i=0;i"+"未审核"+""); }else if(o.getClType()==3) { map.put("cl_type_name", ""+"审核未通过"+""); }else if(o.getClType()==4) { map.put("cl_type_name", ""+"已完成"+""); }else if(o.getClType()==5) { map.put("cl_type_name", ""+"超时完成"+""); }else if(o.getClType()==0) { map.put("cl_type_name", "无"); }else if(o.getClType()==1) { map.put("cl_type_name", ""+"未处理"+""); } if(o.getPersonLiable()!=null) { name_sql2=" where u.id="+o.getPersonLiable(); List name_list2 = ytiotXjInspectorsDao.query(name_sql2, null, null, null, null); if(name_list2.size()>0) { YtiotXjInspectors name_o2 = (YtiotXjInspectors)name_list2.get(0); map.put("person_liable_name", name_o2.getName()); } } if(String.valueOf(o.getDwjlId())!=null) { dwjl_sql = " where u.id="+o.getDwjlId(); List dwjl_list = ytiotXjSpotOperationRecordDao.query(dwjl_sql, null, null, null, null); if(dwjl_list.size()>0) { YtiotXjSpotOperationRecord dwjl_o = (YtiotXjSpotOperationRecord)dwjl_list.get(0); if(dwjl_o.getWbrId()!=null) { name_sql=" where u.id="+dwjl_o.getWbrId(); List name_list = ytiotXjInspectorsDao.query(name_sql, null, null, null, null); if(name_list.size()>0) { YtiotXjInspectors name_o = (YtiotXjInspectors)name_list.get(0); map.put("phone", name_o.getPhone()); } } if(formatter.format(dwjl_o.getWcTime()).equals(hehe1)) { map.put("sbsj", "--"); }else { map.put("sbsj", formatter.format(dwjl_o.getWcTime())); } } } if(o.getYCompleteTime()!=null) { if(formatter.format(o.getYCompleteTime()).equals(hehe)||formatter.format(o.getYCompleteTime()).equals(hehe00)) { map.put("y_complete_time", ""); }else { map.put("y_complete_time", formatter.format(o.getYCompleteTime())); } }else { map.put("y_complete_time", ""); } if(o.getShTime()!=null) { if(formatter.format(o.getShTime()).equals(hehe)||formatter.format(o.getShTime()).equals(hehe00)) { map.put("sh_time", "无"); }else { map.put("sh_time", formatter.format(o.getShTime())); } }else { map.put("sh_time", "无"); } if(o.getShRemarks()!=null) { map.put("sh_remarks", o.getShRemarks()); }else { map.put("sh_remarks", "无"); } JSONObject jSONObject = JSONObject.fromObject(map); jSONArray.add(jSONObject); } json.put("RESULT", jSONArray); } } return json.toString(); } // 维修责任人 @Override public String getwxzrr(String queryJson) throws Exception { // TODO Auto-generated method stub SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String id = null; String name = null; String phone = null; String company_code = null; String V_LOGINNAME = null; String V_PASSWORD = null; String company_code_list = null; String remarks = null; String inspect_role = null; int xh=0; String tdry_hqlwhere=null; String hqlwhere = null; String zrr_hqlwhere = null; String order = null; String dir = null; String order_str = null; JSONObject q_json = null; JSONArray jSONArray = new JSONArray(); JSONObject json = new JSONObject(); json.put("action", "getwxzrr"); if(queryJson!=null) { q_json = JSONObject.fromObject(queryJson); V_LOGINNAME = q_json.has("V_LOGINNAME")?q_json.getString("V_LOGINNAME"):null; order = q_json.has("order")?q_json.getString("order"):null; dir = q_json.has("dir")?q_json.getString("dir"):null; json.put("query", queryJson); } // System.out.println("测试"+id); // System.out.println(); hqlwhere = chkhw(hqlwhere) + "zn in ('4','5','6','7')"; if(V_LOGINNAME!=null) hqlwhere = chkhw(hqlwhere) + "data2='"+V_LOGINNAME+"'"; // // if(order!=null) // order_str = " order by u."+fieldname(order); // else // order_str = " order by u."+fieldname("id"); List list = ytiotXjInspectorsDao.query(hqlwhere, order_str, null, null, null); if(list.size()>0) { for(int i=0;i0&&Integer.parseInt(sj_type)!=0) hqlwhere = chkhw(hqlwhere) + "u.sjType = "+sj_type; if(person_liable!=null && person_liable.length()>0&&Integer.parseInt(person_liable)!=0) hqlwhere = chkhw(hqlwhere) + "u."+fieldname("person_liable")+" = "+person_liable; if(cl_type!=null && cl_type.length()>0&&Integer.parseInt(cl_type)!=0) hqlwhere = chkhw(hqlwhere) + "u."+fieldname("cl_type")+"="+cl_type; if(cl_time_k!=null && cl_time_k.length()>0) { cl_time_k1=cl_time_k+" 00:01:00"; hqlwhere = chkhw(hqlwhere) + "u.clTime >='"+cl_time_k1+"'"; } if(cl_time_j!=null && cl_time_j.length()>0) { cl_time_j1 = cl_time_j+" 23:59:00"; hqlwhere = chkhw(hqlwhere) + "u.clTime <='"+cl_time_j1+"'"; } if(wx_name!=null && wx_name.length()>0) hqlwhere = chkhw(hqlwhere) + "u.wxName like '%"+wx_name+"%'"; // System.out.println(hqlwhere); // if(order!=null) // order_str = " order by u."+fieldname(order); // else // order_str = " order by u."+fieldname("id"); int totalCount = ytiotXjEventProcessingDao.getCount(hqlwhere); json.put("totalCount", totalCount); if(totalCount>0) { List list = ytiotXjEventProcessingDao.query(hqlwhere, null, null, null, null); if(list.size()>0) { for(int i=0;i0) { YtiotXjSpotOperationRecord dwjl_o1 = (YtiotXjSpotOperationRecord)dwjl_list1.get(0); // map.put("dwsb_remarks", dwjl_o1.getDwsbRemarks()); if(String.valueOf(dwjl_o1.getSpotId())!=null) { dz_sql=" where u.id="+dwjl_o1.getSpotId(); List dz_list = ytiotXjInspectionPointsDao.query(dz_sql, null, null, null, null); if( dz_list.size()>0) { YtiotXjInspectionPoints dz_o = (YtiotXjInspectionPoints)dz_list.get(0); map.put("spot_address", dz_o.getSpotAddress()); } } } } if(o.getSjType()==1) { map.put("sj_type_name", "故障"); }else if(o.getSjType()==2) { map.put("sj_type_name", "隐患"); }else if(o.getSjType()==3) { map.put("sj_type_name", "其他"); }else{ map.put("sj_type_name", "--"); } if(o.getYCompleteTime()!=null) { if(formatter.format(o.getYCompleteTime()).equals(hehe)||formatter.format(o.getYCompleteTime()).equals(hehe00)) { map.put("y_complete_time", "--"); }else { map.put("y_complete_time", formatter.format(o.getYCompleteTime())); } }else { map.put("y_complete_time", "--"); } // if(formatter.format(o.getYCompleteTime()).equals(hehe)) { // map.put("y_complete_time", "--"); // }else { // map.put("y_complete_time", formatter.format(o.getYCompleteTime())); // } // if(formatter.format(o.getYCompleteTime()).equals(hehe)) { // map.put("cl_time", "--"); // }else { // map.put("cl_time", formatter.format(o.getClTime())); // } // map.put("cl_time", formatter.format(o.getClTime())); if(o.getClType()==2) { map.put("clzt", "未审核"); map.put("cl_time", "--"); }else if(o.getClType()==3) { map.put("clzt", "审核未通过"); map.put("cl_time", "--"); }else if(o.getClType()==4) { map.put("cl_time", formatter.format(o.getClTime())); map.put("clzt", "已完成"); }else if(o.getClType()==5) { map.put("cl_time", formatter.format(o.getClTime())); map.put("clzt", "超时完成 "); }else if(o.getClType()==1) { map.put("clzt", "未处理"); map.put("cl_time", "--"); }else if(o.getClType()==0) { map.put("clzt", "未处理"); map.put("cl_time", "--"); } if(o.getPersonLiable()!=null) { map.put("dqzt", "已指派"); zrr_sql = " where u.id="+o.getPersonLiable(); List zrr_list = ytiotXjInspectorsDao.query(zrr_sql, null, null, null, null); if(zrr_list .size()>0) { YtiotXjInspectors zrr_o = (YtiotXjInspectors)zrr_list.get(0); map.put("person_liable_name", zrr_o.getName()); map.put("phone", zrr_o.getPhone()); } }else { map.put("dqzt", "未指派"); map.put("person_liable_name", "--"); map.put("phone", "--"); } JSONObject jSONObject = JSONObject.fromObject(map); jSONArray.add(jSONObject); } json.put("result", jSONArray); } } return json.toString(); } }