ApplyPaymentSettleController.java 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379
  1. package com.idea.oa.apply.controller;
  2. import cn.hutool.core.codec.Base64;
  3. import cn.hutool.core.util.CharsetUtil;
  4. import cn.hutool.crypto.SecureUtil;
  5. import cn.hutool.crypto.symmetric.AES;
  6. import cn.hutool.crypto.symmetric.SymmetricAlgorithm;
  7. import com.alibaba.fastjson.JSONArray;
  8. import com.alibaba.fastjson.JSONObject;
  9. import com.idea.oa.apply.model.inout.AddConfirmResult;
  10. import com.idea.oa.apply.model.inout.ApplyPaymentSettleIn;
  11. import com.idea.oa.apply.service.ApplyPaymentSettleService;
  12. import com.idea.oa.apply.util.constant.ConstantFlowType;
  13. import com.idea.oa.flow2.model.FlowMain;
  14. import com.idea.oa.flow2.model.FlowMainExample;
  15. import com.idea.oa.flow2.model.FlowMainPush;
  16. import com.idea.oa.flow2.model.FlowMainPushExample;
  17. import com.idea.oa.flow2.model.in.FlowMainCcVo;
  18. import com.idea.oa.flow2.service.FlowMainCcService;
  19. import com.idea.oa.flow2.service.FlowMainPushService;
  20. import com.idea.oa.flow2.service.FlowMainService;
  21. import com.idea.util.DateUtils;
  22. import com.idea.util.OAUtil;
  23. import com.idea.workPanel.enume.HandleTypeEnum;
  24. import com.idea.workPanel.service.ParkWaitHandleService;
  25. import com.rockstar.common.base.BaseController;
  26. import com.rockstar.common.domain.AjaxResult;
  27. import com.rockstar.flow.exception.FlowException;
  28. import com.rockstar.frame.model.FramePermission;
  29. import com.rockstar.frame.model.FramePermissionExample;
  30. import com.rockstar.frame.model.FrameUser;
  31. import com.rockstar.frame.service.FramePermissionService;
  32. import com.rockstar.frame.service.FrameUserService;
  33. import com.rockstar.shiro.util.ShiroUtils;
  34. import com.rockstar.util.UUIDUtils;
  35. import io.swagger.annotations.Api;
  36. import lombok.extern.slf4j.Slf4j;
  37. import org.apache.commons.codec.digest.DigestUtils;
  38. import org.apache.commons.collections.CollectionUtils;
  39. import org.springframework.beans.factory.annotation.Autowired;
  40. import org.springframework.beans.factory.annotation.Value;
  41. import org.springframework.stereotype.Controller;
  42. import org.springframework.transaction.annotation.Transactional;
  43. import org.springframework.util.StringUtils;
  44. import org.springframework.web.bind.annotation.PostMapping;
  45. import org.springframework.web.bind.annotation.RequestMapping;
  46. import org.springframework.web.bind.annotation.ResponseBody;
  47. import java.math.BigDecimal;
  48. import java.math.MathContext;
  49. import java.text.SimpleDateFormat;
  50. import java.util.Date;
  51. import java.util.HashMap;
  52. import java.util.List;
  53. import java.util.Map;
  54. /**
  55. * Created by zt on 2023
  56. */
  57. @Slf4j
  58. @Controller
  59. @RequestMapping(value = "/ApplyPaymentSettleController")
  60. @Api(value = "分表_付款申请")
  61. public class ApplyPaymentSettleController extends BaseController {
  62. //主表
  63. @Autowired
  64. private ApplyPaymentSettleService modelService;
  65. @Autowired
  66. private FlowMainCcService flowMainCcService;
  67. @Autowired
  68. private FlowMainPushService flowMainPushService;
  69. @Autowired
  70. private FlowMainService flowMainService;
  71. @Autowired
  72. private FrameUserService frameUserService;
  73. @Autowired
  74. private ParkWaitHandleService parkWaitHandleService;
  75. /**
  76. * 付款记录编号 : 付款领用单20240401-002
  77. *
  78. * @return
  79. */
  80. @PostMapping(value = "getMaxNum", produces = {"application/json;charset=UTF-8"})
  81. @ResponseBody
  82. public String getMaxNum() {
  83. return modelService.getMaxNum();
  84. }
  85. /**
  86. * 添加审核结果
  87. * 根据不同的状态值confirmResult判断是 1:审核通过,转下一步;2:退回发起人;3:退回上节点;4:结束流程;
  88. *
  89. * @param addConfirmResult
  90. * @return
  91. */
  92. @PostMapping(value = "AddConfirmResult", produces = {"application/json;charset=UTF-8"})
  93. @ResponseBody
  94. @Transactional
  95. public AjaxResult AddConfirmResult(AddConfirmResult addConfirmResult) throws FlowException {
  96. System.out.println("AddConfirmResult");
  97. System.out.println(addConfirmResult);
  98. if (addConfirmResult.getConfirmResult() == null) {
  99. return result(-1);
  100. }
  101. // String deploymentid = ConstantFlowType.USE_MONEY_DEPLOYMENTID;
  102. // String constantFlowType = ConstantFlowType.USE_MONEY;
  103. FlowMainPush flowMainPush = flowMainPushService.selectByPrimaryKey(addConfirmResult.getFlowMainPushId());
  104. String isOkString = null;
  105. {//进行审核判断
  106. //添加判断条件
  107. HashMap<String, Object> feeMoneyTotalMap = null;//new HashMap<>();
  108. isOkString = flowMainService.doConfirmResult(addConfirmResult, ConstantFlowType.PAYMENT_DEPLOYMENTID, ConstantFlowType.PAYMENT, flowMainPush, feeMoneyTotalMap);
  109. if (!"ok_end".equals(isOkString) && !"ok_noEnd".equals(isOkString)) {
  110. return AjaxResult.error(isOkString);
  111. }
  112. }
  113. String waitUrl = modelService.getWaitUrl();
  114. FlowMain flowMain = flowMainService.selectByPrimaryKey(flowMainPush.getFlowMainId());
  115. String flowId = flowMain.getId();
  116. // 进行审核操作后 就要处理待办 清除数据
  117. String param = "id=" + flowId + "&flowMainPushId=" + flowMainPush.getId() + "&applyUser=" + flowMain.getApplyUser();
  118. parkWaitHandleService.userHandle(HandleTypeEnum.FK, param, ShiroUtils.getUserId());
  119. Boolean isEnd = false;//是否结束
  120. Boolean isAgree = false;//是否同意
  121. if (addConfirmResult.getConfirmResult().equals("4")) {//结束流程
  122. isEnd = true;
  123. isAgree = false;
  124. } else if (addConfirmResult.getConfirmResult().equals("1")) {//1:审核通过,转下一步
  125. if ("ok_end".equals(isOkString)) {
  126. isEnd = true;
  127. isAgree = true;
  128. } else {
  129. modelService.pushOaAndHandle(flowMainPush, flowMain, waitUrl);
  130. }
  131. } else if (addConfirmResult.getConfirmResult().equals("2")) { // 退回发起人
  132. modelService.pushOaAndHandle(flowMainPush, flowMain, waitUrl);
  133. } else if (addConfirmResult.getConfirmResult().equals("3")) { // 退回上一节点
  134. modelService.pushOaAndHandle(flowMainPush, flowMain, waitUrl);
  135. }
  136. //添加业务信息(将请假信息中的修改掉,剩余年假,剩余调休,冻结年假,冻结调休都修改掉)
  137. if (isEnd) {
  138. }
  139. return result(1);
  140. }
  141. /**
  142. * 发起付款申请流程
  143. *
  144. * @param record
  145. * @return
  146. */
  147. @PostMapping(value = "addApplyPaymentSettle", produces = {"application/json;charset=UTF-8"})
  148. @ResponseBody
  149. @Transactional
  150. public AjaxResult addApplyPaymentSettle(ApplyPaymentSettleIn record) throws FlowException {
  151. System.out.println("addApplyPaymentSettle");
  152. System.out.println(record);
  153. if (false) {
  154. return AjaxResult.error("这是一个错误测试信息");
  155. }
  156. return myaddApplyPayment(record, null);
  157. }
  158. /**
  159. * 申请人重新发起申请
  160. *
  161. * @param record
  162. * @return
  163. */
  164. @PostMapping(value = "addApplyPaymentSettleAgain", produces = {"application/json;charset=UTF-8"})
  165. @ResponseBody
  166. @Transactional
  167. public AjaxResult addApplyPaymentSettleAgain(ApplyPaymentSettleIn record) throws FlowException {
  168. System.out.println("addApplyPaymentSettleAgain");
  169. if (StringUtils.isEmpty(record.getFlowMainId())) {
  170. return AjaxResult.error("没有传入flowMainId的值");
  171. }
  172. System.out.println(record);
  173. // record.setRemark("重新发起申请[" + record.getFlowMainId() + "],");
  174. {//修改重新发起前的表状态
  175. FlowMain flowMain1 = new FlowMain();
  176. flowMain1.setId(record.getFlowMainId());
  177. flowMain1.setReturnStatus(1);//0/null无状态,1已撤回并且已重新发起
  178. flowMain1.setUpdatedAt(new Date());
  179. flowMain1.setUpdatedBy(ShiroUtils.getUser().getId());
  180. flowMainService.updateByPrimaryKeySelective(flowMain1);
  181. }
  182. return myaddApplyPayment(record, "重新发起申请[" + record.getFlowMainId() + "],");
  183. }
  184. /**
  185. * 发起请假申请流程
  186. *
  187. * @param record
  188. * @return
  189. */
  190. public AjaxResult myaddApplyPayment(ApplyPaymentSettleIn record, String addSystemRemark) throws FlowException {
  191. String id = UUIDUtils.middleUUID();
  192. {
  193. record.setUpdatedAt(new Date());
  194. record.setCreatedAt(record.getUpdatedAt());
  195. record.setCreatedBy(ShiroUtils.getUser().getId());
  196. record.setUpdatedBy(record.getCreatedBy());
  197. record.setCreatedByDept(ShiroUtils.getUser().getDepartment());
  198. record.setFlowNum(UUIDUtils.middleUUID());
  199. record.setStatus(0);
  200. record.setId(id);
  201. modelService.insertWithoutId(record);
  202. }
  203. HashMap<String, Object> feeMoneyTotalMap = null;//new HashMap<>();
  204. String applyTheme = "" + ShiroUtils.getUser().getTruename() + "的付款申请单";
  205. AjaxResult ajaxResult = flowMainService.doFlowMain(applyTheme, record.getId(), addSystemRemark, record.getCcList(), ConstantFlowType.PAYMENT_PROCESSDEFINE, ConstantFlowType.PAYMENT_DEPLOYMENTID, feeMoneyTotalMap, ConstantFlowType.PAYMENT_NAME, ConstantFlowType.PAYMENT, ShiroUtils.getUser());
  206. modelService.startOaAndHandle(record.getId(), applyTheme);
  207. if (ajaxResult.get("code").equals(1688)) {
  208. // //表成功了 且已经审核完成
  209. //// 需要进行后续的处理
  210. // Boolean isEnd = true;//是否结束
  211. // Boolean isAgree = true;//是否同意
  212. //
  213. // //添加业务信息(将请假信息中的修改掉,剩余年假,剩余调休,冻结年假,冻结调休都修改掉)
  214. // if (isEnd) {
  215. //
  216. // if (isAgree) {//如果是最后 并且同意了,就进行下面的操作,或者不同意就进行另一种操作,
  217. //
  218. //
  219. // } else {
  220. // //如果是不同意
  221. // {
  222. //// 不需要做什么
  223. // }
  224. // }
  225. // }
  226. return AjaxResult.success();
  227. } else {
  228. return ajaxResult;
  229. }
  230. }
  231. /**
  232. * 根据推送表的FlowMainPushId获取信息
  233. *
  234. * @param flowMainPushId
  235. * @return
  236. */
  237. @PostMapping(value = "getInfoByFlowMainPushId", produces = {"application/json;charset=UTF-8"})
  238. @ResponseBody
  239. public ApplyPaymentSettleIn getInfoByFlowMainPushId(String flowMainPushId) {
  240. ApplyPaymentSettleIn myApplyPaymentSettleIn = modelService.getInfoByFlowMainPushId(flowMainPushId);
  241. if (myApplyPaymentSettleIn != null) {
  242. {//获取抄送人
  243. List<FlowMainCcVo> flowMainCcList = flowMainCcService.selectVoByFlowMainId(myApplyPaymentSettleIn.getFlowMainId());
  244. myApplyPaymentSettleIn.setFlowMainCcList(flowMainCcList);
  245. }
  246. }
  247. return myApplyPaymentSettleIn;
  248. }
  249. /**
  250. * 根据主表的FlowMainId获取信息
  251. *
  252. * @param flowMainId
  253. * @return
  254. */
  255. @PostMapping(value = "getInfoByFlowMainId", produces = {"application/json;charset=UTF-8"})
  256. @ResponseBody
  257. public ApplyPaymentSettleIn getInfoByFlowMainId(String flowMainId) {
  258. ApplyPaymentSettleIn myApplyPaymentSettleIn = modelService.getInfoByFlowMainId(flowMainId);
  259. if (myApplyPaymentSettleIn != null) {
  260. {//获取抄送人
  261. List<FlowMainCcVo> flowMainCcList = flowMainCcService.selectVoByFlowMainId(myApplyPaymentSettleIn.getFlowMainId());
  262. myApplyPaymentSettleIn.setFlowMainCcList(flowMainCcList);
  263. }
  264. }
  265. return myApplyPaymentSettleIn;
  266. }
  267. /**
  268. * 根据用户id获取用户姓名和部门名称,岗位信息
  269. *
  270. * @param userId
  271. * @return
  272. */
  273. @PostMapping(value = "getUserInfoByUserId", produces = {"application/json;charset=UTF-8"})
  274. @ResponseBody
  275. public Map<String, Object> getUserInfoByUserId(String userId) {
  276. if (StringUtils.isEmpty(userId)) {
  277. userId = ShiroUtils.getUser().getId();
  278. }
  279. return modelService.getUserInfoByUserId(userId);
  280. }
  281. //=====下面原生的=============================================================================================================
  282. // @PostMapping(value = "list",produces = {"application/json;charset=UTF-8"})
  283. // @ResponseBody
  284. // public Object list(Tablepar tablepar, ApplyPaymentSettle model, DateTrans dt){
  285. // PageInfo<ApplyPaymentSettle> page= modelService.list(tablepar,model,dt);
  286. // TableSplitResult<ApplyPaymentSettle> result=new TableSplitResult<ApplyPaymentSettle>(page.getPageNum(), page.getTotal(), page.getList());
  287. // return result;
  288. // }
  289. //
  290. // @PostMapping(value = "listAll",produces = {"application/json;charset=UTF-8"})
  291. // @ResponseBody
  292. // public Object listAll(ApplyPaymentSettle model, DateTrans dt){
  293. // return modelService.listAll(model,dt);
  294. // }
  295. //
  296. // @PostMapping(value = "add",produces = {"application/json;charset=UTF-8"})
  297. // @ResponseBody
  298. // public AjaxResult add(ApplyPaymentSettle record){
  299. // record.setCreatedAt(new Date());
  300. // int result = modelService.insert(record);
  301. // return result(result);
  302. // }
  303. //
  304. // @PostMapping(value = "remove/{id}",produces = {"application/json;charset=UTF-8"})
  305. // @ResponseBody
  306. // public AjaxResult remove(@PathVariable("id") String id){
  307. // int result = -1;//modelService.deleteByPrimaryKey(id);
  308. // return result(result);
  309. // }
  310. //
  311. // @PostMapping(value = "edit",produces = {"application/json;charset=UTF-8"})
  312. // @ResponseBody
  313. // public AjaxResult editSave(ApplyPaymentSettle model){
  314. // int result = modelService.updateByPrimaryKeySelective(model);
  315. // return result(result);
  316. // }
  317. //
  318. // @PostMapping(value = "getById",produces = {"application/json;charset=UTF-8"})
  319. // @ResponseBody
  320. // public ApplyPaymentSettle getById(String id) {
  321. // return modelService.selectByPrimaryKey(id);
  322. // }
  323. }