package com.bcxin.ins.coninsweb.user.web;

import com.alibaba.fastjson.JSON;
import com.bcxin.ins.entity.policy_core.InsPreservationRecord;
import com.bcxin.ins.enums.TransTypeEnum;
import com.bcxin.ins.third.gyx.taibao.GYX_TBRequestService;
import com.bcxin.ins.third.gzzrx.changan.GZZRX_CARequestService;
import com.bcxin.ins.third.gzzrx.pingancai.GZZRX_PACRequestService;
import com.bcxin.ins.third.gzzrx.renbao.GZZRX_RBRequestService;
import com.bcxin.ins.third.gzzrx.zhonghua.GZZRX_ZHRequestService;
import com.bcxin.ins.third.tyx.pingan.util.FileDownload;
import com.bcxin.ins.third.build.dubang.Build_DBRequestService;
import com.bcxin.ins.third.build.yangguang.YGGCService;
import com.bcxin.ins.third.build.yangguang.yggc.YGGC;
import com.bcxin.ins.third.gzx.pingancai.GZX_PACRequestService;
import com.bcxin.ins.third.tyx.pingancai.PACRequestService;
import com.bcxin.ins.third.zzx.yongan.ZZX_PackageMessageYongAn;
import com.bcxin.ins.third.zzx.yongan.ZZX_YARequestService;
import com.bcxin.ins.third.xyx.taibao.XYX_TBRequestService;
import com.bcxin.ins.service.preservation.InsPreservationPayAPIService;
import com.bcxin.ins.service.preservation.InsPreservationRecordAPIService;
import com.bcxin.ins.service.product.ProductService;
import com.bcxin.ins.rest.UserSupportUtil;
import com.bcxin.ins.core.base.web.BaseController;
import com.bcxin.ins.core.service.ComDeployConfigService;
import com.bcxin.ins.entity.common.ComTaskResidual;
import com.bcxin.ins.service.order.*;
import com.bcxin.ins.spring.util.SpringContextHolder;
import com.bcxin.ins.util.DateUtil;
import com.bcxin.ins.util.FileBatchUtil;
import com.bcxin.ins.util.GlobalResources;
import com.bcxin.ins.vo.*;
import com.google.common.collect.Maps;
import org.apache.commons.lang.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletResponse;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Type;
import java.math.BigDecimal;
import java.util.*;

/**
 * 用户信息
 */
@Controller
@RequestMapping(value = "test")
public class TestController extends BaseController {

    private static org.apache.logging.log4j.Logger log = LogManager.getLogger(TestController.class);

    @Autowired
    private PolicyService policyService;
    @Autowired
    private ProductService productService;

    @Autowired
    private YGGCService yGGCService;

    @Autowired
    private GZX_PACRequestService gZX_PACRequestService;
    @Autowired
    private Build_DBRequestService build_DBRequestService;

    @Autowired
    private ComDeployConfigService comDeployConfigService;

    @Autowired
    private InsTransactionAPIService insTransactionService;

    @Autowired
    private InsPreservationPayAPIService insPreservationPayAPIService;
    @Autowired
    private InsPreservationRecordAPIService insPreservationRecordAPIService;
    @Autowired
    private SpecialPublicDutyAPIService specialPublicDutyAPIService;
    @Autowired
    private GYX_TBRequestService gYX_TBRequestService;
    @Autowired
    private ComTaskResidualAPIService comTaskResidualAPIService;
    @Autowired
    private InsuranceOperationAPIService insuranceOperationAPIService;
    @Autowired
    private GZZRX_RBRequestService gZZRX_RBRequestService;
    @Autowired
    private XYX_TBRequestService xYX_TBRequestService;
    @Autowired
    private ZZX_YARequestService zZX_YARequestService;
    @Autowired
    private GZZRX_ZHRequestService gZZRX_ZHRequestService;
    @Autowired
    private PACRequestService pACRequestService;
    @Autowired
    private GZZRX_PACRequestService gZZRX_PACRequestService;
    @Autowired
    private GZZRX_CARequestService gZZRX_CARequestService;
    @Autowired
    private InsInsuranceSlipAPIService insInsuranceSlipAPIService;
    @Autowired
    private InsCommonReportAPIService insCommonReportAPIService;

