package com.dxhy.base.controller;

import com.dxhy.api.model.config.Tax;
import com.dxhy.base.service.tdxrecordinvoice.BaseIFpbrzService;
import com.dxhy.base.service.tdxrecordinvoice.BaseIFpdrrzService;
import com.dxhy.base.service.tdxrecordinvoice.BaseIFpsmrzService;
import com.dxhy.base.service.tdxrecordinvoice.BaseIRzTDxRecordInvoiceService;
import com.dxhy.common.aspect.SysLog;
import com.dxhy.common.constant.CommonConstants;
import com.dxhy.common.controller.AbstractController;
import com.dxhy.common.util.StringHelper;
import com.dxhy.common.util.UserInfoUtil;
import com.dxhy.common.utils.DateUtils;
import com.dxhy.common.utils.R;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 *
 *
 * 发票认证入口
 *
 * @author 张宏
 * @date 2019年4月25日
 *
 */
@SuppressWarnings({"AlibabaUndefineMagicConstant", "AlibabaMethodTooLong", "AlibabaLowerCamelCaseVariableNaming",
    "AlibabaClassNamingShouldBeCamel"})
@RestController
@RequestMapping("fprz")
@Slf4j
public class BaseRzTDxRecordInvoiceController extends AbstractController {

    @Resource
    private BaseIRzTDxRecordInvoiceService baseIRzTDxRecordInvoiceService;

    @Resource
    private BaseIFpsmrzService baseIFpsmrzService;

    @Resource
    private BaseIFpdrrzService baseIFpdrrzService;

    @Resource
    private BaseIFpbrzService baseIFpbrzService;
    private static final Pattern PATTERN_AMOUNT = Pattern.compile("^(([1-9]{1}\\d*)|([0]{1}))(\\.(\\d){0,2})?$");
    private static final Pattern PATTERN_DATE = Pattern.compile(
        "^(?:(?!0000)[0-9]{4}-(?:(?:0[1-9]|1[0-2])-(?:0[1-9]|1[0-9]|2[0-8])|(?:0[13-9]|1[0-2])-(?:29|30)|(?:0[13578]|1[02])-31)|(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:0[48]|[2468][048]|[13579][26])00)-02-29)$");
    private static final Pattern PATTERN_INVOICE_NO = Pattern.compile("\\d{8}");

    /**
     * 发票手工认证
     *
     * @param map
     *            请求参数
     * @return 返回结果
     */
    @PostMapping("/fpxxrz")
    @SysLog("调用发票手工认证接口")
    public ResponseEntity<?> identifiRecordInvoice(@RequestBody Map<String, Object> map) {
        int curr = 1;
        int size = 10;
        int count = 0;
        String uuids = (String)map.get("uuids");
        String dkses = (String)map.get("dkses");
        String gxType = (String)map.get("gxType");
        Map<String, Object> pramsMap = new HashMap<>(16);
        pramsMap.put("name", getUserName());
        pramsMap.put("dbName", getUserInfo().getDbName());
        pramsMap.put("loginName", getLoginName());
        pramsMap.put("userName", getUserName());
        List<String> gfshList = UserInfoUtil.getGfshAll(getUserInfo().getOrg());

        if (!gfshList.isEmpty()) {
            pramsMap.put("gfsh", gfshList);
        } else {
            return ResponseEntity.ok(R.error("购方信息不能为空！"));
        }

        if (!StringHelper.isBlank(uuids)) {
            pramsMap.put("uuids", uuids);
        } else {
            return ResponseEntity.ok(R.error("请先选择要认证的数据！"));
        }
        if (!StringHelper.isBlank(dkses)) {
            pramsMap.put("dkses", dkses);
        }
        if (!StringHelper.isBlank(gxType)) {
            pramsMap.put("gxType", gxType);
        } else {
            return ResponseEntity.ok(R.error("认证方式不能为空！"));
        }
        try {
            return ResponseEntity
                .ok(R.ok().put("data", baseIRzTDxRecordInvoiceService.identifiByIds(pramsMap, curr, size, count)));
        } catch (Exception e) {
           log.info("业务处理异常：{}", e);
            log.error("", e);
            return ResponseEntity.ok(R.error(CommonConstants.MSG_ERR_DEFAULT));
        }
    }

