| | |
| | | import com.ruoyi.common.utils.MapUtils; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | | import com.ruoyi.domain.ArchiveRecords; |
| | | import com.ruoyi.domain.Archiverecordstouser; |
| | | import com.ruoyi.domain.vo.AnalysisResult; |
| | | import com.ruoyi.domain.vo.ArchiveInfoVo; |
| | | import com.ruoyi.mapper.ArchiveRecordsMapper; |
| | | import com.ruoyi.mapper.ArchiverecordstouserMapper; |
| | | import com.ruoyi.service.IArchiveRecordsService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | /** |
| | | * 档案记录Service业务层处理 |
| | |
| | | |
| | | Date date = Date.from(time.atZone(ZoneId.systemDefault()).toInstant()); |
| | | archiveRecords.setCreateTime(date); |
| | | |
| | | |
| | | archiveRecords.setRecordStatus("未录入"); |
| | | // archiveRecords |
| | | boolean res = this.save(archiveRecords); |
| | | if(res) |
| | | return 1; |
| | |
| | | @Override |
| | | public int deleteArchiveRecordsByIds(Long[] ids) |
| | | { |
| | | if (this.removeByIds(Arrays.asList(ids))) { |
| | | return 1; |
| | | Long res = 0L; |
| | | for(Long id: ids) |
| | | { |
| | | this.baseMapper.updateAllInfoById(id); |
| | | |
| | | } |
| | | else |
| | | return 0; |
| | | return 1; |
| | | } |
| | | |
| | | /** |
| | |
| | | { |
| | | return 0; |
| | | } |
| | | |
| | | @Override |
| | | public ArchiveInfoVo selectByRecordId(Long id) { |
| | | return this.baseMapper.findByRecordId(id); |
| | | } |
| | | |
| | | @Override |
| | | public AjaxResult importExcel(MultipartFile file) { |
| | | ExcelUtil<ArchiveRecords> util = new ExcelUtil<>(ArchiveRecords.class); |
| | | List<ArchiveRecords> dataList = null; |
| | | try { |
| | | dataList = util.importExcel(file.getInputStream()); |
| | | } catch (Exception e) { |
| | | throw new RuntimeException("没有按照规则导入数据"); |
| | | } |
| | | |
| | | assert dataList != null; |
| | | |
| | | for (ArchiveRecords archiveRecords : dataList) { |
| | | // physcialService.mySave(physcial); |
| | | this.mySave(archiveRecords); |
| | | } |
| | | |
| | | return AjaxResult.success(); |
| | | } |
| | | |
| | | @Override |
| | | public List<AnalysisResult> statisticAya() { |
| | | return this.baseMapper.statisticAyasis(); |
| | | } |
| | | |
| | | |
| | | public AjaxResult mySave(ArchiveRecords archiveRecords) { |
| | | |
| | | |
| | | //检查是否有重复数据插入 |
| | | LambdaQueryWrapper<ArchiveRecords> lqw = new LambdaQueryWrapper<>(); |
| | | lqw.eq(!StringUtils.isEmpty(archiveRecords.getRecordId()), ArchiveRecords::getRecordId,archiveRecords.getRecordId()); |
| | | List<ArchiveRecords> list = list(lqw); |
| | | if (list.size() > 0) { |
| | | // throw new RuntimeException("请勿新增重复数据"); |
| | | //如果有重复数据,则根据recordId进行数据修改 |
| | | this.baseMapper.update(archiveRecords, lqw); |
| | | return AjaxResult.success(); |
| | | } |
| | | else { |
| | | if (save(archiveRecords)) { |
| | | return AjaxResult.success(); |
| | | } else { |
| | | return AjaxResult.error(); |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |