doum
2026-01-30 fad455d8943bd6af1501f7dca62f9530ed7d19cc
server/services/src/main/java/com/doumee/service/business/impl/ImportRecordServiceImpl.java
@@ -10,17 +10,11 @@
import com.doumee.core.model.PageWrap;
import com.doumee.core.utils.DateUtil;
import com.doumee.core.utils.tyyun.TyyZosUtil;
import com.doumee.dao.business.CasesMapper;
import com.doumee.dao.business.CategoryMapper;
import com.doumee.dao.business.MemberMapper;
import com.doumee.dao.business.*;
import com.doumee.dao.business.dto.CasesImport;
import com.doumee.dao.business.dto.MemberImport;
import com.doumee.dao.business.model.Cases;
import com.doumee.dao.business.model.Category;
import com.doumee.dao.business.model.ImportRecord;
import com.doumee.dao.business.model.*;
import com.doumee.core.utils.Utils;
import com.doumee.dao.business.ImportRecordMapper;
import com.doumee.dao.business.model.Member;
import com.doumee.dao.system.model.SystemUser;
import com.doumee.service.business.ImportRecordService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@@ -67,6 +61,8 @@
    private MemberMapper memberMapper;
    @Autowired
    private CasesMapper casesMapper;
    @Autowired
    private MultifileMapper multifileMapper;
    @Resource
    private RedisTemplate<String, Object> redisTemplate;
    @Resource
