From 8afeada3d712c0de2b50b5190600e0da22a8997b Mon Sep 17 00:00:00 2001 From: PoffyZhang <99775271@qq.com> Date: Mon, 9 Oct 2023 17:14:37 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A9=BE=E9=A9=B6=E8=88=B1=20=E9=A1=B9?= =?UTF-8?q?=E7=9B=AE=E7=94=BB=E5=83=8F=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dashboard/model/vo/ProtraitProjectInfoVO.java | 3 + .../pmapi/collection/SaveCollectionTest331125.java | 94 ++++++++++++++++++++-- 2 files changed, 90 insertions(+), 7 deletions(-) diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/dashboard/model/vo/ProtraitProjectInfoVO.java b/pmapi/src/main/java/com/ningdatech/pmapi/dashboard/model/vo/ProtraitProjectInfoVO.java index 726f4e1..bc38835 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/dashboard/model/vo/ProtraitProjectInfoVO.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/dashboard/model/vo/ProtraitProjectInfoVO.java @@ -43,6 +43,9 @@ public class ProtraitProjectInfoVO { @ApiModelProperty("项目安全投入占比") private String safetyInputRate; + @ApiModelProperty("项目简介") + private String projectIntroduction; + @ApiModelProperty("超期情况") private String overdueSituation; diff --git a/pmapi/src/test/java/com/ningdatech/pmapi/collection/SaveCollectionTest331125.java b/pmapi/src/test/java/com/ningdatech/pmapi/collection/SaveCollectionTest331125.java index 0b4d6b5..133a10d 100644 --- a/pmapi/src/test/java/com/ningdatech/pmapi/collection/SaveCollectionTest331125.java +++ b/pmapi/src/test/java/com/ningdatech/pmapi/collection/SaveCollectionTest331125.java @@ -25,7 +25,9 @@ import org.springframework.beans.factory.annotation.Autowired; import java.io.*; import java.time.LocalDateTime; +import java.util.List; import java.util.Objects; +import java.util.stream.Collectors; /** * @Classname SaveCollectionTest @@ -57,7 +59,7 @@ public class SaveCollectionTest331125 extends AppTests {// @Test public void importData() throws Exception { Workbook wb; - File f = new File("C:\\Users\\PoffyZhang\\Desktop\\丽水市项目底数清单.xlsx"); + File f = new File("C:\\Users\\PoffyZhang\\Desktop\\丽水开发区(1).xlsx"); wb = readExcel(new FileInputStream(f),f.getName()); Row row = null; if(wb != null) { @@ -78,7 +80,7 @@ public class SaveCollectionTest331125 extends AppTests {// GovBizProjectBaseinfoDTO baseinfoDTO = new GovBizProjectBaseinfoDTO(); // - String projName = Objects.nonNull(row.getCell(3)) ? row.getCell(3).toString() : StringUtils.EMPTY; + String projName = Objects.nonNull(row.getCell(0)) ? row.getCell(0).toString() : StringUtils.EMPTY; baseinfoDTO.setBaseProjName(projName); baseinfoDTO.setBaseAreaCode(RegionConst.LS_KF + BizConst.NINE_AREA_CODE_LAST); baseinfoDTO.setBaseAreaName(RegionConst.LS_KF_NAME); @@ -87,18 +89,16 @@ public class SaveCollectionTest331125 extends AppTests {// baseinfoDTO.setTongTime(LocalDateTime.now()); baseinfoDTO.setBizTime(LocalDateTime.now()); baseinfoDTO.setOp("insert"); - String principal = Objects.nonNull(row.getCell(5)) ? row.getCell(5).toString() : StringUtils.EMPTY; + String principal = Objects.nonNull(row.getCell(3)) ? row.getCell(3).toString() : StringUtils.EMPTY; baseinfoDTO.setBaseProjPrincipal(principal); - String contacts = Objects.nonNull(row.getCell(6)) ? row.getCell(6).toString() : StringUtils.EMPTY; + String contacts = Objects.nonNull(row.getCell(4)) ? row.getCell(4).toString() : StringUtils.EMPTY; baseinfoDTO.setBaseProjContacts(contacts); baseinfoDTO.setBaseProjType("01"); saveDTO.setBaseinfo(baseinfoDTO); GovBizProjectApplyDTO applyDTO = new GovBizProjectApplyDTO(); - String baseProjSetYear = Objects.nonNull(row.getCell(8)) ? row.getCell(8).toString() : StringUtils.EMPTY; + String baseProjSetYear = Objects.nonNull(row.getCell(20)) ? row.getCell(20).toString() : StringUtils.EMPTY; applyDTO.setBaseProjSetYear(baseProjSetYear); - String baseProjIntro = Objects.nonNull(row.getCell(9)) ? row.getCell(9).toString() : StringUtils.EMPTY; - applyDTO.setBaseProjIntro(baseProjIntro); saveDTO.setApply(applyDTO); //生产编号 String projId = projectCodeUtil.generateProjectCode(saveDTO); @@ -154,6 +154,86 @@ public class SaveCollectionTest331125 extends AppTests {// System.out.println("导入完成"); } + @Test + public void test2() throws FileNotFoundException { + //先删除 开发区的 + List lss = baseinfoService.list(Wrappers.lambdaQuery(GovBizProjectBaseinfo.class) + .eq(GovBizProjectBaseinfo::getBaseAreaCode, RegionConst.LS_KF + BizConst.NINE_AREA_CODE_LAST)); + List codes = lss.stream().map(GovBizProjectBaseinfo::getBaseProjId).collect(Collectors.toList()); + applyService.remove(Wrappers.lambdaQuery(GovBizProjectApply.class) + .in(GovBizProjectApply::getBaseProjId,codes)); + approveService.remove(Wrappers.lambdaQuery(GovBizProjectApprove.class) + .in(GovBizProjectApprove::getBaseProjId,codes)); + cimplementService.remove(Wrappers.lambdaQuery(GovBizProjectCimplement.class) + .in(GovBizProjectCimplement::getBaseProjId,codes)); + mimplementService.remove(Wrappers.lambdaQuery(GovBizProjectMimplement.class) + .in(GovBizProjectMimplement::getBaseProjId,codes)); + procureService.remove(Wrappers.lambdaQuery(GovBizProjectProcure.class) + .in(GovBizProjectProcure::getBaseProjId,codes)); + baseinfoService.remove(Wrappers.lambdaQuery(GovBizProjectBaseinfo.class) + .in(GovBizProjectBaseinfo::getBaseProjId,codes)); + + Workbook wb; + File f = new File("C:\\Users\\PoffyZhang\\Desktop\\丽水开发区(1).xlsx"); + wb = readExcel(new FileInputStream(f),f.getName()); + Row row = null; + if(wb != null) { + //获取第一个sheet + Sheet sheet = wb.getSheetAt(0); + //获取最大行数 + int rownum = sheet.getPhysicalNumberOfRows(); + + //获取第一行 + row = sheet.getRow(0); + //获取最大列数 + for (int i = 1; i < rownum; i++) { + row = sheet.getRow(i); + if (Objects.isNull(row) || Objects.isNull(row.getCell(0))) { + break; + } + GovBizProjectSaveDTO saveDTO = new GovBizProjectSaveDTO(); + + GovBizProjectBaseinfoDTO baseinfoDTO = new GovBizProjectBaseinfoDTO(); + // + String projName = Objects.nonNull(row.getCell(0)) ? row.getCell(0).toString() : StringUtils.EMPTY; + baseinfoDTO.setBaseProjName(projName); + baseinfoDTO.setBaseAreaCode(RegionConst.LS_KF + BizConst.NINE_AREA_CODE_LAST); + baseinfoDTO.setBaseAreaName(RegionConst.LS_KF_NAME); + baseinfoDTO.setAreaCode(RegionConst.RC_LS); + baseinfoDTO.setIsEffective(BizProjectContant.ProjectCollection.IS_EFFECTIVE); + baseinfoDTO.setTongTime(LocalDateTime.now()); + baseinfoDTO.setBizTime(LocalDateTime.now()); + baseinfoDTO.setOp("insert"); + String principal = Objects.nonNull(row.getCell(3)) ? row.getCell(3).toString() : StringUtils.EMPTY; + baseinfoDTO.setBaseProjPrincipal(principal); + String contacts = Objects.nonNull(row.getCell(4)) ? row.getCell(4).toString() : StringUtils.EMPTY; + baseinfoDTO.setBaseProjContacts(contacts); + baseinfoDTO.setBaseProjType("01"); + saveDTO.setBaseinfo(baseinfoDTO); + + GovBizProjectApplyDTO applyDTO = new GovBizProjectApplyDTO(); + String baseProjSetYear = Objects.nonNull(row.getCell(20)) ? row.getCell(20).toString().substring(0,4) : StringUtils.EMPTY; + applyDTO.setBaseProjSetYear(baseProjSetYear); + saveDTO.setApply(applyDTO); + //生产编号 + String projId = projectCodeUtil.generateProjectCode(saveDTO); + saveDTO.setBaseProjId(projId); + saveDTO.getBaseinfo().setBaseProjId(projId); + saveDTO.getApply().setBaseProjId(projId); + UserInfoDetails user = new UserInfoDetails(); + user.setRegionCode(RegionConst.LS_KF); + user.setUsername("系统导入"); + String save = ""; + try { + save = manage.save(saveDTO, user); + }catch (Exception e){ + e.printStackTrace(); + } + System.out.println(JSON.toJSONString(save)); + } + } + } + //这个下面是单独函数 public static Workbook readExcel(InputStream is, String extString){ Workbook wb = null;