    @RequestMapping("/dzbd/{oid}")
    @ResponseBody
    public void dzbd(@PathVariable Long oid) throws Exception {
//        policyService.HTTP_TPC_XYX_CB(1327146857943658497L);
//        policyService.saveOrderInfoBySASS(String.valueOf(oid));
//        policyService.recordSyncZC(String.valueOf(oid));
//        String result = xYX_TBRequestService.requestTB(oid, TransType.EPIC_DZBD_XW.getValue(), null);
//        renderString(result,"application/json");
    }

    /**
     * <b> FileBatchUtil测试类 </b>
     * @author ZXF
     * @create 2018/01/15 0015 11:04
     * @version
     * @注意事项 </b>
     */
    @RequestMapping("/fileTest")
    @ResponseBody
    public void fileTest( HttpServletResponse response) throws Exception {
        List<Map<String,String>> list = new ArrayList<Map<String,String>>();
        Map<String,String> map = Maps.newHashMap();
        map.put("name","BusinessLicense");
        map.put("url","http://bcxin-conins-extranet-test.oss-cn-shanghai.aliyuncs.com/policy/1500278970076.jpg");
        list.add(map);
        Map<String,String> map2 = Maps.newHashMap();
        map2.put("name","CopyOfLegalPersonIdCard(positive)");
        map2.put("url","http://bcxin-conins-extranet-test.oss-cn-shanghai.aliyuncs.com/policy/1504666268851.png");
        list.add(map2);
        String path = FileBatchUtil.dealErJinZhiFile("111111",list);
        System.out.println(path);
    }