    /**
     * 发票一键认证
     *
     * @param map
     *            请求参数
     * @return 返回结果
     */
    @PostMapping("/fpxxrzAll")
    @SysLog("调用发票一键认证接口")
    public ResponseEntity<?> identifiRecordInvoiceAll(@RequestBody Map<String, Object> map) {
        String gfsh = (String)map.get("gfsh");
        String invoiceType = (String)map.get("invoiceType");
        String kpksrq = (String)map.get("kpksrq");
        String kpjsrq = (String)map.get("kpjsrq");
        String qszt = (String)map.get("qszt");
        String qsfs = (String)map.get("qsfs");
        String businessCode = (String)map.get("businessCode");
        String invoiceNo = (String)map.get("invoiceNo");
        String qsksrq = (String)map.get("qsksrq");
        String qsjsrq = (String)map.get("qsjsrq");
        String xfmc = (String)map.get("xfmc");
        String position = (String)map.get("position");
        String fpzt = (String)map.get("invoiceStatus");

        String qsr = (String)map.get("qsr");
        Map<String, Object> pramsMap = new HashMap<>(20);
        pramsMap.put("business", getUserInfo().getBusiness());
        pramsMap.put("dbName", getUserInfo().getDbName());
        pramsMap.put("name", getUserName());
        pramsMap.put("loginName", getLoginName());
        List<Tax> taxList = getUserInfo().getOrg();
        pramsMap.put("taxList", taxList);
        pramsMap.put("qsflag", getUserInfo().getQsStatus());

        List<String> gfshList = new ArrayList<>();
        if (!"99".equals(gfsh) && StringUtils.isNotBlank(gfsh)) {
            gfshList.add(gfsh);
        } else {
            gfshList = UserInfoUtil.getGfshAll(getUserInfo().getOrg());
        }
        pramsMap.put("gfsh", gfshList);

        if (!StringUtils.isBlank(invoiceType)) {
            if (!"99".equals(invoiceType)) {
                pramsMap.put("invoiceType", invoiceType);
            }
        } else {
            return ResponseEntity.ok(R.error("发票类型不能为空！"));
        }
        if (StringUtils.isNotBlank(fpzt)) {
            pramsMap.put("fpzt", fpzt);
        } else {
            return ResponseEntity.ok(R.error("发票状态不能为空"));
        }

        pramsMap.put("businessCode", "99");
        if (!StringUtils.isBlank(qszt)) {
            if (!"99".equals(qszt)) {
                pramsMap.put("qszt", qszt);
                if ("1".equals(qszt)) {
                    if (!StringUtils.isBlank(qsksrq)) {
                        pramsMap.put("qsksrq", qsksrq);
                    } else {
                        return ResponseEntity.ok(R.error("签收开始日期不能为空！"));
                    }
                    if (!StringUtils.isBlank(qsjsrq)) {
                        pramsMap.put("qsjsrq", qsjsrq);
                    } else {
                        return ResponseEntity.ok(R.error("签收结束日期不能为空！"));
                    }
                    if (!StringUtils.isBlank(qsfs)) {
                        // 表示全部
                        if (!"99".equals(qsfs)) {
                            pramsMap.put("qsfs", qsfs);
                        }
                    } else {
                        return ResponseEntity.ok(R.error("签收方式不能为空！"));
                    }
                    pramsMap.put("businessCode", businessCode);
                }
            }
        } else {
            return ResponseEntity.ok(R.error("签收状态不能为空！"));
        }
        String qsflag = getUserInfo().getQsStatus();
        if ("1".equals(qsflag)) {
            pramsMap.put("qszt", "1");
        }
        if (!StringUtils.isBlank(kpksrq)) {
            pramsMap.put("kpksrq", kpksrq);
        } else {
            return ResponseEntity.ok(R.error("开票开始日期不能为空！"));
        }
        if (!StringUtils.isBlank(kpjsrq)) {
            pramsMap.put("kpjsrq", kpjsrq);
        } else {
            return ResponseEntity.ok(R.error("开票结束日期不能为空！"));
        }

        if (!StringUtils.isBlank(position)) {
            pramsMap.put("username", getUserName());
            pramsMap.put("position", position);
        }

        if (!StringUtils.isBlank(invoiceNo)) {
            if(invoiceNo.length()==8){
                pramsMap.put("invoiceNo", invoiceNo);
            }else {
                pramsMap.put("eleInvoiceNo", invoiceNo);
            }
        }
        if (!StringUtils.isBlank(xfmc)) {
            pramsMap.put("xfmc", xfmc);
        }
        if (!StringUtils.isBlank(qsr)) {
            pramsMap.put("qsr", qsr);
        }

        if (!gfshList.isEmpty()) {
            pramsMap.put("gfsh", gfshList);
        } else {
            return ResponseEntity.ok(R.error("购方信息不能为空！"));
        }
        String invoiceSource = (String)map.get("invoiceSource");
        if (!StringUtils.isBlank(invoiceSource) && !"99".equals(invoiceSource)) {
            pramsMap.put("invoiceSource", invoiceSource);
        }
        try {
            return ResponseEntity.ok(R.ok().put("data", baseIRzTDxRecordInvoiceService.identifiByAll(pramsMap)));
        } catch (Exception e) {
           log.info("业务处理异常：{}", e);
            log.error("", e);
            return ResponseEntity.ok(R.error(CommonConstants.MSG_ERR_DEFAULT));
        }
    }

