package com.jeeplus.test.cw.projectRecords.service;

import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.google.common.collect.Lists;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.jeeplus.core.query.QueryWrapperGenerator;
import com.jeeplus.sys.domain.User;
import com.jeeplus.sys.mapper.UserMapper;
import com.jeeplus.sys.service.dto.UserDTO;
import com.jeeplus.sys.utils.Global;
import com.jeeplus.sys.utils.StringUtils;
import com.jeeplus.sys.utils.UserUtils;
import com.jeeplus.test.cw.projectRecords.domain.CwProjectRecords;
import com.jeeplus.test.cw.projectRecords.mapper.CwProjectRecordsMapper;
import com.jeeplus.test.cw.projectRecords.service.dto.CwProjectClientInfoDTO;
import com.jeeplus.test.cw.projectRecords.service.dto.CwProjectRecordsDTO;
import com.jeeplus.test.cw.projectRecords.service.mapstruct.CwProjectRecordsWrapper;
import com.jeeplus.test.cw.workClientInfo.service.dto.CwWorkClientBaseDTO;
import com.jeeplus.test.mould.service.SerialnumTplService;
import com.jeeplus.test.oss.domain.WorkAttachment;
import com.jeeplus.test.oss.service.OSSClientService;
import com.jeeplus.test.oss.service.OssService;
import com.jeeplus.test.signature.domain.*;
import com.jeeplus.test.signature.utils.SignaturePostUtil;
import org.springframework.data.redis.connection.jedis.JedisUtils;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import javax.annotation.Resource;
import java.io.File;
import java.lang.reflect.Type;
import java.util.*;
import java.util.stream.Collectors;

/**
 * 财务项目登记service
 * @author: 徐滕
 * @version: 2022-11-10 14:56
 */
@Service
@Transactional
public class CwProjectRecordsService extends ServiceImpl<CwProjectRecordsMapper, CwProjectRecords> {

    @Resource
    private CwProjectRecordsMapper cwProjectRecordsMapper;
    @Resource
    private OssService ossService;

    @Resource
    private SerialnumTplService serialnumTplService;
    @Resource
    private UserMapper userMapper;

    /**
     * 差选项目列表信息
     * @param page
     * @param cwProjectRecordsDTO
     * @return
     * @throws Exception
     */
    public IPage<CwProjectRecordsDTO> findList(Page<CwProjectRecordsDTO> page, CwProjectRecordsDTO cwProjectRecordsDTO) throws Exception{
        QueryWrapper<CwProjectRecords> queryWrapper = QueryWrapperGenerator.buildQueryCondition ( CwProjectRecordsWrapper.INSTANCE.toEntity(cwProjectRecordsDTO), CwProjectRecords.class );
        queryWrapper.eq("a.del_flag","0");
        queryWrapper.orderByDesc("a.create_date");
        if (ObjectUtil.isNotEmpty(cwProjectRecordsDTO)) {
            if (ArrayUtil.isNotEmpty(cwProjectRecordsDTO.getCreateDates())) {
                queryWrapper.between("a.create_date", cwProjectRecordsDTO.getCreateDates()[0], cwProjectRecordsDTO.getCreateDates()[1]);
            }
            if (StringUtils.isNotBlank(cwProjectRecordsDTO.getProjectMasterName())) {
                List<User> userList = userMapper.selectList(new QueryWrapper<User>().lambda().like(User::getName, cwProjectRecordsDTO.getProjectMasterName()));
                List<String> ids = userList.stream().distinct().map(User::getId).collect(Collectors.toList());
                if (CollectionUtil.isNotEmpty(ids)) {
                    queryWrapper.in("a.project_master_id", ids);
                } else {
                    return new Page<>();
                }
            }
            if (StringUtils.isNotBlank(cwProjectRecordsDTO.getCreateId())){
                queryWrapper.eq("a.create_by", cwProjectRecordsDTO.getCreateId());
            }
        }
        IPage<CwProjectRecordsDTO> list = cwProjectRecordsMapper.findList(page, queryWrapper);
        return list;
    }

    /**
     * 根据id查询项目详情
     * @param id
     * @return
     */
    public CwProjectRecordsDTO queryById(String id) {
        CwProjectRecordsDTO cwProjectRecordsDTO = cwProjectRecordsMapper.queryById(id);
        if (ObjectUtil.isNotEmpty(cwProjectRecordsDTO)) {
            if (ObjectUtil.isNotEmpty(cwProjectRecordsDTO.getPlanStartDate()) && ObjectUtil.isNotEmpty(cwProjectRecordsDTO.getPlanEndDate())) {
                Date[] planDate = new Date[2];
                planDate[0] = cwProjectRecordsDTO.getPlanStartDate();
                planDate[1] = cwProjectRecordsDTO.getPlanEndDate();
                cwProjectRecordsDTO.setPlanDate(planDate);
            }
        }
        return cwProjectRecordsDTO;
    }

