k94314517
2025-05-15 6544203a132369d9d1db2531596f837fcc9fa39f
server/service/src/main/java/com/doumee/service/business/impl/SettleClaimsServiceImpl.java
@@ -1,7 +1,6 @@
package com.doumee.service.business.impl;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.extension.api.R;
import com.doumee.biz.system.SystemDictDataBiz;
import com.doumee.core.constants.ResponseStatus;
import com.doumee.core.exception.BusinessException;
@@ -14,6 +13,7 @@
import com.doumee.dao.business.SettleClaimsLogMapper;
import com.doumee.dao.business.SettleClaimsMapper;
import com.doumee.dao.business.dto.SCSupplementDTO;
import com.doumee.dao.business.dto.SettleClaimsDTO;
import com.doumee.dao.business.join.MultifileJoinMapper;
import com.doumee.dao.business.join.SettleClaimsJoinMapper;
import com.doumee.dao.business.join.SettleClaimsLogJoinMapper;
@@ -27,10 +27,12 @@
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.xiaoymin.knife4j.core.util.CollectionUtils;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import io.swagger.annotations.ApiModelProperty;
import org.apache.commons.compress.archivers.zip.ZipArchiveEntry;
import org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream;
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.SecurityUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -40,6 +42,7 @@
import java.io.FileInputStream;
import java.io.IOException;
import java.net.URLEncoder;
import java.nio.charset.Charset;
import java.util.*;
import java.util.stream.Collectors;
@@ -125,6 +128,11 @@
        Constants.NoticeObjectType noticeObjectType = Constants.NoticeObjectType.SETTLE_CLAIMS;
        //删除其他待办
        noticesMapper.delete(new QueryWrapper<Notices>().lambda().eq(Notices::getObjType,noticeObjectType.getKey()).eq(Notices::getObjId,model.getId()));
        Notices notices = new Notices(noticeObjectType,Constants.ONE,model.getId(),model.getInformantName(),
                model.getCompanyId(), Constants.NoticeType.FOUR);
        noticesMapper.insert(notices);
        Constants.SettleClaimsLogType applyLogType = Constants.SettleClaimsLogType.PLATFORM_RETURN;
        String info =applyLogType.getInfo();
@@ -440,6 +448,7 @@
            List<File> fileList = new ArrayList<>();
            List<Multifile> multifileList = multifileJoinMapper.selectList(new QueryWrapper<Multifile>().lambda()
                    .eq(Multifile::getIsdeleted,Constants.ZERO)
                    .eq(Multifile::getObjId,id)
                    .isNotNull(Multifile::getFileurl)
                    .in(Multifile::getObjType, Arrays.asList(new Integer[]{
@@ -449,28 +458,31 @@
                            Constants.MultiFile.LP_SCZL_FILE.getKey(),
                            Constants.MultiFile.LP_JACL_FILE.getKey(),
                    }))
                    .orderByAsc(Multifile::getCreateDate)
            );
            if(multifileList== null || multifileList.size() == 0){
                throw  new BusinessException(ResponseStatus.DATA_EMPTY);
            }
            String path = systemDictDataBiz.queryByCode(Constants.OSS,Constants.RESOURCE_PATH).getCode()+systemDictDataBiz.queryByCode(Constants.OSS,Constants.SETTLE_FILE).getCode();
            Integer sn = 1;
            for(Multifile l : multifileList){
                File f = Constants.getFileByNetFile(path + l.getFileurl(),StringUtils.defaultString(l.getName(),"未命名"));
                File f = Constants.getFileByNetFile(path + l.getFileurl(),StringUtils.defaultString(sn + "_" +l.getName(),"未命名"));
                if(f !=null && f.isFile()){
                    fileList.add(f);
                }
                sn = sn +1;
            }
            if(fileList == null || fileList.size() == 0){
                throw  new BusinessException(ResponseStatus.DATA_EMPTY);
            }
            String fileName =  model.getInformantName() +"理赔资料下_"+System.currentTimeMillis()+".zip" ;
            String encodeFileName = URLEncoder.encode(fileName);
            String fileName =  model.getInformantName() +"-理赔资料-" +System.currentTimeMillis();
            String encodeFileName =URLEncoder.encode(fileName, Charset.forName("UTF-8").toString())+".zip";
            response.setHeader("Content-Disposition","attachment;filename=" + encodeFileName);
            response.setContentType("application/octet-stream");
            response.setHeader("eva-opera-type", "download");
            response.setHeader("eva-download-filename", encodeFileName);
            Constants.packFilesToZip(fileList,response.getOutputStream());
        } catch (IOException e) {
        } catch (Exception e) {
            throw new BusinessException(ResponseStatus.EXPORT_EXCEL_ERROR, e);
        }
    }
