package com.brilliance.isc.common.api.img.service.impl;

import com.brilliance.isc.bo.Imglot;
import com.brilliance.isc.bo.Remark;
import com.brilliance.isc.bo.Smh;
import com.brilliance.isc.common.api.img.service.ImgService;
import com.brilliance.isc.common.codetable.service.CodetableService;
import com.brilliance.isc.common.context.SettleContext;
import com.brilliance.isc.common.counter.service.CounterService;
import com.brilliance.isc.common.exception.CommonServiceException;
import com.brilliance.isc.exception.RestBizException;
import com.brilliance.isc.mda.dao.ImglotMapper;
import com.brilliance.isc.mda.dao.RemarkMapper;
import com.brilliance.isc.mda.dao.SmhMapper;
import com.brilliance.isc.vo.manager.ImglotVo;
import com.brilliance.isc.vo.manager.RemarkVo;
import com.brilliance.isc.vo.manager.SessionUserVo;
import com.github.pagehelper.PageHelper;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.sql.Timestamp;
import java.util.*;
import java.util.stream.Collectors;

@Service
public class ImgServiceImpl implements ImgService {

    private final Logger logger = LoggerFactory.getLogger(ImgServiceImpl.class);
    @Resource
    private CounterService counterService;
    @Resource
    private ImglotMapper imglotMapper;
    @Resource
    private RemarkMapper remarkMapper;
    @Resource
    private CodetableService codetableService;
    @Resource
    private SmhMapper smhMapper;

    private static final String IMGLOT_TAB_NAME = "IMGLOT";
    private static final String IMGUSE_TAB_NAME = "IMGUSE";
    private static final String INVUSE_TAB_NAME = "INVUSE";
    private static final String REMARK_TAB_NAME = "remark";
    private static final String IMGINR_TAB_NAME = "imginr";
    private static final String LOT_NUM_KEY = "lotNum";
    private static final String IMG_INR_KEY = "imgInr";
    private static final String ATH_LEV_KEY = "athlev";
    private static final String BIND_STA_CODE = "Y";
    private static final String UNBIND_STA_CODE = "N";
    // 0-绑定影像,1-解绑影像,2-新增影像,3-修改影像,4-删除影像,5-分行授权,6-总行授权,7-总行退回
    private static final String BIND_OP_CODE = "0";
    private static final String UNBIND_OP_CODE = "1";
    private static final String INSERT_OP_CODE = "2";
    private static final String UPDATE_OP_CODE = "3";
    private static final String DELETE_OP_CODE = "4";
    private static final String FEN_OP_CODE = "5";
    private static final String ZONG_OP_CODE = "6";
    private static final String BACK_OP_CODE = "7";
    // 业务认证等级,0-无授权,1-分行授权,2-总行授权
    private static final String NONE_AUTH_CODE = "0";
    private static final String FEN_AUTH_CODE = "1";
    private static final String ZONG_AUTH_CODE = "2";
    private static final String TBL_MSGSRC = "MSGSRC";
    private static final String LANG = "EN";
    // 渠道来源 0-国结 1-E结算 2-云平台
    private static final String MSG_SRC_0 = "0";
    private static final String MSG_SRC_1 = "1";
    private static final String MSG_SRC_2 = "2";

    @Override
    public Map<String, String> generateLotNum() {
        HashMap<String, String> result = new HashMap<>();
        String s = UUID.randomUUID().toString().replace("-", "").toLowerCase();
        result.put(LOT_NUM_KEY, s);
        return result;
    }

    @Override
    public Map<String, String> generateImgInr() {
        HashMap<String, String> result = new HashMap<>();
        String inr = counterService.dbCounterFormat(IMGINR_TAB_NAME);
        result.put(IMG_INR_KEY, inr);
        return result;
    }