    /**
     * 保存项目以及其他相关信息
     * @param cwProjectRecordsDTO
     * @return
     * @throws Exception
     */
    public String saveForm(CwProjectRecordsDTO cwProjectRecordsDTO) throws Exception{
        if(StringUtils.isBlank(cwProjectRecordsDTO.getId())){
            //获取当前登录人信息
            UserDTO userDTO = UserUtils.getCurrentUserDTO();
            //项目编号生成
            String serialNum = serialnumTplService.genSerialNum(userDTO.getCompanyDTO().getId(), CwProjectRecordsDTO.BIZ_CODE);
            cwProjectRecordsDTO.setProjectNumber(serialNum);
        }
        CwProjectRecords cwProjectRecords = CwProjectRecordsWrapper.INSTANCE.toEntity(cwProjectRecordsDTO);
        if (ObjectUtil.isNotEmpty(cwProjectRecords)) {
            if (StringUtils.isBlank(cwProjectRecords.getCreateBy())) {
                cwProjectRecords.setCreateBy(UserUtils.getCurrentUserDTO().getId());
            }
        }
        this.saveOrUpdate(cwProjectRecords);
        if (ObjectUtil.isNotEmpty(cwProjectRecordsDTO)) {
            // 附件
            ossService.saveOrUpdateFileList(cwProjectRecordsDTO.getWorkAttachmentDtoList(),cwProjectRecords.getId(),"cw_project_records");
            // 被服务单位
            //根据项目id删除原有的被服务单位数据信息
            cwProjectRecordsMapper.deleteProjectClientInfoByProjectId(cwProjectRecords.getId());

            if(null != cwProjectRecordsDTO.getCwProjectClientInfoDTOList() && cwProjectRecordsDTO.getCwProjectClientInfoDTOList().size()>0){
                //根据项目id添加新的被服务单位信息
                List<CwWorkClientBaseDTO> cwWorkClientBaseDTOList = cwProjectRecordsDTO.getCwProjectClientInfoDTOList();
                List<CwProjectClientInfoDTO> cwProjectClientInfoDTOList = new ArrayList<>();
                for (CwWorkClientBaseDTO c : cwWorkClientBaseDTOList) {
                    CwProjectClientInfoDTO cwProjectClientInfoDTO = new CwProjectClientInfoDTO();
                    cwProjectClientInfoDTO.setProjectId(cwProjectRecords.getId());
                    cwProjectClientInfoDTO.setClientId(c.getId());
                    cwProjectClientInfoDTOList.add(cwProjectClientInfoDTO);
                }
                //对数据进行批量插入
                cwProjectRecordsMapper.insertProjectClientInfoList(cwProjectClientInfoDTOList);
            }
        }
        return cwProjectRecords.getId();
    }

    /**
     * 保存项目信息
     * @param cwProjectRecordsDTO
     * @return
     * @throws Exception
     */
    public ResponseEntity save(CwProjectRecordsDTO cwProjectRecordsDTO) throws Exception{
        this.saveForm(cwProjectRecordsDTO);
        return ResponseEntity.ok("保存成功");
    }

    /**
     * 根据id删除项目信息
     * @param ids
     * @return
     */
    public ResponseEntity deleteByIds(String ids) {
        String idArray[] =ids.split(",");
        this.removeByIds (Lists.newArrayList (idArray));
        return ResponseEntity.ok ("删除成功");
    }

    /**
     * 修改状态
     * @param cwProjectRecordsDTO
     * @return
     */
    public String updateStatusById(CwProjectRecordsDTO cwProjectRecordsDTO) {
        CwProjectRecords cwProjectRecords = CwProjectRecordsWrapper.INSTANCE.toEntity(cwProjectRecordsDTO);
        cwProjectRecordsMapper.update(cwProjectRecords, new QueryWrapper<CwProjectRecords>().lambda().eq(CwProjectRecords::getId, cwProjectRecords.getId()));
        return "操作成功";
    }