    /**
     * <b> saas获取人员信息测试 </b>
     * @author ZXF
     * @create 2018/01/15 0015 11:04
     * @version
     * @注意事项 </b>
     */
    @RequestMapping("/saasc")
    @ResponseBody
    public void saasCom() throws Exception {
//        gZZRX_CARequestService.request_ca_gzzrx(1413424598439030785L, TransTypeEnum.HB.getValue(),null);
//        policyService.saveOrderInfoPush("1399975900191162370");
//        insCommonReportAPIService.findXXReportDetails();
//        长安理赔查询接口
//        String policyNo = "";
//        String reportNo = "715162021110000000081";
//        String result = gZZRX_CARequestService.requestXXReportCA(policyNo,reportNo,1, TransTypeEnum.AJCX.getValue());
//        System.out.println(result);
//        InsCommonReportVo vo = new InsCommonReportVo();
//        vo.setIns_common_report_id("10001");
//        vo.setReport_no("715162021110000000080");
//        List<InsClaimInformationVo> list = Lists.newArrayList();
//        InsClaimInformationVo cvo = new InsClaimInformationVo();
//        cvo.setShort_group_code("01");
//        cvo.setFile_name("1600073690328.png");
//        cvo.setFile_path("http://bcxin-conins-extranet-test.oss-cn-shanghai.aliyuncs.com/report/1600073690328.png");
//        cvo.setStatus("0");
//        InsClaimInformationVo cvo1 = new InsClaimInformationVo();
//        cvo1.setShort_group_code("02");
//        cvo1.setFile_name("1601272544780.png");
//        cvo1.setFile_path("http://bcxin-conins-extranet-test.oss-cn-shanghai.aliyuncs.com/report/1601272544780.png");
//        cvo1.setStatus("0");
//        list.add(cvo);
//        list.add(cvo1);
//        vo.setClaimInformationVoList(list);
//        String result = gZZRX_CARequestService.requestReportCA(vo,TransTypeEnum.CLSC.getValue());
//        System.out.println(result);


//        String result = gZZRX_CARequestService.request_ca_gzzrx(Long.parseLong("1376437771425562625"), TransTypeEnum.HB.getValue(),null);
//        System.out.println(result);
//        String ret = "<?xml version=\"1.0\" encoding=\"GBK\"?><PACKET type=\"RESPONSE\"><HEAD><AffirmEndorseResultDto><UnderwriteFlag></UnderwriteFlag><CertiNo></CertiNo><Eendorse></Eendorse></AffirmEndorseResultDto><ReturnMessageDto><RequestType>00</RequestType><ResponseCode>0</ResponseCode><ErrorMessage></ErrorMessage></ReturnMessageDto></HEAD></PACKET>";
//        System.out.println(ret);
//        GZZRX_PackageMessageChangAn gpm = new GZZRX_PackageMessageChangAn();
//        String result = gpm.returnAnalysisXML(ret, TransTypeEnum.PD.getValue());
//        System.out.println(result);
//        policyService.HTTP_CA_GZZRX_CB(1372786683170271234L);
//        List<Map<String, Object>> list = insInsuranceSlipAPIService.orderList("350205198606010019");
//        System.out.println(1231);
//        policyService.policyExpireInform();
//        comTaskResidualAPIService.disposeComTaskResidualList("1");
//        InsPreservationRecordVo vo = insPreservationRecordAPIService.findInsPreservationRecordVoById(1216553302288842753L);
//        String a = gZZRX_PACRequestService.requestPAC(1209394082451927042L,RB_TT.DZPD.getValue(),vo);
//        System.out.println(a);
//        policyService.sendZZPolicyEmail("1204992925289717762");
//        String a = pACRequestService.requestPAC(1190202654657175554L,RB_TT.CBXX.getValue(),null);
//        System.out.println(a);
//        JedisUtils.del("BLB:cache:PRODUCT-DEFAULT-PCO");
//        InsPreservationRecordVo iprVo = insPreservationRecordAPIService.findInsPreservationRecordVoById(Long.parseLong("1037579105000124417"));
//        String roleJson = ConstProp.BLANK_CHAR;
//        if(iprVo.getInsPreservationDetailVoList() != null){
//            JSONObject jsonObject = new JSONObject();
//            int count = ConstProp.INT_NUMBER_ZERO;
//            for(InsPreservationDetailVo ipdVo : iprVo.getInsPreservationDetailVoList()){
//                if("3".equals(iprVo.getRevise_type())){//替换
//                    if(ipdVo.getBusiness_vo() != null){
//                        jsonObject.put(count+ConstProp.BLANK_CHAR,ipdVo.getId_card()+ConstProp.POUND_SIGN+ipdVo.getName()+ConstProp.POUND_SIGN+"1");
//                        count ++;
//                        jsonObject.put(count+ConstProp.BLANK_CHAR,ipdVo.getBusiness_vo().getId_card()+ConstProp.POUND_SIGN+ipdVo.getBusiness_vo().getName()+ConstProp.POUND_SIGN+"2");
//                        count ++;
//                    }
//                }else{
//                    jsonObject.put(count+ConstProp.BLANK_CHAR,ipdVo.getId_card()+ConstProp.POUND_SIGN+ipdVo.getName()+ConstProp.POUND_SIGN+iprVo.getRevise_type());
//                    count ++;
//                }
//            }
//            jsonObject.put("count",String.valueOf(count-1));
//            roleJson = jsonObject.toString();
//        }
//        System.out.println(roleJson);
//        GZZRX_PackageMessageZhongHua a = new GZZRX_PackageMessageZhongHua();
//        String ret = "<?xml version=\"1.0\" encoding=\"GBK\"?><INSUREQRET>\t<HEAD>\t\t<TRANSRNO>2011</TRANSRNO>\t\t<RESULTCODE>0000</RESULTCODE>\t\t<ERRINFO>投保确认成功</ERRINFO>\t</HEAD>\t<MAIN> \t\t<POLNO></POLNO>\t\t<APPNO>051985170001043U000022</APPNO>\t\t<EURL></EURL>\t\t<COMM_RATE>0.25</COMM_RATE>\t\t<PREM_NOTAX>17169.81</PREM_NOTAX>\t\t<PREM_VAT>1030.19</PREM_VAT>\t</MAIN></INSUREQRET>";
//        a.returnAnalysisXML(ret, "1");
//        comTaskResidualAPIService.disposeComTaskResidualList();
        /*String eurl = "http://ptn.cic.cn/facade/print/epolicy?polno=011985170001043U000017&sign=5156EE4E5EEFA09C1333FE41DB82845B";
        String polno = "011985170001043U000017";
        new Thread(()->{ //异步
            try {
                System.out.println("电子保单："+GZZRX_PackageMessageZhongHua.unloading_bd(polno,eurl));
            } catch(Exception e) {
                logger.error("------------中华雇主责任险电子保单保存，异常："+e.getMessage());
            }
        }).start();*/

//        gZZRX_ZHRequestService.request_zh_gzzrx(1101013982192455681L,"5",null);
        /*String p = "http://tapi.yaic.com.cn/yaicservice/apppdfServlet?user=BCX&policyno=23306000010021180000074&sign=2e307fe1797015668581891b4b4ee239";
        String u = ZZX_YARequestService.unloading_ya(p);
        System.out.println(u);*/
//        String resultDate = insPreservationRecordAPIService.getEffectiveByPolicyId(Long.parseLong("1044831567549505538"));
//        System.out.println(resultDate);
//        policyService.pushRecordInfo("1045508933615554562");
//        policyService.saveOrderInfoBySASS("1049498964717862913");
        /*OrderFormVo vo = policyService.accordingToOrderIDToGetPolicyDto(1039445795690426370L);
        policyService.HTTP_PAC_GZX_DZBD(Long.parseLong(vo.getOid()),null,vo);*/
//        zZX_YARequestService.requestYA(1017587812543172610L,"1",null);
//        JedisUtils.batchDel("BLB");
//        String result = xYX_TBRequestService.requestTB(1007136862594580481L, TransType.EPIC_DZBD_XW.getValue(), null);
//        policyService.gainDZBDByTiming();
//        policyService.pushZZXOrderToYWZC("1001650742987190274");
        /*String result = gZZRX_RBRequestService.request_rb_gzzrx(996315083578630146L, "1", null);
        System.out.println(result);*/
//        policyService.HTTP_TPC_XYX_DZBD(996315083578630146L);
//        policyService.HTTP_TPC_XYX_CB(998835393653747713L);
        /*List<String> strList = new ArrayList<String>();
        List<String> arsList = insPreservationRecordAPIService.selectRecordIdByWebType("ARS");
        strList.addAll(arsList);
        for(String str : strList){
            policyService.pushRecordInfo(str);
        }*/
//        insuranceOperationAPIService.orderSyncZC("945471164269346817");
        /*myAsyncExecutor.execute(()->{

        });*/
//        policyService.HTTP_TPC_XYX_DZBD(Long.parseLong("986538565352669186"));
        /*List<RoleSubjectVo> voList = policyService.getComAndEmpByUserID_SAASAPI("1", "ARS-KF");
        System.out.println("List<RoleSubjectVo>:"+voList.size());
        OrderFormVo dto = policyService.accordingToOrderIDToGetPolicyDto(977087575278129153L);
        JSONObject msgJson = new JSONObject();
        msgJson.put("successInd","1");
        msgJson.put("errorCode","0000");
        msgJson.put("errorMessage","完成");

        String result = gYX_TBRequestService.signXmlResult(dto, msgJson);
        System.out.println(result);*/
//        policyService.HTTP_TPC_XYX_YX(Long.parseLong("986520709021831170"));
    }

