From 71060ebaca69a4f4ad0f2504ba58183720626c50 Mon Sep 17 00:00:00 2001 From: shilei <798989044@qq.com> Date: Mon, 8 Apr 2024 19:31:02 +0800 Subject: [PATCH] =?UTF-8?q?#E10-20#=20=E7=BE=A4=E8=81=8A=E6=95=B0=E9=87=8F?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/HrmSelfHelpController.java | 138 ++++-- .../jcldoor/util/JucailinPortalUtils.java | 392 +++++++++++++++++- 2 files changed, 495 insertions(+), 35 deletions(-) diff --git a/src/main/java/com/weaver/seconddev/jcldoor/controller/HrmSelfHelpController.java b/src/main/java/com/weaver/seconddev/jcldoor/controller/HrmSelfHelpController.java index 92056b8..3433070 100644 --- a/src/main/java/com/weaver/seconddev/jcldoor/controller/HrmSelfHelpController.java +++ b/src/main/java/com/weaver/seconddev/jcldoor/controller/HrmSelfHelpController.java @@ -1,11 +1,12 @@ package com.weaver.seconddev.jcldoor.controller; import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; import com.weaver.common.authority.annotation.WeaPermission; import com.weaver.common.base.entity.result.WeaResult; import com.weaver.ebuilder.datasource.api.entity.SqlParamEntity; import com.weaver.ebuilder.datasource.api.enums.SqlParamType; -import com.weaver.ebuilder.form.client.entity.obj.Obj; import com.weaver.framework.remote.client.rest.RestClient; import com.weaver.framework.rpc.annotation.RpcReference; import com.weaver.mc.api.async.AsyncSystemMessageRest; @@ -145,7 +146,9 @@ public class HrmSelfHelpController { Map dataMap = new HashMap(); dataMap.put("test","testSapi15"); try { - Map dMap = jucailinPortalUtils.getChatGroup(); + String tablename = "uf_nj_cyqltjb" ; + dataMap.put("tablename",tablename); + Map dMap = jucailinPortalUtils.getChatGroup(tenant_key,tablename); dataMap.putAll(dMap); } catch (Exception e) { e.printStackTrace(); @@ -163,7 +166,9 @@ public class HrmSelfHelpController { Map dataMap = new HashMap(); dataMap.put("test","testSapi16"); try { - Map dMap = jucailinPortalUtils.getChatDay(); + String tablename = "uf_nj_pjmrdlhhsl" ; + dataMap.put("tablename",tablename); + Map dMap = jucailinPortalUtils.getChatDay(tenant_key,tablename); dataMap.putAll(dMap); } catch (Exception e) { e.printStackTrace(); @@ -1269,32 +1274,53 @@ public class HrmSelfHelpController { //com.weaver.workrelate.performance.api.rest.RemotePerformanceService#queryFlowData + String groupId = "weaver-ebuilder-form-service"; + String sourceType = "LOGIC"; + SimpleEmployee employee = UserContext.getCurrentUser(); + Long cid = employee.getCid(); + long employeeId = employee.getEmployeeId(); + Map dataMap = new HashMap(); dataMap.put("test","testSapi8"); + String tablename = "uf_nj_cyqltjb" ; try { - FlowDataListReq flowDataListReq = new FlowDataListReq(); - flowDataListReq.setCurrent(1); - flowDataListReq.setPageSize(20); - flowDataListReq.setStartTime("2024-01-01"); - flowDataListReq.setEndTime("2024-01-31"); - flowDataListReq.setDateType("month"); - flowDataListReq.setTenantKey("t7akvdnf84"); - List userList = new ArrayList(); - Long employeeId = UserContext.getCurrentEmployeeId(); - userList.add(employeeId); - flowDataListReq.setUserList(userList); - FlowData flowData = remotePerformanceService.queryFlowData(flowDataListReq); - - Long total = flowData.getTotal(); - dataMap.put("total",total+""); - List flowDataList = flowData.getDataList(); - for(int i = 0 ;i sqlparam = new ArrayList(); + SqlParamEntity sqlParamEntity = new SqlParamEntity(); + sqlParamEntity.setParamType(SqlParamType.VARCHAR); + sqlParamEntity.setValue(userid+""); + sqlparam.add(sqlParamEntity); + + sqlParamEntity = new SqlParamEntity(); + sqlParamEntity.setParamType(SqlParamType.VARCHAR); + sqlParamEntity.setValue(tenant_key+""); + sqlparam.add(sqlParamEntity); + + Map result = databaseUtils.execute(sourceType, groupId, sql); + List> recordList = databaseUtils.getDataSourceList(result); + if(!recordList.isEmpty()){ + jucailinPortalUtils.updateChatDayDate(userid,amount,sourceType,groupId,tenant_key,tablename); + }else{ + jucailinPortalUtils.insertChatDayDate(userid,amount,employeeId,sourceType,groupId,tenant_key,tablename); + } + + } + } + } } } catch (Exception e) { e.printStackTrace(); @@ -1303,4 +1329,64 @@ public class HrmSelfHelpController { return WeaResult.success(dataMap); } + @GetMapping("/testSapi9") + @WeaPermission(publicPermission = true) + public WeaResult testSapi9(HttpServletRequest request){ + + //com.weaver.workrelate.performance.api.rest.RemotePerformanceService#queryFlowData + + String groupId = "weaver-ebuilder-form-service"; + String sourceType = "LOGIC"; + SimpleEmployee employee = UserContext.getCurrentUser(); + Long cid = employee.getCid(); + long employeeId = employee.getEmployeeId(); + + Map dataMap = new HashMap(); + dataMap.put("test","testSapi9"); + String tablename = "uf_nj_pjmrdlhhsl" ; + try { + String data = "{\"actionMsg\":{\"code\":0,\"message\":\"成功\",\"traceId\":\"1712572288230237829\"},\"data\":{\"count\":11200,\"data\":[{\"userid\":\"100001840000000001\",\"amount\":\"15478\"},{\"userid\":\"732740550661120001\",\"amount\":\"19\"},{\"userid\":\"732740623600066568\",\"amount\":\"1\"},{\"userid\":\"732740838411632644\",\"amount\":\"1\"},{\"userid\":\"732741031760855045\",\"amount\":\"1\"},{\"userid\":\"732742522042859521\",\"amount\":\"2\"},{\"userid\":\"732742595040526345\",\"amount\":\"1\"},{\"userid\":\"732742672291217409\",\"amount\":\"2\"},{\"userid\":\"732742676670070786\",\"amount\":\"3\"},{\"userid\":\"732742745263718407\",\"amount\":\"1\"}]}}"; + JSONObject dataJson = JSONObject.parseObject(data); + JSONObject actionMsg = dataJson.getJSONObject("actionMsg"); + if(actionMsg.containsKey("code")){ + String code = actionMsg.getString("code"); + if("0".equals(code)){ + JSONObject dataObject = dataJson.getJSONObject("data"); + if(dataObject.containsKey("data")){ + JSONArray dataArray = dataObject.getJSONArray("data"); + for(int i=0;i sqlparam = new ArrayList(); + SqlParamEntity sqlParamEntity = new SqlParamEntity(); + sqlParamEntity.setParamType(SqlParamType.VARCHAR); + sqlParamEntity.setValue(userid+""); + sqlparam.add(sqlParamEntity); + + sqlParamEntity = new SqlParamEntity(); + sqlParamEntity.setParamType(SqlParamType.VARCHAR); + sqlParamEntity.setValue(tenant_key+""); + sqlparam.add(sqlParamEntity); + + Map result = databaseUtils.execute(sourceType, groupId, sql); + List> recordList = databaseUtils.getDataSourceList(result); + if(!recordList.isEmpty()){ + jucailinPortalUtils.updateChatDayDate(userid,amount,sourceType,groupId,tenant_key,tablename); + }else{ + jucailinPortalUtils.insertChatDayDate(userid,amount,employeeId,sourceType,groupId,tenant_key,tablename); + } + } + } + } + } + } catch (Exception e) { + e.printStackTrace(); + log.error("testSapi9:"+e); + } + return WeaResult.success(dataMap); + } + } diff --git a/src/main/java/com/weaver/seconddev/jcldoor/util/JucailinPortalUtils.java b/src/main/java/com/weaver/seconddev/jcldoor/util/JucailinPortalUtils.java index db1f681..572337a 100644 --- a/src/main/java/com/weaver/seconddev/jcldoor/util/JucailinPortalUtils.java +++ b/src/main/java/com/weaver/seconddev/jcldoor/util/JucailinPortalUtils.java @@ -1,9 +1,12 @@ package com.weaver.seconddev.jcldoor.util; import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; +import com.weaver.common.distribution.genid.IdGenerator; import com.weaver.ebuilder.datasource.api.entity.SqlParamEntity; import com.weaver.ebuilder.datasource.api.enums.SqlParamType; +import com.weaver.ebuilder.form.client.entity.obj.Obj; import com.weaver.em.msg.api.entity.Request; import com.weaver.em.msg.api.entity.Response; import com.weaver.framework.rpc.annotation.RpcReference; @@ -78,22 +81,26 @@ public class JucailinPortalUtils { * * */ - public Map getChatGroup(){ + public Map getChatGroup(String tenant_key,String tablename){ Map dataMap = new HashMap(); SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); try { - SimpleEmployee employee = UserContext.getCurrentUser(); - Calendar cal = Calendar.getInstance(); - int year = cal.get(Calendar.YEAR); - String startDate = "2020-01-01"; + + String startDate = "2001-01-01"; //设置当前时间 + + Calendar cal = Calendar.getInstance(); cal.setTime(new Date()); //同理增加一天的方法: cal.add(Calendar.DATE, -1); String endDate = format.format(cal.getTime()); + log.error("startDate:"+startDate); log.error("endDate:"+endDate); + + SimpleEmployee employee = UserContext.getCurrentUser(); Long cid = employee.getCid(); + long employeeId = employee.getEmployeeId(); log.error("getChatGroup--cid:"+cid); String pageSize = "10"; @@ -129,35 +136,222 @@ public class JucailinPortalUtils { JSONObject dataObject = dataJson.getJSONObject("data"); String count = dataObject.getString("count"); dataMap.put("count",count); + if(StringUtils.isNotBlank(count)){ + int cou = Integer.parseInt(count); + updateUserChatGroup(cou,cid,startDate,endDate,employeeId,tenant_key,tablename); + } } } } } } catch (Exception e) { e.printStackTrace(); - log.error("testSapi13:"+e); + log.error("getChatGroup:"+e); } return dataMap; } - public Map getChatDay(){ + /*** + * + * @param count + * @param cid + * @param startDate + * @param endDate + * @param employeeId + */ + public void updateUserChatGroup(int count,long cid,String startDate,String endDate,long employeeId,String tenant_key,String tablename){ + int pagesize = 1000; + int num = (int)Math.ceil(count/1000.0); + log.error("updateUserChatGroup-num:"+num); + for(int i=1;i<=num;i++){ + updateUserChatGroup2Mode(cid,startDate,endDate,i,pagesize,employeeId,tenant_key,tablename); + } + } + + + /*** + * + * @param cid + * @param startDate + * @param endDate + * @param pageNum + * @param pageSize + * @param employeeId + */ + public void updateUserChatGroup2Mode(long cid,String startDate,String endDate,int pageNum,int pageSize,long employeeId,String tenant_key,String tablename){ + try { + String groupId = "weaver-ebuilder-form-service"; + String sourceType = "LOGIC"; + + Map json = new HashMap(); + json.put("cid",cid); + json.put("pageNum",pageNum); + json.put("pageSize",pageSize); + json.put("startDate",startDate); + json.put("endDate",endDate); + + log.error("json:"+ JSON.toJSONString(json)); + + Request request = new Request(); + request.setUrl("/user-profile/groupSession"); + request.setParamsMap(json); + request.setAsync(false); + + log.error("request:"+ request.toString()); + Response response = oaRest.executeIm(request); + log.error("getChatGroup--isSuccess"+response.isSuccess()); + log.error("response2:"+ response.toString()); + if (response.isSuccess()){ + String data = response.getData(); + if(StringUtils.isNotBlank(data)){ + JSONObject dataJson = JSONObject.parseObject(data); + JSONObject actionMsg = dataJson.getJSONObject("actionMsg"); + if(actionMsg.containsKey("code")){ + String code = actionMsg.getString("code"); + if("0".equals(code)){ + JSONObject dataObject = dataJson.getJSONObject("data"); + if(dataObject.containsKey("data")){ + JSONArray dataArray = dataObject.getJSONArray("data"); + for(int i=0;i sqlparam = new ArrayList(); + SqlParamEntity sqlParamEntity = new SqlParamEntity(); + sqlParamEntity.setParamType(SqlParamType.VARCHAR); + sqlParamEntity.setValue(userid+""); + sqlparam.add(sqlParamEntity); + + sqlParamEntity = new SqlParamEntity(); + sqlParamEntity.setParamType(SqlParamType.VARCHAR); + sqlParamEntity.setValue(tenant_key+""); + sqlparam.add(sqlParamEntity); + + Map result = databaseUtils.execute(sourceType, groupId, sql); + List> recordList = databaseUtils.getDataSourceList(result); + if(!recordList.isEmpty()){ + updateChatGroupDate(userid,amount,sourceType,groupId,tenant_key,tablename); + }else{ + insertChatGroupDate(userid,amount,employeeId,sourceType,groupId,tenant_key,tablename); + } + } + } + } + } + } + } + } catch (Exception e) { + e.printStackTrace(); + log.error("updateUserChatGroup2Mode:"+e); + } + } + + /*** + * + * @param userid + * @param amount + * @param employeeId + * @param sourceType + * @param groupId + * @param tenant_key + */ + public void insertChatGroupDate(String userid,String amount,long employeeId,String sourceType,String groupId,String tenant_key,String tablename){ + + try { + long generate = IdGenerator.generate(); + String sql =" insert into "+tablename+"(id,ry,amount,form_data_id,data_index,create_time,update_time,tenant_key,is_delete,creator,delete_type) " + + " values (" + generate + "," + userid + ",'"+amount+"'," + generate + ",0,now(),now(),'"+tenant_key+"'," + Character.MIN_VALUE + "," + employeeId + "," + Character.MIN_VALUE + ")"; + Map result = databaseUtils.execute(sourceType, groupId, sql); + Iterator> iterator = result.entrySet().iterator(); + while (iterator.hasNext()){ + Map.Entry next = iterator.next(); + log.error("insertChatDayDate--key="+next.getKey()+" value="+String.valueOf(next.getValue())); + } + + List> recordList = databaseUtils.getDataSourceList(result); + for(int i=0;i map = recordList.get(i); + for (String key:map.keySet()){ + System.out.println("insertChatDayDate222--key= "+key+" and value= "+String.valueOf(map.get(key))); + } + } + }catch (Exception e){ + e.printStackTrace(); + log.error("insertChatGroupDate:"+e); + } + } + + /*** + * + * @param userid + * @param amount + * @param sourceType + * @param groupId + * @param tenant_key + */ + public void updateChatGroupDate(String userid,String amount,String sourceType,String groupId,String tenant_key,String tablename){ + try { + String sql =" update "+tablename+" set amount=?,update_time=now() where ry = ? and tenant_key= ? and delete_type=0 "; + List sqlparam = new ArrayList(); + SqlParamEntity sqlParamEntity = new SqlParamEntity(); + sqlParamEntity.setParamType(SqlParamType.VARCHAR); + sqlParamEntity.setValue(amount+""); + sqlparam.add(sqlParamEntity); + + sqlParamEntity = new SqlParamEntity(); + sqlParamEntity.setParamType(SqlParamType.VARCHAR); + sqlParamEntity.setValue(userid+""); + sqlparam.add(sqlParamEntity); + + sqlParamEntity = new SqlParamEntity(); + sqlParamEntity.setParamType(SqlParamType.VARCHAR); + sqlParamEntity.setValue(tenant_key); + sqlparam.add(sqlParamEntity); + + Map result = databaseUtils.executeForQuery(sourceType, groupId, sql,sqlparam); + Iterator> iterator = result.entrySet().iterator(); + while (iterator.hasNext()){ + Map.Entry next = iterator.next(); + log.error("insertChatDayDate--key="+next.getKey()+" value="+String.valueOf(next.getValue())); + } + + List> recordList = databaseUtils.getDataSourceList(result); + for(int i=0;i map = recordList.get(i); + for (String key:map.keySet()){ + System.out.println("insertChatDayDate222--key= "+key+" and value= "+String.valueOf(map.get(key))); + } + } + }catch (Exception e){ + e.printStackTrace(); + log.error("updateChatGroupDate:"+e); + } + } + + + public Map getChatDay(String tenant_key,String tablename){ Map dataMap = new HashMap(); SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); try { SimpleEmployee employee = UserContext.getCurrentUser(); + + String startDate = "2001-01-01"; + Calendar cal = Calendar.getInstance(); - int year = cal.get(Calendar.YEAR); - String startDate = "2020-01-01"; //设置当前时间 cal.setTime(new Date()); //同理增加一天的方法: cal.add(Calendar.DATE, -1); String endDate = format.format(cal.getTime()); + log.error("startDate:"+startDate); log.error("endDate:"+endDate); Long cid = employee.getCid(); log.error("getChatGroup--cid:"+cid); + Long employeeId = employee.getEmployeeId(); String pageSize = "10"; String pageNum = "1"; @@ -192,6 +386,11 @@ public class JucailinPortalUtils { JSONObject dataObject = dataJson.getJSONObject("data"); String count = dataObject.getString("count"); dataMap.put("count",count); + + if(StringUtils.isNotBlank(count)){ + int cou = Integer.parseInt(count); + updateUserChatDay(cou,cid,startDate,endDate,employeeId,tenant_key,tablename); + } } } } @@ -203,4 +402,179 @@ public class JucailinPortalUtils { return dataMap; } + + public void updateUserChatDay(int count,long cid,String startDate,String endDate,long employeeId,String tenant_key,String tablename){ + int pagesize = 1000; + int num = (int)Math.ceil(count/1000.0); + log.error("updateUserChatGroup-num:"+num); + for(int i=1;i<=num;i++){ + updateUserChatDay2Mode(cid,startDate,endDate,i,pagesize,employeeId,tenant_key,tablename); + } + } + + + /*** + * + * @param cid + * @param startDate + * @param endDate + * @param pageNum + * @param pageSize + * @param employeeId + */ + public void updateUserChatDay2Mode(long cid,String startDate,String endDate,int pageNum,int pageSize,long employeeId,String tenant_key,String tablename){ + try { + String groupId = "weaver-ebuilder-form-service"; + String sourceType = "LOGIC"; + + Map json = new HashMap(); + json.put("cid",cid); + json.put("pageNum",pageNum); + json.put("pageSize",pageSize); + json.put("startDate",startDate); + json.put("endDate",endDate); + + log.error("json:"+ JSON.toJSONString(json)); + + Request request = new Request(); + request.setUrl("/user-profile/groupSession"); + request.setParamsMap(json); + request.setAsync(false); + + log.error("request:"+ request.toString()); + Response response = oaRest.executeIm(request); + log.error("getChatGroup--isSuccess"+response.isSuccess()); + log.error("response2:"+ response.toString()); + if (response.isSuccess()){ + String data = response.getData(); + if(StringUtils.isNotBlank(data)){ + JSONObject dataJson = JSONObject.parseObject(data); + JSONObject actionMsg = dataJson.getJSONObject("actionMsg"); + if(actionMsg.containsKey("code")){ + String code = actionMsg.getString("code"); + if("0".equals(code)){ + JSONObject dataObject = dataJson.getJSONObject("data"); + if(dataObject.containsKey("data")){ + JSONArray dataArray = dataObject.getJSONArray("data"); + for(int i=0;i sqlparam = new ArrayList(); + SqlParamEntity sqlParamEntity = new SqlParamEntity(); + sqlParamEntity.setParamType(SqlParamType.VARCHAR); + sqlParamEntity.setValue(userid+""); + sqlparam.add(sqlParamEntity); + + sqlParamEntity = new SqlParamEntity(); + sqlParamEntity.setParamType(SqlParamType.VARCHAR); + sqlParamEntity.setValue(tenant_key+""); + sqlparam.add(sqlParamEntity); + + Map result = databaseUtils.execute(sourceType, groupId, sql); + List> recordList = databaseUtils.getDataSourceList(result); + if(!recordList.isEmpty()){ + updateChatDayDate(userid,amount,sourceType,groupId,tenant_key,tablename); + }else{ + insertChatDayDate(userid,amount,employeeId,sourceType,groupId,tenant_key,tablename); + } + } + } + } + } + } + } + } catch (Exception e) { + e.printStackTrace(); + log.error("updateUserChatGroup2Mode:"+e); + } + } + + + /*** + * + * @param userid + * @param amount + * @param employeeId + * @param sourceType + * @param groupId + * @param tenant_key + */ + public void insertChatDayDate(String userid,String amount,long employeeId,String sourceType,String groupId,String tenant_key,String tablename){ + + try { + long generate = IdGenerator.generate(); + String sql =" insert into "+tablename+"(id,ry,amount,form_data_id,data_index,create_time,update_time,tenant_key,is_delete,creator,delete_type) " + + " values (" + generate + "," + userid + ",'"+amount+"'," + generate + ",0,now(),now(),'"+tenant_key+"'," + Character.MIN_VALUE + "," + employeeId + "," + Character.MIN_VALUE + ")"; + Map result = databaseUtils.execute(sourceType, groupId, sql); + + Iterator> iterator = result.entrySet().iterator(); + while (iterator.hasNext()){ + Map.Entry next = iterator.next(); + log.error("insertChatDayDate--key="+next.getKey()+" value="+String.valueOf(next.getValue())); + } + + List> recordList = databaseUtils.getDataSourceList(result); + for(int i=0;i map = recordList.get(i); + for (String key:map.keySet()){ + System.out.println("insertChatDayDate222--key= "+key+" and value= "+String.valueOf(map.get(key))); + } + } + }catch (Exception e){ + e.printStackTrace(); + log.error("insertChatGroupDate:"+e); + } + } + + /*** + * + * @param userid + * @param amount + * @param sourceType + * @param groupId + * @param tenant_key + */ + public void updateChatDayDate(String userid,String amount,String sourceType,String groupId,String tenant_key,String tablename){ + try { + String sql =" update "+tablename+" set amount=?,update_time=now() where ry = ? and tenant_key= ? and delete_type=0 "; + List sqlparam = new ArrayList(); + SqlParamEntity sqlParamEntity = new SqlParamEntity(); + sqlParamEntity.setParamType(SqlParamType.VARCHAR); + sqlParamEntity.setValue(amount+""); + sqlparam.add(sqlParamEntity); + + sqlParamEntity = new SqlParamEntity(); + sqlParamEntity.setParamType(SqlParamType.VARCHAR); + sqlParamEntity.setValue(userid+""); + sqlparam.add(sqlParamEntity); + + sqlParamEntity = new SqlParamEntity(); + sqlParamEntity.setParamType(SqlParamType.VARCHAR); + sqlParamEntity.setValue(tenant_key); + sqlparam.add(sqlParamEntity); + + Map result = databaseUtils.executeForQuery(sourceType, groupId, sql,sqlparam); + Iterator> iterator = result.entrySet().iterator(); + while (iterator.hasNext()){ + Map.Entry next = iterator.next(); + log.error("insertChatDayDate--key="+next.getKey()+" value="+String.valueOf(next.getValue())); + } + + List> recordList = databaseUtils.getDataSourceList(result); + for(int i=0;i map = recordList.get(i); + for (String key:map.keySet()){ + System.out.println("insertChatDayDate222--key= "+key+" and value= "+String.valueOf(map.get(key))); + } + } + }catch (Exception e){ + e.printStackTrace(); + log.error("updateChatGroupDate:"+e); + } + } + + }