package com.idea.oa.apply.controller; import cn.hutool.core.codec.Base64; import cn.hutool.core.util.CharsetUtil; import cn.hutool.crypto.SecureUtil; import cn.hutool.crypto.symmetric.AES; import cn.hutool.crypto.symmetric.SymmetricAlgorithm; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.idea.oa.apply.model.inout.AddConfirmResult; import com.idea.oa.apply.model.inout.ApplyPaymentSettleIn; import com.idea.oa.apply.service.ApplyPaymentSettleService; 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.model.in.FlowMainCcVo; import com.idea.oa.flow2.service.FlowMainCcService; 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.BaseController; import com.rockstar.common.domain.AjaxResult; import com.rockstar.flow.exception.FlowException; 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.UUIDUtils; import io.swagger.annotations.Api; import lombok.extern.slf4j.Slf4j; import org.apache.commons.codec.digest.DigestUtils; import org.apache.commons.collections.CollectionUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Controller; import org.springframework.transaction.annotation.Transactional; import org.springframework.util.StringUtils; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; import java.math.BigDecimal; import java.math.MathContext; import java.text.SimpleDateFormat; import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; /** * Created by zt on 2023 */ @Slf4j @Controller @RequestMapping(value = "/ApplyPaymentSettleController") @Api(value = "分表_付款申请") public class ApplyPaymentSettleController extends BaseController { //主表 @Autowired private ApplyPaymentSettleService modelService; @Autowired private FlowMainCcService flowMainCcService; @Autowired private FlowMainPushService flowMainPushService; @Autowired private FlowMainService flowMainService; @Autowired private FrameUserService frameUserService; @Autowired private ParkWaitHandleService parkWaitHandleService; /** * 付款记录编号 : 付款领用单20240401-002 * * @return */ @PostMapping(value = "getMaxNum", produces = {"application/json;charset=UTF-8"}) @ResponseBody public String getMaxNum() { return modelService.getMaxNum(); } /** * 添加审核结果 * 根据不同的状态值confirmResult判断是 1:审核通过,转下一步;2:退回发起人;3:退回上节点;4:结束流程; * * @param addConfirmResult * @return */ @PostMapping(value = "AddConfirmResult", produces = {"application/json;charset=UTF-8"}) @ResponseBody @Transactional public AjaxResult AddConfirmResult(AddConfirmResult addConfirmResult) throws FlowException { System.out.println("AddConfirmResult"); System.out.println(addConfirmResult); if (addConfirmResult.getConfirmResult() == null) { return result(-1); } // String deploymentid = ConstantFlowType.USE_MONEY_DEPLOYMENTID; // String constantFlowType = ConstantFlowType.USE_MONEY; FlowMainPush flowMainPush = flowMainPushService.selectByPrimaryKey(addConfirmResult.getFlowMainPushId()); String isOkString = null; {//进行审核判断 //添加判断条件 HashMap feeMoneyTotalMap = null;//new HashMap<>(); isOkString = flowMainService.doConfirmResult(addConfirmResult, ConstantFlowType.PAYMENT_DEPLOYMENTID, ConstantFlowType.PAYMENT, flowMainPush, feeMoneyTotalMap); if (!"ok_end".equals(isOkString) && !"ok_noEnd".equals(isOkString)) { return AjaxResult.error(isOkString); } } String waitUrl = modelService.getWaitUrl(); FlowMain flowMain = flowMainService.selectByPrimaryKey(flowMainPush.getFlowMainId()); String flowId = flowMain.getId(); // 进行审核操作后 就要处理待办 清除数据 String param = "id=" + flowId + "&flowMainPushId=" + flowMainPush.getId() + "&applyUser=" + flowMain.getApplyUser(); parkWaitHandleService.userHandle(HandleTypeEnum.FK, param, ShiroUtils.getUserId()); Boolean isEnd = false;//是否结束 Boolean isAgree = false;//是否同意 if (addConfirmResult.getConfirmResult().equals("4")) {//结束流程 isEnd = true; isAgree = false; } else if (addConfirmResult.getConfirmResult().equals("1")) {//1:审核通过,转下一步 if ("ok_end".equals(isOkString)) { isEnd = true; isAgree = true; } else { modelService.pushOaAndHandle(flowMainPush, flowMain, waitUrl); } } else if (addConfirmResult.getConfirmResult().equals("2")) { // 退回发起人 modelService.pushOaAndHandle(flowMainPush, flowMain, waitUrl); } else if (addConfirmResult.getConfirmResult().equals("3")) { // 退回上一节点 modelService.pushOaAndHandle(flowMainPush, flowMain, waitUrl); } //添加业务信息(将请假信息中的修改掉,剩余年假,剩余调休,冻结年假,冻结调休都修改掉) if (isEnd) { } return result(1); } /** * 发起付款申请流程 * * @param record * @return */ @PostMapping(value = "addApplyPaymentSettle", produces = {"application/json;charset=UTF-8"}) @ResponseBody @Transactional public AjaxResult addApplyPaymentSettle(ApplyPaymentSettleIn record) throws FlowException { System.out.println("addApplyPaymentSettle"); System.out.println(record); if (false) { return AjaxResult.error("这是一个错误测试信息"); } return myaddApplyPayment(record, null); } /** * 申请人重新发起申请 * * @param record * @return */ @PostMapping(value = "addApplyPaymentSettleAgain", produces = {"application/json;charset=UTF-8"}) @ResponseBody @Transactional public AjaxResult addApplyPaymentSettleAgain(ApplyPaymentSettleIn record) throws FlowException { System.out.println("addApplyPaymentSettleAgain"); if (StringUtils.isEmpty(record.getFlowMainId())) { return AjaxResult.error("没有传入flowMainId的值"); } System.out.println(record); // record.setRemark("重新发起申请[" + record.getFlowMainId() + "],"); {//修改重新发起前的表状态 FlowMain flowMain1 = new FlowMain(); flowMain1.setId(record.getFlowMainId()); flowMain1.setReturnStatus(1);//0/null无状态,1已撤回并且已重新发起 flowMain1.setUpdatedAt(new Date()); flowMain1.setUpdatedBy(ShiroUtils.getUser().getId()); flowMainService.updateByPrimaryKeySelective(flowMain1); } return myaddApplyPayment(record, "重新发起申请[" + record.getFlowMainId() + "],"); } /** * 发起请假申请流程 * * @param record * @return */ public AjaxResult myaddApplyPayment(ApplyPaymentSettleIn record, String addSystemRemark) throws FlowException { String id = UUIDUtils.middleUUID(); { record.setUpdatedAt(new Date()); record.setCreatedAt(record.getUpdatedAt()); record.setCreatedBy(ShiroUtils.getUser().getId()); record.setUpdatedBy(record.getCreatedBy()); record.setCreatedByDept(ShiroUtils.getUser().getDepartment()); record.setFlowNum(UUIDUtils.middleUUID()); record.setStatus(0); record.setId(id); modelService.insertWithoutId(record); } HashMap feeMoneyTotalMap = null;//new HashMap<>(); String applyTheme = "" + ShiroUtils.getUser().getTruename() + "的付款申请单"; AjaxResult ajaxResult = flowMainService.doFlowMain(applyTheme, record.getId(), addSystemRemark, record.getCcList(), ConstantFlowType.PAYMENT_PROCESSDEFINE, ConstantFlowType.PAYMENT_DEPLOYMENTID, feeMoneyTotalMap, ConstantFlowType.PAYMENT_NAME, ConstantFlowType.PAYMENT, ShiroUtils.getUser()); modelService.startOaAndHandle(record.getId(), applyTheme); if (ajaxResult.get("code").equals(1688)) { // //表成功了 且已经审核完成 //// 需要进行后续的处理 // Boolean isEnd = true;//是否结束 // Boolean isAgree = true;//是否同意 // // //添加业务信息(将请假信息中的修改掉,剩余年假,剩余调休,冻结年假,冻结调休都修改掉) // if (isEnd) { // // if (isAgree) {//如果是最后 并且同意了,就进行下面的操作,或者不同意就进行另一种操作, // // // } else { // //如果是不同意 // { //// 不需要做什么 // } // } // } return AjaxResult.success(); } else { return ajaxResult; } } /** * 根据推送表的FlowMainPushId获取信息 * * @param flowMainPushId * @return */ @PostMapping(value = "getInfoByFlowMainPushId", produces = {"application/json;charset=UTF-8"}) @ResponseBody public ApplyPaymentSettleIn getInfoByFlowMainPushId(String flowMainPushId) { ApplyPaymentSettleIn myApplyPaymentSettleIn = modelService.getInfoByFlowMainPushId(flowMainPushId); if (myApplyPaymentSettleIn != null) { {//获取抄送人 List flowMainCcList = flowMainCcService.selectVoByFlowMainId(myApplyPaymentSettleIn.getFlowMainId()); myApplyPaymentSettleIn.setFlowMainCcList(flowMainCcList); } } return myApplyPaymentSettleIn; } /** * 根据主表的FlowMainId获取信息 * * @param flowMainId * @return */ @PostMapping(value = "getInfoByFlowMainId", produces = {"application/json;charset=UTF-8"}) @ResponseBody public ApplyPaymentSettleIn getInfoByFlowMainId(String flowMainId) { ApplyPaymentSettleIn myApplyPaymentSettleIn = modelService.getInfoByFlowMainId(flowMainId); if (myApplyPaymentSettleIn != null) { {//获取抄送人 List flowMainCcList = flowMainCcService.selectVoByFlowMainId(myApplyPaymentSettleIn.getFlowMainId()); myApplyPaymentSettleIn.setFlowMainCcList(flowMainCcList); } } return myApplyPaymentSettleIn; } /** * 根据用户id获取用户姓名和部门名称,岗位信息 * * @param userId * @return */ @PostMapping(value = "getUserInfoByUserId", produces = {"application/json;charset=UTF-8"}) @ResponseBody public Map getUserInfoByUserId(String userId) { if (StringUtils.isEmpty(userId)) { userId = ShiroUtils.getUser().getId(); } return modelService.getUserInfoByUserId(userId); } //=====下面原生的============================================================================================================= // @PostMapping(value = "list",produces = {"application/json;charset=UTF-8"}) // @ResponseBody // public Object list(Tablepar tablepar, ApplyPaymentSettle model, DateTrans dt){ // PageInfo page= modelService.list(tablepar,model,dt); // TableSplitResult result=new TableSplitResult(page.getPageNum(), page.getTotal(), page.getList()); // return result; // } // // @PostMapping(value = "listAll",produces = {"application/json;charset=UTF-8"}) // @ResponseBody // public Object listAll(ApplyPaymentSettle model, DateTrans dt){ // return modelService.listAll(model,dt); // } // // @PostMapping(value = "add",produces = {"application/json;charset=UTF-8"}) // @ResponseBody // public AjaxResult add(ApplyPaymentSettle record){ // record.setCreatedAt(new Date()); // int result = modelService.insert(record); // return result(result); // } // // @PostMapping(value = "remove/{id}",produces = {"application/json;charset=UTF-8"}) // @ResponseBody // public AjaxResult remove(@PathVariable("id") String id){ // int result = -1;//modelService.deleteByPrimaryKey(id); // return result(result); // } // // @PostMapping(value = "edit",produces = {"application/json;charset=UTF-8"}) // @ResponseBody // public AjaxResult editSave(ApplyPaymentSettle model){ // int result = modelService.updateByPrimaryKeySelective(model); // return result(result); // } // // @PostMapping(value = "getById",produces = {"application/json;charset=UTF-8"}) // @ResponseBody // public ApplyPaymentSettle getById(String id) { // return modelService.selectByPrimaryKey(id); // } }