    /**
     * <b> saas推送保单信息测试 </b>
     * @author ZXF
     * @create 2018/01/15 0015 11:05
     * @version
     * @注意事项 </b>
     */
    @RequestMapping("/saass")
    @ResponseBody
    public void saasSave() throws Exception {
        System.out.println(ZZX_PackageMessageYongAn.getZipCode("120100"));
//        policyService.returnsAnOrderToTheSpecifiedPlatform("1030286773716471810");
//        policyService.pushOrderToPSS("1027018314932985858");
//        System.out.println(policyService.getArsPath("ARS-NC"));
        /*ComTaskResidual ctr = new ComTaskResidual("testReflect"
                ,"测试方法"
                ,"com.bcxin.ins.service.order.PolicyService"
                ,1
                ,"String"
                ,"886939169605902337"
        );
        classReflect(ctr);*/
//        policyService.saveOrderInfo("1007492256697311233");
//        productService.listProductAndResponsibility();
//        policyService.returnsAnOrderToTheSpecifiedPlatform("980985646083588098");
//        ComTaskResidual ctr = comTaskResidualAPIService.selectById(1027231906286473218L);
//        comTaskResidualAPIService.applyReturnBooleanOfClassReflect(ctr);
//        comTaskResidualAPIService.disposeComTaskResidualList();
    }

