package com.liang.controller;

import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.liang.common.base.BaseController;
import com.liang.common.base.BaseResult;
import com.liang.common.enums.PostInfoEnum;
import com.liang.entity.*;
import com.liang.service.*;
import io.swagger.annotations.ApiOperation;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*;

/**
 * 科技项目审批(PrjApproverecord)表控制层
 *
 * @author makejava
 * @since 2023-05-03 13:23:09
 */
@Controller
@RequestMapping("prjApproverecord")
public class PrjApproverecordController extends BaseController {
    /**
     * 服务对象
     */
    @Resource
    private PrjApproverecordService prjApproverecordService;
    @Resource
    private SysDictInfoService sysDictInfoService;

    @Resource
    private StaBudgetapprovalService staBudgetapprovalService;
    @Resource
    private SysUserPostService sysUserPostService;
    @Resource
    private SysDeptInfoService sysDeptInfoService;

    /**
     * 分页查询
     *
     * @param prjApproverecord 筛选条件
     * @param pageRequest      分页对象
     * @return 查询结果
     */
    @GetMapping
    public ResponseEntity<Page<PrjApproverecord>> queryByPage(PrjApproverecord prjApproverecord, PageRequest pageRequest) {
        return ResponseEntity.ok(this.prjApproverecordService.queryByPage(prjApproverecord, pageRequest));
    }

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("{id}")
    public ResponseEntity<PrjApproverecord> queryById(@PathVariable("id") Integer id) {
        return ResponseEntity.ok(this.prjApproverecordService.queryById(id));
    }

    /**
     * 删除数据
     *
     * @param id 主键
     * @return 删除是否成功
     */
    @DeleteMapping
    public ResponseEntity<Boolean> deleteById(Integer id) {
        return ResponseEntity.ok(this.prjApproverecordService.deleteById(id));
    }

    @ApiOperation(value = "页面初始化", notes = "页面初始化")
    @RequestMapping(value = "/init", method = RequestMethod.GET)
    public String init(Model model) {
        //状态
        List<Map<String, String>> approveList = sysDictInfoService.queryByCode("kybg_status");
        approveList.addAll(sysDictInfoService.queryByCode("approve_status"));
        model.addAttribute("approveList", approveList);

        return "prjapproverecord/list";
    }
    @ApiOperation(value = "页面初始化", notes = "页面初始化")
    @RequestMapping(value = "/inits", method = RequestMethod.GET)
    public String inits(Model model) {
      /*  //状态
        List<Map<String, String>> approveList = sysDictInfoService.queryByCode("kybg_status");
        approveList.addAll(sysDictInfoService.queryByCode("approve_status"));
        model.addAttribute("approveList", approveList);*/

        return "prjproject/expect";
    }

    /**
     * 付款申请
     */
    @Resource
    private StaPayapprovalService staPayapprovalService;
    /**
     * 报账
     */
    @Resource
    private StaReimbursementService staReimbursementService;
    /**
     * 费用申请
     */
    @Resource
    private SysUserInfoService sysUserInfoService;
    /**
     * 任务书
     */
    @Resource
    private PrjProjectService prjProjectService;

    @Resource
    private PrjAnnualbudgetService prjAnnualbudgetService;


