| | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.github.yulichang.wrapper.MPJLambdaWrapper; |
| | | import com.sun.xml.internal.messaging.saaj.util.ByteInputStream; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.apache.poi.ss.usermodel.CellType; |
| | |
| | | import org.springframework.util.CollectionUtils; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.annotation.PostConstruct; |
| | | import javax.annotation.Resource; |
| | | import java.io.ByteArrayInputStream; |
| | | import java.math.BigDecimal; |
| | |
| | | MPJLambdaWrapper<ImportRecord> queryWrapper = new MPJLambdaWrapper<>(); |
| | | Utils.MP.blankToNull(pageWrap.getModel()); |
| | | queryWrapper.selectAll(ImportRecord.class ) |
| | | .selectAs(SystemUser::getRealname,ImportRecord::getUpdateUserName) |
| | | .select( "(select count(c.id) from cases c where c.import_id= t.id)",ImportRecord::getIngNum) |
| | | .selectAs(SystemUser::getRealname,ImportRecord::getUpdateUserName) |
| | | .leftJoin(SystemUser.class,SystemUser::getId,ImportRecord::getUpdateUser); |
| | | queryWrapper.eq(pageWrap.getModel().getId() != null,ImportRecord::getId, pageWrap.getModel().getId()); |
| | | queryWrapper.eq(pageWrap.getModel().getDeleted() != null,ImportRecord::getDeleted, pageWrap.getModel().getDeleted()); |
| | |
| | | int index = 1; |
| | | for(CasesImport param :casesImportList){ |
| | | index ++; |
| | | if( ( param.getImageList() == null |
| | | ||param.getImageList().size() == 0 ) |
| | | &&StringUtils.isBlank(param.getName()) |
| | | if( StringUtils.isBlank(param.getName()) |
| | | &&StringUtils.isBlank(param.getMemberCode()) |
| | | &&StringUtils.isBlank(param.getStartDate()) |
| | | &&StringUtils.isBlank(param.getEndDate()) |
| | |
| | | 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 |
| | | /* 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+"行数据, 开始日期读取失败"); |
| | | } |
| | |
| | | } |
| | | |
| | | /** |
| | | * 异步执行文件任务 |
| | | */ |
| | | @Override |
| | | public void clearImporTask(){ |
| | | try { |
| | | List<ImportRecord> records = importRecordMapper.selectList(new QueryWrapper<ImportRecord>() |
| | | .select("id,total_num,(select count(c.id) from cases c where c.import_id= import_record.id) as doneNum") |
| | | .lambda() |
| | | .eq(ImportRecord::getDeleted,Constants.ZERO) |
| | | .ne(ImportRecord::getStatus,Constants.TWO) |
| | | ); |
| | | for(ImportRecord importRecord : records){ |
| | | importRecord.setErrorNum(Constants.formatIntegerNum(importRecord.getTotalNum()- Constants.formatIntegerNum(importRecord.getDoneNum()))); |
| | | importRecord.setStatus(Constants.TWO); |
| | | importRecord.setUpdateTime(new Date()); |
| | | importRecord.setRemark("任务执行中断,强制设置任务状态"); |
| | | importRecordMapper.updateById(importRecord); |
| | | } |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | }finally { |
| | | redisTemplate.delete(Constants.RedisKeys.IMPORTING_RECORD); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 处理案例导入任务 |
| | | * @param importRecord |
| | | */ |
| | |
| | | @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(),"图集上传失败!"); |
| | | if(param.getImgdataList()!=null && param.getImgdataList().size()>0){ |
| | | 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); |
| | | } |
| | | multifileMapper.insert(multifileList); |
| | | return success; |
| | | } |
| | | |