diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/controller/OperAccessLibraryController.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/controller/OperAccessLibraryController.java index 472a6c9..896e2f3 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/controller/OperAccessLibraryController.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/controller/OperAccessLibraryController.java @@ -41,7 +41,7 @@ public class OperAccessLibraryController extends BladeController { * 删除 */ @PostMapping("/remove") - @ApiOperationSupport(order = 10) + @ApiOperationSupport(order = 1) @ApiOperation(value = "逻辑删除") public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) { return R.status(service.deleteLogic(Func.toLongList(ids))); @@ -51,7 +51,7 @@ public class OperAccessLibraryController extends BladeController { * 新增 */ @PostMapping("/save") - @ApiOperationSupport(order = 20) + @ApiOperationSupport(order = 2) @ApiOperation(value = "新增") public R save(@Valid @RequestBody OperAccessLibraryDTO req) { return service.doSave(req); @@ -61,7 +61,7 @@ public class OperAccessLibraryController extends BladeController { * 修改 */ @PostMapping("/update") - @ApiOperationSupport(order = 30) + @ApiOperationSupport(order = 3) @ApiOperation(value = "修改") public R update(@Valid @RequestBody OperAccessLibraryDTO req) { return service.doUpdateById(req); @@ -72,7 +72,7 @@ public class OperAccessLibraryController extends BladeController { */ @ApiLog @GetMapping("/detail") - @ApiOperationSupport(order = 40) + @ApiOperationSupport(order = 4) @ApiOperation(value = "详情") public R detail(@RequestParam Long id) { return service.detail(id); @@ -83,7 +83,7 @@ public class OperAccessLibraryController extends BladeController { */ @ApiLog @GetMapping("/list") - @ApiOperationSupport(order = 50) + @ApiOperationSupport(order = 5) @ApiOperation(value = "分页 查询参数:emCode,gradeCode") @OperationAnnotation(moduleName = "检修管理",title = "检修库",operatorType = OperatorType.MOBILE,businessType = BusinessType.GENCODE, @@ -92,13 +92,10 @@ public class OperAccessLibraryController extends BladeController { return service.list(req, query); } - /** - * 导入数据 - */ - @ApiOperation(value = "导入Excel") - @ApiOperationSupport(order = 70) - @PostMapping(value = "/importExcel") - public R importExcel(MultipartFile file) throws Exception { - return service.importExcel(file); + @ApiOperation(value = "导入模板下载") + @ApiOperationSupport(order = 6) + @PostMapping(value = "/template_download") + public void downLoad() { + service.downLoad(); } -} +} \ No newline at end of file diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/IOperAccessLibraryService.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/IOperAccessLibraryService.java index 86e0ad0..6704dcd 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/IOperAccessLibraryService.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/IOperAccessLibraryService.java @@ -26,5 +26,5 @@ public interface IOperAccessLibraryService extends BaseService> list(OperAccessLibraryListDTO req, Query query); - R importExcel(MultipartFile file) throws Exception; + void downLoad(); } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/OperAccessLibraryServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/OperAccessLibraryServiceImpl.java index 7c79c98..f4d82a6 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/OperAccessLibraryServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/OperAccessLibraryServiceImpl.java @@ -1,7 +1,6 @@ package com.hnac.hzims.operational.access.service.impl; -import cn.afterturn.easypoi.excel.ExcelImportUtil; -import cn.afterturn.easypoi.excel.entity.ImportParams; +import cn.afterturn.easypoi.excel.entity.TemplateExportParams; import com.alibaba.nacos.client.config.NacosConfigService; import com.baomidou.mybatisplus.core.conditions.Wrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; @@ -20,17 +19,20 @@ import com.hnac.hzims.operational.access.vo.OperAccessLibraryVO; import com.hnac.hzims.operational.access.wrapper.OperAccessLibraryWrapper; import com.hnac.hzims.safeproduct.feign.IDangerSourceClient; import org.apache.commons.lang.StringUtils; +import org.jfree.chart.util.ExportUtils; import org.springblade.core.mp.base.BaseServiceImpl; import org.springblade.core.mp.support.Condition; import org.springblade.core.mp.support.Query; import org.springblade.core.tool.api.R; -import org.springblade.core.tool.utils.BeanUtil; import org.springblade.core.tool.utils.CollectionUtil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; -import org.springframework.web.multipart.MultipartFile; +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; +import javax.servlet.http.HttpServletResponse; +import java.io.*; import java.util.ArrayList; import java.util.List; import java.util.Set; @@ -92,38 +94,16 @@ public class OperAccessLibraryServiceImpl extends BaseServiceImpl data = ExcelImportUtil.importExcel(file.getInputStream(), OperAccessLibraryUpload.class, params); - - for (OperAccessLibraryUpload libraryExcel : data) { - try { - //数据校验 - R r = this.validExcel(libraryExcel); - if (r != null && r.getCode() != 500) { - return r; - } + public void downLoad() { + ServletRequestAttributes servletRequestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); + HttpServletResponse response = servletRequestAttributes.getResponse(); - //数据库操作 - OperAccessLibraryDTO libraryDTO = BeanUtil.copy(libraryExcel, OperAccessLibraryDTO.class); - this.doSave(libraryDTO); - if (CollectionUtil.isNotEmpty(libraryExcel.getDetails())) { - List libraryDetailEntities = libraryExcel.getDetails().stream().map(o -> { - OperAccessLibraryDetailEntity detailEntity = BeanUtil.copy(o, OperAccessLibraryDetailEntity.class); - detailEntity.setPid(libraryDTO.getId()); - return detailEntity; - }).collect(Collectors.toList()); - libraryDetailService.saveBatch(libraryDetailEntities); - } - } catch (Exception ex) { - throw new RuntimeException(String.format("第%s行导入数据异常!", counter), ex); - } - } - - return R.success("OK"); - } + } /** * 调整检修库明细 diff --git a/hzims-service/operational/src/main/resources/template/excel/access_import_template.xls b/hzims-service/operational/src/main/resources/template/excel/access_import_template.xls new file mode 100644 index 0000000..6c76782 Binary files /dev/null and b/hzims-service/operational/src/main/resources/template/excel/access_import_template.xls differ diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/repair/service/impl/WorkTaskServiceImpl.java b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/repair/service/impl/WorkTaskServiceImpl.java index 5076782..f1a271d 100644 --- a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/repair/service/impl/WorkTaskServiceImpl.java +++ b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/repair/service/impl/WorkTaskServiceImpl.java @@ -1,6 +1,7 @@ package com.hnac.hzims.ticket.repair.service.impl; import cn.afterturn.easypoi.excel.entity.TemplateExportParams; +import cn.afterturn.easypoi.word.WordExportUtil; import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.TypeReference; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; @@ -12,13 +13,16 @@ import com.hnac.hzims.ticket.repair.service.IWorkTaskService; import com.hnac.hzims.ticket.repair.vo.WorkTaskContentVO; import com.hnac.hzims.ticket.repair.vo.WorkTaskPreviewVO; import com.hnac.hzims.ticket.repair.vo.WorkTaskVO; +import com.hnac.hzims.ticket.utils.AsposeUtil; import com.hnac.hzims.ticket.utils.ExcelUtil; import com.hnac.hzims.ticket.utils.PdfUtils; +import com.hnac.hzims.ticket.utils.WordUtils; import com.hnac.hzims.ticket.workTicket.entity.WorkTicketInfoEntity; import com.hnac.hzims.ticket.workTicket.service.IWorkTicketInfoService; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.apache.poi.ss.usermodel.Workbook; +import org.apache.poi.xwpf.usermodel.XWPFDocument; import org.springblade.core.log.exception.ServiceException; import org.springblade.core.mp.base.BaseServiceImpl; import org.springblade.core.mp.support.Condition; @@ -39,6 +43,10 @@ import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.context.request.ServletRequestAttributes; import javax.servlet.http.HttpServletResponse; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; import java.util.*; /** @@ -57,8 +65,8 @@ public class WorkTaskServiceImpl extends BaseServiceImpl params = new HashMap<>(); try { @@ -194,27 +202,15 @@ public class WorkTaskServiceImpl extends BaseServiceImpl