    @ResponseBody
    @RequestMapping(value = "/list", method = RequestMethod.POST)
    public BaseResult    list(@RequestParam("page") Integer pageNum,
                           @RequestParam("limit") Integer pageSize,
                           @RequestParam(required = false, defaultValue = "", value = "xm") String xm,
                           @RequestParam(required = false, defaultValue = "", value = "spzt") String zt,
                           @RequestParam(required = false, defaultValue = "", value = "wc") String wc,
                           @RequestParam(required = false, defaultValue = "", value = "tablename") String tablename,
                           @RequestParam(required = false, defaultValue = "", value = "sortName") String sortName,
                           @RequestParam(required = false, defaultValue = "", value = "sortOrder") String sortOrder) {

        List<PrjApproverecord> prjApproverecords = new ArrayList<>();
        Map<String, String> paraMap = new HashMap<>();
        paraMap.put("sortName", sortName);
        paraMap.put("sortOrder", sortOrder);
        paraMap.put("xm", xm);
        paraMap.put("zt", zt);
        paraMap.put("wc", wc);
        paraMap.put("tablename", tablename);
        SysUserInfo userInfo = getSysUserInfo();
        if (!userInfo.getAccount().equals("admin")) {
            paraMap.put("userId", userInfo.getUserId().toString());
        }
            paraMap.put("id",userInfo.getUserId().toString());
        // 获取当前人员岗位名称
        List<SysUserInfo> accounts = sysUserInfoService.getGw(paraMap);
        // 去重
        if (accounts.size()==0){
            return BaseResult.success(prjApproverecords);
        }
        // 创建 SimpleDateFormat，定义输出格式
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            Map<String, Object> maps = new HashMap<>();
            for (int i = 0 ;i<accounts.size();i++) {

                if (accounts.get(i).getUserPostName() == null){
                    continue;
                }
                maps.put("spzt", accounts.get(i).getUserPostName() + "审批");
                if (accounts.get(i).getUserPostName().equals("部门主任")){
                    maps.put("ssbmmc",getSysUserInfo().getDeptName());
                    maps.put("ssbm",getSysUserInfo().getDeptName());
                }
                /*
                maps.put("xmmc");
                maps.put()*/
                // 获取费用申请界面全部审批数据
                List<StaBudgetapproval> fysq = staBudgetapprovalService.getAllApplyList(maps);
                if (fysq.size() > 0) {
                    for (int j = 0; j < fysq.size(); j++) {
                        // 将 Date 转换为 String
                        String formattedDate = formatter.format(fysq.get(j).getSqsj());
                        PrjApproverecord prjApproverecord = new PrjApproverecord();
                        prjApproverecord.setXmlxmc("费用申请");
                        prjApproverecord.setXm(fysq.get(j).getXmmc());
                        prjApproverecord.setErpbh(fysq.get(j).getErpbh());
                        prjApproverecord.setTjrxm(fysq.get(j).getSqrxm());
                        prjApproverecord.setTjsj(formattedDate);
                        prjApproverecord.setSpzt(fysq.get(j).getSpzt());
                        prjApproverecord.setTablename("sta_BudgetApproval");
                        prjApproverecord.setXmid(fysq.get(j).getId());
                        prjApproverecord.setSqje(fysq.get(j).getSqje());
                        // 存入费用申请至list集合
                        prjApproverecords.add(prjApproverecord);
                    }
                }
                //获取报账列表全部审批数据
                List<StaReimbursement> bz = staReimbursementService.getReimburseList(maps);
                if (bz.size() > 0) {
                    for (int k = 0; k < bz.size(); k++) {
                        String formattedDate = formatter.format(bz.get(k).getCjsj());
                        PrjApproverecord prjApproverecord = new PrjApproverecord();
                        prjApproverecord.setXmlxmc("报账");
                        prjApproverecord.setXm(bz.get(k).getXmmc());
                        prjApproverecord.setErpbh(bz.get(k).getErpbh());
                        prjApproverecord.setTjrxm(bz.get(k).getBzrxm());
                        prjApproverecord.setTjsj(formattedDate);
                        prjApproverecord.setSpzt(bz.get(k).getSpzt());
                        prjApproverecord.setTablename("sta_Reimbursement");
                        prjApproverecord.setXmid(bz.get(k).getId());
                        prjApproverecord.setBzje(bz.get(k).getBzje());
                        // 存入 报账数据至 list 集合
                        prjApproverecords.add(prjApproverecord);
                    }
                }
                if (accounts.get(i).getUserPostName().equals("科技项目管理专责1") ||
                        accounts.get(i).getUserPostName().equals("科技项目管理专责2") ||
                accounts.get(i).getUserPostName().equals("科技部部门主任")){
                    // 获取付款申请界面全部审批数据
                    List<StaPayapproval> fk = staPayapprovalService.getFksqList(maps);
                    if (fk.size() > 0) {
                        for (int l = 0; l < fk.size(); l++) {
                            String formattedDate = formatter.format(fk.get(l).getCjsj());
                            PrjApproverecord prjApproverecord = new PrjApproverecord();
                            prjApproverecord.setXmlxmc("付款申请");
                            prjApproverecord.setXm(fk.get(l).getXmmc());
                            prjApproverecord.setErpbh(fk.get(l).getErpbh());
                            prjApproverecord.setTjrxm(fk.get(l).getCjrxm());
                            prjApproverecord.setTjsj(formattedDate);
                            prjApproverecord.setSpzt(fk.get(l).getSpzt());
                            prjApproverecord.setTablename("sta_PayApproval");
                            prjApproverecord.setXmid(fk.get(l).getId());
                            prjApproverecord.setHtje(fk.get(l).getHtje());
                            // 存入 付款数据至 list 集合
                            prjApproverecords.add(prjApproverecord);
                        }
                    }
                }
                if (accounts.get(i).getUserPostName().equals("科研计划专责 ")){
                    // 获取任务数据界面全部审批数据
                    List<PrjProject> rws = prjProjectService.getProjectList(maps);
                    if (rws.size() > 0) {
                        for (int m = 0; m < rws.size(); m++) {
                            String formattedDate = formatter.format(rws.get(m).getCjrq());
                            PrjApproverecord prjApproverecord = new PrjApproverecord();
                            prjApproverecord.setXmlxmc("任务书");
                            prjApproverecord.setXm(rws.get(m).getZwmc());
                            prjApproverecord.setErpbh(rws.get(m).getErpbh());
                            prjApproverecord.setTjrxm(rws.get(m).getCjrxm());
                            prjApproverecord.setTjsj(formattedDate);
                            prjApproverecord.setSpzt(rws.get(m).getSpzt());
                            prjApproverecord.setTablename("prj_Project");
                            prjApproverecord.setXmid(rws.get(m).getId());
                            if (rws.get(m).getYsje()!=null){
                                prjApproverecord.setRysje(rws.get(m).getYsje().doubleValue());
                            }
                            // 存入 付款数据至 list 集合
                            prjApproverecords.add(prjApproverecord);
                        }
                    }
                }
                if (accounts.get(i).getUserPostName().equals("科技项目管理专责")){
                    // 获取年度预算界面审批数据
                    List<PrjAnnualbudget> ndys = prjAnnualbudgetService.getNdysList(maps);
                    if (ndys.size() > 0) {
                        for (int n = 0; n < ndys.size(); n++) {
                            String formattedDate = ndys.get(n).getSqsj();
                            PrjApproverecord prjApproverecord = new PrjApproverecord();
                            prjApproverecord.setXmlxmc("年度预算");
                            prjApproverecord.setXm(ndys.get(n).getXmmc());
                            prjApproverecord.setErpbh(ndys.get(n).getErpbh());
                            prjApproverecord.setTjrxm(ndys.get(n).getSqrxm());
                            prjApproverecord.setTjsj(formattedDate);
                            prjApproverecord.setSpzt(ndys.get(n).getSpzt());
                            prjApproverecord.setTablename("prj_AnnualBudget");
                            prjApproverecord.setXmid(ndys.get(n).getId());
                            // 存入 付款数据至 list 集合
                            prjApproverecords.add(prjApproverecord);
                        }
                    }
                }


            }
        // 获取年度预算修改申请审批数据
        List<PrjApproverecord> prjAnnualBudgetRecordList= prjApproverecordService.getPrjAnnualBudgetRecordList(getUserId().toString());
        if(prjAnnualBudgetRecordList.size()>0){
            for (int j = 0; j < prjAnnualBudgetRecordList.size(); j++) {
                prjApproverecords.add(prjAnnualBudgetRecordList.get(j));
            }
        }
        // 获取任务书预算修改申请审批数据
        List<PrjApproverecord> prjProjectRecordRecordList= prjApproverecordService.getPrjProjectRecordRecordList(getUserId().toString());
        if(prjProjectRecordRecordList.size()>0){
            for (int k = 0; k < prjProjectRecordRecordList.size(); k++) {
                prjApproverecords.add(prjProjectRecordRecordList.get(k));
            }
        }
        // 合同模块待审批数据
        List<PrjApproverecord> prjContractRecordList= prjApproverecordService.getprjContractRecordList(getUserId().toString());
        if(prjContractRecordList.size()>0){
            for (int k = 0; k < prjContractRecordList.size(); k++) {
                prjApproverecords.add(prjContractRecordList.get(k));
            }
        }
        // 计算总记录数
        int total = prjApproverecords.size();

        // 计算起始索引和结束索引
        int fromIndex = (pageNum - 1) * pageSize;
        int toIndex = Math.min(fromIndex + pageSize, total);

        // 确保起始索引不超过列表大小
        if (fromIndex >= total || fromIndex < 0) {
            fromIndex = total; // 返回空的结果
        }
        // 获取当前页的数据
        List<PrjApproverecord> rows = prjApproverecords.subList(fromIndex, toIndex);
        // 构建返回结果
        Map<String, Object> result = new HashMap<>();
        result.put(RESULT_ROWS, rows);
        result.put(RESULT_TOTAL, total);

        return BaseResult.success(result);
    }
    /**
     * 年度预算修改申请列表
     * */
    @ResponseBody
    @RequestMapping(value = "/xgsqList", method = RequestMethod.POST)
    public BaseResult xgsqList(@RequestParam("page") Integer pageNum,
                           @RequestParam("limit") Integer pageSize
                            ) {
        PageHelper.startPage(pageNum, pageSize);

        Map<String, String> paraMap = new HashMap<>();
        SysUserInfo userInfo = getSysUserInfo();
        if (!userInfo.getAccount().equals("admin")) {
            paraMap.put("userId", userInfo.getUserId().toString());
        }
            paraMap.put("tablename","prj_AnnualBudgetRecord");
// 获取待审批的年度预算修改申请
        List<PrjApproverecord> xglist = prjApproverecordService.getApproveList(paraMap);

        for (int i = 0; i < xglist.size(); i++) {
            xglist.get(i).setSpzt(xglist.get(i).getZt());
        }

        PageInfo<PrjApproverecord> pageinfo = new PageInfo<>(xglist);
        //取出查询结果
        List<PrjApproverecord> rows = pageinfo.getList();
        int total = (int) pageinfo.getTotal();
        Map<String, Object> result = new HashMap<>();
        result.put(RESULT_ROWS, rows);
        result.put(RESULT_TOTAL, total);

        return BaseResult.success(result);
    }
    /**
     * 合同修改申请列表
     * */
    @ResponseBody
    @RequestMapping(value = "/htxgsqList", method = RequestMethod.POST)
    public BaseResult htxgsqList(@RequestParam("page") Integer pageNum,
                           @RequestParam("limit") Integer pageSize
                            ) {
        PageHelper.startPage(pageNum, pageSize);

        Map<String, String> paraMap = new HashMap<>();
        SysUserInfo userInfo = getSysUserInfo();
        if (!userInfo.getAccount().equals("admin")) {
            paraMap.put("userId", userInfo.getUserId().toString());
        }
            paraMap.put("tablename","prj_Contract");
// 获取待审批的修改申请
        List<PrjApproverecord> xglist = prjApproverecordService.getApproveList(paraMap);

        for (int i = 0; i < xglist.size(); i++) {
            xglist.get(i).setSpzt(xglist.get(i).getZt());
        }

        PageInfo<PrjApproverecord> pageinfo = new PageInfo<>(xglist);
        //取出查询结果
        List<PrjApproverecord> rows = pageinfo.getList();
        int total = (int) pageinfo.getTotal();
        Map<String, Object> result = new HashMap<>();
        result.put(RESULT_ROWS, rows);
        result.put(RESULT_TOTAL, total);

        return BaseResult.success(result);
    }
    /**
     * 任务书修改申请列表
     * */
    @ResponseBody
    @RequestMapping(value = "/rwsxgsqList", method = RequestMethod.POST)
    public BaseResult rwsxgsqList(@RequestParam("page") Integer pageNum,
                           @RequestParam("limit") Integer pageSize
                            ) {
        PageHelper.startPage(pageNum, pageSize);

        Map<String, String> paraMap = new HashMap<>();
        SysUserInfo userInfo = getSysUserInfo();
        if (!userInfo.getAccount().equals("admin")) {
            paraMap.put("userId", userInfo.getUserId().toString());
        }
            paraMap.put("tablename","prj_ProjectRecord");
// 获取待审批的修改申请
        List<PrjApproverecord> xglist = prjApproverecordService.getApproveList(paraMap);

        for (int i = 0; i < xglist.size(); i++) {
            xglist.get(i).setSpzt(xglist.get(i).getZt());
        }

        PageInfo<PrjApproverecord> pageinfo = new PageInfo<>(xglist);
        //取出查询结果
        List<PrjApproverecord> rows = pageinfo.getList();
        int total = (int) pageinfo.getTotal();
        Map<String, Object> result = new HashMap<>();
        result.put(RESULT_ROWS, rows);
        result.put(RESULT_TOTAL, total);

        return BaseResult.success(result);
    }

    /**
     * 保存数据（提交审批：可研报告，任务书，年度预算，报账）
     *
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "/doAddApprove", method = RequestMethod.POST)
    public BaseResult doAddApprove(PrjApproverecord approverecord) {
        List<PrjApproverecord> recordList = new ArrayList<>();

        PrjApproverecord record1 = new PrjApproverecord();
        record1.setXm(approverecord.getXm());
        record1.setXmid(approverecord.getXmid());
        record1.setZt(approverecord.getZt());
        record1.setTablename(approverecord.getTablename());
        record1.setSpcz(approverecord.getSpcz());
        record1.setTjr(approverecord.getTjr());
        record1.setTjsj(approverecord.getTjsj());
        record1.setShr(record1.getTjr());
        record1.setShsj(record1.getTjsj());
        record1.setSfsjsh(true);//是否需要上级审核
        record1.setSjshr(approverecord.getSjshr());
        record1.setSjshgw(approverecord.getSjshgw());//上级审核岗位
        record1.setSffh(false);//是否返回
        record1.setYcshr(false);//隐藏审核人
        record1.setWc(true);//完成
        recordList.add(record1);

        PrjApproverecord record2 = new PrjApproverecord();
        record2.setXm(approverecord.getXm());
        record2.setXmid(approverecord.getXmid());
        record2.setTablename(approverecord.getTablename());
        record2.setTjr(approverecord.getTjr());
        record2.setTjsj(approverecord.getTjsj());
        if ("sta_FeasibilityReport".equals(approverecord.getTablename()) || "prj_Project".equals(approverecord.getTablename())) {
            record2.setZt(PostInfoEnum.KYJHZZ.postName() + "审批");//状态
        } else {
            record2.setZt(PostInfoEnum.KJXMGLZZ.postName() + "审批");//状态
        }
        record2.setWc(false);//完成
        record2.setShr(approverecord.getSjshr());//审核人
        record2.setShgw(approverecord.getSjshgw());//审核岗位
        recordList.add(record2);

        int num = prjApproverecordService.insertBatch(recordList);
        if (num > 0) {
            return BaseResult.success("保存成功!", approverecord);
        } else {
            return BaseResult.failure("保存失败!");
        }
    }
    /**
     * 保存年度预算修改申请
    * */
    @ResponseBody
    @RequestMapping(value = "/doUpdatApprove", method = RequestMethod.POST)
    public BaseResult doUpdatApprove(PrjApproverecord approverecord) {
//        获取审批列表信息
        SysUserInfo sysUserInfo = getSysUserInfo();
        List<PrjApproverecord> recordList = new ArrayList<>();//提交人
        // 获取当前时间
        LocalDateTime currentTime = LocalDateTime.now();
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");//提交时间
        //获取部门主任审批默认审核人
        Map<String, String> paraMap2 = new HashMap<>();//提交人
        paraMap2.put("deptName",sysUserInfo.getDeptName());
        if (sysUserInfo != null && sysUserInfo.getDeptId().equals("52")) {
            paraMap2.put("postName", "科技部部门主任");
            paraMap2.put("postId","16");
        } else {
            paraMap2.put("postName", "科研负责人");
            paraMap2.put("postId","28");
        }
        if(paraMap2.get("postId")=="28"){
            String deptName=sysDeptInfoService.getUserDept(sysUserInfo.getUserId());
            if(deptName.contains("电源")){
                deptName = "电源技术中心化学与环保技术室";
            }
            paraMap2.put("deptName",deptName);
        }
        List<SysUserPost> userPostList = sysUserPostService.getPostUserList(paraMap2);
        Integer shr = userPostList.get(0).getUserId();

        PrjApproverecord record1 = new PrjApproverecord();
        record1.setXm(approverecord.getXm());
        record1.setXmid(approverecord.getXmid());

        if (approverecord.getTablename() != null || "prj_Contract".equals(approverecord.getTablename())) {
            record1.setTablename(approverecord.getTablename());
            record1.setSpcz(approverecord.getSpcz());
            record1.setZt(approverecord.getSpzt());
        }else {
            record1.setTablename("prj_AnnualBudgetRecord");
            record1.setSpcz("预算申请修改");
            record1.setZt(approverecord.getZt());
        }
        record1.setTjr(sysUserInfo.getUserId());
        record1.setTjsj(currentTime.format(formatter));
        record1.setShr(record1.getTjr());
        record1.setShsj(record1.getTjsj());
        record1.setSfsjsh(true);//是否需要上级审核
        record1.setSjshr(shr);
        record1.setSjshgw(28);//上级审核岗位
        record1.setSffh(false);//是否返回
        record1.setYcshr(false);//隐藏审核人
        record1.setWc(true);//完成
        recordList.add(record1);

        PrjApproverecord record2 = new PrjApproverecord();
        record2.setXm(approverecord.getXm());
        record2.setXmid(approverecord.getXmid());
        record2.setTablename(record1.getTablename());
        record2.setTjr(sysUserInfo.getUserId());
        record2.setTjsj(currentTime.format(formatter));
        record2.setZt(PostInfoEnum.BMZR.postName() + "审批");//状态
        record2.setWc(false);//完成
        record2.setShr(shr);//审核人
        record2.setShgw(28);//审核岗位
        recordList.add(record2);

        int num = prjApproverecordService.insertBatch(recordList);
        if (num > 0) {
            return BaseResult.success("保存成功!", approverecord);
        } else {
            return BaseResult.failure("保存失败!");
        }
    }
    /**
     * 保存任务书修改申请
     * */
    @ResponseBody
    @RequestMapping(value = "/doUpdatPrjProject", method = RequestMethod.POST)
    public BaseResult doUpdatPrjProject(PrjApproverecord approverecord) {
//        获取审批列表信息
        SysUserInfo sysUserInfo = getSysUserInfo();
        List<PrjApproverecord> recordList = new ArrayList<>();//提交人

        LocalDateTime currentTime = LocalDateTime.now();
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");//提交时间


        Map<String, String> paraMap2 = new HashMap<>();
        paraMap2.put("postName", "科研计划专责");
        paraMap2.put("postId","19");
        List<SysUserPost> userPostList = sysUserPostService.getPostUserList(paraMap2);
        Integer shr = userPostList.get(0).getUserId();


        PrjApproverecord record1 = new PrjApproverecord();
        record1.setXm(approverecord.getXm());
        record1.setXmid(approverecord.getXmid());
        record1.setZt(approverecord.getZt());
        record1.setTablename("prj_ProjectRecord");
        record1.setSpcz("预算申请修改");
        record1.setTjr(sysUserInfo.getUserId());
        record1.setTjsj(currentTime.format(formatter));
        record1.setShr(record1.getTjr());
        record1.setShsj(record1.getTjsj());
        record1.setSfsjsh(true);//是否需要上级审核
        record1.setSjshr(shr);
        record1.setSjshgw(19);//上级审核岗位
        record1.setSffh(false);//是否返回
        record1.setYcshr(false);//隐藏审核人
        record1.setWc(true);//完成
        recordList.add(record1);

        PrjApproverecord record2 = new PrjApproverecord();
        record2.setXm(approverecord.getXm());
        record2.setXmid(approverecord.getXmid());
        record2.setTablename("prj_ProjectRecord");
        record2.setTjr(sysUserInfo.getUserId());
        record2.setTjsj(currentTime.format(formatter));
        record2.setZt(PostInfoEnum.KYJHZZ.postName() + "审批");//状态
        record2.setWc(false);//完成
        record2.setShr(shr);//审核人
        record2.setShgw(19);//审核岗位
        recordList.add(record2);

        int num = prjApproverecordService.insertBatch(recordList);
        if (num > 0) {
            return BaseResult.success("保存成功!", approverecord);
        } else {
            return BaseResult.failure("保存失败!");
        }
    }

    /**
     * 保存数据（提交审批：费用申请）
     *
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "/doAddApproveFysq", method = RequestMethod.POST)
    public BaseResult doAddApproveFysq(PrjApproverecord approverecord) {
        List<PrjApproverecord> recordList = new ArrayList<>();

        PrjApproverecord record1 = new PrjApproverecord();
        record1.setXm(approverecord.getXm());
        record1.setXmid(approverecord.getXmid());
        record1.setZt(approverecord.getZt());
        record1.setTablename(approverecord.getTablename());
        record1.setSpcz(approverecord.getSpcz());
        record1.setTjr(approverecord.getTjr());
        record1.setTjsj(approverecord.getTjsj());
        record1.setShr(record1.getTjr());
        record1.setShsj(record1.getTjsj());
        record1.setSfsjsh(true);//是否需要上级审核
        record1.setSjshr(approverecord.getSjshr());
        record1.setSjshgw(approverecord.getSjshgw());//上级审核岗位
        record1.setSffh(false);//是否返回
        record1.setYcshr(false);//隐藏审核人
        record1.setWc(true);//完成
        recordList.add(record1);

        PrjApproverecord record2 = new PrjApproverecord();
        record2.setXm(approverecord.getXm());
        record2.setXmid(approverecord.getXmid());
        record2.setTablename(approverecord.getTablename());
        record2.setTjr(approverecord.getTjr());
        record2.setTjsj(approverecord.getTjsj());
        record2.setZt(PostInfoEnum.BMZR.postName() + "审批");//状态
        record2.setWc(false);//完成
        record2.setShr(approverecord.getSjshr());//审核人
        record2.setShgw(approverecord.getSjshgw());//审核岗位
        recordList.add(record2);

        int num = prjApproverecordService.insertBatch(recordList);
        if (num > 0) {
            return BaseResult.success("保存成功!", approverecord);
        } else {
            return BaseResult.failure("保存失败!");
        }
    }

    /**
     * 保存数据（提交审批：付款申请）
     *
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "/doAddApproveFksq", method = RequestMethod.POST)
    public BaseResult doAddApproveFksq(PrjApproverecord approverecord) {
        List<PrjApproverecord> recordList = new ArrayList<>();

        PrjApproverecord record1 = new PrjApproverecord();
        record1.setXm(approverecord.getXm());
        record1.setXmid(approverecord.getXmid());
        record1.setZt(approverecord.getZt());
        record1.setTablename(approverecord.getTablename());
        record1.setSpcz(approverecord.getSpcz());
        record1.setTjr(approverecord.getTjr());
        record1.setTjsj(approverecord.getTjsj());
        record1.setShr(record1.getTjr());
        record1.setShsj(record1.getTjsj());
        record1.setSfsjsh(true);//是否需要上级审核
        record1.setSjshr(approverecord.getSjshr());
        record1.setSjshgw(approverecord.getSjshgw());//上级审核岗位
        record1.setSffh(false);//是否返回
        record1.setYcshr(false);//隐藏审核人
        record1.setWc(true);//完成
        recordList.add(record1);

        PrjApproverecord record2 = new PrjApproverecord();
        record2.setXm(approverecord.getXm());
        record2.setXmid(approverecord.getXmid());
        record2.setTablename(approverecord.getTablename());
        record2.setTjr(approverecord.getTjr());
        record2.setTjsj(approverecord.getTjsj());
        record2.setZt(PostInfoEnum.KJXMGLZZ2.postName() + "审批");//状态
        record2.setWc(false);//完成
        record2.setShr(approverecord.getSjshr());//审核人
        record2.setShgw(approverecord.getSjshgw());//审核岗位
        recordList.add(record2);

        int num = prjApproverecordService.insertBatch(recordList);
        if (num > 0) {
            return BaseResult.success("保存成功!", approverecord);
        } else {
            return BaseResult.failure("保存失败!");
        }
    }

    /**
     * 保存合同修改申请
     * */
    @ResponseBody
    @RequestMapping(value = "/doUpdatPrjContract", method = RequestMethod.POST)
    public BaseResult doUpdatPrjContract(PrjApproverecord approverecord) {
//        获取审批列表信息
        SysUserInfo sysUserInfo = getSysUserInfo();
        List<PrjApproverecord> recordList = new ArrayList<>();//提交人

        LocalDateTime currentTime = LocalDateTime.now();
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");//提交时间


        Map<String, String> paraMap2 = new HashMap<>();
        paraMap2.put("postName", "科技项目管理专责");
        paraMap2.put("postId","39");
        List<SysUserPost> userPostList = sysUserPostService.getPostUserList(paraMap2);
        Integer shr = userPostList.get(0).getUserId();


        PrjApproverecord record1 = new PrjApproverecord();
        record1.setXm(approverecord.getXm());
        record1.setXmid(approverecord.getId());
        record1.setZt("未提交");
        record1.setTablename("prj_Contract");
        record1.setSpcz("合同修改申请");
        record1.setTjr(sysUserInfo.getUserId());
        record1.setTjsj(currentTime.format(formatter));
        record1.setShr(record1.getTjr());
        record1.setShsj(record1.getTjsj());
        record1.setSfsjsh(true);//是否需要上级审核
        record1.setSjshr(shr);
        record1.setSjshgw(39);//上级审核岗位
        record1.setSffh(false);//是否返回
        record1.setYcshr(false);//隐藏审核人
        record1.setWc(true);//完成
        recordList.add(record1);

        PrjApproverecord record2 = new PrjApproverecord();
        record2.setXm(approverecord.getXm());
        record2.setXmid(approverecord.getId());
        record2.setTablename("prj_Contract");
        record2.setTjr(sysUserInfo.getUserId());
        record2.setTjsj(currentTime.format(formatter));
        record2.setZt(PostInfoEnum.KJXMGLZZ.postName() + "审批");//状态
        record2.setWc(false);//完成
        record2.setShr(shr);//审核人
        record2.setShgw(39);//审核岗位
        recordList.add(record2);

        int num = prjApproverecordService.insertBatch(recordList);
        if (num > 0) {
            return BaseResult.success("保存成功!", approverecord);
        } else {
            return BaseResult.failure("保存失败!");
        }
    }
    /**
     * 编辑数据（提交审批：可研报告，任务书，年度预算，报账）
     *
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "/doUpdateApprove", method = RequestMethod.POST)
    public BaseResult doUpdateApprove(PrjApproverecord approverecord) {
        List<PrjApproverecord> recordList = new ArrayList<>();

        PrjApproverecord record1 = new PrjApproverecord();
        record1.setId(approverecord.getId());
        record1.setSpcz(approverecord.getSpcz());
        record1.setShr(approverecord.getShr());
        record1.setShsj(approverecord.getShsj());

            if (approverecord.getSpcz().equals("返回修改")) {
            record1.setSffh(true);//是否返回
                if (approverecord.getYj2()!=null) {
                    record1.setYj(approverecord.getYj2());
                }else {
                    record1.setYj(approverecord.getYj());
                }
        } else {
            record1.setSffh(false);//是否返回
            if (!approverecord.getSpcz().equals("提交审批"))
                record1.setYj(approverecord.getYj());
            //是否需要上级审核
            if (approverecord.getZt().equals(PostInfoEnum.KYJHZZ.postName() + "审批")) {
                record1.setSfsjsh(false);
            } else {
                record1.setSfsjsh(true);
                record1.setSjshr(approverecord.getSjshr());
                record1.setSjshgw(approverecord.getSjshgw());
            }
        }
        record1.setYcshr(false);//隐藏审核人
        record1.setWc(true);//完成
        recordList.add(record1);

        if (approverecord.getZt().equals("未提交(返回)") || approverecord.getSpcz().equals("返回修改")) {
            PrjApproverecord record2 = new PrjApproverecord();
            record2.setXm(approverecord.getXm());
            record2.setXmid(approverecord.getXmid());
            record2.setTablename(approverecord.getTablename());
            record2.setTjr(approverecord.getTjr());
            record2.setTjsj(approverecord.getTjsj());
            if (approverecord.getSpcz().equals("返回修改")) {
                record2.setZt("未提交(返回)");
                record2.setShr(approverecord.getTjr());//审核人
            } else {
                record2.setZt(PostInfoEnum.KYJHZZ.postName() + "审批");
                record2.setShr(approverecord.getSjshr());//审核人
                record2.setShgw(approverecord.getSjshgw());//审核岗位
            }
            record2.setWc(false);
            recordList.add(record2);
        }
        int num = prjApproverecordService.insertApprove(recordList);
        if (num > 0) {
            return BaseResult.success("保存成功!");
        } else {
            return BaseResult.failure("保存失败!");
        }
    }

    /**
     * 编辑数据（提交审批：费用申请）
     *
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "/doUpdateApproveFysq", method = RequestMethod.POST)
    @Transactional
    public BaseResult doUpdateApproveFysq(PrjApproverecord approverecord) {


        LocalDateTime currentTime = LocalDateTime.now();
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");//提交时间

        List<PrjApproverecord> recordList = new ArrayList<>();

        PrjApproverecord record1 = new PrjApproverecord();
        record1.setId(approverecord.getId());
        record1.setSpcz(approverecord.getSpcz());
        record1.setShr(approverecord.getShr());
        record1.setShsj(currentTime.format(formatter));
        double dmoney = approverecord.getSqje();

        if (approverecord.getSpcz().equals("返回修改")) {
            record1.setSffh(true);//是否返回
            record1.setYj(approverecord.getYj());
        } else {
            record1.setSffh(false);//是否返回
            if (!approverecord.getSpcz().equals("提交审批")) {
                record1.setYj(approverecord.getYj());
            }
            //是否需要上级审核
            if (approverecord.getZt().equals(PostInfoEnum.YZ.postName() + "审批") || approverecord.getZt().equals(PostInfoEnum.ZGYLD.postName() + "审批") && dmoney < 1000000) {
                record1.setSfsjsh(false);
            } else {
                record1.setSfsjsh(true);
                record1.setSjshr(approverecord.getSjshr());
                record1.setSjshgw(approverecord.getSjshgw());
            }
        }
        record1.setYcshr(false);//隐藏审核人
        record1.setWc(true);//完成
        recordList.add(record1);

        if (!(approverecord.getZt().equals(PostInfoEnum.YZ.postName() + "审批") || approverecord.getZt().equals(PostInfoEnum.ZGYLD.postName() + "审批") && dmoney < 1000000)
                || approverecord.getSpcz().equals("返回修改")) {
            PrjApproverecord record2 = new PrjApproverecord();
            record2.setXm(approverecord.getXm());
            record2.setXmid(approverecord.getXmid());
            record2.setTablename(approverecord.getTablename());
            record2.setTjr(approverecord.getTjr());
            record2.setTjsj(approverecord.getTjsj());
            if (approverecord.getSpcz().equals("返回修改")) {
                record2.setZt("未提交(返回)");
                record2.setShr(approverecord.getTjr());//审核人
            } else {
                if (approverecord.getZt().equals(PostInfoEnum.BMZR.postName() + "审批"))
                    record2.setZt(PostInfoEnum.KJXMGLZZ.postName() + "审批");
                else if (approverecord.getZt().equals(PostInfoEnum.KJXMGLZZ.postName() + "审批"))
                    record2.setZt(PostInfoEnum.KJBBMZR.postName() + "审批");
                else if (approverecord.getZt().equals(PostInfoEnum.KJBBMZR.postName() + "审批"))
                    record2.setZt(PostInfoEnum.ZGYLD.postName() + "审批");
                else if (approverecord.getZt().equals(PostInfoEnum.ZGYLD.postName() + "审批"))
                    record2.setZt(PostInfoEnum.YZ.postName() + "审批");
                else
                    record2.setZt(PostInfoEnum.BMZR.postName() + "审批");

                record2.setShr(approverecord.getSjshr());//审核人
                record2.setShgw(approverecord.getSjshgw());//审核岗位
            }
            record2.setWc(false);
            recordList.add(record2);
        }

        int num = prjApproverecordService.insertApprove(recordList);
        if (num > 0) {
            return BaseResult.success("保存成功!");
        } else {
            return BaseResult.failure("保存失败!");
        }
    }

    /**
     * 编辑数据（提交审批：付款申请）
     *
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "/doUpdateApproveFksq", method = RequestMethod.POST)
    @Transactional
    public BaseResult doUpdateApproveFksq(PrjApproverecord approverecord) {
        LocalDateTime currentTime = LocalDateTime.now();
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");//提交时间
        List<PrjApproverecord> recordList = new ArrayList<>();

        PrjApproverecord record1 = new PrjApproverecord();
        record1.setId(approverecord.getId());
        record1.setSpcz(approverecord.getSpcz());
        record1.setShr(approverecord.getShr());
        record1.setShsj(currentTime.format(formatter));

        if (approverecord.getSpcz().equals("返回修改")) {
            record1.setSffh(true);//是否返回
            record1.setYj(approverecord.getYj());
        } else {
            record1.setSffh(false);//是否返回
            if (!approverecord.getSpcz().equals("提交审批"))
                if (approverecord.getYj()==null){
                    record1.setYj("同意。");
                }else {
                    record1.setYj(approverecord.getYj());
                }
            //是否需要上级审核
            if (approverecord.getZt().equals(PostInfoEnum.KJBBMZR.postName() + "审批")) {
                record1.setSfsjsh(false);
            } else {
                record1.setSfsjsh(true);
                record1.setSjshr(approverecord.getSjshr());
                record1.setSjshgw(approverecord.getSjshgw());
            }
        }
        record1.setYcshr(false);//隐藏审核人
        record1.setWc(true);//完成
        recordList.add(record1);

        if (!(approverecord.getZt().equals(PostInfoEnum.KJBBMZR.postName() + "审批")) || approverecord.getSpcz().equals("返回修改")) {
            PrjApproverecord record2 = new PrjApproverecord();
            record2.setXm(approverecord.getXm());
            record2.setXmid(approverecord.getXmid());
            record2.setTablename(approverecord.getTablename());
            record2.setTjr(approverecord.getTjr());
            record2.setTjsj(approverecord.getTjsj());
            if (approverecord.getSpcz().equals("返回修改")) {
                record2.setZt("未提交(返回)");
                record2.setShr(approverecord.getTjr());//审核人
            } else {
                if (approverecord.getZt().equals(PostInfoEnum.KJXMGLZZ2.postName() + "审批")) {
                    record2.setZt(PostInfoEnum.KJBBMZR.postName() + "审批");
                } else {
                    record2.setZt(PostInfoEnum.KJXMGLZZ2.postName() + "审批");
                }

                record2.setShr(approverecord.getSjshr());//审核人
                record2.setShgw(approverecord.getSjshgw());//审核岗位
            }
            record2.setWc(false);
            recordList.add(record2);
        }

        int num = prjApproverecordService.insertApprove(recordList);
        if (num > 0) {
            return BaseResult.success("保存成功!");
        } else {
            return BaseResult.failure("保存失败!");
        }
    }

    /**
     * 编辑数据（年度预算修改申请）
     * @param approverecord
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "/doUpdateApproveRecord", method = RequestMethod.POST)
    @Transactional
    public BaseResult doUpdateApproveRecord(PrjApproverecord approverecord) {
        LocalDateTime currentTime = LocalDateTime.now();
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");//提交时间
        List<PrjApproverecord> recordList = new ArrayList<>();
        Map<String, String> paraMap = new HashMap<>();
        paraMap.put("postName", "科技项目管理专责");
        paraMap.put("postId","39");
        List<SysUserPost> userPostLists = sysUserPostService.getPostUserList(paraMap);
        Integer shr2 = userPostLists.get(0).getUserId();

        PrjApproverecord record1 = new PrjApproverecord();
        record1.setId(approverecord.getId());
        record1.setSpcz(approverecord.getSpcz());
        record1.setShr(approverecord.getShr());
        record1.setShsj(currentTime.format(formatter));

        if (approverecord.getSpcz().equals("返回修改")) {
            record1.setSffh(true);//是否返回
            record1.setYj(approverecord.getYj());
        } else {
            record1.setSffh(false);//是否返回
            if (!approverecord.getSpcz().equals("提交审批"))
                if (approverecord.getYj()==null){
                    record1.setYj("同意。");
                }else {
                    record1.setYj(approverecord.getYj());
                }
            //是否需要上级审核
            if (approverecord.getZt().equals(PostInfoEnum.KJXMGLZZ.postName() + "审批")) {
                record1.setSfsjsh(false);
            } else {
                record1.setSfsjsh(true);
                record1.setSjshr(approverecord.getSjshr());
                record1.setSjshgw(approverecord.getSjshgw());
            }
        }
        record1.setYcshr(false);//隐藏审核人
        record1.setWc(true);//完成
        recordList.add(record1);
        if (!(approverecord.getZt().equals(PostInfoEnum.KJXMGLZZ.postName() + "审批")) || approverecord.getSpcz().equals("返回修改")) {
            PrjApproverecord record2 = new PrjApproverecord();
            record2.setXm(approverecord.getXm());
            record2.setXmid(approverecord.getXmid());
            record2.setTablename(approverecord.getTablename());
            record2.setTjr(approverecord.getTjr());
            record2.setTjsj(approverecord.getTjsj());
            if (approverecord.getSpcz().equals("返回修改")) {
                record2.setZt("未提交(返回)");
                record2.setShr(approverecord.getTjr());
            } else {
                if (approverecord.getZt().equals(PostInfoEnum.BMZR.postName() + "审批")) {
                    record2.setZt(PostInfoEnum.KJXMGLZZ.postName() + "审批");
                } else {
                    record2.setZt(PostInfoEnum.BMZR.postName() + "审批");
                }

                record2.setShr(shr2);//审核人
                record2.setShgw(39);//审核岗位
            }
            record2.setWc(false);
            recordList.add(record2);
        }

        int num = prjApproverecordService.insertApprove(recordList);
        if (num > 0) {
            return BaseResult.success("保存成功!");
        } else {
            return BaseResult.failure("保存失败!");
        }
    }
    /**
         * 编辑数据（合同修改申请）
         * @param approverecord
         * @return
         */
        @ResponseBody
        @RequestMapping(value = "/doUpdateApprovePrjContract", method = RequestMethod.POST)
        @Transactional
        public BaseResult doUpdateApprovePrjContract(PrjApproverecord approverecord) {
            LocalDateTime currentTime = LocalDateTime.now();
            DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");//提交时间
            List<PrjApproverecord> recordList = new ArrayList<>();

            PrjApproverecord record1 = new PrjApproverecord();
            record1.setId(approverecord.getId());
            record1.setSpcz(approverecord.getSpcz());
            record1.setShr(approverecord.getShr());
            record1.setShsj(currentTime.format(formatter));

            if (approverecord.getSpcz().equals("返回修改")) {
                record1.setSffh(true);//是否返回
                record1.setYj(approverecord.getYj());
            } else {
                record1.setSffh(false);//是否返回
                if (!approverecord.getSpcz().equals("提交审批"))
                    if (approverecord.getYj()==null){
                        record1.setYj("同意。");
                    }else {
                        record1.setYj(approverecord.getYj());
                    }
                //是否需要上级审核
                if (approverecord.getZt().equals(PostInfoEnum.KJXMGLZZ2.postName() + "审批")) {
                    record1.setSfsjsh(false);
                } else {
                    record1.setSfsjsh(true);
                    record1.setSjshr(approverecord.getSjshr());
                    record1.setSjshgw(approverecord.getSjshgw());
                }
            }
            record1.setYcshr(false);//隐藏审核人
            record1.setWc(true);//完成
            recordList.add(record1);
            int num = prjApproverecordService.insertApprove(recordList);
            if (num > 0) {
                return BaseResult.success("保存成功!");
            } else {
                return BaseResult.failure("保存失败!");
            }
        }