    @Override
    @Transactional
    public int bindOrUnbind(ImglotVo record) {
        SessionUserVo sessionUserVo = SettleContext.getSessionUserVo();
        if (sessionUserVo == null) {
            sessionUserVo = new SessionUserVo();
            sessionUserVo.setLogName(record.getOpuser());
            sessionUserVo.setOwnOrgDepartmentNumber(record.getBranch());
            SettleContext.setSessionUserVo(sessionUserVo);
        }
        // 当前登录用户
        String opuser = record.getOpuser();
        // 当前登录用户的所属机构
        String ownOrgDepartmentNumber = sessionUserVo.getOwnOrgDepartmentNumber();
        // 业务参考号
        String ownref = record.getOwnref();
        if (StringUtils.isEmpty(ownref)) {
            logger.error("请求参数不合法：业务参考号为空！");
            return -2;
        }
        // 影像唯一标识
        String imginr = record.getImginr();
        if (StringUtils.isEmpty(imginr)) {
            logger.error("请求参数不合法：影像唯一标识为空！");
            return -3;
        }
        // 交易码
        String trncod = record.getTrncod();
        if (StringUtils.isEmpty(trncod)) {
            logger.error("请求参数不合法：交易码为空！");
            return -4;
        }
        // 影像批次32位ID
        String lotnum = record.getLotnum();
        if (StringUtils.isEmpty(lotnum)) {
            logger.error("请求参数不合法：影像批次号为空！");
            return -5;
        }
        // 操作类型
        String optype = record.getOptype();
        if (StringUtils.isEmpty(optype)) {
            logger.error("请求参数不合法：操作类型为空！");
            return -6;
        }
        Timestamp timestamp = new Timestamp(System.currentTimeMillis());

        Imglot reqImg = new Imglot();
        reqImg.setLotnum(record.getLotnum());
        Imglot imgRecord = imglotMapper.selectByLotNum(reqImg);

        if(StringUtils.isNotEmpty(record.getTrninr())) {
            imgRecord.setTrninr(record.getTrninr());
        }

        if (BIND_OP_CODE.equalsIgnoreCase(optype)) {
            // 绑定
            return bind(opuser, ownOrgDepartmentNumber, ownref, imginr, trncod, lotnum, timestamp, imgRecord);
        } else if (UNBIND_OP_CODE.equalsIgnoreCase(optype)) {
            // 解绑
            return unbind(opuser, lotnum, timestamp, imgRecord);
        } else {
            logger.error("请求参数不合法：操作类型应为[绑定]或[解绑]！");
            return -7;
        }
    }

    @Override
    @Transactional
    public int bindOrUnbindForInvsel(ImglotVo record) {
        SessionUserVo sessionUserVo = SettleContext.getSessionUserVo();
        if (sessionUserVo == null) {
            sessionUserVo = new SessionUserVo();
            sessionUserVo.setLogName(record.getOpuser());
            sessionUserVo.setOwnOrgDepartmentNumber(record.getBranch());
            SettleContext.setSessionUserVo(sessionUserVo);
        }
        // 当前登录用户
        String opuser = record.getOpuser();
        // 当前登录用户的所属机构
        String ownOrgDepartmentNumber = sessionUserVo.getOwnOrgDepartmentNumber();
        // 业务参考号
        String ownref = record.getOwnref();
        if (StringUtils.isEmpty(ownref)) {
            logger.error("请求参数不合法：业务参考号为空！");
            return -2;
        }
        // 影像唯一标识
        String imginr = record.getImginr();
        if (StringUtils.isEmpty(imginr)) {
            logger.error("请求参数不合法：影像唯一标识为空！");
            return -3;
        }
        // 交易码
        String trncod = record.getTrncod();
        if (StringUtils.isEmpty(trncod)) {
            logger.error("请求参数不合法：交易码为空！");
            return -4;
        }
        // 影像批次32位ID
        String lotnum = record.getLotnum();
        if (StringUtils.isEmpty(lotnum)) {
            logger.error("请求参数不合法：影像批次号为空！");
            return -5;
        }
        // 操作类型
        String optype = record.getOptype();
        if (StringUtils.isEmpty(optype)) {
            logger.error("请求参数不合法：操作类型为空！");
            return -6;
        }
        Timestamp timestamp = new Timestamp(System.currentTimeMillis());

        Imglot reqImg = new Imglot();
        reqImg.setLotnum(record.getLotnum());
        Imglot imgRecord = imglotMapper.selectByLotNum(reqImg);

        if(StringUtils.isNotEmpty(record.getTrninr())) {
            imgRecord.setTrninr(record.getTrninr());
        }

        if (BIND_OP_CODE.equalsIgnoreCase(optype)) {
            // 绑定
            return bind(opuser, ownOrgDepartmentNumber, ownref, imginr, trncod, lotnum, timestamp, imgRecord);
        } else if (UNBIND_OP_CODE.equalsIgnoreCase(optype)) {
            // 解绑
            return unbindForInvsel(opuser, lotnum, timestamp, imgRecord);
        } else {
            logger.error("请求参数不合法：操作类型应为[绑定]或[解绑]！");
            return -7;
        }
    }