    /**
     * 根据客户id获取关联的项目信息
     * @param clientId
     * @return
     */
    public List<CwProjectRecordsDTO> getByClientId(String clientId,CwProjectRecordsDTO cwProjectRecordsDTO) throws Exception {
        if(StringUtils.isNotBlank(clientId)){
            List<String> projectIdByClientId = cwProjectRecordsMapper.getProjectIdByClientId(clientId);
            List<String> projectList = projectIdByClientId.stream().distinct().collect(Collectors.toList());
            if (CollectionUtil.isNotEmpty(projectList)) {
                QueryWrapper<CwProjectRecords> queryWrapper = QueryWrapperGenerator.buildQueryCondition ( CwProjectRecordsWrapper.INSTANCE.toEntity(cwProjectRecordsDTO), CwProjectRecords.class );
                queryWrapper.in("a.id", projectList);
                queryWrapper.eq("a.del_flag","0");
                queryWrapper.eq("a.status","5");
                queryWrapper.orderByDesc("a.create_date");
                return cwProjectRecordsMapper.getProjectByIdList(queryWrapper);
            } else {
                return new ArrayList<>();
            }
        } else {
            return new ArrayList<>();
        }
    }

    /**
     * 根据合同id获取关联的项目信息
     * @param contractId
     * @return
     */
    public List<CwProjectRecordsDTO> getByContractId(String contractId,CwProjectRecordsDTO cwProjectRecordsDTO) throws Exception{
        if (StringUtils.isNotBlank(contractId)) {
            QueryWrapper<CwProjectRecords> queryWrapper = QueryWrapperGenerator.buildQueryCondition ( CwProjectRecordsWrapper.INSTANCE.toEntity(cwProjectRecordsDTO), CwProjectRecords.class );
            queryWrapper.eq("a.contract_id", contractId);
            queryWrapper.eq("a.del_flag","0");
            queryWrapper.eq("a.status","5");
            queryWrapper.orderByDesc("a.create_date");
            return cwProjectRecordsMapper.getByContractId(queryWrapper);
        }
        return new ArrayList<>();
    }










