123
This commit is contained in:
		
							parent
							
								
									c1694bd76c
								
							
						
					
					
						commit
						1cc6ae357d
					
				|  | @ -0,0 +1,7 @@ | |||
| <?xml version="1.0" encoding="gb2312"?> | ||||
| <module name="pu"> | ||||
|     <public> | ||||
|     </public> | ||||
|     <private> | ||||
|     </private> | ||||
| </module> | ||||
|  | @ -0,0 +1,3 @@ | |||
| <component name="ssctp" displayname="ssctp"> | ||||
|   <dependencies/> | ||||
| </component> | ||||
|  | @ -0,0 +1,281 @@ | |||
| package nccloud.web.ssctp.sscbd.ssctask.action; | ||||
| import com.alibaba.fastjson.JSONArray; | ||||
| import com.alibaba.fastjson.JSONObject; | ||||
| import com.yonyou.cloud.utils.StringUtils; | ||||
| import java.util.ArrayList; | ||||
| import java.util.List; | ||||
| import java.util.Map; | ||||
| import nc.bs.framework.common.ITimeService; | ||||
| import nc.bs.sscrp.pub.query.PageInfo; | ||||
| import nc.vo.pub.lang.UFBoolean; | ||||
| import nc.vo.pub.lang.UFDate; | ||||
| import nc.vo.pub.lang.UFDateTime; | ||||
| import nc.vo.pub.lang.UFDouble; | ||||
| import nc.vo.ssctp.sscbd.SSCTaskVO; | ||||
| import nc.vo.ssctp.sscbd.enumeration.DealStatus; | ||||
| import nc.vo.ssctp.sscbd.enumeration.TaskStatus; | ||||
| import nccloud.framework.core.exception.ExceptionUtils; | ||||
| import nccloud.framework.core.json.IJson; | ||||
| import nccloud.framework.service.ServiceLocator; | ||||
| import nccloud.framework.web.action.itf.ICommonAction; | ||||
| import nccloud.framework.web.container.IRequest; | ||||
| import nccloud.framework.web.container.SessionContext; | ||||
| import nccloud.framework.web.json.JsonFactory; | ||||
| import nccloud.pubitf.ssctp.sscbd.ssctask.ISSCTaskQueryService; | ||||
| import nccloud.web.sscrp.rpbill.query.RPBillQryCondition; | ||||
| import nccloud.web.sscrp.rpbill.query.util.RPBillQryUtil; | ||||
| import nccloud.web.ssctp.sscbd.ssctask.query.util.TaskConvertUtil; | ||||
| import nccloud.web.ssctp.sscbd.ssctask.query.util.TaskQryUtil; | ||||
| public class SSCTaskHandleQueryAction | ||||
|   implements ICommonAction | ||||
| { | ||||
|   public Object doAction(IRequest request) { | ||||
|     IJson json = JsonFactory.create(); | ||||
|     String read = request.read(); | ||||
|     Map<String, Object> map = (Map)json.fromJson(read, Map.class); | ||||
|     JSONObject result = new JSONObject(); | ||||
|     String appcode = request.readSysParam().getAppcode(); | ||||
|     try { | ||||
|       UFDateTime curTime = ((ITimeService)ServiceLocator.find(ITimeService.class)).getUFDateTime(); | ||||
|        | ||||
|       PageInfo pageInfo = contructPageInfo(map); | ||||
|        | ||||
|       String taskstatus = (String)map.get("taskstatus"); | ||||
|       String userid = SessionContext.getInstance().getClientInfo().getUserid(); | ||||
|        | ||||
|       String condition = buildCondition4BillNum(map, taskstatus, userid); | ||||
|        | ||||
|       String taskCondition = buildCondition4Task(map, condition); | ||||
|        | ||||
|       SSCTaskVO[] task_vos = new SSCTaskVO[0]; | ||||
|       List<Map<String, String>> orderByInfo = (List)map.get(RPBillQryCondition.ORDERBYINFO); | ||||
|       ISSCTaskQueryService taskQueryService = (ISSCTaskQueryService)ServiceLocator.find(ISSCTaskQueryService.class); | ||||
|       if (orderByInfo != null && orderByInfo.size() > 0) { | ||||
|         task_vos = taskQueryService.queryByCondition(taskCondition, RPBillQryUtil.getOrderInfo(orderByInfo, "rpbill"), pageInfo); | ||||
|       } else { | ||||
|         task_vos = taskQueryService.queryByCondition(taskCondition, pageInfo); | ||||
|       }  | ||||
|        | ||||
|       List<String> taskPkList = new ArrayList<String>(); | ||||
|       if (DealStatus.pending.getValue().equals(taskstatus)) { | ||||
|         SSCTaskVO[] taskPkListVOs = taskQueryService.queryByCondition(taskCondition); | ||||
|         for (SSCTaskVO sscTaskVO : taskPkListVOs) { | ||||
|           taskPkList.add(sscTaskVO.getPk_task()); | ||||
|         } | ||||
|       }  | ||||
|       result.put("taskPkList", taskPkList); | ||||
|        | ||||
|       SSCTaskVO[] task_countvos = taskQueryService.queryByCondition(condition); | ||||
|       JSONArray billTypeCounts = taskQueryService.getBillTypeCounts(task_countvos); | ||||
|       JSONObject totalNum = taskQueryService.getTaskHandleNum(userid); | ||||
|        | ||||
|       String iscmpreject = (String)map.get("iscmpreject"); | ||||
|        | ||||
|       int cmprjectNum = 0; | ||||
|       if (iscmpreject != null && UFBoolean.FALSE.toString().equals(iscmpreject)) { | ||||
|         SSCTaskVO[] cmpRejectTask = taskQueryService.queryByCondition(" task.pk_sscuser = '" + userid + "' and task.iscmpreject = 'Y' and task.taskstatus='sscapprove' and task.pk_sscnode in ('0001ZG10000000NODE01','0001ZG10000000NODE02') "); | ||||
|         cmprjectNum = cmpRejectTask.length; | ||||
|       }  | ||||
|       result.put("pending", Integer.valueOf((cmprjectNum == 0) ? Integer.parseInt(totalNum.getString("pending")) : (Integer.parseInt(totalNum.getString("pending")) + cmprjectNum))); | ||||
|       result.put("handon", totalNum.getString("handon")); | ||||
|       result.put("adjust", totalNum.getString("adjust")); | ||||
|       result.put("sscreject", totalNum.getString("sscreject")); | ||||
|       result.put("searchArea", TaskQryUtil.getQryTempJsonOfBilltype(billTypeCounts)); | ||||
|       boolean isCreditInstall = taskQueryService.isCreditInstall(); | ||||
|       result.put("isCreditInstall", Boolean.valueOf(isCreditInstall)); | ||||
|        | ||||
|       double totalPage = Integer.parseInt(StringUtils.isEmpty(totalNum.getString(taskstatus)) ? "0" : totalNum.getString(taskstatus)) / pageInfo.getPageSize(); | ||||
|       int TotalPage = (int)Math.ceil(totalPage); | ||||
|       pageInfo.setTotalPage(TotalPage); | ||||
|        | ||||
|       JSONObject pageInfoJson = new JSONObject(); | ||||
|       pageInfoJson.put("number", Integer.valueOf(pageInfo.getPageIndex())); | ||||
|       pageInfoJson.put("size", Integer.valueOf(pageInfo.getPageSize())); | ||||
|       pageInfoJson.put("totalElements", Integer.valueOf(pageInfo.getTotal())); | ||||
|       pageInfoJson.put("totalPages", Integer.valueOf(pageInfo.getTotalPage())); | ||||
|        | ||||
|       JSONObject listTableJson = new JSONObject(); | ||||
|       JSONObject cardTableJson = new JSONObject(); | ||||
|        | ||||
|       listTableJson.put("areacode", "ssctaskhandle"); | ||||
|       listTableJson.put("pageinfo", pageInfoJson); | ||||
|        | ||||
|       TaskConvertUtil.translate(task_vos, taskstatus, listTableJson, cardTableJson, appcode); | ||||
|        | ||||
|       result.put("tasklist", listTableJson); | ||||
|       result.put("taskcard", cardTableJson); | ||||
|       result.put("lastQueryTime", curTime); | ||||
|     } | ||||
|     catch (Exception e) { | ||||
|       ExceptionUtils.wrapException(e); | ||||
|     }  | ||||
|     return result; | ||||
|   } | ||||
|    | ||||
|   private String buildCondition4Task(Map<String, Object> map, String condition) { | ||||
|     String pk_tradetype = (String)map.get("pk_tradetype"); | ||||
|     if (pk_tradetype != null && !"ALL".equals(pk_tradetype.toUpperCase())) { | ||||
|       condition = condition + " and task.pk_tradetype='" + pk_tradetype + "' "; | ||||
|     } | ||||
|     return condition; | ||||
|   } | ||||
|    | ||||
|   private String buildCondition4BillNum(Map<String, Object> map, String taskstatus, String userid) { | ||||
|     String condition = " (task.pk_sscuser = '" + userid + "'"; | ||||
|     String pk_task = (String)map.get("pk_task"); | ||||
|     if (pk_task != null && !"".equals(pk_task)) { | ||||
|       condition = condition + " and task.pk_task ='" + pk_task + "' "; | ||||
|     } | ||||
|      | ||||
|     if (DealStatus.pending.getValue().equals(taskstatus)) { | ||||
|       condition = condition + " and task.taskstatus = '" + TaskStatus.taken.getValue() + "'"; | ||||
|     } else if (DealStatus.handon.getValue().equals(taskstatus)) { | ||||
|       condition = condition + " and (task.taskstatus = '" + TaskStatus.handon.getValue() + "' or task." + "taskstatus" + " = '" + TaskStatus.outerhandon.getValue() + "')"; | ||||
|     } else if (DealStatus.adjust.getValue().equals(taskstatus)) { | ||||
|       condition = condition + " and task.taskstatus = '" + TaskStatus.adjust.getValue() + "'"; | ||||
|     } else if (DealStatus.sscreject.getValue().equals(taskstatus)) { | ||||
|       condition = condition + " and task.taskstatus = '" + TaskStatus.reject.getValue() + "'"; | ||||
|     } else if (DealStatus.handled.getValue().equals(taskstatus)) { | ||||
|       condition = condition + " and task.taskstatus = '" + TaskStatus.sscapprove.getValue() + "'"; | ||||
|     }  | ||||
|      | ||||
|     String sscnode = (String)map.get("pk_sscnode"); | ||||
|     if (sscnode != null && !"ALL".equals(sscnode.toUpperCase())) { | ||||
|       condition = condition + " and task.pk_sscnode='" + sscnode + "' "; | ||||
|     } else { | ||||
|       condition = condition + " and task.pk_sscnode in ('0001ZG10000000NODE01','0001ZG10000000NODE02') "; | ||||
|     }  | ||||
|      | ||||
|     String barcode = (String)map.get("barcode"); | ||||
|     if (barcode != null && !"".equals(barcode)) { | ||||
|       condition = condition + " and task.barcode = '" + barcode + "'"; | ||||
|     } | ||||
|      | ||||
|     String urgent = (String)map.get("urgent"); | ||||
|     if (urgent != null && !"ALL".equals(urgent.toUpperCase())) { | ||||
|       condition = condition + " and task.urgent ='" + urgent + "' "; | ||||
|     } | ||||
|     String information = (String)map.get("information"); | ||||
|     if (information != null && !!"".equals(information)) { | ||||
|       condition = condition + " and exists (select 1 from sscrp_bill bill where task.busiid = bill.busiid and bill.defitem1 = '" + information + "' )"; | ||||
|     } | ||||
|      | ||||
|     String alarm = (String)map.get("alarm"); | ||||
|     if (alarm != null && !"ALL".equals(alarm.toUpperCase())) { | ||||
|       UFDate curDate = new UFDate(); | ||||
|       switch (alarm) { | ||||
|         case "isExceed": | ||||
|           condition = condition + " and task.endtime <='" + curDate.toString() + "' "; | ||||
|           break; | ||||
|         case "isPreExceed": | ||||
|           condition = condition + " and task.warningtime <='" + curDate.toString() + "' and task." + "endtime" + " >'" + curDate.toString() + "' "; | ||||
|           break; | ||||
|         case "noExceed": | ||||
|           condition = condition + " and (task.warningtime >='" + curDate.toString() + "' or " + "endtime" + " is null or (" + "endtime" + " >'" + curDate.toString() + "' and " + "warningtime" + " is null ))"; | ||||
|           break; | ||||
|       }  | ||||
|      | ||||
|     }  | ||||
|     String timerange = (String)map.get("timerange"); | ||||
|     if (timerange != null && !"ALL".equals(timerange.toUpperCase())) { | ||||
|       UFDateTime ut = new UFDateTime(); | ||||
|       UFDate endDate = new UFDate(ut.getMillis()); | ||||
|       UFDate startDate = new UFDate(); | ||||
|       if ("ONEDAY".equals(timerange.toUpperCase())) { | ||||
|         startDate = endDate.getDateBefore(1); | ||||
|       } | ||||
|       if ("ONEWEEK".equals(timerange.toUpperCase())) { | ||||
|         startDate = endDate.getDateBefore(7); | ||||
|       } | ||||
|       if ("ONEMONTH".equals(timerange.toUpperCase())) { | ||||
|         startDate = endDate.getDateBefore(30); | ||||
|       } | ||||
|       condition = condition + " and task.operatetime>= '" + startDate.toLocalString().substring(0, 10) + "' "; | ||||
|     }  | ||||
|      | ||||
|     String timerange2 = (String)map.get("timerange2"); | ||||
|     if (timerange2 != null && !"ALL".equals(timerange2.toUpperCase())) { | ||||
|       UFDateTime ut = new UFDateTime(); | ||||
|       UFDate endDate = new UFDate(ut.getMillis()); | ||||
|       UFDate startDate = new UFDate(); | ||||
|       if ("ONEDAY".equals(timerange2.toUpperCase())) { | ||||
|         startDate = endDate.getDateBefore(1); | ||||
|       } | ||||
|       if ("ONEWEEK".equals(timerange2.toUpperCase())) { | ||||
|         startDate = endDate.getDateBefore(7); | ||||
|       } | ||||
|       if ("ONEMONTH".equals(timerange2.toUpperCase())) { | ||||
|         startDate = endDate.getDateBefore(30); | ||||
|       } | ||||
|       condition = condition + " and task.creationtime >= '" + startDate.toLocalString().substring(0, 10) + "' "; | ||||
|     }  | ||||
|      | ||||
|     Object fuzzyQueryKey = map.get("fuzzyQueryKey"); | ||||
|     List<String> vas = new ArrayList<String>(); | ||||
|     if (fuzzyQueryKey != null && !fuzzyQueryKey.toString().equals("")) { | ||||
|       for (Object c : (List)fuzzyQueryKey) { | ||||
|         vas.add((String)c); | ||||
|       } | ||||
|     } | ||||
|     StringBuilder whereSql = new StringBuilder(); | ||||
|     if (vas != null && vas.size() > 0) { | ||||
|       String taskcondition = condition; | ||||
|       taskcondition = buildCondition4Task(map, taskcondition); | ||||
|       taskcondition = taskcondition + " )"; | ||||
|       String taskFilterSQL = "select busiid from ssctp_task where " + taskcondition; | ||||
|       for (String s : vas) { | ||||
|         whereSql.append(" and task.busiid in ( "); | ||||
|         if (s.contains("=")) { | ||||
|           String[] strs = s.split("="); | ||||
|           whereSql.append(" SELECT a.busiid FROM sscrp_bill a,sscrp_detail b WHERE a.pk_bill = b.pk_bill AND CODE = '" + strs[0] + "' AND VALUE like '%" + strs[1].replaceAll("'", "") + "%' AND a.busiid IN (" + taskFilterSQL + ") "); | ||||
|           whereSql.append(" UNION ALL "); | ||||
|           whereSql.append(" SELECT a.busiid FROM sscrp_bill_done a,sscrp_detail_done b WHERE a.pk_bill = b.pk_bill AND CODE = '" + strs[0] + "' AND VALUE like '%" + strs[1].replaceAll("'", "") + "%' AND a.busiid IN (" + taskFilterSQL + ") "); | ||||
|         } else { | ||||
|           whereSql.append(" SELECT a.busiid FROM sscrp_bill a,sscrp_detail b WHERE a.pk_bill = b.pk_bill AND VALUE like '%" + s.replaceAll("'", "") + "%' AND a.busiid IN (" + taskFilterSQL + ") "); | ||||
|           whereSql.append(" UNION ALL "); | ||||
|           whereSql.append(" SELECT a.busiid FROM sscrp_bill_done a,sscrp_detail_done b WHERE a.pk_bill = b.pk_bill AND VALUE like '%" + s.replaceAll("'", "") + "%' AND a.busiid IN (" + taskFilterSQL + ") "); | ||||
|         }  | ||||
|         whereSql.append(" ) "); | ||||
|       }  | ||||
|     }  | ||||
|     if (whereSql.length() > 0) { | ||||
|       condition = condition + whereSql.toString(); | ||||
|     } | ||||
|      | ||||
|     if (DealStatus.pending.getValue().equals(taskstatus)) { | ||||
|        | ||||
|       String iscmpreject = (String)map.get("iscmpreject"); | ||||
|       if (iscmpreject != null && UFBoolean.TRUE.toString().equals(iscmpreject)) { | ||||
|         condition = "  task.pk_sscuser = '" + userid + "' and  task." + "taskstatus" + " in( '" + TaskStatus.sscapprove.getValue() + "','" + TaskStatus.taken.getValue() + "') and  task." + "iscmpreject" + " ='Y' "; | ||||
|       } else { | ||||
|         condition = condition + " or  ( task.taskstatus = '" + TaskStatus.sscapprove.getValue() + "' and  task." + "iscmpreject" + " ='Y' and  task." + "pk_sscuser" + " = '" + userid + "'))"; | ||||
|       }  | ||||
|     } else { | ||||
|       condition = condition + " )"; | ||||
|     }  | ||||
|      | ||||
|     return condition; | ||||
|   } | ||||
|    | ||||
| 	private PageInfo contructPageInfo(Map<String, Object> map) { | ||||
| 		PageInfo pageInfo = null; | ||||
| 		if (map.containsKey("pageinfo")) { | ||||
| 			pageInfo = new PageInfo(); | ||||
| 
 | ||||
| 			Map<String, Object> pageinfo = (Map) map.get("pageinfo"); | ||||
| 			Object size = pageinfo.get("size"); | ||||
| 			Object number = pageinfo.get("number"); | ||||
| 			if (size instanceof Double) { | ||||
| 				pageInfo.setPageSize((new UFDouble((Double) size)).intValue()); | ||||
| 			} else if (size instanceof String) { | ||||
| 				pageInfo.setPageSize((new UFDouble((String) size)).intValue()); | ||||
| 			} | ||||
| 			if (number instanceof Double) { | ||||
| 				pageInfo.setPageIndex((new UFDouble((Double) number)).intValue()); | ||||
| 			} else if (number instanceof String) { | ||||
| 				pageInfo.setPageIndex((new UFDouble((String) number)).intValue()); | ||||
| 			} | ||||
| 		} | ||||
| 		return pageInfo; | ||||
| 	} | ||||
| } | ||||
		Loading…
	
		Reference in New Issue