    /**
     * 发票一键认证数量、税额计算
     *
     * @param map
     *            请求参数
     * @return 返回结果
     */
    @PostMapping("/fpxxrzAllCount")
    @SysLog("调用发票一键认证数量税额计算接口")
    public ResponseEntity<?> fpxxrzAllCount(@RequestBody Map<String, Object> map) {
        String gfsh = (String)map.get("gfsh");
        String invoiceType = (String)map.get("invoiceType");
        String kpksrq = (String)map.get("kpksrq");
        String kpjsrq = (String)map.get("kpjsrq");
        String qszt = (String)map.get("qszt");
        String qsfs = (String)map.get("qsfs");
        String businessCode = (String)map.get("businessCode");
        String invoiceNo = (String)map.get("invoiceNo");
        String qsksrq = (String)map.get("qsksrq");
        String qsjsrq = (String)map.get("qsjsrq");
        String xfmc = (String)map.get("xfmc");
        String position = (String)map.get("position");
        String fpzt = (String)map.get("invoiceStatus");

        String qsr = (String)map.get("qsr");
        Map<String, Object> pramsMap = new HashMap<>(20);
        pramsMap.put("business", getUserInfo().getBusiness());
        pramsMap.put("dbName", getUserInfo().getDbName());
        pramsMap.put("name", getUserName());
        List<Tax> taxList = getUserInfo().getOrg();
        pramsMap.put("taxList", taxList);
        pramsMap.put("qsflag", getUserInfo().getQsStatus());

        List<String> gfshList = new ArrayList<>();
        if (!"99".equals(gfsh) && StringUtils.isNotBlank(gfsh)) {
            gfshList.add(gfsh);
        } else {
            gfshList = UserInfoUtil.getGfshAll(getUserInfo().getOrg());
        }
        pramsMap.put("gfsh", gfshList);

        if (!StringUtils.isBlank(invoiceType)) {
            if (!"99".equals(invoiceType)) {
                pramsMap.put("invoiceType", invoiceType);
            }
        } else {
            return ResponseEntity.ok(R.error("发票类型不能为空！"));
        }
        if (StringUtils.isNotBlank(fpzt)) {
            pramsMap.put("fpzt", fpzt);
        } else {
            return ResponseEntity.ok(R.error("发票状态不能为空"));
        }

        pramsMap.put("businessCode", "99");
        if (!StringUtils.isBlank(qszt)) {
            if (!"99".equals(qszt)) {
                pramsMap.put("qszt", qszt);
                if ("1".equals(qszt)) {
                    if (!StringUtils.isBlank(qsksrq)) {
                        pramsMap.put("qsksrq", qsksrq);
                    } else {
                        return ResponseEntity.ok(R.error("签收开始日期不能为空！"));
                    }
                    if (!StringUtils.isBlank(qsjsrq)) {
                        pramsMap.put("qsjsrq", qsjsrq);
                    } else {
                        return ResponseEntity.ok(R.error("签收结束日期不能为空！"));
                    }
                    if (!StringUtils.isBlank(qsfs)) {
                        // 表示全部
                        if (!"99".equals(qsfs)) {
                            pramsMap.put("qsfs", qsfs);
                        }
                    } else {
                        return ResponseEntity.ok(R.error("签收方式不能为空！"));
                    }
                    pramsMap.put("businessCode", businessCode);
                }
            }
        } else {
            return ResponseEntity.ok(R.error("签收状态不能为空！"));
        }
        String qsflag = getUserInfo().getQsStatus();
        if ("1".equals(qsflag)) {
            pramsMap.put("qszt", "1");
        }
        if (!StringUtils.isBlank(kpksrq)) {
            pramsMap.put("kpksrq", kpksrq);
        } else {
            return ResponseEntity.ok(R.error("开票开始日期不能为空！"));
        }
        if (!StringUtils.isBlank(kpjsrq)) {
            pramsMap.put("kpjsrq", kpjsrq);
        } else {
            return ResponseEntity.ok(R.error("开票结束日期不能为空！"));
        }

        if (!StringUtils.isBlank(position)) {
            pramsMap.put("username", getUserName());
            pramsMap.put("position", position);
        }

        if (!StringUtils.isBlank(invoiceNo)) {
            if(invoiceNo.length()==8){
                pramsMap.put("invoiceNo", invoiceNo);
            }else {
                pramsMap.put("eleInvoiceNo", invoiceNo);
            }
        }
        if (!StringUtils.isBlank(xfmc)) {
            pramsMap.put("xfmc", xfmc);
        }
        if (!StringUtils.isBlank(qsr)) {
            pramsMap.put("qsr", qsr);
        }

        if (!gfshList.isEmpty()) {
            pramsMap.put("gfsh", gfshList);
        } else {
            return ResponseEntity.ok(R.error("购方信息不能为空！"));
        }
        String invoiceSource = (String)map.get("invoiceSource");
        if (!StringUtils.isBlank(invoiceSource) && !"99".equals(invoiceSource)) {
            pramsMap.put("invoiceSource", invoiceSource);
        }
        try {
            return ResponseEntity.ok(R.ok().put("data", baseIRzTDxRecordInvoiceService.identifiAllCount(pramsMap)));
        } catch (Exception e) {
           log.info("业务处理异常：{}", e);
            log.error("", e);
            return ResponseEntity.ok(R.error(CommonConstants.MSG_ERR_DEFAULT));
        }
    }