    @ResponseBody
    @RequestMapping(value = "/spList/{xmid}/{tableName}", method = RequestMethod.POST)
    public BaseResult spList(@PathVariable("xmid") String xmid,
                             @PathVariable("tableName") String tableName,
                             @RequestParam("page") Integer pageNum,
                             @RequestParam("limit") Integer pageSize,
                             @RequestParam(required = false, defaultValue = "", value = "sortName") String sortName,
                             @RequestParam(required = false, defaultValue = "", value = "sortOrder") String sortOrder) {
        PageHelper.startPage(pageNum, pageSize);

        Map<String, String> paraMap = new HashMap<>();
        paraMap.put("sortName", sortName);
        paraMap.put("sortOrder", sortOrder);
        paraMap.put("xmid", xmid.toString());
        paraMap.put("tableName", tableName.toString());
        List<PrjApproverecord> list = prjApproverecordService.getApproveByXmId2(paraMap);
        if (list.isEmpty()){
            Map<String, Object> result = new HashMap<>();
            return BaseResult.success(result);
        }else {
            //判断备用金是否关联项目
            if (list.get(0).getTablename().equals("sta_BudgetApproval")) {
                PrjApproverecord prjApproverecord = new PrjApproverecord();
                StaBudgetapproval staBudgetapproval = staBudgetapprovalService.queryById(list.get(0).getXmid());
                System.out.println(staBudgetapproval.toString());
                if (staBudgetapproval.getSfbyj() == true && staBudgetapproval.getXmmc() != null) {
                    prjApproverecord.setWc(true);
                    prjApproverecord.setZt("该备用金已关联项目");
                    list.add(prjApproverecord);
                } else if (staBudgetapproval.getSfbyj() == true && staBudgetapproval.getXmmc() == null && "审批结束".equals(staBudgetapproval.getSpzt()) || "".equals(staBudgetapproval.getXmmc())) {
                    prjApproverecord.setWc(false);
                    prjApproverecord.setZt("该备用金暂未关联项目");
                    prjApproverecord.setShrxm(PostInfoEnum.KJXMGLZZ.postName());
                    list.add(prjApproverecord);
                }
            }
            PageInfo<PrjApproverecord> pageinfo = new PageInfo<>(list);
            //取出查询结果
            List<PrjApproverecord> rows = pageinfo.getList();
            int total = (int) pageinfo.getTotal();
            Map<String, Object> result = new HashMap<>();
            result.put(RESULT_ROWS, rows);
            result.put(RESULT_TOTAL, total);

            return BaseResult.success(result);
        }
    }
    @ResponseBody
    @RequestMapping(value = "/spLists/{xmid}/{tableName}", method = RequestMethod.GET)
    public List spList(@PathVariable("xmid") String xmid,
                             @PathVariable("tableName") String tableName) {

        Map<String, String> paraMap = new HashMap<>();
        paraMap.put("xmid", xmid.toString());
        paraMap.put("tableName", tableName.toString());
        List<PrjApproverecord> list = prjApproverecordService.getApproveByXmId2(paraMap);
        if (list.isEmpty()){
            return new ArrayList<>();
        }else {
            //判断备用金是否关联项目
            if (list.get(0).getTablename().equals("sta_BudgetApproval")) {
                PrjApproverecord prjApproverecord = new PrjApproverecord();
                StaBudgetapproval staBudgetapproval = staBudgetapprovalService.queryById(list.get(0).getXmid());
                System.out.println(staBudgetapproval.toString());
                if (staBudgetapproval.getSfbyj() == true && staBudgetapproval.getXmmc() != null) {
                    prjApproverecord.setWc(true);
                    prjApproverecord.setZt("该备用金已关联项目");
                    list.add(prjApproverecord);
                } else if (staBudgetapproval.getSfbyj() == true && staBudgetapproval.getXmmc() == null && "审批结束".equals(staBudgetapproval.getSpzt()) || "".equals(staBudgetapproval.getXmmc())) {
                    prjApproverecord.setWc(false);
                    prjApproverecord.setZt("该备用金暂未关联项目");
                    prjApproverecord.setShrxm(PostInfoEnum.KJXMGLZZ.postName());
                    list.add(prjApproverecord);
                }
            }

            return list;
        }
    }
    //修改审批列表wc状态
    @ResponseBody
    @RequestMapping(value = "/updatSpList/{id}", method = RequestMethod.GET)
    public BaseResult updatSpList(@PathVariable("id") String id){
        Integer userId = getSysUserInfo().getUserId();
        prjApproverecordService.updatSpList(id,userId);
        return BaseResult.success("修改成功！");
    }
}

