From 1d788d03414c0a1856ac67eebd082f6cf1f2678e Mon Sep 17 00:00:00 2001 From: gaojiabao Date: Fri, 19 May 2023 20:10:55 +0800 Subject: [PATCH] =?UTF-8?q?OA=20=E6=94=BE=E5=BC=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/WebServiceOAServiceImpl.java | 628 +++++++++--------- 1 file changed, 314 insertions(+), 314 deletions(-) diff --git a/src/main/java/com/ydw/bat/wkflow/business_oa/webService/service/impl/WebServiceOAServiceImpl.java b/src/main/java/com/ydw/bat/wkflow/business_oa/webService/service/impl/WebServiceOAServiceImpl.java index 8ebf2e2f..8d7f011b 100644 --- a/src/main/java/com/ydw/bat/wkflow/business_oa/webService/service/impl/WebServiceOAServiceImpl.java +++ b/src/main/java/com/ydw/bat/wkflow/business_oa/webService/service/impl/WebServiceOAServiceImpl.java @@ -89,43 +89,43 @@ public class WebServiceOAServiceImpl implements WebServiceOAService { CreateMQService oaService = SpringContextUtil.getBean(CreateMQService.class); log.info("--------------------------ESP 发送单个删除OA待办----------------------------"); -// if(StringUtils.isNotBlank(todoId) && StringUtils.isNotBlank(assignee)){ -// -// QueryWrapper wrapper = new QueryWrapper(); -// wrapper.eq("TODO_ID",todoId); -// wrapper.eq("MSG_TYPE","0"); -// List list = sendTodoLogMapper.selectList(wrapper); -// if(!list.isEmpty()){ -// net.sf.json.JSONObject fromObject = net.sf.json.JSONObject.fromObject(list.get(0).getMesg()); -// net.sf.json.JSONObject jsonObjectFilter = net.sf.json.JSONObject.fromObject(list.get(0).getMesg()); -// jsonObjectFilter = jsonObjectFilter.discard("PId"); -// jsonObjectFilter.remove("createTime"); -// jsonObjectFilter.remove("updateTime"); -// jsonObjectFilter.put("pid",fromObject.getString("PId")); -// BusProcessNew object = JSON.parseObject(jsonObjectFilter.toString(),BusProcessNew.class); -// -// List notifyTodoSendContexts = new ArrayList<>(); -// NotifyTodoSendContext notifyTodoSendContext = new NotifyTodoSendContext(); -// notifyTodoSendContext.setAppName("SPRS"); -// notifyTodoSendContext.setModelId(todoId); -// notifyTodoSendContext.setModelName(object.getTaskInfo()); -// notifyTodoSendContext.setType("1"); -// notifyTodoSendContext.setOptType("2"); -// Map map = new HashMap<>(); -// ResponseMessage byId = lawsUserInfoService.getById(assignee); -// map.put("LoginName",byId == null ? "" : byId.getData().getAccount()); -// JSONObject jsonLoginName = new JSONObject(map); -// notifyTodoSendContext.setTargets(jsonLoginName.toJSONString()); -// notifyTodoSendContext.setUserId(assignee); -// notifyTodoSendContexts.add(notifyTodoSendContext); -// Map objectMap = new TreeMap<>(); -// objectMap.put("todoId",todoId); -// objectMap.put("list",notifyTodoSendContexts); -// net.sf.json.JSONObject jsonObject = net.sf.json.JSONObject.fromObject(objectMap); -// log.info("=================发送单个删除OA待办:"+jsonObject.toString()); -// oaService.setTodoDeleteMq(jsonObject.toString()); -// } -// } + if(StringUtils.isNotBlank(todoId) && StringUtils.isNotBlank(assignee)){ + + QueryWrapper wrapper = new QueryWrapper(); + wrapper.eq("TODO_ID",todoId); + wrapper.eq("MSG_TYPE","0"); + List list = sendTodoLogMapper.selectList(wrapper); + if(!list.isEmpty()){ + net.sf.json.JSONObject fromObject = net.sf.json.JSONObject.fromObject(list.get(0).getMesg()); + net.sf.json.JSONObject jsonObjectFilter = net.sf.json.JSONObject.fromObject(list.get(0).getMesg()); + jsonObjectFilter = jsonObjectFilter.discard("PId"); + jsonObjectFilter.remove("createTime"); + jsonObjectFilter.remove("updateTime"); + jsonObjectFilter.put("pid",fromObject.getString("PId")); + BusProcessNew object = JSON.parseObject(jsonObjectFilter.toString(),BusProcessNew.class); + + List notifyTodoSendContexts = new ArrayList<>(); + NotifyTodoSendContext notifyTodoSendContext = new NotifyTodoSendContext(); + notifyTodoSendContext.setAppName("SPRS"); + notifyTodoSendContext.setModelId(todoId); + notifyTodoSendContext.setModelName(object.getTaskInfo()); + notifyTodoSendContext.setType("1"); + notifyTodoSendContext.setOptType("2"); + Map map = new HashMap<>(); + ResponseMessage byId = lawsUserInfoService.getById(assignee); + map.put("LoginName",byId == null ? "" : byId.getData().getAccount()); + JSONObject jsonLoginName = new JSONObject(map); + notifyTodoSendContext.setTargets(jsonLoginName.toJSONString()); + notifyTodoSendContext.setUserId(assignee); + notifyTodoSendContexts.add(notifyTodoSendContext); + Map objectMap = new TreeMap<>(); + objectMap.put("todoId",todoId); + objectMap.put("list",notifyTodoSendContexts); + net.sf.json.JSONObject jsonObject = net.sf.json.JSONObject.fromObject(objectMap); + log.info("=================发送单个删除OA待办:"+jsonObject.toString()); + oaService.setTodoDeleteMq(jsonObject.toString()); + } + } } /** @@ -137,47 +137,47 @@ public class WebServiceOAServiceImpl implements WebServiceOAService { CreateMQService oaService = SpringContextUtil.getBean(CreateMQService.class); log.info("--------------------------ESP 发送删除待办任务 及 再次发送待办----------------------------"); -// if(busProcessNew != null && StringUtils.isNotBlank(busProcessNew.getId())){ -// -// QueryWrapper wrapper = new QueryWrapper(); -// wrapper.eq("TODO_ID",busProcessNew.getId()); -// wrapper.eq("MSG_TYPE","0"); -// List list = sendTodoLogMapper.selectList(wrapper); -// if(!list.isEmpty()){ -// net.sf.json.JSONObject fromObject = net.sf.json.JSONObject.fromObject(list.get(0).getMesg()); -// net.sf.json.JSONObject jsonObjectFilter = net.sf.json.JSONObject.fromObject(list.get(0).getMesg()); -// jsonObjectFilter = jsonObjectFilter.discard("PId"); -// jsonObjectFilter.remove("createTime"); -// jsonObjectFilter.remove("updateTime"); -// jsonObjectFilter.put("pid",fromObject.getString("PId")); -// BusProcessNew object = JSON.parseObject(jsonObjectFilter.toString(),BusProcessNew.class); -// -// List notifyTodoSendContexts = new ArrayList<>(); -// NotifyTodoSendContext notifyTodoSendContext = new NotifyTodoSendContext(); -// notifyTodoSendContext.setAppName("SPRS"); -// notifyTodoSendContext.setModelId(busProcessNew.getId()); -// notifyTodoSendContext.setModelName(object.getTaskInfo()); -// notifyTodoSendContext.setType("1"); -// notifyTodoSendContext.setOptType("2"); -// Map map = new HashMap<>(); -// ResponseMessage byId = lawsUserInfoService.getById(busProcessNew.getUserId()); -// map.put("LoginName",byId == null ? "" : byId.getData().getAccount()); -// JSONObject jsonLoginName = new JSONObject(map); -// notifyTodoSendContext.setTargets(jsonLoginName.toJSONString()); -// notifyTodoSendContext.setUserId(busProcessNew.getUserId()); -// notifyTodoSendContexts.add(notifyTodoSendContext); -// Map objectMap = new TreeMap<>(); -// objectMap.put("todoId",busProcessNew.getId()); -// objectMap.put("list",notifyTodoSendContexts); -// net.sf.json.JSONObject jsonObject = net.sf.json.JSONObject.fromObject(objectMap); -// oaService.setTodoDeleteMq(jsonObject.toString()); -// log.info("=================ESP 发送删除待办任务 及 再次发送待办:"+jsonObject.toString()); -// -// // 重新发送OA待办 -// object.setUserId(assignee); -// oaService.sendTodoMq(object); -// } -// } + if(busProcessNew != null && StringUtils.isNotBlank(busProcessNew.getId())){ + + QueryWrapper wrapper = new QueryWrapper(); + wrapper.eq("TODO_ID",busProcessNew.getId()); + wrapper.eq("MSG_TYPE","0"); + List list = sendTodoLogMapper.selectList(wrapper); + if(!list.isEmpty()){ + net.sf.json.JSONObject fromObject = net.sf.json.JSONObject.fromObject(list.get(0).getMesg()); + net.sf.json.JSONObject jsonObjectFilter = net.sf.json.JSONObject.fromObject(list.get(0).getMesg()); + jsonObjectFilter = jsonObjectFilter.discard("PId"); + jsonObjectFilter.remove("createTime"); + jsonObjectFilter.remove("updateTime"); + jsonObjectFilter.put("pid",fromObject.getString("PId")); + BusProcessNew object = JSON.parseObject(jsonObjectFilter.toString(),BusProcessNew.class); + + List notifyTodoSendContexts = new ArrayList<>(); + NotifyTodoSendContext notifyTodoSendContext = new NotifyTodoSendContext(); + notifyTodoSendContext.setAppName("SPRS"); + notifyTodoSendContext.setModelId(busProcessNew.getId()); + notifyTodoSendContext.setModelName(object.getTaskInfo()); + notifyTodoSendContext.setType("1"); + notifyTodoSendContext.setOptType("2"); + Map map = new HashMap<>(); + ResponseMessage byId = lawsUserInfoService.getById(busProcessNew.getUserId()); + map.put("LoginName",byId == null ? "" : byId.getData().getAccount()); + JSONObject jsonLoginName = new JSONObject(map); + notifyTodoSendContext.setTargets(jsonLoginName.toJSONString()); + notifyTodoSendContext.setUserId(busProcessNew.getUserId()); + notifyTodoSendContexts.add(notifyTodoSendContext); + Map objectMap = new TreeMap<>(); + objectMap.put("todoId",busProcessNew.getId()); + objectMap.put("list",notifyTodoSendContexts); + net.sf.json.JSONObject jsonObject = net.sf.json.JSONObject.fromObject(objectMap); + oaService.setTodoDeleteMq(jsonObject.toString()); + log.info("=================ESP 发送删除待办任务 及 再次发送待办:"+jsonObject.toString()); + + // 重新发送OA待办 + object.setUserId(assignee); + oaService.sendTodoMq(object); + } + } } /** @@ -190,234 +190,234 @@ public class WebServiceOAServiceImpl implements WebServiceOAService { CreateMQService oaService = SpringContextUtil.getBean(CreateMQService.class); log.info("--------------------------ESP 批量发送删除待办任务----------------------------"); -// QueryWrapper queryWrapper1 = new QueryWrapper(); -// queryWrapper1.eq("P_ID",pId); -// List list = iBusProcessNewService.list(queryWrapper1); -// if(!list.isEmpty()){ -// List notifyTodoSendContexts = new ArrayList<>(); -// list.forEach(busProcessNew -> { -// NotifyTodoSendContext notifyTodoSendContext = new NotifyTodoSendContext(); -// notifyTodoSendContext.setAppName("SPRS"); -// notifyTodoSendContext.setModelId(busProcessNew.getId()); -// notifyTodoSendContext.setModelName(busProcessNew.getTaskInfo()); -// notifyTodoSendContext.setType("1"); -// notifyTodoSendContext.setOptType("2"); -// Map map = new HashMap<>(); -// ResponseMessage byId = lawsUserInfoService.getById(busProcessNew.getUserId()); -// map.put("LoginName",byId == null ? "" : byId.getData().getAccount()); -// JSONObject jsonLoginName = new JSONObject(map); -// notifyTodoSendContext.setTargets(jsonLoginName.toJSONString()); -// notifyTodoSendContext.setUserId(busProcessNew.getUserId()); -// notifyTodoSendContexts.add(notifyTodoSendContext); -// }); -// for (NotifyTodoSendContext data: notifyTodoSendContexts){ -// List notifyTodoSendContextArrayList = new ArrayList<>(); -// notifyTodoSendContextArrayList.add(data); -// Map map = new TreeMap<>(); -// map.put("todoId",pId); -// map.put("list",notifyTodoSendContextArrayList); -// net.sf.json.JSONObject jsonObject = net.sf.json.JSONObject.fromObject(map); -// log.info("调用MQ数据!!!:"+jsonObject.toString()); -// OASendLog oaSendLog = new OASendLog(); -// oaSendLog.setType("delete"); -// oaSendLog.setCreateTime(new Date()); -// oaSendLog.setMeans("deleteOAByPid"); -// oaSendLog.setMsgLog(jsonObject.toString()); -// oaSendLogService.addOASendLog(oaSendLog); -// oaService.setTodoDeleteMq(jsonObject.toString()); -// } -// } + QueryWrapper queryWrapper1 = new QueryWrapper(); + queryWrapper1.eq("P_ID",pId); + List list = iBusProcessNewService.list(queryWrapper1); + if(!list.isEmpty()){ + List notifyTodoSendContexts = new ArrayList<>(); + list.forEach(busProcessNew -> { + NotifyTodoSendContext notifyTodoSendContext = new NotifyTodoSendContext(); + notifyTodoSendContext.setAppName("SPRS"); + notifyTodoSendContext.setModelId(busProcessNew.getId()); + notifyTodoSendContext.setModelName(busProcessNew.getTaskInfo()); + notifyTodoSendContext.setType("1"); + notifyTodoSendContext.setOptType("2"); + Map map = new HashMap<>(); + ResponseMessage byId = lawsUserInfoService.getById(busProcessNew.getUserId()); + map.put("LoginName",byId == null ? "" : byId.getData().getAccount()); + JSONObject jsonLoginName = new JSONObject(map); + notifyTodoSendContext.setTargets(jsonLoginName.toJSONString()); + notifyTodoSendContext.setUserId(busProcessNew.getUserId()); + notifyTodoSendContexts.add(notifyTodoSendContext); + }); + for (NotifyTodoSendContext data: notifyTodoSendContexts){ + List notifyTodoSendContextArrayList = new ArrayList<>(); + notifyTodoSendContextArrayList.add(data); + Map map = new TreeMap<>(); + map.put("todoId",pId); + map.put("list",notifyTodoSendContextArrayList); + net.sf.json.JSONObject jsonObject = net.sf.json.JSONObject.fromObject(map); + log.info("调用MQ数据!!!:"+jsonObject.toString()); + OASendLog oaSendLog = new OASendLog(); + oaSendLog.setType("delete"); + oaSendLog.setCreateTime(new Date()); + oaSendLog.setMeans("deleteOAByPid"); + oaSendLog.setMsgLog(jsonObject.toString()); + oaSendLogService.addOASendLog(oaSendLog); + oaService.setTodoDeleteMq(jsonObject.toString()); + } + } } @Override @Async public NotifyTodoAppDeleteResult setTodoDelete(String object) throws Exception{ -// Map objectMap = net.sf.json.JSONObject.fromObject(object); -// List notifyTodoSendContexts = JSONObject.parseArray(objectMap.get("list").toString(), NotifyTodoSendContext.class); -// NotifyTodoAppDeleteResult notifyTodoAppResult = new NotifyTodoAppDeleteResult(); -// String result = ""; -// SimpleDateFormat sdf=new SimpleDateFormat("yyy-MM-dd HH:mm:ss"); -// -// JsonSend jsonSend = new JsonSend(); -// HEAD head = new HEAD(); -// head.setACCOUNT("OA"); -// head.setBIZTRANSACTIONID("SYC_161320210206133219"); -// head.setCONSUMER("SPRS"); -// head.setCOUNT("1"); -// head.setPASSWORD("TEST_oa201611241710"); -// head.setSRVLEVEL("1"); -// List list = new ArrayList<>(); -// list.addAll(notifyTodoSendContexts); -// jsonSend.setHEAD(head); -// jsonSend.setLIST(list); -// net.sf.json.JSONObject json = net.sf.json.JSONObject.fromObject(jsonSend); -// Map mapCtr = new TreeMap<>(); -// mapCtr.put("Authorization",credentials); -// log.info("处理完文件数据,开始请求发送删除接口数据:【"+sdf.format(new Date())+"】"); -// log.info("删除当前处理的文件数据(josnSend):"+jsonSend.toString()); -// log.info("删除当前处理的文件数据(Object):"+object); -// result = okHttpUtil.postForJson("https://fesbnew.foton.com.cn/WP_FOTON_FSOA/APP_DOC_SERVICES/Proxy_Services/TA_OA/DOC_SYC_1020_SendRemoveTodo_PS",json.toString(),mapCtr); -// log.info("请求发送删除接口完毕,返回响应状态:【"+sdf.format(new Date())+"】"); -//// JSONObject jsonObject = JSONObject.parseObject(result); -// if(!result.contains("操作成功")){ -// log.error("请求发送删除接口出现异常:"+result); -// notifyTodoAppResult.setSign("1"); -// notifyTodoAppResult.setMassage(result); -// log.info("删除失败当前处理的文件数据(josnSend):"+jsonSend.toString()); -// log.info("删除失败当前处理的文件数据(Object):"+object); -// }else { -// log.info("--------------------------成功发送 ESP 删除待办 "+object+"----------------------------"); -// log.info("okHttp请求发送删除接口成功结果:"+result); -// notifyTodoAppResult = (NotifyTodoAppDeleteResult) net.sf.json.JSONObject.toBean(net.sf.json.JSONObject.fromObject(result), NotifyTodoAppDeleteResult.class); -// } + Map objectMap = net.sf.json.JSONObject.fromObject(object); + List notifyTodoSendContexts = JSONObject.parseArray(objectMap.get("list").toString(), NotifyTodoSendContext.class); + NotifyTodoAppDeleteResult notifyTodoAppResult = new NotifyTodoAppDeleteResult(); + String result = ""; + SimpleDateFormat sdf=new SimpleDateFormat("yyy-MM-dd HH:mm:ss"); + + JsonSend jsonSend = new JsonSend(); + HEAD head = new HEAD(); + head.setACCOUNT("OA"); + head.setBIZTRANSACTIONID("SYC_161320210206133219"); + head.setCONSUMER("SPRS"); + head.setCOUNT("1"); + head.setPASSWORD("TEST_oa201611241710"); + head.setSRVLEVEL("1"); + List list = new ArrayList<>(); + list.addAll(notifyTodoSendContexts); + jsonSend.setHEAD(head); + jsonSend.setLIST(list); + net.sf.json.JSONObject json = net.sf.json.JSONObject.fromObject(jsonSend); + Map mapCtr = new TreeMap<>(); + mapCtr.put("Authorization",credentials); + log.info("处理完文件数据,开始请求发送删除接口数据:【"+sdf.format(new Date())+"】"); + log.info("删除当前处理的文件数据(josnSend):"+jsonSend.toString()); + log.info("删除当前处理的文件数据(Object):"+object); + result = okHttpUtil.postForJson("https://fesbnew.foton.com.cn/WP_FOTON_FSOA/APP_DOC_SERVICES/Proxy_Services/TA_OA/DOC_SYC_1020_SendRemoveTodo_PS",json.toString(),mapCtr); + log.info("请求发送删除接口完毕,返回响应状态:【"+sdf.format(new Date())+"】"); +// JSONObject jsonObject = JSONObject.parseObject(result); + if(!result.contains("操作成功")){ + log.error("请求发送删除接口出现异常:"+result); + notifyTodoAppResult.setSign("1"); + notifyTodoAppResult.setMassage(result); + log.info("删除失败当前处理的文件数据(josnSend):"+jsonSend.toString()); + log.info("删除失败当前处理的文件数据(Object):"+object); + }else { + log.info("--------------------------成功发送 ESP 删除待办 "+object+"----------------------------"); + log.info("okHttp请求发送删除接口成功结果:"+result); + notifyTodoAppResult = (NotifyTodoAppDeleteResult) net.sf.json.JSONObject.toBean(net.sf.json.JSONObject.fromObject(result), NotifyTodoAppDeleteResult.class); + } // try { // // } catch (Exception e) { // log.error(errMes, e.getMessage()); // } - return null; + return notifyTodoAppResult; } @Override @Async public void completeOA(Task task){ -// CreateMQService oaService = SpringContextUtil.getBean(CreateMQService.class); -// log.info("--------------------------ESP 发送已办任务----------------------------"); -// SimpleDateFormat sdf = new SimpleDateFormat("yyy-MM-dd HH:mm:ss"); -// NotifyTodoSendContext notifyTodoSendContext = new NotifyTodoSendContext(); -// notifyTodoSendContext.setAppName("SPRS"); -// notifyTodoSendContext.setCreateTime(sdf.format(new Date())); -// -// QueryWrapper queryWrapper1 = new QueryWrapper(); -// queryWrapper1.eq("P_ID",task.getProcessInstanceId()); -// queryWrapper1.eq("TASK_ID",task.getId()); -// List list = iBusProcessNewService.list(queryWrapper1); -// if(!list.isEmpty()){ -// notifyTodoSendContext.setModelId(list.get(0).getId()); -// notifyTodoSendContext.setModelName(task.getName()); -// notifyTodoSendContext.setOptType("1"); -// Map map = new HashMap<>(); -// ResponseMessage byId = lawsUserInfoService.getById(task.getAssignee()); -// map.put("LoginName",byId == null ? "" : byId.getData().getAccount()); -// JSONObject jsonLoginName = new JSONObject(map); -// notifyTodoSendContext.setTargets(jsonLoginName.toJSONString()); -// notifyTodoSendContext.setUserId(task.getAssignee()); -// oaService.setTodoDoneMq(notifyTodoSendContext); -// } + CreateMQService oaService = SpringContextUtil.getBean(CreateMQService.class); + log.info("--------------------------ESP 发送已办任务----------------------------"); + SimpleDateFormat sdf = new SimpleDateFormat("yyy-MM-dd HH:mm:ss"); + NotifyTodoSendContext notifyTodoSendContext = new NotifyTodoSendContext(); + notifyTodoSendContext.setAppName("SPRS"); + notifyTodoSendContext.setCreateTime(sdf.format(new Date())); + + QueryWrapper queryWrapper1 = new QueryWrapper(); + queryWrapper1.eq("P_ID",task.getProcessInstanceId()); + queryWrapper1.eq("TASK_ID",task.getId()); + List list = iBusProcessNewService.list(queryWrapper1); + if(!list.isEmpty()){ + notifyTodoSendContext.setModelId(list.get(0).getId()); + notifyTodoSendContext.setModelName(task.getName()); + notifyTodoSendContext.setOptType("1"); + Map map = new HashMap<>(); + ResponseMessage byId = lawsUserInfoService.getById(task.getAssignee()); + map.put("LoginName",byId == null ? "" : byId.getData().getAccount()); + JSONObject jsonLoginName = new JSONObject(map); + notifyTodoSendContext.setTargets(jsonLoginName.toJSONString()); + notifyTodoSendContext.setUserId(task.getAssignee()); + oaService.setTodoDoneMq(notifyTodoSendContext); + } } @Override @Async public NotifyTodoAppResult setTodoDone(NotifyTodoSendContext notifyTodoSendContext) throws Exception{ -// NotifyTodoAppResult notifyTodoAppResult = new NotifyTodoAppResult(); -// String result = ""; -// SimpleDateFormat sdf=new SimpleDateFormat("yyy-MM-dd HH:mm:ss"); -// -// JsonSend jsonSend = new JsonSend(); -// HEAD head = new HEAD(); -// head.setACCOUNT("OA"); -// head.setBIZTRANSACTIONID("SYC_161320210206133219"); -// head.setCONSUMER("SPRS"); -// head.setCOUNT("1"); -// head.setPASSWORD("oa201611241710"); -// head.setSRVLEVEL("1"); -// List list = new ArrayList<>(); -// list.add(notifyTodoSendContext); -// jsonSend.setHEAD(head); -// jsonSend.setLIST(list); -// net.sf.json.JSONObject json = net.sf.json.JSONObject.fromObject(jsonSend); -// Map mapCtr = new TreeMap<>(); -// mapCtr.put("Authorization",credentials); -// log.info("处理完文件数据,开始请求发送已办接口数据:【"+sdf.format(new Date())+"】"); -// log.info("Done当前处理的文件数据(josnSend):"+jsonSend.toString()); -// log.info("Done当前处理的文件数据(notifyTodoSendContext):"+notifyTodoSendContext.toString()); -// result = okHttpUtil.postForJson("https://fesbnew.foton.com.cn/WP_FOTON_FSOA/APP_DOC_SERVICES/Proxy_Services/TA_OA/DOC_SYC_1021_SendNotifyTodo_PS",json.toString(),mapCtr); -// log.info("请求发送已办接口完毕,返回响应状态:【"+sdf.format(new Date())+"】"); -//// JSONObject jsonObject = JSONObject.parseObject(result); -// if(!result.contains("操作成功")){ -// log.error("请求发送已办接口出现异常:"+result); -// log.info("Done当前处理的文件数据(josnSend):"+jsonSend.toString()); -// log.info("Done当前处理的文件数据(notifyTodoSendContext):"+notifyTodoSendContext.toString()); -// notifyTodoAppResult.setSIGN("1"); -// notifyTodoAppResult.setMASSAGE(result); -// }else { -// log.info("--------------------------成功发送 ESP 已办 模块ID"+notifyTodoSendContext.getModelId()+"----------------------------"); -// log.info("okHttp请求发送已办接口成功结果:"+result); -// notifyTodoAppResult = (NotifyTodoAppResult) net.sf.json.JSONObject.toBean(net.sf.json.JSONObject.fromObject(result), NotifyTodoAppResult.class); -// } + NotifyTodoAppResult notifyTodoAppResult = new NotifyTodoAppResult(); + String result = ""; + SimpleDateFormat sdf=new SimpleDateFormat("yyy-MM-dd HH:mm:ss"); + + JsonSend jsonSend = new JsonSend(); + HEAD head = new HEAD(); + head.setACCOUNT("OA"); + head.setBIZTRANSACTIONID("SYC_161320210206133219"); + head.setCONSUMER("SPRS"); + head.setCOUNT("1"); + head.setPASSWORD("oa201611241710"); + head.setSRVLEVEL("1"); + List list = new ArrayList<>(); + list.add(notifyTodoSendContext); + jsonSend.setHEAD(head); + jsonSend.setLIST(list); + net.sf.json.JSONObject json = net.sf.json.JSONObject.fromObject(jsonSend); + Map mapCtr = new TreeMap<>(); + mapCtr.put("Authorization",credentials); + log.info("处理完文件数据,开始请求发送已办接口数据:【"+sdf.format(new Date())+"】"); + log.info("Done当前处理的文件数据(josnSend):"+jsonSend.toString()); + log.info("Done当前处理的文件数据(notifyTodoSendContext):"+notifyTodoSendContext.toString()); + result = okHttpUtil.postForJson("https://fesbnew.foton.com.cn/WP_FOTON_FSOA/APP_DOC_SERVICES/Proxy_Services/TA_OA/DOC_SYC_1021_SendNotifyTodo_PS",json.toString(),mapCtr); + log.info("请求发送已办接口完毕,返回响应状态:【"+sdf.format(new Date())+"】"); +// JSONObject jsonObject = JSONObject.parseObject(result); + if(!result.contains("操作成功")){ + log.error("请求发送已办接口出现异常:"+result); + log.info("Done当前处理的文件数据(josnSend):"+jsonSend.toString()); + log.info("Done当前处理的文件数据(notifyTodoSendContext):"+notifyTodoSendContext.toString()); + notifyTodoAppResult.setSIGN("1"); + notifyTodoAppResult.setMASSAGE(result); + }else { + log.info("--------------------------成功发送 ESP 已办 模块ID"+notifyTodoSendContext.getModelId()+"----------------------------"); + log.info("okHttp请求发送已办接口成功结果:"+result); + notifyTodoAppResult = (NotifyTodoAppResult) net.sf.json.JSONObject.toBean(net.sf.json.JSONObject.fromObject(result), NotifyTodoAppResult.class); + } // try { // // } catch (Exception e) { // log.error(errMes, e.getMessage()); // } - return null; + return notifyTodoAppResult; } @Override @Async public NotifyTodoAppResult sendTodo(BusProcessNew busProcessNew) throws Exception{ -// NotifyTodoAppResult notifyTodoAppResult = new NotifyTodoAppResult(); -// String result = ""; -// SimpleDateFormat sdf=new SimpleDateFormat("yyy-MM-dd HH:mm:ss"); -// JsonSend jsonSend = new JsonSend(); -// HEAD head = new HEAD(); -// head.setACCOUNT("OA"); -// head.setBIZTRANSACTIONID("SYC_161320210206133219"); -// head.setCONSUMER("SPRS"); -// head.setCOUNT("1"); -// head.setPASSWORD("oa201611241710"); -// head.setSRVLEVEL("1"); -// List list = new ArrayList<>(); -// NotifyTodoSendContext notifyTodoSendContext = new NotifyTodoSendContext(); -// // 待办来源的系统 -// notifyTodoSendContext.setAppName("SPRS"); -// //创建时间 -// notifyTodoSendContext.setCreateTime(sdf.format(new Date())); -// // 待办在原系统唯一标识 -// notifyTodoSendContext.setModelId(busProcessNew.getId()); -// //模块名称 -// notifyTodoSendContext.setModelName(busProcessNew.getTaskInfo()); -// //标题 -// notifyTodoSendContext.setSubject(busProcessNew.getPrcName()); -// //地址 -// QueryWrapper queryWrapper = new QueryWrapper(); -// queryWrapper.eq("PRC_ID", busProcessNew.getPId()); -// BusProcessName busProcessName = iBusProcessNameService.getOne(queryWrapper); -// String linkParam = "&taskIds="+busProcessNew.getTaskId()+"&prcId="+busProcessNew.getPId()+"&prcNum="+busProcessName.getPrcNum()+"&prcName="+busProcessNew.getPrcName(); -// notifyTodoSendContext.setLink(webUrl+busProcessNew.getLink()+linkParam); -// //待办类型 -// notifyTodoSendContext.setType("1"); -// -// Map map = new HashMap<>(); -// ResponseMessage byId = lawsUserInfoService.getById(busProcessNew.getUserId()); -// map.put("LoginName",byId == null ? "" : byId.getData().getAccount()); -// JSONObject jsonLoginName = new JSONObject(map); -// notifyTodoSendContext.setTargets(jsonLoginName.toJSONString()); -// list.add(notifyTodoSendContext); -// jsonSend.setHEAD(head); -// jsonSend.setLIST(list); -// net.sf.json.JSONObject json = net.sf.json.JSONObject.fromObject(jsonSend); -// Map mapCtr = new TreeMap<>(); -// mapCtr.put("Authorization",credentials); -// log.info("处理完文件数据,开始请求发送待办接口数据:【"+sdf.format(new Date())+"】"); -// log.info("sendTodo当前处理的文件数据(josnSend):"+jsonSend.toString()); -// log.info("sendTodo当前处理的文件数据(notifyTodoSendContext):"+notifyTodoSendContext.toString()); -// result = okHttpUtil.postForJson("https://fesbnew.foton.com.cn/WP_FOTON_FSOA/APP_DOC_SERVICES/Proxy_Services/TA_OA/DOC_SYC_1019_SendTodo_PS",json.toString(),mapCtr); -// log.info("请求发送待办接口完毕,返回响应状态:【"+sdf.format(new Date())+"】"); -//// JSONObject jsonObject = JSONObject.parseObject(result); -// if(!result.contains("操作成功")){ -// log.error("请求发送待办接口出现异常:"+result); -// log.info("sendTodo当前处理的文件数据(josnSend):"+jsonSend.toString()); -// log.info("sendTodo当前处理的文件数据(notifyTodoSendContext):"+notifyTodoSendContext.toString()); -// notifyTodoAppResult.setSIGN("1"); -// notifyTodoAppResult.setMASSAGE(result); -// }else { -// log.info("okHttp请求发送待办接口成功结果:"+result); -// notifyTodoAppResult = (NotifyTodoAppResult) net.sf.json.JSONObject.toBean(net.sf.json.JSONObject.fromObject(result), NotifyTodoAppResult.class); -// } + NotifyTodoAppResult notifyTodoAppResult = new NotifyTodoAppResult(); + String result = ""; + SimpleDateFormat sdf=new SimpleDateFormat("yyy-MM-dd HH:mm:ss"); + JsonSend jsonSend = new JsonSend(); + HEAD head = new HEAD(); + head.setACCOUNT("OA"); + head.setBIZTRANSACTIONID("SYC_161320210206133219"); + head.setCONSUMER("SPRS"); + head.setCOUNT("1"); + head.setPASSWORD("oa201611241710"); + head.setSRVLEVEL("1"); + List list = new ArrayList<>(); + NotifyTodoSendContext notifyTodoSendContext = new NotifyTodoSendContext(); + // 待办来源的系统 + notifyTodoSendContext.setAppName("SPRS"); + //创建时间 + notifyTodoSendContext.setCreateTime(sdf.format(new Date())); + // 待办在原系统唯一标识 + notifyTodoSendContext.setModelId(busProcessNew.getId()); + //模块名称 + notifyTodoSendContext.setModelName(busProcessNew.getTaskInfo()); + //标题 + notifyTodoSendContext.setSubject(busProcessNew.getPrcName()); + //地址 + QueryWrapper queryWrapper = new QueryWrapper(); + queryWrapper.eq("PRC_ID", busProcessNew.getPId()); + BusProcessName busProcessName = iBusProcessNameService.getOne(queryWrapper); + String linkParam = "&taskIds="+busProcessNew.getTaskId()+"&prcId="+busProcessNew.getPId()+"&prcNum="+busProcessName.getPrcNum()+"&prcName="+busProcessNew.getPrcName(); + notifyTodoSendContext.setLink(webUrl+busProcessNew.getLink()+linkParam); + //待办类型 + notifyTodoSendContext.setType("1"); + + Map map = new HashMap<>(); + ResponseMessage byId = lawsUserInfoService.getById(busProcessNew.getUserId()); + map.put("LoginName",byId == null ? "" : byId.getData().getAccount()); + JSONObject jsonLoginName = new JSONObject(map); + notifyTodoSendContext.setTargets(jsonLoginName.toJSONString()); + list.add(notifyTodoSendContext); + jsonSend.setHEAD(head); + jsonSend.setLIST(list); + net.sf.json.JSONObject json = net.sf.json.JSONObject.fromObject(jsonSend); + Map mapCtr = new TreeMap<>(); + mapCtr.put("Authorization",credentials); + log.info("处理完文件数据,开始请求发送待办接口数据:【"+sdf.format(new Date())+"】"); + log.info("sendTodo当前处理的文件数据(josnSend):"+jsonSend.toString()); + log.info("sendTodo当前处理的文件数据(notifyTodoSendContext):"+notifyTodoSendContext.toString()); + result = okHttpUtil.postForJson("https://fesbnew.foton.com.cn/WP_FOTON_FSOA/APP_DOC_SERVICES/Proxy_Services/TA_OA/DOC_SYC_1019_SendTodo_PS",json.toString(),mapCtr); + log.info("请求发送待办接口完毕,返回响应状态:【"+sdf.format(new Date())+"】"); +// JSONObject jsonObject = JSONObject.parseObject(result); + if(!result.contains("操作成功")){ + log.error("请求发送待办接口出现异常:"+result); + log.info("sendTodo当前处理的文件数据(josnSend):"+jsonSend.toString()); + log.info("sendTodo当前处理的文件数据(notifyTodoSendContext):"+notifyTodoSendContext.toString()); + notifyTodoAppResult.setSIGN("1"); + notifyTodoAppResult.setMASSAGE(result); + }else { + log.info("okHttp请求发送待办接口成功结果:"+result); + notifyTodoAppResult = (NotifyTodoAppResult) net.sf.json.JSONObject.toBean(net.sf.json.JSONObject.fromObject(result), NotifyTodoAppResult.class); + } // try { // // @@ -425,7 +425,7 @@ public class WebServiceOAServiceImpl implements WebServiceOAService { // log.error(errMes, e.getMessage()); // } - return null; + return notifyTodoAppResult; } /** @@ -434,45 +434,45 @@ public class WebServiceOAServiceImpl implements WebServiceOAService { */ @Async public void deleteOAByPidInfo(String pId){ -// CreateMQService oaService = SpringContextUtil.getBean(CreateMQService.class); -// log.info("--------------------------ESP 批量发送删除待办任务----------------------------"); -// -// QueryWrapper queryWrapper1 = new QueryWrapper(); -// queryWrapper1.eq("P_ID",pId); -// List list = iBusProcessNewService.list(queryWrapper1); -// if(!list.isEmpty()){ -// List notifyTodoSendContexts = new ArrayList<>(); -// list.forEach(busProcessNew -> { -// NotifyTodoSendContext notifyTodoSendContext = new NotifyTodoSendContext(); -// notifyTodoSendContext.setAppName("SPRS"); -// notifyTodoSendContext.setModelId(busProcessNew.getId()); -// notifyTodoSendContext.setModelName("技术标准起草"); -// notifyTodoSendContext.setType("1"); -// notifyTodoSendContext.setOptType("2"); -// Map map = new HashMap<>(); -// ResponseMessage byId = lawsUserInfoService.getById(busProcessNew.getUserId()); -// map.put("LoginName",byId == null ? "" : byId.getData().getAccount()); -// JSONObject jsonLoginName = new JSONObject(map); -// notifyTodoSendContext.setTargets(jsonLoginName.toJSONString()); -// notifyTodoSendContext.setUserId(busProcessNew.getUserId()); -// notifyTodoSendContexts.add(notifyTodoSendContext); -// }); -// for (NotifyTodoSendContext data: notifyTodoSendContexts){ -// List notifyTodoSendContextArrayList = new ArrayList<>(); -// notifyTodoSendContextArrayList.add(data); -// Map map = new TreeMap<>(); -// map.put("todoId",pId); -// map.put("list",notifyTodoSendContextArrayList); -// net.sf.json.JSONObject jsonObject = net.sf.json.JSONObject.fromObject(map); -// log.info("调用MQ数据!!!:"+jsonObject.toString()); -// OASendLog oaSendLog = new OASendLog(); -// oaSendLog.setType("delete"); -// oaSendLog.setCreateTime(new Date()); -// oaSendLog.setMeans("deleteOAByPid"); -// oaSendLog.setMsgLog(jsonObject.toString()); -// oaSendLogService.addOASendLog(oaSendLog); -// oaService.setTodoDeleteMq(jsonObject.toString()); -// } -// } + CreateMQService oaService = SpringContextUtil.getBean(CreateMQService.class); + log.info("--------------------------ESP 批量发送删除待办任务----------------------------"); + + QueryWrapper queryWrapper1 = new QueryWrapper(); + queryWrapper1.eq("P_ID",pId); + List list = iBusProcessNewService.list(queryWrapper1); + if(!list.isEmpty()){ + List notifyTodoSendContexts = new ArrayList<>(); + list.forEach(busProcessNew -> { + NotifyTodoSendContext notifyTodoSendContext = new NotifyTodoSendContext(); + notifyTodoSendContext.setAppName("SPRS"); + notifyTodoSendContext.setModelId(busProcessNew.getId()); + notifyTodoSendContext.setModelName("技术标准起草"); + notifyTodoSendContext.setType("1"); + notifyTodoSendContext.setOptType("2"); + Map map = new HashMap<>(); + ResponseMessage byId = lawsUserInfoService.getById(busProcessNew.getUserId()); + map.put("LoginName",byId == null ? "" : byId.getData().getAccount()); + JSONObject jsonLoginName = new JSONObject(map); + notifyTodoSendContext.setTargets(jsonLoginName.toJSONString()); + notifyTodoSendContext.setUserId(busProcessNew.getUserId()); + notifyTodoSendContexts.add(notifyTodoSendContext); + }); + for (NotifyTodoSendContext data: notifyTodoSendContexts){ + List notifyTodoSendContextArrayList = new ArrayList<>(); + notifyTodoSendContextArrayList.add(data); + Map map = new TreeMap<>(); + map.put("todoId",pId); + map.put("list",notifyTodoSendContextArrayList); + net.sf.json.JSONObject jsonObject = net.sf.json.JSONObject.fromObject(map); + log.info("调用MQ数据!!!:"+jsonObject.toString()); + OASendLog oaSendLog = new OASendLog(); + oaSendLog.setType("delete"); + oaSendLog.setCreateTime(new Date()); + oaSendLog.setMeans("deleteOAByPid"); + oaSendLog.setMsgLog(jsonObject.toString()); + oaSendLogService.addOASendLog(oaSendLog); + oaService.setTodoDeleteMq(jsonObject.toString()); + } + } } }