| | |
| | | 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()); |
| | |
| | | } |
| | | |
| | | /** |
| | | * 异步执行文件任务 |
| | | */ |
| | | @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 |
| | | */ |