|
@@ -25,7 +25,9 @@ import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
|
|
|
|
|
import java.io.*; |
|
|
import java.io.*; |
|
|
import java.time.LocalDateTime; |
|
|
import java.time.LocalDateTime; |
|
|
|
|
|
import java.util.List; |
|
|
import java.util.Objects; |
|
|
import java.util.Objects; |
|
|
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* @Classname SaveCollectionTest |
|
|
* @Classname SaveCollectionTest |
|
@@ -57,7 +59,7 @@ public class SaveCollectionTest331125 extends AppTests {// |
|
|
@Test |
|
|
@Test |
|
|
public void importData() throws Exception { |
|
|
public void importData() throws Exception { |
|
|
Workbook wb; |
|
|
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()); |
|
|
wb = readExcel(new FileInputStream(f),f.getName()); |
|
|
Row row = null; |
|
|
Row row = null; |
|
|
if(wb != null) { |
|
|
if(wb != null) { |
|
@@ -78,7 +80,7 @@ public class SaveCollectionTest331125 extends AppTests {// |
|
|
|
|
|
|
|
|
GovBizProjectBaseinfoDTO baseinfoDTO = new GovBizProjectBaseinfoDTO(); |
|
|
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.setBaseProjName(projName); |
|
|
baseinfoDTO.setBaseAreaCode(RegionConst.LS_KF + BizConst.NINE_AREA_CODE_LAST); |
|
|
baseinfoDTO.setBaseAreaCode(RegionConst.LS_KF + BizConst.NINE_AREA_CODE_LAST); |
|
|
baseinfoDTO.setBaseAreaName(RegionConst.LS_KF_NAME); |
|
|
baseinfoDTO.setBaseAreaName(RegionConst.LS_KF_NAME); |
|
@@ -87,18 +89,16 @@ public class SaveCollectionTest331125 extends AppTests {// |
|
|
baseinfoDTO.setTongTime(LocalDateTime.now()); |
|
|
baseinfoDTO.setTongTime(LocalDateTime.now()); |
|
|
baseinfoDTO.setBizTime(LocalDateTime.now()); |
|
|
baseinfoDTO.setBizTime(LocalDateTime.now()); |
|
|
baseinfoDTO.setOp("insert"); |
|
|
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); |
|
|
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.setBaseProjContacts(contacts); |
|
|
baseinfoDTO.setBaseProjType("01"); |
|
|
baseinfoDTO.setBaseProjType("01"); |
|
|
saveDTO.setBaseinfo(baseinfoDTO); |
|
|
saveDTO.setBaseinfo(baseinfoDTO); |
|
|
|
|
|
|
|
|
GovBizProjectApplyDTO applyDTO = new GovBizProjectApplyDTO(); |
|
|
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); |
|
|
applyDTO.setBaseProjSetYear(baseProjSetYear); |
|
|
String baseProjIntro = Objects.nonNull(row.getCell(9)) ? row.getCell(9).toString() : StringUtils.EMPTY; |
|
|
|
|
|
applyDTO.setBaseProjIntro(baseProjIntro); |
|
|
|
|
|
saveDTO.setApply(applyDTO); |
|
|
saveDTO.setApply(applyDTO); |
|
|
//生产编号 |
|
|
//生产编号 |
|
|
String projId = projectCodeUtil.generateProjectCode(saveDTO); |
|
|
String projId = projectCodeUtil.generateProjectCode(saveDTO); |
|
@@ -154,6 +154,86 @@ public class SaveCollectionTest331125 extends AppTests {// |
|
|
System.out.println("导入完成"); |
|
|
System.out.println("导入完成"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
|
public void test2() throws FileNotFoundException { |
|
|
|
|
|
//先删除 开发区的 |
|
|
|
|
|
List<GovBizProjectBaseinfo> lss = baseinfoService.list(Wrappers.lambdaQuery(GovBizProjectBaseinfo.class) |
|
|
|
|
|
.eq(GovBizProjectBaseinfo::getBaseAreaCode, RegionConst.LS_KF + BizConst.NINE_AREA_CODE_LAST)); |
|
|
|
|
|
List<String> 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){ |
|
|
public static Workbook readExcel(InputStream is, String extString){ |
|
|
Workbook wb = null; |
|
|
Workbook wb = null; |
|
|