All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.founder.core.service.impl.UdiDocCompServiceImpl Maven / Gradle / Ivy

There is a newer version: 3.6.1.9
Show newest version
package com.founder.core.service.impl;

import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.founder.core.base.BaseResult;
import com.founder.core.domain.GsUdiDoc;
import com.founder.core.domain.GsUdiDocComp;
import com.founder.core.domain.GsUdiDoclist;
import com.founder.core.exception.BizException;
import com.founder.core.log.MyLog;
import com.founder.core.mapper.GsPublicMapper;
import com.founder.core.mapper.GsUdiDocCompMapper;
import com.founder.core.service.UdiDocCompService;
import com.founder.core.service.UdiDocService;
import com.founder.core.service.UdiDoclistService;
import com.founder.core.service.UdiDoclistUseService;
import com.founder.core.valid.ValidList;
import com.founder.core.vopackage.*;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import java.util.List;

@Service
public class UdiDocCompServiceImpl extends ServiceImpl implements UdiDocCompService {

    private static final MyLog _log = MyLog.getLog(UdiDocCompServiceImpl.class);

    @Autowired
    UdiDoclistUseService udiDoclistUseService;

    @Autowired
    UdiDoclistService udiDoclistService;

    @Autowired
    UdiDocService udiDocService;

    @Autowired
    GsPublicMapper publicMapper;

    /**
     * 查询通用档案对照
     *
     * @param req
     * @return
     */
    @Override
    public VoBusinessResult listUdiDocComp(VoGs5101Req req) {
        VoBusinessResult result = new VoBusinessResult();
        _log.info("查询通用档案对照参数:" + JSON.toJSONString(req));
        String id_udi = req.getId_udi();
        String id_udidoclist = req.getId_udidoclist();
        String eu_status = req.getEu_status();
        QueryWrapper queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("id_udi",id_udi);
        queryWrapper.eq("id_udidoclist",id_udidoclist);
        if (StringUtils.isNotEmpty(eu_status)) {
            queryWrapper.eq("eu_status",eu_status);
        }
        List compList = this.list(queryWrapper);
        result.setCode(BaseResult.SUCCESS);
        result.setMsg("ok");
        result.setObject(compList);
        return result;
    }

    /**
     * 刷新通用档案对照表
     *
     * @param req
     * @return
     */
    @Override
    public VoBusinessResult listUdiDocCompRefresh(VoGs5102Req req) {
        VoBusinessResult result = new VoBusinessResult();
        _log.info("刷新通用档案对照表参数:" + JSON.toJSONString(req));
        String id_udi = req.getId_udi();
        String id_udidoclist = req.getId_udidoclist();
        GsUdiDoclist udiDoclist = udiDoclistService.getById(id_udidoclist);
        String fg_needrefresh = udiDoclist.getFg_needrefresh();
        if (StringUtils.isNotEmpty(fg_needrefresh) && "1".equals(fg_needrefresh)){

        }
        String code = udiDoclist.getComp_codecolumn();
        String name = udiDoclist.getComp_namecolumn();
        String table_name = udiDoclist.getComp_tablename();
        String where_str = udiDoclist.getComp_condition();
        String sqlStr = "select " + code + " code_his," + name + " name_his from " + table_name + " where " + where_str;
        _log.info("动态sql查询:" + sqlStr);
        List compList = publicMapper.getCompData(sqlStr);
        compList.stream().forEach(x->{
            x.setId_udi(id_udi);
            x.setId_udidoclist(id_udidoclist);
            x.setEu_status(BaseResult.FAIL);
            QueryWrapper queryWrapper = new QueryWrapper<>();
            queryWrapper.eq("id_udi",id_udi);
            queryWrapper.eq("id_udidoclist",id_udidoclist);
            queryWrapper.eq("code_his",x.getCode_his());
            List gsUdiDocCompList = this.list(queryWrapper);
            if (CollectionUtils.isEmpty(gsUdiDocCompList)) {
                x.setCode_udi("");
                x.setName_udi("");
                x.setId_udidoc("");
                this.save(x);
                _log.info("同步数据:" + JSON.toJSONString(x));
            }
        });
        result.setCode(BaseResult.SUCCESS);
        result.setMsg("ok");
        return result;
    }

    /**
     * 保存通用档案对照状态
     *
     * @param reqList
     * @return
     */
    @Override
    public VoBusinessResult listUdiDocCompUpdate(ValidList reqList) {
        VoBusinessResult result = new VoBusinessResult();
        reqList.stream().forEach(x->{
            String id_udidoc_comp = x.getId_udidoc_comp();
            String id_udidoc = x.getId_udidoc();
            GsUdiDoc gsUdiDoc = udiDocService.getById(id_udidoc);
            if (gsUdiDoc == null){
                throw new BizException("根据主键查询档案表失败:" + id_udidoc);
            }
            GsUdiDocComp gsUdiDocComp = this.getById(id_udidoc_comp);
            String eu_status = gsUdiDocComp.getEu_status();
            if ("1".equals(eu_status)){
                throw new BizException("已是对照状态:" + id_udidoc_comp);
            }
            gsUdiDocComp.setId_udidoc(id_udidoc);
            gsUdiDocComp.setCode_udi(gsUdiDoc.getCode());
            gsUdiDocComp.setName_udi(gsUdiDoc.getName());
            gsUdiDocComp.setEu_status("1");
            this.updateById(gsUdiDocComp);
        });
        result.setCode(BaseResult.SUCCESS);
        result.setMsg("ok");
        return result;
    }

    /**
     * 删除通用档案对照状态
     *
     * @param reqList
     * @return
     */
    @Override
    public VoBusinessResult listUdiDocCompDelete(ValidList reqList) {
        VoBusinessResult result = new VoBusinessResult();
        result.setMsg("ok");
        reqList.stream().forEach(x->{
            String id_udidoc_comp = x.getId_udidoc_comp();
            GsUdiDocComp gsUdiDocComp = this.getById(id_udidoc_comp);
            String eu_status = gsUdiDocComp.getEu_status();
            if (StringUtils.isEmpty(eu_status) || "0".equals(eu_status)){
                this.removeById(id_udidoc_comp);
                result.setMsg("删除成功");
            } else {
                gsUdiDocComp.setId_udidoc("");
                gsUdiDocComp.setCode_udi("");
                gsUdiDocComp.setName_udi("");
                gsUdiDocComp.setEu_status("0");
                this.updateById(gsUdiDocComp);
            }
        });
        result.setCode(BaseResult.SUCCESS);
        return result;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy