package com.dxhy.baseInterface.bigBTab.service.impl;

import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.dxhy.api.model.bigB.enterpriseInterface.*;
import com.dxhy.api.model.config.UserInfo;
import com.dxhy.api.model.config.sys.SysEnterpriseConfigEntity;
import com.dxhy.api.model.config.sys.SysGroupConfigEntity;
import com.dxhy.api.model.db.SysLqZldwConfigEntity;
import com.dxhy.baseInterface.bigBTab.service.BigBEnterpriseService;
import com.dxhy.common.constant.ConfigureConstant;
import com.dxhy.common.constant.RedisConstant;
import com.dxhy.common.util.redis.RedisUtils;
import com.dxhy.common.utils.DateUtils;
import com.dxhy.jxpt.baseService.config.dao.SysEnterpriseConfigDao;
import com.dxhy.jxpt.baseService.config.dao.SysGroupConfigDao;
import com.dxhy.jxpt.baseService.config.dao.SysLqZldwConfigDao;
import com.dxhy.jxpt.baseService.config.service.SysEnterpriseConfigService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

/**
* @Description 对大B接口业务层-企业管理
* @Return
* @Author wangruwei
* @Date 2023/7/10 11:03
**/
@Service("bigBErpService")
@Slf4j
public class BigBEnterpriseServiceImpl implements BigBEnterpriseService {

    @Autowired(required = false)
    private com.dxhy.baseInterface.bigBTab.dao.BigBTabDao bigBTabDao;

    @Autowired
    private SysEnterpriseConfigService sysEnterpriseConfigService;
    @Autowired
    private SysGroupConfigDao sysGroupConfigDao;
    @Resource
    private SysEnterpriseConfigDao sysEnterpriseConfigDao;
    @Resource
    private SysLqZldwConfigDao sysLqZldwConfigDao;

    @Resource
    private RedisUtils redisUtils;

    /**
     * @Description 企业信息—RPA企业使用-企业信息变化(增删改)-大企业
     * @param enterpriseChangeReq
     * @Return java.lang.Object
     * @Author wangruwei
     * @Date 2023/7/10 11:16
     **/
    @Override
    public EnterpriseChangeResp enterpriseDqyChange(EnterpriseDqyChangeReq enterpriseChangeReq) {
        EnterpriseChangeResp result = new EnterpriseChangeResp();
        UserInfo userInfo = new UserInfo();
        userInfo.setUsername("系统推送");
        userInfo.setId("1");
        try {
            String id = enterpriseChangeReq.getId();
            String nsrsbh = enterpriseChangeReq.getNsrsbh();
            String type = enterpriseChangeReq.getType();
            String company = getJxCompany();

            //统一处理sysEnterpriseConfig验证逻辑
            log.info("统一验证sysEnterpriseConfig逻辑，得出操作是:新增1，修改2@1(税号维度修改)，修改2@2(sydwqyid维度修改)，删除3");
            String resultType = dealEnterpriseBusiness(id, nsrsbh, type);
            log.info("操作是{}",resultType);

            SysEnterpriseConfigEntity enterpriseReq = new SysEnterpriseConfigEntity();
            if("1".equals(resultType)){
                //新增
                enterpriseReq = buildDqyInsertEnterpriseEntity(enterpriseChangeReq);
            }else if("2@1".equals(resultType)||"2@2".equals(resultType)){
                SysEnterpriseConfigEntity dbEnterprise = new SysEnterpriseConfigEntity();
                if("2@1".equals(resultType)){
                    dbEnterprise = sysEnterpriseConfigDao.selectOne(new LambdaQueryWrapper<SysEnterpriseConfigEntity>().select(SysEnterpriseConfigEntity::getId)
                            .eq(SysEnterpriseConfigEntity::getCompany, company)
                            .eq(SysEnterpriseConfigEntity::getNsrsbh, nsrsbh));
                }else{
                    dbEnterprise = sysEnterpriseConfigDao.selectOne(new LambdaQueryWrapper<SysEnterpriseConfigEntity>().select(SysEnterpriseConfigEntity::getId)
                            .eq(SysEnterpriseConfigEntity::getCompany, company)
                            .eq(SysEnterpriseConfigEntity::getSydwqyid, id));
                }
                enterpriseReq.setId(dbEnterprise.getId());
                enterpriseReq.setJrfs("0");
                enterpriseReq.setNsrsbh(nsrsbh);
                enterpriseReq.setNsrmc(enterpriseChangeReq.getNsrmc());
                enterpriseReq.setSydwqyid(id);
                enterpriseReq.setUpdateTime(enterpriseChangeReq.getGxsj());
                sysEnterpriseConfigDao.update(null, new LambdaUpdateWrapper<SysEnterpriseConfigEntity>()
                        .set(SysEnterpriseConfigEntity::getNsrsbh, nsrsbh)
                        .eq(SysEnterpriseConfigEntity::getSydwqyid, id)
                );
                log.info("更新的内容：{}", JSON.toJSONString(enterpriseReq));
            }else if("3".equals(resultType)){
                log.info("删除成功");
            }else{
                log.error("没有此返回结果:{}",resultType);
            }

            if(!"3".equals(resultType)){
                log.info("调统一修改企业接口");
                enterpriseReq.setCompany(company);
                String msg = sysEnterpriseConfigService.updateEnterpriseInfo(enterpriseReq, userInfo);
                if(StringUtils.isNotEmpty(msg)){
                    result.setCode("1001");
                    result.setMessage(msg);
                    return result;
                }else{
                    //成功
                }
            }
            result.setCode("0000");
            result.setMessage("处理成功");
        } catch (Exception e) {
            log.error("处理失败:{}",e);
            result.setCode("9999");
            result.setMessage("处理失败");
        }
        return result;
    }