    /**
     * 扫码发票认证信息查询
     *
     * @param map
     *            请求参数
     * @return 返回结果
     */
    @PostMapping("/smrzxxlb")
    @SysLog("调用扫码发票认证信息查询接口")
    public ResponseEntity<?> smrzRecordInvoice(@RequestBody Map<String, Object> map) {
        String invoiceCode = (String) map.get("invoiceCode");
        String invoiceNo = (String) map.get("invoiceNo");
        String invoiceAmount = (String) map.get("invoiceAmount");
        String invoiceDate = (String) map.get("invoiceDate");
        String checkCode = (String) map.get("checkCode");
        Map<String, Object> pramsMap = new HashMap<>(16);
        pramsMap.put("dbName", getUserInfo().getDbName());
        List<Tax> taxList = getUserInfo().getOrg();
        pramsMap.put("taxList", taxList);
        List<String> gfshList = UserInfoUtil.getGfshAll(getUserInfo().getOrg());
        pramsMap.put("gfsh", gfshList);
        String qsflag = getUserInfo().getQsStatus();
        pramsMap.put("qsflag", qsflag);

        pramsMap.put("company", map.get("company"));
        pramsMap.put("menuId", map.get("menuId"));
        if (!StringHelper.isBlank(invoiceCode)){
            pramsMap.put("fpdm", invoiceCode);
        }
        if (!StringHelper.isBlank(invoiceNo)){
            pramsMap.put("fphm", invoiceNo);
        }
        if (!StringHelper.isBlank(invoiceAmount)){
            pramsMap.put("je", invoiceAmount);
        }
        if (!StringHelper.isBlank(checkCode)){
            pramsMap.put("jym", checkCode);
        }

        if (!StringHelper.isBlank(invoiceDate)) {
            // 判断日期
            // yyyy-mm-dd
            // 的正则表达式（能够区分真实日期，区分闰年）

            Matcher match = PATTERN_DATE.matcher(invoiceDate);
            if (match.matches()) {
                pramsMap.put("kprq", invoiceDate);
            } else {
                return ResponseEntity.ok(R.error(" 开票日期格式错误！"));
            }
        } else {
            return ResponseEntity.ok(R.error("开票日期不能为空！"));
        }

        try {
            return ResponseEntity.ok(R.ok().put("data", baseIFpsmrzService.selectBySmrzCxtj(pramsMap)));
        } catch (Exception e) {
           log.info("业务处理异常：{}", e);
            log.error("", e);
            return ResponseEntity.ok(R.error(CommonConstants.MSG_ERR_DEFAULT));
        }

    }