    private int unbind(String logName, String lotnum, Timestamp timestamp, Imglot imgRecord) {
        // 解绑操作
        if (imgRecord == null) {
            // 影像不存在，返回信息告知影像不存在
            logger.error("影像批次不存在！");
            return -9;
        } else {
            // 进行解绑操作，同时删除对应的备注信息
            imgRecord.setOwnref(null);
            imgRecord.setTrncod(null);
            imgRecord.setImginr(null);
            imgRecord.setAthlev(null);
            imgRecord.setBndsta(UNBIND_STA_CODE);
            imgRecord.setOptype(UNBIND_OP_CODE);
            imgRecord.setOpuser(logName);
            imgRecord.setOptime(timestamp);
            imglotMapper.updateByPrimaryKey(imgRecord);
            Remark remark = new Remark();
            remark.setLotnum(lotnum);
            remarkMapper.deleteByLotNum(remark);
            logger.info("解绑成功！");
            return 3;
        }
    }

    private int unbindForInvsel(String logName, String lotnum, Timestamp timestamp, Imglot imgRecord) {
        // 解绑操作
        if (imgRecord == null) {
            // 影像不存在，返回信息告知影像不存在
            logger.error("影像批次不存在！");
            return -9;
        } else {
            // 进行解绑操作，同时删除对应的备注信息
            imgRecord.setOwnref(null);
            imgRecord.setTrncod(null);
            imgRecord.setImginr(null);
            imgRecord.setAthlev(null);
            imgRecord.setBndsta(UNBIND_STA_CODE);
            imgRecord.setOptype(UNBIND_OP_CODE);
            imgRecord.setOpuser(logName);
            imgRecord.setOptime(timestamp);
            imglotMapper.updateByPrimaryKey(imgRecord);
            Remark remark = new Remark();
            remark.setLotnum(lotnum);
            remarkMapper.deleteByLotNum(remark);
            logger.info("解绑成功！");
            return 3;
        }
    }


    private int bind(String logName, String ownOrgDepartmentNumber, String ownref, String imginr, String trncod, String lotnum, Timestamp timestamp, Imglot imgRecord) {
        if (imgRecord == null) {
            // 新增，并绑定
            Imglot imglot = new Imglot();
            String inr = counterService.dbCounterFormat(IMGLOT_TAB_NAME);
            imglot.setInr(inr);
            imglot.setLotnum(lotnum);
            imglot.setOwnref(ownref);
            imglot.setTrncod(trncod);
            imglot.setBranch(ownOrgDepartmentNumber);
            imglot.setImginr(imginr);
            imglot.setImgusr(logName);
            imglot.setImgtim(timestamp);
            imglot.setBndsta(BIND_STA_CODE);
            // 0-绑定影像,1-解绑影像,2-新增影像,3-修改影像,4-删除影像,5-分行授权,6-总行授权,7-总行退回
            imglot.setOptype(BIND_OP_CODE);
            imglot.setOpuser(logName);
            imglot.setOptime(timestamp);
            imglotMapper.insertSelective(imglot);
            logger.info("新增影像批次,并绑定成功！");
            return 2;
        } else {
            if (BIND_STA_CODE.equalsIgnoreCase(imgRecord.getBndsta())) {
                // 已绑定 返回信息告知已与其他业务绑定
                logger.warn("该影像批次已与其它业务绑定！");
                return -8;
            } else {
                // 未绑定 进行绑定处理
                imgRecord.setOwnref(ownref);
                imgRecord.setTrncod(trncod);
                imgRecord.setImginr(imginr);
                imgRecord.setBndsta(BIND_STA_CODE);
                imgRecord.setOptype(BIND_OP_CODE);
                imgRecord.setOpuser(logName);
                imgRecord.setOptime(timestamp);
                imglotMapper.updateByPrimaryKeySelective(imgRecord);
                logger.info("绑定成功！");
                return 1;
            }
        }
    }

    @Override
    public List<ImglotVo> listBindLotNum(ImglotVo record) {
        ArrayList<ImglotVo> result = new ArrayList<>();
        // 业务要求将E结算、云平台渠道来的影像展示在img列表中
        if (StringUtils.isNotEmpty(record.getMsginr())) {
            Imglot req = new Imglot();
            req.setBndsta(UNBIND_STA_CODE);
            List<Smh> smhs = smhMapper.selectByGrpinr(record.getMsginr());
            if (smhs != null && smhs.size() > 0) {
                for (Smh smh : smhs) {
                    if (smh != null) {
                        req.setMsginr(smh.getInr());
                        Imglot imglot = imglotMapper.selectByIncomingMsg(req);
                        ImglotVo vo = getVo(imglot);
                        if (vo != null) {
                            result.add(vo);
                            break;
                        }
                    }
                }
            } else {
                req.setMsginr(record.getMsginr());
                Imglot imglot = imglotMapper.selectByIncomingMsg(req);
                ImglotVo vo = getVo(imglot);
                if (vo != null) {
                    result.add(vo);
                }
            }
        }
        if (record.getTrninr() != null) {
            Imglot imglot1 = imglotMapper.selectByTrnInr(record);
            if (imglot1 != null) {
                ImglotVo vo = getVo(imglot1);
                result.add(vo);
            }
        }
        record.setBndsta(BIND_STA_CODE);
        List<Imglot> imglots = imglotMapper.listBindLotNum(record);
        for (Imglot imglot : imglots) {
            ImglotVo vo = getVo(imglot);
            if (vo != null) {
                result.add(vo);
            }
        }
        //自开自议寄单编号查询
        if (org.springframework.util.StringUtils.hasText(record.getOwnref())){
            List<Imglot> imglots1 = imglotMapper.listBindLotNumByRelatedref(record.getOwnref());
            for (Imglot imglot : imglots1) {
                ImglotVo vo = getVo(imglot);
                if (vo != null) {
                    result.add(vo);
                }
            }
        }
        //自开自议电证来报
        if (StringUtils.isNotEmpty(record.getRelatedref())){
            List<Imglot> imglots2 = imglotMapper.listBindLotNumByRelatedref(record.getRelatedref());
            for (Imglot imglot : imglots2) {
                ImglotVo vo = getVo(imglot);
                if (vo != null) {
                    result.add(vo);
                }
            }
        }
        HashSet<ImglotVo> imglotVos = new HashSet<ImglotVo>(result);
        ArrayList<ImglotVo> removeDuplicates = new ArrayList<>(imglotVos);
        return removeDuplicates;
    }

    @Override
    public List<ImglotVo> listAllBindByOwnref(ImglotVo record) {
        Imglot req = new Imglot();
        req.setOwnref(record.getOwnref());
        List<Imglot> imglots = imglotMapper.listAllBindByOwnref(req);
        // 排除掉本次业务的影像，剩余的就是历史影像
        List<Imglot> collect = imglots.stream().filter(item -> !record.getImginr().equalsIgnoreCase(item.getImginr())).collect(Collectors.toList());
        ArrayList<ImglotVo> result = new ArrayList<>();
        for (Imglot imglot : collect) {
            ImglotVo vo = getVo(imglot);
            if (vo != null) {
                result.add(vo);
            }
        }
        return result;
    }

    @Override
    public List<Imglot> listUnbindLotNum(ImglotVo record) {
        ImglotVo imglotVo = new ImglotVo();
        imglotVo.setBndsta(UNBIND_STA_CODE);
        if (StringUtils.isEmpty(record.getBranch())) {
            logger.error("请求参数机构号branch为空!");
            throw new CommonServiceException("请求参数机构号branch为空!");
        }
        imglotVo.setBranch(record.getBranch());
        imglotVo.setMsgsrc(MSG_SRC_0);
        if (record.getPageNum() == null) {
            record.setPageNum(0);
        }
        if (record.getPageSize() == null) {
            record.setPageSize(10);
        }
        PageHelper.startPage(record.getPageNum(), record.getPageSize());
        List<Imglot> imglots = imglotMapper.listFuzzyByRecord(imglotVo);
        return imglots;
    }