    /**
    * @Description 获取进项的company，取groupconfig里的第一条
    * @param
    * @Return java.lang.String
    * @Author wangruwei
    * @Date 2024/12/5 16:09
    **/
    private String getJxCompany() {
        List<SysGroupConfigEntity> sysGroupConfigEntities = sysGroupConfigDao.selectList(new LambdaQueryWrapper<SysGroupConfigEntity>().select(SysGroupConfigEntity::getCompany));
        if(sysGroupConfigEntities.size()>0){
            return sysGroupConfigEntities.get(0).getCompany();
        }else{
            return ConfigureConstant.ZXQY;
        }
    }

    /**
    * @Description 统一处理sysEnterpriseConfig表验证逻辑
    * @param id     大B同步业务数据唯一标识
    * @param nsrsbh 税号
    * @param type   操作类型  1 增加 2修改 3删除
    * @Return String   1增加  2修改  3删除
    * @Author wangruwei
    * @Date 2024/12/5 10:40
    **/
    private String dealEnterpriseBusiness(String id, String nsrsbh, String type) {
        String company = getJxCompany();
        if("3".equals(type)){
            log.info("删除企业信息");
            int delete = sysEnterpriseConfigDao.delete(new LambdaQueryWrapper<SysEnterpriseConfigEntity>()
                    .eq(SysEnterpriseConfigEntity::getCompany, company)
                    .eq(SysEnterpriseConfigEntity::getNsrsbh, nsrsbh));
            log.info("删除成功，删除{}条",delete);
            return "3";
        }else{
            log.info("增加或删除。根据传来的id和nsrsbh判断操作，优先id");
            SysEnterpriseConfigEntity dbEnterprise = sysEnterpriseConfigDao.selectOne(new LambdaQueryWrapper<SysEnterpriseConfigEntity>()
                    .eq(SysEnterpriseConfigEntity::getCompany, company)
                    .eq(SysEnterpriseConfigEntity::getSydwqyid, id));
            //调企业增加修改接口返回内容
            if(ObjectUtils.isEmpty(dbEnterprise)){
                log.info("大b的id查到的数据为空，用税号去查");
                dbEnterprise = sysEnterpriseConfigDao.selectOne(new LambdaQueryWrapper<SysEnterpriseConfigEntity>()
                        .eq(SysEnterpriseConfigEntity::getCompany, company)
                        .eq(SysEnterpriseConfigEntity::getNsrsbh, nsrsbh));

                if(ObjectUtils.isEmpty(dbEnterprise)){
                    log.info("大b的id和税号均未找到数据，执行插入操作");
                    return "1";
                }else{
                    log.info("大b的id未找到，税号找到数据，更新");
                    return "2@1";
                }
            }else{
                log.info("通过大b的id找到数据，更新");
                return "2@2";
            }
        }
    }