    /**
     * 发票导入认证信息查询
     *
     * @param datalist
     *            请求参数
     * @return 返回结果
     */
    @PostMapping("/drrzxxlb")
    @SysLog("调用发票导入认证信息查询接口")
    public ResponseEntity<?> drrzRecordInvoice(@RequestBody(required = false) String datalist) {

        Map<String, Object> pramsMap = new HashMap<>(16);

        List<String> gfshList = UserInfoUtil.getGfshAll(getUserInfo().getOrg());
        pramsMap.put("dbName", getUserInfo().getDbName());

        pramsMap.put("gfsh", gfshList);
        String qsflag = getUserInfo().getQsStatus();
        pramsMap.put("qsflag", qsflag);
        if (!StringHelper.isBlank(datalist)) {

            pramsMap.put("datalist", datalist);
        } else {
            return ResponseEntity.ok(R.error("请上传excel文件!"));
        }

        try {
            return ResponseEntity.ok(R.ok().put("data", baseIFpdrrzService.selectByDrrzCxtj(pramsMap)));
        } catch (Exception e) {
           log.info("业务处理异常：{}", e);
            log.error("", e);
            return ResponseEntity.ok(R.error(CommonConstants.MSG_ERR_DEFAULT));
        }
    }

    /**
     * 不认证发票信息查询
     *
     * @param map
     *            请求参数
     * @return 返回结果
     */
    @PostMapping("/brzxxlb")
    @SysLog("调用不认证发票信息查询接口")
    public ResponseEntity<?> brzRecordInvoice(@RequestBody Map<String, Object> map) {
        String gfsh = (String)map.get("gfsh");
        String fplx = (String)map.get("fplx");
        String invoiceSource = (String)map.get("invoiceSource");
        String fphm = (String)map.get("fphm");
        String qsfs = (String)map.get("qsfs");
        String sfszbrz = (String)map.get("sfszbrz");
        String xfmc = (String)map.get("xfmc");
        String kprqq = (String)map.get("kprqq");
        String kprqz = (String)map.get("kprqz");
        String qszt = (String)map.get("qszt");
        String qsrqq = (String)map.get("qsrqq");
        String qsrqz = (String)map.get("qsrqz");
        String qsr = (String)map.get("qsr");
        int curr = (int)map.get("curr");
        int size = (int)map.get("size");
        Map<String, Object> pramsMap = new HashMap<>(18);
        String qsflag = getUserInfo().getQsStatus();
        pramsMap.put("dbName", getUserInfo().getDbName());
        pramsMap.put("isQs", getUserInfo().getQsStatus());
        pramsMap.put("business", getUserInfo().getBusiness());
        pramsMap.put("company", map.get("company"));
        pramsMap.put("menuId", map.get("menuId"));
        List<String> gfshList = new ArrayList<>();
        List<Tax> taxList = getUserInfo().getOrg();
        List<Tax> newTaxList = new ArrayList<>();
        if (!"99".equals(gfsh) && StringUtils.isNotBlank(gfsh)) {
            for (Tax tax : taxList) {
                if (gfsh.equals(tax.getTaxno())) {
                    String upgradeStatus = tax.getUpgradeStatus();
                    if ("1".equals(upgradeStatus)) {
                        gfshList.add(gfsh);
                    }
                }
            }
        } else {
            for (Tax tax : taxList) {
                String upgradeStatus = tax.getUpgradeStatus();
                if ("1".equals(upgradeStatus)) {
                    newTaxList.add(tax);
                }
            }
            gfshList = UserInfoUtil.getGfshAll(newTaxList);
        }
        pramsMap.put("gfsh", gfshList);

        if (!StringUtils.isBlank(fplx)) {
            if (!"99".equals(fplx)) {
                pramsMap.put("fplx", fplx);
            }
        } else {
            return ResponseEntity.ok(R.error("发票类型不能为空！"));
        }
        if (invoiceSource != null) {
            if (!"99".equals(invoiceSource)) {
                pramsMap.put("invoiceSource", invoiceSource);
            }
        }

        if (!StringUtils.isBlank(sfszbrz)) {
            if (!sfszbrz.equals("99")&&!sfszbrz.equals("0")&&!sfszbrz.equals("4")) {
                return ResponseEntity.ok(R.error("认证标志只能为99、0、4！"));
            }
            if (!"99".equals(sfszbrz)) {
                pramsMap.put("sfszbrz", sfszbrz);
            }
        } else {
            return ResponseEntity.ok(R.error("认证标志不能为空！"));
        }
        pramsMap.put("businessCode", "99");
        if (!StringUtils.isBlank(qszt)) {
            if (!"99".equals(qszt)) {
                pramsMap.put("qszt", qszt);
                if ("1".equals(qszt)) {
                    if (!StringUtils.isBlank(qsrqq)) {
                        pramsMap.put("qsrqq", qsrqq);
                    }
                    if (!StringUtils.isBlank(qsrqz)) {
                        pramsMap.put("qsrqz", qsrqz);
                    }
                    if (!StringUtils.isBlank(qsfs)) {
                        if (!"99".equals(qsfs)) {
                            pramsMap.put("qsfs", qsfs);
                        }
                    } else {
                        return ResponseEntity.ok(R.error("签收方式不能为空！"));
                    }
                    pramsMap.put("businessCode", map.get("businessCode"));
                }
            }
        } else {
            return ResponseEntity.ok(R.error("签收状态不能为空！"));
        }
        if ("1".equals(qsflag)) {
            pramsMap.put("qszt", qsflag);
        }
        if (!StringUtils.isBlank(fphm)) {
            if (fphm.length() == 8) {
                pramsMap.put("fphm", fphm);
            } else {
                pramsMap.put("eleInvoiceNo", fphm);
            }
        }

        if (!StringUtils.isBlank(xfmc)) {
            pramsMap.put("xfmc", xfmc);
        }
        if (StringUtils.isNotBlank(qsr)) {
            pramsMap.put("qsr", qsr);
        }
        if (!StringUtils.isBlank(kprqq)) {
            if(!DateUtils.checkStrFormat(kprqq, "yyyy-MM-dd")){
                return ResponseEntity.ok(R.error("开票日期起格式不正确！"));
            }
            pramsMap.put("kprqq", kprqq);
        } else {
            return ResponseEntity.ok(R.error("开票日期不能为空！"));
        }

        if (!StringUtils.isBlank(kprqz)) {
            if(!DateUtils.checkStrFormat(kprqz, "yyyy-MM-dd")){
                return ResponseEntity.ok(R.error("开票日期止格式不正确！"));
            }
            pramsMap.put("kprqz", kprqz);
        } else {
            return ResponseEntity.ok(R.error("开票日期不能为空！"));
        }

        try {
            return ResponseEntity.ok(R.ok().put("data", baseIFpbrzService.selectByFpbrz(pramsMap, curr, size)));
        } catch (Exception e) {
           log.info("业务处理异常：{}", e);
            log.error("", e);
            return ResponseEntity.ok(R.error(CommonConstants.MSG_ERR_DEFAULT));
        }
    }

