|
@@ -0,0 +1,401 @@
|
|
|
+package com.idea.oa.apply.service;
|
|
|
+
|
|
|
+import cn.hutool.core.codec.Base64;
|
|
|
+import cn.hutool.core.util.IdUtil;
|
|
|
+import cn.hutool.crypto.SecureUtil;
|
|
|
+import cn.hutool.crypto.symmetric.AES;
|
|
|
+import com.idea.oa.apply.mapper.ApplyFinanceExtendMapper;
|
|
|
+import com.idea.oa.apply.mapper.ApplyFinanceMapper;
|
|
|
+import com.idea.oa.apply.model.ApplyFinance;
|
|
|
+import com.idea.oa.apply.model.ApplyFinanceExample;
|
|
|
+import com.idea.oa.apply.model.inout.ApplyFinanceDto;
|
|
|
+import com.idea.oa.apply.util.constant.ConstantFlowType;
|
|
|
+import com.idea.oa.flow2.model.FlowMain;
|
|
|
+import com.idea.oa.flow2.model.FlowMainExample;
|
|
|
+import com.idea.oa.flow2.model.FlowMainPush;
|
|
|
+import com.idea.oa.flow2.model.FlowMainPushExample;
|
|
|
+import com.idea.oa.flow2.service.FlowMainPushService;
|
|
|
+import com.idea.oa.flow2.service.FlowMainService;
|
|
|
+import com.idea.util.DateUtils;
|
|
|
+import com.idea.util.OAUtil;
|
|
|
+import com.idea.workPanel.enume.HandleTypeEnum;
|
|
|
+import com.idea.workPanel.service.ParkWaitHandleService;
|
|
|
+import com.rockstar.common.base.BaseService;
|
|
|
+import com.rockstar.frame.model.FramePermission;
|
|
|
+import com.rockstar.frame.model.FramePermissionExample;
|
|
|
+import com.rockstar.frame.model.FrameUser;
|
|
|
+import com.rockstar.frame.service.FramePermissionService;
|
|
|
+import com.rockstar.frame.service.FrameUserService;
|
|
|
+import com.rockstar.shiro.util.ShiroUtils;
|
|
|
+import com.rockstar.util.StringUtils;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.commons.collections.CollectionUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import java.util.Date;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+@Slf4j
|
|
|
+@Service
|
|
|
+public class ApplyFinanceService implements BaseService<ApplyFinance, ApplyFinanceExample> {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ApplyFinanceMapper modelMapper;
|
|
|
+ @Autowired
|
|
|
+ private ApplyFinanceExtendMapper applyFinanceExtendMapper;
|
|
|
+ @Autowired
|
|
|
+ private FlowMainPushService flowMainPushService;
|
|
|
+ @Autowired
|
|
|
+ private FlowMainService flowMainService;
|
|
|
+ @Autowired
|
|
|
+ private ParkWaitHandleService parkWaitHandleService;
|
|
|
+ @Autowired
|
|
|
+ private FramePermissionService framePermissionService;
|
|
|
+ @Autowired
|
|
|
+ private FrameUserService frameUserService;
|
|
|
+ @Value("${serverUrl}")
|
|
|
+ private String serverUrl;
|
|
|
+ @Value("${ssoKey}")
|
|
|
+ private String ssoKey;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public int deleteByPrimaryKey(String s) {
|
|
|
+ return modelMapper.deleteByPrimaryKey(s);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public int insertSelective(ApplyFinance applyFinance) {
|
|
|
+ applyFinance.setId(IdUtil.simpleUUID());
|
|
|
+ return modelMapper.insertSelective(applyFinance);
|
|
|
+ }
|
|
|
+
|
|
|
+ public int insertWithoutId(ApplyFinance applyFinance) {
|
|
|
+ return modelMapper.insertSelective(applyFinance);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ApplyFinance selectByPrimaryKey(String s) {
|
|
|
+ return modelMapper.selectByPrimaryKey(s);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public int updateByPrimaryKeySelective(ApplyFinance applyFinance) {
|
|
|
+ return modelMapper.updateByPrimaryKeySelective(applyFinance);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public int updateByExampleSelective(ApplyFinance applyFinance, ApplyFinanceExample applyFinanceExample) {
|
|
|
+ return modelMapper.updateByExampleSelective(applyFinance, applyFinanceExample);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public int updateByExample(ApplyFinance applyFinance, ApplyFinanceExample applyFinanceExample) {
|
|
|
+ return modelMapper.updateByExample(applyFinance, applyFinanceExample);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<ApplyFinance> selectByExample(ApplyFinanceExample applyFinanceExample) {
|
|
|
+ return modelMapper.selectByExample(applyFinanceExample);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public long countByExample(ApplyFinanceExample applyFinanceExample) {
|
|
|
+ return modelMapper.countByExample(applyFinanceExample);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public int deleteByExample(ApplyFinanceExample applyFinanceExample) {
|
|
|
+ return modelMapper.deleteByExample(applyFinanceExample);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public ApplyFinanceDto getInfoByFlowMainId(String flowMainId) {
|
|
|
+ return applyFinanceExtendMapper.getInfoByFlowMainId(flowMainId);
|
|
|
+ }
|
|
|
+
|
|
|
+ public ApplyFinanceDto getInfoByFlowMainPushId(String flowMainPushId) {
|
|
|
+ return applyFinanceExtendMapper.getInfoByFlowMainPushId(flowMainPushId);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public Map<String, Object> getUserInfoByUserId(String userId) {
|
|
|
+ Map<String, Object> userInfoByUserId = applyFinanceExtendMapper.getUserInfoByUserId(userId);
|
|
|
+ return userInfoByUserId;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 付款记录编号 : 付款领用单20240401-002
|
|
|
+ *
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public String getMaxNum() {
|
|
|
+
|
|
|
+ // RZ202412110001
|
|
|
+
|
|
|
+ String flowNum = "";
|
|
|
+ String maxNum = applyFinanceExtendMapper.selectMaxNum();
|
|
|
+ if(StringUtils.isNotEmpty(maxNum)){
|
|
|
+ maxNum = "0001";
|
|
|
+ }else {
|
|
|
+ maxNum.substring(10);
|
|
|
+ }
|
|
|
+ String yyyyMMdd = DateUtils.parseDateToStr("yyyyMMdd", new Date());
|
|
|
+ flowNum = "RZ" + yyyyMMdd + maxNum;
|
|
|
+
|
|
|
+ return flowNum;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 发起流程 推送泛微和工作台待办
|
|
|
+ * @param id
|
|
|
+ * @param applyTheme
|
|
|
+ */
|
|
|
+ public void startOaAndHandle(String id,String applyTheme) {
|
|
|
+
|
|
|
+ try {
|
|
|
+
|
|
|
+ String flowId = "";
|
|
|
+ String nodeName = "";
|
|
|
+
|
|
|
+ FlowMainExample flowMainExample = new FlowMainExample();
|
|
|
+ flowMainExample.createCriteria().andFormIdEqualTo(id).andFlowTypeEqualTo(ConstantFlowType.FINANCE);
|
|
|
+ List<FlowMain> flowMains = flowMainService.selectByExample(flowMainExample);
|
|
|
+ if (CollectionUtils.isNotEmpty(flowMains)) {
|
|
|
+ FlowMain flowMain = flowMains.get(0);
|
|
|
+ flowId = flowMain.getId();
|
|
|
+
|
|
|
+ FlowMainPushExample flowMainPushExample = new FlowMainPushExample();
|
|
|
+ flowMainPushExample.createCriteria().andFlowMainIdEqualTo(flowId).andStatusEqualTo(0);
|
|
|
+ List<FlowMainPush> flowMainPushes = flowMainPushService.selectByExample(flowMainPushExample);
|
|
|
+ if (CollectionUtils.isNotEmpty(flowMainPushes)) {
|
|
|
+ FlowMainPush flowMainPush = flowMainPushes.get(0);
|
|
|
+ nodeName = flowMainPush.getNodeName();
|
|
|
+
|
|
|
+ // 给本系统下一个节点的人推送待办
|
|
|
+ /**
|
|
|
+ * 添加待办
|
|
|
+ * @param title 显示标题
|
|
|
+ * @param typeEnum 处理类型枚举
|
|
|
+ * @param srcUserType 来源用户类型 0管理,1企业
|
|
|
+ * @param srcUserId 来源用户id
|
|
|
+ * @param srcUserName 来源用户名称
|
|
|
+ * @param receiveUserId 接收用户id or 0=全部 or 角色id
|
|
|
+ * @param routeParam 跳转携带参数,例: id=***&type=**
|
|
|
+ */
|
|
|
+
|
|
|
+ String waitUrl = "";
|
|
|
+ // 查询待办页面的 菜单id
|
|
|
+ FramePermissionExample framePermissionExample = new FramePermissionExample();
|
|
|
+ framePermissionExample.createCriteria().andNameEqualTo("流程审批");
|
|
|
+ List<FramePermission> framePermissions = framePermissionService.selectByExample(framePermissionExample);
|
|
|
+ if (CollectionUtils.isNotEmpty(framePermissions)) {
|
|
|
+ String menuIndex = framePermissions.get(0).getId();
|
|
|
+ FramePermissionExample permissionExample = new FramePermissionExample();
|
|
|
+ permissionExample.createCriteria().andNameEqualTo("付款审批流程");
|
|
|
+ List<FramePermission> permissions = framePermissionService.selectByExample(framePermissionExample);
|
|
|
+ if (CollectionUtils.isNotEmpty(permissions)) {
|
|
|
+ String subMenu = permissions.get(0).getId();
|
|
|
+ waitUrl = "/backstage?menuIndex=" + menuIndex + "&subMenu=" + subMenu;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ String title = applyTheme;
|
|
|
+ HandleTypeEnum typeEnum = HandleTypeEnum.YSKTZ;
|
|
|
+ Integer srcUserType = 0;//来源用户类型 0管理,1企业
|
|
|
+ String srcUserId = ShiroUtils.getUserId();
|
|
|
+ String srcUserName = ShiroUtils.getUser().getTruename();
|
|
|
+ String receiveUserId = flowMainPush.getPushUser();
|
|
|
+ String routeParam = "id=" + flowId + "&flowMainPushId=" + flowMainPush.getId() + "&applyUser=" + flowMain.getApplyUser();
|
|
|
+ HandleTypeEnum.YSKTZ.setUrl(waitUrl);
|
|
|
+ parkWaitHandleService.addHandle(title, typeEnum, srcUserType, srcUserId, srcUserName, receiveUserId, routeParam);
|
|
|
+
|
|
|
+ // TODO: 2024/11/21 和泛OA对接 推送待办
|
|
|
+ FrameUser receiveUser = frameUserService.selectByPrimaryKey(receiveUserId);
|
|
|
+ String username = encryptUsername(receiveUser.getUsername());
|
|
|
+ String syscode = "AJ";
|
|
|
+ String requestname = applyTheme;
|
|
|
+ String workflowname = ConstantFlowType.FINANCE_NAME;
|
|
|
+ String pcurl = serverUrl + "&loginid=" + username;
|
|
|
+ String appurl = "";
|
|
|
+ String isremark = "0";
|
|
|
+ String viewtype = "0";
|
|
|
+ // TODO: 2024/11/15 创建者和接收者需求oa协商
|
|
|
+ String creator = "ceshi";
|
|
|
+ String receiver = "ceshi";
|
|
|
+ String date = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, new Date());
|
|
|
+ String receivets = System.currentTimeMillis() + "";
|
|
|
+ Map map = new HashMap<String, Object>();
|
|
|
+ map.put("syscode", syscode);
|
|
|
+ map.put("flowid", flowId);
|
|
|
+ map.put("requestname", requestname);
|
|
|
+ map.put("workflowname", workflowname);
|
|
|
+ map.put("nodeName", nodeName);
|
|
|
+ map.put("pcurl", pcurl);
|
|
|
+ map.put("appurl", appurl);
|
|
|
+ map.put("creator", creator);
|
|
|
+ map.put("createdatetime", date);
|
|
|
+ map.put("receiver", receiver);
|
|
|
+ map.put("receivedatetime", date);
|
|
|
+ map.put("isremark", isremark);
|
|
|
+ map.put("viewtype", viewtype);
|
|
|
+ map.put("receivets", receivets);
|
|
|
+
|
|
|
+ log.info("泛微推送详情:{}", map);
|
|
|
+ String result = OAUtil.receiveRequestInfoByJson(map);
|
|
|
+ log.info("泛微推送结果:{}", result);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("推送异常", e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 推送泛微和工作台待办
|
|
|
+ *
|
|
|
+ * @param flowMainPush
|
|
|
+ * @param flowMain
|
|
|
+ * @param waitUrl
|
|
|
+ */
|
|
|
+ public void pushOaAndHandle(FlowMainPush flowMainPush, FlowMain flowMain, String waitUrl) {
|
|
|
+
|
|
|
+ try {
|
|
|
+ String flowId = flowMain.getId();
|
|
|
+ FlowMainPushExample flowMainPushExample = new FlowMainPushExample();
|
|
|
+ flowMainPushExample.createCriteria().andFlowMainIdEqualTo(flowId).andStatusEqualTo(0);
|
|
|
+ List<FlowMainPush> flowMainPushes = flowMainPushService.selectByExample(flowMainPushExample);
|
|
|
+ if (CollectionUtils.isNotEmpty(flowMainPushes)) {
|
|
|
+ FlowMainPush push = flowMainPushes.get(0);
|
|
|
+
|
|
|
+ // 给本系统下一个节点的人推送待办
|
|
|
+ /**
|
|
|
+ * 添加待办
|
|
|
+ * @param title 显示标题
|
|
|
+ * @param typeEnum 处理类型枚举
|
|
|
+ * @param srcUserType 来源用户类型 0管理,1企业
|
|
|
+ * @param srcUserId 来源用户id
|
|
|
+ * @param srcUserName 来源用户名称
|
|
|
+ * @param receiveUserId 接收用户id or 0=全部 or 角色id
|
|
|
+ * @param routeParam 跳转携带参数,例: id=***&type=**
|
|
|
+ */
|
|
|
+ String title = flowMain.getApplyTheme();
|
|
|
+ HandleTypeEnum typeEnum = HandleTypeEnum.YSKTZ;
|
|
|
+ Integer srcUserType = 0;//来源用户类型 0管理,1企业
|
|
|
+ String srcUserId = ShiroUtils.getUserId();
|
|
|
+ String srcUserName = ShiroUtils.getUser().getTruename();
|
|
|
+ String receiveUserId = push.getPushUser();
|
|
|
+ String routeParam = "id=" + flowId + "&flowMainPushId=" + push.getId() + "&applyUser=" + flowMain.getApplyUser();
|
|
|
+ HandleTypeEnum.YSKTZ.setUrl(waitUrl);
|
|
|
+ parkWaitHandleService.addHandle(title, typeEnum, srcUserType, srcUserId, srcUserName, receiveUserId, routeParam);
|
|
|
+
|
|
|
+ // TODO: 2024/11/21 和泛微对接 推送信息
|
|
|
+ FrameUser receiveUser = frameUserService.selectByPrimaryKey(receiveUserId);
|
|
|
+ String username = encryptUsername(receiveUser.getUsername());
|
|
|
+ String syscode = "AJ";
|
|
|
+ String requestname = flowMain.getApplyTheme();
|
|
|
+ String workflowname = ConstantFlowType.FINANCE_NAME;
|
|
|
+ String nodeName = flowMainPush.getNodeName();
|
|
|
+ String pcurl = serverUrl + "&loginid=" + username;
|
|
|
+ String appurl = "";
|
|
|
+ String isremark = "0";
|
|
|
+ String viewtype = "0";
|
|
|
+ // TODO: 2024/11/15 创建者和接收者需求oa协商
|
|
|
+ String creator = "ceshi";
|
|
|
+ String receiver = "ceshi";
|
|
|
+ String date = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, new Date());
|
|
|
+ String receivets = System.currentTimeMillis() + "";
|
|
|
+
|
|
|
+ Map map = new HashMap<String, Object>();
|
|
|
+ map.put("syscode", syscode);
|
|
|
+ map.put("flowid", flowId);
|
|
|
+ map.put("requestname", requestname);
|
|
|
+ map.put("workflowname", workflowname);
|
|
|
+ map.put("nodeName", nodeName);
|
|
|
+ map.put("pcurl", pcurl);
|
|
|
+ map.put("appurl", appurl);
|
|
|
+ map.put("creator", creator);
|
|
|
+ map.put("createdatetime", date);
|
|
|
+ map.put("receiver", receiver);
|
|
|
+ map.put("receivedatetime", date);
|
|
|
+ map.put("isremark", isremark);
|
|
|
+ map.put("viewtype", viewtype);
|
|
|
+ map.put("receivets", receivets);
|
|
|
+
|
|
|
+ log.info("泛微推送详情:{}", map);
|
|
|
+ String result = OAUtil.receiveRequestInfoByJson(map);
|
|
|
+ log.info("泛微推送结果:{}", result);
|
|
|
+
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("推送异常", e);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取待办页面的url
|
|
|
+ *
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public String getWaitUrl() {
|
|
|
+
|
|
|
+ String waitUrl = "";
|
|
|
+ // 查询待办页面的 菜单id
|
|
|
+ FramePermissionExample framePermissionExample = new FramePermissionExample();
|
|
|
+ framePermissionExample.createCriteria().andNameEqualTo("流程审批");
|
|
|
+ List<FramePermission> framePermissions = framePermissionService.selectByExample(framePermissionExample);
|
|
|
+ if (CollectionUtils.isNotEmpty(framePermissions)) {
|
|
|
+ String menuIndex = framePermissions.get(0).getId();
|
|
|
+ FramePermissionExample permissionExample = new FramePermissionExample();
|
|
|
+ permissionExample.createCriteria().andNameEqualTo("付款审批流程");
|
|
|
+ List<FramePermission> permissions = framePermissionService.selectByExample(framePermissionExample);
|
|
|
+ if (CollectionUtils.isNotEmpty(permissions)) {
|
|
|
+ String subMenu = permissions.get(0).getId();
|
|
|
+ waitUrl = "/backstage?menuIndex=" + menuIndex + "&subMenu=" + subMenu;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ return waitUrl;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 加密用户名
|
|
|
+ *
|
|
|
+ * @param username
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public String encryptUsername(String username) {
|
|
|
+
|
|
|
+ byte[] key = Base64.decode(ssoKey);
|
|
|
+ // 构建
|
|
|
+ AES aes = SecureUtil.aes(key);
|
|
|
+ return aes.encryptHex(username);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+}
|