    /**
     * @Description 直连单位-乐企（增删改）
     * @param enterpriseLqZlChangeReq
     * @Return java.lang.Object
     * @Author wangruwei
     * @Date 2023/7/10 11:16
     **/
    @Override
    public EnterpriseChangeResp enterpriseLqZlChange(EnterpriseLqZlChangeReq enterpriseLqZlChangeReq) {
        EnterpriseChangeResp result = new EnterpriseChangeResp();
        UserInfo userInfo = new UserInfo();
        userInfo.setUsername("系统推送");
        userInfo.setId("1");
        try {
            //大B传来的id
            String id = enterpriseLqZlChangeReq.getId();
            String nsrsbh = enterpriseLqZlChangeReq.getTaxpayerCode();
            //操作类型
            String type = enterpriseLqZlChangeReq.getType();
            String company = getJxCompany();
            log.info("统一验证sysEnterpriseConfig逻辑，得出操作是:新增1，修改2@1(税号维度修改)，修改2@2(sydwqyid维度修改)，删除3");
            String resultType = dealEnterpriseBusiness(id, nsrsbh, type);
            log.info("操作是{}",resultType);

            log.info("处理sys_lq_zldw_config表业务逻辑。根据传来的id和nsrsbh判断操作，优先id");
            dealZldwConfig(enterpriseLqZlChangeReq);

            SysEnterpriseConfigEntity enterpriseReq = new SysEnterpriseConfigEntity();
            if("1".equals(resultType)){
                //新增
                enterpriseReq = buildLqZlInsertEnterpriseEntity(enterpriseLqZlChangeReq);
            }else if("2@1".equals(resultType)||"2@2".equals(resultType)){
                SysEnterpriseConfigEntity dbEnterprise = new SysEnterpriseConfigEntity();
                if("2@1".equals(resultType)){
                    dbEnterprise = sysEnterpriseConfigDao.selectOne(new LambdaQueryWrapper<SysEnterpriseConfigEntity>().select(SysEnterpriseConfigEntity::getId)
                            .eq(SysEnterpriseConfigEntity::getCompany, company)
                            .eq(SysEnterpriseConfigEntity::getNsrsbh, nsrsbh));
                }else{
                    dbEnterprise = sysEnterpriseConfigDao.selectOne(new LambdaQueryWrapper<SysEnterpriseConfigEntity>().select(SysEnterpriseConfigEntity::getId)
                            .eq(SysEnterpriseConfigEntity::getCompany, company)
                            .eq(SysEnterpriseConfigEntity::getSydwqyid, id));
                }
                enterpriseReq.setId(dbEnterprise.getId());
                enterpriseReq.setJrfs("1");
                enterpriseReq.setNsrsbh(nsrsbh);
                enterpriseReq.setNsrmc(enterpriseLqZlChangeReq.getCompanyName());
                enterpriseReq.setSydwqyid(id);
                enterpriseReq.setZldwqyid(id);
                enterpriseReq.setSydwptbm(enterpriseLqZlChangeReq.getLqId());
                enterpriseReq.setUpdateTime(enterpriseLqZlChangeReq.getUpdateTime());
                log.info("更新的内容：{}", JSON.toJSONString(enterpriseReq));
                //先行修改企业税号，后续逻辑正常执行
                sysEnterpriseConfigDao.update(null, new LambdaUpdateWrapper<SysEnterpriseConfigEntity>()
                        .set(SysEnterpriseConfigEntity::getNsrsbh, nsrsbh)
                        .eq(SysEnterpriseConfigEntity::getSydwqyid, id)
                );
                log.info("刷新使用平台编码  对应 直连单位信息 redis缓存");
                sysEnterpriseConfigService.refreshSyptbmZldw(enterpriseLqZlChangeReq.getLqId(),id);
            }else if("3".equals(resultType)){
                sysEnterpriseConfigDao.update(null, new LambdaUpdateWrapper<SysEnterpriseConfigEntity>()
                        .set(SysEnterpriseConfigEntity::getZldwqyid, "")
                        .eq(SysEnterpriseConfigEntity::getZldwqyid, id)
                );
                sysLqZldwConfigDao.delete(new LambdaQueryWrapper<SysLqZldwConfigEntity>().eq(SysLqZldwConfigEntity::getZldwqyid, id));
                log.info("删除zldw成功，更新对应使用单位的zldwqyid为空，清空syptbm对应企业的redis为空");
                redisUtils.delete(RedisConstant.LQ_SYDWPTBH+enterpriseLqZlChangeReq.getLqId());
            }else{
                log.error("没有此返回结果:{}",resultType);
            }

            if(!"3".equals(resultType)){
                log.info("调统一修改企业接口");
                enterpriseReq.setCompany(company);
                enterpriseReq.setNcpgnqyrq(DateUtils.getMonthByMonth(-6));
                String msg = sysEnterpriseConfigService.updateEnterpriseInfo(enterpriseReq, userInfo);
                if(StringUtils.isNotEmpty(msg)){
                    result.setCode("1001");
                    result.setMessage(msg);
                    return result;
                }else{
                    //成功
                }
            }

            result.setCode("0000");
            result.setMessage("处理成功");
        } catch (Exception e) {
            log.error("处理失败:{}",e);
            result.setCode("9999");
            result.setMessage("处理失败");
        }
        return result;
    }