    /**
     * 不认证发票设置
     *
     * @param map
     *            请求参数
     * @return 返回结果
     */
    @PostMapping("/brzfpsz")
    @SysLog("调用不认证发票设置接口")
    public ResponseEntity<?> brzfpszRecordInvoice(@RequestBody Map<String, Object> map) {
        String uuids = (String)map.get("uuids");
        Map<String, Object> pramsMap = new HashMap<>(16);
        pramsMap.put("name", getUserName());
        pramsMap.put("dbName", getUserInfo().getDbName());
        if (!StringHelper.isBlank(uuids)) {

            pramsMap.put("uuids", uuids);
        } else {
            return ResponseEntity.ok(R.error("请选择发票!"));
        }
        String bdkMessage = (String) map.get("bdkMessage");
        if(!StringHelper.isBlank(bdkMessage)){
            pramsMap.put("bdkMessage",bdkMessage);
        }else {
            return ResponseEntity.ok(R.error("请选择不抵扣类型!"));
        }
        String bdkYy = (String) map.get("bdkYy");
        if(!StringHelper.isBlank(bdkYy)){
            pramsMap.put("bdkYy",bdkYy);
        }
        try {

            return ResponseEntity.ok(R.ok().put("data", baseIFpbrzService.updateByFpbrz(pramsMap)));
        } catch (Exception e) {
           log.info("业务处理异常：{}", e);
            log.error("", e);
            return ResponseEntity.ok(R.error("提交失败"));
        }

    }

    /**
     * 取消不认证发票设置
     *
     * @param map
     *            请求参数
     * @return 返回结果
     */
    @PostMapping("/qxbrzfpsz")
    @SysLog("调用取消不认证发票设置接口")
    public ResponseEntity<?> qxbrzfpszRecordInvoice(@RequestBody Map<String, Object> map) {
        String uuids = (String)map.get("uuids");
        Map<String, Object> pramsMap = new HashMap<>(16);
        pramsMap.put("name", getUserName());
        pramsMap.put("dbName", getUserInfo().getDbName());
        if (!StringHelper.isBlank(uuids)) {

            pramsMap.put("uuids", uuids);
        } else {
            return ResponseEntity.ok(R.error("请选择发票!"));
        }
        try {

            return ResponseEntity.ok(R.ok().put("data", baseIFpbrzService.updateByQxFpbrz(pramsMap)));
        } catch (Exception e) {
           log.info("业务处理异常：{}", e);
            log.error("", e);
            return ResponseEntity.ok(R.error("提交失败"));
        }
    }

}
