package cn.com.usky.iot.maintenanceplan.service; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Calendar; import java.util.HashMap; import java.util.List; import java.util.ArrayList; import java.util.Map; import cn.com.usky.iot.entity.YtiotTMaintenancePlan; import cn.com.usky.iot.entity.YtiotTPatrolPlan; import cn.com.usky.iot.entity.YtiotTRoute; import cn.com.usky.iot.entity.YtiotVUsercompany; import cn.com.usky.iot.entity.YtiotVUsercompanyId; import cn.com.usky.iot.entity.YtiotTAdmin; import cn.com.usky.iot.entity.YtiotTArea; import cn.com.usky.iot.entity.YtiotTInspectors; import cn.com.usky.iot.entity.YtiotTMaintenancePerson; import cn.com.usky.iot.entity.YtiotTRoute2; 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.iot.admin.dao.YtiotTAdminDao; import cn.com.usky.iot.maintenanceperson.dao.YtiotTMaintenancePersonDao; import cn.com.usky.iot.maintenanceplan.dao.YtiotTMaintenancePlanDao; import cn.com.usky.iot.route2.dao.YtiotTRoute2Dao; import cn.com.usky.utils.DaoResult; import cn.com.usky.utils.MD5Util; import net.sf.json.JSONArray; import net.sf.json.JSONObject; public class YtiotTMaintenancePlanServicesImpl implements YtiotTMaintenancePlanService { private YtiotTMaintenancePlanDao ytiotTMaintenancePlanDao; private YtiotVUserCompanyDao ytiotVUserCompanyDao; private YtiotTAdminDao ytiotTAdminDao; private YtiotTRoute2Dao ytiotTRoute2Dao; private YtiotTMaintenancePersonDao ytiotTMaintenancePersonDao; public YtiotTAdminDao getYtiotTAdminDao() { return ytiotTAdminDao; } public void setYtiotTAdminDao(YtiotTAdminDao ytiotTAdminDao) { this.ytiotTAdminDao = ytiotTAdminDao; } public YtiotTMaintenancePlanDao getYtiotTMaintenancePlanDao() { return ytiotTMaintenancePlanDao; } public void setYtiotTMaintenancePlanDao(YtiotTMaintenancePlanDao ytiotTMaintenancePlanDao) { this.ytiotTMaintenancePlanDao = ytiotTMaintenancePlanDao; } public YtiotVUserCompanyDao getYtiotVUserCompanyDao() { return ytiotVUserCompanyDao; } public void setYtiotVUserCompanyDao(YtiotVUserCompanyDao ytiotVUserCompanyDao) { this.ytiotVUserCompanyDao = ytiotVUserCompanyDao; } public YtiotTMaintenancePersonDao getYtiotTMaintenancePersonDao() { return ytiotTMaintenancePersonDao; } public void setYtiotTMaintenancePersonDao(YtiotTMaintenancePersonDao ytiotTMaintenancePersonDao) { this.ytiotTMaintenancePersonDao = ytiotTMaintenancePersonDao; } public YtiotTRoute2Dao getYtiotTRoute2Dao() { return ytiotTRoute2Dao; } public void setYtiotTRoute2Dao(YtiotTRoute2Dao ytiotTRoute2Dao) { this.ytiotTRoute2Dao = ytiotTRoute2Dao; } 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("id")) return "id"; if(field.equals("personnel")) return "personnel"; if(field.equals("route")) return "route"; if(field.equals("planned_date")) return "plannedDate"; if(field.equals("start_time")) return "startTime"; if(field.equals("end_time")) return "endTime"; if(field.equals("completion_status")) return "completionStatus"; if(field.equals("name")) return "name"; if(field.equals("route_name")) return "routeName"; if(field.equals("company_code")) return "companyCode"; return null; } public static String[] getDates(String dateFrom, String dateEnd, String weekDays) { long time = 1l; long perDayMilSec = 24 * 60 * 60 * 1000; List dateList = new ArrayList(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); //需要查询的星期系数 String strWeekNumber = weekForNum(weekDays); try { dateFrom = sdf.format(sdf.parse(dateFrom).getTime() - perDayMilSec); while (true) { time = sdf.parse(dateFrom).getTime(); time = time + perDayMilSec; Date date = new Date(time); dateFrom = sdf.format(date); if (dateFrom.compareTo(dateEnd) <= 0) { //查询的某一时间的星期系数 Integer weekDay = dayForWeek(date); //判断当期日期的星期系数是否是需要查询的 if (strWeekNumber.indexOf(weekDay.toString())!=-1) { System.out.println(dateFrom); dateList.add(dateFrom); } } else { break; } } } catch (Exception e1) { e1.printStackTrace(); } String[] dateArray = new String[dateList.size()]; dateList.toArray(dateArray); return dateArray; } //等到当期时间的周系数。星期日:1,星期一:2,星期二:3,星期三:4,星期四:5,星期五:6,星期六:7 public static Integer dayForWeek(Date date) { Calendar calendar = Calendar.getInstance(); calendar.setTime(date); return calendar.get(Calendar.DAY_OF_WEEK); } /** * 得到对应星期的系数 星期日:1,星期一:2,星期二:3,星期三:4,星期四:5,星期五:6,星期六:7 * @param weekDays 星期格式 星期一|星期二 */ public static String weekForNum(String weekDays){ //返回结果为组合的星期系数 String weekNumber = ""; //解析传入的星期 if(weekDays.indexOf("|")!=-1){//多个星期数 String []strWeeks = weekDays.split("\\|"); for(int i=0;i0) { // for(int i=0;i0) { YtiotTMaintenancePlan o = (YtiotTMaintenancePlan) list.get(0); if(personnel!=null) o.setPersonnel(personnel_id); if(route!=null) o.setRoute(route_id); if(planned_date!=null) o.setPlannedDate(planned_date); if(start_time!=null) o.setStartTime(start_time); if(end_time!=null) o.setEndTime(end_time); if(completion_status!=null) o.setCompletionStatus(completion_status); DaoResult ret = ytiotTMaintenancePlanDao.update(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 getMaintenancePlanList(String queryJson, String page, String start, String limit, String sort) throws Exception { // TODO Auto-generated method stub SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String id = null; String personnel = null; String route = null; String planned_date = null; String start_time = null; String end_time = null; String completion_status = null; String company_code = null; String Company_Code_List = null; String V_LOGINNAME = null; String Page = null; String Start = null; JSONArray Sort = null; String Limit = null; String hqlwhere4 = null; String hqlwhere3 = null; String hqlwhere2 = null; String hqlwhere1 = null; String 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", "getMaintenancePlanList"); if(queryJson!=null) { q_json = JSONObject.fromObject(queryJson); id = q_json.has("id")?q_json.getString("id"):null; personnel = q_json.has("personnel")?q_json.getString("personnel"):null; route = q_json.has("route")?q_json.getString("route"):null; planned_date = q_json.has("planned_date")?q_json.getString("planned_date"):null; start_time = q_json.has("start_time")?q_json.getString("start_time"):null; end_time = q_json.has("end_time")?q_json.getString("end_time"):null; completion_status = q_json.has("completion_status")?q_json.getString("completion_status"):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"; V_LOGINNAME = q_json.has("V_LOGINNAME")?q_json.getString("V_LOGINNAME"):null; json.put("query", queryJson); } if(personnel!=null) { hqlwhere3 = "u."+fieldname("name")+"='"+personnel+"'"; List list3 =ytiotTMaintenancePlanDao.query1(hqlwhere3); YtiotTMaintenancePerson p = (YtiotTMaintenancePerson)list3.get(0); personnel = Integer.toString(p.getId()); } if(route!=null) { hqlwhere4 = "u."+fieldname("route_name")+"='"+route+"'"; List list4 =ytiotTMaintenancePlanDao.query2(hqlwhere4); YtiotTRoute2 t = (YtiotTRoute2)list4.get(0); route = Integer.toString(t.getId()); } // 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); } if((V_LOGINNAME!=null)&&(company_code==null)&&(Company_Code_List==null)) { String where = " where u.id.agentid='"+V_LOGINNAME+"' "; List list = ytiotVUserCompanyDao.query(where, null, null, null, null); if(list.size()>0) { for(int i=0;itotalCount){ 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); if(totalCount>0) { List list = ytiotTMaintenancePlanDao.query(hqlwhere, order_str, dir, Start, Limit); if(list.size()>0) { for(int i=0;i0) { YtiotTMaintenancePerson g = (YtiotTMaintenancePerson)list1.get(0); map.put("personnel", g.getName()); } } if(o.getRoute()!=null) { hqlwhere2 = "u."+fieldname("id")+"='"+o.getRoute()+"'"; List list2 = ytiotTMaintenancePlanDao.query2(hqlwhere2); if(list2.size()>0) { YtiotTRoute2 r = (YtiotTRoute2)list2.get(0); map.put("route", r.getRouteName()); } } map.put("id", o.getId()); // map.put("personnel", o.getPersonnel()); // map.put("route", o.getRoute()); map.put("planned_date", o.getPlannedDate()); map.put("start_time", o.getStartTime()); map.put("end_time", o.getEndTime()); map.put("completion_status", o.getCompletionStatus()); //map.put("E_STATUS", o.getEStatus()); // map.put("D_STORETIME", formatter.format(o.getDStoretime())); JSONObject jSONObject = JSONObject.fromObject(map); jSONArray.add(jSONObject); } json.put("RESULT", jSONArray); } } return json.toString(); } @Override public String getMaintenancePlanExcelList(String queryJson) throws Exception { // TODO Auto-generated method stub SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String id = null; String personnel = null; String route = null; String planned_date = null; String start_time = null; String end_time = null; String completion_status = null; String company_code = null; String Company_Code_List = null; String V_LOGINNAME = null; String Page = null; String Start = null; JSONArray Sort = null; String Limit = null; String hqlwhere4 = null; String hqlwhere3 = null; String hqlwhere2 = null; String hqlwhere1 = null; String 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", "getMaintenancePlanList"); if(queryJson!=null) { q_json = JSONObject.fromObject(queryJson); id = q_json.has("id")?q_json.getString("id"):null; personnel = q_json.has("personnel")?q_json.getString("personnel"):null; route = q_json.has("route")?q_json.getString("route"):null; planned_date = q_json.has("planned_date")?q_json.getString("planned_date"):null; start_time = q_json.has("start_time")?q_json.getString("start_time"):null; end_time = q_json.has("end_time")?q_json.getString("end_time"):null; completion_status = q_json.has("completion_status")?q_json.getString("completion_status"):null; order = q_json.has("order")?q_json.getString("order"):null; dir = q_json.has("dir")?q_json.getString("dir"):null; V_LOGINNAME = q_json.has("V_LOGINNAME")?q_json.getString("V_LOGINNAME"):null; json.put("query", queryJson); } if((personnel!=null)&&(personnel.length()>0)) { hqlwhere3 = "u."+fieldname("name")+"='"+personnel+"'"; List list3 =ytiotTMaintenancePlanDao.query1(hqlwhere3); YtiotTInspectors p = (YtiotTInspectors)list3.get(0); personnel = Integer.toString(p.getId()); } if((route!=null)&&(route.length()>0)) { hqlwhere4 = "u."+fieldname("route_name")+"='"+route+"'"; List list4 =ytiotTMaintenancePlanDao.query2(hqlwhere4); YtiotTRoute t = (YtiotTRoute)list4.get(0); route = Integer.toString(t.getId()); } // System.out.println(); if((V_LOGINNAME!=null)&&(company_code==null)&&(Company_Code_List==null)) { String where = " where u.id.agentid='"+V_LOGINNAME+"' "; List list = ytiotVUserCompanyDao.query(where, null, null, null, null); if(list.size()>0) { for(int i=0;i0)) hqlwhere = chkhw(hqlwhere) + "u."+fieldname("personnel")+"='"+personnel+"'"; if((route!=null)&&(route.length()>0)) hqlwhere = chkhw(hqlwhere) + "u."+fieldname("route")+"='"+route+"'"; if((start_time!=null)&&(start_time.length()>0)) hqlwhere = chkhw(hqlwhere) + "u."+fieldname("start_time")+"='"+start_time+"'"; if((end_time!=null)&&(end_time.length()>0)) hqlwhere = chkhw(hqlwhere) + "u."+fieldname("end_time")+"='"+end_time+"'"; if((planned_date!=null)&&(planned_date.length()>0)) hqlwhere = chkhw(hqlwhere) + "u."+fieldname("planned_date")+"='"+planned_date+"'"; if(completion_status!=null) hqlwhere = chkhw(hqlwhere) + "u."+fieldname("completion_status")+"='"+completion_status+"'"; System.out.println(hqlwhere); if(order!=null) order_str = " order by u."+fieldname(order); else order_str = " order by u."+fieldname("id"); int totalCount = ytiotTMaintenancePlanDao.getCount(hqlwhere); json.put("totalCount", totalCount); if(totalCount>0) { List list = ytiotTMaintenancePlanDao.query(hqlwhere, order_str, dir, Start, Limit); if(list.size()>0) { for(int i=0;i0) { YtiotTMaintenancePerson g = (YtiotTMaintenancePerson)list1.get(0); map.put("personnel", g.getName()); } } if(o.getRoute()!=null) { hqlwhere2 = "u."+fieldname("id")+"='"+o.getRoute()+"'"; List list2 = ytiotTMaintenancePlanDao.query2(hqlwhere2); if(list2.size()>0) { YtiotTRoute2 r = (YtiotTRoute2)list2.get(0); map.put("route", r.getRouteName()); } } map.put("id", o.getId()); map.put("planned_date", o.getPlannedDate()); map.put("start_time", o.getStartTime()); map.put("end_time", o.getEndTime()); map.put("completion_status", o.getCompletionStatus()); JSONObject jSONObject = JSONObject.fromObject(map); jSONArray.add(jSONObject); } json.put("result", jSONArray); } } return json.toString(); } // 巡检记录 @Override public String getCheckRecord2List(String queryJson, String page, String start, String limit, String sort) throws Exception { // TODO Auto-generated method stub SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); //设置时间格式,将该时间格式的时间转换为时间戳 SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); String id = null; String personnel = null; String route = null; String planned_date = null; String start_time = null; String end_time = null; String completion_status = null; String sjc1=null; String sjc2=null; String company_code=null; String V_LOGINNAME = null; String V_PASSWORD = null; int E_STATUS=-1; String company_code_list = null; String Page = null; String Start = null; JSONArray Sort = null; String Limit = null; String hqlwhere4 = null; String hqlwhere3 = null; String hqlwhere2 = null; String hqlwhere1 = null; String 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", "getMaintenancePlanList"); if(queryJson!=null) { q_json = JSONObject.fromObject(queryJson); id = q_json.has("id")?q_json.getString("id"):null; personnel = q_json.has("personnel")?q_json.getString("personnel"):null; route = q_json.has("route")?q_json.getString("route"):null; planned_date = q_json.has("planned_date")?q_json.getString("planned_date"):null; start_time = q_json.has("start_time")?q_json.getString("start_time"):null; end_time = q_json.has("end_time")?q_json.getString("end_time"):null; completion_status = q_json.has("completion_status")?q_json.getString("completion_status"):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); } if((V_LOGINNAME!=null)&&(V_PASSWORD!=null)) { List list88 = ytiotTAdminDao.query(" where MD5(u.VLoginname)='"+MD5Util.EncoderByMd5(V_LOGINNAME)+"' and u.VPassword='" +V_PASSWORD+"' ", null, null, null, null); if(list88.size()>0) { YtiotTAdmin b2 = (YtiotTAdmin)list88.get(0); System.out.println("测试1"+b2.getEStatus()); E_STATUS = Integer.parseInt(b2.getEStatus()); // System.out.println("测试2"+E_STATUS); } } if(E_STATUS==1) { if(V_LOGINNAME!=null) { String where99 = " where u.id.agentid='"+V_LOGINNAME+"' "; List list66 = ytiotVUserCompanyDao.query(where99, null, null, null, null); if(list66.size()>0) { for(int i=0;i0)) { 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; if(company_code!=null) hqlwhere = chkhw(hqlwhere) + "u."+fieldname("company_code")+"='"+company_code+"'"; if(company_code_list!=null) hqlwhere = chkhw(hqlwhere) + "u."+fieldname("company_code")+" in("+company_code_list+")"; if(personnel!=null) hqlwhere = chkhw(hqlwhere) + "u."+fieldname("personnel")+"='"+personnel+"'"; if(route!=null) hqlwhere = chkhw(hqlwhere) + "u."+fieldname("route")+"='"+route+"'"; if(start_time!=null) hqlwhere = chkhw(hqlwhere) + "u."+fieldname("start_time")+"='"+start_time+"'"; if(end_time!=null) hqlwhere = chkhw(hqlwhere) + "u."+fieldname("end_time")+"='"+end_time+"'"; if(planned_date!=null) hqlwhere = chkhw(hqlwhere) + "u."+fieldname("planned_date")+" like '%"+planned_date+"%'"; if(completion_status!=null) hqlwhere = chkhw(hqlwhere) + "u."+fieldname("completion_status")+"='"+completion_status+"'"; if(order!=null) order_str = " order by u."+fieldname(order); else order_str = " order by u."+fieldname("id"); int totalCount = ytiotTMaintenancePlanDao.getCount(hqlwhere); //System.out.println(totalCount); 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); if(totalCount>0) { List list = ytiotTMaintenancePlanDao.query(hqlwhere, order_str, dir, Start, Limit); if(list.size()>0) { //获得当天时间 Date date1 = simpleDateFormat.parse(simpleDateFormat.format(new Date())); // System.out.println("测试三当前时间yyyy-MM-dd"+simpleDateFormat.format(new Date())); long time1 = date1.getTime()/1000; sjc1 = String.valueOf(time1); for(int i=0;i0) { YtiotTMaintenancePerson g = (YtiotTMaintenancePerson)list1.get(0); map.put("personnel", g.getName()); } } if(o.getRoute()!=null) { hqlwhere2 = "u."+fieldname("id")+"='"+o.getRoute()+"'"; List list2 = ytiotTMaintenancePlanDao.query2(hqlwhere2); if(list2.size()>0) { YtiotTRoute2 r = (YtiotTRoute2)list2.get(0); map.put("route", r.getRouteName()); } } map.put("id", o.getId()); // map.put("personnel", o.getPersonnel()); // map.put("route", o.getRoute()); map.put("planned_date", o.getPlannedDate()); map.put("start_time", o.getStartTime()); map.put("end_time", o.getEndTime()); map.put("completion_status", o.getCompletionStatus()); map.put("company_code1", o.getCompanyCode()); JSONObject jSONObject = JSONObject.fromObject(map); jSONArray.add(jSONObject); } } json.put("RESULT", jSONArray); } } }else { json.put("success", "false"); json.put("MSG", "用户权限错误,请重新登录后再试。"); } return json.toString(); } @Override public String getCheckRecord2ExcelList(String queryJson) throws Exception { // TODO Auto-generated method stub SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); //设置时间格式,将该时间格式的时间转换为时间戳 SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); String id = null; String personnel = null; String route = null; String planned_date = null; String start_time = null; String end_time = null; String completion_status = null; String sjc1=null; String sjc2=null; String company_code=null; String V_LOGINNAME = null; String V_PASSWORD = null; int E_STATUS=-1; String company_code_list = null; String Page = null; String Start = null; JSONArray Sort = null; String Limit = null; String hqlwhere4 = null; String hqlwhere3 = null; String hqlwhere2 = null; String hqlwhere1 = null; String 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", "getPatrolPlanList"); if(queryJson!=null) { q_json = JSONObject.fromObject(queryJson); id = q_json.has("id")?q_json.getString("id"):null; personnel = q_json.has("personnel")?q_json.getString("personnel"):null; route = q_json.has("route")?q_json.getString("route"):null; planned_date = q_json.has("planned_date")?q_json.getString("planned_date"):null; start_time = q_json.has("start_time")?q_json.getString("start_time"):null; end_time = q_json.has("end_time")?q_json.getString("end_time"):null; completion_status = q_json.has("completion_status")?q_json.getString("completion_status"):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); } if((V_LOGINNAME!=null)&&(V_PASSWORD!=null)) { List list88 = ytiotTAdminDao.query(" where MD5(u.VLoginname)='"+MD5Util.EncoderByMd5(V_LOGINNAME)+"' and u.VPassword='" +V_PASSWORD+"' ", null, null, null, null); if(list88.size()>0) { YtiotTAdmin b2 = (YtiotTAdmin)list88.get(0); // System.out.println("测试1"+b2.getEStatus()); E_STATUS = Integer.parseInt(b2.getEStatus()); // System.out.println("测试2"+E_STATUS); } } // System.out.println("bengkui"+E_STATUS); if(E_STATUS==1) { if(V_LOGINNAME!=null) { String where99 = " where u.id.agentid='"+V_LOGINNAME+"' "; List list66 = ytiotVUserCompanyDao.query(where99, null, null, null, null); if(list66.size()>0) { for(int i=0;i0)) { hqlwhere3 = "u."+fieldname("name")+"='"+personnel+"'"; List list3 =ytiotTMaintenancePlanDao.query1(hqlwhere3); YtiotTMaintenancePerson p = (YtiotTMaintenancePerson)list3.get(0); personnel = Integer.toString(p.getId()); } if((route!=null)&&(route.length()>0)) { hqlwhere4 = "u."+fieldname("route_name")+"='"+route+"'"; List list4 =ytiotTMaintenancePlanDao.query2(hqlwhere4); YtiotTRoute2 t = (YtiotTRoute2)list4.get(0); route = Integer.toString(t.getId()); } // System.out.println(); if(company_code!=null) hqlwhere = chkhw(hqlwhere) + "u."+fieldname("company_code")+"='"+company_code+"'"; if(company_code_list!=null) hqlwhere = chkhw(hqlwhere) + "u."+fieldname("company_code")+" in("+company_code_list+")"; if((personnel!=null)&&(personnel.length()>0)) hqlwhere = chkhw(hqlwhere) + "u."+fieldname("personnel")+"='"+personnel+"'"; if((route!=null)&&(route.length()>0)) hqlwhere = chkhw(hqlwhere) + "u."+fieldname("route")+"='"+route+"'"; if((start_time!=null)&&(start_time.length()>0)) hqlwhere = chkhw(hqlwhere) + "u."+fieldname("start_time")+"='"+start_time+"'"; if((end_time!=null)&&(end_time.length()>0)) hqlwhere = chkhw(hqlwhere) + "u."+fieldname("end_time")+"='"+end_time+"'"; if((planned_date!=null)&&(planned_date.length()>0)) hqlwhere = chkhw(hqlwhere) + "u."+fieldname("planned_date")+" like '%"+planned_date+"%'"; if((completion_status!=null)&&(completion_status.length()>0)) hqlwhere = chkhw(hqlwhere) + "u."+fieldname("completion_status")+"='"+completion_status+"'"; if(order!=null) order_str = " order by u."+fieldname(order); else order_str = " order by u."+fieldname("id"); int totalCount = ytiotTMaintenancePlanDao.getCount(hqlwhere); json.put("totalCount", totalCount); if(totalCount>0) { List list = ytiotTMaintenancePlanDao.query(hqlwhere, order_str, dir, Start, Limit); if(list.size()>0) { //获得当天时间 Date date1 = simpleDateFormat.parse(simpleDateFormat.format(new Date())); // System.out.println("测试三当前时间yyyy-MM-dd"+simpleDateFormat.format(new Date())); long time1 = date1.getTime()/1000; sjc1 = String.valueOf(time1); for(int i=0;i0) { YtiotTMaintenancePerson g = (YtiotTMaintenancePerson)list1.get(0); map.put("personnel", g.getName()); } } if(o.getRoute()!=null) { hqlwhere2 = "u."+fieldname("id")+"='"+o.getRoute()+"'"; List list2 = ytiotTMaintenancePlanDao.query2(hqlwhere2); if(list2.size()>0) { YtiotTRoute2 r = (YtiotTRoute2)list2.get(0); map.put("route", r.getRouteName()); } } map.put("id", o.getId()); // map.put("personnel", o.getPersonnel()); // map.put("route", o.getRoute()); map.put("planned_date", o.getPlannedDate()); map.put("start_time", o.getStartTime()); map.put("end_time", o.getEndTime()); map.put("completion_status", o.getCompletionStatus()); map.put("company_code1", o.getCompanyCode()); JSONObject jSONObject = JSONObject.fromObject(map); jSONArray.add(jSONObject); } } json.put("result", jSONArray); } } }else { json.put("success", "false"); json.put("MSG", "用户权限错误,请重新登录后再试。"); } return json.toString(); } // @Override // public String getPatrolPointVerList(String queryJson, String page, String start, String limit, String sort) throws Exception { // // TODO Auto-generated method stub // SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); // String UQ_POINT_ID = null; // String I_ORDER_IDX = null; // String V_POINT_ADDRESS = null; // int I_FLOOR = 0; // String F_HEIGHT = null; // String I_VERSION = null; // String D_STORETIME = null; // String UQ_ADMIN_ID = null; // String V_COMMENT = null; // // String sqlwhere = null; // String order = null; // String dir = null; // String Start = null; // String Limit = null; // String Page = null; // String order_str = null; // JSONObject q_json = null; // JSONArray Sort = null; // JSONArray jSONArray = new JSONArray(); // JSONObject json = new JSONObject(); // json.put("action", "getPointVerList"); // if(queryJson!=null) { // q_json = JSONObject.fromObject(queryJson); // UQ_POINT_ID = q_json.has("UQ_POINT_ID")?q_json.getString("UQ_POINT_ID"):null; // V_POINT_ADDRESS = q_json.has("V_POINT_ADDRESS")?q_json.getString("V_POINT_ADDRESS"):null; // I_FLOOR = q_json.has("I_FLOOR")?q_json.getInt("I_FLOOR"):0; // //F_HEIGHT = q_json.has("F_HEIGHT")?q_json.getString("F_HEIGHT"):null; // //I_ORDER_IDX= q_json.has("I_ORDER_IDX")?q_json.getString("I_ORDER_IDX"):null; // UQ_ADMIN_ID = q_json.has("UQ_ADMIN_ID")?q_json.getString("UQ_ADMIN_ID"):null; // I_VERSION = q_json.has("I_VERSION")?q_json.getString("I_VERSION"):null; //// System.out.println("测试"+E_STATUS); // // 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; // if(V_POINT_ADDRESS!=null) // sqlwhere = chkhw(sqlwhere) + "u."+fieldname("V_POINT_ADDRESS")+"='"+V_POINT_ADDRESS+"'"; // if(I_FLOOR!=0&&I_FLOOR>-1) // sqlwhere = chkhw(sqlwhere) + "u."+fieldname("I_FLOOR")+"='"+I_FLOOR+"'"; // // if(UQ_POINT_ID!=null) // sqlwhere = chkhw(sqlwhere) + "u."+fieldname("UQ_POINT_ID")+"='"+UQ_POINT_ID+"'"; // // if(UQ_ADMIN_ID!=null) // sqlwhere = chkhw(sqlwhere) + "u."+fieldname("UQ_ADMIN_ID")+"='"+UQ_ADMIN_ID+"'"; // // //hqlwhere = chkhw(hqlwhere) + "u."+fieldname("V_UNIT_NAME")+" like '%"+V_UNIT_NAME+"%'"; //// int b=Integer.parseInt(E_STATUS); //// if(b!=10) //// hqlwhere = chkhw(hqlwhere) + "u."+fieldname("E_STATUS")+"='"+E_STATUS+"'"; // // if(order!=null) // order_str = " order by u."+fieldname(order); // else // order_str = " order by u."+fieldname("UQ_POINT_ID"); // // //System.out.println("测试:"+sqlwhere); //// System.out.println(order_str); // // //YtiotTPointVerDao // int totalCount = ytiotTPointVerDao.getCount(sqlwhere); // //System.out.println("测试:"+totalCount); // json.put("totalCount", totalCount); // if(Start!=null){ // if(Integer.parseInt(Start)>totalCount){ // Start = "0"; // Page = "0"; // }else if(page==null) // Page="0"; // }else{ // Start = "0"; // Page = "0"; // } // json.put("page", Page); // json.put("start", Start); // json.put("limit", Limit); // //// System.out.println("测试:"+Page); //// System.out.println("测试:"+Start); //// System.out.println("测试:"+Limit); // if(totalCount>0) { // List list = ytiotTPointVerDao.query(sqlwhere, order_str, dir, Start, Limit); // System.out.println(list); // if(list.size()>0) { // for(int i=0;i