    @Override
    public int insert(ImglotVo record) {
        SessionUserVo sessionUserVo = SettleContext.getSessionUserVo();
        if (sessionUserVo == null) {
            sessionUserVo = new SessionUserVo();
            sessionUserVo.setLogName(record.getImgusr());
            sessionUserVo.setOwnOrgDepartmentNumber(record.getBranch());
            SettleContext.setSessionUserVo(sessionUserVo);
        }
        Imglot imglot = new Imglot();
        String inr = counterService.dbCounterFormat(IMGLOT_TAB_NAME);
        imglot.setInr(inr);
        imglot.setLotnum(record.getLotnum());
        imglot.setOwnref(null);
        imglot.setTrncod(null);
        if (StringUtils.isEmpty(record.getBranch())) {
            String branch = sessionUserVo.getOwnOrgDepartmentNumber();
            imglot.setBranch(branch);
        } else {
            imglot.setBranch(record.getBranch());
        }
        imglot.setImginr(null);
        imglot.setImgusr(record.getImgusr());
        Timestamp timestamp = new Timestamp(System.currentTimeMillis());
        imglot.setImgtim(timestamp);
        imglot.setAthlev(null);
        imglot.setBndsta(UNBIND_STA_CODE);
        imglot.setOptype(INSERT_OP_CODE);
        imglot.setOpuser(record.getImgusr());
        imglot.setOptime(timestamp);
        // 渠道来源 默认为 0-国结
        if (StringUtils.isEmpty(record.getMsgsrc())) {
            imglot.setMsgsrc(MSG_SRC_0);
            imglot.setMsginr(null);
        } else {
            imglot.setMsgsrc(record.getMsgsrc().toUpperCase());
            // 关联来报的唯一标识号
            imglot.setMsginr(record.getMsginr());
        }
        Imglot result = imglotMapper.selectByLotNum(imglot);
        if (result != null) {
            imglot.setInr(result.getInr());
            return imglotMapper.updateByPrimaryKeySelective(imglot);
        } else {
            return imglotMapper.insert(imglot);
        }
    }

    @Override
    public int updateByPrimaryKey(ImglotVo record) {
        Imglot imglot = new Imglot();
        imglot.setInr(record.getInr());
        Imglot result = imglotMapper.selectByPrimaryKey(imglot);
        if (result != null && BIND_STA_CODE.equalsIgnoreCase(result.getBndsta())) {
            logger.error("绑定状态的影像批次不允许修改！");
            throw new RestBizException("noAlert", "绑定状态的影像批次不允许修改！");
        }
        imglot.setLotnum(record.getLotnum());
        imglot.setOwnref(record.getOwnref());
        imglot.setTrncod(record.getTrncod());
        imglot.setImginr(record.getImginr());
        imglot.setAthlev(record.getAthlev());
        imglot.setBndsta(record.getBndsta());
        imglot.setOptype(UPDATE_OP_CODE);
        imglot.setOpuser(record.getOpuser());
        imglot.setOptime(new Timestamp(System.currentTimeMillis()));
        return imglotMapper.updateByPrimaryKeySelective(imglot);
    }

    @Override
    public int deleteByPrimaryKey(ImglotVo record) {
        Imglot imglot = new Imglot();
        imglot.setInr(record.getInr());
        imglot.setOptype(DELETE_OP_CODE);
        imglot.setOpuser(record.getOpuser());
        return imglotMapper.updateByPrimaryKeySelective(imglot);
    }

    @Override
    public ImglotVo selectByPrimaryKey(ImglotVo record) {
        Imglot imglot = new Imglot();
        imglot.setInr(record.getInr());
        Imglot result = imglotMapper.selectByPrimaryKey(imglot);
        if (result == null) {
            logger.warn("该批次信息不存在！");
            throw new RestBizException("noAlert", "该批次信息不存在！");
        }
        return getVo(result);
    }

    @Override
    public int insertRemark(RemarkVo record) {
        Remark remark = new Remark();
        String inr = counterService.dbCounterFormat(REMARK_TAB_NAME);
        remark.setInr(inr);
        remark.setLotnum(record.getLotnum());
        remark.setNote(record.getNote());
        remark.setExtkey(record.getExtkey());
        Timestamp timestamp = new Timestamp(System.currentTimeMillis());
        remark.setCretim(timestamp);
        remark.setUpdtim(timestamp);
        return remarkMapper.insert(remark);
    }