@@ -795,6 +807,7 @@
                .leftJoin(InsuranceApply.class,InsuranceApply::getId,SettleClaims::getInsuranceApplyId)
                .leftJoin(Solutions.class,Solutions::getId,SettleClaims::getSolutionId);
        queryWrapper.eq(DispatchUnit::getIsdeleted,Constants.ZERO);
        queryWrapper.eq(SettleClaims::getIsdeleted,Constants.ZERO);
        if(Constants.equalsInteger(user.getType(),Constants.ZERO)){
            //只能看权限范围内
            if(user.getCompanyIdList() == null || user.getCompanyIdList().size() == 0){
@@ -930,4 +943,199 @@
        QueryWrapper<SettleClaims> wrapper = new QueryWrapper<>(settleClaims);
        return settleClaimsMapper.selectCount(wrapper);
    }
    public void saveSettleClaims(SettleClaimsDTO settleClaimsDTO){
        LoginUserInfo loginUserInfo = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal();
        if(!loginUserInfo.getType().equals(Constants.ONE)){
            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"非企业员工无法进行该操作");
        }
        if(Objects.isNull(settleClaimsDTO)
            || Objects.isNull(settleClaimsDTO.getSaveType())
            || Objects.isNull(settleClaimsDTO.getMemberId())
            ||StringUtils.isBlank(settleClaimsDTO.getIdcardNo())
        ){
            throw new BusinessException(ResponseStatus.BAD_REQUEST);
        }
        if(Constants.equalsInteger(settleClaimsDTO.getSaveType(),Constants.ONE)){
            if(Objects.isNull(settleClaimsDTO.getSolutionId())
                    ||Objects.isNull(settleClaimsDTO.getWorktypeId())
                    ||Objects.isNull(settleClaimsDTO.getDuId())
                    ||StringUtils.isBlank(settleClaimsDTO.getHappenTime())
                    ||StringUtils.isBlank(settleClaimsDTO.getContent())
                    ||Objects.isNull(settleClaimsDTO.getType())
                    ||Objects.isNull(settleClaimsDTO.getInHospital())
                    ||Objects.isNull(settleClaimsDTO.getHurtType())
                    ||Objects.isNull(settleClaimsDTO.getMedicalInsurance())
                    ||StringUtils.isBlank(settleClaimsDTO.getInformantName())
                    ||StringUtils.isBlank(settleClaimsDTO.getInformantPhone())
                    ||StringUtils.isBlank(settleClaimsDTO.getReceiveUserName())
                    ||StringUtils.isBlank(settleClaimsDTO.getReceiveBank())
                    ||StringUtils.isBlank(settleClaimsDTO.getReceiveAccount())
            ){
                throw new BusinessException(ResponseStatus.BAD_REQUEST);
            }
        }
        SettleClaims settleClaims = new SettleClaims();
        BeanUtils.copyProperties(settleClaimsDTO,settleClaims);
        if(Objects.nonNull(settleClaims.getId())){
            settleClaims.setEditDate(new Date());
            settleClaims.setEditor(loginUserInfo.getId());
            settleClaimsMapper.updateById(settleClaims);
        }else{
            settleClaims.setCreateDate(new Date());
            settleClaims.setIsdeleted(Constants.ZERO);
            settleClaims.setCompanyId(loginUserInfo.getCompanyId());
            settleClaims.setStatus(Constants.equalsInteger(settleClaimsDTO.getSaveType(),Constants.ONE)?
                    Constants.SettleClaimsStatus.RETURN_ACCEPTANCE.getKey():Constants.SettleClaimsStatus.WAIT_ACCEPTANCE.getKey());
            settleClaims.setCreator(loginUserInfo.getId());
            settleClaims.setCheckUserId(loginUserInfo.getId());
            settleClaimsMapper.insert(settleClaims);
        }
        this.saveFile(settleClaims,settleClaimsDTO,loginUserInfo);
    }
    public void saveFile(SettleClaims settleClaims,SettleClaimsDTO settleClaimsDTO,LoginUserInfo loginUserInfo){
        multifileJoinMapper.delete(new QueryWrapper<Multifile>().lambda()
                .eq(Multifile::getObjId,settleClaims.getId())
                .in(Multifile::getObjType,
                        Constants.MultiFile.LP_SGXC_FILE.getKey(),
                        Constants.MultiFile.LP_YGGX_FILE.getKey(),
                        Constants.MultiFile.LP_MZCL_FILE.getKey(),
                        Constants.MultiFile.LP_ZYCL_FILE.getKey(),
                        Constants.MultiFile.LP_OTHER_FILE.getKey(),
                        Constants.MultiFile.LP_SCZL_FILE.getKey()
                )
        );
        List<Multifile> reportVideo = settleClaimsDTO.getReportFileList();
        if(CollectionUtils.isNotEmpty(reportVideo)){
            for (int i = 0; i < reportVideo.size(); i++) {
                Multifile multifile = reportVideo.get(i);
                if(Objects.isNull(multifile.getFileurl())
                        || Objects.isNull(multifile.getType())
                        || StringUtils.isBlank(multifile.getName())
                ){
                    throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"附件内容异常");
                }
                multifile.setCreator(loginUserInfo.getId());
                multifile.setCreateDate(new Date());
                multifile.setIsdeleted(Constants.ZERO);
                multifile.setObjId(settleClaims.getId());
                multifile.setObjType(Constants.MultiFile.LP_SGXC_FILE.getKey());
                multifile.setSortnum(i+1);
                multifileJoinMapper.insert(multifile);
            }
        }
        List<Multifile> relationFileList = settleClaimsDTO.getRelationFileList();
        if(CollectionUtils.isNotEmpty(relationFileList)){
            for (int i = 0; i < reportVideo.size(); i++) {
                Multifile multifile = reportVideo.get(i);
                if(Objects.isNull(multifile.getFileurl())
                        || Objects.isNull(multifile.getType())
                        || StringUtils.isBlank(multifile.getName())
                ){
                    throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"附件内容异常");
                }
                multifile.setCreator(loginUserInfo.getId());
                multifile.setCreateDate(new Date());
                multifile.setIsdeleted(Constants.ZERO);
                multifile.setObjId(settleClaims.getId());
                multifile.setObjType(Constants.MultiFile.LP_YGGX_FILE.getKey());
                multifile.setSortnum(i+1);
                multifileJoinMapper.insert(multifile);
            }
        }
        List<Multifile> outpatientFileList = settleClaimsDTO.getOutpatientFileList();
        if(CollectionUtils.isNotEmpty(outpatientFileList)){
            for (int i = 0; i < reportVideo.size(); i++) {
                Multifile multifile = reportVideo.get(i);
                if(Objects.isNull(multifile.getFileurl())
                        || Objects.isNull(multifile.getType())
                        || StringUtils.isBlank(multifile.getName())
                ){
                    throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"附件内容异常");
                }
                multifile.setCreator(loginUserInfo.getId());
                multifile.setCreateDate(new Date());
                multifile.setIsdeleted(Constants.ZERO);
                multifile.setObjId(settleClaims.getId());
                multifile.setObjType(Constants.MultiFile.LP_MZCL_FILE.getKey());
                multifile.setSortnum(i+1);
                multifileJoinMapper.insert(multifile);
            }
        }
        List<Multifile> hospitalFileList = settleClaimsDTO.getHospitalFileList();
        if(CollectionUtils.isNotEmpty(hospitalFileList)){
            for (int i = 0; i < reportVideo.size(); i++) {
                Multifile multifile = reportVideo.get(i);
                if(Objects.isNull(multifile.getFileurl())
                        || Objects.isNull(multifile.getType())
                        || StringUtils.isBlank(multifile.getName())
                ){
                    throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"附件内容异常");
                }
                multifile.setCreator(loginUserInfo.getId());
                multifile.setCreateDate(new Date());
                multifile.setIsdeleted(Constants.ZERO);
                multifile.setObjId(settleClaims.getId());
                multifile.setObjType(Constants.MultiFile.LP_ZYCL_FILE.getKey());
                multifile.setSortnum(i+1);
                multifileJoinMapper.insert(multifile);
            }
        }
        List<Multifile> disabilityFileList = settleClaimsDTO.getDisabilityFileList();
        if(CollectionUtils.isNotEmpty(disabilityFileList)){
            for (int i = 0; i < reportVideo.size(); i++) {
                Multifile multifile = reportVideo.get(i);
                if(Objects.isNull(multifile.getFileurl())
                        || Objects.isNull(multifile.getType())
                        || StringUtils.isBlank(multifile.getName())
                ){
                    throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"附件内容异常");
                }
                multifile.setCreator(loginUserInfo.getId());
                multifile.setCreateDate(new Date());
                multifile.setIsdeleted(Constants.ZERO);
                multifile.setObjId(settleClaims.getId());
                multifile.setObjType(Constants.MultiFile.LP_SCZL_FILE.getKey());
                multifile.setSortnum(i+1);
                multifileJoinMapper.insert(multifile);
            }
        }
        List<Multifile> otherFileList = settleClaimsDTO.getOtherFileList();
        if(CollectionUtils.isNotEmpty(otherFileList)){
            for (int i = 0; i < reportVideo.size(); i++) {
                Multifile multifile = reportVideo.get(i);
                if(Objects.isNull(multifile.getFileurl())
                        || Objects.isNull(multifile.getType())
                        || StringUtils.isBlank(multifile.getName())
                ){
                    throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"附件内容异常");
                }
                multifile.setCreator(loginUserInfo.getId());
                multifile.setCreateDate(new Date());
                multifile.setIsdeleted(Constants.ZERO);
                multifile.setObjId(settleClaims.getId());
                multifile.setObjType(Constants.MultiFile.LP_OTHER_FILE.getKey());
                multifile.setSortnum(i+1);
                multifileJoinMapper.insert(multifile);
            }
        }
    }
}