|
|
@ -1836,6 +1836,411 @@ public class QyWxOperationService { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 用于发送物料出库审批(用于立即出库) |
|
|
|
|
|
* |
|
|
|
|
|
* @param userAgent 加密后的userAgent |
|
|
|
|
|
* @param userToken 申请人 |
|
|
|
|
|
* @param mainId 出库的主订单 |
|
|
|
|
|
* @return 发送结果 |
|
|
|
|
|
*/ |
|
|
|
|
|
public JSONObject sendOutApprovalTemplateForImmediately(String userAgent, UserByPort userToken, Integer mainId,String userKey,String token) { |
|
|
|
|
|
|
|
|
|
|
|
// 获取当前出库主订单
|
|
|
|
|
|
ApplicationOutRecord mainRecord = depositoryRecordMapper.findApplicationOutRecordPById(mainId); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 事先定义其他部门负责人列表
|
|
|
|
|
|
List<String> otherDepartmentIdList = new ArrayList<>(); |
|
|
|
|
|
|
|
|
|
|
|
// 获取当前出库明细
|
|
|
|
|
|
List<ApplicationOutRecordMin> minRecordList = depositoryRecordMapper.findApplicationOutRecordMinByParent(mainId); |
|
|
|
|
|
// 定义审批模板
|
|
|
|
|
|
ApprovalTemplate approvalTemplate = new ApprovalTemplate(); |
|
|
|
|
|
|
|
|
|
|
|
// 获取申请人的userId
|
|
|
|
|
|
String workwechat = userToken.getWorkwechat(); |
|
|
|
|
|
if (workwechat == null || "".equals(workwechat)) { |
|
|
|
|
|
workwechat = userToken.getWechat(); |
|
|
|
|
|
} |
|
|
|
|
|
// 设置申请人
|
|
|
|
|
|
approvalTemplate.setCreator_userid(workwechat); |
|
|
|
|
|
|
|
|
|
|
|
// 设置模板id
|
|
|
|
|
|
approvalTemplate.setTemplate_id(QyWxConfig.out_approval_template_id); |
|
|
|
|
|
|
|
|
|
|
|
// 设置审批人模式为通过接口设置(系统内部自定义)
|
|
|
|
|
|
approvalTemplate.setUse_template_approver(0); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//审批流程信息,用于指定审批申请的审批流程,支持单人审批、多人会签、多人或签,可能有多个审批节点,仅use_template_approver为0时生效。
|
|
|
|
|
|
List<Approval_template_approver> approval_template_approver_list = new ArrayList<>(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<String> userIdList = new ArrayList<>(); |
|
|
|
|
|
List<UserByPort> departmentHeadForUserToken = PublicConfig.findDepartmentHeadByUser(userToken.getMaindeparment(),userKey,token ); |
|
|
|
|
|
for (UserByPort departmentHead : departmentHeadForUserToken |
|
|
|
|
|
) { |
|
|
|
|
|
String departmentHeadWorkwechat = departmentHead.getWorkwechat(); |
|
|
|
|
|
if (departmentHeadWorkwechat == null || "".equals(departmentHeadWorkwechat)) { |
|
|
|
|
|
departmentHeadWorkwechat = departmentHead.getWechat(); |
|
|
|
|
|
} |
|
|
|
|
|
userIdList.add(departmentHeadWorkwechat); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 获取当前登录用户部门与企业微信部门对照
|
|
|
|
|
|
JSONObject userPortByQyWx = PublicConfig.getUserPortByQyWx(userToken.getMaindeparment()); |
|
|
|
|
|
String portName = userPortByQyWx.getString("name"); |
|
|
|
|
|
Integer portByQyWxInteger = userPortByQyWx.getInteger("wechatorganizationid"); |
|
|
|
|
|
|
|
|
|
|
|
// 用于设置部门负责人流程
|
|
|
|
|
|
Approval_template_approver approval_template_approver_departMentHeader = new Approval_template_approver(); |
|
|
|
|
|
approval_template_approver_departMentHeader.setAttr(1); |
|
|
|
|
|
userIdList = new ArrayList<>(Collections.singleton("PangFuZhen")); |
|
|
|
|
|
approval_template_approver_departMentHeader.setUserid(userIdList); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
approval_template_approver_list.add(approval_template_approver_departMentHeader); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 审批申请数据,可定义审批申请中各个控件的值,其中必填项必须有值,选填项可为空,数据结构同“获取审批申请详情”接口返回值中同名参数“apply_data”
|
|
|
|
|
|
Approval_template_apply_data approval_template_apply_data = new Approval_template_apply_data(); |
|
|
|
|
|
|
|
|
|
|
|
// 定义控件列表
|
|
|
|
|
|
List<Approval_template_apply_data_contents> approval_template_apply_data_contents_list = new ArrayList<>(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//定义模板控件——发起人
|
|
|
|
|
|
Approval_template_apply_data_contents approval_template_apply_data_contents_initiator = new Approval_template_apply_data_contents(); |
|
|
|
|
|
// 控件类型
|
|
|
|
|
|
approval_template_apply_data_contents_initiator.setControl("Contact"); |
|
|
|
|
|
// 控件id
|
|
|
|
|
|
approval_template_apply_data_contents_initiator.setId("Contact-1668051509196"); |
|
|
|
|
|
|
|
|
|
|
|
// 成员控件值(control参数为Contact,且value参数为members)
|
|
|
|
|
|
Map<String, Object> members_initiator = new HashMap<>(); |
|
|
|
|
|
Map<String, String> contact_user = new HashMap<>(); |
|
|
|
|
|
List<Map<String, String>> membersMap_initiator = new ArrayList<>(); |
|
|
|
|
|
contact_user.put("userid", workwechat); |
|
|
|
|
|
contact_user.put("name", userToken.getName()); |
|
|
|
|
|
membersMap_initiator.add(contact_user); |
|
|
|
|
|
members_initiator.put("members", membersMap_initiator); |
|
|
|
|
|
approval_template_apply_data_contents_initiator.setValue(members_initiator); |
|
|
|
|
|
|
|
|
|
|
|
// 添加到控件列表
|
|
|
|
|
|
approval_template_apply_data_contents_list.add(approval_template_apply_data_contents_initiator); |
|
|
|
|
|
|
|
|
|
|
|
//定义模板控件——发起时间
|
|
|
|
|
|
Approval_template_apply_data_contents approval_template_apply_data_contents_time = new Approval_template_apply_data_contents(); |
|
|
|
|
|
approval_template_apply_data_contents_time.setControl("Date"); |
|
|
|
|
|
approval_template_apply_data_contents_time.setId("Date-1668051535322"); |
|
|
|
|
|
|
|
|
|
|
|
Map<String, Object> members_time = new HashMap<>(); |
|
|
|
|
|
Map<String, String> contact_time = new HashMap<>(); |
|
|
|
|
|
contact_time.put("type", "hour"); |
|
|
|
|
|
contact_time.put("s_timestamp", String.valueOf(System.currentTimeMillis() / 1000)); |
|
|
|
|
|
members_time.put("date", contact_time); |
|
|
|
|
|
approval_template_apply_data_contents_time.setValue(members_time); |
|
|
|
|
|
|
|
|
|
|
|
// 添加到控件列表
|
|
|
|
|
|
approval_template_apply_data_contents_list.add(approval_template_apply_data_contents_time); |
|
|
|
|
|
//定义模板控件——所在部门
|
|
|
|
|
|
Approval_template_apply_data_contents approval_template_apply_data_contents_department = new Approval_template_apply_data_contents(); |
|
|
|
|
|
approval_template_apply_data_contents_department.setControl("Contact"); |
|
|
|
|
|
approval_template_apply_data_contents_department.setId("Contact-1668048405619"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 部门控件值(control参数为Contact,且value参数为departments)
|
|
|
|
|
|
Map<String, Object> members_department = new HashMap<>(); |
|
|
|
|
|
Map<String, String> contact_department = new HashMap<>(); |
|
|
|
|
|
List<Map<String, String>> membersMap_department = new ArrayList<>(); |
|
|
|
|
|
contact_department.put("openapi_id", portByQyWxInteger.toString()); |
|
|
|
|
|
contact_department.put("name", portName); |
|
|
|
|
|
membersMap_department.add(contact_department); |
|
|
|
|
|
members_department.put("departments", membersMap_department); |
|
|
|
|
|
approval_template_apply_data_contents_department.setValue(members_department); |
|
|
|
|
|
|
|
|
|
|
|
// 添加到控件列表
|
|
|
|
|
|
approval_template_apply_data_contents_list.add(approval_template_apply_data_contents_department); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 获取当前登录用户请求时的备注
|
|
|
|
|
|
String applyRemark = mainRecord.getApplyRemark(); |
|
|
|
|
|
if (applyRemark == null) { |
|
|
|
|
|
applyRemark = ""; |
|
|
|
|
|
} |
|
|
|
|
|
//定义模板控件——申请备注
|
|
|
|
|
|
Approval_template_apply_data_contents approval_template_apply_data_contents_applyRemark = new Approval_template_apply_data_contents(); |
|
|
|
|
|
approval_template_apply_data_contents_applyRemark.setControl("Textarea"); |
|
|
|
|
|
approval_template_apply_data_contents_applyRemark.setId("Textarea-1668046298633"); |
|
|
|
|
|
Map<String, String> applyRemark_text = new HashMap<>(); |
|
|
|
|
|
applyRemark_text.put("text", applyRemark); |
|
|
|
|
|
approval_template_apply_data_contents_applyRemark.setValue(applyRemark_text); |
|
|
|
|
|
|
|
|
|
|
|
// 添加到控件列表
|
|
|
|
|
|
approval_template_apply_data_contents_list.add(approval_template_apply_data_contents_applyRemark); |
|
|
|
|
|
|
|
|
|
|
|
//定义模板控件——明细
|
|
|
|
|
|
Approval_template_apply_data_contents approval_template_apply_data_contents_info = new Approval_template_apply_data_contents(); |
|
|
|
|
|
approval_template_apply_data_contents_info.setControl("Table"); |
|
|
|
|
|
approval_template_apply_data_contents_info.setId("Table-1668046309360"); |
|
|
|
|
|
// 定义明细列表
|
|
|
|
|
|
List<Object> contents_detail = new ArrayList<>(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 定义仓库Id列表
|
|
|
|
|
|
List<Integer> depositoryIdList = new ArrayList<>(); |
|
|
|
|
|
for (ApplicationOutRecordMin recordMin : minRecordList) { |
|
|
|
|
|
// 获取明细信息
|
|
|
|
|
|
|
|
|
|
|
|
// 获取当前出库物料
|
|
|
|
|
|
Inventory materialById = materialMapper.findInventoryById(recordMin.getMid()); |
|
|
|
|
|
|
|
|
|
|
|
// 获取当前物料所在仓库
|
|
|
|
|
|
Integer depositoryId = recordMin.getDepositoryId(); |
|
|
|
|
|
Depository depositoryById = depositoryMapper.findDepositoryById(depositoryId); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!depositoryIdList.contains(depositoryId)) { |
|
|
|
|
|
// 如果当前仓库列表中不存在该仓库id
|
|
|
|
|
|
depositoryIdList.add(depositoryId); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Map<String, Object> detail_list = new HashMap<>(); |
|
|
|
|
|
// 定义明细种的控件列表
|
|
|
|
|
|
List<Object> detail_list_control = new ArrayList<>(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 物料名称
|
|
|
|
|
|
Map<String, Object> detail_list_control_info_materialName = new HashMap<>(); |
|
|
|
|
|
detail_list_control_info_materialName.put("control", "Text"); |
|
|
|
|
|
detail_list_control_info_materialName.put("id", "Text-1668046310921"); |
|
|
|
|
|
Map<String, String> detail_list_control_info_title_materialName = new HashMap<>(); |
|
|
|
|
|
detail_list_control_info_title_materialName.put("text", "物料名称"); |
|
|
|
|
|
detail_list_control_info_title_materialName.put("lang", "zh_CN"); |
|
|
|
|
|
|
|
|
|
|
|
List<Object> detail_list_control_info_title_list_materialName = new ArrayList<>(); |
|
|
|
|
|
detail_list_control_info_title_list_materialName.add(detail_list_control_info_title_materialName); |
|
|
|
|
|
detail_list_control_info_materialName.put("title", detail_list_control_info_title_list_materialName); |
|
|
|
|
|
|
|
|
|
|
|
Map<String, String> detail_list_control_info_value_Mname = new HashMap<>(); |
|
|
|
|
|
detail_list_control_info_value_Mname.put("text", materialById.getMname()); |
|
|
|
|
|
detail_list_control_info_materialName.put("value", detail_list_control_info_value_Mname); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 物料编码
|
|
|
|
|
|
Map<String, Object> detail_list_control_info_materialCode = new HashMap<>(); |
|
|
|
|
|
detail_list_control_info_materialCode.put("control", "Text"); |
|
|
|
|
|
detail_list_control_info_materialCode.put("id", "Text-1668046336721"); |
|
|
|
|
|
Map<String, String> detail_list_control_info_title_materialCode = new HashMap<>(); |
|
|
|
|
|
detail_list_control_info_title_materialCode.put("text", "物料编码"); |
|
|
|
|
|
detail_list_control_info_title_materialCode.put("lang", "zh_CN"); |
|
|
|
|
|
|
|
|
|
|
|
List<Object> detail_list_control_info_title_list_Code = new ArrayList<>(); |
|
|
|
|
|
detail_list_control_info_title_list_Code.add(detail_list_control_info_title_materialCode); |
|
|
|
|
|
detail_list_control_info_materialCode.put("title", detail_list_control_info_title_list_Code); |
|
|
|
|
|
|
|
|
|
|
|
Map<String, String> detail_list_control_info_value_Code = new HashMap<>(); |
|
|
|
|
|
detail_list_control_info_value_Code.put("text", materialById.getCode()); |
|
|
|
|
|
detail_list_control_info_materialCode.put("value", detail_list_control_info_value_Code); |
|
|
|
|
|
|
|
|
|
|
|
// 请求数量
|
|
|
|
|
|
Map<String, Object> detail_list_control_info_outNumber = new HashMap<>(); |
|
|
|
|
|
detail_list_control_info_outNumber.put("control", "Number"); |
|
|
|
|
|
detail_list_control_info_outNumber.put("id", "Number-1668051559772"); |
|
|
|
|
|
Map<String, String> detail_list_control_info_title_outNumber = new HashMap<>(); |
|
|
|
|
|
detail_list_control_info_title_outNumber.put("text", "数量"); |
|
|
|
|
|
detail_list_control_info_title_outNumber.put("lang", "zh_CN"); |
|
|
|
|
|
|
|
|
|
|
|
List<Object> detail_list_control_info_title_list_outNumber = new ArrayList<>(); |
|
|
|
|
|
detail_list_control_info_title_list_outNumber.add(detail_list_control_info_title_outNumber); |
|
|
|
|
|
detail_list_control_info_outNumber.put("title", detail_list_control_info_title_list_outNumber); |
|
|
|
|
|
|
|
|
|
|
|
Map<String, String> detail_list_control_info_value_outNumber = new HashMap<>(); |
|
|
|
|
|
detail_list_control_info_value_outNumber.put("new_number", String.valueOf(recordMin.getQuantity() / 100)); |
|
|
|
|
|
detail_list_control_info_outNumber.put("value", detail_list_control_info_value_outNumber); |
|
|
|
|
|
|
|
|
|
|
|
// 请求单位
|
|
|
|
|
|
Map<String, Object> detail_list_control_info_unit = new HashMap<>(); |
|
|
|
|
|
detail_list_control_info_unit.put("control", "Text"); |
|
|
|
|
|
detail_list_control_info_unit.put("id", "Text-1672816068840"); |
|
|
|
|
|
Map<String, String> detail_list_control_info_title_unit = new HashMap<>(); |
|
|
|
|
|
detail_list_control_info_title_unit.put("text", "单位"); |
|
|
|
|
|
detail_list_control_info_title_unit.put("lang", "zh_CN"); |
|
|
|
|
|
|
|
|
|
|
|
List<Object> detail_list_control_info_title_list_unit = new ArrayList<>(); |
|
|
|
|
|
detail_list_control_info_title_list_unit.add(detail_list_control_info_title_unit); |
|
|
|
|
|
detail_list_control_info_unit.put("title", detail_list_control_info_title_list_unit); |
|
|
|
|
|
|
|
|
|
|
|
Map<String, String> detail_list_control_info_value_unit = new HashMap<>(); |
|
|
|
|
|
// 定义出库单位
|
|
|
|
|
|
String unit = recordMin.getUnit(); |
|
|
|
|
|
if ("-1".equals(unit)) { |
|
|
|
|
|
unit = materialById.getUnit(); |
|
|
|
|
|
} |
|
|
|
|
|
detail_list_control_info_value_unit.put("text", unit); |
|
|
|
|
|
detail_list_control_info_unit.put("value", detail_list_control_info_value_unit); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 仓库名称
|
|
|
|
|
|
Map<String, Object> detail_list_control_info_depositoryName = new HashMap<>(); |
|
|
|
|
|
detail_list_control_info_depositoryName.put("control", "Text"); |
|
|
|
|
|
detail_list_control_info_depositoryName.put("id", "Text-1668137728919"); |
|
|
|
|
|
Map<String, String> detail_list_control_info_title_depositoryName = new HashMap<>(); |
|
|
|
|
|
detail_list_control_info_title_depositoryName.put("text", "所在仓库"); |
|
|
|
|
|
detail_list_control_info_title_depositoryName.put("lang", "zh_CN"); |
|
|
|
|
|
|
|
|
|
|
|
List<Object> detail_list_control_info_title_list_depositoryName = new ArrayList<>(); |
|
|
|
|
|
detail_list_control_info_title_list_depositoryName.add(detail_list_control_info_title_depositoryName); |
|
|
|
|
|
detail_list_control_info_depositoryName.put("title", detail_list_control_info_title_list_depositoryName); |
|
|
|
|
|
|
|
|
|
|
|
Map<String, String> detail_list_control_info_value_dname = new HashMap<>(); |
|
|
|
|
|
detail_list_control_info_value_dname.put("text", depositoryById.getDname()); |
|
|
|
|
|
detail_list_control_info_depositoryName.put("value", detail_list_control_info_value_dname); |
|
|
|
|
|
|
|
|
|
|
|
// 物料规格型号
|
|
|
|
|
|
Map<String, Object> detail_list_control_info_version = new HashMap<>(); |
|
|
|
|
|
detail_list_control_info_version.put("control", "Text"); |
|
|
|
|
|
detail_list_control_info_version.put("id", "Text-1672879620723"); |
|
|
|
|
|
Map<String, String> detail_list_control_info_title_version = new HashMap<>(); |
|
|
|
|
|
detail_list_control_info_title_version.put("text", "规格型号"); |
|
|
|
|
|
detail_list_control_info_title_version.put("lang", "zh_CN"); |
|
|
|
|
|
|
|
|
|
|
|
List<Object> detail_list_control_info_title_list_version = new ArrayList<>(); |
|
|
|
|
|
detail_list_control_info_title_list_version.add(detail_list_control_info_title_version); |
|
|
|
|
|
detail_list_control_info_version.put("title", detail_list_control_info_title_list_version); |
|
|
|
|
|
|
|
|
|
|
|
Map<String, String> detail_list_control_info_value_version = new HashMap<>(); |
|
|
|
|
|
detail_list_control_info_value_version.put("text", materialById.getVersion() == null ? "" : materialById.getVersion()); |
|
|
|
|
|
detail_list_control_info_version.put("value", detail_list_control_info_value_version); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
detail_list_control.add(detail_list_control_info_materialName); |
|
|
|
|
|
detail_list_control.add(detail_list_control_info_materialCode); |
|
|
|
|
|
detail_list_control.add(detail_list_control_info_version); |
|
|
|
|
|
detail_list_control.add(detail_list_control_info_outNumber); |
|
|
|
|
|
detail_list_control.add(detail_list_control_info_unit); |
|
|
|
|
|
detail_list_control.add(detail_list_control_info_depositoryName); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
detail_list.put("list", detail_list_control); |
|
|
|
|
|
|
|
|
|
|
|
contents_detail.add(detail_list); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Map<String, Object> approval_template_apply_data_contents_info_children = new HashMap<>(); |
|
|
|
|
|
approval_template_apply_data_contents_info_children.put("children", contents_detail); |
|
|
|
|
|
approval_template_apply_data_contents_info.setValue(approval_template_apply_data_contents_info_children); |
|
|
|
|
|
|
|
|
|
|
|
// 添加到控件列表
|
|
|
|
|
|
approval_template_apply_data_contents_list.add(approval_template_apply_data_contents_info); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 将控件列表添加到审批申请数据
|
|
|
|
|
|
approval_template_apply_data.setContents(approval_template_apply_data_contents_list); |
|
|
|
|
|
|
|
|
|
|
|
// 定义摘要信息,用于显示在审批通知卡片、审批列表的摘要信息,最多3行
|
|
|
|
|
|
List<Object> approval_template_apply_data_contents_summary_list = new ArrayList<>(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Approval_template_summary_info summary_info_name = new Approval_template_summary_info(); |
|
|
|
|
|
summary_info_name.setText("发起人:" + userToken.getName()); |
|
|
|
|
|
summary_info_name.setLang("zh_CN"); |
|
|
|
|
|
Approval_template_summary_info summary_info_time = new Approval_template_summary_info(); |
|
|
|
|
|
summary_info_time.setText("发起时间:" + DateUtil.TimeStampToDateTime(Long.valueOf(mainRecord.getApplicantTime()))); |
|
|
|
|
|
summary_info_time.setLang("zh_CN"); |
|
|
|
|
|
Approval_template_summary_info summary_info_department = new Approval_template_summary_info(); |
|
|
|
|
|
summary_info_department.setText("所在部门:" + portName); |
|
|
|
|
|
summary_info_department.setLang("zh_CN"); |
|
|
|
|
|
// 发起人
|
|
|
|
|
|
Map<String, Object> summary_info_name_map = new HashMap<>(); |
|
|
|
|
|
List<Approval_template_summary_info> summary_info_name_list = new ArrayList<>(); |
|
|
|
|
|
summary_info_name_list.add(summary_info_name); |
|
|
|
|
|
summary_info_name_map.put("summary_info", summary_info_name_list); |
|
|
|
|
|
// 发起时间
|
|
|
|
|
|
Map<String, Object> summary_info_time_map = new HashMap<>(); |
|
|
|
|
|
List<Approval_template_summary_info> summary_info_time_list = new ArrayList<>(); |
|
|
|
|
|
summary_info_time_list.add(summary_info_time); |
|
|
|
|
|
summary_info_time_map.put("summary_info", summary_info_time_list); |
|
|
|
|
|
// 所在部门
|
|
|
|
|
|
Map<String, Object> summary_info_department_map = new HashMap<>(); |
|
|
|
|
|
List<Approval_template_summary_info> summary_info_time_department = new ArrayList<>(); |
|
|
|
|
|
summary_info_time_department.add(summary_info_department); |
|
|
|
|
|
summary_info_department_map.put("summary_info", summary_info_time_department); |
|
|
|
|
|
|
|
|
|
|
|
approval_template_apply_data_contents_summary_list.add(summary_info_name_map); |
|
|
|
|
|
approval_template_apply_data_contents_summary_list.add(summary_info_time_map); |
|
|
|
|
|
approval_template_apply_data_contents_summary_list.add(summary_info_department_map); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 将摘要信息添加到模板中
|
|
|
|
|
|
approvalTemplate.setSummary_list(approval_template_apply_data_contents_summary_list); |
|
|
|
|
|
//审批申请数据,可定义审批申请中各个控件的值,其中必填项必须有值,选填项可为空
|
|
|
|
|
|
approvalTemplate.setApply_data(approval_template_apply_data); |
|
|
|
|
|
|
|
|
|
|
|
//抄送方式:1-提单时抄送(默认值); 2-单据通过后抄送;3-提单和单据通过后抄送。仅use_template_approver为0时生效。
|
|
|
|
|
|
approvalTemplate.setNotify_type(2); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 获取仓储中心负责人标签的用户userId
|
|
|
|
|
|
List<String> qyWxLabelUserList = QyWxConfig.getQyWxLabelUserList(userAgent); |
|
|
|
|
|
// 用于设置仓储中心负责人流程
|
|
|
|
|
|
Approval_template_approver approval_template_approver_Label = new Approval_template_approver(); |
|
|
|
|
|
approval_template_approver_Label.setAttr(1); |
|
|
|
|
|
approval_template_approver_Label.setUserid(qyWxLabelUserList); |
|
|
|
|
|
approval_template_approver_list.add(approval_template_approver_Label); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (Integer depositoryId : depositoryIdList |
|
|
|
|
|
|
|
|
|
|
|
) { |
|
|
|
|
|
// 获取当前仓库的管理员列表
|
|
|
|
|
|
List<Integer> userIdByDid = roleMapper.findUserIdByDid(depositoryId); |
|
|
|
|
|
// 获取当前管理员的企业微信userId
|
|
|
|
|
|
List<String> qywxUserIdList = new ArrayList<>(); |
|
|
|
|
|
for (Integer userId : userIdByDid |
|
|
|
|
|
) { |
|
|
|
|
|
// 获取对应管理员信息
|
|
|
|
|
|
UserByPort userByPort = LinkInterfaceUtil.FindUserById(userId, userKey,token); |
|
|
|
|
|
String user = userByPort.getWorkwechat(); |
|
|
|
|
|
if (user == null || "".equals(user)) { |
|
|
|
|
|
user = userByPort.getWechat(); |
|
|
|
|
|
} |
|
|
|
|
|
qywxUserIdList.add(user); |
|
|
|
|
|
} |
|
|
|
|
|
if (qywxUserIdList.size() > 0) { |
|
|
|
|
|
// 用于设置仓库管理员流程
|
|
|
|
|
|
Approval_template_approver approval_template_approver_depository_manager = new Approval_template_approver(); |
|
|
|
|
|
approval_template_approver_depository_manager.setAttr(1); |
|
|
|
|
|
approval_template_approver_depository_manager.setUserid(qywxUserIdList); |
|
|
|
|
|
|
|
|
|
|
|
approval_template_approver_list.add(approval_template_approver_depository_manager); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 设置审批流程
|
|
|
|
|
|
approvalTemplate.setApprover(approval_template_approver_list); |
|
|
|
|
|
|
|
|
|
|
|
// 获取最终模板字符串
|
|
|
|
|
|
String jsonString = JSONObject.toJSONString(approvalTemplate); |
|
|
|
|
|
|
|
|
|
|
|
String url = String.format("https://qyapi.weixin.qq.com/cgi-bin/oa/applyevent?access_token=%s", QyWxConfig.GetQYWXToken(userAgent)); |
|
|
|
|
|
|
|
|
|
|
|
String s = HttpUtils.doPost(url, jsonString); |
|
|
|
|
|
JSONObject jsonObject = JSONObject.parseObject(s); |
|
|
|
|
|
jsonObject.put("otherDepartmentIdList", JSONObject.toJSONString(otherDepartmentIdList)); |
|
|
|
|
|
return jsonObject; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 用于发送入库审批 |
|
|
* 用于发送入库审批 |
|
|
* |
|
|
* |
|
|
|