    /**
     * <b> 类反射 </b>
     *
     * @author ZXF
     * @create 2018/03/19 0019 14:06
     * @version
     * @注意事项 </b>
     */
    public void classReflect(ComTaskResidual ctr){
        ClassLoader cls = Thread.currentThread().getContextClassLoader();
        try {
            Class c =  cls.loadClass(ctr.getClass_name());
            String[] tArr = ctr.getParam_type_arr().split(",");
            String[] vArr = ctr.getParam_value_arr().split(",");
            Class[] csArr = new Class[ctr.getParam_num()];
            Object[] otArr = new Object[ctr.getParam_num()];
            for(int i = 0; i<ctr.getParam_num();i++){
                String tp = tArr[i];
                if("String".equals(tp)){
                    csArr[i] = String.class;
                    otArr[i] = String.valueOf(vArr[i]);
                }else if("int".equals(tp)){
                    csArr[i] = int.class;
                    otArr[i] = Integer.parseInt(vArr[i]);
                }else if("BigDecimal".equals(tp)){
                    csArr[i] = BigDecimal.class;
                    otArr[i] = new BigDecimal(vArr[i]);
                }else if("Long".equals(tp)){
                    csArr[i] = Long.class;
                    otArr[i] = Long.parseLong(vArr[i]);
                }
            }
            Object o =  SpringContextHolder.getBean(c);
            Method method = o.getClass().getDeclaredMethod(ctr.getMethod_name(),csArr);
            method.setAccessible(true);
            Type t = method.getAnnotatedReturnType().getType();
            System.out.println("----------"+t.getTypeName());
            String ret = (String)method.invoke(o, otArr);
            System.out.println("----------"+ret);
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (NoSuchMethodException e) {
            e.printStackTrace();
        } catch (SecurityException e) {
            e.printStackTrace();
        } catch (IllegalArgumentException e) {
            e.printStackTrace();
        } catch (InvocationTargetException e) {
            e.printStackTrace();
        }
    }

    @RequestMapping("/testtk/{token}")
    @ResponseBody
    public String testtk(@PathVariable String token) {
        if(!"blb-tk-02".equals(token)){
            return "300-token不匹配";
        }
        try {
            Long oid = Long.parseLong("897016761103327233");
            String result = "200#6350100130120170000003#http://infntlb.core.online.taikang.com/netcore2c_port/resources/down/downPolicy?policyNo=32C21D74BE93DE21B111DE64B0D82AE104CF19D122BF58B64B88AE91D68B15BF42DE22A65B55A31B65D78DE53BE29BF75CE84AF1B71C119&appliName=20C62BE25AE78BF33D115D18C16DE114AF75AF73A9A117DF15AE50D91BE11BF19AF36A44DF44BF48DF39DF26B86D54AF49C11A50D49B117CE109B18CE2CE95AF80AE104C93B88B2AE69DF22B105DF21D56C3A101B81";
            log.info("----------TK-GMR-PolicyDto-request(oid:"+oid+"，"+result+")-----------");
            log.info("------------"+result);
            String[] strs = result.split(ConstProp.POUND_SIGN);
            if("200".equals(strs[0])&&strs.length == 3) {
                if (StringUtils.isNotEmpty(strs[1])) {
                    log.info("----------TK-GMR-PolicyDto-request(oid:"+oid+"，SUCCESS!!)-----------");
                    PolicyTransactionVo vo= new PolicyTransactionVo();
                    //保存保单号
                    vo.setPolicy_number(strs[1]);//policy.setExternalReference();
                    vo.setPolicy_id(String.valueOf(oid));
                    insTransactionService.savePolicyExternalReference(vo);
                    //保存保单地址
                    vo.setInsure_path(strs[2]);//保单地址
                    insTransactionService.savePolicyOther(vo);
                    //如果团意险承保就推给百保盾
                    policyService.saveOrderInfo(String.valueOf(oid));
                }
            }
        }catch (Exception e){
            e.printStackTrace();
            return "300-操作异常";
        }
        return "200-操作完成";
    }

    @RequestMapping("/test1")
    @ResponseBody
    public void register() throws Exception {
        String result = build_DBRequestService.requestDB(946257438651613185L,"4",null);
        System.out.println(result);
//        String values =  Build_PackageMessageDuBang.test_941();
        /*String values = "<?xml version=\"1.0\" encoding=\"GBK\"?><PACKET type=\"REQUEST\" version=\"1.0\" ><BODY><REQUEST_TYPE><![CDATA[941]]></REQUEST_TYPE>\n" +
                "<SENDINFO><OUTORDERNO><![CDATA[943664893041700864]]></OUTORDERNO>\n" +
                "<AMOUNT><![CDATA[0.01]]></AMOUNT>\n" +
                "<PAYSTATUS><![CDATA[2]]></PAYSTATUS>\n" +
                "<PAYTIME><![CDATA[2017-12-21 10:16:59]]></PAYTIME>\n" +
                "<ORDERSOURCE><![CDATA[00003]]></ORDERSOURCE>\n" +
                "</SENDINFO><SIGNINFO><SIGN><![CDATA[AE89875E5A727B326BF67DAB095CBDBF]]></SIGN>\n" +
                "</SIGNINFO></BODY></PACKET>";
        System.out.println(values);
        String result = RequestUtil.sendPost("http://192.168.30.232:8080/DB-API/Build/callbackPay",values);
        System.out.println(result);*/
        /*String a = build_DBRequestService.requestDB(943685089012109314L,"4",null);
        System.out.println(a);*/
//        System.out.println("是否存在单子："+specialPublicDutyAPIService.getSpecialPublicDutyVoByThrOrderId(oid));
//        policyService.getComAndEmpByUserID_BBDAPI("1393","");
//        String doAmount_yy = String.valueOf((new BigDecimal("500000")).multiply(new BigDecimal("0.7")));
//        System.out.println(productService.api_request_sign("TYX-PAS-3")==1);
//        policyService.TYX_TK_02();

       /*String policyUrl = "97f5a1c6-a372-4777-824f-bd07008974b3";
        String fileUrl = "";
        if(StringUtils.isNotEmpty(policyUrl)){
            FileDownload fd = new FileDownload();
            fileUrl = fd.getFileAddress(policyUrl);
            if(StringUtils.isNotEmpty(fileUrl)){
                System.out.println(GlobalResources.WEB_PRO_URL+fileUrl);

            }else{
                System.out.println("300#（APP-PA-014.1）电子保单转码失败");
            }
        }else{
            System.out.println("300#（APP-PA-014.2）电子保单fileId获取失败");
        }*/

        /*System.out.println(aaaT("2"));
        System.out.println(aaaT("3"));
        System.out.println(aaaT("4"));*/
//        return policyService.pn_access_token();
        /*ModelAndView view = new ModelAndView("/coninsweb/insurance/build/transaction/finishPay_pg");
        logger.info("test1");
        return view;*/
    }

    private String aaaT(String ty) throws Exception {
        String sta_time = ConstProp.BLANK_CHAR;
        String end_time = ConstProp.BLANK_CHAR;
        if(StringUtils.isNotBlank(ty)) {
            Date nowDate = new Date();
            String nowDate_str = DateUtil.getCurrentDateTime(DateUtil.FORMAT2);
            String a = "5";
            String b = "3";
            if (ConstProp.DIGIT_ONE.equals(ty)) {
                sta_time = DateUtil.getTomorrow();
                end_time = DateUtil.getTomorrow();
            } else if (ConstProp.DIGIT_TWO.equals(ty)) {
                sta_time = DateUtil.dateAdd(0, nowDate_str, -Integer.parseInt(a));
                end_time = DateUtil.dateAdd(0, nowDate_str, -1);

            } else if (ConstProp.DIGIT_THREE.equals(ty)) {
                sta_time = DateUtil.dateAdd(0, nowDate_str, 1);
                end_time = DateUtil.dateAdd(0, nowDate_str, Integer.parseInt(b));
            } else {
                sta_time = DateUtil.dateAdd(0, nowDate_str, -Integer.parseInt(a));
                end_time = DateUtil.dateAdd(0, nowDate_str, Integer.parseInt(b));
            }
        }
        return sta_time+","+end_time;
    }

    @RequestMapping("/test2")
    public ModelAndView test2(String policyStatus, DwzPage page) {
        ModelAndView view = new ModelAndView("/coninsweb/news/test2");
        logger.info("test2");
        ClientUserVo userdetail = UserSupportUtil.getSessionUser();
        if(userdetail == null){
            return new ModelAndView("redirect:/");
        }
        if(GlobalResources.IS_POLICY_TP107001_OPEN.equals("YES")){
            policyService.policyEndStatus(userdetail.getOid());//TODO 检索投标产品支付完成重置状态并获取电子保单保函（等接口对接再使用）
        }
        if(policyStatus == null){
            policyStatus = ConstProp.DIGIT_ONE;
        }
        page.setNumPerPage(5);
        String keyword = getRequest().getParameter("keyword");
        String starDate = getRequest().getParameter("starDate");
        String endDate = getRequest().getParameter("endDate");
        view.addObject(ConstProp.USERDETAIL,userdetail);
        InsOrderSearchVo search = InsOrderSearchVo.build(Long.parseLong(userdetail.getOid()),policyStatus,ConstProp.BLANK_CHAR, keyword, starDate, endDate, ConstProp.BLANK_CHAR,page);
        view.addObject("policyTotals",policyService.findTotalPolicyNum(search));
        List<OrderFormVo> orderList = policyService.findPolicyForPage(search);
        view.addObject(ConstProp.ORDERLIST,orderList);
        view.addObject("policyStatus",policyStatus);
        return view;
    }

    @RequestMapping("/test_order")
    public void test_order() {
        List<OrderFormVo> dtoList = new ArrayList<OrderFormVo>();
//        List<OrderFormVo> dtoList = policyService.selectInsOrderFormByStatusAndProductCode(ConstProp.DIGIT_FOUR,"TYX-TK");
        System.out.println((dtoList != null ? dtoList.size() : "null"));
    }


    /*@RequestMapping("/test3")
    public void test3() {
        logger.info("test3");
        String  url=  GlobalResources.PNS_GET_ACCESS_TOKEN_URL;
        logger.info("===========================PN_GET_ACCESS_TOKEN_URL-START======================");
        try {
            String s= RequestUtil.sendGet(url, null);
            if(StringUtils.isNotEmpty(s)){
                JSONObject json= JSON.parseObject(s);
                String status=json.get("ret").toString();
                if("0".equals(status)){
                    String data=json.getString("data");
                    logger.info("平安返回值："+data);
                    JSONObject result=JSONObject.parseObject(data);
                    ComDeployConfig config= new ComDeployConfig();
                    config.setConfig_type(GlobalResources.ENVI);
                    config.setConfig_key("PN_ACCESS_TOKEN");
                    //new EntityWrapper<SysRoleMenu>().addFilter("role_id={0}",roleId)
                    ComDeployConfig  configNow =comDeployConfigService.selectOne(new EntityWrapper<>(config));
                    configNow.setConfig_value(result.getString("PN_ACCESS_TOKEN"));
                    comDeployConfigService.updateById(configNow);
                    GlobalResources.PN_ACCESS_TOKEN=result.getString("PN_ACCESS_TOKEN");
                    logger.info("===========================PN_GET_ACCESS_TOKEN_URL-END======================");

                }
            }
        }catch (Exception ex){
            logger.error("ACCESS_TOKEN",ex);


        }
    }*/

    @RequestMapping("/test4")
    @ResponseBody
    public Object test4() throws Exception {
        logger.info("test4");
        return yGGCService.underwritingHttpSend(JSON.toJSONString(YGGC.getDemo()),"1");
    }

    @RequestMapping("/test5/{policyNo}/{premiumP}")
    @ResponseBody
    public Object test5(@PathVariable String policyNo, @PathVariable String premiumP) throws Exception {
        logger.info("test5");
//        return yGGCService.payUrlZFB("TV5N2213201700362906","1");
        return yGGCService.payUrlZFB(policyNo,premiumP);
    }


    @RequestMapping("/test6")
    public void test6()  {
//        log.info("=是否冻结束带结发了3");
//        log1.info("=是否冻结束带结发了2");
        logger.info("test6");

//        ExecutorService executorService = Executors.newFixedThreadPool(50);
//        FileDownloadTest test = new FileDownloadTest();
//        for (int i = 0; i < 1; i++) {
//            executorService.execute(test);
//        }
//        executorService.shutdown();
        FileDownload test = new FileDownload();
        try {
            logger.info(test.getFileAddress("38a964ad-22bc-45f0-90d1-942d78717897"));

        } catch (Exception e) {
            e.printStackTrace();
        }
    }


    @RequestMapping("/test7")
    public void test7()  {
        log.info("http://" + getRequest().getServerName() //服务器地址
                + ":"
                + getRequest().getServerPort());

    }

    public static void main(String[] args) {
        /*JSONArray jarr = new JSONArray();
        JSONObject jsonObject = null;
        for(int i=0;i<10;i++){
            jsonObject = new JSONObject();
            jsonObject.put("idCardNo","123123"+i);
            jsonObject.put("name","各个"+i);
            jarr.add(jsonObject);
            jsonObject = null;
        }
        System.out.println(jarr.toJSONString());*/
//        String a = (new BigDecimal("220.50")).multiply(new BigDecimal("1000")).divide(new BigDecimal("320000"),2, RoundingMode.HALF_UP).toString();
//        System.out.println(a);
        /*Map<String,Object> map = new HashMap<String,Object>();
        Integer b = 0;
        map.put("a",b);
        String v = String.valueOf(map.get("a"));
        System.out.println(v);*/
        /*String data="2017-07-13";
        log.info(data.length()+"");*/
        /*String a = "t.kind\n" +
                "\t\t, t.role_type\n" +
                "\t\t, t.related_to_insured\n" +
                "\t\t, t.name_cn\n" +
                "\t\t, t.name_en\n" +
                "\t\t, t.insurance_slip_id\n" +
                "\t\t, t.app_idcard_path\n" +
                "\t\t, t.app_idcard_versa_path\n" +
                "\t\t, t.app_address_path\n" +
                "\t\t, t.app_spouse_card_path\n" +
                "\t\t, t.app_trauschein_path\n" +
                "\t\t, t.app_business_path\n" +
                "\t\t, t.app_organizing_path\n" +
                "\t\t, t.app_tax_path\n" +
                "\t\t, t.idx\n" +
                "\t\t, t.code\n" +
                "\t\t, t.codex\n" +
                "\t\t, t.status\n" +
                "\t\t, t.id_type\n" +
                "\t\t, t.address\n" +
                "\t\t, t.phone\n" +
                "\t\t, t.tel\n" +
                "\t\t, t.email\n" +
                "\t\t, t.reg_province\n" +
                "\t\t, t.reg_city\n" +
                "\t\t, t.reg_district\n" +
                "\t\t, t.reg_address\n" +
                "\t\t, t.total_emp\n" +
                "\t\t, t.do_business_address\n" +
                "\t\t, t.region\n" +
                "\t\t, t.organization_code\n" +
                "\t\t, t.tax_code\n" +
                "\t\t, t.aaum_code\n" +
                "\t\t, t.customs_code \n" +
                "\t\t, t.com_type\n" +
                "\t\t, t.business_nature\n" +
                "\t\t, t.sectors_sold\n" +
                "\t\t, t.companies_detail\n" +
                "\t\t, t.id_insurance\n" +
                "\t\t, t.insurance_name\n" +
                "\t\t, t.turnover_domestic\n" +
                "\t\t, t.turnover_export\n" +
                "\t\t, t.currency_required\n" +
                "\t\t, t.com_nature\n" +
                "\t\t, t.nature_two\n" +
                "\t\t, t.id_option\n" +
                "\t\t, t.id_star_date\n" +
                "\t\t, t.id_end_date\n" +
                "\t\t, t.link_section\n" +
                "\t\t, t.business_area\n" +
                "\t\t, t.industry\n" +
                "\t\t, t.other_industry\n" +
                "\t\t, t.legal_name\n" +
                "\t\t, t.legal_duty\n" +
                "\t\t, t.legal_phone\n" +
                "\t\t, t.agent_name\n" +
                "\t\t, t.agent_duty\n" +
                "\t\t, t.agent_phone\n" +
                "\t\t, t.agent_email\n" +
                "\t\t, t.link_name\n" +
                "\t\t, t.link_duty\n" +
                "\t\t, t.link_fax\n" +
                "\t\t, t.link_phone\n" +
                "\t\t, t.link_email\n" +
                "\t\t, t.link_tel\n" +
                "\t\t, t.zip_code\n" +
                "\t\t, t.right_as_principal\n" +
                "\t\t, t.nationality\n" +
                "\t\t, t.id_no\n" +
                "\t\t, t.sex\n" +
                "\t\t, t.major_group\n" +
                "\t\t, t.mobile\n" +
                "\t\t, t.province\n" +
                "\t\t, t.city\n" +
                "\t\t, t.area_code\n" +
                "\t\t, t.register_date\n" +
                "\t\t, t.validity_end\n" +
                "\t\t, t.birth_date\n" +
                "\t\t, t.stature\n" +
                "\t\t, t.weight\n" +
                "\t\t, t.annual_income";
        String b = a.replace("\t\t, t.",",").replace("\n","").replace("t.","");
        String[] cs = b.split(",");
        for(String c : cs){
            System.out.println(c+" = VALUES("+c+"),");
        }*/
    }

    @RequestMapping("/saveOrderInfo/{oid}")
    @ResponseBody
    public String saveOrderInfo(@PathVariable String oid) throws Exception {
        try {
            policyService.saveOrderInfo(oid);
            return "{code:200,message:SUCCESS!}";
        }catch (Exception e){
            e.printStackTrace();
            return "{code:300,message:FAIL!,result:"+e+"}";
        }
    }

    @RequestMapping("/test5")
    public ModelAndView test5() {
        ModelAndView view = new ModelAndView("/coninsweb/test/test1");
        view.addObject("proPath",GlobalResources.DONOW_PATH);
        return view;
    }
    @RequestMapping("/test5-service")
    public void test5Service(HttpServletResponse response, @RequestBody PingAnCaiPayVo pacVo) {
        Map<String, String> requestMap = pacVo.toMap();
        logger.info("支付接口回调-callbackPay-PAC-ZZX：接收到数据-"+requestMap.toString());
    }
}
