diff --git a/src/weaver/interfaces/dito/overtime/OfflinePushInfoVo.java b/src/weaver/interfaces/dito/overtime/OfflinePushInfoVo.java new file mode 100644 index 00000000..3e7de9bb --- /dev/null +++ b/src/weaver/interfaces/dito/overtime/OfflinePushInfoVo.java @@ -0,0 +1,24 @@ +package weaver.interfaces.dito.overtime; + +public class OfflinePushInfoVo { + + private String offlinePushTitle; + private String offlinePushDesc; + + public String getOfflinePushTitle() { + return offlinePushTitle; + } + + public void setOfflinePushTitle(String offlinePushTitle) { + this.offlinePushTitle = offlinePushTitle; + } + + public String getOfflinePushDesc() { + return offlinePushDesc; + } + + public void setOfflinePushDesc(String offlinePushDesc) { + this.offlinePushDesc = offlinePushDesc; + } + +} diff --git a/src/weaver/interfaces/dito/overtime/OverTimeMsgBean.java b/src/weaver/interfaces/dito/overtime/OverTimeMsgBean.java new file mode 100644 index 00000000..bab46517 --- /dev/null +++ b/src/weaver/interfaces/dito/overtime/OverTimeMsgBean.java @@ -0,0 +1,35 @@ +package weaver.interfaces.dito.overtime; + +import weaver.interfaces.dito.comInfo.PropBean; + +public class OverTimeMsgBean { + + // /open-apis/contact/v1/staff/dito/batchUserQuery + public static String sendMsgUrl = PropBean.getUfPropValue("OverTimeSendMsgUrl"); + + + // /open-apis/notification/v2/work/send + public static String queryUserUrl = PropBean.getUfPropValue("OverTimeQueryUserUrl"); + + //2022101710170001-8Q0jTlYmb5nT2 + public static String appKey = PropBean.getUfPropValue("OverTimeMsgAppkey"); + + //O5xRZ6djy4c1g268x4eLuszi7qxX8jj + public static String appSecret = PropBean.getUfPropValue("OverTimeMsgAppSecret"); + + //sapp-test-idito.dito.ph:30443 + public static String hostName = PropBean.getUfPropValue("OverTimeHostName"); + + //https + public static String scheme = PropBean.getUfPropValue("OverTimeScheme"); + + // true + public static String ignoreSslCheck = PropBean.getUfPropValue("OverTimeMsgIgnoreSslCheck"); + + // 1 + public static String tenantId = PropBean.getUfPropValue("OverTimeMsgTenantId"); + + + + +} diff --git a/src/weaver/interfaces/dito/overtime/SendMessageResultUtil.java b/src/weaver/interfaces/dito/overtime/SendMessageResultUtil.java new file mode 100644 index 00000000..b2bcdbaf --- /dev/null +++ b/src/weaver/interfaces/dito/overtime/SendMessageResultUtil.java @@ -0,0 +1,111 @@ +package weaver.interfaces.dito.overtime; + +import org.apache.commons.lang3.StringUtils; +import weaver.conn.RecordSet; +import weaver.formmode.setup.ModeRightInfo; +import weaver.general.BaseBean; +import weaver.general.Util; + +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; + +public class SendMessageResultUtil { + /*** + * + * @param lcid + * @param tzry + * @param tzsj + * @param jkdz + * @param xxcs + * @param zh + * @param fhcs + * @param resultcode + * @param resultmsg + */ + public void doRecordOverTimeMsgInfo(String lcid,String lcmc,String tzry,String tzsj,String jkdz,String xxcs,String zh,String fhcs,String resultcode,String resultmsg){ + BaseBean bb = new BaseBean(); + RecordSet rs = new RecordSet(); + bb.writeLog("doRecordOverTimeMsgInfo"); + String uf_table = "uf_overtime_msg" ; + + ModeRightInfo modeRightInfo = new ModeRightInfo(); + modeRightInfo.setNewRight(true); + + if(StringUtils.isNotEmpty(xxcs)){ + xxcs = xxcs.replace("\"","\\\""); + } + + String formmodeid = "" ; + String sql =" select k.id from modeinfo k \n" + + " inner join workflow_bill l on formid = l.id\n" + + " where l.tablename = '"+uf_table+"' " ; + rs.execute(sql); + if(rs.next()){ + formmodeid = Util.null2String(rs.getString("id")); + } + String modedatacreater = "1"; + SimpleDateFormat sdfDate = new SimpleDateFormat("yyyy-MM-dd");//设置日期格式 + SimpleDateFormat sdfTime = new SimpleDateFormat("HH:mm:ss");//设置日期格式 + String modedatacreatedate = sdfDate.format(new Date()); + String modedatacreatetime = sdfTime.format(new Date()); + String modedatacreatertype = "0"; + String uuid = UUID.randomUUID().toString(); + + + Map mainMap = new HashMap(); + mainMap.put("lcid",lcid); + mainMap.put("lcmc",lcmc); + mainMap.put("tzry",tzry); + mainMap.put("tzsj",tzsj); + mainMap.put("jkdz",jkdz); + mainMap.put("xxcs",xxcs); + mainMap.put("zh",zh); + mainMap.put("fhcs",fhcs); + mainMap.put("resultcode",resultcode); + mainMap.put("resultmsg",resultmsg); + mainMap.put("formmodeid",formmodeid); + mainMap.put("modedatacreater",modedatacreater); + mainMap.put("modedatacreatertype",modedatacreatertype); + mainMap.put("modedatacreatedate",modedatacreatedate); + mainMap.put("modedatacreatetime",modedatacreatetime); + mainMap.put("uuid",uuid); + + String tablename = "" ; + String tablenvalue = "" ; + for (Map.Entry entry : mainMap.entrySet()) + { + String fieldname = Util.null2String(entry.getKey()).trim(); + String fieldvalue = Util.null2String(entry.getValue()).replace("'", "''").trim(); + tablename += tablename==""? fieldname :","+fieldname ; + tablenvalue += tablenvalue=="" ? "'"+fieldvalue+"'" :",'"+fieldvalue+"'" ; + } + bb.writeLog("tablename:"+tablename); + bb.writeLog("tablenvalue:"+tablenvalue); + + + if(tablename !="" && tablenvalue !="") + { + sql = " insert into "+uf_table+"("+tablename+") values ("+ tablenvalue +")"; + bb.writeLog("sql:"+sql); + boolean boo = rs.execute(sql); + if(boo) + { + String dataid = "" ; + sql = " select * from "+uf_table+" where uuid='"+uuid+"' " ; + bb.writeLog("sql:"+sql); + rs.execute(sql); + if(rs.next()){ + dataid = Util.null2String(rs.getString("id")); + } + bb.writeLog("dataid:"+dataid); + if(!"".equals(dataid)) + { + modeRightInfo.editModeDataShare(Integer.valueOf(modedatacreater), Integer.parseInt(formmodeid), Integer.parseInt(dataid)); + } + } + } + } +} diff --git a/src/weaver/interfaces/dito/overtime/SendPortalOverTimeMsgUtil.java b/src/weaver/interfaces/dito/overtime/SendPortalOverTimeMsgUtil.java index 53cf515b..b46a4197 100644 --- a/src/weaver/interfaces/dito/overtime/SendPortalOverTimeMsgUtil.java +++ b/src/weaver/interfaces/dito/overtime/SendPortalOverTimeMsgUtil.java @@ -1,14 +1,22 @@ package weaver.interfaces.dito.overtime; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.constant.Constants; +import okhttp3.*; import org.apache.commons.lang3.StringUtils; import weaver.conn.RecordSet; import weaver.general.BaseBean; import weaver.general.Util; +import weaver.hrm.resource.ResourceComInfo; import weaver.interfaces.dito.comInfo.PropBean; -import weaver.interfaces.dito.util.SendMessageUtil; import weaver.workflow.msg.entity.MsgEntity; - +import java.net.URLEncoder; +import java.text.SimpleDateFormat; +import java.util.Date; import java.util.List; +import java.util.Set; + /*** * @@ -16,36 +24,243 @@ import java.util.List; public class SendPortalOverTimeMsgUtil { public void SendOverTimeMsg(List requestMsgEntity){ - String CusField_MsgId = PropBean.getUfPropValue("CusField_MsgId"); - String scopeid = "-1"; - String scope = "HrmCustomFieldByInfoType" ; + BaseBean bb = new BaseBean(); bb.writeLog("SendPortalOverTimeMsgUtil"); RecordSet rs = new RecordSet(); - if(StringUtils.isNotBlank(CusField_MsgId)) - { + ResourceComInfo resourceComInfo = null ; + + SendPortalOverTimeMsgUtil sendPortalOverTimeMsgUtil = new SendPortalOverTimeMsgUtil(); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + String tzsj = sdf.format(new Date()) ; + + try{ + resourceComInfo = new ResourceComInfo(); + + JSONArray userCodeArray = new JSONArray() ; + JSONArray userIdArray = new JSONArray(); for(int i=0;i userSet = msgEntity.getUserId(); + + for(String userid : userSet){ + String usercode = resourceComInfo.getLoginID(userid); + userCodeArray.add(usercode); + + userIdArray.add(userid); + } String requestname = msgEntity.getDetailTitle(); String requestid = msgEntity.getDetailId(); - bb.writeLog("SendPortalOverTimeMsgUtil-requestid:"+requestid); + String receiverArray = "" ; + if(!userCodeArray.isEmpty()){ + receiverArray = sendPortalOverTimeMsgUtil.getUserIdByCode(userCodeArray,requestid,requestname,tzsj); + } + if(StringUtils.isNotBlank(receiverArray)){ + sendPortalOverTimeMsgUtil.senMessageToPortal(receiverArray,requestid,requestname,tzsj,userIdArray.toJSONString()); + } + } + }catch (Exception e){ + + } + } + + + /** + * + * @param userCodeArray + * @return + */ + public String getUserIdByCode(JSONArray userCodeArray,String lcid,String lcmc,String tzsj){ + + SendMessageResultUtil sendMessageResultUtil = new SendMessageResultUtil(); + String userIds = ""; + BaseBean bb = new BaseBean(); + + String queryUserUrl = PropBean.getUfPropValue("OverTimeQueryUserUrl").trim(); + String appKey = PropBean.getUfPropValue("OverTimeMsgAppkey").trim(); + String appSecret = PropBean.getUfPropValue("OverTimeMsgAppSecret").trim(); + String hostName = PropBean.getUfPropValue("OverTimeHostName").trim(); + String scheme = PropBean.getUfPropValue("OverTimeScheme").trim(); + boolean ignoreSslCheck = PropBean.getUfPropValue("OverTimeMsgIgnoreSslCheck").trim().equals("true") ? true : false ; + String tenantId = PropBean.getUfPropValue("OverTimeMsgTenantId").trim(); + + bb.writeLog("queryUserUrl:"+queryUserUrl); + bb.writeLog("appKey:"+appKey); + bb.writeLog("appSecret:"+appSecret); + bb.writeLog("hostName:"+hostName); + bb.writeLog("scheme:"+scheme); + bb.writeLog("ignoreSslCheck:"+ignoreSslCheck); + bb.writeLog("a:"+tenantId); + bb.writeLog("userCodeArray:"+userCodeArray.toJSONString()); + + OkHttpClient client = new OkHttpClient().newBuilder().build(); + MediaType mediaType = MediaType.parse("application/json"); + + try{ + if(!userCodeArray.isEmpty()&& userCodeArray.size()>0) + { + + JSONObject requestParams = new JSONObject(); + requestParams.put("tenantId", tenantId); + requestParams.put("userCodes",userCodeArray); + + RequestBody body = RequestBody.create(mediaType, requestParams.toJSONString()); + Request ok3request = new Request.Builder() + .url(scheme+"://"+hostName+queryUserUrl) + .method("POST", body) + .addHeader("appKey", appKey) + .addHeader("appSecret", appSecret) + .addHeader("Content-Type", "application/json") + .build(); + + Response ok3response = client.newCall(ok3request).execute(); + String bodyMsg = ok3response.body().string(); - SendMessageUtil sendMessageUtil = new SendMessageUtil(); - String msgid = "" ; - if(StringUtils.isNotEmpty(userid)){ - rs.executeQuery(" select "+CusField_MsgId+" as msgid from cus_fielddata where scopeid=? and scope = ? and id=? ",new Object[]{scopeid,scope,userid} ); - if(rs.next()){ - msgid = Util.null2String(rs.getString("seqorder")); + String resultCode = "" ; + String resultMsg = "" ; + if(StringUtils.isNotBlank(bodyMsg)){ + JSONObject repsonseObject = JSONObject.parseObject(bodyMsg); + resultCode = Util.null2String(repsonseObject.get("resultCode")); + resultMsg = Util.null2String(repsonseObject.get("resultMsg")); + String result = Util.null2String(repsonseObject.get("result")); + System.out.println("resultCode:"+resultCode); + System.out.println("resultMsg:"+resultMsg); + System.out.println("result:"+result); + + if(StringUtils.isNotBlank(result) && !"{}".equals(result)){ + JSONObject resultObject = JSONObject.parseObject(result); + if(resultObject.containsKey("userList")){ + String userListObject = resultObject.getString("userList"); + JSONArray userArray = JSONArray.parseArray(userListObject); + for(int i=0;i) is due soon. Please check it out and handle it as soon as you can."; + String title = "Workflow Reminder "; + + JSONObject offlinePParams = new JSONObject(); + offlinePParams.put("offlinePushTitle:",title); + offlinePParams.put("offlinePushDesc:",text); + + OfflinePushInfoVo OfflinePushInfoVo = new OfflinePushInfoVo(); + OfflinePushInfoVo.setOfflinePushTitle(title); + OfflinePushInfoVo.setOfflinePushDesc(text); + requestParams.put("offlinePushInfo",OfflinePushInfoVo); + requestParams.put("msg","{'msgtype':'link','link': {'messageUrl': '"+messageUrl+"','pcMessageUrl': '"+pcMessageUrl+"','picUrl': '','title': '"+title+"','text': '"+text+"'}}"); + //获取完成response + + bb.writeLog("senMessageToPortal-requestParams:"+requestParams.toJSONString()); + + OkHttpClient client = new OkHttpClient().newBuilder().build(); + MediaType mediaType = MediaType.parse("application/json"); +// RequestBody body = RequestBody.create(mediaType, "{\"msg\":\"{'msgtype':'link','link': {'messageUrl': 'phospherus://client/action/open_h5_app?url=https%3A%2F%2Foa-test-idito.dito.ph%3A9443%2Fbpm%2Fspa%2Fworkflow%2Fstatic4mobileform%2Findex.html%23%2Freq%3Frequestid%3D598605','pcMessageUrl': 'phospherus://pc/page/link?url=%2Fbpm%2Fworkflow%2Frequest%2FViewRequestForwardSPA.jsp%3Frequestid%3D598605','picUrl': '','title': 'Workflow Reminder ','text': 'The Workflow (To-do_) is due soon. Please check it out and handle it as soon as you can.'}}\",\"orgCodes\":\"\",\"receiverIds\":\""+receiverIds+"\",\"tenantId\":\"1\",\"bizMsgId\":\""+"weaver"+requestid+currentTime+"\",\"offlinePushInfo\":{\"offlinePushDesc\":\"The Workflow (To-do_) is due soon. Please check it out and handle it as soon as you can.\",\"offlinePushTitle\":\"Workflow Reminder \"}}\r\n"); + + RequestBody body = RequestBody.create(mediaType, requestParams.toJSONString()); + + bb.writeLog("url:"+scheme+"://"+hostName+sendMsgUrl); + Request ok3request = new Request.Builder() + .url(scheme+"://"+hostName+sendMsgUrl) + .method("POST", body) + .addHeader("appKey", appKey) + .addHeader("appSecret", appSecret) + .addHeader("Content-Type", "application/json") + .build(); + + Response ok3response = client.newCall(ok3request).execute(); + String bodyMsg = ok3response.body().string(); + bb.writeLog("bodyMsg:"+bodyMsg); + bb.writeLog(ok3response.code()); + + String resultCode = "" ; + String resultMsg = "" ; + if(StringUtils.isNotBlank(bodyMsg)){ + JSONObject repsonseObject = JSONObject.parseObject(bodyMsg); + resultCode = Util.null2String(repsonseObject.get("resultCode")); + resultMsg = Util.null2String(repsonseObject.get("resultMsg")); } + sendMessageResultUtil.doRecordOverTimeMsgInfo(requestid,requestname,userIds,tzsj,sendMsgUrl,requestParams.toJSONString(),tenantId,bodyMsg,resultCode,resultMsg); + + }else{ + msgCode = "1"; } + }catch (Exception e) { + e.printStackTrace(); + bb.writeLog("senMessageToPortal-:e"+e); } + + return msgCode; } + + + } diff --git a/src/weaver/interfaces/dito/overtime/SendPortalOverTimeSubmitUtil.java b/src/weaver/interfaces/dito/overtime/SendPortalOverTimeSubmitUtil.java index a36f79ad..448bb3f8 100644 --- a/src/weaver/interfaces/dito/overtime/SendPortalOverTimeSubmitUtil.java +++ b/src/weaver/interfaces/dito/overtime/SendPortalOverTimeSubmitUtil.java @@ -215,7 +215,6 @@ public class SendPortalOverTimeSubmitUtil { String taskType = "1"; String objectAction = "0" ; String objectType = "0"; - String emailArray = ""; try { String cus_staff = PropBean.getUfPropValue("cus_staff") ; @@ -256,7 +255,8 @@ public class SendPortalOverTimeSubmitUtil { } requestObject.put("center",center); requestObject.put("title",requestname); - requestObject.put("taskCode","weaver"+requestid); + requestObject.put("taskCode", requestid+"_cs_"+userids); + requestObject.put("nodeId",nodeId); requestObject.put("taskType",taskType); requestObject.put("actionType",actionType);