123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379 |
- 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<String, Object> 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<String, Object> 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<FlowMainCcVo> 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<FlowMainCcVo> 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<String, Object> 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<ApplyPaymentSettle> page= modelService.list(tablepar,model,dt);
- // TableSplitResult<ApplyPaymentSettle> result=new TableSplitResult<ApplyPaymentSettle>(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);
- // }
- }
|