| | |
| | | import com.ruoyi.common.core.domain.entity.SysUser; |
| | | import com.ruoyi.common.core.exception.ServiceException; |
| | | import com.ruoyi.common.enums.BusinessType; |
| | | import com.ruoyi.common.utils.DateUtils; |
| | | import com.ruoyi.common.utils.WebUtils; |
| | | import com.ruoyi.system.export.OldsterImport; |
| | | import com.ruoyi.system.model.TNotice; |
| | | import com.ruoyi.system.model.TOldster; |
| | | import com.ruoyi.system.query.BannerListQuery; |
| | | import com.ruoyi.system.query.OldsterListQuery; |
| | |
| | | @Transactional |
| | | @Log(title = "老人户籍信息-添加", businessType = BusinessType.INSERT) |
| | | @PostMapping(value = "/add") |
| | | public R<Boolean> save(@RequestBody TOldster entity) { |
| | | oldsterService.save(entity); |
| | | public R<Boolean> save(@RequestBody TOldster dto) { |
| | | oldsterService.save(dto); |
| | | return R.ok(); |
| | | } |
| | | @ApiOperation(value = "修改") |
| | | @Log(title = "老人户籍信息-修改", businessType = BusinessType.UPDATE) |
| | | @PostMapping(value = "/edit") |
| | | public R<Boolean> edit(@RequestBody TOldster entity) { |
| | | oldsterService.updateById(entity); |
| | | public R<Boolean> edit(@RequestBody TOldster dto) { |
| | | oldsterService.updateById(dto); |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | | * 查看老人户籍信息详情 |
| | | */ |
| | | @ApiOperation(value = "查看老人户籍信息详情") |
| | | @GetMapping(value = "/getDetailById") |
| | | public R<TOldster> getDetailById(@RequestParam String id) { |
| | | return R.ok(oldsterService.getById(id)); |
| | | } |
| | | |
| | | /** |
| | | * 删除老人户籍信息 |
| | | */ |
| | | @Log(title = "老人户籍信息-删除", businessType = BusinessType.DELETE) |
| | | @ApiOperation(value = "老人户籍信息-删除") |
| | | @DeleteMapping(value = "/delete") |
| | | public R delete(@RequestParam String ids) { |
| | | List<Integer> res = Arrays.stream(ids.split(",")).map(Integer::parseInt).collect(Collectors.toList()); |
| | | // 转换成Integer |
| | | oldsterService.removeBatchByIds(res); |
| | | return R.ok(); |
| | | @DeleteMapping(value = "/deleteById") |
| | | public R<Boolean> deleteById(@RequestParam String id) { |
| | | return R.ok(oldsterService.removeById(id)); |
| | | } |
| | | |
| | | /** |
| | | * 批量删除老人户籍信息 |
| | | */ |
| | | @Log(title = "老人户籍信息-批量删除", businessType = BusinessType.DELETE) |
| | | @ApiOperation(value = "老人户籍信息-批量删除") |
| | | @DeleteMapping(value = "/deleteByIds") |
| | | public R<Boolean> deleteByIds(@RequestBody List<String> ids) { |
| | | return R.ok(oldsterService.removeByIds(ids)); |
| | | } |
| | | @ApiOperation(value = "导入模板下载") |
| | | @GetMapping("/import-template") |
| | |
| | | } |
| | | } |
| | | } |
| | | @Log(title = "老人户籍信息导入", businessType = BusinessType.INSERT) |
| | | @Log(title = "老人户籍信息-老人户籍信息导入", businessType = BusinessType.INSERT) |
| | | @ApiOperation(value = "老人户籍信息导入") |
| | | @Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRES_NEW) |
| | | @PostMapping("/import") |
| | | public R<String> importLocation(@RequestPart("file") MultipartFile file) { |
| | | public R<String> importInfo(@RequestPart("file") MultipartFile file) { |
| | | List<TOldster> oldsters = new ArrayList<>(); |
| | | ImportParams params = new ImportParams(); |
| | | params.setHeadRows(1); //表头行数 |
| | |
| | | for (OldsterImport oldsterImport : assetHouseInspectionImports) { |
| | | if (!StringUtils.hasLength(oldsterImport.getOldsterName())){ |
| | | result.append("第"+i+"行:[", "老人姓名"+"]不能为空"); |
| | | i++; |
| | | continue; |
| | | } |
| | | if (oldsterImport.getOldsterAge()!=null){ |
| | | result.append("第"+i+"行:[", "老人年龄"+"]不能为空"); |
| | | } |
| | | if (oldsterImport.getOldsterSex()!=null){ |
| | | if (!StringUtils.hasLength(oldsterImport.getOldsterSexStr())){ |
| | | result.append("第"+i+"行:[", "老人性别"+"]不能为空"); |
| | | i++; |
| | | continue; |
| | | } |
| | | if (!StringUtils.hasLength(oldsterImport.getContactPhone())){ |
| | | result.append("第"+i+"行:[", "联系方式"+"]不能为空"); |
| | | i++; |
| | | continue; |
| | | } |
| | | if (oldsterImport.getOldsterType()!=null){ |
| | | if (!StringUtils.hasLength(oldsterImport.getOldsterTypeStr())){ |
| | | result.append("第"+i+"行:[", "人员类型"+"]不能为空"); |
| | | i++; |
| | | continue; |
| | | } |
| | | if (!StringUtils.hasLength(oldsterImport.getAddress())){ |
| | | result.append("第"+i+"行:[", "居住地址"+"]不能为空"); |
| | | i++; |
| | | continue; |
| | | } |
| | | TOldster tOldster = new TOldster(); |
| | | BeanUtils.copyProperties(oldsterImport, tOldster); |
| | | if(StringUtils.hasLength(oldsterImport.getBirthDateStr())){ |
| | | try{ |
| | | LocalDate localDate = DateUtils.stringToLocalDate(oldsterImport.getBirthDateStr()); |
| | | tOldster.setBirthDate(localDate); |
| | | }catch (Exception e){ |
| | | result.append("第"+i+"行:[", "出生日期"+"]格式错误"); |
| | | i++; |
| | | continue; |
| | | } |
| | | } |
| | | switch (oldsterImport.getOldsterSexStr()){ |
| | | case "男": |
| | | tOldster.setOldsterSex(1); |
| | | break; |
| | | case "女": |
| | | tOldster.setOldsterSex(2); |
| | | break; |
| | | } |
| | | switch (oldsterImport.getOldsterTypeStr()){ |
| | | case "独居老人": |
| | | tOldster.setOldsterType(1); |
| | | break; |
| | | case "高龄老人": |
| | | tOldster.setOldsterType(2); |
| | | break; |
| | | case "散居特困供养老人": |
| | | tOldster.setOldsterType(3); |
| | | break; |
| | | case "失能老人": |
| | | tOldster.setOldsterType(4); |
| | | break; |
| | | } |
| | | oldsters.add(tOldster); |
| | | i++; |
| | | } |