@@ -203,9 +199,7 @@
            Map<String, XSSFPictureData> pics = ie.getExcelPictures();
            if(type == 1) {
              List<CasesImport> importList =  (ie.getDataList(CasesImport.class,null));
              if(importList==null || importList.size()==0){
                  throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"导入文件案例信息内容为空!");
              }
              model.setCaseList(isvalidImpartCasesParam(loginUserInfo,pics,importList));
              model.setTotalNum(model.getCaseList().size());
            }else{
               List<MemberImport> importList = (ie.getDataList(MemberImport.class,null));
@@ -242,19 +236,21 @@
        int index = 1;
         for(MemberImport param :memberList){
             index ++;
             if(StringUtils.isBlank(param.getImgurl())
             ||StringUtils.isBlank(param.getFee())
             ||StringUtils.isBlank(param.getName())
             ||StringUtils.isBlank(param.getInfo())
             ||StringUtils.isBlank(param.getJobYear())
             ||StringUtils.isBlank(param.getPosition())
             ||StringUtils.isBlank(param.getFieldNames())
             ||StringUtils.isBlank(param.getSex())
             ||StringUtils.isBlank(param.getCode())
             ||StringUtils.isBlank(param.getZqNames())
             ||StringUtils.isBlank(param.getLevelName())
             ||StringUtils.isBlank(param.getServeNum())
             ||StringUtils.isBlank(param.getTypeNames())){
             if(( param.getImgurl() == null
                 ||param.getImgurl().getData() == null
                 ||param.getImgurl().getData().length == 0)
                     &&StringUtils.isBlank(param.getFee())
                     &&StringUtils.isBlank(param.getName())
                     &&StringUtils.isBlank(param.getInfo())
                     &&StringUtils.isBlank(param.getJobYear())
                     &&StringUtils.isBlank(param.getPosition())
                     &&StringUtils.isBlank(param.getFieldNames())
                     &&StringUtils.isBlank(param.getSex())
                     &&StringUtils.isBlank(param.getCode())
                     &&StringUtils.isBlank(param.getZqNames())
                     &&StringUtils.isBlank(param.getLevelName())
                     &&StringUtils.isBlank(param.getServeNum())
                     &&StringUtils.isBlank(param.getTypeNames())){
                 continue;
             }
             Member member = new Member();
@@ -295,7 +291,7 @@
             if(StringUtils.isBlank(param.getFee())){
                 throw  new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"对不起,第"+index+"行数据, 费用标准信息不能为空");
             }
             if(pics!=null && StringUtils.isNotBlank(param.getImgurl())){
          /*   if(pics!=null && StringUtils.isNotBlank(param.getImgurl())){
                log.info("===================="+param.getImgurl());
                int start = param.getImgurl().indexOf("(\"")+2;
                int end = param.getImgurl().indexOf("\",");
@@ -307,7 +303,11 @@
                        member.setImgurlData(data.getData());
                    }
                }
            }
            }*/
             if(param.getImgurl() ==null ){
                 throw  new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"对不起,第"+index+"行【"+param.getName()+"】数据, 未读取到任何职业照图片数据");
             }
             member.setImgurlData(param.getImgurl().getData());
             if(member.getImgurlData() ==null || member.getImgurlData().length==0){
                 throw  new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"对不起,第"+index+"行【"+param.getName()+"】数据, 未读取到任何职业照图片数据");
             }
@@ -350,6 +350,93 @@
            throw  new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"对不起,未读取到有效数据");
        }
         return insertMember;
    }
    private  List<Cases> isvalidImpartCasesParam(LoginUserInfo user,  Map<String, XSSFPictureData> pics, List<CasesImport> casesImportList) {
        if(casesImportList ==null || casesImportList.size()==0){
            throw  new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"对不起,未读取到有效数据");
        }
        if(pics ==null || pics.size()==0){
            throw  new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"对不起,未读取到任何职业照图片数据");
        }
        List<Cases> insertList = new ArrayList<>();
        List<Member> allList = memberMapper.selectList(new QueryWrapper<Member>().lambda()
                .eq(Member::getDeleted,Constants.ZERO));
        allList=allList==null?new ArrayList<>():allList;
        if(allList == null || allList.size()==0){
            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"对不起, 读取老师数据异常,请先维护老师数据信息!");
        }
        Date date = new Date();
        int index = 1;
         for(CasesImport param :casesImportList){
             index ++;
             if( ( param.getImageList() == null
                 ||param.getImageList().size() == 0 )
                     &&StringUtils.isBlank(param.getName())
                     &&StringUtils.isBlank(param.getMemberCode())
                     &&StringUtils.isBlank(param.getStartDate())
                     &&StringUtils.isBlank(param.getEndDate())
                     &&StringUtils.isBlank(param.getDetail())){
                 continue;
             }
             Cases cases = new Cases();
             cases.setStartDate(DateUtil.fromStringToDate("yyyy-MM-dd",param.getStartDate()));
             cases.setEndDate(DateUtil.fromStringToDate("yyyy-MM-dd",param.getEndDate()));
             if(StringUtils.isBlank(param.getName())){
                 throw  new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"对不起,第"+index+"行数据, 案例主题不能为空");
             }
             Member member =null;
             for(Member m : allList){
                 if(StringUtils.equals(param.getMemberCode(),m.getCode())){
                    member = m;
                 }
             }
             if(member == null){
                 throw  new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"对不起,第"+index+"行数据, 老师工号【"+param.getMemberCode()+"】信息不存在,请确认不要重复录入");
             }
             if(StringUtils.isBlank(param.getDetail())){
                 throw  new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"对不起,第"+index+"行数据, 案例说明不能为空");
             }
             if(param.getImageList() == null){
                 param.setImageList(new ArrayList<>());
             }
             param.getImageList().addAll(param.getImageList1()!=null?param.getImageList1():new ArrayList<>());
             param.getImageList().addAll(param.getImageList2()!=null?param.getImageList2():new ArrayList<>());
             param.getImageList().addAll(param.getImageList3()!=null?param.getImageList3():new ArrayList<>());
             param.getImageList().addAll(param.getImageList4()!=null?param.getImageList4():new ArrayList<>());
             param.getImageList().addAll(param.getImageList5()!=null?param.getImageList5():new ArrayList<>());
             if(param.getImageList() == null
                     ||param.getImageList().size() == 0 ){
                 throw  new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"对不起,第"+index+"行数据, 案例图信息不能为空");
             }
             if(cases.getStartDate()==null){
                 throw  new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"对不起,第"+index+"行数据, 开始日期读取失败");
             }
             if(cases.getEndDate()==null){
                 throw  new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"对不起,第"+index+"行数据, 结束日期读取失败");
             }
             cases.setImgdataList(new ArrayList<>());
             for(XSSFPictureData d : param.getImageList()){
                 cases.getImgdataList().add(d.getData());
             }
             cases.setCreateTime(date);
             cases.setUpdateTime(date);
             cases.setCreateUser(user.getId());
             cases.setUpdateUser(user.getId());
             cases.setAddType(Constants.ONE);
             cases.setDeleted(Constants.ZERO);
             cases.setStatus(Constants.ZERO);
             cases.setName(param.getName());
             cases.setDetail(param.getDetail());
             cases.setMemberId(member.getId());
             insertList.add(cases);
         }
        if(insertList ==null || insertList.size()==0){
            throw  new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"对不起,未读取到有效数据");
        }
         return insertList;
    }
@@ -420,16 +507,34 @@
    private int dealCaseImportBiz(ImportRecord importRecord) {
        int success=0;
        String msg ="";
        String msg = "";
        String nowDate =DateUtil.getNowShortDate();
        try {
            for(Cases param:importRecord.getCaseList()){
            String bucket =systemDictDataBiz.queryByCode(Constants.OBJCET_STORAGE,Constants.BUCKETNAME).getCode();
            String folder =systemDictDataBiz.queryByCode(Constants.OBJCET_STORAGE,Constants.CASES_FILES).getCode();
            TyyZosUtil obs = new TyyZosUtil(systemDictDataBiz.queryByCode(Constants.OBJCET_STORAGE,Constants.ENDPOINT).getCode(),
                    systemDictDataBiz.queryByCode(Constants.OBJCET_STORAGE,Constants.ACCESS_ID).getCode(),
                    systemDictDataBiz.queryByCode(Constants.OBJCET_STORAGE,Constants.ACCESS_KEY).getCode());
            for(Cases param: importRecord.getCaseList()){
                int ts =0;
                try {
                    param.setImportId(importRecord.getId());
                    param.setAddType(Constants.ONE);
                    ts =  dealCasesInsert(obs,param,folder,nowDate,bucket);
                }catch (Exception e){
                    log.error("处理人员信息发生异常{}",e.getMessage());
                    ts =0;
                }
                success += ts;
            }
            obs.shutDown();
        }catch (Exception e){
        }
        importRecord.setDoneNum(success);
        importRecord.setErrorNum(importRecord.getTotalNum() - success);
        importRecord.setDetail(msg);
        redisTemplate.delete(Constants.RedisKeys.IMPORTING_RECORD);
        return success;
    }
@@ -464,6 +569,33 @@
    }
    @Transactional
    private int dealCasesInsert( TyyZosUtil obs,Cases param,String folder,String nowDate,String bucketName) {
        int success = casesMapper.insert(param);
        List<Multifile> multifileList = new ArrayList<>();
        for(byte[] d : param.getImgdataList()){
            String fileName = UUID.randomUUID() + ".png";
            String tempFileName = nowDate + "/" + fileName;
            String key = folder + tempFileName;// 文件名
            if (obs.uploadInputstreamObjectNoShutdown(new ByteArrayInputStream(d ) ,bucketName,  key)) {
                Multifile s = new Multifile();
                s.setIsdeleted(Constants.ZERO);
                s.setCreator(param.getCreateUser());
                s.setCreateDate(param.getCreateTime());
                s.setObjId(param.getId());
                s.setType(Constants.ZERO);
                s.setFileurl(tempFileName);
                s.setObjType(Constants.ONE);
                multifileList.add(s);
                param.setImgurl(tempFileName);//证件照地址
            }else{
                throw  new BusinessException(ResponseStatus.SERVER_ERROR.getCode(),"图集上传失败!");
            }
        }
        multifileMapper.insert(multifileList);
        return success;
}
    private int dealMemberInsert( TyyZosUtil obs,Member param,String folder,String nowDate,String bucketName) {
        int success =0;
        try {