    /*public String createSignatureContractId(){
    //public Map<String,Object> createSignatureContractId(){
        List<WorkAttachment> fileList = Lists.newArrayList();
        if(fileList.size()>0){

            //下载审定单文件
            String path = null;
            if(System.getProperty("os.name").toLowerCase().contains("win")){
                path = "D:/attachment-file/";
            }else{
                path = "/attachment-file/";
            }
            String aliyunUrl = Global.getAliyunUrl();
            String aliDownloadUrl = Global.getAliDownloadUrl();

            //获取文件生成的documentId
            List<String> documentList = Lists.newArrayList();

            for (WorkAttachment workattachment : fileList) {
                String deleteFile = null;
                try{
                if(StringUtils.isBlank(workattachment.getUrl())){
                    return "审定单文件存储路径为空，无法进行签章操作，请驳回后重新上传审定单";
                }

                String file = workattachment.getUrl();
                file = file.replace("amp;","");
                String fileName = file.substring(file.lastIndexOf("/") + 1, file.length());
                String cons = "";
                if (file.contains(aliyunUrl)){
                    cons = aliyunUrl;
                }else if (file.contains("http://gangwan-app.oss-cn-hangzhou.aliyuncs.com")){
                    cons = "http://gangwan-app.oss-cn-hangzhou.aliyuncs.com";
                }else {
                    cons = aliDownloadUrl;
                }
                String ossKey = file.split(cons+"/")[1];
                new OSSClientService().downByStreamSaveLocal(ossKey,fileName,path+fileName);
                //将下载下来的文件转换为file文件
                File srcFile = new File(path+fileName);
                deleteFile = path+fileName;

                //截取文件名称
                String srcFileName = srcFile.getName().substring(0,srcFile.getName().lastIndexOf("."));
                //截取文件后缀名
                String substring = srcFile.getName().substring(srcFile.getName().lastIndexOf(".")+1, srcFile.getName().length());
                if(!"doc".equals(substring.toLowerCase()) && !"docx".equals(substring.toLowerCase()) && !"pdf".equals(substring.toLowerCase())){
                    return "请上传doc、docx或者pdf的文件进行签章操作";
                }
                //获取真签单的documentId
                HashMap hashMap = SignaturePostUtil.getDocument(srcFile);
                String code = hashMap.get("code").toString();
                String documentId = "";
                if("0".equals(code)){
                    String result = hashMap.get("result").toString();
                    HashMap documentIdMap = JSON.parseObject(result, HashMap.class);
                    documentId =  documentIdMap.get("documentId").toString();
                    if("".equals(documentId)){
                        return "签章文件创建失败";
                    }
                }else{
                    String message = hashMap.get("message").toString();
                    return message;
                }

                documentList.add(documentId);

                }catch (Exception e){

                }finally {
                    if(StringUtils.isNotBlank(deleteFile)){
                        //根据路径创建文件对象
                        File file = new File(deleteFile);
                        //路径是个文件且不为空时删除文件
                        if(file.isFile()&&file.exists()){
                            file.delete();
                        }
                    }
                }

            }


            //将documentId存入数据库中
            projectReportData.setSignatureInvalidDocumentId(String.join(",", documentList));
            //根据项目id 和 documentId生成合同id
            HashMap contractIdHashMap = ruralProjectMessageService.getSignatureContractIdByPageSign(ruralProjectRecords.getId(), documentList);
            String contractIdCode = contractIdHashMap.get("code").toString();
            String contractId = "";
            if("0".equals(contractIdCode)){
                contractId = contractIdHashMap.get("contractId").toString();
                if("".equals(contractId)){
                    return "签章文件创建失败";
                }
                contractUrl = ruralProjectMessageService.getSignatureContractUrl(contractId);
                System.out.println(contractUrl);
            }else{
                return contractIdHashMap.get("message").toString();
            }
            //将documentId 和contractId存储到质量复核对应的数据种
            //签章完成则进行数据的保存
            projectReportData.setSignatureFlag(1);
            projectReportData.setSignatureDocumentId(documentId);
            projectReportData.setSignatureContractId(contractId);
            projectReportData.setSignatureFileName(srcFileName);
            projectReportData.setSignatureUploadFileUser(UserUtils.getUser());
            projectReportData.setSignatureUploadDate(new Date());
            //修改签章对应信息文件
            projectReportDataService.updateSignatureInfo(projectReportData);

            //将数据信息以contractId作为key 并且有效期为1天 存储在redis中
            Gson gson = new Gson();
            String toJson = gson.toJson(projectApprovalSignature);

            if(StringUtils.isNotBlank(toJson)){
                Jedis jedis = JedisUtils.getResource();
                String contractIdRedis = jedis.get("qiyuesuo" + contractId);
                if (StringUtils.isBlank(contractIdRedis)) {
                    //将该盖章url存放到redis 并设置1天的过期时间
                    jedis.set("qiyuesuo" + contractId, toJson);
                    jedis.expire("qiyuesuo" + contractId,86400);
                }
            }

            String auditUserListJson = gson.toJson(auditUsers);

            if(StringUtils.isNotBlank(auditUserListJson)){
                Jedis jedis = JedisUtils.getResource();
                String contractIdRedis = jedis.get("qiyuesuoAuditUserList" + contractId);
                if (StringUtils.isBlank(contractIdRedis)) {
                    //将该盖章url存放到redis 并设置1天的过期时间
                    jedis.set("qiyuesuoAuditUserList" + contractId, auditUserListJson);
                    jedis.expire("qiyuesuoAuditUserList" + contractId,86400);
                }
            }

        }else{
            return "审定单文件未找到，无法进行签章操作";
        }
        return null;
    }





    private static final String HTTPTOP = Global.getConfig("signature_http_top");
    private static final String COMPANYROUNDSEALID = Global.getConfig("company_round_seal_id");
    private static final String COMPANYROUNDSEALIDVERTICAL = Global.getConfig("company_round_seal_id_vertical");
    private static final String COMPANYPARTIESSEALID = Global.getConfig("company_parties_seal_id");
    private static final String APPROVALCATEGORYID = Global.getConfig("approval_category_id");
    private static final String APPROVALYCCATEGORYID = Global.getConfig("approval_YC_category_id");
    private static final String REPORTCATEGORYID = Global.getConfig("report_category_id");
    private static final String REPORTYCCATEGORYID = Global.getConfig("report_YC_category_id");
    private static final String JUDGEMENTCATEGORYID = Global.getConfig("judgement_category_id");


    *//**
     * 根据项目id 和 documentId生成合同id(页面签署生成)
     * 个人签字章功能
     * @param projectId
     * @param documentList
     * @return
     *//*
    public HashMap getSignatureContractIdByPageSign(String projectId, List<String> documentList){
        HashMap hashMap = new HashMap();
        Set<String> serialIdSet = new HashSet<>();
        //根据项目id查询项目信息
        RuralProjectRecords ruralProjectRecords = ruralProjectRecordsService.get(projectId);
        //创建签署方信息
        List<Action> actions = Lists.newArrayList();
        Action companyAction = new Action();
        companyAction.setType("CORPORATE");
        companyAction.setName("公司印章");
        companyAction.setSerialNo("3");
        //公司圆章-竖
        //serialIdSet.add(COMPANYROUNDSEALIDVERTICAL);
        //添加盖章位置
        List<Location> locations = Lists.newArrayList();
        *//*for (String documentId: documentList) {
            Location location = new Location();
            location.setSealId(COMPANYROUNDSEALIDVERTICAL);
            location.setDocumentId(documentId);
            location.setPage("0");
            location.setRectType("SEAL_CORPORATE");
            location.setKeywordIndex(-1);
            location.setOffsetX("0.5264");
            location.setOffsetY("0.6787");
            locations.add(location);
        }*//*

        //根据角色信息录入签署方信息
        //负责人
        if(StringUtils.isNotBlank(principalUserId)){
            User user = UserUtils.get(principalUserId);
            if(null != user){
                //获取成员印章id信息
                String userSealId = SignaturePostUtil.getUserSealByMobile(user.getMobile(),"","江苏兴光项目管理有限公司公章");



                if(StringUtils.isNotBlank(userSealId)){
                    for (String documentId: documentList) {
                        //添加盖章位置
                        Location principalLocation = new Location();
                        serialIdSet.add(userSealId);
                        principalLocation.setSealId(userSealId);
                        principalLocation.setDocumentId(documentId);
                        principalLocation.setPage("0");
                        principalLocation.setRectType("SEAL_CORPORATE");
                        principalLocation.setKeywordIndex(-1);
                        principalLocation.setOffsetX("0.5971");
                        principalLocation.setOffsetY("0.8176");
                        locations.add(principalLocation);
                    }
                }else{
                    hashMap.put("code","2");
                    hashMap.put("message","查询不到江苏兴光项目管理有限公司公章信息！请联系管理员");
                    return hashMap;
                }
            }
        }else{
            hashMap.put("code","2");
            hashMap.put("message","查询不到江苏兴光项目管理有限公司公章信息！请联系管理员");
            return hashMap;
        }

        List<String> serialIdList = new ArrayList<String>(serialIdSet);
        companyAction.setSealIds("[" + String.join(",", serialIdList) + "]");
        //判定该action是否采用自动签署
        companyAction.setAutoSign("false");
        companyAction.setLocations(locations);
        actions.add(companyAction);

        //创建个人职业章参数
        Action professionalChapterAction = new Action();
        professionalChapterAction.setType("PRACTICE");
        professionalChapterAction.setName("杨荣华个人职业章");
        professionalChapterAction.setSerialNo("1");

        //添加盖章位置
        List<Location> professionalChapterLocations = Lists.newArrayList();

        Set<String> professionalChapterSerialIdSet = new HashSet<>();

        //添加个人职业章人员信息
        ActionOperatorInfo actionOperatorInfo = new ActionOperatorInfo();
        actionOperatorInfo.setOperatorContact("15240492484");//个人职业章盖章人的手机号
        List<ActionOperatorInfo> actionOperators = Lists.newArrayList();
        actionOperators.add(actionOperatorInfo);
        professionalChapterAction.setActionOperators(actionOperators);

        //获取成员印章id信息
        long s1=System.currentTimeMillis();
        String userSealId = SignaturePostUtil.getUserSealByMobile("15240492484","","杨荣华个人签名");
        long s2=System.currentTimeMillis();
        System.out.println("第三个人员印章获取时间：" + (s2 - s1));
        if(StringUtils.isNotBlank(userSealId)){
        }else{
            hashMap.put("code","2");
            hashMap.put("message","查询不到项目负责人 的印章信息！请联系管理员");
            return hashMap;
        }

        List<String> serialIdsList = new ArrayList<String>(professionalChapterSerialIdSet);
        professionalChapterAction.setSealIds("[" + String.join(",", serialIdsList) + "]");
        professionalChapterAction.setLocations(professionalChapterLocations);
        net.sf.json.JSONObject professionalChapterJson = net.sf.json.JSONObject.fromObject(professionalChapterAction);
        System.out.println(professionalChapterJson.toString());
        actions.add(professionalChapterAction);




        //创建个人职业章参数
        Action professionalChapterTwoAction = new Action();
        professionalChapterTwoAction.setType("PRACTICE");
        professionalChapterTwoAction.setName("刘建春个人职业章");
        professionalChapterTwoAction.setSerialNo("2");

        //添加盖章位置
        List<Location> professionalChapterTwoLocations = Lists.newArrayList();

        Set<String> professionalChapterTwoSerialIdSet = new HashSet<>();

        //添加个人职业章人员信息
        ActionOperatorInfo actionTwoOperatorInfo = new ActionOperatorInfo();
        actionTwoOperatorInfo.setOperatorContact("13398782899");
        List<ActionOperatorInfo> actionTwoOperators = Lists.newArrayList();
        actionTwoOperators.add(actionTwoOperatorInfo);
        professionalChapterTwoAction.setActionOperators(actionTwoOperators);

        //获取成员印章id信息
        long s3=System.currentTimeMillis();
        String userSealId2 = SignaturePostUtil.getUserSealByMobile("13398782899","","杨荣华个人签名章");
        long s4=System.currentTimeMillis();
        System.out.println("第四个人员印章获取时间：" + (s4 - s3));

        serialIdsList = new ArrayList<String>(professionalChapterTwoSerialIdSet);
        professionalChapterTwoAction.setSealIds("[" + String.join(",", serialIdsList) + "]");
        professionalChapterTwoAction.setLocations(professionalChapterTwoLocations);
        professionalChapterJson = net.sf.json.JSONObject.fromObject(professionalChapterTwoAction);
        System.out.println(professionalChapterJson.toString());
        actions.add(professionalChapterTwoAction);



        //创建签署方信息表
        List<SignatorieInfo> signatories = Lists.newArrayList();
        SignatorieInfo signatorieInfo1 = new SignatorieInfo();
        signatorieInfo1.setSerialNo("1");
        signatorieInfo1.setTenantName("江苏兴光项目管理有限公司");
        signatorieInfo1.setTenantType("COMPANY");
        signatorieInfo1.setActions(actions);
        signatories.add(signatorieInfo1);
        SignatureContract signatureContract = new SignatureContract();
        signatureContract.setDocuments(documentList);
        //审定单用印流程id
        signatureContract.setCategoryId(APPROVALCATEGORYID);
        signatureContract.setSend(true);
        signatureContract.setSignatories(signatories);
        signatureContract.setSn("");
        signatureContract.setSubject(ruralProjectRecords.getProjectName());//添加项目名称
        net.sf.json.JSONObject json = net.sf.json.JSONObject.fromObject(signatureContract);
        System.out.println(json.toString());
        long s5=System.currentTimeMillis();
        System.out.println(json.toString());
        String contractIdMapStr = SignaturePostUtil.sendPostApplicationJson(HTTPTOP + "/contract/createbycategory", json.toString());
        long s6=System.currentTimeMillis();
        System.out.println("获取合同id获取时间：" + (s6 - s5));
        hashMap = JSON.parseObject(contractIdMapStr, HashMap.class);


        return hashMap;
    }*/