    @Override
    public int updateRemarkByPrimaryKey(RemarkVo record) {
        Remark remark = new Remark();
        remark.setInr(record.getInr());
        remark.setNote(record.getNote());
        remark.setExtkey(record.getExtkey());
        remark.setUpdtim(new Timestamp(System.currentTimeMillis()));
        return remarkMapper.updateByPrimaryKeySelective(remark);
    }

    @Override
    public int deleteRemarkByPrimaryKey(RemarkVo record) {
        Remark remark = new Remark();
        remark.setInr(record.getInr());
        return remarkMapper.deleteByPrimaryKey(remark);
    }

    @Override
    public RemarkVo selectRemarkByPrimaryKey(RemarkVo record) {
        Remark remark = new Remark();
        remark.setInr(record.getInr());
        Remark result = remarkMapper.selectByPrimaryKey(remark);
        if (result == null) {
            logger.warn("该批注信息不存在！");
            throw new RestBizException("noAlert", "该批注信息不存在！");
        }
        return getRemarkVo(result);
    }

    @Override
    public List<RemarkVo> listRemarkByLotNum(RemarkVo record) {
        Remark remark = new Remark();
        remark.setLotnum(record.getLotnum());
        List<Remark> remarks = remarkMapper.listByLotNum(remark);
        ArrayList<RemarkVo> remarkVos = new ArrayList<>();
        for (Remark item : remarks) {
            RemarkVo remarkVo = getRemarkVo(item);
            remarkVos.add(remarkVo);
        }
        return remarkVos;
    }

    @Override
    public Map<String, String> authorityHandler(ImglotVo record) {
        Imglot imglot = new Imglot();
        imglot.setInr(record.getInr());
        if (FEN_OP_CODE.equalsIgnoreCase(record.getOptype())) {
            imglot.setAthlev(FEN_AUTH_CODE);
        } else if (ZONG_OP_CODE.equalsIgnoreCase(record.getOptype())) {
            imglot.setAthlev(ZONG_AUTH_CODE);
        } else if (BACK_OP_CODE.equalsIgnoreCase(record.getOptype())) {
            imglot.setAthlev(NONE_AUTH_CODE);
        }
        imglot.setOptype(record.getOptype());
        imglot.setOpuser(record.getOpuser());
        imglot.setOptime(new Timestamp(System.currentTimeMillis()));
        imglotMapper.updateByPrimaryKeySelective(imglot);
        HashMap<String, String> result = new HashMap<>();
        result.put(ATH_LEV_KEY, imglot.getAthlev());
        return result;
    }


    @Override
    public ImglotVo getVo(Imglot bo) {
        if (bo == null) {
            logger.error("影像记录为空!");
            return null;
        }
        ImglotVo imglotVo = new ImglotVo();
        imglotVo.setInr(bo.getInr());
        imglotVo.setLotnum(bo.getLotnum());
        imglotVo.setOwnref(bo.getOwnref());
        imglotVo.setTrncod(bo.getTrncod());
        imglotVo.setBranch(bo.getBranch());
        imglotVo.setImginr(bo.getImginr());
        imglotVo.setImgusr(bo.getImgusr());
        imglotVo.setImgtim(bo.getImgtim());
        imglotVo.setAthlev(bo.getAthlev());
        imglotVo.setBndsta(bo.getBndsta());
        imglotVo.setOptype(bo.getOptype());
        imglotVo.setOpuser(bo.getOpuser());
        imglotVo.setOptime(bo.getOptime());
        imglotVo.setMsgsrc(bo.getMsgsrc());
        String label = codetableService.getTblLabel(bo.getMsgsrc(), TBL_MSGSRC, LANG);
        imglotVo.setMsgsrcname(label);
        imglotVo.setMsginr(bo.getMsginr());
        return imglotVo;
    }

    private RemarkVo getRemarkVo(Remark bo) {
        RemarkVo remarkVo = new RemarkVo();
        remarkVo.setInr(bo.getInr());
        remarkVo.setLotnum(bo.getLotnum());
        remarkVo.setNote(bo.getNote());
        remarkVo.setExtkey(bo.getExtkey());
        remarkVo.setCretim(bo.getCretim());
        remarkVo.setUpdtim(bo.getUpdtim());
        return remarkVo;
    }
}