    /**
     * @Description 使用单位-乐企（增删改）
     * @param enterpriseLqSyChangeReq
     * @Return java.lang.Object
     * @Author wangruwei
     * @Date 2023/7/10 11:16
     **/
    @Override
    public EnterpriseChangeResp enterpriseLqSyChange(EnterpriseLqSyChangeReq enterpriseLqSyChangeReq) {
        EnterpriseChangeResp result = new EnterpriseChangeResp();
        UserInfo userInfo = new UserInfo();
        userInfo.setUsername("系统推送");
        userInfo.setId("1");
        try {
            String id = enterpriseLqSyChangeReq.getId();
            String nsrsbh = enterpriseLqSyChangeReq.getTaxpayerCode();
            String type = enterpriseLqSyChangeReq.getType();
            String company = getJxCompany();
            //统一处理sysEnterpriseConfig验证逻辑
            log.info("统一验证sysEnterpriseConfig逻辑，得出操作是:新增1，修改2@1(税号维度修改)，修改2@2(sydwqyid维度修改)，删除3");
            String resultType = dealEnterpriseBusiness(id, nsrsbh, type);
            log.info("操作是{}",resultType);

            SysEnterpriseConfigEntity enterpriseReq = new SysEnterpriseConfigEntity();

            if("1".equals(resultType)){
                //新增
                enterpriseReq = buildLqSyInsertEnterpriseEntity(enterpriseLqSyChangeReq);
            }else if("2@1".equals(resultType)||"2@2".equals(resultType)){
                SysEnterpriseConfigEntity dbEnterprise = new SysEnterpriseConfigEntity();
                if("2@1".equals(resultType)){
                    dbEnterprise = sysEnterpriseConfigDao.selectOne(new LambdaQueryWrapper<SysEnterpriseConfigEntity>().select(SysEnterpriseConfigEntity::getId)
                            .eq(SysEnterpriseConfigEntity::getCompany, company)
                            .eq(SysEnterpriseConfigEntity::getNsrsbh, nsrsbh));
                }else{
                    dbEnterprise = sysEnterpriseConfigDao.selectOne(new LambdaQueryWrapper<SysEnterpriseConfigEntity>().select(SysEnterpriseConfigEntity::getId)
                            .eq(SysEnterpriseConfigEntity::getCompany, company)
                            .eq(SysEnterpriseConfigEntity::getSydwqyid, id));
                }
                enterpriseReq.setId(dbEnterprise.getId());
                enterpriseReq.setJrfs("1");
                enterpriseReq.setNsrsbh(nsrsbh);
                enterpriseReq.setNsrmc(enterpriseLqSyChangeReq.getCompanyName());
                enterpriseReq.setSydwqyid(id);
                enterpriseReq.setZldwqyid(enterpriseLqSyChangeReq.getParentId());
                enterpriseReq.setSydwptbm(enterpriseLqSyChangeReq.getLqId());
                enterpriseReq.setUpdateTime(enterpriseLqSyChangeReq.getUpdateTime());
                sysEnterpriseConfigDao.update(null, new LambdaUpdateWrapper<SysEnterpriseConfigEntity>()
                        .set(SysEnterpriseConfigEntity::getNsrsbh, nsrsbh)
                        .eq(SysEnterpriseConfigEntity::getSydwqyid, id)
                );

                log.info("更新的内容：{}", JSON.toJSONString(enterpriseReq));
                log.info("刷新使用平台编码  对应 直连单位信息 redis缓存");
                sysEnterpriseConfigService.refreshSyptbmZldw(enterpriseLqSyChangeReq.getLqId(), enterpriseLqSyChangeReq.getParentId());
            }else if("3".equals(resultType)){
                log.info("删除成功,同时删除对应syptbh缓存");
                redisUtils.delete(RedisConstant.LQ_SYDWPTBH+enterpriseLqSyChangeReq.getLqId());
            }else{
                log.error("没有此返回结果:{}",resultType);
            }

            if(!"3".equals(resultType)){
                log.info("调统一修改企业接口");
                enterpriseReq.setCompany(company);
                enterpriseReq.setNcpgnqyrq(DateUtils.getMonthByMonth(-6));
                String msg = sysEnterpriseConfigService.updateEnterpriseInfo(enterpriseReq, userInfo);
                if(StringUtils.isNotEmpty(msg)){
                    result.setCode("1001");
                    result.setMessage(msg);
                    return result;
                }else{
                    //成功
                }
            }
            result.setCode("0000");
            result.setMessage("处理成功");
        } catch (Exception e) {
            log.error("处理失败:{}",e);
            result.setCode("9999");
            result.setMessage("处理失败");
        }
        return result;
    }