    /**
     * 审定单签章回调操作(个人职业章盖章)
     * @param presignCallBack  回调参数
     * @return
     */
    /*@RequestMapping(value = "/getApprovalCallBackCoordinates", method= RequestMethod.POST)
    public String getApprovalCallBackCoordinates(PresignCallBack presignCallBack) throws Exception {

        Jedis jedis = JedisUtils.getResource();
        String contractIdRedis = jedis.get("qiyuesuo" + presignCallBack.getContractId());
        String auditUsersStr = jedis.get("qiyuesuoAuditUserList" + presignCallBack.getContractId());
        Gson gson = new Gson();
        ProjectApprovalSignature projectApprovalSignature1 = gson.fromJson(contractIdRedis, ProjectApprovalSignature.class);

        Type listType = new TypeToken<ArrayList<User>>(){}.getType();
        List<User> auditUserList = new Gson().fromJson(auditUsersStr, listType);

        //根据contractId查询对应的报告信息
        ProjectReportData projectReportData = projectReportDataService.getReportDataByProjectId(projectApprovalSignature1.getProjectId());

        if(null == projectReportData){
            return null;
        }
        //根据项目id查询对应的审定单数据状态是否是已经被送审或者 是否存在值
        ProjectApprovalSignature projectApprovalSignature = ruralProjectMessageElectronicSealService.getProjectApprovalSignature(projectReportData.getProject().getId());
        projectApprovalSignature1.setCreateBy(projectApprovalSignature.getCreateBy());

        //对流程数据进行处理
        approvalSaveAudit(projectApprovalSignature1,auditUserList);

        return null;
    }*/

}
