From 87485a34345315bd876d68d3d58e241ebbea383d Mon Sep 17 00:00:00 2001 From: 15036302109 Date: Wed, 13 Dec 2023 10:08:26 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BA=94=E6=80=A5=E6=95=91=E6=8F=B4=E9=98=9F?= =?UTF-8?q?=E4=BC=8D=E4=BA=BA=E5=91=98=E4=BF=A1=E6=81=AF=E5=AF=BC=E5=85=A5?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E5=AE=8C=E6=88=90=20=E5=85=AC=E6=96=87?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E5=85=AC=E6=96=87=E5=88=A0=E9=99=A4=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/ehs/EhsDocumentController.java | 8 ++- .../ehs/EhsRescueTeamWorkerController.java | 9 +-- .../mapper/EhsDocTransferMapper.java | 7 +++ .../service/IEhsDocTransferService.java | 7 +++ .../impl/EhsDocTransferServiceImpl.java | 11 ++++ .../domain/EhsRescueTeamWorker.java | 6 +- .../RescueTeamWorkerImportTemplate.java | 56 +++++++++++++++++ .../service/IEhsRescueTeamWorkerService.java | 4 ++ .../impl/EhsRescueTeamWorkerServiceImpl.java | 61 +++++++++++++++++++ .../mapper/ehs/EhsDocTransferMapper.xml | 9 +++ ruoyi-ui/src/components/upload/upload.vue | 4 +- .../views/ehs/ehsRescueTeamWorker/index.vue | 7 ++- 12 files changed, 176 insertions(+), 13 deletions(-) create mode 100644 ruoyi-system/src/main/java/com/ruoyi/ehsRescueTeamWorker/domain/RescueTeamWorkerImportTemplate.java diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/ehs/EhsDocumentController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/ehs/EhsDocumentController.java index 8216ef2..9943252 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/ehs/EhsDocumentController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/ehs/EhsDocumentController.java @@ -14,6 +14,7 @@ import com.ruoyi.ehsDocTransfer.service.IEhsDocTransferService; import com.ruoyi.ehsDocument.vo.DocResponseVo; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.transaction.annotation.Transactional; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PutMapping; @@ -138,13 +139,16 @@ public class EhsDocumentController extends BaseController { } /** - * 删除公文管理 + * 删除公文管理,同时删除该公文流转记录 */ @ApiOperation("删除公文管理") @PreAuthorize("@ss.hasPermi('ehs:ehsDocument:remove')") @Log(title = "公文管理", businessType = BusinessType.DELETE) + @Transactional @DeleteMapping("/{ids}") public AjaxResult remove(@PathVariable Long[] ids) { - return toAjax(ehsDocumentService.removeByIds(Arrays.asList(ids))); + ehsDocumentService.removeByIds(Arrays.asList(ids)); + boolean result = transferService.removeByDocumentIds(Arrays.asList(ids)); + return toAjax(result); } } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/ehs/EhsRescueTeamWorkerController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/ehs/EhsRescueTeamWorkerController.java index 7b9a59d..25e5550 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/ehs/EhsRescueTeamWorkerController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/ehs/EhsRescueTeamWorkerController.java @@ -13,6 +13,7 @@ import com.ruoyi.ehsRescueTeam.domain.RescueTeamImportTemplate; import com.ruoyi.ehsRescueTeam.service.IEhsRescueTeamService; import com.ruoyi.ehsRescueTeam.vo.TeamResponseVo; import com.ruoyi.ehsRescueTeamWorker.domain.EhsRescueTeamWorker; +import com.ruoyi.ehsRescueTeamWorker.domain.RescueTeamWorkerImportTemplate; import com.ruoyi.ehsRescueTeamWorker.service.IEhsRescueTeamWorkerService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -141,10 +142,10 @@ public class EhsRescueTeamWorkerController extends BaseController { * 批量导入 */ @PostMapping("/importData") - public AjaxResult importHubManage(MultipartFile file, Boolean updateSupport) throws Exception { - ExcelUtil util = new ExcelUtil<>(RescueTeamImportTemplate.class); - List list = util.importExcel(file.getInputStream()); - String message = ehsRescueTeamService.importRescueTeam(list, updateSupport); + public AjaxResult importData(MultipartFile file, Boolean updateSupport, Long params) throws Exception { + ExcelUtil util = new ExcelUtil<>(RescueTeamWorkerImportTemplate.class); + List list = util.importExcel(file.getInputStream()); + String message = ehsRescueTeamWorkerService.importRescueTeamWorker(list, updateSupport, params); return AjaxResult.success(message); } } diff --git a/ruoyi-system/src/main/java/com/ruoyi/ehsDocTransfer/mapper/EhsDocTransferMapper.java b/ruoyi-system/src/main/java/com/ruoyi/ehsDocTransfer/mapper/EhsDocTransferMapper.java index e8de08c..0f42a4c 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/ehsDocTransfer/mapper/EhsDocTransferMapper.java +++ b/ruoyi-system/src/main/java/com/ruoyi/ehsDocTransfer/mapper/EhsDocTransferMapper.java @@ -33,4 +33,11 @@ public interface EhsDocTransferMapper extends BaseMapper { * 根据公文id获取公文流转信息 */ List getTransferInfoByDocId(@Param("id") Long id); + + /** + * 删除公文同时,删除该公文的流转记录 + * @param documentIds + * @return + */ + boolean removeByDocumentIds(List documentIds); } diff --git a/ruoyi-system/src/main/java/com/ruoyi/ehsDocTransfer/service/IEhsDocTransferService.java b/ruoyi-system/src/main/java/com/ruoyi/ehsDocTransfer/service/IEhsDocTransferService.java index 4e6dc4a..8c831fe 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/ehsDocTransfer/service/IEhsDocTransferService.java +++ b/ruoyi-system/src/main/java/com/ruoyi/ehsDocTransfer/service/IEhsDocTransferService.java @@ -33,4 +33,11 @@ public interface IEhsDocTransferService extends IService { * 根据公文id获取公文流转信息 */ List getTransferInfoByDocId(Long id); + + /** + * 删除公文同时,删除该公文的流转记录 + * @param documentIds + * @return + */ + boolean removeByDocumentIds(List documentIds); } diff --git a/ruoyi-system/src/main/java/com/ruoyi/ehsDocTransfer/service/impl/EhsDocTransferServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/ehsDocTransfer/service/impl/EhsDocTransferServiceImpl.java index 229f417..bf1aa97 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/ehsDocTransfer/service/impl/EhsDocTransferServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/ehsDocTransfer/service/impl/EhsDocTransferServiceImpl.java @@ -56,6 +56,17 @@ public class EhsDocTransferServiceImpl extends ServiceImpl documentIds) { + + return ehsDocTransferMapper.removeByDocumentIds(documentIds); + } + private LambdaQueryWrapper buildQueryWrapper(EhsDocTransfer query) { Map params = query.getParams(); diff --git a/ruoyi-system/src/main/java/com/ruoyi/ehsRescueTeamWorker/domain/EhsRescueTeamWorker.java b/ruoyi-system/src/main/java/com/ruoyi/ehsRescueTeamWorker/domain/EhsRescueTeamWorker.java index 060c334..d3c5b7b 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/ehsRescueTeamWorker/domain/EhsRescueTeamWorker.java +++ b/ruoyi-system/src/main/java/com/ruoyi/ehsRescueTeamWorker/domain/EhsRescueTeamWorker.java @@ -37,7 +37,7 @@ public class EhsRescueTeamWorker extends BaseEntity { /** * 应急救援队伍id */ - @Excel(name = "应急救援队伍id") + // @Excel(name = "应急救援队伍id") private Long rescueTeamId; /** @@ -55,14 +55,14 @@ public class EhsRescueTeamWorker extends BaseEntity { /** * 性别 */ - @Excel(name = "性别") + @Excel(name = "性别(0男 1女)") private Integer gender; /** * 出生年月 */ @JsonFormat(pattern = "yyyy-MM-dd") - @Excel(name = "出生年月", width = 30, dateFormat = "yyyy-MM-dd") + @Excel(name = "出生年月(格式为2023-12-12)", width = 30, dateFormat = "yyyy-MM-dd") private Date birthday; /** diff --git a/ruoyi-system/src/main/java/com/ruoyi/ehsRescueTeamWorker/domain/RescueTeamWorkerImportTemplate.java b/ruoyi-system/src/main/java/com/ruoyi/ehsRescueTeamWorker/domain/RescueTeamWorkerImportTemplate.java new file mode 100644 index 0000000..8af3bed --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/ehsRescueTeamWorker/domain/RescueTeamWorkerImportTemplate.java @@ -0,0 +1,56 @@ +package com.ruoyi.ehsRescueTeamWorker.domain; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.ruoyi.common.annotation.Excel; +import lombok.Data; + +import java.util.Date; + +@Data +public class RescueTeamWorkerImportTemplate { + /** + * 人员姓名 + */ + @Excel(name = "人员姓名", type = Excel.Type.ALL) + private String workerName; + /** + * 性别 + */ + @Excel(name = "性别(0男 1女)", type = Excel.Type.ALL) + private Integer gender; + /** + * 出生年月 + */ + @JsonFormat(pattern = "yyyy-MM-dd") + @Excel(name = "出生年月(格式为2023-12-12)", width = 30, dateFormat = "yyyy-MM-dd", type = Excel.Type.ALL) + private Date birthday; + /** + * 身份证号 + */ + @Excel(name = "身份证号", type = Excel.Type.ALL) + private String idCard; + + /** + * 联系方式 + */ + @Excel(name = "联系方式", type = Excel.Type.ALL) + private String phone; + + /** + * 工作年限 + */ + @Excel(name = "工作年限", type = Excel.Type.ALL) + private String workYear; + + /** + * 救援技能特长 + */ + @Excel(name = "救援技能特长", type = Excel.Type.ALL) + private String speciality; + + /** + * 备注 + */ + @Excel(name = "备注", type = Excel.Type.ALL) + private String remark; +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/ehsRescueTeamWorker/service/IEhsRescueTeamWorkerService.java b/ruoyi-system/src/main/java/com/ruoyi/ehsRescueTeamWorker/service/IEhsRescueTeamWorkerService.java index 06e0c15..b4a55c8 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/ehsRescueTeamWorker/service/IEhsRescueTeamWorkerService.java +++ b/ruoyi-system/src/main/java/com/ruoyi/ehsRescueTeamWorker/service/IEhsRescueTeamWorkerService.java @@ -4,6 +4,7 @@ import java.util.List; import com.baomidou.mybatisplus.extension.service.IService; import com.ruoyi.ehsRescueTeamWorker.domain.EhsRescueTeamWorker; +import com.ruoyi.ehsRescueTeamWorker.domain.RescueTeamWorkerImportTemplate; /** * 应急救援队人员信息Service接口 @@ -31,4 +32,7 @@ public interface IEhsRescueTeamWorkerService extends IService teamIds); + + // 批量导入数据 + public String importRescueTeamWorker(List list, Boolean updateSupport, Long params) throws Exception; } diff --git a/ruoyi-system/src/main/java/com/ruoyi/ehsRescueTeamWorker/service/impl/EhsRescueTeamWorkerServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/ehsRescueTeamWorker/service/impl/EhsRescueTeamWorkerServiceImpl.java index d075d4a..1ad8a4d 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/ehsRescueTeamWorker/service/impl/EhsRescueTeamWorkerServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/ehsRescueTeamWorker/service/impl/EhsRescueTeamWorkerServiceImpl.java @@ -3,6 +3,11 @@ package com.ruoyi.ehsRescueTeamWorker.service.impl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.ruoyi.ehsRescueTeam.domain.EhsRescueTeam; +import com.ruoyi.ehsRescueTeam.domain.RescueTeamImportTemplate; +import com.ruoyi.ehsRescueTeam.mapper.EhsRescueTeamMapper; +import com.ruoyi.ehsRescueTeam.vo.TeamResponseVo; +import com.ruoyi.ehsRescueTeamWorker.domain.RescueTeamWorkerImportTemplate; import org.springframework.stereotype.Service; import org.springframework.beans.factory.annotation.Autowired; import com.ruoyi.common.utils.StringUtils; @@ -25,6 +30,8 @@ public class EhsRescueTeamWorkerServiceImpl extends ServiceImpl list, Boolean updateSupport, Long params) throws Exception { + if (StringUtils.isNull(list) || list.size() == 0) { + throw new Exception("导入应急救援队伍人员信息数据不能为空!"); + } + int successNum = 0; + int failureNum = 0; + + StringBuilder successMsg = new StringBuilder(); + StringBuilder failureMsg = new StringBuilder(); + for (RescueTeamWorkerImportTemplate rescueTeamWorkerTemplate : list) { + + EhsRescueTeamWorker temp = new EhsRescueTeamWorker(); + /** + * 因为是插入数据,所以id需要处理,如果id是String类型,那么生成个uuid插入到数据库 + * 如果id是整数,并且自动递增,那么无需设置id + */ + // temp.setId(IdUtils.fastSimpleUUID()); + // 根据teamId查询队伍信息,parms前端传过来的是teamId + TeamResponseVo teamResponseVo = ehsRescueTeamMapper.getTeamInfoByTeamId(params); + temp.setRescueTeamId(teamResponseVo.getRescueTeamId());// 队伍id + temp.setRescueTeamName(teamResponseVo.getRescueTeamName());// 队伍名称 + temp.setWorkerName(rescueTeamWorkerTemplate.getWorkerName());// 人员姓名 + temp.setGender(rescueTeamWorkerTemplate.getGender());// 性别(0男 1女) + temp.setBirthday(rescueTeamWorkerTemplate.getBirthday());// 出生年月(格式为2023-12-12) + temp.setIdCard(rescueTeamWorkerTemplate.getIdCard());// 身份证号 + temp.setPhone(rescueTeamWorkerTemplate.getPhone());// 联系方式 + temp.setWorkYear(rescueTeamWorkerTemplate.getWorkYear());// 工作年限 + temp.setSpeciality(rescueTeamWorkerTemplate.getSpeciality());// 救援技能特长 + temp.setRemark(rescueTeamWorkerTemplate.getRemark());// 备注 + + try { + //插入数据 + this.save(temp); + successNum++; + successMsg.append("
" + successNum + "、应急救援队伍人员信息" + temp.getWorkerName() + "导入成功"); + } catch (Exception e) { + e.printStackTrace(); + log.error(e.getLocalizedMessage()); + failureNum++; + successMsg.append("
" + failureNum + "、应急救援队伍人员信息" + temp.getWorkerName() + "导入异常,请联系管理员!"); + continue; + } + } + return successMsg.toString(); + } + private LambdaQueryWrapper buildQueryWrapper(EhsRescueTeamWorker query) { Map params = query.getParams(); diff --git a/ruoyi-system/src/main/resources/mapper/ehs/EhsDocTransferMapper.xml b/ruoyi-system/src/main/resources/mapper/ehs/EhsDocTransferMapper.xml index 68561c4..c604f49 100644 --- a/ruoyi-system/src/main/resources/mapper/ehs/EhsDocTransferMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/ehs/EhsDocTransferMapper.xml @@ -27,6 +27,7 @@ select id, transfer_user_id, transfer_name, transfer_time, doc_transfer_status, document_id, document_name, create_by, create_time, update_by, update_time, remark, dept_id, create_user_id, update_user_id from ehs_doc_transfer + + + delete from ehs_doc_transfer + where document_id in + + #{items} + + + \ No newline at end of file diff --git a/ruoyi-ui/src/components/upload/upload.vue b/ruoyi-ui/src/components/upload/upload.vue index ca4f297..b505e95 100644 --- a/ruoyi-ui/src/components/upload/upload.vue +++ b/ruoyi-ui/src/components/upload/upload.vue @@ -10,7 +10,7 @@ :limit="3" accept=".xlsx, .xls" :headers="upload.headers" - :action="upload.url + '?updateSupport=' + upload.updateSupport" + :action="upload.url + '?updateSupport=' + upload.updateSupport + '¶ms=' + upload.params" :disabled="upload.isUploading" :on-progress="handleFileUploadProgress" :on-success="handleFileSuccess" @@ -52,6 +52,8 @@ export default { open: false, // 弹出层标题(用户导入) title: "", + // 发送给后端的参数 + params: "", // 是否禁用上传 isUploading: false, // 是否更新已经存在的用户数据 diff --git a/ruoyi-ui/src/views/ehs/ehsRescueTeamWorker/index.vue b/ruoyi-ui/src/views/ehs/ehsRescueTeamWorker/index.vue index d09ff42..153920b 100644 --- a/ruoyi-ui/src/views/ehs/ehsRescueTeamWorker/index.vue +++ b/ruoyi-ui/src/views/ehs/ehsRescueTeamWorker/index.vue @@ -149,7 +149,7 @@ {{ Number(scope.$index) + 1 }} - + @@ -200,9 +200,9 @@ - + @@ -448,6 +448,7 @@ export default { console.log(this.$refs.uploadRef.upload); this.$refs.uploadRef.upload.open = true; this.$refs.uploadRef.upload.title = "应急救援队伍人员导入"; + this.$refs.uploadRef.upload.params = this.id;// 这个id是rescueTeamId this.$refs.uploadRef.upload.url = process.env.VUE_APP_BASE_API + "/ehs/ehsRescueTeamWorker/importData"; },