feat(inspect): 新增新聚检验订单编辑功能并优化报告生成流程
- 新增 updateNewJuInsOrder 接口支持新聚检验订单修改
- 增加文件上传大小限制至200MB,请求大小限制至400MB
- 在设备信息中新增出厂编号字段显示
- 优化温湿度处理逻辑,报告中仅显示温度信息
- 新增印章管理功能,支持MA标志章、报告章和骑缝章配置
- 完善检验报告生成流程,增加多种报告类型常量定义
- 优化附件上传功能,增加空值检查和返回值处理
- 调整委托编号生成逻辑,完善新聚订单可编辑性判断
- 更新CNAS流程中报告编号使用正式报告编号替代委托编号
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.basic.controller; |
| | | |
| | | import com.alibaba.excel.EasyExcel; |
| | | import com.alibaba.excel.ExcelWriter; |
| | | import com.alibaba.excel.write.metadata.WriteSheet; |
| | | import com.alibaba.excel.write.style.column.LongestMatchColumnWidthStyleStrategy; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.basic.dto.SealConfigExport; |
| | | import com.ruoyi.basic.pojo.SealConfig; |
| | | import com.ruoyi.basic.service.SealConfigService; |
| | | import com.ruoyi.common.core.domain.Result; |
| | | import com.ruoyi.common.exception.base.BaseException; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.File; |
| | | import java.io.IOException; |
| | | import java.net.URLEncoder; |
| | | import java.time.LocalDateTime; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * å°ç« 管ç(æ¥åç¨å°) æ§å¶å± |
| | | */ |
| | | @Api(tags = "å°ç« 管ç") |
| | | @RestController |
| | | @RequestMapping("/sealConfig") |
| | | public class SealConfigController { |
| | | |
| | | @Resource |
| | | private SealConfigService sealConfigService; |
| | | |
| | | @Value("${file.path}") |
| | | private String filePath; |
| | | |
| | | @ApiOperation(value = "æ¥è¯¢å°ç« å表") |
| | | @GetMapping("/pageSeal") |
| | | public Result<IPage<SealConfig>> pageSeal(Page page, SealConfig query) { |
| | | return Result.success(sealConfigService.pageSeal(page, query)); |
| | | } |
| | | |
| | | @ApiOperation(value = "æ°å¢å°ç« ") |
| | | @PostMapping("/addSeal") |
| | | public Result addSeal(@RequestBody SealConfig seal) { |
| | | return Result.success(sealConfigService.addSeal(seal)); |
| | | } |
| | | |
| | | @ApiOperation(value = "ä¿®æ¹å°ç« ") |
| | | @PostMapping("/updateSeal") |
| | | public Result updateSeal(@RequestBody SealConfig seal) { |
| | | return Result.success(sealConfigService.updateSeal(seal)); |
| | | } |
| | | |
| | | @ApiOperation(value = "å é¤å°ç« ") |
| | | @DeleteMapping("/delSeal") |
| | | public Result delSeal(Integer id) { |
| | | return Result.success(sealConfigService.delSeal(id)); |
| | | } |
| | | |
| | | @ApiOperation(value = "å¯ç¨å°ç« 䏿å表ï¼ä¾æ¥åæ¹åéæ©å°ç« ï¼") |
| | | @GetMapping("/selectEnabled") |
| | | public Result selectEnabled() { |
| | | return Result.success(sealConfigService.selectEnabled()); |
| | | } |
| | | |
| | | @ApiOperation(value = "ä¸ä¼ å°ç« å¾ç") |
| | | @PostMapping("/upload") |
| | | public Result upload(MultipartFile file) { |
| | | if (file == null || file.isEmpty()) { |
| | | throw new BaseException("è¯·éæ©å°ç« å¾ç"); |
| | | } |
| | | String originalName = file.getOriginalFilename() == null ? "" : file.getOriginalFilename(); |
| | | String suffix = originalName.substring(originalName.lastIndexOf(".") + 1).toLowerCase(); |
| | | if (!"jpg".equals(suffix) && !"jpeg".equals(suffix) && !"png".equals(suffix)) { |
| | | throw new BaseException("ä»
æ¯æ jpg / png å¾ç"); |
| | | } |
| | | String fileName = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyMMddHHmmssSSS")) + "." + suffix; |
| | | try { |
| | | File dir = new File(filePath); |
| | | if (!dir.exists()) { |
| | | dir.mkdirs(); |
| | | } |
| | | file.transferTo(new File(dir.getPath() + File.separator + fileName)); |
| | | } catch (IOException e) { |
| | | throw new BaseException("å°ç« å¾çä¸ä¼ 失败"); |
| | | } |
| | | return Result.success(fileName); |
| | | } |
| | | |
| | | @ApiOperation(value = "导åºå°ç« ") |
| | | @GetMapping("/exportSeal") |
| | | public void exportSeal(SealConfig query, HttpServletResponse response) { |
| | | List<SealConfigExport> list = sealConfigService.listForExport(query); |
| | | response.setContentType("application/vnd.ms-excel"); |
| | | response.setCharacterEncoding("UTF-8"); |
| | | String fileName; |
| | | try { |
| | | fileName = URLEncoder.encode("å°ç« 管ç", "UTF-8"); |
| | | } catch (Exception e) { |
| | | throw new BaseException("导åºå¤±è´¥"); |
| | | } |
| | | response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx"); |
| | | try { |
| | | ExcelWriter excelWriter = EasyExcel.write(response.getOutputStream()) |
| | | .registerWriteHandler(new LongestMatchColumnWidthStyleStrategy()).build(); |
| | | WriteSheet mainSheet = EasyExcel.writerSheet(0, "å°ç« 管ç").head(SealConfigExport.class).build(); |
| | | excelWriter.write(list, mainSheet); |
| | | excelWriter.finish(); |
| | | } catch (IOException e) { |
| | | throw new BaseException("导åºå¤±è´¥"); |
| | | } |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.basic.dto; |
| | | |
| | | import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; |
| | | import com.alibaba.excel.annotation.ExcelProperty; |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * å°ç« 管ç导åºå¯¹è±¡ |
| | | */ |
| | | @Data |
| | | @ExcelIgnoreUnannotated |
| | | public class SealConfigExport { |
| | | |
| | | @ExcelProperty(value = "å°ç« ç¼å·") |
| | | private String code; |
| | | |
| | | @ExcelProperty(value = "å°ç« åç§°") |
| | | private String name; |
| | | |
| | | @ExcelProperty(value = "使ç¨èå´") |
| | | private String useScope; |
| | | |
| | | @ExcelProperty(value = "ç¶æ") |
| | | private String statusName; |
| | | |
| | | @ExcelProperty(value = "夿³¨") |
| | | private String remark; |
| | | |
| | | @ExcelProperty(value = "å建æ¶é´") |
| | | private String createTime; |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.basic.mapper; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.ruoyi.basic.pojo.SealConfig; |
| | | |
| | | /** |
| | | * å°ç« 管ç(æ¥åç¨å°) Mapper |
| | | */ |
| | | public interface SealConfigMapper extends BaseMapper<SealConfig> { |
| | | |
| | | /** |
| | | * æ¥è¯¢å½åæå¤§çå°ç« ç¼å·åç¼æ°åï¼ç¨äºèªå¨çæ YZ-00Nï¼ã |
| | | */ |
| | | Integer selectMaxCodeSuffix(); |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.basic.pojo; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.FieldFill; |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | import java.time.LocalDateTime; |
| | | |
| | | /** |
| | | * å°ç« 管ç(æ¥åç¨å°)表对象 |
| | | * |
| | | * <p>åºå«äºæå®éªå®¤ç»´æ¤çæ§ seal è¡¨ï¼æ¬è¡¨ç¨äºéä¸ç»´æ¤åºå
·æ¥åæéçåç±»å°ç« ï¼ |
| | | * ä¾âæ¥åç¼å¶-æ¹åâæ¶çå°ç« å¤éä¸æä½¿ç¨ï¼ä»
å¯ç¨ç¶æçå°ç« å¯éï¼ã</p> |
| | | */ |
| | | @TableName(value = "cnas_seal") |
| | | @Data |
| | | public class SealConfig implements Serializable { |
| | | |
| | | @ApiModelProperty(value = "主é®") |
| | | @TableId(type = IdType.AUTO) |
| | | private Integer id; |
| | | |
| | | @ApiModelProperty(value = "å°ç« ç¼å·ï¼ä¿åæ¶èªå¨çæï¼å¦ YZ-001ï¼") |
| | | private String code; |
| | | |
| | | @ApiModelProperty(value = "å°ç« åç§°") |
| | | private String name; |
| | | |
| | | @ApiModelProperty(value = "å°ç« å¾çï¼ç¸å¯¹ file.path çæä»¶åï¼") |
| | | private String address; |
| | | |
| | | @ApiModelProperty(value = "使ç¨èå´") |
| | | private String useScope; |
| | | |
| | | @ApiModelProperty(value = "ç¶æï¼1å¯ç¨ 0åç¨") |
| | | private Integer status; |
| | | |
| | | @ApiModelProperty(value = "夿³¨") |
| | | private String remark; |
| | | |
| | | @ApiModelProperty(value = "å建人id") |
| | | @TableField(fill = FieldFill.INSERT) |
| | | private Integer createUser; |
| | | |
| | | @ApiModelProperty(value = "å建æ¶é´") |
| | | @TableField(fill = FieldFill.INSERT) |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | private LocalDateTime createTime; |
| | | |
| | | @ApiModelProperty(value = "æ´æ°äººid") |
| | | @TableField(fill = FieldFill.INSERT_UPDATE) |
| | | private Integer updateUser; |
| | | |
| | | @ApiModelProperty(value = "æ´æ°æ¶é´") |
| | | @TableField(fill = FieldFill.INSERT_UPDATE) |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | private LocalDateTime updateTime; |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.basic.service; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.ruoyi.basic.dto.SealConfigExport; |
| | | import com.ruoyi.basic.pojo.SealConfig; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * å°ç« 管ç(æ¥åç¨å°) æå¡ç±» |
| | | */ |
| | | public interface SealConfigService extends IService<SealConfig> { |
| | | |
| | | IPage<SealConfig> pageSeal(Page page, SealConfig query); |
| | | |
| | | int addSeal(SealConfig seal); |
| | | |
| | | int updateSeal(SealConfig seal); |
| | | |
| | | int delSeal(Integer id); |
| | | |
| | | /** |
| | | * æ¥è¯¢å¯ç¨ç¶æçå°ç« ï¼ä¾æ¥åæ¹åå°ç« å¤éä¸æä½¿ç¨ï¼ã |
| | | */ |
| | | List<SealConfig> selectEnabled(); |
| | | |
| | | /** |
| | | * ææ¡ä»¶æ¥è¯¢å¯¼åºå表ã |
| | | */ |
| | | List<SealConfigExport> listForExport(SealConfig query); |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.basic.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.basic.dto.SealConfigExport; |
| | | import com.ruoyi.basic.mapper.SealConfigMapper; |
| | | import com.ruoyi.basic.pojo.SealConfig; |
| | | import com.ruoyi.basic.service.SealConfigService; |
| | | import com.ruoyi.common.exception.base.BaseException; |
| | | import com.ruoyi.common.utils.QueryWrappers; |
| | | import com.baomidou.mybatisplus.core.toolkit.StringUtils; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * å°ç« 管ç(æ¥åç¨å°) æå¡å®ç° |
| | | */ |
| | | @Service |
| | | public class SealConfigServiceImpl extends ServiceImpl<SealConfigMapper, SealConfig> implements SealConfigService { |
| | | |
| | | @Resource |
| | | private SealConfigMapper sealConfigMapper; |
| | | |
| | | private static final DateTimeFormatter DATE_FORMAT = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); |
| | | |
| | | @Override |
| | | public IPage<SealConfig> pageSeal(Page page, SealConfig query) { |
| | | QueryWrapper<SealConfig> wrapper = QueryWrappers.queryWrappers(query); |
| | | if (wrapper == null) { |
| | | wrapper = Wrappers.query(); |
| | | } |
| | | wrapper.orderByDesc("create_time").orderByAsc("code"); |
| | | return this.page(page, wrapper); |
| | | } |
| | | |
| | | @Override |
| | | public int addSeal(SealConfig seal) { |
| | | validate(seal); |
| | | seal.setCode(generateCode()); |
| | | return sealConfigMapper.insert(seal); |
| | | } |
| | | |
| | | @Override |
| | | public int updateSeal(SealConfig seal) { |
| | | if (seal.getId() == null) { |
| | | throw new BaseException("å°ç« idä¸è½ä¸ºç©º"); |
| | | } |
| | | validate(seal); |
| | | // ç¼å·ä¸å
许å端修æ¹ï¼ä¿æèªå¨çæå¼ä¸å |
| | | SealConfig db = sealConfigMapper.selectById(seal.getId()); |
| | | if (db != null) { |
| | | seal.setCode(db.getCode()); |
| | | } |
| | | return sealConfigMapper.updateById(seal); |
| | | } |
| | | |
| | | @Override |
| | | public int delSeal(Integer id) { |
| | | return sealConfigMapper.deleteById(id); |
| | | } |
| | | |
| | | @Override |
| | | public List<SealConfig> selectEnabled() { |
| | | return this.list(Wrappers.<SealConfig>lambdaQuery() |
| | | .eq(SealConfig::getStatus, 1) |
| | | .orderByAsc(SealConfig::getCode)); |
| | | } |
| | | |
| | | @Override |
| | | public List<SealConfigExport> listForExport(SealConfig query) { |
| | | QueryWrapper<SealConfig> wrapper = QueryWrappers.queryWrappers(query); |
| | | if (wrapper == null) { |
| | | wrapper = Wrappers.query(); |
| | | } |
| | | wrapper.orderByAsc("code"); |
| | | List<SealConfig> list = this.list(wrapper); |
| | | List<SealConfigExport> exports = new ArrayList<>(); |
| | | for (SealConfig seal : list) { |
| | | SealConfigExport export = new SealConfigExport(); |
| | | export.setCode(seal.getCode()); |
| | | export.setName(seal.getName()); |
| | | export.setUseScope(seal.getUseScope()); |
| | | export.setStatusName(seal.getStatus() != null && seal.getStatus() == 1 ? "å¯ç¨" : "åç¨"); |
| | | export.setRemark(seal.getRemark()); |
| | | export.setCreateTime(seal.getCreateTime() == null ? "" : seal.getCreateTime().format(DATE_FORMAT)); |
| | | exports.add(export); |
| | | } |
| | | return exports; |
| | | } |
| | | |
| | | private void validate(SealConfig seal) { |
| | | if (StringUtils.isBlank(seal.getName())) { |
| | | throw new BaseException("å°ç« åç§°ä¸è½ä¸ºç©º"); |
| | | } |
| | | if (StringUtils.isBlank(seal.getAddress())) { |
| | | throw new BaseException("å°ç« å¾çä¸è½ä¸ºç©º"); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * èªå¨çæå°ç« ç¼å·ï¼YZ-001ãYZ-002 ... |
| | | */ |
| | | private String generateCode() { |
| | | Integer max = sealConfigMapper.selectMaxCodeSuffix(); |
| | | int next = (max == null ? 0 : max) + 1; |
| | | return String.format("YZ-%03d", next); |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper |
| | | PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" |
| | | "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.ruoyi.basic.mapper.SealConfigMapper"> |
| | | |
| | | <select id="selectMaxCodeSuffix" resultType="java.lang.Integer"> |
| | | select ifnull(max(cast(substring(code, 4) as unsigned)), 0) |
| | | from cnas_seal |
| | | where code like 'YZ-%' |
| | | </select> |
| | | </mapper> |
| | |
| | | processReportService.exportProcessReport(dto, response); |
| | | } |
| | | |
| | | @ApiOperation(value = "ä¸è½½æ¹ååçæç« æ¥å") |
| | | @GetMapping("/downloadStampedReport") |
| | | public void downloadStampedReport(Integer id, String format, HttpServletResponse response) { |
| | | processReportService.downloadStampedReport(id, format, response); |
| | | } |
| | | |
| | | } |
| | |
| | | return; |
| | | } |
| | | // å¹çï¼å䏿å订åå·²ææ£éªå§æååè·³è¿ |
| | | Long count = inspectionOrderMapper.selectCount(Wrappers.<InspectionOrder>lambdaQuery() |
| | | .eq(InspectionOrder::getInsOrderId, order.getId())); |
| | | if (count > 0) { |
| | | InspectionOrder existingOrder = inspectionOrderMapper.selectOne(Wrappers.<InspectionOrder>lambdaQuery() |
| | | .eq(InspectionOrder::getInsOrderId, order.getId()).last("limit 1")); |
| | | if (existingOrder != null) { |
| | | existingOrder.setEntrustCode(order.getEntrustCode()); |
| | | existingOrder.setSampleName(StringUtils.isNotBlank(order.getSampleView()) ? order.getSampleView() : order.getSample()); |
| | | existingOrder.setProduction(order.getProduction()); |
| | | existingOrder.setQuantity(order.getTestQuantity()); |
| | | existingOrder.setCommissionUnit(order.getCompany()); |
| | | existingOrder.setCommissionUser(order.getPrepareUser()); |
| | | existingOrder.setCommissionPhone(order.getPhone()); |
| | | existingOrder.setIsLeave(Integer.valueOf(1).equals(order.getIsLeave()) ? 1 : 2); |
| | | existingOrder.setProcessing(Integer.valueOf(1).equals(order.getSampleDisposal()) ? 0 : 1); |
| | | existingOrder.setSend(Integer.valueOf(1).equals(order.getReportDelivery()) ? 1 : 0); |
| | | inspectionOrderMapper.updateById(existingOrder); |
| | | return; |
| | | } |
| | | InspectionOrder inspectionOrder = new InspectionOrder(); |
| | |
| | | @ApiModelProperty("æ£éªæ¥åç¼å·") |
| | | private String insReportCode; |
| | | |
| | | @ApiModelProperty("页æ°") |
| | | private String pages; |
| | | |
| | | @ApiModelProperty("åé份æ°") |
| | | private String number; |
| | | |
| | | @ApiModelProperty("åå¾ä½å¤") |
| | | private String send; |
| | | |
| | |
| | | |
| | | @ApiModelProperty("å§æåid") |
| | | private Integer inspectionOrderId; |
| | | |
| | | @ApiModelProperty("颿¥åæ¥æ") |
| | | @JsonFormat(pattern = "yyyy-MM-dd") |
| | | private LocalDate receiveDate; |
| | | |
| | | @ApiModelProperty("颿¥å人") |
| | | private String receiveUser; |
| | | |
| | | } |
| | |
| | | IPage<ProcessReportDto> pageProcessReport(Page page, ProcessReportDto processReport); |
| | | |
| | | void exportProcessReport(ProcessReportDto dto, HttpServletResponse response); |
| | | |
| | | /** ä¸è½½æ¹ååçæçæç« æ¥åï¼formatï¼pdf æ wordã */ |
| | | void downloadStampedReport(Integer id, String format, HttpServletResponse response); |
| | | } |
| | |
| | | /*æ°å¢7.8æ¥åç»æ*/ |
| | | ProcessReport processReport = new ProcessReport(); |
| | | processReport.setInspectionOrderId(inspectionOrder.getInsOrderId()); |
| | | processReport.setInsReportCode(inspectionOrder.getEntrustCode());//æ¥åç¼å·=å§æç¼å· |
| | | //é¡µæ° |
| | | try { |
| | | com.aspose.words.Document doc = new com.aspose.words.Document(path); |
| | | processReport.setPages(doc.getPageCount()+""); |
| | | } catch (Exception e) { |
| | | } |
| | | processReport.setNumber("1");//åé份æ°é»è®¤1 |
| | | processReport.setInsReportCode(insReport.getCode());//æ¥åç¼å·ä½¿ç¨æ£å¼æ¥åç¼å· |
| | | processReport.setSend(inspectionOrder.getCommissionUnit());//åå¾ä½å¤=å§æåä½ |
| | | processReport.setMethod(inspectionOrder.getSend()==1?"èªå":"å
¶ä»");//åéæ¹å¼ |
| | | processReport.setSendTime(insReport.getRatifyTime().toLocalDate());//å鿥æ |
| | |
| | | inspectionOrderDetailService.saveBatch(InspectionOrder.getOrderDetailList()); |
| | | |
| | | //ä¿®æ¹7.9æ¥åç»æ |
| | | ProcessReport processReport = processReportService.getOne(Wrappers.<ProcessReport>lambdaQuery().eq(ProcessReport::getInspectionOrderId, InspectionOrder.getInspectionOrderId())); |
| | | processReport.setInsReportCode(InspectionOrder.getEntrustCode());//æ¥åç¼å·=å§æç¼å· |
| | | ProcessReport processReport = processReportService.getOne(Wrappers.<ProcessReport>lambdaQuery() |
| | | .eq(ProcessReport::getInspectionOrderId, InspectionOrder.getInsOrderId()) |
| | | .last("limit 1")); |
| | | InsReport insReport = insReportService.getOne(Wrappers.<InsReport>lambdaQuery() |
| | | .eq(InsReport::getInsOrderId, InspectionOrder.getInsOrderId()) |
| | | .orderByDesc(InsReport::getId) |
| | | .last("limit 1")); |
| | | if (processReport != null && insReport != null) { |
| | | processReport.setInsReportCode(insReport.getCode());//æ¥åç¼å·ä½¿ç¨æ£å¼æ¥åç¼å· |
| | | processReportService.updateById(processReport); |
| | | } |
| | | |
| | | return true; |
| | | } |
| | |
| | | import com.ruoyi.common.utils.QueryWrappers; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.common.utils.SignatureImageUtil; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.ruoyi.framework.exception.ErrorException; |
| | | import com.ruoyi.inspect.mapper.InsOrderMapper; |
| | | import com.ruoyi.inspect.mapper.InsReportMapper; |
| | | import com.ruoyi.inspect.pojo.InsOrder; |
| | | import com.ruoyi.inspect.pojo.InsReport; |
| | | import com.ruoyi.inspect.util.HackLoopTableRenderPolicy; |
| | | import com.ruoyi.process.dto.ProcessReportDto; |
| | | import com.ruoyi.process.mapper.ProcessReportMapper; |
| | |
| | | import java.io.*; |
| | | import java.net.URLEncoder; |
| | | import java.nio.file.Files; |
| | | import java.nio.file.Path; |
| | | import java.nio.file.Paths; |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.HashSet; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Set; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | |
| | | private ProcessReportMapper processReportMapper; |
| | | @Value("${file.path}") |
| | | private String imgUrl; |
| | | @Value("${wordUrl}") |
| | | private String wordUrl; |
| | | |
| | | @Resource |
| | | private UserMapper userMapper; |
| | | |
| | | @Resource |
| | | private InsReportMapper insReportMapper; |
| | | |
| | | @Resource |
| | | private InsOrderMapper insOrderMapper; |
| | | |
| | | @Override |
| | | public IPage<ProcessReportDto> pageProcessReport(Page page, ProcessReportDto processReport) { |
| | | // #21 æå¼å表æ¶ï¼èªå¨å¸¦åºå·²éè¿å®¡æ¹ï¼æ¹åç¶æ=æ¹åï¼ä½å°æªç»è®°çæ£éªå |
| | | autoBringOutApproved(); |
| | | IPage<ProcessReportDto> processReportIPage = processReportMapper.pageProcessReport(page, QueryWrappers.queryWrappers(processReport)); |
| | | |
| | | return processReportIPage; |
| | | } |
| | | |
| | | /** |
| | | * æ«æå·²æ¹åä½å°æªè¿å
¥æ¥åç»æç»è®°è¡¨çæ£éªæ¥åï¼èªå¨çæå¾
ç»è®°è®°å½ï¼ä»¥æ¥åç¼å·å»éï¼å¹çï¼ã |
| | | */ |
| | | private void autoBringOutApproved() { |
| | | List<InsReport> approved = insReportMapper.selectList(Wrappers.<InsReport>lambdaQuery() |
| | | .eq(InsReport::getIsRatify, 1) |
| | | .eq(InsReport::getIsPass, 1)); |
| | | if (approved.isEmpty()) { |
| | | return; |
| | | } |
| | | Set<String> existing = this.list(Wrappers.<ProcessReport>lambdaQuery() |
| | | .select(ProcessReport::getInsReportCode)).stream() |
| | | .map(ProcessReport::getInsReportCode) |
| | | .filter(StringUtils::isNotBlank) |
| | | .collect(Collectors.toCollection(HashSet::new)); |
| | | for (InsReport report : approved) { |
| | | String code = report.getCode(); |
| | | if (StringUtils.isBlank(code) || existing.contains(code)) { |
| | | continue; |
| | | } |
| | | ProcessReport pr = new ProcessReport(); |
| | | pr.setInsReportCode(code); |
| | | pr.setInspectionOrderId(report.getInsOrderId()); |
| | | if (report.getRatifyTime() != null) { |
| | | pr.setSendTime(report.getRatifyTime().toLocalDate()); |
| | | } |
| | | if (report.getInsOrderId() != null) { |
| | | InsOrder order = insOrderMapper.selectById(report.getInsOrderId()); |
| | | if (order != null) { |
| | | pr.setSend(order.getCompany()); |
| | | pr.setMethod(getReportDeliveryName(order)); |
| | | } |
| | | } |
| | | this.save(pr); |
| | | existing.add(code); |
| | | } |
| | | } |
| | | |
| | | private String getReportDeliveryName(InsOrder order) { |
| | | if (order.getReportDelivery() != null) { |
| | | switch (order.getReportDelivery()) { |
| | | case 1: |
| | | return "èªå"; |
| | | case 2: |
| | | return "å¿«é"; |
| | | case 3: |
| | | return "çµåä¼ é"; |
| | | default: |
| | | break; |
| | | } |
| | | } |
| | | // å
¼å®¹å°æªç»´æ¤ report_delivery çåå²å§æåã |
| | | return order.getSend() != null && order.getSend() == 1 ? "èªå" : "å
¶ä»"; |
| | | } |
| | | |
| | | @Override |
| | | public void downloadStampedReport(Integer id, String format, HttpServletResponse response) { |
| | | if (id == null) { |
| | | throw new ErrorException("æ¥åç»æä¸è½ä¸ºç©º"); |
| | | } |
| | | ProcessReport processReport = getById(id); |
| | | if (processReport == null) { |
| | | throw new ErrorException("æ¥åç»æä¸åå¨"); |
| | | } |
| | | if (StringUtils.isBlank(processReport.getInsReportCode()) |
| | | && processReport.getInspectionOrderId() == null) { |
| | | throw new ErrorException("è¯¥è®°å½æªå
³èæ£éªæ¥åï¼æ æ³ä¸è½½"); |
| | | } |
| | | |
| | | String downloadFormat = StringUtils.isBlank(format) ? "pdf" : format.trim().toLowerCase(); |
| | | if (!"pdf".equals(downloadFormat) && !"word".equals(downloadFormat)) { |
| | | throw new ErrorException("ä¸è½½æ ¼å¼ä¸æ£ç¡®"); |
| | | } |
| | | |
| | | com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper<InsReport> query = |
| | | Wrappers.<InsReport>lambdaQuery() |
| | | .eq(InsReport::getIsRatify, 1) |
| | | .eq(StringUtils.isNotBlank(processReport.getInsReportCode()), |
| | | InsReport::getCode, processReport.getInsReportCode()) |
| | | .eq(processReport.getInspectionOrderId() != null, |
| | | InsReport::getInsOrderId, processReport.getInspectionOrderId()) |
| | | .orderByDesc(InsReport::getId) |
| | | .last("limit 1"); |
| | | InsReport report = insReportMapper.selectOne(query); |
| | | if (report == null) { |
| | | throw new ErrorException("æªæ¾å°å·²æ¹åçæ¥åï¼æ æ³ä¸è½½æç« æ¥å"); |
| | | } |
| | | |
| | | String fileUrl; |
| | | String extension; |
| | | String contentType; |
| | | if ("word".equals(downloadFormat)) { |
| | | fileUrl = StringUtils.isNotBlank(report.getUrlS()) ? report.getUrlS() : report.getUrl(); |
| | | extension = ".docx"; |
| | | contentType = "application/vnd.openxmlformats-officedocument.wordprocessingml.document"; |
| | | } else { |
| | | fileUrl = report.getTempUrlPdf(); |
| | | extension = ".pdf"; |
| | | contentType = "application/pdf"; |
| | | } |
| | | if ("pdf".equals(downloadFormat) && StringUtils.isBlank(fileUrl)) { |
| | | String reportUrl = StringUtils.isNotBlank(report.getUrlS()) ? report.getUrlS() : report.getUrl(); |
| | | if (StringUtils.isNotBlank(reportUrl) && reportUrl.toLowerCase().endsWith(".docx")) { |
| | | fileUrl = reportUrl.substring(0, reportUrl.length() - 5) + ".pdf"; |
| | | } |
| | | } |
| | | if (StringUtils.isBlank(fileUrl) || !fileUrl.replace('\\', '/').startsWith("/word/")) { |
| | | throw new ErrorException("æç« æ¥åå°æªçæï¼è¯·å
宿æ¥åæ¹å"); |
| | | } |
| | | |
| | | Path root = Paths.get(wordUrl).toAbsolutePath().normalize(); |
| | | Path file = root.resolve(fileUrl.replace('\\', '/').substring("/word/".length())).normalize(); |
| | | if (!file.startsWith(root) || !Files.isRegularFile(file)) { |
| | | throw new ErrorException("æç« æ¥åæä»¶ä¸åå¨ï¼è¯·éæ°æ¹åçæ"); |
| | | } |
| | | |
| | | try { |
| | | String filename = StringUtils.isNotBlank(processReport.getInsReportCode()) |
| | | ? processReport.getInsReportCode() + extension : file.getFileName().toString(); |
| | | String encodedName = URLEncoder.encode(filename, "UTF-8").replace("+", "%20"); |
| | | response.setContentType(contentType); |
| | | response.setHeader("Content-Disposition", "attachment; filename*=UTF-8''" + encodedName); |
| | | response.setHeader("Access-Control-Expose-Headers", "Content-Disposition,download-filename"); |
| | | response.setHeader("download-filename", encodedName); |
| | | response.setContentLengthLong(Files.size(file)); |
| | | try (InputStream inputStream = Files.newInputStream(file); |
| | | OutputStream outputStream = response.getOutputStream()) { |
| | | IOUtils.copy(inputStream, outputStream); |
| | | outputStream.flush(); |
| | | } |
| | | } catch (IOException e) { |
| | | throw new ErrorException("æç« æ¥åä¸è½½å¤±è´¥"); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void exportProcessReport(ProcessReportDto dto, HttpServletResponse response) { |
| | | List<ProcessReportDto> processReports = processReportMapper.exportProcessReport(); |
| | |
| | | <resultMap id="BaseResultMap" type="com.ruoyi.process.pojo.ProcessReport"> |
| | | <id column="id" property="id"/> |
| | | <result column="ins_report_code" property="insReportCode"/> |
| | | <result column="pages" property="pages"/> |
| | | <result column="number" property="number"/> |
| | | <result column="send" property="send"/> |
| | | <result column="method" property="method"/> |
| | | <result column="send_time" property="sendTime"/> |
| | |
| | | <result column="update_time" property="updateTime"/> |
| | | </resultMap> |
| | | <select id="pageProcessReport" resultType="com.ruoyi.process.dto.ProcessReportDto"> |
| | | select * from (select cpr.* , |
| | | select * from (select cpr.id, |
| | | cpr.ins_report_code, |
| | | cpr.send, |
| | | case io.report_delivery |
| | | when 1 then 'èªå' |
| | | when 2 then 'å¿«é' |
| | | when 3 then 'çµåä¼ é' |
| | | else cpr.method |
| | | end method, |
| | | cpr.send_time, |
| | | cpr.send_user, |
| | | cpr.signatory, |
| | | cpr.remark, |
| | | cpr.create_user, |
| | | cpr.create_time, |
| | | cpr.update_user, |
| | | cpr.update_time, |
| | | cpr.inspection_order_id, |
| | | cpr.receive_date, |
| | | cpr.receive_user, |
| | | u1.name sendUserName |
| | | from cnas_process_report cpr |
| | | left join user u1 on send_user=u1.id )A |
| | | left join user u1 on send_user=u1.id |
| | | inner join ins_report ir on ir.code = cpr.ins_report_code |
| | | and ir.ins_order_id = cpr.inspection_order_id |
| | | and ir.is_ratify = 1 and ir.is_pass = 1 |
| | | left join ins_order io on io.id = ir.ins_order_id )A |
| | | <if test="ew.customSqlSegment != null and ew.customSqlSegment != ''"> |
| | | ${ew.customSqlSegment} |
| | | </if> |
| | | </select> |
| | | <select id="exportProcessReport" resultType="com.ruoyi.process.dto.ProcessReportDto"> |
| | | select ROW_NUMBER() OVER (ORDER BY cpr.id) AS indexs, |
| | | cpr.* , |
| | | cpr.id, |
| | | cpr.ins_report_code, |
| | | cpr.send, |
| | | case io.report_delivery |
| | | when 1 then 'èªå' |
| | | when 2 then 'å¿«é' |
| | | when 3 then 'çµåä¼ é' |
| | | else cpr.method |
| | | end method, |
| | | cpr.send_time, |
| | | cpr.send_user, |
| | | cpr.signatory, |
| | | cpr.remark, |
| | | cpr.create_user, |
| | | cpr.create_time, |
| | | cpr.update_user, |
| | | cpr.update_time, |
| | | cpr.inspection_order_id, |
| | | cpr.receive_date, |
| | | cpr.receive_user, |
| | | u1.signature_url sendUserUrl |
| | | from cnas_process_report cpr |
| | | left join user u1 on send_user=u1.id |
| | | inner join ins_report ir on ir.code = cpr.ins_report_code |
| | | and ir.ins_order_id = cpr.inspection_order_id |
| | | and ir.is_ratify = 1 and ir.is_pass = 1 |
| | | left join ins_order io on io.id = ir.ins_order_id |
| | | </select> |
| | | </mapper> |
| | |
| | | return Result.success(insOrderService.addInsOrder(insPlaceOrderDto.getSampleList(), insPlaceOrderDto.getInsOrder())); |
| | | } |
| | | |
| | | @ApiOperation(value = "ä¿®æ¹æ°èæ£éªä¸åæ°æ®") |
| | | @PostMapping("/updateNewJuInsOrder") |
| | | public Result<?> updateNewJuInsOrder(@RequestBody InsPlaceOrderDto insPlaceOrderDto) { |
| | | return Result.success(insOrderService.updateNewJuInsOrder(insPlaceOrderDto)); |
| | | } |
| | | |
| | | @ApiOperation(value = "æ¥è¯¢è®¢åæé¿é¢è®¡æ¶é´") |
| | | @GetMapping("/selectOrderManDay") |
| | | public Result<?> selectOrderManDay(Integer id) { |
| | |
| | | return Result.success(map); |
| | | } |
| | | |
| | | @ApiOperation(value = "填忏©åº¦ä¸æ¹¿åº¦") |
| | | @ApiOperation(value = "填忏©åº¦") |
| | | @PostMapping("/write") |
| | | public Result<?> write(@RequestBody WriteInspectionConditionDto dto) { |
| | | return Result.success(insProductService.write(dto)); |
| | |
| | | Integer id = (Integer) param.get("id"); |
| | | Integer isRatify = (Integer) param.get("isRatify"); |
| | | String ratifyTell = (String) param.get("ratifyTell"); |
| | | return Result.success(insReportService.ratifyReport(id, isRatify, ratifyTell)); |
| | | Object sealIdsObj = param.get("sealIds"); |
| | | String sealIds = sealIdsObj == null ? null : String.valueOf(sealIdsObj); |
| | | Integer maSealId = toInteger(param.get("maSealId")); |
| | | Integer reportSealId = toInteger(param.get("reportSealId")); |
| | | Integer seamSealId = toInteger(param.get("seamSealId")); |
| | | return Result.success(insReportService.ratifyReport( |
| | | id, isRatify, ratifyTell, sealIds, maSealId, reportSealId, seamSealId)); |
| | | } |
| | | |
| | | private Integer toInteger(Object value) { |
| | | if (value == null || String.valueOf(value).trim().isEmpty()) { |
| | | return null; |
| | | } |
| | | return value instanceof Number ? ((Number) value).intValue() : Integer.valueOf(String.valueOf(value)); |
| | | } |
| | | |
| | | @Anonymous |
| | |
| | | @Data |
| | | public class InsPlaceOrderDto{ |
| | | |
| | | @ApiModelProperty("ç¼è¾ç订åID") |
| | | private Integer orderId; |
| | | |
| | | @ApiModelProperty("æ ·å") |
| | | private List<SampleProductDto> sampleList; |
| | | |
| | |
| | | @ExcelIgnoreUnannotated |
| | | public class SampleOrderDto extends InsOrder { |
| | | |
| | | @ApiModelProperty("æ¯å¦å
许ç¼è¾") |
| | | private Boolean editable; |
| | | |
| | | @ApiModelProperty("æ£éªå¯¹è±¡") |
| | | private String sampleType; |
| | | |
| | |
| | | private Integer templateId; |
| | | private String remark; |
| | | private String temperature; |
| | | private String humidity; |
| | | |
| | | @JsonFormat(pattern = "yyyy-MM-dd") |
| | | private LocalDate detectionTime; |
| | |
| | | |
| | | @JsonIgnore |
| | | private boolean temperaturePresent; |
| | | @JsonIgnore |
| | | private boolean humidityPresent; |
| | | @JsonIgnore |
| | | private boolean detectionTimePresent; |
| | | @JsonIgnore |
| | |
| | | public void setTemperature(String temperature) { |
| | | this.temperature = temperature; |
| | | this.temperaturePresent = true; |
| | | } |
| | | |
| | | public void setHumidity(String humidity) { |
| | | this.humidity = humidity; |
| | | this.humidityPresent = true; |
| | | } |
| | | |
| | | public void setDetectionTime(LocalDate detectionTime) { |
| | |
| | | @ApiModelProperty(value = "æ¯å¦æ¯éè¿çæ¥å, 0:æªéè¿, 1:éè¿") |
| | | private Integer isPass; |
| | | |
| | | @ApiModelProperty(value = "æ¹åæ¶éç¨çå°ç« idï¼å¤éï¼éå·åéï¼") |
| | | private String sealIds; |
| | | |
| | | @ApiModelProperty(value = "æ¹åæ¶éç¨çå°ç« åç§°ï¼å¤ä¸ªï¼éå·åéï¼") |
| | | private String sealNames; |
| | | |
| | | @ApiModelProperty(value = "MAæ å¿ç« idï¼PDF第1页左ä¸è§ï¼") |
| | | private Integer maSealId; |
| | | |
| | | @ApiModelProperty(value = "MAæ å¿ç« åç§°") |
| | | private String maSealName; |
| | | |
| | | @ApiModelProperty(value = "æ¥åç« idï¼å¯¹åºæ¨¡æ¿ seal1ãseal2ï¼") |
| | | private Integer reportSealId; |
| | | |
| | | @ApiModelProperty(value = "æ¥åç« åç§°") |
| | | private String reportSealName; |
| | | |
| | | @ApiModelProperty(value = "PDFéªç¼ç« çå°ç« id") |
| | | private Integer seamSealId; |
| | | |
| | | @ApiModelProperty(value = "PDFéªç¼ç« çå°ç« åç§°") |
| | | private String seamSealName; |
| | | |
| | | } |
| | |
| | | |
| | | int addNewJuInsOrder(InsPlaceOrderDto insPlaceOrderDto); |
| | | |
| | | int updateNewJuInsOrder(InsPlaceOrderDto insPlaceOrderDto); |
| | | |
| | | Map<String, Object> getInsOrder(Integer id); |
| | | |
| | | int upInsOrderOfState(InsOrder insOrder); |
| | |
| | | |
| | | Map<String,Object> pageInsReport(Page page, ReportPageDto reportPageDto); |
| | | |
| | | void wordToPdf(String path,String sealUrl, boolean isRawMater); |
| | | void wordToPdf(String path, String maSealUrl, String seamSealUrl, boolean isRawMater); |
| | | |
| | | int inReport(String url, Integer id); |
| | | |
| | |
| | | int examineReport(Integer id, Integer isExamine, String examineTell, Integer userId); |
| | | |
| | | //æ¹å |
| | | int ratifyReport(Integer id, Integer isRatify, String ratifyTell); |
| | | int ratifyReport(Integer id, Integer isRatify, String ratifyTell, String sealIds, |
| | | Integer maSealId, Integer reportSealId, Integer seamSealId); |
| | | |
| | | int wordInsertUrl(Map<String, Object> map, String url); |
| | | |
| | |
| | | import java.util.concurrent.atomic.AtomicReference; |
| | | import java.util.regex.Pattern; |
| | | import java.util.stream.Collectors; |
| | | import java.util.stream.Stream; |
| | | |
| | | /** |
| | | * æ£éªä»»å¡-ä¸å¡å®ç°å± |
| | |
| | | |
| | | @Override |
| | | public int uploadFile(Integer orderId, MultipartFile file) { |
| | | if (orderId == null || file == null || file.isEmpty()) { |
| | | throw new ErrorException("è¯·éæ©è¦ä¸ä¼ çéä»¶"); |
| | | } |
| | | String urlString; |
| | | String pathName; |
| | | String path; |
| | |
| | | urlString = realpath + "/" + pathName; |
| | | file.transferTo(new File(urlString)); |
| | | insOrderFile.setFileUrl(pathName); |
| | | return insOrderFileMapper.insert(insOrderFile); |
| | | return insOrderFileMapper.insert(insOrderFile) > 0 ? insOrderFile.getId() : 0; |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | System.err.println("éä»¶ä¸ä¼ é误"); |
| | |
| | | boolean directTemplateOrder = isDirectTemplateOrder(orderId); |
| | | if (currentState != null && Objects.equals(currentState.getInsState(), 5) |
| | | && existingReport != null && StringUtils.isNotBlank(existingReport.getUrl()) |
| | | && Objects.equals(existingReport.getIsPass(), 1) |
| | | && (!directTemplateOrder || StringUtils.isNotBlank(existingReport.getInspectionUrl()))) { |
| | | // 鲿¢å¤æ ¸é¡µé¢éå¤ç¹å»æç½ç»éè¯éå¤çææ¥åãéå¤åèµ·æ¥å审æ¹ã |
| | | // ä»
对ä»å¨æ¥åç¼å¶ä¸çè®°å½é²éå¤ï¼é忣éªä»»å¡çæ¥åéè¦ç»§ç»æ§è¡å¹¶æ¢å¤ is_passã |
| | | return 1; |
| | | } |
| | | if (directTemplateOrder && Objects.equals(type, 1) |
| | |
| | | if (StringUtils.isBlank(tempPdfName)) { |
| | | throw new ErrorException("æ¥åé¢è§æä»¶çæå¤±è´¥"); |
| | | } |
| | | // generateReport ä¼åå
¥å½åæ¶é´ï¼éæ°çæä¸åºæ¹åå审æ¹è®°å½æ¶é´ã |
| | | // generateReport ä¼åå
¥å½åæ¶é´ï¼é¨åæ¥åè¿ä¼ææ¶åå
¥ is_pass=0ï¼ |
| | | // éæ°çæä¸åºæ¹åå审æ¹è®°å½æ¶é´åå¯è§ç¶æã |
| | | insReportMapper.update(null, Wrappers.<InsReport>lambdaUpdate() |
| | | .eq(InsReport::getId, reportId) |
| | | .set(InsReport::getWriteTime, report.getWriteTime()) |
| | | .set(InsReport::getIsPass, report.getIsPass()) |
| | | .set(InsReport::getTempUrlPdf, "/word/" + tempPdfName)); |
| | | } |
| | | |
| | |
| | | String insTime = formatReportTestDate(detectionDates); |
| | | String insTimeEn = formatReportTestDateEn(detectionDates, monthNames); |
| | | |
| | | // æ£éªç¯å¢ï¼ä¼å
æ±æ»å模æ¿å¡«åçæ¸©æ¹¿åº¦ï¼æ¥åå±ç¤ºå
¨é¨æ¨¡æ¿çæå°å¼å°æå¤§å¼ã |
| | | // æ£éªç¯å¢ï¼ä¼å
æ±æ»å模æ¿å¡«åçæ¸©åº¦ï¼æ¥åå±ç¤ºå
¨é¨æ¨¡æ¿çæå°å¼å°æå¤§å¼ã |
| | | String environment = buildReportEnvironment(orderId, insOrder); |
| | | String finalEnvironment = environment; |
| | | LocalDateTime finalSendTime = sendTime; |
| | |
| | | String finalResultRemark = resultRemark; |
| | | String equipmentText = buildEquipmentText(finalDeviceList); |
| | | String issueDate = now.format(DateTimeFormatter.ofPattern("yyyyå¹´MMæddæ¥")); |
| | | String conclusionDate = now.format(DateTimeFormatter.ofPattern("yyyy å¹´ MM æ dd æ¥")); |
| | | String finalReportModelStr = finalModelStr; |
| | | LocalDateTime finalReportSendTime = finalSendTime; |
| | | XWPFTemplate template = XWPFTemplate.compile(inputStream, configure).render( |
| | |
| | | put("customer", finalCustomerName); |
| | | put("category", finalDetectionCategory); |
| | | put("date", issueDate); |
| | | put("conclusionDate", conclusionDate); |
| | | put("maker", defaultReportText(insOrder.getProduction(), "/")); |
| | | put("env", finalEnvironment); |
| | | put("qty", defaultReportText(insOrder.getTestQuantity(), "/")); |
| | |
| | | for (Map<String, String> device : deviceList) { |
| | | String name = getMapText(device, "deviceName", "device_name"); |
| | | String managementNumber = getMapText(device, "managementNumber", "management_number"); |
| | | String factoryNo = getMapText(device, "factoryNo", "factory_no"); |
| | | if (StringUtils.isBlank(name) || "/".equals(name.trim())) { |
| | | continue; |
| | | } |
| | | String number = StringUtils.isBlank(managementNumber) || "/".equals(managementNumber.trim()) |
| | | ? "åºåç¼å·" : managementNumber.trim(); |
| | | String item = name.trim() + "ï¼" + number; |
| | | String number = managementNumber; |
| | | if (StringUtils.isBlank(number) || "/".equals(number.trim())) { |
| | | number = factoryNo; |
| | | } |
| | | if (StringUtils.isBlank(number) || "/".equals(number.trim())) { |
| | | continue; |
| | | } |
| | | String item = name.trim() + "ï¼" + number.trim(); |
| | | equipmentItems.add(item); |
| | | } |
| | | if (equipmentItems.isEmpty()) { |
| | |
| | | List<InsOrderStandardTemplate> snapshots = insOrderStandardTemplateService.list( |
| | | Wrappers.<InsOrderStandardTemplate>lambdaQuery() |
| | | .eq(InsOrderStandardTemplate::getInsOrderId, orderId) |
| | | .select(InsOrderStandardTemplate::getTemperature, |
| | | InsOrderStandardTemplate::getHumidity)); |
| | | .select(InsOrderStandardTemplate::getTemperature)); |
| | | List<String> temperatures = snapshots.stream() |
| | | .map(InsOrderStandardTemplate::getTemperature) |
| | | .filter(StringUtils::isNotBlank) |
| | | .collect(Collectors.toList()); |
| | | List<String> humidities = snapshots.stream() |
| | | .map(InsOrderStandardTemplate::getHumidity) |
| | | .filter(StringUtils::isNotBlank) |
| | | .collect(Collectors.toList()); |
| | | |
| | | String temperature = formatConditionRange(temperatures, order.getTemperature(), "â"); |
| | | String humidity = formatConditionRange(humidities, order.getHumidity(), "%RH"); |
| | | return Stream.of(temperature, humidity) |
| | | .filter(StringUtils::isNotBlank) |
| | | .collect(Collectors.joining(" ")); |
| | | return formatConditionRange(temperatures, order.getTemperature(), "â"); |
| | | } |
| | | |
| | | private static String formatConditionRange(List<String> values, String fallback, String unit) { |
| | |
| | | } |
| | | // æ£éªä¸ï¼æ°èä¸åå
å®¡æ ¸å³åçï¼éæ ·åæ¥æ¶æäº¤åï¼ins_sample_receipt.status=1ï¼æå±ç¤º |
| | | String receiptSubmitted = sampleOrderDto.getState() != null && sampleOrderDto.getState() == 1 ? "1" : null; |
| | | return insOrderMapper.selectInsOrderPage(page, QueryWrappers.queryWrappers(sampleOrderDto), laboratory, |
| | | isOrderAll, receiptSubmitted); |
| | | IPage<SampleOrderDto> result = insOrderMapper.selectInsOrderPage(page, |
| | | QueryWrappers.queryWrappers(sampleOrderDto), laboratory, isOrderAll, receiptSubmitted); |
| | | List<Integer> candidateIds = result.getRecords().stream() |
| | | .filter(row -> Integer.valueOf(-1).equals(row.getTypeSource()) |
| | | && Integer.valueOf(1).equals(row.getState())) |
| | | .map(SampleOrderDto::getId) |
| | | .collect(Collectors.toList()); |
| | | if (!candidateIds.isEmpty()) { |
| | | Set<Integer> receivedIds = insSampleReceiptMapper.selectList(Wrappers.<InsSampleReceipt>lambdaQuery() |
| | | .in(InsSampleReceipt::getInsOrderId, candidateIds) |
| | | .eq(InsSampleReceipt::getStatus, 1) |
| | | .select(InsSampleReceipt::getInsOrderId)).stream() |
| | | .map(InsSampleReceipt::getInsOrderId).collect(Collectors.toSet()); |
| | | Set<Integer> taskIds = insOrderStateService.list(Wrappers.<InsOrderState>lambdaQuery() |
| | | .in(InsOrderState::getInsOrderId, candidateIds) |
| | | .select(InsOrderState::getInsOrderId)).stream() |
| | | .map(InsOrderState::getInsOrderId).collect(Collectors.toSet()); |
| | | Set<Integer> assignedIds = insSampleUserMapper.selectList(Wrappers.<InsSampleUser>lambdaQuery() |
| | | .in(InsSampleUser::getInsSampleId, candidateIds) |
| | | .select(InsSampleUser::getInsSampleId)).stream() |
| | | .map(InsSampleUser::getInsSampleId).collect(Collectors.toSet()); |
| | | result.getRecords().forEach(row -> row.setEditable( |
| | | candidateIds.contains(row.getId()) && !receivedIds.contains(row.getId()) |
| | | && !taskIds.contains(row.getId()) && !assignedIds.contains(row.getId()))); |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | |
| | |
| | | } |
| | | // å§æè¦æ±åæ®µæ ¡éªï¼åç»åéå¿
éï¼åå
/å¿«éèå¨å¿
å¡« |
| | | InsOrder reqOrder = dto.getInsOrder(); |
| | | if (reqOrder.getSampleDate() == null) { |
| | | throw new ErrorException("éæ ·æ¥æä¸è½ä¸ºç©º"); |
| | | } |
| | | if (reqOrder.getSubcontractType() == null || reqOrder.getSampleDisposal() == null |
| | | || reqOrder.getResultEvaluation() == null || reqOrder.getReportDelivery() == null) { |
| | | throw new ErrorException("è¯·éæ©åå
å
å®¹ãæ ·åå¤ç½®ãå¯¹ç»æè¯ä»·åæ¥åäº¤ä»æ¹å¼"); |
| | |
| | | return order.getId(); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public int updateNewJuInsOrder(InsPlaceOrderDto dto) { |
| | | if (dto == null || dto.getOrderId() == null || dto.getInsOrder() == null || dto.getStandardTreeId() == null) { |
| | | throw new ErrorException("ä¸åä¿¡æ¯ææ åä¸è½ä¸ºç©º"); |
| | | } |
| | | InsOrder currentOrder = insOrderMapper.selectById(dto.getOrderId()); |
| | | if (currentOrder == null) { |
| | | throw new ErrorException("æ£éªåä¸åå¨"); |
| | | } |
| | | if (!Integer.valueOf(1).equals(currentOrder.getState()) || !Integer.valueOf(-1).equals(currentOrder.getTypeSource())) { |
| | | throw new ErrorException("å½åå§æä¸å
许ç¼è¾"); |
| | | } |
| | | assertNewJuOrderEditable(dto.getOrderId()); |
| | | |
| | | String sampleCode = StringUtils.trim(dto.getSampleCode()); |
| | | if (StringUtils.isBlank(sampleCode) || sampleCode.length() < 2) { |
| | | throw new ErrorException("æ ·åç¼å·ä¸è½ä¸ºç©ºä¸ä¸è½å°äº2ä½"); |
| | | } |
| | | InsOrder order = dto.getInsOrder(); |
| | | if (order.getSampleDate() == null) { |
| | | throw new ErrorException("éæ ·æ¥æä¸è½ä¸ºç©º"); |
| | | } |
| | | if (order.getSubcontractType() == null || order.getSampleDisposal() == null |
| | | || order.getResultEvaluation() == null || order.getReportDelivery() == null) { |
| | | throw new ErrorException("è¯·éæ©åå
å
å®¹ãæ ·åå¤ç½®ãå¯¹ç»æè¯ä»·åæ¥åäº¤ä»æ¹å¼"); |
| | | } |
| | | if (Integer.valueOf(1).equals(order.getSubcontractType()) && StringUtils.isBlank(order.getSubcontractCompany())) { |
| | | throw new ErrorException("åå
å
å®¹ä¸ºææ¶ï¼åå
åä½ä¿¡æ¯ä¸è½ä¸ºç©º"); |
| | | } |
| | | if (Integer.valueOf(2).equals(order.getReportDelivery()) |
| | | && (StringUtils.isBlank(order.getReportAddress()) || StringUtils.isBlank(order.getReportReceiver()))) { |
| | | throw new ErrorException("æ¥åäº¤ä»æ¹å¼ä¸ºå¿«éæ¶ï¼è¯·å¡«åæ¥åå¯éå°ååæ¶ä»¶äººåçµè¯"); |
| | | } |
| | | |
| | | StandardTree standard = standardTreeService.getById(dto.getStandardTreeId()); |
| | | if (standard == null || StringUtils.isBlank(standard.getSample()) |
| | | || standard.getSampleType() != null || standard.getModel() != null) { |
| | | throw new ErrorException("è¯·éæ©æ ååºäºçº§æ å"); |
| | | } |
| | | List<StandardTreeTemplateBindingVo> bindings = standardTreeService.selectTemplateBindings(dto.getStandardTreeId()); |
| | | if (bindings.isEmpty()) { |
| | | throw new ErrorException("该æ åå°æªç»å®å¯ç¨çåå§è®°å½æ¨¡æ¿"); |
| | | } |
| | | Map<Integer, StandardTreeTemplateBindingVo> bindingMap = bindings.stream() |
| | | .collect(Collectors.toMap(StandardTreeTemplateBindingVo::getTemplateId, binding -> binding, (first, ignored) -> first)); |
| | | List<OrderTemplateSelectionDto> selections = dto.getTemplateList(); |
| | | if (selections == null) { |
| | | selections = bindings.stream().map(binding -> { |
| | | OrderTemplateSelectionDto selection = new OrderTemplateSelectionDto(); |
| | | selection.setTemplateId(binding.getTemplateId()); |
| | | selection.setSort(binding.getSort()); |
| | | return selection; |
| | | }).collect(Collectors.toList()); |
| | | } |
| | | if (selections.isEmpty()) { |
| | | throw new ErrorException("请è³å°ä¿çä¸ä¸ªåå§è®°å½æ¨¡æ¿"); |
| | | } |
| | | Set<Integer> selectedTemplateIds = new HashSet<>(); |
| | | for (int index = 0; index < selections.size(); index++) { |
| | | OrderTemplateSelectionDto selection = selections.get(index); |
| | | if (selection == null || selection.getTemplateId() == null || !bindingMap.containsKey(selection.getTemplateId())) { |
| | | throw new ErrorException("æéåå§è®°å½æ¨¡æ¿ä¸å±äºå½åæ å"); |
| | | } |
| | | if (!selectedTemplateIds.add(selection.getTemplateId())) { |
| | | throw new ErrorException("åå§è®°å½æ¨¡æ¿ä¸è½éå¤éæ©"); |
| | | } |
| | | if (selection.getSort() == null) { |
| | | selection.setSort(index); |
| | | } |
| | | } |
| | | selections.sort(Comparator.comparing(OrderTemplateSelectionDto::getSort) |
| | | .thenComparing(OrderTemplateSelectionDto::getTemplateId)); |
| | | Map<Integer, Integer> templateSortMap = selections.stream().collect(Collectors.toMap( |
| | | OrderTemplateSelectionDto::getTemplateId, OrderTemplateSelectionDto::getSort)); |
| | | List<TemplateInspectionItemDto> templateItems = standardTreeService.selectTemplateInspectionItems(dto.getStandardTreeId()).stream() |
| | | .filter(item -> selectedTemplateIds.contains(item.getTemplateId())) |
| | | .sorted(Comparator.comparing((TemplateInspectionItemDto item) -> templateSortMap.get(item.getTemplateId())) |
| | | .thenComparing(item -> item.getTemplateRowIndex() == null ? Integer.MAX_VALUE : item.getTemplateRowIndex())) |
| | | .collect(Collectors.toList()); |
| | | StandardMethod standardMethod = standardMethodService.getById(standard.getStandardMethodId()); |
| | | if (standardMethod == null || StringUtils.isBlank(standardMethod.getCode())) { |
| | | throw new ErrorException("æ åç¼å·ä¸åå¨"); |
| | | } |
| | | String standardCode = standardMethod.getCode().trim(); |
| | | |
| | | order.setId(currentOrder.getId()); |
| | | order.setState(currentOrder.getState()); |
| | | order.setInsState(currentOrder.getInsState()); |
| | | order.setExamineTime(currentOrder.getExamineTime()); |
| | | order.setSendTime(currentOrder.getSendTime()); |
| | | order.setIsExemption(currentOrder.getIsExemption()); |
| | | order.setFactory(null); |
| | | order.setLaboratory(standard.getLaboratory()); |
| | | order.setSampleType(null); |
| | | order.setSample(standardCode); |
| | | order.setPrepareUserEn(null); |
| | | order.setPrepareCode(null); |
| | | order.setRemarkEn(null); |
| | | order.setTemperature(null); |
| | | order.setHumidity(null); |
| | | if (!Integer.valueOf(1).equals(order.getSubcontractType())) { |
| | | order.setSubcontractCompany(null); |
| | | } |
| | | if (!Integer.valueOf(2).equals(order.getReportDelivery())) { |
| | | order.setReportAddress(null); |
| | | order.setReportReceiver(null); |
| | | } |
| | | insOrderMapper.updateById(order); |
| | | |
| | | List<InsSample> samples = insSampleMapper.selectList(Wrappers.<InsSample>lambdaQuery() |
| | | .eq(InsSample::getInsOrderId, currentOrder.getId()).orderByAsc(InsSample::getId)); |
| | | if (samples.size() != 1) { |
| | | throw new ErrorException("æ£éªæ ·åæ°æ®å¼å¸¸"); |
| | | } |
| | | InsSample sample = samples.get(0); |
| | | sample.setSampleCode(sampleCode); |
| | | sample.setLaboratory(standard.getLaboratory()); |
| | | sample.setSampleType(null); |
| | | sample.setSample(standardCode); |
| | | sample.setModel(null); |
| | | insSampleMapper.updateById(sample); |
| | | insProductMapper.delete(Wrappers.<InsProduct>lambdaQuery().eq(InsProduct::getInsSampleId, sample.getId())); |
| | | insOrderStandardTemplateMapper.delete(Wrappers.<InsOrderStandardTemplate>lambdaQuery() |
| | | .eq(InsOrderStandardTemplate::getInsOrderId, currentOrder.getId())); |
| | | insOrderTemplateDeviceMapper.delete(Wrappers.<InsOrderTemplateDevice>lambdaQuery() |
| | | .eq(InsOrderTemplateDevice::getInsOrderId, currentOrder.getId())); |
| | | int productSort = 0; |
| | | for (TemplateInspectionItemDto item : templateItems) { |
| | | InsProduct product = new InsProduct(); |
| | | product.setInsSampleId(sample.getId()); |
| | | product.setInspectionItem(item.getInspectionItem()); |
| | | product.setInspectionItemClass(""); |
| | | product.setInspectionItemSubclass(""); |
| | | product.setLaboratory(standard.getLaboratory()); |
| | | product.setSample(standardCode); |
| | | product.setTemplateId(item.getTemplateId()); |
| | | product.setTemplateRowIndex(item.getTemplateRowIndex()); |
| | | product.setSonLaboratory(DIRECT_TEMPLATE_LABORATORY); |
| | | product.setState(1); |
| | | product.setSort(productSort++); |
| | | insProductMapper.insert(product); |
| | | } |
| | | saveTemplateSnapshots(currentOrder.getId(), selections, bindingMap); |
| | | String entrustCode = buildEntrustCode(order, Collections.singletonList(sample)); |
| | | assertEntrustCodeUnique(entrustCode, currentOrder.getId()); |
| | | insOrderMapper.update(null, Wrappers.<InsOrder>lambdaUpdate().eq(InsOrder::getId, currentOrder.getId()) |
| | | .set(InsOrder::getEntrustCode, entrustCode)); |
| | | applicationEventPublisher.publishEvent(new com.ruoyi.inspect.event.NewJuOrderPlacedEvent(currentOrder.getId())); |
| | | return currentOrder.getId(); |
| | | } |
| | | |
| | | private void assertNewJuOrderEditable(Integer orderId) { |
| | | Long receiptCount = insSampleReceiptMapper.selectCount(Wrappers.<InsSampleReceipt>lambdaQuery() |
| | | .eq(InsSampleReceipt::getInsOrderId, orderId).eq(InsSampleReceipt::getStatus, 1)); |
| | | Long taskCount = insOrderStateService.count(Wrappers.<InsOrderState>lambdaQuery() |
| | | .eq(InsOrderState::getInsOrderId, orderId)); |
| | | Long userCount = insSampleUserMapper.selectCount(Wrappers.<InsSampleUser>lambdaQuery() |
| | | .eq(InsSampleUser::getInsSampleId, orderId)); |
| | | if (receiptCount > 0 || taskCount > 0 || userCount > 0) { |
| | | throw new ErrorException("è¯¥å§æå·²è¿å
¥æ£éªï¼ä¸è½ç¼è¾"); |
| | | } |
| | | } |
| | | |
| | | private void saveTemplateSnapshots(Integer orderId, List<OrderTemplateSelectionDto> selections, |
| | | Map<Integer, StandardTreeTemplateBindingVo> bindingMap) { |
| | | for (OrderTemplateSelectionDto selection : selections) { |
| | |
| | | map.put("sampleCode", orderSamples.isEmpty() ? null : orderSamples.get(0).getSampleCode()); |
| | | map.put("insOrderTemplate", map1); |
| | | map.put("templateList", templateList); |
| | | Set<Integer> orderTemplateIds = templateList.stream() |
| | | .map(OrderTemplateSummaryVo::getTemplateId).collect(Collectors.toSet()); |
| | | List<Integer> methodIds = standardMethodService.list(Wrappers.<StandardMethod>lambdaQuery() |
| | | .eq(StandardMethod::getCode, insOrder.getSample()) |
| | | .select(StandardMethod::getId)).stream() |
| | | .map(StandardMethod::getId).collect(Collectors.toList()); |
| | | if (!methodIds.isEmpty() && !orderTemplateIds.isEmpty()) { |
| | | List<StandardTree> candidates = standardTreeService.list(Wrappers.<StandardTree>lambdaQuery() |
| | | .in(StandardTree::getStandardMethodId, methodIds) |
| | | .isNull(StandardTree::getSampleType) |
| | | .isNull(StandardTree::getModel)); |
| | | Map<StandardTree, Set<Integer>> matches = candidates.stream() |
| | | .filter(tree -> StringUtils.isNotBlank(tree.getSample()) |
| | | && Objects.equals(tree.getLaboratory(), insOrder.getLaboratory())) |
| | | .collect(Collectors.toMap(tree -> tree, |
| | | tree -> standardTreeService.selectTemplateBindings(tree.getId()).stream() |
| | | .map(StandardTreeTemplateBindingVo::getTemplateId) |
| | | .collect(Collectors.toSet()))); |
| | | matches.entrySet().removeIf(entry -> !entry.getValue().containsAll(orderTemplateIds)); |
| | | if (matches.size() == 1) { |
| | | map.put("standardTreeId", matches.keySet().iterator().next().getId()); |
| | | } else if (matches.size() > 1) { |
| | | List<StandardTree> exactMatches = matches.entrySet().stream() |
| | | .filter(entry -> entry.getValue().equals(orderTemplateIds)) |
| | | .map(Map.Entry::getKey).collect(Collectors.toList()); |
| | | if (exactMatches.size() == 1) { |
| | | map.put("standardTreeId", exactMatches.get(0).getId()); |
| | | } |
| | | } |
| | | } |
| | | return map; |
| | | } |
| | | |
| | |
| | | .eq(InsOrderStandardTemplate::getInsOrderId, id) |
| | | .select(InsOrderStandardTemplate::getTemplateId, |
| | | InsOrderStandardTemplate::getTemperature, |
| | | InsOrderStandardTemplate::getHumidity, |
| | | InsOrderStandardTemplate::getDetectionTime, |
| | | InsOrderStandardTemplate::getDetectionPlace, |
| | | InsOrderStandardTemplate::getInsResult) |
| | |
| | | TemplateConditionVo condition = new TemplateConditionVo(); |
| | | condition.setTemplateId(snapshot.getTemplateId()); |
| | | condition.setTemperature(snapshot.getTemperature()); |
| | | condition.setHumidity(snapshot.getHumidity()); |
| | | condition.setDetectionTime(snapshot.getDetectionTime()); |
| | | condition.setDetectionPlace(snapshot.getDetectionPlace()); |
| | | condition.setInsResult(snapshot.getInsResult()); |
| | |
| | | if (snapshot == null) { |
| | | throw new ErrorException("æªæ¾å°å½å模æ¿çåå§è®°å½å¿«ç
§"); |
| | | } |
| | | boolean hasSnapshotField = dto.isTemperaturePresent() || dto.isHumidityPresent() |
| | | || dto.isDetectionTimePresent() || dto.isDetectionPlacePresent() |
| | | boolean hasSnapshotField = dto.isTemperaturePresent() || dto.isDetectionTimePresent() |
| | | || dto.isDetectionPlacePresent() |
| | | || dto.isInsResultPresent(); |
| | | if (hasSnapshotField) { |
| | | insOrderStandardTemplateMapper.update(null, |
| | |
| | | .eq(InsOrderStandardTemplate::getId, snapshot.getId()) |
| | | .set(dto.isTemperaturePresent(), |
| | | InsOrderStandardTemplate::getTemperature, dto.getTemperature()) |
| | | .set(dto.isHumidityPresent(), |
| | | InsOrderStandardTemplate::getHumidity, dto.getHumidity()) |
| | | .set(dto.isDetectionTimePresent(), |
| | | InsOrderStandardTemplate::getDetectionTime, dto.getDetectionTime()) |
| | | .set(dto.isDetectionPlacePresent(), |
| | |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.deepoove.poi.XWPFTemplate; |
| | | import com.deepoove.poi.config.Configure; |
| | | import com.deepoove.poi.data.PictureRenderData; |
| | | import com.deepoove.poi.data.PictureType; |
| | | import com.deepoove.poi.data.Pictures; |
| | | import com.itextpdf.text.BadElementException; |
| | | import com.itextpdf.text.DocumentException; |
| | |
| | | import com.itextpdf.text.pdf.PdfReader; |
| | | import com.itextpdf.text.pdf.PdfStamper; |
| | | import com.ruoyi.basic.mapper.IfsInventoryQuantityMapper; |
| | | import com.ruoyi.basic.mapper.SealConfigMapper; |
| | | import com.ruoyi.basic.pojo.IfsInventoryQuantity; |
| | | import com.ruoyi.basic.pojo.SealConfig; |
| | | import com.ruoyi.basic.vo.IfsInventoryQuantityVO; |
| | | import com.ruoyi.common.config.WechatProperty; |
| | | import com.ruoyi.common.constant.InsOrderTypeConstants; |
| | |
| | | import com.ruoyi.inspect.service.InsReportService; |
| | | import com.ruoyi.inspect.service.RawMaterialOrderService; |
| | | import com.ruoyi.inspect.util.PreserveReportPicturePlaceholderHandler; |
| | | import com.ruoyi.inspect.util.ReportSealLayoutUtil; |
| | | import com.ruoyi.inspect.util.ReportSignaturePictureUtils; |
| | | import com.ruoyi.system.mapper.UserMapper; |
| | | import com.ruoyi.system.service.InformationNotificationService; |
| | |
| | | private InsOrderMapper insOrderMapper; |
| | | @Resource |
| | | private IfsInventoryQuantityMapper ifsInventoryQuantityMapper; |
| | | @Resource |
| | | private SealConfigMapper sealConfigMapper; |
| | | @Resource |
| | | private InsUnqualifiedHandlerMapper insUnqualifiedHandlerMapper; |
| | | @Resource |
| | |
| | | //æ¹å |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public int ratifyReport(Integer id, Integer isRatify, String ratifyTell) { |
| | | public int ratifyReport(Integer id, Integer isRatify, String ratifyTell, String sealIds, |
| | | Integer maSealId, Integer reportSealId, Integer seamSealId) { |
| | | InsReport insReport = insReportMapper.selectById(id); |
| | | if (Objects.equals(insReport.getExamineUserId(), SecurityUtils.getUserId().intValue())) { |
| | | throw new ErrorException("å®¡æ ¸äººåæ¹å人ä¸è½ä¸ºåä¸äººï¼è¯·éæ°éæ©æ¹å人"); |
| | |
| | | InsOrder order = insOrderMapper.selectById(insOrderId); |
| | | boolean isRawMater = order.getTypeSource() != null && order.getTypeSource().equals(1); |
| | | |
| | | //è·ååºæçæ¥åä¸ç¨ç« |
| | | String sealUrl; |
| | | String laboratory = insOrderMapper.selectById(insReport.getInsOrderId()).getLaboratory(); |
| | | try { |
| | | String type = ""; |
| | | if (isRawMater && order.getOrderType().equals(InsOrderTypeConstants.ENTER_THE_FACTORY)) { |
| | | type = "è¿åæ¥å"; |
| | | // æ°çæç¨ééæ©ï¼MAç« ãæ¥åç« ï¼æ¨¡æ¿ seal1/seal2ï¼ãPDFéªç¼ç« ã |
| | | // å
¼å®¹æ§å端ï¼åªä¼ sealIds æ¶ï¼ç¬¬ä¸æç« ç»§ç»ä½ä¸ºæ¥åç« åéªç¼ç« ï¼MAç« ç空ã |
| | | SealConfig maSeal; |
| | | SealConfig reportSeal; |
| | | SealConfig seamSeal; |
| | | boolean positionMode = maSealId != null || reportSealId != null || seamSealId != null; |
| | | if (positionMode) { |
| | | maSeal = resolveSeal(maSealId); |
| | | reportSeal = resolveSeal(reportSealId); |
| | | seamSeal = resolveSeal(seamSealId); |
| | | } else { |
| | | type = "å§ææ¥å"; |
| | | SealConfig legacySeal = resolveSeals(sealIds).get(0); |
| | | maSeal = null; |
| | | reportSeal = legacySeal; |
| | | seamSeal = legacySeal; |
| | | } |
| | | sealUrl = insReportMapper.getLaboratoryByName(laboratory, type); |
| | | } catch (Exception e) { |
| | | throw new ErrorException(laboratory + "æ¾ä¸å°æ¥åä¸ç¨ç« "); |
| | | |
| | | LinkedHashMap<Integer, SealConfig> chosenById = new LinkedHashMap<>(); |
| | | Arrays.asList(maSeal, reportSeal, seamSeal).stream() |
| | | .filter(Objects::nonNull) |
| | | .forEach(seal -> chosenById.put(seal.getId(), seal)); |
| | | List<SealConfig> chosenSeals = new ArrayList<>(chosenById.values()); |
| | | if (chosenSeals.isEmpty()) { |
| | | throw new ErrorException("请è³å°éæ©ä¸ç§æ¥åå°ç« "); |
| | | } |
| | | if (StringUtils.isBlank(sealUrl)) { |
| | | throw new ErrorException(laboratory + "æ¾ä¸å°æ¥åä¸ç¨ç« "); |
| | | } |
| | | |
| | | insReport.setSealIds(chosenSeals.stream().map(s -> String.valueOf(s.getId())).collect(Collectors.joining(","))); |
| | | insReport.setSealNames(chosenSeals.stream().map(SealConfig::getName).collect(Collectors.joining(","))); |
| | | insReport.setMaSealId(maSeal == null ? null : maSeal.getId()); |
| | | insReport.setMaSealName(maSeal == null ? null : maSeal.getName()); |
| | | insReport.setReportSealId(reportSeal == null ? null : reportSeal.getId()); |
| | | insReport.setReportSealName(reportSeal == null ? null : reportSeal.getName()); |
| | | insReport.setSeamSealId(seamSeal == null ? null : seamSeal.getId()); |
| | | insReport.setSeamSealName(seamSeal == null ? null : seamSeal.getName()); |
| | | String primaryReportUrl = getPrimaryReportUrl(insReport); |
| | | String finalUrl = primaryReportUrl.replace("/word", wordUrl); |
| | | |
| | | Map<String, Object> ratifyMarks = new HashMap<String, Object>() {{ |
| | | put("ratifyUrl", ReportSignaturePictureUtils.create(imgUrl, signatureUrl)); |
| | | put("ratifyDateUrl", Pictures.ofStream(DateImageUtil.createDateImage(null)).create()); |
| | | put("seal1", Pictures.ofLocal(imgUrl + "/" + sealUrl).create()); |
| | | put("seal2", Pictures.ofLocal(imgUrl + "/" + sealUrl).create()); |
| | | }}; |
| | | writeMarksToReportFiles(insReport, ratifyMarks); |
| | | Map<String, Object> ratifyMarks = new HashMap<>(); |
| | | ratifyMarks.put("ratifyUrl", ReportSignaturePictureUtils.create(imgUrl, signatureUrl)); |
| | | ratifyMarks.put("ratifyDateUrl", Pictures.ofStream(DateImageUtil.createDateImage(null)).create()); |
| | | if (reportSeal != null) { |
| | | ratifyMarks.put("seal1", createSealPicture(reportSeal.getAddress())); |
| | | ratifyMarks.put("seal2", createSealPicture(reportSeal.getAddress())); |
| | | } |
| | | writeApprovalMarksToReportFiles(insReport, ratifyMarks); |
| | | |
| | | // å°ç« å¿
é¡»ä½¿ç¨æµ®å¨å®ä½ï¼å¦åè¡å
å¾ç伿髿®µè½/è¡¨æ ¼å¹¶æ¹å忥åå页ã |
| | | for (String reportUrl : getApprovalReportUrls(insReport)) { |
| | | try { |
| | | ReportSealLayoutUtil.apply( |
| | | reportUrl.replace("/word", wordUrl), |
| | | reportSeal == null ? null : Paths.get(imgUrl, reportSeal.getAddress()).toString(), |
| | | maSeal == null ? null : Paths.get(imgUrl, maSeal.getAddress()).toString()); |
| | | } catch (Exception e) { |
| | | log.error("æ¥åå°ç« æµ®å¨å®ä½å¤±è´¥: {}", reportUrl, e); |
| | | throw new ErrorException("æ¥åçç« å¤±è´¥ï¼è¯·æ£æ¥å°ç« å¾ç忥åæä»¶"); |
| | | } |
| | | } |
| | | |
| | | // ä¿®æ¹ä¸´æ¶pdf |
| | | insReport.setTempUrlPdf(primaryReportUrl.replace(".docx", ".pdf")); |
| | |
| | | insOrderMapper.updateById(insOrder); |
| | | |
| | | for (String reportUrl : getApprovalReportUrls(insReport)) { |
| | | wordToPdf(reportUrl.replace("/word", wordUrl), sealUrl, |
| | | wordToPdf(reportUrl.replace("/word", wordUrl), |
| | | null, |
| | | seamSeal == null ? null : seamSeal.getAddress(), |
| | | isRawMater && order.getOrderType().equals(InsOrderTypeConstants.ENTER_THE_FACTORY)); |
| | | } |
| | | |
| | |
| | | return insReportMapper.updateById(insReport); |
| | | } |
| | | |
| | | /** |
| | | * è§£ææ¹åæ¶éæ©çå°ç« ï¼éå·åéçå°ç« idï¼ã |
| | | * æªä¼ æå
¨é¨æ ææ¶åéå°ç¬¬ä¸ä¸ªå¯ç¨å°ç« ï¼é»è®¤â1å·ç« âï¼ã |
| | | */ |
| | | private List<SealConfig> resolveSeals(String sealIds) { |
| | | List<SealConfig> chosen = new ArrayList<>(); |
| | | if (StringUtils.isNotBlank(sealIds)) { |
| | | List<Integer> ids = new ArrayList<>(); |
| | | for (String s : sealIds.split(",")) { |
| | | if (StringUtils.isNotBlank(s)) { |
| | | ids.add(Integer.valueOf(s.trim())); |
| | | } |
| | | } |
| | | if (!ids.isEmpty()) { |
| | | Map<Integer, SealConfig> byId = sealConfigMapper.selectBatchIds(ids).stream() |
| | | .collect(Collectors.toMap(SealConfig::getId, x -> x)); |
| | | for (Integer sid : ids) { |
| | | SealConfig seal = byId.get(sid); |
| | | if (seal != null && Objects.equals(seal.getStatus(), 1) |
| | | && StringUtils.isNotBlank(seal.getAddress())) { |
| | | chosen.add(seal); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | if (chosen.isEmpty()) { |
| | | List<SealConfig> enabled = sealConfigMapper.selectList(Wrappers.<SealConfig>lambdaQuery() |
| | | .eq(SealConfig::getStatus, 1).orderByAsc(SealConfig::getCode)); |
| | | if (!enabled.isEmpty()) { |
| | | chosen.add(enabled.get(0)); |
| | | } |
| | | } |
| | | if (chosen.isEmpty()) { |
| | | throw new ErrorException("æªæ¾å°å¯ç¨å°ç« ï¼è¯·å
å¨å°ç« 管çä¸ç»´æ¤å¹¶å¯ç¨å°ç« "); |
| | | } |
| | | return chosen; |
| | | } |
| | | |
| | | private SealConfig resolveSeal(Integer sealId) { |
| | | if (sealId == null) { |
| | | return null; |
| | | } |
| | | SealConfig seal = sealConfigMapper.selectById(sealId); |
| | | if (seal == null) { |
| | | throw new ErrorException("æéå°ç« ä¸åå¨ï¼è¯·éæ°éæ©"); |
| | | } |
| | | if (!Objects.equals(seal.getStatus(), 1)) { |
| | | throw new ErrorException("å°ç« â" + seal.getName() + "âå·²åç¨ï¼è¯·éæ°éæ©"); |
| | | } |
| | | if (StringUtils.isBlank(seal.getAddress())) { |
| | | throw new ErrorException("å°ç« â" + seal.getName() + "âæªä¸ä¼ å¾çï¼è¯·éæ°éæ©"); |
| | | } |
| | | return seal; |
| | | } |
| | | |
| | | /** |
| | | * æå¾çå
容è¯å«å°ç« æ ¼å¼ï¼å
¼å®¹å岿°æ®ä¸æ©å±å被ä¿å为â_pngâçéæ åæä»¶åçæ
åµã |
| | | */ |
| | | private PictureRenderData createSealPicture(String sealUrl) { |
| | | Path sealPath = Paths.get(imgUrl, sealUrl); |
| | | if (!Files.isRegularFile(sealPath)) { |
| | | throw new ErrorException("å°ç« å¾çæä»¶ä¸åå¨ï¼è¯·éæ°ä¸ä¼ å°ç« å¾ç"); |
| | | } |
| | | try { |
| | | byte[] imageBytes = Files.readAllBytes(sealPath); |
| | | PictureType pictureType = PictureType.suggestFileType(imageBytes); |
| | | return Pictures.ofBytes(imageBytes, pictureType).create(); |
| | | } catch (Exception e) { |
| | | log.error("读åå°ç« å¾ç失败: {}", sealPath, e); |
| | | throw new ErrorException("å°ç« å¾çæ æ³è¯å«ï¼è¯·éæ°ä¸ä¼ jpg æ png å¾ç"); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public int wordInsertUrl(Map<String, Object> map, String url) { |
| | | Configure configure = Configure.builder() |
| | | .setValidErrorHandler(new PreserveReportPicturePlaceholderHandler()) |
| | | .build(); |
| | | XWPFTemplate template = XWPFTemplate.compile(url, configure).render(map); |
| | | try { |
| | | template.writeAndClose(Files.newOutputStream(Paths.get(url))); |
| | | } catch (IOException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | return 1; |
| | | } |
| | | |
| | | private int wordInsertApprovalMarks(Map<String, Object> map, String url) { |
| | | Configure configure = Configure.builder() |
| | | .setValidErrorHandler(new PreserveReportPicturePlaceholderHandler( |
| | | new HashSet<>(Arrays.asList("seal1", "seal2")))) |
| | | .build(); |
| | | XWPFTemplate template = XWPFTemplate.compile(url, configure).render(map); |
| | | try { |
| | |
| | | private void writeMarksToReportFiles(InsReport report, Map<String, Object> marks) { |
| | | for (String reportUrl : getApprovalReportUrls(report)) { |
| | | wordInsertUrl(marks, reportUrl.replace("/word", wordUrl)); |
| | | } |
| | | } |
| | | |
| | | private void writeApprovalMarksToReportFiles(InsReport report, Map<String, Object> marks) { |
| | | for (String reportUrl : getApprovalReportUrls(report)) { |
| | | wordInsertApprovalMarks(marks, reportUrl.replace("/word", wordUrl)); |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | @Override |
| | | public void wordToPdf(String path, String sealUrl, boolean isRawMater) { |
| | | public void wordToPdf(String path, String maSealUrl, String seamSealUrl, boolean isRawMater) { |
| | | try { |
| | | wordToPdf(path, path.replace(".docx", ".pdf"), sealUrl, isRawMater); |
| | | wordToPdf(path, path.replace(".docx", ".pdf"), maSealUrl, seamSealUrl, isRawMater); |
| | | } catch (Exception e) { |
| | | throw new ErrorException("转æ¢å¤±è´¥"); |
| | | } |
| | | } |
| | | |
| | | |
| | | public String wordToPdf(String wordPath, String pdfPath, String sealUrl, boolean isRawMater) { |
| | | public String wordToPdf(String wordPath, String pdfPath, String maSealUrl, |
| | | String seamSealUrl, boolean isRawMater) { |
| | | FileOutputStream os = null; |
| | | try { |
| | | //åè¯ ä¸ç¶åæ¢åææ°´å° |
| | |
| | | log.info("Licenseéªè¯ä¸éè¿..."); |
| | | return null; |
| | | } |
| | | //çæä¸ä¸ªç©ºçPDFæä»¶ |
| | | File file; |
| | | //夿æ¯å¦æ¯è¿åæ¥å |
| | | if (!isRawMater) { |
| | | file = new File(pdfPath.replace(".pdf", "-1.pdf")); |
| | | } else { |
| | | file = new File(pdfPath.replace(".pdf", ".pdf")); |
| | | } |
| | | String effectiveSeamSealUrl = isRawMater ? null : seamSealUrl; |
| | | boolean addPdfMarks = StringUtils.isNotBlank(maSealUrl) |
| | | || StringUtils.isNotBlank(effectiveSeamSealUrl); |
| | | String sourcePdfPath = addPdfMarks ? pdfPath.replace(".pdf", "-stamp-source.pdf") : pdfPath; |
| | | File file = new File(sourcePdfPath); |
| | | os = new FileOutputStream(file); |
| | | //è¦è½¬æ¢çwordæä»¶ |
| | | com.aspose.words.Document doc = new com.aspose.words.Document(wordPath); |
| | | doc.save(os, SaveFormat.PDF); |
| | | os.close(); |
| | | os = null; |
| | | |
| | | //æ·»å éªç¼ç« |
| | | if (!isRawMater) { |
| | | stamperCheckMarkPDF(pdfPath.replace(".pdf", "-1.pdf"), pdfPath, imgUrl + "/" + sealUrl); |
| | | // MAç« åºå®å¨ç¬¬1页左ä¸è§ï¼éªç¼ç« æé¡µåçåºå®å¨å³ä¾§ä¸é¨ã |
| | | if (addPdfMarks) { |
| | | stamperReportMarksPDF( |
| | | sourcePdfPath, |
| | | pdfPath, |
| | | StringUtils.isBlank(maSealUrl) ? null : Paths.get(imgUrl, maSealUrl).toString(), |
| | | StringUtils.isBlank(effectiveSeamSealUrl) |
| | | ? null : Paths.get(imgUrl, effectiveSeamSealUrl).toString()); |
| | | } |
| | | |
| | | |
| | | return new File(pdfPath).getName(); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | log.error("çæçç« PDF失败: {}", wordPath, e); |
| | | throw new ErrorException("æ¥å转PDFæçç« å¤±è´¥"); |
| | | } finally { |
| | | if (os != null) { |
| | | try { |
| | |
| | | } |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | |
| | | subImg = img.getSubimage(i * sw, 0, sw, h); |
| | | } |
| | | ByteArrayOutputStream out = new ByteArrayOutputStream(); |
| | | ImageIO.write(subImg, Path.substring(Path.lastIndexOf('.') + 1), out); |
| | | // ç»ä¸ç¼ç 为 PNGï¼å
¼å®¹åå²â_pngâçæ²¡ææ åæ©å±åçå¾çæä»¶ã |
| | | ImageIO.write(subImg, "png", out); |
| | | nImage[i] = com.itextpdf.text.Image.getInstance(out.toByteArray()); |
| | | |
| | | } |
| | |
| | | } |
| | | |
| | | /** |
| | | * çéªç¼ç« |
| | | * æåèæ¥åç PDF æ å¿ç« ï¼MAç« ä½äºç¬¬1页左ä¸è§ï¼éªç¼ç« ä½äºæ¯é¡µå³ä¾§ä¸é¨ã |
| | | * |
| | | * @param infilePath åPDFè·¯å¾ |
| | | * @param outFilePath è¾åºPDFè·¯å¾ |
| | | */ |
| | | public static void stamperCheckMarkPDF(String infilePath, String outFilePath, String picPath) throws IOException, DocumentException { |
| | | public static void stamperReportMarksPDF(String infilePath, String outFilePath, |
| | | String maPicPath, String seamPicPath) |
| | | throws IOException, DocumentException { |
| | | PdfReader reader = new PdfReader(infilePath);//éæ©éè¦å°ç« çpdf |
| | | PdfStamper stamp = new PdfStamper(reader, new FileOutputStream(outFilePath));//å å®å°ç« åçpdf |
| | | |
| | | |
| | | com.itextpdf.text.Rectangle pageSize = reader.getPageSize(1);//è·å¾ç¬¬ä¸é¡µ |
| | | float height = pageSize.getHeight(); |
| | | float width = pageSize.getWidth(); |
| | | |
| | | int nums = reader.getNumberOfPages(); |
| | | com.itextpdf.text.Image[] nImage = slicingImages(picPath, nums);//çæéªç¼ç« åå²å¾ç |
| | | boolean hasMaSeal = maPicPath != null && !maPicPath.trim().isEmpty(); |
| | | boolean hasSeamSeal = seamPicPath != null && !seamPicPath.trim().isEmpty(); |
| | | com.itextpdf.text.Image[] seamImages = hasSeamSeal ? slicingImages(seamPicPath, nums) : null; |
| | | |
| | | for (int n = 1; n <= nums; n++) { |
| | | com.itextpdf.text.Rectangle pageSize = reader.getPageSize(n); |
| | | float height = pageSize.getHeight(); |
| | | float width = pageSize.getWidth(); |
| | | PdfContentByte over = stamp.getOverContent(n);//设置å¨ç¬¬å 页æå°å°ç« |
| | | com.itextpdf.text.Image img = nImage[n - 1];//éæ©å¾ç |
| | | |
| | | if (n == 1 && hasMaSeal) { |
| | | com.itextpdf.text.Image maImage = com.itextpdf.text.Image.getInstance(maPicPath); |
| | | maImage.scaleToFit(100f, 90f); |
| | | maImage.setAbsolutePosition(30f, height - maImage.getScaledHeight() - 30f); |
| | | over.addImage(maImage); |
| | | } |
| | | |
| | | if (hasSeamSeal) { |
| | | com.itextpdf.text.Image seamImage = seamImages[n - 1]; |
| | | float newHeight = 100f; |
| | | float newWidth = img.getWidth() / (img.getHeight() / 100); |
| | | img.scaleAbsolute(newWidth, newHeight);//æ§å¶å¾çå¤§å° |
| | | img.setAbsolutePosition(width - newWidth, height / 2 - newHeight / 2);//æ§å¶å¾çä½ç½® |
| | | over.addImage(img); |
| | | float newWidth = seamImage.getWidth() / (seamImage.getHeight() / newHeight); |
| | | seamImage.scaleAbsolute(newWidth, newHeight); |
| | | seamImage.setAbsolutePosition(width - newWidth, height / 2 - newHeight / 2); |
| | | over.addImage(seamImage); |
| | | } |
| | | } |
| | | stamp.close(); |
| | | reader.close(); |
| | | } |
| | | |
| | | @Override |
| | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public boolean sendBackTask(Integer id) { |
| | | InsReport report = insReportMapper.selectById(id); |
| | | // æ ¹æ®è®¢åæ¥è¯¢è¯éªå®¤ |
| | | String laboratory = insOrderMapper.selectLaboratoryByOrderId(report.getInsOrderId()); |
| | | if (report == null || report.getInsOrderId() == null) { |
| | | throw new ErrorException("æ¥åä¸å卿æªå
³èæ£éªå"); |
| | | } |
| | | |
| | | // ä¿®æ¹è®¢åç¶æ |
| | | // æ¥åç±è®¢åä¸åè¯éªå®¤å
±åå½¢æï¼éåæ¶å
¨é¨æ¢å¤ä¸ºå¾
夿 ¸ï¼é¿å
åªéæºéåä¸ä¸ªè¯éªå®¤ã |
| | | insOrderStateMapper.update(null, Wrappers.<InsOrderState>lambdaUpdate() |
| | | .eq(InsOrderState::getInsOrderId, report.getInsOrderId()) |
| | | .eq(InsOrderState::getLaboratory, laboratory) |
| | | .set(InsOrderState::getInsState, 4)); |
| | | |
| | | Integer insSampleId = insSampleUserMapper.selectOne(Wrappers.<InsSampleUser>lambdaQuery() |
| | | InsSampleUser sampleUser = insSampleUserMapper.selectOne(Wrappers.<InsSampleUser>lambdaQuery() |
| | | .eq(InsSampleUser::getInsSampleId, report.getInsOrderId()) |
| | | .orderByDesc(InsSampleUser::getId) |
| | | .last("limit 1")).getId(); |
| | | insSampleUserMapper.deleteById(insSampleId); |
| | | .last("limit 1")); |
| | | if (sampleUser != null) { |
| | | insSampleUserMapper.deleteById(sampleUser.getId()); |
| | | } |
| | | |
| | | // ä¿®æ¹æ¥åè¡ä¸ºæªæ¾ç¤º |
| | | insReportMapper.update(null, Wrappers.<InsReport>lambdaUpdate() |
| | |
| | | import com.deepoove.poi.template.ElementTemplate; |
| | | |
| | | import java.util.Arrays; |
| | | import java.util.Collections; |
| | | import java.util.HashSet; |
| | | import java.util.Set; |
| | | |
| | |
| | | )); |
| | | |
| | | private final Configure.ClearHandler clearHandler = new Configure.ClearHandler(); |
| | | private final Set<String> clearPictureTags; |
| | | |
| | | public PreserveReportPicturePlaceholderHandler() { |
| | | this(Collections.emptySet()); |
| | | } |
| | | |
| | | public PreserveReportPicturePlaceholderHandler(Set<String> clearPictureTags) { |
| | | this.clearPictureTags = clearPictureTags == null ? Collections.emptySet() : clearPictureTags; |
| | | } |
| | | |
| | | @Override |
| | | public void handler(RenderContext<?> context) { |
| | | ElementTemplate template = context.getEleTemplate(); |
| | | if (template != null |
| | | && Character.valueOf('@').equals(template.getSign()) |
| | | && DEFERRED_PICTURE_TAGS.contains(template.getTagName())) { |
| | | && DEFERRED_PICTURE_TAGS.contains(template.getTagName()) |
| | | && !clearPictureTags.contains(template.getTagName())) { |
| | | return; |
| | | } |
| | | clearHandler.handler(context); |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.inspect.util; |
| | | |
| | | import com.aspose.words.Document; |
| | | import com.aspose.words.LayoutCollector; |
| | | import com.aspose.words.LayoutEnumerator; |
| | | import com.aspose.words.License; |
| | | import com.aspose.words.Node; |
| | | import com.aspose.words.NodeCollection; |
| | | import com.aspose.words.NodeType; |
| | | import com.aspose.words.PageSetup; |
| | | import com.aspose.words.Paragraph; |
| | | import com.aspose.words.RelativeHorizontalPosition; |
| | | import com.aspose.words.RelativeVerticalPosition; |
| | | import com.aspose.words.SaveFormat; |
| | | import com.aspose.words.Section; |
| | | import com.aspose.words.Shape; |
| | | import com.aspose.words.ShapeType; |
| | | import com.aspose.words.WrapType; |
| | | |
| | | import javax.imageio.ImageIO; |
| | | import java.awt.image.BufferedImage; |
| | | import java.awt.geom.Rectangle2D; |
| | | import java.io.ByteArrayInputStream; |
| | | import java.io.InputStream; |
| | | import java.nio.file.Files; |
| | | import java.nio.file.Path; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * å°æ¥åä¸çå°ç« æ¹ä¸ºæµ®å¨å¾çï¼é¿å
å¾çå䏿£æè¡é«è®¡ç®èæ¹å忥åå页ã |
| | | */ |
| | | public final class ReportSealLayoutUtil { |
| | | |
| | | private static final double MA_LEFT = 30D; |
| | | private static final double MA_TOP = 30D; |
| | | private static final double MA_MAX_WIDTH = 90D; |
| | | private static final double MA_MAX_HEIGHT = 80D; |
| | | private static final double REPORT_MAX_WIDTH = 105D; |
| | | private static final double REPORT_MAX_HEIGHT = 105D; |
| | | private static final double LAST_PAGE_MAX_WIDTH = 110D; |
| | | private static final double LAST_PAGE_MAX_HEIGHT = 110D; |
| | | private static final double POSITION_GAP = 14D; |
| | | |
| | | private ReportSealLayoutUtil() { |
| | | } |
| | | |
| | | public static void apply(String wordPath, String reportSealPath, String maSealPath) throws Exception { |
| | | applyAsposeLicense(); |
| | | Document document = new Document(wordPath); |
| | | byte[] reportSealBytes = readImage(reportSealPath); |
| | | byte[] maSealBytes = readImage(maSealPath); |
| | | |
| | | if (reportSealBytes != null) { |
| | | removeMatchingImages(document, reportSealBytes); |
| | | document.updatePageLayout(); |
| | | addCoverReportSeal(document, reportSealPath); |
| | | addConclusionReportSeal(document, reportSealPath); |
| | | addLastPageReportSeal(document, reportSealPath); |
| | | } |
| | | if (maSealBytes != null) { |
| | | removeMatchingImages(document, maSealBytes); |
| | | document.updatePageLayout(); |
| | | // reportSeal ä¸ maSeal å¯è½éæ©åä¸å¼ å¾çï¼ç§»é¤åéè¦æ¢å¤ä¸ä¸ªæ¥åç« ä½ç½®ã |
| | | if (reportSealBytes != null && Arrays.equals(reportSealBytes, maSealBytes)) { |
| | | addCoverReportSeal(document, reportSealPath); |
| | | addConclusionReportSeal(document, reportSealPath); |
| | | addLastPageReportSeal(document, reportSealPath); |
| | | } |
| | | addFirstPageMaSeal(document, maSealPath); |
| | | } |
| | | |
| | | document.updatePageLayout(); |
| | | document.save(wordPath, SaveFormat.DOCX); |
| | | } |
| | | |
| | | private static void applyAsposeLicense() throws Exception { |
| | | try (InputStream inputStream = ReportSealLayoutUtil.class.getResourceAsStream("/lib/license.xml")) { |
| | | if (inputStream == null) { |
| | | throw new IllegalStateException("æªæ¾å° Aspose æææä»¶"); |
| | | } |
| | | License license = new License(); |
| | | license.setLicense(inputStream); |
| | | if (!license.getIsLicensed()) { |
| | | throw new IllegalStateException("Aspose ææéªè¯å¤±è´¥"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | private static byte[] readImage(String imagePath) throws Exception { |
| | | if (imagePath == null || imagePath.trim().isEmpty()) { |
| | | return null; |
| | | } |
| | | Path path = java.nio.file.Paths.get(imagePath); |
| | | return Files.isRegularFile(path) ? Files.readAllBytes(path) : null; |
| | | } |
| | | |
| | | private static void removeMatchingImages(Document document, byte[] imageBytes) throws Exception { |
| | | for (Shape shape : imageShapes(document)) { |
| | | if (sameImage(shape, imageBytes)) { |
| | | shape.remove(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | private static void addFirstPageMaSeal(Document document, String imagePath) throws Exception { |
| | | Paragraph anchor = firstBodyParagraph(document); |
| | | double[] size = fitImage(imagePath, MA_MAX_WIDTH, MA_MAX_HEIGHT); |
| | | Shape shape = createFloatingImage(document, imagePath, size[0], size[1]); |
| | | shape.setLeft(MA_LEFT); |
| | | shape.setTop(MA_TOP); |
| | | anchor.appendChild(shape); |
| | | } |
| | | |
| | | private static void addCoverReportSeal(Document document, String imagePath) throws Exception { |
| | | Paragraph anchor = firstBodyParagraph(document); |
| | | PageSetup pageSetup = document.getFirstSection().getPageSetup(); |
| | | double[] size = fitImage(imagePath, REPORT_MAX_WIDTH, REPORT_MAX_HEIGHT); |
| | | Shape shape = createFloatingImage(document, imagePath, size[0], size[1]); |
| | | shape.setLeft(pageSetup.getLeftMargin() + 20D); |
| | | shape.setTop(pageSetup.getPageHeight() - pageSetup.getBottomMargin() |
| | | - size[1] - POSITION_GAP); |
| | | shape.setBehindText(true); |
| | | anchor.appendChild(shape); |
| | | } |
| | | |
| | | private static void addConclusionReportSeal(Document document, String imagePath) throws Exception { |
| | | document.updatePageLayout(); |
| | | LayoutCollector collector = new LayoutCollector(document); |
| | | Paragraph anchor = findBodyParagraphContaining(document, "çç« ", collector, null); |
| | | if (anchor == null) { |
| | | return; |
| | | } |
| | | Rectangle2D rectangle = getLayoutRectangle(document, collector, anchor); |
| | | Section section = (Section) anchor.getAncestor(NodeType.SECTION); |
| | | PageSetup pageSetup = section.getPageSetup(); |
| | | int page = collector.getStartPageIndex(anchor); |
| | | Paragraph placementAnchor = findPageBodyAnchor(document, collector, page); |
| | | if (placementAnchor == null) { |
| | | placementAnchor = anchor; |
| | | } |
| | | double[] size = fitImage(imagePath, REPORT_MAX_WIDTH, REPORT_MAX_HEIGHT); |
| | | Shape shape = createFloatingImage(document, imagePath, size[0], size[1]); |
| | | shape.setLeft((pageSetup.getPageWidth() - size[0]) / 2D); |
| | | double preferredTop = rectangle == null |
| | | ? pageSetup.getPageHeight() - pageSetup.getBottomMargin() - size[1] - 120D |
| | | : rectangle.getY() - size[1] + rectangle.getHeight() / 2D; |
| | | shape.setTop(clamp(preferredTop, |
| | | pageSetup.getTopMargin(), |
| | | pageSetup.getPageHeight() - pageSetup.getBottomMargin() - size[1])); |
| | | // ç»è®ºç« ä½äºè¡¨æ ¼åå
æ ¼å
ï¼å¿
é¡»ç½®äºæå䏿¹ï¼å¦åä¼è¢«åå
æ ¼åºçº¹é®ä½ã |
| | | shape.setBehindText(false); |
| | | placementAnchor.appendChild(shape); |
| | | } |
| | | |
| | | private static void addLastPageReportSeal(Document document, String imagePath) throws Exception { |
| | | int lastPage = document.getPageCount(); |
| | | LayoutCollector collector = new LayoutCollector(document); |
| | | Paragraph anchor = findLastPageAnchor(document, collector, lastPage); |
| | | if (anchor == null) { |
| | | return; |
| | | } |
| | | Section section = (Section) anchor.getAncestor(NodeType.SECTION); |
| | | PageSetup pageSetup = section.getPageSetup(); |
| | | double[] size = fitImage(imagePath, LAST_PAGE_MAX_WIDTH, LAST_PAGE_MAX_HEIGHT); |
| | | Shape shape = createFloatingImage(document, imagePath, size[0], size[1]); |
| | | shape.setLeft((pageSetup.getPageWidth() - size[0]) / 2D); |
| | | Rectangle2D rectangle = getLayoutRectangle(document, collector, anchor); |
| | | double preferredTop = rectangle == null |
| | | ? pageSetup.getPageHeight() - pageSetup.getBottomMargin() - size[1] - POSITION_GAP |
| | | : rectangle.getY() + rectangle.getHeight() + POSITION_GAP; |
| | | shape.setTop(clamp(preferredTop, |
| | | pageSetup.getTopMargin(), |
| | | pageSetup.getPageHeight() - pageSetup.getBottomMargin() - size[1])); |
| | | shape.setBehindText(true); |
| | | anchor.appendChild(shape); |
| | | } |
| | | |
| | | private static Shape createFloatingImage(Document document, String imagePath, |
| | | double width, double height) throws Exception { |
| | | Shape shape = new Shape(document, ShapeType.IMAGE); |
| | | shape.getImageData().setImage(imagePath); |
| | | shape.setWidth(width); |
| | | shape.setHeight(height); |
| | | shape.setWrapType(WrapType.NONE); |
| | | shape.setRelativeHorizontalPosition(RelativeHorizontalPosition.PAGE); |
| | | shape.setRelativeVerticalPosition(RelativeVerticalPosition.PAGE); |
| | | shape.setAllowOverlap(true); |
| | | return shape; |
| | | } |
| | | |
| | | private static Paragraph firstBodyParagraph(Document document) { |
| | | Paragraph paragraph = document.getFirstSection().getBody().getFirstParagraph(); |
| | | if (paragraph != null) { |
| | | return paragraph; |
| | | } |
| | | return document.getFirstSection().getBody().appendParagraph(""); |
| | | } |
| | | |
| | | private static Paragraph findLastPageAnchor(Document document, LayoutCollector collector, int lastPage) |
| | | throws Exception { |
| | | Paragraph fallback = null; |
| | | NodeCollection paragraphs = document.getChildNodes(NodeType.PARAGRAPH, true); |
| | | for (int i = paragraphs.getCount() - 1; i >= 0; i--) { |
| | | Paragraph paragraph = (Paragraph) paragraphs.get(i); |
| | | if (paragraph.getAncestor(NodeType.BODY) == null) { |
| | | continue; |
| | | } |
| | | if (collector.getStartPageIndex(paragraph) != lastPage) { |
| | | continue; |
| | | } |
| | | if (fallback == null) { |
| | | fallback = paragraph; |
| | | } |
| | | if (paragraph.getText().contains("æ¥åç»æ")) { |
| | | return paragraph; |
| | | } |
| | | } |
| | | return fallback; |
| | | } |
| | | |
| | | private static Paragraph findBodyParagraphContaining(Document document, String text, |
| | | LayoutCollector collector, Integer page) |
| | | throws Exception { |
| | | NodeCollection paragraphs = document.getChildNodes(NodeType.PARAGRAPH, true); |
| | | for (int i = 0; i < paragraphs.getCount(); i++) { |
| | | Paragraph paragraph = (Paragraph) paragraphs.get(i); |
| | | if (paragraph.getAncestor(NodeType.BODY) == null || !paragraph.getText().contains(text)) { |
| | | continue; |
| | | } |
| | | if (page == null || collector.getStartPageIndex(paragraph) == page) { |
| | | return paragraph; |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | private static Paragraph findPageBodyAnchor(Document document, LayoutCollector collector, int page) |
| | | throws Exception { |
| | | NodeCollection paragraphs = document.getChildNodes(NodeType.PARAGRAPH, true); |
| | | for (int i = 0; i < paragraphs.getCount(); i++) { |
| | | Paragraph paragraph = (Paragraph) paragraphs.get(i); |
| | | if (paragraph.getAncestor(NodeType.BODY) == null |
| | | || paragraph.getAncestor(NodeType.CELL) != null) { |
| | | continue; |
| | | } |
| | | if (collector.getStartPageIndex(paragraph) == page) { |
| | | return paragraph; |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | private static Rectangle2D getLayoutRectangle(Document document, LayoutCollector collector, |
| | | Paragraph paragraph) throws Exception { |
| | | Object entity = collector.getEntity(paragraph); |
| | | if (entity == null) { |
| | | NodeCollection runs = paragraph.getChildNodes(NodeType.RUN, true); |
| | | for (int i = 0; i < runs.getCount() && entity == null; i++) { |
| | | entity = collector.getEntity(runs.get(i)); |
| | | } |
| | | } |
| | | if (entity == null) { |
| | | return null; |
| | | } |
| | | LayoutEnumerator enumerator = new LayoutEnumerator(document); |
| | | enumerator.setCurrent(entity); |
| | | return enumerator.getRectangle(); |
| | | } |
| | | |
| | | private static double clamp(double value, double min, double max) { |
| | | return Math.max(min, Math.min(value, max)); |
| | | } |
| | | |
| | | private static List<Shape> imageShapes(Document document) throws Exception { |
| | | List<Shape> result = new ArrayList<>(); |
| | | NodeCollection nodes = document.getChildNodes(NodeType.SHAPE, true); |
| | | for (int i = 0; i < nodes.getCount(); i++) { |
| | | Shape shape = (Shape) nodes.get(i); |
| | | if (shape.hasImage()) { |
| | | result.add(shape); |
| | | } |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | private static boolean sameImage(Shape shape, byte[] imageBytes) throws Exception { |
| | | return Arrays.equals(shape.getImageData().toByteArray(), imageBytes); |
| | | } |
| | | |
| | | private static double[] fitImage(String imagePath, double maxWidth, double maxHeight) throws Exception { |
| | | BufferedImage image = ImageIO.read(new ByteArrayInputStream(Files.readAllBytes( |
| | | java.nio.file.Paths.get(imagePath)))); |
| | | if (image == null || image.getWidth() <= 0 || image.getHeight() <= 0) { |
| | | return new double[]{maxWidth, maxHeight}; |
| | | } |
| | | double scale = Math.min(maxWidth / image.getWidth(), maxHeight / image.getHeight()); |
| | | return new double[]{image.getWidth() * scale, image.getHeight() * scale}; |
| | | } |
| | | |
| | | } |
| | |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | import java.time.LocalDateTime; |
| | | import java.time.LocalDate; |
| | | |
| | | /** |
| | | * @Author zhuo |
| | |
| | | @ApiModelProperty("è§æ ¼åå·") |
| | | private String sampleModel; |
| | | |
| | | @ApiModelProperty("å§ææ¥æ") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | private LocalDateTime sendTime; |
| | | @ApiModelProperty("éæ ·æ¥æ") |
| | | @JsonFormat(pattern = "yyyy-MM-dd") |
| | | private LocalDate sampleDate; |
| | | |
| | | @ApiModelProperty("å§æäºº") |
| | | private String prepareUser; |
| | |
| | | @ApiModelProperty("温度") |
| | | private String temperature; |
| | | |
| | | @ApiModelProperty("湿度") |
| | | private String humidity; |
| | | |
| | | @ApiModelProperty("æ£æµæ¥æ") |
| | | @JsonFormat(pattern = "yyyy-MM-dd") |
| | | private LocalDate detectionTime; |
| | |
| | | en_device_name, |
| | | specification_model, |
| | | management_number, |
| | | factory_no, |
| | | date_format(activation_date,'%Y-%m-%d') |
| | | latest_traceability |
| | | from device |
| | |
| | | from (select io2.id insOrderId, |
| | | io2.sample_view, |
| | | io2.production, |
| | | io2.send_time, |
| | | io2.sample_date, |
| | | GROUP_CONCAT(DISTINCT isa.model SEPARATOR ' ') AS sample_model, |
| | | io2.prepare_user, |
| | | io2.entrust_code, |
| | |
| | | case when type_source = 0 then 'æåä¸å' else 'åææä¸å' end type_source, |
| | | case |
| | | when order_type = 'æ½æ£' then 'æ½æ£' |
| | | when order_type = 'Commissioned testing' then 'å§ææ£æµ' |
| | | when order_type = 'Inter-laboratory comparison' then 'å®éªå®¤é´æ¯å¯¹' |
| | | when order_type = 'Proficiency testing' then 'è½åéªè¯' |
| | | when order_type = 'Customer-ordered test' then 'å§ææ£éª' |
| | | when order_type = 'è¿åæ£éª' then 'è¿åæ£éª' |
| | | when order_type = 'Quarterly inspection' then 'å£åº¦æ£éª' |
| | |
| | | # port: 6379 |
| | | port: 11102 |
| | | # æ°æ®åºç´¢å¼ |
| | | database: 0 |
| | | database: 6 |
| | | # # å¯ç |
| | | password: |
| | | # è¿æ¥è¶
æ¶æ¶é´ |
| | |
| | | # å¼åç¯å¢é
ç½® |
| | | server: |
| | | # æå¡å¨çHTTPç«¯å£ |
| | | port: 8001 |
| | | # æå¡å¨ç«¯å£ |
| | | # port: 9509 |
| | | port: 9509 |
| | | servlet: |
| | | # åºç¨ç访é®è·¯å¾ |
| | | context-path: /lims |
| | |
| | | servlet: |
| | | multipart: |
| | | # å个æä»¶å¤§å° |
| | | max-file-size: 10MB |
| | | max-file-size: 200MB |
| | | # 设置æ»ä¸ä¼ çæä»¶å¤§å° |
| | | max-request-size: 20MB |
| | | max-request-size: 400MB |
| | | # æå¡æ¨¡å |
| | | # devtools: |
| | | # restart: |
| | |
| | | * @Date 2024/8/11 |
| | | */ |
| | | public class InsOrderTypeConstants { |
| | | // å§ææ£æµ |
| | | public static final String COMMISSIONED_TEST = "Commissioned testing"; |
| | | // å®éªå®¤é´æ¯å¯¹ |
| | | public static final String INTER_LABORATORY_COMPARISON = "Inter-laboratory comparison"; |
| | | // è½åéªè¯ |
| | | public static final String PROFICIENCY_TESTING = "Proficiency testing"; |
| | | // æ£éªç±»å |
| | | public static final String SPOT_CHECK = "æ½æ£"; |
| | | // å§ææ£éª |
| | |
| | | // è·åç®æ æ¹æ³ä¸ç注解 |
| | | PersonalScope annotation = signature.getMethod().getAnnotation(PersonalScope.class); |
| | | |
| | | // è¶
级管çåæ¥çæ¥åç¼å¶æ¶ä¸éå¶ä¸ºâä»
çæâ |
| | | if (SecurityUtils.isAdmin(userId) && "business:reportPreparation".equals(annotation.permsName())) { |
| | | return; |
| | | } |
| | | |
| | | // è·åæé夿æ¯å¦æ¯ä»
çæ |
| | | SysRoleVo sysRoleVo = sysRoleMenuMapper.selectRoleMenu(annotation.permsName(), userId); |
| | | |