From 1d908e629d7a1750eebaa849e944be08ba7f5876 Mon Sep 17 00:00:00 2001 From: liuxm <liuxm_a@163.com> Date: 星期四, 23 五月 2024 10:30:01 +0800 Subject: [PATCH] id序列化;技术参数保存修改 --- pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/product/ProductSv.java | 61 ++++++++++++++++++++++++++---- 1 files changed, 52 insertions(+), 9 deletions(-) diff --git a/pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/product/ProductSv.java b/pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/product/ProductSv.java index 2c1dcaf..52970e2 100644 --- a/pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/product/ProductSv.java +++ b/pms-parent/pms-web-platform/src/main/java/com/dy/pmsPlatform/product/ProductSv.java @@ -1,5 +1,6 @@ package com.dy.pmsPlatform.product; +import com.alibaba.excel.util.StringUtils; import com.dy.common.webUtil.QueryResultVo; import com.dy.pmsGlobal.daoOth.OthFileMapper; import com.dy.pmsGlobal.daoPlt.PltProParamsMapper; @@ -11,10 +12,12 @@ import com.dy.pmsGlobal.pojoOth.OthFile; import com.dy.pmsGlobal.pojoPlt.PltProduct; import com.dy.pmsGlobal.pojoPlt.PltProductFile; +import jakarta.servlet.http.HttpServletResponse; import lombok.extern.slf4j.Slf4j; import org.apache.dubbo.common.utils.PojoUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; +import org.springframework.dao.DuplicateKeyException; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -35,6 +38,9 @@ @Value("${dy.webFile.fmUrl}") private String fmUrl ; + + private static final String DEFAULT_CODE = "001"; + private static final String CODE_FORMAT = "%03d"; @Autowired public void setFileOperate(FileOperate fileOperate){ @@ -65,12 +71,38 @@ @Transactional public int save(PltProduct p) { - int count = dao.insert(p); - if(count>0){ - saveProRel(p); - } - return count; + int flag=0; + do { + p.code = getNextCode(); + try { + int count = dao.insertSelective(p); + if (count > 0) { + saveProRel(p); + return count; + } + } catch (DuplicateKeyException e) { + // 濡傛灉鍑虹幇鍞竴绾︽潫杩濆弽寮傚父锛屽皾璇曡幏鍙栨柊鐨刢ode骞堕噸璇� + log.warn("鎻掑叆浜у搧鏃堕亣鍒板敮涓�绾︽潫寮傚父锛屽皾璇曡幏鍙栨柊鐨刢ode", e); + } + flag++; + } while (flag<5); + return 0; } + private String getNextCode(){ + log.info("鑾峰彇浜у搧缂栧彿"); + String maxCode = dao.selectMaxCode(); + if (StringUtils.isBlank(maxCode)) { + return DEFAULT_CODE; + } else { + int nextCode = Integer.parseInt(maxCode) + 1; + // 妫�鏌ユ孩鍑� + if (nextCode > 999) { + throw new RuntimeException("浜у搧缂栧彿婧㈠嚭"); + } + return String.format(CODE_FORMAT, nextCode); + } + } + @Transactional public int update(PltProduct p) { int count = dao.updateByPrimaryKeySelective(p); @@ -87,6 +119,7 @@ if(param.id !=null){ paramDao.updateByPrimaryKeySelective(param); }else{ + param.deleted=false; paramDao.insert(param); } }); @@ -134,8 +167,12 @@ Stream.concat(pro.processDocuments.stream(), pro.materials.stream()) ) .forEach(doc -> { - String webUrl = getFilePathWithWebUrl(doc.fileId); - doc.webUrl = webUrl; + OthFile file = othFileMapper.selectByPrimaryKey(doc.fileId); + FileRestVo fileRestVo = fileOperate.parseHashcode(fmUrl, file.hash); + + doc.webUrl = fileRestVo.fileWebUrl + file.filePath; + doc.orgName = file.orgName; + doc.extName = file.extName; }); } return pro; @@ -187,7 +224,13 @@ } - public List<PltProduct> selectAll() { - return dao.selectAll(); + public List<PltProduct> selectAll(QueryVo queryVo) { + Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(queryVo); + return dao.selectAll(params); + } + + + public void downloadDoc(HttpServletResponse response) { + PltProduct pro=dao.selectByPrimaryKey(Long.valueOf(1)); } } -- Gitblit v1.8.0