    /**
    * @Description 构建乐企入库企业实体
    * @param enterpriseLqSyChangeReq
    * @Return com.dxhy.api.model.config.sys.SysEnterpriseConfigEntity
    * @Author wangruwei
    * @Date 2024/12/5 15:35
    **/
    private SysEnterpriseConfigEntity buildLqSyInsertEnterpriseEntity(EnterpriseLqSyChangeReq enterpriseLqSyChangeReq) {
        SysEnterpriseConfigEntity insertEnter = new SysEnterpriseConfigEntity();
        insertEnter.setNsrsbh(enterpriseLqSyChangeReq.getTaxpayerCode());
        insertEnter.setNsrmc(enterpriseLqSyChangeReq.getCompanyName());
        insertEnter.setJrfs("1");
        insertEnter.setSfcy("1");
        insertEnter.setSfcj("1");
        insertEnter.setSydwptbm(enterpriseLqSyChangeReq.getLqId());
        insertEnter.setPassword(null);
        insertEnter.setIsDown(null);
        insertEnter.setCheckFlag("0");
        insertEnter.setCzrMc("系统自动");
        insertEnter.setCzrId(null);
        insertEnter.setSfqyncpdk("1");
        insertEnter.setSfqyncpjjkc("1");
        insertEnter.setNcpgnqyrq(DateUtils.getNowMonthStr());
        insertEnter.setLqncpywbgsj(null);
        insertEnter.setLqncpjjkcqysj(null);
        insertEnter.setTspzxz("CKZNXFP,CKZNXJKS,ZZSDKDJWSPZ");
        insertEnter.setCreateTime(new Date());
        insertEnter.setUpdateTime(null);
        insertEnter.setSydwqyid(enterpriseLqSyChangeReq.getId());
        insertEnter.setZldwqyid(enterpriseLqSyChangeReq.getParentId());
        return insertEnter;
    }

