ApplyPaymentSettleController.java 13 KB

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