|
@@ -1,137 +1,134 @@
|
|
|
-package com.example.controller;
|
|
|
-
|
|
|
-import cn.hutool.poi.excel.WorkbookUtil;
|
|
|
-import com.example.config.annotation.IgnoreAuth;
|
|
|
-import com.example.entity.OtnAreaEntity;
|
|
|
-import com.example.entity.WzHouseContractCompareEntity;
|
|
|
-import com.example.service.WzHouseContractCompareService;
|
|
|
-import com.example.service.WzHouseContractTopService;
|
|
|
-import com.example.service.WzOtnAreaService;
|
|
|
-import com.example.utils.PageMap;
|
|
|
-import com.example.utils.PageUtils;
|
|
|
-import com.example.utils.Query;
|
|
|
-import com.example.utils.R;
|
|
|
-import org.apache.poi.ss.usermodel.Cell;
|
|
|
-import org.apache.poi.ss.usermodel.Row;
|
|
|
-import org.apache.poi.ss.usermodel.Sheet;
|
|
|
-import org.apache.poi.ss.usermodel.Workbook;
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.web.bind.annotation.PathVariable;
|
|
|
-import org.springframework.web.bind.annotation.PostMapping;
|
|
|
-import org.springframework.web.bind.annotation.RequestBody;
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
-import org.springframework.web.bind.annotation.RestController;
|
|
|
-
|
|
|
-import java.io.File;
|
|
|
-import java.text.DateFormat;
|
|
|
-import java.text.SimpleDateFormat;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.List;
|
|
|
-
|
|
|
-import static com.example.utils.excel.ExcelTool.getCellValue;
|
|
|
-
|
|
|
-/**
|
|
|
- * 房屋出租(合同管理)
|
|
|
- */
|
|
|
-@RestController
|
|
|
-@RequestMapping("/house-car/house/dist/api/wzOtnArea")
|
|
|
-public class WzOtnAreaController {
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private WzOtnAreaService wzOtnAreaService;
|
|
|
- @Autowired
|
|
|
- private WzHouseContractTopService wzHouseContractTopService;
|
|
|
- @Autowired
|
|
|
- private WzHouseContractCompareService wzHouseContractCompareService;
|
|
|
-
|
|
|
- @RequestMapping("/list")
|
|
|
- @IgnoreAuth
|
|
|
- public R list(@RequestBody PageMap pageMap) {
|
|
|
- //查询列表数据
|
|
|
- Query query = new Query(pageMap);
|
|
|
- List<OtnAreaEntity> list = wzOtnAreaService.queryList(query);
|
|
|
- int total = wzOtnAreaService.queryTotal(query);
|
|
|
- PageUtils pageUtil = new PageUtils(list, total, query.getLimit(), query.getPage());
|
|
|
- return R.ok().put("page", pageUtil);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 查找所有的省份
|
|
|
- */
|
|
|
- @RequestMapping("/getCityOption/{id}")
|
|
|
- @IgnoreAuth
|
|
|
- public R getCityOption(@PathVariable("id") String id) {
|
|
|
- List<OtnAreaEntity> list=wzOtnAreaService.getCityOption(Long.valueOf(id));
|
|
|
- return R.ok().put("list",list);
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- /**
|
|
|
- * 导入Excel
|
|
|
- */
|
|
|
- @PostMapping("/import")
|
|
|
- @IgnoreAuth
|
|
|
- public R importExcel(){
|
|
|
- DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
- OtnAreaEntity sysConfig;
|
|
|
- int errorIndex = 0;
|
|
|
- try {
|
|
|
- String[] title = new String[]{
|
|
|
- "使用单位层级","使用单位隶属的省级公司","使用单位隶属的地市级公司",
|
|
|
- "使用单位隶属的区县级公司", "使用专业线","租入实际用途",
|
|
|
- "租入其他用途说明","城市区域","地段","合同总金额(含税)(元)","租入建筑面积(平米)", "租期(年)","每平米月租金","","",
|
|
|
- "合同编号","合同名称"
|
|
|
- };
|
|
|
- File file=new File("C:\\Users\\PRO\\Desktop\\版本\\version3\\test1.xlsx");
|
|
|
- List<String[]> list = new ArrayList();
|
|
|
- Workbook workbook = WorkbookUtil.createBook(file);
|
|
|
- // 获取第一张工作表
|
|
|
- Sheet sheet = workbook.getSheetAt(0);
|
|
|
- // 循环获取每一行数据 因为默认第一行为标题行,我们可以从 1 开始循环,如果需要读取标题行,从 0 开始
|
|
|
- // sheet.getRows() 获取总行数
|
|
|
- Row row;
|
|
|
- for (int i = sheet.getFirstRowNum() + 1; i <= sheet.getLastRowNum(); i++) {
|
|
|
- row = sheet.getRow(i);
|
|
|
- System.out.println(i);
|
|
|
- if (i >= 1 && row != null && row.getCell(0) != null && !row.getCell(0).toString().equals("")) {
|
|
|
- String[] t = new String[title.length];
|
|
|
- for (int m = 0; m < title.length; m++) {
|
|
|
- Cell cell = row.getCell(m);
|
|
|
- t[m] = getCellValue(cell);
|
|
|
- }
|
|
|
- list.add(t);
|
|
|
- }
|
|
|
- }
|
|
|
- for(int i=0;i<list.size();i++){
|
|
|
- WzHouseContractCompareEntity topEntity=new WzHouseContractCompareEntity();
|
|
|
- topEntity.setUseTheUnitsHierarchy(list.get(i)[0]);
|
|
|
- topEntity.setProvince(list.get(i)[1]);
|
|
|
- topEntity.setCity(list.get(i)[2]);
|
|
|
- topEntity.setCounty(list.get(i)[3]);
|
|
|
- topEntity.setUseTheProLine(list.get(i)[4]);
|
|
|
- topEntity.setLeaseInPracticalUse(list.get(i)[5]);
|
|
|
- topEntity.setDescriptionOfOtherUsesOfTheLease(list.get(i)[6]);
|
|
|
- topEntity.setCityArea(list.get(i)[7]);
|
|
|
- topEntity.setDistrict(list.get(i)[8]);
|
|
|
- topEntity.setRentalBuildingArea(list.get(i)[9]);
|
|
|
- topEntity.setHireTime(list.get(i)[10]);
|
|
|
- topEntity.setTotalMonthlyRent(list.get(i)[11]);
|
|
|
- topEntity.setContractAmountIncludingTax(list.get(i)[12]);
|
|
|
- topEntity.setFtProvinceAverage(list.get(i)[13]);
|
|
|
- topEntity.setPriceProvinceAverage(list.get(i)[14]);
|
|
|
- topEntity.setContractNumber(list.get(i)[15]);
|
|
|
- topEntity.setContractName(list.get(i)[16]);
|
|
|
- wzHouseContractCompareService.save(topEntity);
|
|
|
- }
|
|
|
-
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
- return R.error("第"+(errorIndex)+"行数据有问题,导入失败");
|
|
|
- }
|
|
|
- return R.ok();
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-}
|
|
|
+//package com.example.controller;
|
|
|
+//
|
|
|
+//import cn.hutool.poi.excel.WorkbookUtil;
|
|
|
+//import com.example.config.annotation.IgnoreAuth;
|
|
|
+//import com.example.entity.OtnAreaEntity;
|
|
|
+//import com.example.entity.WzHouseContractCompareEntity;
|
|
|
+//import com.example.service.WzHouseContractCompareService;
|
|
|
+//import com.example.service.WzHouseContractTopService;
|
|
|
+//import com.example.service.WzOtnAreaService;
|
|
|
+//import com.example.utils.PageMap;
|
|
|
+//import com.example.utils.PageUtils;
|
|
|
+//import com.example.utils.R;
|
|
|
+//import org.apache.poi.ss.usermodel.Cell;
|
|
|
+//import org.apache.poi.ss.usermodel.Row;
|
|
|
+//import org.apache.poi.ss.usermodel.Sheet;
|
|
|
+//import org.apache.poi.ss.usermodel.Workbook;
|
|
|
+//import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+//import org.springframework.web.bind.annotation.PathVariable;
|
|
|
+//import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+//import org.springframework.web.bind.annotation.RestController;
|
|
|
+//
|
|
|
+//import java.io.File;
|
|
|
+//import java.text.DateFormat;
|
|
|
+//import java.text.SimpleDateFormat;
|
|
|
+//import java.util.ArrayList;
|
|
|
+//import java.util.List;
|
|
|
+//
|
|
|
+//import static com.example.utils.excel.ExcelTool.getCellValue;
|
|
|
+//
|
|
|
+///**
|
|
|
+// * 房屋出租(合同管理)
|
|
|
+// */
|
|
|
+//@RestController
|
|
|
+//@RequestMapping("/house-car/house/dist/api/wzOtnArea")
|
|
|
+//public class WzOtnAreaController {
|
|
|
+//
|
|
|
+// @Autowired
|
|
|
+// private WzOtnAreaService wzOtnAreaService;
|
|
|
+// @Autowired
|
|
|
+// private WzHouseContractTopService wzHouseContractTopService;
|
|
|
+// @Autowired
|
|
|
+// private WzHouseContractCompareService wzHouseContractCompareService;
|
|
|
+//
|
|
|
+// @RequestMapping("/list")
|
|
|
+// @IgnoreAuth
|
|
|
+// public R list(@RequestBody PageMap pageMap) {
|
|
|
+// //查询列表数据
|
|
|
+// Query query = new Query(pageMap);
|
|
|
+// List<OtnAreaEntity> list = wzOtnAreaService.queryList(query);
|
|
|
+// int total = wzOtnAreaService.queryTotal(query);
|
|
|
+// PageUtils pageUtil = new PageUtils(list, total, query.getLimit(), query.getPage());
|
|
|
+// return R.ok().put("page", pageUtil);
|
|
|
+// }
|
|
|
+//
|
|
|
+// /**
|
|
|
+// * 查找所有的省份
|
|
|
+// */
|
|
|
+// @RequestMapping("/getCityOption/{id}")
|
|
|
+// @IgnoreAuth
|
|
|
+// public R getCityOption(@PathVariable("id") String id) {
|
|
|
+// List<OtnAreaEntity> list=wzOtnAreaService.getCityOption(Long.valueOf(id));
|
|
|
+// return R.ok().put("list",list);
|
|
|
+// }
|
|
|
+//
|
|
|
+//
|
|
|
+// /**
|
|
|
+// * 导入Excel
|
|
|
+// */
|
|
|
+//// @PostMapping("/import")
|
|
|
+// @IgnoreAuth
|
|
|
+// public R importExcel(){
|
|
|
+// DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+// OtnAreaEntity sysConfig;
|
|
|
+// int errorIndex = 0;
|
|
|
+// try {
|
|
|
+// String[] title = new String[]{
|
|
|
+// "使用单位层级","使用单位隶属的省级公司","使用单位隶属的地市级公司",
|
|
|
+// "使用单位隶属的区县级公司", "使用专业线","租入实际用途",
|
|
|
+// "租入其他用途说明","城市区域","地段","合同总金额(含税)(元)","租入建筑面积(平米)", "租期(年)","每平米月租金","","",
|
|
|
+// "合同编号","合同名称"
|
|
|
+// };
|
|
|
+// File file=new File("C:\\Users\\PRO\\Desktop\\版本\\version3\\test1.xlsx");
|
|
|
+// List<String[]> list = new ArrayList();
|
|
|
+// Workbook workbook = WorkbookUtil.createBook(file);
|
|
|
+// // 获取第一张工作表
|
|
|
+// Sheet sheet = workbook.getSheetAt(0);
|
|
|
+// // 循环获取每一行数据 因为默认第一行为标题行,我们可以从 1 开始循环,如果需要读取标题行,从 0 开始
|
|
|
+// // sheet.getRows() 获取总行数
|
|
|
+// Row row;
|
|
|
+// for (int i = sheet.getFirstRowNum() + 1; i <= sheet.getLastRowNum(); i++) {
|
|
|
+// row = sheet.getRow(i);
|
|
|
+// System.out.println(i);
|
|
|
+// if (i >= 1 && row != null && row.getCell(0) != null && !row.getCell(0).toString().equals("")) {
|
|
|
+// String[] t = new String[title.length];
|
|
|
+// for (int m = 0; m < title.length; m++) {
|
|
|
+// Cell cell = row.getCell(m);
|
|
|
+// t[m] = getCellValue(cell);
|
|
|
+// }
|
|
|
+// list.add(t);
|
|
|
+// }
|
|
|
+// }
|
|
|
+// for(int i=0;i<list.size();i++){
|
|
|
+// WzHouseContractCompareEntity topEntity=new WzHouseContractCompareEntity();
|
|
|
+// topEntity.setUseTheUnitsHierarchy(list.get(i)[0]);
|
|
|
+// topEntity.setProvince(list.get(i)[1]);
|
|
|
+// topEntity.setCity(list.get(i)[2]);
|
|
|
+// topEntity.setCounty(list.get(i)[3]);
|
|
|
+// topEntity.setUseTheProLine(list.get(i)[4]);
|
|
|
+// topEntity.setLeaseInPracticalUse(list.get(i)[5]);
|
|
|
+// topEntity.setDescriptionOfOtherUsesOfTheLease(list.get(i)[6]);
|
|
|
+// topEntity.setCityArea(list.get(i)[7]);
|
|
|
+// topEntity.setDistrict(list.get(i)[8]);
|
|
|
+// topEntity.setRentalBuildingArea(list.get(i)[9]);
|
|
|
+// topEntity.setHireTime(list.get(i)[10]);
|
|
|
+// topEntity.setTotalMonthlyRent(list.get(i)[11]);
|
|
|
+// topEntity.setContractAmountIncludingTax(list.get(i)[12]);
|
|
|
+// topEntity.setFtProvinceAverage(list.get(i)[13]);
|
|
|
+// topEntity.setPriceProvinceAverage(list.get(i)[14]);
|
|
|
+// topEntity.setContractNumber(list.get(i)[15]);
|
|
|
+// topEntity.setContractName(list.get(i)[16]);
|
|
|
+// wzHouseContractCompareService.save(topEntity);
|
|
|
+// }
|
|
|
+//
|
|
|
+// } catch (Exception e) {
|
|
|
+// e.printStackTrace();
|
|
|
+// return R.error("第"+(errorIndex)+"行数据有问题,导入失败");
|
|
|
+// }
|
|
|
+// return R.ok();
|
|
|
+// }
|
|
|
+//
|
|
|
+//
|
|
|
+//
|
|
|
+//
|
|
|
+//}
|