    /**
    * @Description 处理直连单位表逻辑
    * @param
    * @param enterpriseLqZlChangeReq
     * @Return void
    * @Author wangruwei
    * @Date 2024/12/5 14:43
    **/
    private void dealZldwConfig(EnterpriseLqZlChangeReq enterpriseLqZlChangeReq) {
        String id = enterpriseLqZlChangeReq.getId();
        String nsrsbh = enterpriseLqZlChangeReq.getTaxpayerCode();
        SysLqZldwConfigEntity dbZldw = sysLqZldwConfigDao.selectOne(new LambdaQueryWrapper<SysLqZldwConfigEntity>().eq(SysLqZldwConfigEntity::getZldwqyid, id));
        if(ObjectUtils.isEmpty(dbZldw)){
            log.info("大b的id查到的数据为空，用税号去查");
            dbZldw = sysLqZldwConfigDao.selectOne(new LambdaQueryWrapper<SysLqZldwConfigEntity>().eq(SysLqZldwConfigEntity::getNsrsbh, nsrsbh));

            if(ObjectUtils.isEmpty(dbZldw)){
                log.info("大b的id和税号均未找到数据，执行插入操作");
                SysLqZldwConfigEntity insertZldw = buildLqZldwEntity(enterpriseLqZlChangeReq);

                sysLqZldwConfigDao.insert(insertZldw);
            }else{
                log.info("大b的id未找到，税号找到数据，更新");
                SysLqZldwConfigEntity updateZldw = buildLqZldwEntity(enterpriseLqZlChangeReq);
                updateZldw.setId(dbZldw.getId());

                sysLqZldwConfigDao.updateById(updateZldw);
            }
        }else{
            log.info("通过大b的id找到数据，更新");
            SysLqZldwConfigEntity updateZldw = buildLqZldwEntity(enterpriseLqZlChangeReq);
            updateZldw.setId(dbZldw.getId());
            sysLqZldwConfigDao.updateById(updateZldw);
        }
    }

    /**
    * @Description 创建直连单位实体数据
    * @param
    * @param enterpriseLqZlChangeReq
     * @Return void
    * @Author wangruwei
    * @Date 2024/12/5 14:41
    **/
    private SysLqZldwConfigEntity buildLqZldwEntity(EnterpriseLqZlChangeReq enterpriseLqZlChangeReq) {
        SysLqZldwConfigEntity lqZldw = new SysLqZldwConfigEntity();
        //大B传来的id
        String id = enterpriseLqZlChangeReq.getId();
        String nsrsbh = enterpriseLqZlChangeReq.getTaxpayerCode();
        lqZldw.setZldwqyid(id);
        lqZldw.setNsrsbh(nsrsbh);
        lqZldw.setNsrmc(enterpriseLqZlChangeReq.getCompanyName());
        lqZldw.setJrdwptbm(enterpriseLqZlChangeReq.getLqId());
        lqZldw.setLqKey(enterpriseLqZlChangeReq.getApiKey());
        lqZldw.setLinkType(enterpriseLqZlChangeReq.getLinkType());
        lqZldw.setApiUrl(enterpriseLqZlChangeReq.getApiUrl());
        lqZldw.setCzrId(enterpriseLqZlChangeReq.getCreateUser());
        lqZldw.setUpdateTime(enterpriseLqZlChangeReq.getUpdateTime());
        lqZldw.setCreateTime(enterpriseLqZlChangeReq.getCreateTime());
        //lqZldw.setUpdateTime(StringUtils.isNotBlank(enterpriseLqZlChangeReq.getUpdateTime())?DateUtils.strToDate(enterpriseLqZlChangeReq.getUpdateTime()):null );
        //lqZldw.setCreateTime(StringUtils.isNotBlank(enterpriseLqZlChangeReq.getCreateTime())?DateUtils.strToDate(enterpriseLqZlChangeReq.getCreateTime()):null );
        return lqZldw;
    }

