From bdf665572d23721b2bed2623bc6bd5fbc9ecf295 Mon Sep 17 00:00:00 2001 From: wenc000 <450292408@qq.com> Date: Tue, 7 Apr 2020 19:50:49 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9C=B0=E5=8C=BA=E5=92=8C=E4=BC=81=E4=B8=9A?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=AF=BC=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/apis/data/DataController.java | 39 +++ .../listener/excel/data/AreaExcel.java | 57 ++++ .../excel/data/AreaExcelListener.java | 48 ++++ .../listener/excel/data/EnterpriseExcel.java | 252 ++++++++++++++++++ .../excel/data/EnterpriseExcelListener.java | 50 ++++ .../pojo/dtos/enterprise/EnterpriseDTO.java | 199 +++++++++----- .../pojo/vos/enterprise/EnterpriseVO.java | 86 +++++- .../inspection/service/data/IDataService.java | 30 +++ .../service/data/impl/DataServiceImpl.java | 236 ++++++++++++++++ .../mapper/enterprise/enterprise-mapper.xml | 32 +++ .../assets/layuiadmin/tpl/system/about.html | 8 - 11 files changed, 958 insertions(+), 79 deletions(-) create mode 100644 src/main/java/com/cm/inspection/controller/apis/data/DataController.java create mode 100644 src/main/java/com/cm/inspection/listener/excel/data/AreaExcel.java create mode 100644 src/main/java/com/cm/inspection/listener/excel/data/AreaExcelListener.java create mode 100644 src/main/java/com/cm/inspection/listener/excel/data/EnterpriseExcel.java create mode 100644 src/main/java/com/cm/inspection/listener/excel/data/EnterpriseExcelListener.java create mode 100644 src/main/java/com/cm/inspection/service/data/IDataService.java create mode 100644 src/main/java/com/cm/inspection/service/data/impl/DataServiceImpl.java diff --git a/src/main/java/com/cm/inspection/controller/apis/data/DataController.java b/src/main/java/com/cm/inspection/controller/apis/data/DataController.java new file mode 100644 index 0000000..9cb8dbe --- /dev/null +++ b/src/main/java/com/cm/inspection/controller/apis/data/DataController.java @@ -0,0 +1,39 @@ +package com.cm.inspection.controller.apis.data; + +import com.cm.common.constants.ISystemConstant; +import com.cm.common.result.SuccessResult; +import com.cm.inspection.service.data.IDataService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * When you feel like quitting. Think about why you started + * 当你想要放弃的时候,想想当初你为何开始 + * + * @ClassName: DataController + * @Description: 数据 + * @Author: WangGeng + * @Date: 2020/4/7 10:59 + * @Version: 1.0 + **/ +@RestController +@RequestMapping(ISystemConstant.API_PREFIX + "/data") +public class DataController { + + @Autowired + private IDataService dataService; + + @PostMapping("saveareadatamigration") + public SuccessResult saveAreaDataMigration() throws Exception { + return dataService.saveAreaDataMigration(); + } + + @PostMapping("saveenterprisedatamigration") + public SuccessResult saveEnterpriseDataMigration() throws Exception { + return dataService.saveEnterpriseDataMigration(); + } + +} diff --git a/src/main/java/com/cm/inspection/listener/excel/data/AreaExcel.java b/src/main/java/com/cm/inspection/listener/excel/data/AreaExcel.java new file mode 100644 index 0000000..4767d6a --- /dev/null +++ b/src/main/java/com/cm/inspection/listener/excel/data/AreaExcel.java @@ -0,0 +1,57 @@ +package com.cm.inspection.listener.excel.data; + +import com.alibaba.excel.annotation.ExcelProperty; + +/** + * When you feel like quitting. Think about why you started + * 当你想要放弃的时候,想想当初你为何开始 + * + * @ClassName: DataExcel + * @Description: 地区 + * @Author: WangGeng + * @Date: 2020/4/7 11:02 + * @Version: 1.0 + **/ +public class AreaExcel { + + @ExcelProperty(index = 0) + private Integer id; + @ExcelProperty(index = 1) + private String name; + @ExcelProperty(index = 2) + private String code; + @ExcelProperty(index = 3) + private Integer pid; + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getName() { + return name == null ? "" : name; + } + + public void setName(String name) { + this.name = name; + } + + public String getCode() { + return code == null ? "" : code; + } + + public void setCode(String code) { + this.code = code; + } + + public Integer getPid() { + return pid; + } + + public void setPid(Integer pid) { + this.pid = pid; + } +} diff --git a/src/main/java/com/cm/inspection/listener/excel/data/AreaExcelListener.java b/src/main/java/com/cm/inspection/listener/excel/data/AreaExcelListener.java new file mode 100644 index 0000000..e03f3c0 --- /dev/null +++ b/src/main/java/com/cm/inspection/listener/excel/data/AreaExcelListener.java @@ -0,0 +1,48 @@ +package com.cm.inspection.listener.excel.data; + +import com.alibaba.excel.context.AnalysisContext; +import com.alibaba.excel.event.AnalysisEventListener; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.ArrayList; +import java.util.List; + +/** + * When you feel like quitting. Think about why you started + * 当你想要放弃的时候,想想当初你为何开始 + * + * @ClassName: AreaExcelListener + * @Description: 地区 + * @Author: WangGeng + * @Date: 2020/4/7 11:03 + * @Version: 1.0 + **/ +public abstract class AreaExcelListener extends AnalysisEventListener { + + private static final Logger LOG = LoggerFactory.getLogger(AreaExcelListener.class); + private List areaExcels = new ArrayList<>(0); + + @Override + public void invoke(AreaExcel areaExcel, AnalysisContext analysisContext) { + areaExcels.add(areaExcel); + } + + @Override + public void doAfterAllAnalysed(AnalysisContext analysisContext) { + try { + listAreaExcel(areaExcels); + } catch (Exception e) { + LOG.error(e.getMessage()); + } + areaExcels.clear(); + } + + /** + * 获取用户列表 + * + * @param areaExcels + */ + public abstract void listAreaExcel(List areaExcels) throws Exception; + +} diff --git a/src/main/java/com/cm/inspection/listener/excel/data/EnterpriseExcel.java b/src/main/java/com/cm/inspection/listener/excel/data/EnterpriseExcel.java new file mode 100644 index 0000000..d33684c --- /dev/null +++ b/src/main/java/com/cm/inspection/listener/excel/data/EnterpriseExcel.java @@ -0,0 +1,252 @@ +package com.cm.inspection.listener.excel.data; + +import com.alibaba.excel.annotation.ExcelProperty; + +/** + * When you feel like quitting. Think about why you started + * 当你想要放弃的时候,想想当初你为何开始 + * + * @ClassName: EnterpriseExcel + * @Description: 企业 + * @Author: WangGeng + * @Date: 2020/4/7 11:06 + * @Version: 1.0 + **/ +public class EnterpriseExcel { + + @ExcelProperty(index = 1) + private String name; + @ExcelProperty(index = 2) + private String address; + @ExcelProperty(index = 3) + private String area1; + @ExcelProperty(index = 4) + private String area2; + @ExcelProperty(index = 5) + private String area3; + @ExcelProperty(index = 6) + private String area4; + @ExcelProperty(index = 7) + private String area5; + @ExcelProperty(index = 9) + private String managementLevel1; + @ExcelProperty(index = 10) + private String managementLevel2; + @ExcelProperty(index = 13) + private String establishmentDay; + @ExcelProperty(index = 14) + private String businessRegNum; + @ExcelProperty(index = 18) + private String legalPerson; + @ExcelProperty(index = 20) + private String principalPerson; + @ExcelProperty(index = 21) + private String principalMobile; + @ExcelProperty(index = 27) + private Integer employeeNum; + @ExcelProperty(index = 29) + private String businessScope; + @ExcelProperty(index = 65) + private Integer isDelete; + @ExcelProperty(index = 76) + private String companyType; + @ExcelProperty(index = 136) + private String highRisk; + + public String getName() { + return name == null ? "" : name; + } + + public void setName(String name) { + this.name = name; + } + + public String getAddress() { + return address == null ? "" : address; + } + + public void setAddress(String address) { + this.address = address; + } + + public String getArea1() { + return area1 == null ? "" : area1; + } + + public void setArea1(String area1) { + this.area1 = area1; + } + + public String getArea2() { + return area2 == null ? "" : area2; + } + + public void setArea2(String area2) { + this.area2 = area2; + } + + public String getArea3() { + return area3 == null ? "" : area3; + } + + public void setArea3(String area3) { + this.area3 = area3; + } + + public String getArea4() { + return area4 == null ? "" : area4; + } + + public void setArea4(String area4) { + this.area4 = area4; + } + + public String getArea5() { + return area5 == null ? "" : area5; + } + + public void setArea5(String area5) { + this.area5 = area5; + } + + public String getManagementLevel1() { + return managementLevel1 == null ? "" : managementLevel1; + } + + public void setManagementLevel1(String managementLevel1) { + this.managementLevel1 = managementLevel1; + } + + public String getManagementLevel2() { + return managementLevel2 == null ? "" : managementLevel2; + } + + public void setManagementLevel2(String managementLevel2) { + this.managementLevel2 = managementLevel2; + } + + public String getEstablishmentDay() { + return establishmentDay == null ? "" : establishmentDay; + } + + public void setEstablishmentDay(String establishmentDay) { + this.establishmentDay = establishmentDay; + } + + public String getBusinessRegNum() { + return businessRegNum == null ? "" : businessRegNum; + } + + public void setBusinessRegNum(String businessRegNum) { + this.businessRegNum = businessRegNum; + } + + public String getLegalPerson() { + return legalPerson == null ? "" : legalPerson; + } + + public void setLegalPerson(String legalPerson) { + this.legalPerson = legalPerson; + } + + public String getPrincipalPerson() { + return principalPerson == null ? "" : principalPerson; + } + + public void setPrincipalPerson(String principalPerson) { + this.principalPerson = principalPerson; + } + + public String getPrincipalMobile() { + return principalMobile == null ? "" : principalMobile; + } + + public void setPrincipalMobile(String principalMobile) { + this.principalMobile = principalMobile; + } + + public Integer getEmployeeNum() { + return employeeNum; + } + + public void setEmployeeNum(Integer employeeNum) { + this.employeeNum = employeeNum; + } + + public String getBusinessScope() { + return businessScope == null ? "" : businessScope; + } + + public void setBusinessScope(String businessScope) { + this.businessScope = businessScope; + } + + public Integer getIsDelete() { + return isDelete; + } + + public void setIsDelete(Integer isDelete) { + this.isDelete = isDelete; + } + + public String getCompanyType() { + return companyType == null ? "" : companyType; + } + + public void setCompanyType(String companyType) { + this.companyType = companyType; + } + + public String getHighRisk() { + return highRisk == null ? "" : highRisk; + } + + public void setHighRisk(String highRisk) { + this.highRisk = highRisk; + } + + @Override + public String toString() { + final StringBuilder sb = new StringBuilder("{"); + sb.append("\"name\":\"") + .append(name).append('\"'); + sb.append(",\"address\":\"") + .append(address).append('\"'); + sb.append(",\"area1\":\"") + .append(area1).append('\"'); + sb.append(",\"area2\":\"") + .append(area2).append('\"'); + sb.append(",\"area3\":\"") + .append(area3).append('\"'); + sb.append(",\"area4\":\"") + .append(area4).append('\"'); + sb.append(",\"area5\":\"") + .append(area5).append('\"'); + sb.append(",\"managementLevel1\":\"") + .append(managementLevel1).append('\"'); + sb.append(",\"managementLevel2\":\"") + .append(managementLevel2).append('\"'); + sb.append(",\"establishmentDay\":\"") + .append(establishmentDay).append('\"'); + sb.append(",\"businessRegNum\":\"") + .append(businessRegNum).append('\"'); + sb.append(",\"legalPerson\":\"") + .append(legalPerson).append('\"'); + sb.append(",\"principalPerson\":\"") + .append(principalPerson).append('\"'); + sb.append(",\"principalMobile\":\"") + .append(principalMobile).append('\"'); + sb.append(",\"employeeNum\":") + .append(employeeNum); + sb.append(",\"businessScope\":\"") + .append(businessScope).append('\"'); + sb.append(",\"isDelete\":") + .append(isDelete); + sb.append(",\"companyType\":\"") + .append(companyType).append('\"'); + sb.append(",\"highRisk\":\"") + .append(highRisk).append('\"'); + sb.append('}'); + return sb.toString(); + } +} diff --git a/src/main/java/com/cm/inspection/listener/excel/data/EnterpriseExcelListener.java b/src/main/java/com/cm/inspection/listener/excel/data/EnterpriseExcelListener.java new file mode 100644 index 0000000..c62cb26 --- /dev/null +++ b/src/main/java/com/cm/inspection/listener/excel/data/EnterpriseExcelListener.java @@ -0,0 +1,50 @@ +package com.cm.inspection.listener.excel.data; + +import com.alibaba.excel.context.AnalysisContext; +import com.alibaba.excel.event.AnalysisEventListener; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.ArrayList; +import java.util.List; + +/** + * When you feel like quitting. Think about why you started + * 当你想要放弃的时候,想想当初你为何开始 + * + * @ClassName: EnterpriseExcelListener + * @Description: 企业 + * @Author: WangGeng + * @Date: 2020/4/7 11:06 + * @Version: 1.0 + **/ +public abstract class EnterpriseExcelListener extends AnalysisEventListener { + + private static final Logger LOG = LoggerFactory.getLogger(EnterpriseExcelListener.class); + private List enterpriseExcels = new ArrayList<>(); + + @Override + public void invoke(EnterpriseExcel enterpriseExcel, AnalysisContext analysisContext) { + enterpriseExcels.add(enterpriseExcel); + if (enterpriseExcels.size() > 2000) { + try { + listEnterpriseExcel(enterpriseExcels); + } catch (Exception e) { + LOG.error(e.getMessage(), e); + } + enterpriseExcels.clear(); + } + } + + @Override + public void doAfterAllAnalysed(AnalysisContext analysisContext) { + try { + listEnterpriseExcel(enterpriseExcels); + } catch (Exception e) { + LOG.error(e.getMessage()); + } + enterpriseExcels.clear(); + } + + public abstract void listEnterpriseExcel(List enterpriseExcels) throws Exception; +} diff --git a/src/main/java/com/cm/inspection/pojo/dtos/enterprise/EnterpriseDTO.java b/src/main/java/com/cm/inspection/pojo/dtos/enterprise/EnterpriseDTO.java index a06e561..23f9f32 100644 --- a/src/main/java/com/cm/inspection/pojo/dtos/enterprise/EnterpriseDTO.java +++ b/src/main/java/com/cm/inspection/pojo/dtos/enterprise/EnterpriseDTO.java @@ -43,6 +43,10 @@ public class EnterpriseDTO { private String area5DictionaryName; @ApiModelProperty(name = "address", value = "详细地址") private String address; + @ApiModelProperty(name = "industryType", value = "行业类型") + private String industryType; + @ApiModelProperty(name = "industryTypeDictionaryName", value = "行业类型字典名称") + private String industryTypeDictionaryName; @ApiModelProperty(name = "industry", value = "管理行业") private String industry; @ApiModelProperty(name = "industryDictionaryName", value = "管理行业字典名称") @@ -61,9 +65,15 @@ public class EnterpriseDTO { private String factoryGate; @ApiModelProperty(name = "workplace", value = "作业场所") private String workplace; + @ApiModelProperty(name = "bussinessRegNum", value = "组织机构代码") + private String bussinessRegNum; + @ApiModelProperty(name = "legalPerson", value = "法人") + private String legalPerson; + @ApiModelProperty(name = "summary", value = "营业范围") + private String summary; public String getEnterpriseId() { - return enterpriseId == null ? "" : enterpriseId.trim(); + return enterpriseId == null ? "" : enterpriseId; } public void setEnterpriseId(String enterpriseId) { @@ -71,7 +81,7 @@ public class EnterpriseDTO { } public String getName() { - return name == null ? "" : name.trim(); + return name == null ? "" : name; } public void setName(String name) { @@ -79,7 +89,7 @@ public class EnterpriseDTO { } public String getType() { - return type == null ? "" : type.trim(); + return type == null ? "" : type; } public void setType(String type) { @@ -87,7 +97,7 @@ public class EnterpriseDTO { } public String getTypeDictionaryName() { - return typeDictionaryName == null ? "" : typeDictionaryName.trim(); + return typeDictionaryName == null ? "" : typeDictionaryName; } public void setTypeDictionaryName(String typeDictionaryName) { @@ -95,7 +105,7 @@ public class EnterpriseDTO { } public String getArea1() { - return area1 == null ? "" : area1.trim(); + return area1 == null ? "" : area1; } public void setArea1(String area1) { @@ -103,7 +113,7 @@ public class EnterpriseDTO { } public String getArea1DictionaryName() { - return area1DictionaryName == null ? "" : area1DictionaryName.trim(); + return area1DictionaryName == null ? "" : area1DictionaryName; } public void setArea1DictionaryName(String area1DictionaryName) { @@ -111,7 +121,7 @@ public class EnterpriseDTO { } public String getArea2() { - return area2 == null ? "" : area2.trim(); + return area2 == null ? "" : area2; } public void setArea2(String area2) { @@ -119,7 +129,7 @@ public class EnterpriseDTO { } public String getArea2DictionaryName() { - return area2DictionaryName == null ? "" : area2DictionaryName.trim(); + return area2DictionaryName == null ? "" : area2DictionaryName; } public void setArea2DictionaryName(String area2DictionaryName) { @@ -127,7 +137,7 @@ public class EnterpriseDTO { } public String getArea3() { - return area3 == null ? "" : area3.trim(); + return area3 == null ? "" : area3; } public void setArea3(String area3) { @@ -135,7 +145,7 @@ public class EnterpriseDTO { } public String getArea3DictionaryName() { - return area3DictionaryName == null ? "" : area3DictionaryName.trim(); + return area3DictionaryName == null ? "" : area3DictionaryName; } public void setArea3DictionaryName(String area3DictionaryName) { @@ -143,7 +153,7 @@ public class EnterpriseDTO { } public String getArea4() { - return area4 == null ? "" : area4.trim(); + return area4 == null ? "" : area4; } public void setArea4(String area4) { @@ -151,7 +161,7 @@ public class EnterpriseDTO { } public String getArea4DictionaryName() { - return area4DictionaryName == null ? "" : area4DictionaryName.trim(); + return area4DictionaryName == null ? "" : area4DictionaryName; } public void setArea4DictionaryName(String area4DictionaryName) { @@ -159,7 +169,7 @@ public class EnterpriseDTO { } public String getArea5() { - return area5 == null ? "" : area5.trim(); + return area5 == null ? "" : area5; } public void setArea5(String area5) { @@ -167,7 +177,7 @@ public class EnterpriseDTO { } public String getArea5DictionaryName() { - return area5DictionaryName == null ? "" : area5DictionaryName.trim(); + return area5DictionaryName == null ? "" : area5DictionaryName; } public void setArea5DictionaryName(String area5DictionaryName) { @@ -175,15 +185,31 @@ public class EnterpriseDTO { } public String getAddress() { - return address == null ? "" : address.trim(); + return address == null ? "" : address; } public void setAddress(String address) { this.address = address; } + public String getIndustryType() { + return industryType == null ? "" : industryType; + } + + public void setIndustryType(String industryType) { + this.industryType = industryType; + } + + public String getIndustryTypeDictionaryName() { + return industryTypeDictionaryName == null ? "" : industryTypeDictionaryName; + } + + public void setIndustryTypeDictionaryName(String industryTypeDictionaryName) { + this.industryTypeDictionaryName = industryTypeDictionaryName; + } + public String getIndustry() { - return industry == null ? "" : industry.trim(); + return industry == null ? "" : industry; } public void setIndustry(String industry) { @@ -191,7 +217,7 @@ public class EnterpriseDTO { } public String getIndustryDictionaryName() { - return industryDictionaryName == null ? "" : industryDictionaryName.trim(); + return industryDictionaryName == null ? "" : industryDictionaryName; } public void setIndustryDictionaryName(String industryDictionaryName) { @@ -207,7 +233,7 @@ public class EnterpriseDTO { } public String getRiskOperation() { - return riskOperation == null ? "" : riskOperation.trim(); + return riskOperation == null ? "" : riskOperation; } public void setRiskOperation(String riskOperation) { @@ -215,7 +241,7 @@ public class EnterpriseDTO { } public String getRiskOperationDictionaryName() { - return riskOperationDictionaryName == null ? "" : riskOperationDictionaryName.trim(); + return riskOperationDictionaryName == null ? "" : riskOperationDictionaryName; } public void setRiskOperationDictionaryName(String riskOperationDictionaryName) { @@ -223,7 +249,7 @@ public class EnterpriseDTO { } public String getMaster() { - return master == null ? "" : master.trim(); + return master == null ? "" : master; } public void setMaster(String master) { @@ -231,7 +257,7 @@ public class EnterpriseDTO { } public String getPhone() { - return phone == null ? "" : phone.trim(); + return phone == null ? "" : phone; } public void setPhone(String phone) { @@ -239,7 +265,7 @@ public class EnterpriseDTO { } public String getFactoryGate() { - return factoryGate == null ? "" : factoryGate.trim(); + return factoryGate == null ? "" : factoryGate; } public void setFactoryGate(String factoryGate) { @@ -247,64 +273,99 @@ public class EnterpriseDTO { } public String getWorkplace() { - return workplace == null ? "" : workplace.trim(); + return workplace == null ? "" : workplace; } public void setWorkplace(String workplace) { this.workplace = workplace; } + public String getBussinessRegNum() { + return bussinessRegNum == null ? "" : bussinessRegNum; + } + + public void setBussinessRegNum(String bussinessRegNum) { + this.bussinessRegNum = bussinessRegNum; + } + + public String getLegalPerson() { + return legalPerson == null ? "" : legalPerson; + } + + public void setLegalPerson(String legalPerson) { + this.legalPerson = legalPerson; + } + + + public String getSummary() { + return summary == null ? "" : summary; + } + + public void setSummary(String summary) { + this.summary = summary; + } + @Override public String toString() { final StringBuilder sb = new StringBuilder("{"); - sb.append("\"enterpriseId\":") - .append("\"").append(enterpriseId).append("\""); - sb.append(",\"name\":") - .append("\"").append(name).append("\""); - sb.append(",\"type\":") - .append("\"").append(type).append("\""); - sb.append(",\"typeDictionaryName\":") - .append("\"").append(typeDictionaryName).append("\""); - sb.append(",\"area1\":") - .append("\"").append(area1).append("\""); - sb.append(",\"area1DictionaryName\":") - .append("\"").append(area1DictionaryName).append("\""); - sb.append(",\"area2\":") - .append("\"").append(area2).append("\""); - sb.append(",\"area2DictionaryName\":") - .append("\"").append(area2DictionaryName).append("\""); - sb.append(",\"area3\":") - .append("\"").append(area3).append("\""); - sb.append(",\"area3DictionaryName\":") - .append("\"").append(area3DictionaryName).append("\""); - sb.append(",\"area4\":") - .append("\"").append(area4).append("\""); - sb.append(",\"area4DictionaryName\":") - .append("\"").append(area4DictionaryName).append("\""); - sb.append(",\"area5\":") - .append("\"").append(area5).append("\""); - sb.append(",\"area5DictionaryName\":") - .append("\"").append(area5DictionaryName).append("\""); - sb.append(",\"address\":") - .append("\"").append(address).append("\""); - sb.append(",\"industry\":") - .append("\"").append(industry).append("\""); - sb.append(",\"industryDictionaryName\":") - .append("\"").append(industryDictionaryName).append("\""); + sb.append("\"enterpriseId\":\"") + .append(enterpriseId).append('\"'); + sb.append(",\"name\":\"") + .append(name).append('\"'); + sb.append(",\"type\":\"") + .append(type).append('\"'); + sb.append(",\"typeDictionaryName\":\"") + .append(typeDictionaryName).append('\"'); + sb.append(",\"area1\":\"") + .append(area1).append('\"'); + sb.append(",\"area1DictionaryName\":\"") + .append(area1DictionaryName).append('\"'); + sb.append(",\"area2\":\"") + .append(area2).append('\"'); + sb.append(",\"area2DictionaryName\":\"") + .append(area2DictionaryName).append('\"'); + sb.append(",\"area3\":\"") + .append(area3).append('\"'); + sb.append(",\"area3DictionaryName\":\"") + .append(area3DictionaryName).append('\"'); + sb.append(",\"area4\":\"") + .append(area4).append('\"'); + sb.append(",\"area4DictionaryName\":\"") + .append(area4DictionaryName).append('\"'); + sb.append(",\"area5\":\"") + .append(area5).append('\"'); + sb.append(",\"area5DictionaryName\":\"") + .append(area5DictionaryName).append('\"'); + sb.append(",\"address\":\"") + .append(address).append('\"'); + sb.append(",\"industryType\":\"") + .append(industryType).append('\"'); + sb.append(",\"industryTypeDictionaryName\":\"") + .append(industryTypeDictionaryName).append('\"'); + sb.append(",\"industry\":\"") + .append(industry).append('\"'); + sb.append(",\"industryDictionaryName\":\"") + .append(industryDictionaryName).append('\"'); sb.append(",\"engagedCount\":") .append(engagedCount); - sb.append(",\"riskOperation\":") - .append("\"").append(riskOperation).append("\""); - sb.append(",\"riskOperationDictionaryName\":") - .append("\"").append(riskOperationDictionaryName).append("\""); - sb.append(",\"master\":") - .append("\"").append(master).append("\""); - sb.append(",\"phone\":") - .append("\"").append(phone).append("\""); - sb.append(",\"factoryGate\":") - .append("\"").append(factoryGate).append("\""); - sb.append(",\"workplace\":") - .append("\"").append(workplace).append("\""); + sb.append(",\"riskOperation\":\"") + .append(riskOperation).append('\"'); + sb.append(",\"riskOperationDictionaryName\":\"") + .append(riskOperationDictionaryName).append('\"'); + sb.append(",\"master\":\"") + .append(master).append('\"'); + sb.append(",\"phone\":\"") + .append(phone).append('\"'); + sb.append(",\"factoryGate\":\"") + .append(factoryGate).append('\"'); + sb.append(",\"workplace\":\"") + .append(workplace).append('\"'); + sb.append(",\"bussinessRegNum\":\"") + .append(bussinessRegNum).append('\"'); + sb.append(",\"legalPerson\":\"") + .append(legalPerson).append('\"'); + sb.append(",\"summary\":\"") + .append(summary).append('\"'); sb.append('}'); return sb.toString(); } diff --git a/src/main/java/com/cm/inspection/pojo/vos/enterprise/EnterpriseVO.java b/src/main/java/com/cm/inspection/pojo/vos/enterprise/EnterpriseVO.java index 44cff57..1097875 100644 --- a/src/main/java/com/cm/inspection/pojo/vos/enterprise/EnterpriseVO.java +++ b/src/main/java/com/cm/inspection/pojo/vos/enterprise/EnterpriseVO.java @@ -6,7 +6,6 @@ import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; /** - * * @ClassName: EnterpriseVO * @Description: 企业 * @Author: WenG @@ -33,6 +32,8 @@ public class EnterpriseVO { private String area5; @ApiModelProperty(name = "address", value = "详细地址") private String address; + @ApiModelProperty(name = "industryType", value = "行业类型") + private String industryType; @ApiModelProperty(name = "industry", value = "管理行业") private String industry; @ApiModelProperty(name = "engagedCount", value = "从业人数") @@ -50,6 +51,12 @@ public class EnterpriseVO { private String factoryGate; @ApiModelProperty(name = "workplace", value = "作业场所") private String workplace; + @ApiModelProperty(name = "bussinessRegNum", value = "组织机构代码") + private String bussinessRegNum; + @ApiModelProperty(name = "legalPerson", value = "法人") + private String legalPerson; + @ApiModelProperty(name = "summary", value = "营业范围") + private String summary; public String getName() { return name == null ? "" : name; @@ -115,6 +122,14 @@ public class EnterpriseVO { this.address = address; } + public String getIndustryType() { + return industryType == null ? "" : industryType; + } + + public void setIndustryType(String industryType) { + this.industryType = industryType; + } + public String getIndustry() { return industry == null ? "" : industry; } @@ -124,7 +139,7 @@ public class EnterpriseVO { } public Integer getEngagedCount() { - return engagedCount == null ? 0 : engagedCount; + return engagedCount; } public void setEngagedCount(Integer engagedCount) { @@ -171,5 +186,72 @@ public class EnterpriseVO { this.workplace = workplace; } + public String getBussinessRegNum() { + return bussinessRegNum == null ? "" : bussinessRegNum; + } + public void setBussinessRegNum(String bussinessRegNum) { + this.bussinessRegNum = bussinessRegNum; + } + + public String getLegalPerson() { + return legalPerson == null ? "" : legalPerson; + } + + public void setLegalPerson(String legalPerson) { + this.legalPerson = legalPerson; + } + + public String getSummary() { + return summary == null ? "" : summary; + } + + public void setSummary(String summary) { + this.summary = summary; + } + + @Override + public String toString() { + final StringBuilder sb = new StringBuilder("{"); + sb.append("\"name\":\"") + .append(name).append('\"'); + sb.append(",\"type\":\"") + .append(type).append('\"'); + sb.append(",\"area1\":\"") + .append(area1).append('\"'); + sb.append(",\"area2\":\"") + .append(area2).append('\"'); + sb.append(",\"area3\":\"") + .append(area3).append('\"'); + sb.append(",\"area4\":\"") + .append(area4).append('\"'); + sb.append(",\"area5\":\"") + .append(area5).append('\"'); + sb.append(",\"address\":\"") + .append(address).append('\"'); + sb.append(",\"industryType\":\"") + .append(industryType).append('\"'); + sb.append(",\"industry\":\"") + .append(industry).append('\"'); + sb.append(",\"engagedCount\":") + .append(engagedCount); + sb.append(",\"riskOperation\":\"") + .append(riskOperation).append('\"'); + sb.append(",\"master\":\"") + .append(master).append('\"'); + sb.append(",\"phone\":\"") + .append(phone).append('\"'); + sb.append(",\"factoryGate\":\"") + .append(factoryGate).append('\"'); + sb.append(",\"workplace\":\"") + .append(workplace).append('\"'); + sb.append(",\"bussinessRegNum\":\"") + .append(bussinessRegNum).append('\"'); + sb.append(",\"legalPerson\":\"") + .append(legalPerson).append('\"'); + sb.append(",\"summary\":\"") + .append(summary).append('\"'); + sb.append('}'); + return sb.toString(); + } } diff --git a/src/main/java/com/cm/inspection/service/data/IDataService.java b/src/main/java/com/cm/inspection/service/data/IDataService.java new file mode 100644 index 0000000..9a3dc94 --- /dev/null +++ b/src/main/java/com/cm/inspection/service/data/IDataService.java @@ -0,0 +1,30 @@ +package com.cm.inspection.service.data; + +import com.cm.common.result.SuccessResult; + +/** + * When you feel like quitting. Think about why you started + * 当你想要放弃的时候,想想当初你为何开始 + * + * @ClassName: IDataService + * @Description: 数据 + * @Author: WangGeng + * @Date: 2020/4/7 11:35 + * @Version: 1.0 + **/ +public interface IDataService { + /** + * 地区数据迁移 + * + * @return + */ + SuccessResult saveAreaDataMigration() throws Exception; + + /** + * 企业数据迁移 + * + * @return + * @throws Exception + */ + SuccessResult saveEnterpriseDataMigration() throws Exception; +} diff --git a/src/main/java/com/cm/inspection/service/data/impl/DataServiceImpl.java b/src/main/java/com/cm/inspection/service/data/impl/DataServiceImpl.java new file mode 100644 index 0000000..841ce40 --- /dev/null +++ b/src/main/java/com/cm/inspection/service/data/impl/DataServiceImpl.java @@ -0,0 +1,236 @@ +package com.cm.inspection.service.data.impl; + +import com.alibaba.excel.EasyExcel; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.cm.common.plugin.pojo.dtos.datadictionary.DataDictionaryDTO; +import com.cm.common.plugin.pojo.vos.datadictionary.DataDictionaryVO; +import com.cm.common.plugin.service.datadictionary.IDataDictionaryService; +import com.cm.common.result.SuccessResult; +import com.cm.inspection.listener.excel.data.AreaExcel; +import com.cm.inspection.listener.excel.data.AreaExcelListener; +import com.cm.inspection.listener.excel.data.EnterpriseExcel; +import com.cm.inspection.listener.excel.data.EnterpriseExcelListener; +import com.cm.inspection.pojo.vos.enterprise.EnterpriseVO; +import com.cm.inspection.service.data.IDataService; +import com.cm.inspection.service.enterprise.IEnterpriseService; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.io.File; +import java.util.ArrayList; +import java.util.List; + +/** + * When you feel like quitting. Think about why you started + * 当你想要放弃的时候,想想当初你为何开始 + * + * @ClassName: DataServiceImpl + * @Description: 数据 + * @Author: WangGeng + * @Date: 2020/4/7 11:36 + * @Version: 1.0 + **/ +@Service +public class DataServiceImpl implements IDataService { + + @Autowired + private IDataDictionaryService dataDictionaryService; + @Autowired + private IEnterpriseService enterpriseService; + + @Override + public SuccessResult saveAreaDataMigration() throws Exception { + File areaDataFile = new File("C:\\Users\\Administrator\\Desktop\\area.xls"); + JSONArray excelDataJsonArray = new JSONArray(); + EasyExcel.read(areaDataFile, AreaExcel.class, new AreaExcelListener() { + @Override + public void listAreaExcel(List areaExcels) throws Exception { + for (AreaExcel areaExcel : areaExcels) { + JSONObject areaObj = new JSONObject(); + areaObj.put("id", areaExcel.getId()); + areaObj.put("name", areaExcel.getName()); + areaObj.put("code", areaExcel.getCode()); + areaObj.put("pid", areaExcel.getPid()); + excelDataJsonArray.add(areaObj); + } + } + }).sheet().doRead(); + + buildAllAreaDataJsonArray(excelDataJsonArray, null); + + saveAreaData("6aba668e-8ab3-4fbb-8886-b2d468ccf00e", excelDataJsonArray); + return new SuccessResult(); + } + + @Override + public SuccessResult saveEnterpriseDataMigration() throws Exception { + File enterpriseDataFile = new File("C:\\Users\\Administrator\\Desktop\\core_company.xls"); + // 地区列表 + List areaDatas = dataDictionaryService.listDictionaryByDictionaryCode("0004"); + // 行业列表 + List industryDatas = dataDictionaryService.listDictionaryByDictionaryCode("0002"); + // 企业类型 + List typeDatas = dataDictionaryService.listDictionaryByDictionaryCode("0001"); + // 高风险列表 + List riskDatas = dataDictionaryService.listDictionaryByDictionaryCode("0003"); + + EasyExcel.read(enterpriseDataFile, EnterpriseExcel.class, new EnterpriseExcelListener() { + @Override + public void listEnterpriseExcel(List enterpriseExcels) throws Exception { + for (EnterpriseExcel enterpriseExcel : enterpriseExcels) { + if (enterpriseExcel.getIsDelete() != 0) { + continue; + } + EnterpriseVO enterpriseVO = new EnterpriseVO(); + enterpriseVO.setName(enterpriseExcel.getName()); + enterpriseVO.setType(getTypeId(enterpriseExcel.getCompanyType(), typeDatas)); + enterpriseVO.setAddress(enterpriseExcel.getAddress()); + enterpriseVO.setArea1("6aba668e-8ab3-4fbb-8886-b2d468ccf00e"); + enterpriseVO.setArea2(getAreaId(enterpriseExcel.getArea1(), areaDatas)); + enterpriseVO.setArea3(getAreaId(enterpriseExcel.getArea2(), areaDatas)); + enterpriseVO.setArea4(getAreaId(enterpriseExcel.getArea3(), areaDatas)); + enterpriseVO.setArea5(getAreaId(enterpriseExcel.getArea4(), areaDatas)); + enterpriseVO.setIndustryType(getIndustryId(enterpriseExcel.getManagementLevel1(), industryDatas)); + enterpriseVO.setIndustry(getIndustryId(enterpriseExcel.getManagementLevel2(), industryDatas)); + enterpriseVO.setBussinessRegNum(enterpriseExcel.getBusinessRegNum()); + enterpriseVO.setLegalPerson(enterpriseExcel.getLegalPerson()); + enterpriseVO.setMaster(enterpriseExcel.getPrincipalPerson()); + enterpriseVO.setPhone(enterpriseExcel.getPrincipalMobile()); + enterpriseVO.setSummary(enterpriseExcel.getBusinessScope()); + enterpriseVO.setEngagedCount(enterpriseExcel.getEmployeeNum()); + enterpriseVO.setRiskOperation(getRiskOperationId(enterpriseExcel.getHighRisk(), riskDatas)); + enterpriseService.saveEnterprise(enterpriseVO); + } + } + }).sheet().doRead(); + return new SuccessResult(); + } + + /** + * 设置高风险 + * + * @param sourceCode + * @param riskDatas + * @return + */ + private String getRiskOperationId(String sourceCode, List riskDatas) { + String riskOperationId = ""; + for (DataDictionaryDTO riskData : riskDatas) { + if (StringUtils.equals(sourceCode, riskData.getDictionarySummary())) { + riskOperationId = riskData.getDictionaryId(); + break; + } + } + return riskOperationId; + } + + /** + * 设置类型 + * + * @param sourceCode + * @param typeDatas + * @return + */ + private String getTypeId(String sourceCode, List typeDatas) { + String typeId = ""; + for (DataDictionaryDTO typeData : typeDatas) { + if (StringUtils.equals(sourceCode, typeData.getDictionarySummary())) { + typeId = typeData.getDictionaryId(); + break; + } + } + return typeId; + } + + /** + * 设置行业 + * + * @param sourceCode + * @param industryDatas + * @return + */ + private String getIndustryId(String sourceCode, List industryDatas) { + String industryId = ""; + for (DataDictionaryDTO industryData : industryDatas) { + if (StringUtils.equals(sourceCode, industryData.getDictionarySummary())) { + industryId = industryData.getDictionaryId(); + break; + } + } + return industryId; + } + + /** + * 获取区域编码 + * + * @param sourceCode + * @param areaDatas + * @return + */ + private String getAreaId(String sourceCode, List areaDatas) { + String areaId = ""; + for (DataDictionaryDTO areaData : areaDatas) { + if (StringUtils.equals(sourceCode, areaData.getDictionarySummary())) { + areaId = areaData.getDictionaryId(); + break; + } + } + return areaId; + } + + /** + * 保存地区数据 + * + * @param excelDataJsonArray + */ + private void saveAreaData(String parentId, JSONArray excelDataJsonArray) throws Exception { + for (int i = 0; i < excelDataJsonArray.size(); i++) { + JSONObject excelDataJsonObject = excelDataJsonArray.getJSONObject(i); + DataDictionaryVO dataDictionaryVO = new DataDictionaryVO(); + dataDictionaryVO.setDictionaryParentId(parentId); + dataDictionaryVO.setDictionaryName(excelDataJsonObject.getString("name")); + dataDictionaryVO.setDictionarySummary(excelDataJsonObject.getString("code")); + dataDictionaryVO.setDictionarySort(i + 1); + String dictionaryId = dataDictionaryService.saveDictionaryReturnId(dataDictionaryVO); + JSONArray subAreaDataJsonArray = excelDataJsonObject.getJSONArray("subAreaData"); + if (subAreaDataJsonArray != null) { + saveAreaData(dictionaryId, subAreaDataJsonArray); + } + } + } + + /** + * 构建地区数据 + * + * @param excelDataJsonArray + */ + private void buildAllAreaDataJsonArray(JSONArray excelDataJsonArray, JSONArray sourceDataJsonArray) { + // 合并数据为树形结构 + for (int i = 0; i < excelDataJsonArray.size(); i++) { + JSONObject parentObj = excelDataJsonArray.getJSONObject(i); + JSONArray subAreaDataJsonArray = new JSONArray(); + // 遍历列表,合并子项 + if (sourceDataJsonArray == null) { + sourceDataJsonArray = excelDataJsonArray; + } + for (int j = 0; j < sourceDataJsonArray.size(); j++) { + JSONObject areaDataObj = sourceDataJsonArray.getJSONObject(j); + if (parentObj.getInteger("id").equals(areaDataObj.getInteger("pid"))) { + subAreaDataJsonArray.add(areaDataObj); + sourceDataJsonArray.remove(j); + j--; + } + } + // 添加字列表 + if (!subAreaDataJsonArray.isEmpty()) { + buildAllAreaDataJsonArray(subAreaDataJsonArray, sourceDataJsonArray); + parentObj.put("subAreaData", subAreaDataJsonArray); + i--; + continue; + } + } + } + +} diff --git a/src/main/resources/mybatis/mapper/enterprise/enterprise-mapper.xml b/src/main/resources/mybatis/mapper/enterprise/enterprise-mapper.xml index 0a9b6bf..030fa47 100644 --- a/src/main/resources/mybatis/mapper/enterprise/enterprise-mapper.xml +++ b/src/main/resources/mybatis/mapper/enterprise/enterprise-mapper.xml @@ -27,6 +27,10 @@ + + + + @@ -48,6 +52,10 @@ phone, factory_gate, workplace, + industry_type, + bussiness_reg_num, + legal_person, + summary, creator, gmt_create, modifier, @@ -70,6 +78,10 @@ #{phone}, #{factoryGate}, #{workplace}, + #{industryType}, + #{bussinessRegNum}, + #{legalPerson}, + #{summary}, #{creator}, #{gmtCreate}, #{modifier}, @@ -142,6 +154,18 @@ workplace = #{workplace}, + + + industry_type = #{industryType}, + + + bussiness_reg_num = #{bussinessRegNum}, + + + legal_person = #{legalPerson}, + + + summary = #{summary}, modifier = #{modifier}, gmt_modified = #{gmtModified} @@ -175,6 +199,10 @@ t1.phone, t1.factory_gate, t1.workplace, + t1.industry_type, + t1.bussiness_reg_num, + t1.legal_person, + t1.summary, t1.enterprise_id FROM gen_enterprise t1 @@ -258,6 +286,10 @@ dt3.dictionary_name risk_operation_dictionary_name, t1.master, t1.phone, + t1.industry_type, + t1.bussiness_reg_num, + t1.legal_person, + t1.summary, t1.enterprise_id FROM gen_enterprise t1 diff --git a/src/main/resources/static/assets/layuiadmin/tpl/system/about.html b/src/main/resources/static/assets/layuiadmin/tpl/system/about.html index f37c793..854aec2 100644 --- a/src/main/resources/static/assets/layuiadmin/tpl/system/about.html +++ b/src/main/resources/static/assets/layuiadmin/tpl/system/about.html @@ -8,11 +8,3 @@

数据库版本:MySQL{{ layui.admin.mysql }}

- -
关于版权
-
- - - -

© 2019 山西腾狮 版权所有

-
\ No newline at end of file