    /**
    * @Description 构建乐企enterprise表入库参数
    * @param enterpriseLqZlChangeReq
    * @Return com.dxhy.api.model.config.sys.SysEnterpriseConfigEntity
    * @Author wangruwei
    * @Date 2024/12/5 11:04
    **/
    private SysEnterpriseConfigEntity buildLqZlInsertEnterpriseEntity(EnterpriseLqZlChangeReq enterpriseLqZlChangeReq) {
        SysEnterpriseConfigEntity insertEnter = new SysEnterpriseConfigEntity();
        insertEnter.setNsrsbh(enterpriseLqZlChangeReq.getTaxpayerCode());
        insertEnter.setNsrmc(enterpriseLqZlChangeReq.getCompanyName());
        insertEnter.setJrfs("1");
        insertEnter.setSfcy("1");
        insertEnter.setSfcj("1");
        insertEnter.setSydwptbm(enterpriseLqZlChangeReq.getLqId());
        insertEnter.setPassword(null);
        insertEnter.setIsDown(null);
        insertEnter.setCheckFlag("0");
        insertEnter.setCzrMc("系统自动");
        insertEnter.setCzrId(null);
        insertEnter.setSfqyncpdk("1");
        insertEnter.setSfqyncpjjkc("1");
        insertEnter.setNcpgnqyrq(DateUtils.getNowMonthStr());
        insertEnter.setLqncpywbgsj(null);
        insertEnter.setLqncpjjkcqysj(null);
        insertEnter.setTspzxz("CKZNXFP,CKZNXJKS,ZZSDKDJWSPZ");
        insertEnter.setCreateTime(new Date());
        insertEnter.setUpdateTime(null);
        insertEnter.setSydwqyid(enterpriseLqZlChangeReq.getId());
        insertEnter.setZldwqyid(enterpriseLqZlChangeReq.getId());
        return insertEnter;
    }

    /**
    * @Description 构建大企业入库参数
    * @param
    * @param enterpriseChangeReq
     * @Return com.dxhy.api.model.config.sys.SysEnterpriseConfigEntity
    * @Author wangruwei
    * @Date 2024/12/4 17:08
    **/
    private SysEnterpriseConfigEntity buildDqyInsertEnterpriseEntity(EnterpriseDqyChangeReq enterpriseChangeReq) {
        SysEnterpriseConfigEntity insertEnter = new SysEnterpriseConfigEntity();
        insertEnter.setNsrsbh(enterpriseChangeReq.getNsrsbh());
        insertEnter.setNsrmc(enterpriseChangeReq.getNsrmc());
        insertEnter.setJrfs("0");
        insertEnter.setSfcy("1");
        insertEnter.setSfcj("1");
        insertEnter.setSydwptbm("");
        insertEnter.setPassword(null);
        insertEnter.setIsDown(null);
        insertEnter.setCheckFlag("0");
        insertEnter.setCzrMc("系统自动");
        insertEnter.setCzrId(null);
        insertEnter.setSfqyncpdk("");
        insertEnter.setSfqyncpjjkc("");
        insertEnter.setNcpgnqyrq("");
        insertEnter.setLqncpywbgsj(null);
        insertEnter.setLqncpjjkcqysj(null);
        insertEnter.setTspzxz("");
        insertEnter.setCreateTime(new Date());
        insertEnter.setUpdateTime(null);
        insertEnter.setSydwqyid(enterpriseChangeReq.getId());
        insertEnter.setZldwqyid(null);
        return insertEnter;
    }


}
