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 index 9cb8dbe..7273d22 100644 --- a/src/main/java/com/cm/inspection/controller/apis/data/DataController.java +++ b/src/main/java/com/cm/inspection/controller/apis/data/DataController.java @@ -4,7 +4,6 @@ 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; @@ -26,14 +25,29 @@ public class DataController { @Autowired private IDataService dataService; - @PostMapping("saveareadatamigration") - public SuccessResult saveAreaDataMigration() throws Exception { - return dataService.saveAreaDataMigration(); + @PostMapping("savearea") + public SuccessResult saveArea() throws Exception { + return dataService.saveArea(); } - @PostMapping("saveenterprisedatamigration") - public SuccessResult saveEnterpriseDataMigration() throws Exception { - return dataService.saveEnterpriseDataMigration(); + @PostMapping("saveenterprise") + public SuccessResult saveEnterprise() throws Exception { + return dataService.saveEnterprise(); + } + + @PostMapping("savevillagegroup") + public SuccessResult saveVillageGroupDataMigration() throws Exception { + return dataService.saveVillageGroup(); + } + + @PostMapping("savevillageorgan") + public SuccessResult saveVillageOrgan() throws Exception { + return dataService.saveVillageGroupOrgan(); + } + + @PostMapping("savevillageperson") + public SuccessResult saveVillagePerson() throws Exception { + return dataService.saveVillageGroupPerson(); } } diff --git a/src/main/java/com/cm/inspection/dao/data/IDataDao.java b/src/main/java/com/cm/inspection/dao/data/IDataDao.java new file mode 100644 index 0000000..47043ed --- /dev/null +++ b/src/main/java/com/cm/inspection/dao/data/IDataDao.java @@ -0,0 +1,30 @@ +package com.cm.inspection.dao.data; + +import com.cm.inspection.pojo.dtos.data.DepartmentDTO; +import com.cm.inspection.pojo.dtos.data.UserDTO; +import com.cm.inspection.pojo.vos.data.DepartmentVO; +import org.springframework.stereotype.Repository; + +import java.util.Map; + +/** + * When you feel like quitting. Think about why you started + * 当你想要放弃的时候,想想当初你为何开始 + * + * @ClassName: IDataDao + * @Description: 数据 + * @Author: WangGeng + * @Date: 2020/5/1 16:18 + * @Version: 1.0 + **/ +@Repository +public interface IDataDao { + + void saveDepartment(Map params); + + DepartmentDTO getDepartment(Map params); + + UserDTO getUser(Map params); + + void saveUser(Map userParams); +} 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 index d33684c..37bd2cb 100644 --- a/src/main/java/com/cm/inspection/listener/excel/data/EnterpriseExcel.java +++ b/src/main/java/com/cm/inspection/listener/excel/data/EnterpriseExcel.java @@ -14,6 +14,8 @@ import com.alibaba.excel.annotation.ExcelProperty; **/ public class EnterpriseExcel { + @ExcelProperty(index = 0) + private String id; @ExcelProperty(index = 1) private String name; @ExcelProperty(index = 2) @@ -53,6 +55,14 @@ public class EnterpriseExcel { @ExcelProperty(index = 136) private String highRisk; + public String getId() { + return id == null ? "" : id; + } + + public void setId(String id) { + this.id = id; + } + public String getName() { return name == null ? "" : name; } @@ -205,48 +215,4 @@ public class EnterpriseExcel { 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/VillageGroupExcel.java b/src/main/java/com/cm/inspection/listener/excel/data/VillageGroupExcel.java new file mode 100644 index 0000000..812a1c9 --- /dev/null +++ b/src/main/java/com/cm/inspection/listener/excel/data/VillageGroupExcel.java @@ -0,0 +1,48 @@ +package com.cm.inspection.listener.excel.data; + +import com.alibaba.excel.annotation.ExcelProperty; + +/** + * When you feel like quitting. Think about why you started + * 当你想要放弃的时候,想想当初你为何开始 + * + * @ClassName: VillageGroupExcel + * @Description: 村镇 + * @Author: WangGeng + * @Date: 2020/5/1 14:56 + * @Version: 1.0 + **/ +public class VillageGroupExcel { + + @ExcelProperty(index = 1) + private String id; + @ExcelProperty(index = 2) + private String name; + @ExcelProperty(index = 9) + private Integer isDelete; + + public String getId() { + return id == null ? "" : id; + } + + public void setId(String id) { + this.id = id; + } + + public String getName() { + return name == null ? "" : name; + } + + public void setName(String name) { + this.name = name; + } + + public Integer getIsDelete() { + return isDelete; + } + + public void setIsDelete(Integer isDelete) { + this.isDelete = isDelete; + } + +} diff --git a/src/main/java/com/cm/inspection/listener/excel/data/VillageGroupExcelListener.java b/src/main/java/com/cm/inspection/listener/excel/data/VillageGroupExcelListener.java new file mode 100644 index 0000000..428323a --- /dev/null +++ b/src/main/java/com/cm/inspection/listener/excel/data/VillageGroupExcelListener.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: VillageGroupExcelListener + * @Description: 村镇组 + * @Author: WangGeng + * @Date: 2020/5/1 15:42 + * @Version: 1.0 + **/ +public abstract class VillageGroupExcelListener extends AnalysisEventListener { + + private static final Logger LOG = LoggerFactory.getLogger(VillageGroupExcelListener.class); + private List villageGroupExcels = new ArrayList<>(); + + @Override + public void invoke(VillageGroupExcel villageGroupExcel, AnalysisContext analysisContext) { + villageGroupExcels.add(villageGroupExcel); + if (villageGroupExcels.size() > 100) { + try { + listVillageGroupExcel(villageGroupExcels); + } catch (Exception e) { + LOG.error(e.getMessage(), e); + } + villageGroupExcels.clear(); + } + } + + @Override + public void doAfterAllAnalysed(AnalysisContext analysisContext) { + try { + listVillageGroupExcel(villageGroupExcels); + } catch (Exception e) { + LOG.error(e.getMessage(), e); + } + villageGroupExcels.clear(); + } + + public abstract void listVillageGroupExcel(List villageGroupExcels) throws Exception; +} diff --git a/src/main/java/com/cm/inspection/listener/excel/data/VillageOrganExcel.java b/src/main/java/com/cm/inspection/listener/excel/data/VillageOrganExcel.java new file mode 100644 index 0000000..7454301 --- /dev/null +++ b/src/main/java/com/cm/inspection/listener/excel/data/VillageOrganExcel.java @@ -0,0 +1,68 @@ +package com.cm.inspection.listener.excel.data; + +import com.alibaba.excel.annotation.ExcelProperty; + +/** + * When you feel like quitting. Think about why you started + * 当你想要放弃的时候,想想当初你为何开始 + * + * @ClassName: VillageOrganExcel + * @Description: 村镇机构 + * @Author: WangGeng + * @Date: 2020/5/1 14:57 + * @Version: 1.0 + **/ +public class VillageOrganExcel { + + @ExcelProperty(index = 1) + private String id; + @ExcelProperty(index = 2) + private String name; + @ExcelProperty(index = 3) + private String groupId; + @ExcelProperty(index = 9) + private Integer deleted; + @ExcelProperty(index = 10) + private String areaCode; + + public String getId() { + return id == null ? "" : id; + } + + public void setId(String id) { + this.id = id; + } + + public String getName() { + return name == null ? "" : name; + } + + public void setName(String name) { + this.name = name; + } + + public String getGroupId() { + return groupId == null ? "" : groupId; + } + + public void setGroupId(String groupId) { + this.groupId = groupId; + } + + public Integer getDeleted() { + return deleted; + } + + public void setDeleted(Integer deleted) { + this.deleted = deleted; + } + + public String getAreaCode() { + return areaCode == null ? "" : areaCode; + } + + public void setAreaCode(String areaCode) { + this.areaCode = areaCode; + } + +} diff --git a/src/main/java/com/cm/inspection/listener/excel/data/VillageOrganExcelListener.java b/src/main/java/com/cm/inspection/listener/excel/data/VillageOrganExcelListener.java new file mode 100644 index 0000000..196a830 --- /dev/null +++ b/src/main/java/com/cm/inspection/listener/excel/data/VillageOrganExcelListener.java @@ -0,0 +1,49 @@ +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: VillageOrganExcelListener + * @Description: 村镇机构 + * @Author: WangGeng + * @Date: 2020/5/1 15:42 + * @Version: 1.0 + **/ +public abstract class VillageOrganExcelListener extends AnalysisEventListener { + private static final Logger LOG = LoggerFactory.getLogger(VillageOrganExcelListener.class); + private List villageOrganExcels = new ArrayList<>(); + + @Override + public void invoke(VillageOrganExcel villageOrganExcel, AnalysisContext analysisContext) { + villageOrganExcels.add(villageOrganExcel); + if (villageOrganExcels.size() > 200) { + try { + listVillageOrganExcel(villageOrganExcels); + } catch (Exception e) { + LOG.error(e.getMessage(), e); + } + villageOrganExcels.clear(); + } + } + + @Override + public void doAfterAllAnalysed(AnalysisContext analysisContext) { + try { + listVillageOrganExcel(villageOrganExcels); + } catch (Exception e) { + LOG.error(e.getMessage(), e); + } + villageOrganExcels.clear(); + } + + public abstract void listVillageOrganExcel(List villageOrganExcels) throws Exception; +} \ No newline at end of file diff --git a/src/main/java/com/cm/inspection/listener/excel/data/VillagePerson.java b/src/main/java/com/cm/inspection/listener/excel/data/VillagePerson.java new file mode 100644 index 0000000..eae846d --- /dev/null +++ b/src/main/java/com/cm/inspection/listener/excel/data/VillagePerson.java @@ -0,0 +1,167 @@ +package com.cm.inspection.listener.excel.data; + +import com.alibaba.excel.annotation.ExcelProperty; + +/** + * When you feel like quitting. Think about why you started + * 当你想要放弃的时候,想想当初你为何开始 + * + * @ClassName: VillagePerson + * @Description: 村镇人员 + * @Author: WangGeng + * @Date: 2020/5/1 14:58 + * @Version: 1.0 + **/ +public class VillagePerson { + + @ExcelProperty(index = 1) + private String id; + @ExcelProperty(index = 2) + private String name; + @ExcelProperty(index = 3) + private String duty; + @ExcelProperty(index = 4) + private String phone; + @ExcelProperty(index = 6) + private String handset; + @ExcelProperty(index = 10) + private String title; + @ExcelProperty(index = 16) + private String villageCaption; + @ExcelProperty(index = 22) + private Integer deleted; + @ExcelProperty(index = 24) + private String areaCode; + @ExcelProperty(index = 26) + private String villageId; + @ExcelProperty(index = 28) + private String stafftyCheckId; + @ExcelProperty(index = 29) + private Integer hasCheckId; + @ExcelProperty(index = 30) + private String account; + @ExcelProperty(index = 31) + private String belongAreaCode; + @ExcelProperty(index = 32) + private String belongAreaName; + + public String getId() { + return id == null ? "" : id; + } + + public void setId(String id) { + this.id = id; + } + + public String getName() { + return name == null ? "" : name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDuty() { + return duty == null ? "" : duty; + } + + public void setDuty(String duty) { + this.duty = duty; + } + + public String getPhone() { + return phone == null ? "" : phone; + } + + public void setPhone(String phone) { + this.phone = phone; + } + + public String getHandset() { + return handset == null ? "" : handset; + } + + public void setHandset(String handset) { + this.handset = handset; + } + + public String getTitle() { + return title == null ? "" : title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getVillageCaption() { + return villageCaption == null ? "" : villageCaption; + } + + public void setVillageCaption(String villageCaption) { + this.villageCaption = villageCaption; + } + + public Integer getDeleted() { + return deleted; + } + + public void setDeleted(Integer deleted) { + this.deleted = deleted; + } + + public String getAreaCode() { + return areaCode == null ? "" : areaCode; + } + + public void setAreaCode(String areaCode) { + this.areaCode = areaCode; + } + + public String getVillageId() { + return villageId == null ? "" : villageId; + } + + public void setVillageId(String villageId) { + this.villageId = villageId; + } + + public String getStafftyCheckId() { + return stafftyCheckId == null ? "" : stafftyCheckId; + } + + public void setStafftyCheckId(String stafftyCheckId) { + this.stafftyCheckId = stafftyCheckId; + } + + public Integer getHasCheckId() { + return hasCheckId; + } + + public void setHasCheckId(Integer hasCheckId) { + this.hasCheckId = hasCheckId; + } + + public String getAccount() { + return account == null ? "" : account; + } + + public void setAccount(String account) { + this.account = account; + } + + public String getBelongAreaCode() { + return belongAreaCode == null ? "" : belongAreaCode; + } + + public void setBelongAreaCode(String belongAreaCode) { + this.belongAreaCode = belongAreaCode; + } + + public String getBelongAreaName() { + return belongAreaName == null ? "" : belongAreaName; + } + + public void setBelongAreaName(String belongAreaName) { + this.belongAreaName = belongAreaName; + } +} diff --git a/src/main/java/com/cm/inspection/listener/excel/data/VillagePersonListener.java b/src/main/java/com/cm/inspection/listener/excel/data/VillagePersonListener.java new file mode 100644 index 0000000..7db58df --- /dev/null +++ b/src/main/java/com/cm/inspection/listener/excel/data/VillagePersonListener.java @@ -0,0 +1,49 @@ +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: VillagePersonListener + * @Description: 村镇人员 + * @Author: WangGeng + * @Date: 2020/5/1 15:43 + * @Version: 1.0 + **/ +public abstract class VillagePersonListener extends AnalysisEventListener { + private static final Logger LOG = LoggerFactory.getLogger(VillagePersonListener.class); + private List villagePersons = new ArrayList<>(); + + @Override + public void invoke(VillagePerson villagePerson, AnalysisContext analysisContext) { + villagePersons.add(villagePerson); + if (villagePersons.size() > 200) { + try { + listVillagePerson(villagePersons); + } catch (Exception e) { + LOG.error(e.getMessage(), e); + } + villagePersons.clear(); + } + } + + @Override + public void doAfterAllAnalysed(AnalysisContext analysisContext) { + try { + listVillagePerson(villagePersons); + } catch (Exception e) { + LOG.error(e.getMessage(), e); + } + villagePersons.clear(); + } + + public abstract void listVillagePerson(List villagePersons) throws Exception; +} diff --git a/src/main/java/com/cm/inspection/pojo/dtos/data/DepartmentDTO.java b/src/main/java/com/cm/inspection/pojo/dtos/data/DepartmentDTO.java new file mode 100644 index 0000000..ee24496 --- /dev/null +++ b/src/main/java/com/cm/inspection/pojo/dtos/data/DepartmentDTO.java @@ -0,0 +1,78 @@ +package com.cm.inspection.pojo.dtos.data; + +/** + * When you feel like quitting. Think about why you started + * 当你想要放弃的时候,想想当初你为何开始 + * + * @ClassName: DepartmentDTO + * @Description: 部门 + * @Author: WangGeng + * @Date: 2020/5/1 16:21 + * @Version: 1.0 + **/ +public class DepartmentDTO { + + private String departmentId; + private String departmentParentId; + private String departmentName; + private Integer departmentType; + private Integer departmentState; + private String departmentSummary; + private String departmentCode; + + public String getDepartmentId() { + return departmentId == null ? "" : departmentId; + } + + public void setDepartmentId(String departmentId) { + this.departmentId = departmentId; + } + + public String getDepartmentParentId() { + return departmentParentId == null ? "" : departmentParentId; + } + + public void setDepartmentParentId(String departmentParentId) { + this.departmentParentId = departmentParentId; + } + + public String getDepartmentName() { + return departmentName == null ? "" : departmentName; + } + + public void setDepartmentName(String departmentName) { + this.departmentName = departmentName; + } + + public Integer getDepartmentType() { + return departmentType; + } + + public void setDepartmentType(Integer departmentType) { + this.departmentType = departmentType; + } + + public Integer getDepartmentState() { + return departmentState; + } + + public void setDepartmentState(Integer departmentState) { + this.departmentState = departmentState; + } + + public String getDepartmentSummary() { + return departmentSummary == null ? "" : departmentSummary; + } + + public void setDepartmentSummary(String departmentSummary) { + this.departmentSummary = departmentSummary; + } + + public String getDepartmentCode() { + return departmentCode == null ? "" : departmentCode; + } + + public void setDepartmentCode(String departmentCode) { + this.departmentCode = departmentCode; + } +} diff --git a/src/main/java/com/cm/inspection/pojo/dtos/data/UserDTO.java b/src/main/java/com/cm/inspection/pojo/dtos/data/UserDTO.java new file mode 100644 index 0000000..87c707a --- /dev/null +++ b/src/main/java/com/cm/inspection/pojo/dtos/data/UserDTO.java @@ -0,0 +1,78 @@ +package com.cm.inspection.pojo.dtos.data; + + +public class UserDTO { + + private String userId; + private String userUsername; + private String userName; + private String userPhone; + private String userEmail; + private Integer userState; + private Integer loginType; + private String remarks; + + public String getUserId() { + return userId == null ? "" : userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public String getUserUsername() { + return userUsername == null ? "" : userUsername; + } + + public void setUserUsername(String userUsername) { + this.userUsername = userUsername; + } + + public String getUserName() { + return userName == null ? "" : userName; + } + + public void setUserName(String userName) { + this.userName = userName; + } + + public String getUserPhone() { + return userPhone == null ? "" : userPhone; + } + + public void setUserPhone(String userPhone) { + this.userPhone = userPhone; + } + + public String getUserEmail() { + return userEmail == null ? "" : userEmail; + } + + public void setUserEmail(String userEmail) { + this.userEmail = userEmail; + } + + public Integer getUserState() { + return userState; + } + + public void setUserState(Integer userState) { + this.userState = userState; + } + + public Integer getLoginType() { + return loginType; + } + + public void setLoginType(Integer loginType) { + this.loginType = loginType; + } + + public String getRemarks() { + return remarks == null ? "" : remarks; + } + + public void setRemarks(String remarks) { + this.remarks = remarks; + } +} 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 05e21cc..9f6f23b 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 @@ -81,6 +81,8 @@ public class EnterpriseDTO { private String natureDictionaryName; @ApiModelProperty(name = "isLogOff", value = "是否注销") private Integer isLogOff; + @ApiModelProperty(name = "remarks", value = "备注") + private String remarks; public String getEnterpriseId() { return enterpriseId == null ? "" : enterpriseId; @@ -355,6 +357,14 @@ public class EnterpriseDTO { this.isLogOff = isLogOff; } + public String getRemarks() { + return remarks == null ? "" : remarks; + } + + public void setRemarks(String remarks) { + this.remarks = remarks; + } + @Override public String toString() { final StringBuilder sb = new StringBuilder("{"); @@ -426,6 +436,8 @@ public class EnterpriseDTO { .append(natureDictionaryName).append('\"'); sb.append(",\"isLogOff\":") .append(isLogOff); + sb.append(",\"remarks\":\"") + .append(remarks).append('\"'); sb.append('}'); return sb.toString(); } diff --git a/src/main/java/com/cm/inspection/pojo/vos/data/DepartmentVO.java b/src/main/java/com/cm/inspection/pojo/vos/data/DepartmentVO.java new file mode 100644 index 0000000..2c98672 --- /dev/null +++ b/src/main/java/com/cm/inspection/pojo/vos/data/DepartmentVO.java @@ -0,0 +1,71 @@ +package com.cm.inspection.pojo.vos.data; + +import io.swagger.annotations.ApiModelProperty; + +/** + * When you feel like quitting. Think about why you started + * 当你想要放弃的时候,想想当初你为何开始 + * + * @ClassName: DepartmentVO + * @Description: 部门 + * @Author: WangGeng + * @Date: 2020/5/1 16:20 + * @Version: 1.0 + **/ +public class DepartmentVO { + + private String departmentParentId; + private String departmentName; + private Integer departmentType; + private Integer departmentState; + private String departmentSummary; + private String departmentCode; + + public String getDepartmentParentId() { + return departmentParentId == null ? "" : departmentParentId; + } + + public void setDepartmentParentId(String departmentParentId) { + this.departmentParentId = departmentParentId; + } + + public String getDepartmentName() { + return departmentName == null ? "" : departmentName; + } + + public void setDepartmentName(String departmentName) { + this.departmentName = departmentName; + } + + public Integer getDepartmentType() { + return departmentType; + } + + public void setDepartmentType(Integer departmentType) { + this.departmentType = departmentType; + } + + public Integer getDepartmentState() { + return departmentState; + } + + public void setDepartmentState(Integer departmentState) { + this.departmentState = departmentState; + } + + public String getDepartmentSummary() { + return departmentSummary == null ? "" : departmentSummary; + } + + public void setDepartmentSummary(String departmentSummary) { + this.departmentSummary = departmentSummary; + } + + public String getDepartmentCode() { + return departmentCode == null ? "" : departmentCode; + } + + public void setDepartmentCode(String departmentCode) { + this.departmentCode = departmentCode; + } +} diff --git a/src/main/java/com/cm/inspection/pojo/vos/data/UserVO.java b/src/main/java/com/cm/inspection/pojo/vos/data/UserVO.java new file mode 100644 index 0000000..0fd792c --- /dev/null +++ b/src/main/java/com/cm/inspection/pojo/vos/data/UserVO.java @@ -0,0 +1,78 @@ +package com.cm.inspection.pojo.vos.data; + + +public class UserVO { + + private String userUsername; + private String userPassword; + private String userName; + private String userPhone; + private String userEmail; + private Integer userState; + private Integer loginType; + private String remarks; + + public String getUserUsername() { + return userUsername == null ? "" : userUsername; + } + + public void setUserUsername(String userUsername) { + this.userUsername = userUsername; + } + + public String getUserPassword() { + return userPassword == null ? "" : userPassword; + } + + public void setUserPassword(String userPassword) { + this.userPassword = userPassword; + } + + public String getUserName() { + return userName == null ? "" : userName; + } + + public void setUserName(String userName) { + this.userName = userName; + } + + public String getUserPhone() { + return userPhone == null ? "" : userPhone; + } + + public void setUserPhone(String userPhone) { + this.userPhone = userPhone; + } + + public String getUserEmail() { + return userEmail == null ? "" : userEmail; + } + + public void setUserEmail(String userEmail) { + this.userEmail = userEmail; + } + + public Integer getUserState() { + return userState; + } + + public void setUserState(Integer userState) { + this.userState = userState; + } + + public Integer getLoginType() { + return loginType; + } + + public void setLoginType(Integer loginType) { + this.loginType = loginType; + } + + public String getRemarks() { + return remarks == null ? "" : remarks; + } + + public void setRemarks(String remarks) { + this.remarks = remarks; + } +} 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 9ed5487..3ac825e 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 @@ -65,6 +65,8 @@ public class EnterpriseVO { private String natureDictionaryName; @ApiModelProperty(name = "isLogOff", value = "是否注销") private Integer isLogOff; + @ApiModelProperty(name = "remarks", value = "备注") + private String remarks; public String getName() { return name == null ? "" : name; @@ -258,6 +260,14 @@ public class EnterpriseVO { this.isLogOff = isLogOff; } + public String getRemarks() { + return remarks == null ? "" : remarks; + } + + public void setRemarks(String remarks) { + this.remarks = remarks; + } + @Override public String toString() { final StringBuilder sb = new StringBuilder("{"); @@ -309,6 +319,8 @@ public class EnterpriseVO { .append(natureDictionaryName).append('\"'); sb.append(",\"isLogOff\":") .append(isLogOff); + sb.append(",\"remarks\":\"") + .append(remarks).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 index 9a3dc94..ac3fcb8 100644 --- a/src/main/java/com/cm/inspection/service/data/IDataService.java +++ b/src/main/java/com/cm/inspection/service/data/IDataService.java @@ -18,7 +18,7 @@ public interface IDataService { * * @return */ - SuccessResult saveAreaDataMigration() throws Exception; + SuccessResult saveArea() throws Exception; /** * 企业数据迁移 @@ -26,5 +26,29 @@ public interface IDataService { * @return * @throws Exception */ - SuccessResult saveEnterpriseDataMigration() throws Exception; + SuccessResult saveEnterprise() throws Exception; + + /** + * 村镇组数据迁移 + * + * @return + * @throws Exception + */ + SuccessResult saveVillageGroup() throws Exception; + + /** + * 村镇机构数据迁移 + * + * @return + * @throws Exception + */ + SuccessResult saveVillageGroupOrgan() throws Exception; + + /** + * 网格员数据迁移 + * + * @return + * @throws Exception + */ + SuccessResult saveVillageGroupPerson() 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 index 841ce40..be811b1 100644 --- a/src/main/java/com/cm/inspection/service/data/impl/DataServiceImpl.java +++ b/src/main/java/com/cm/inspection/service/data/impl/DataServiceImpl.java @@ -1,26 +1,37 @@ package com.cm.inspection.service.data.impl; import com.alibaba.excel.EasyExcel; +import com.alibaba.excel.ExcelReader; 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.common.utils.DateUtil; +import com.cm.common.utils.HashMapUtil; +import com.cm.common.utils.UUIDUtil; +import com.cm.inspection.dao.data.IDataDao; +import com.cm.inspection.listener.excel.data.*; +import com.cm.inspection.pojo.dtos.data.DepartmentDTO; +import com.cm.inspection.pojo.dtos.data.UserDTO; +import com.cm.inspection.pojo.vos.data.DepartmentVO; +import com.cm.inspection.pojo.vos.data.UserVO; import com.cm.inspection.pojo.vos.enterprise.EnterpriseVO; +import com.cm.inspection.service.BaseService; import com.cm.inspection.service.data.IDataService; import com.cm.inspection.service.enterprise.IEnterpriseService; +import com.hazelcast.util.MD5Util; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; import org.springframework.stereotype.Service; import java.io.File; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; /** * When you feel like quitting. Think about why you started @@ -33,15 +44,17 @@ import java.util.List; * @Version: 1.0 **/ @Service -public class DataServiceImpl implements IDataService { +public class DataServiceImpl extends BaseService implements IDataService { @Autowired private IDataDictionaryService dataDictionaryService; @Autowired private IEnterpriseService enterpriseService; + @Autowired + private IDataDao dataDao; @Override - public SuccessResult saveAreaDataMigration() throws Exception { + public SuccessResult saveArea() throws Exception { File areaDataFile = new File("C:\\Users\\Administrator\\Desktop\\area.xls"); JSONArray excelDataJsonArray = new JSONArray(); EasyExcel.read(areaDataFile, AreaExcel.class, new AreaExcelListener() { @@ -65,8 +78,8 @@ public class DataServiceImpl implements IDataService { } @Override - public SuccessResult saveEnterpriseDataMigration() throws Exception { - File enterpriseDataFile = new File("C:\\Users\\Administrator\\Desktop\\core_company.xls"); + public SuccessResult saveEnterprise() throws Exception { + File enterpriseDataFile = new File("C:\\Users\\Administrator\\Desktop\\core_company.xlsx"); // 地区列表 List areaDatas = dataDictionaryService.listDictionaryByDictionaryCode("0004"); // 行业列表 @@ -84,6 +97,7 @@ public class DataServiceImpl implements IDataService { continue; } EnterpriseVO enterpriseVO = new EnterpriseVO(); + enterpriseVO.setRemarks(enterpriseExcel.getId()); enterpriseVO.setName(enterpriseExcel.getName()); enterpriseVO.setType(getTypeId(enterpriseExcel.getCompanyType(), typeDatas)); enterpriseVO.setAddress(enterpriseExcel.getAddress()); @@ -108,6 +122,121 @@ public class DataServiceImpl implements IDataService { return new SuccessResult(); } + @Override + public SuccessResult saveVillageGroup() throws Exception { + File villageGroupFile = new File("C:\\Users\\Administrator\\Desktop\\jd_village_group.xlsx"); + EasyExcel.read(villageGroupFile, VillageGroupExcel.class, new VillageGroupExcelListener() { + @Override + public void listVillageGroupExcel(List villageGroupExcels) throws Exception { + int departmentIndex = 0; + String currentDate = DateUtil.getTime(); + for (VillageGroupExcel villageGroupExcel : villageGroupExcels) { + if (StringUtils.isBlank(villageGroupExcel.getName())) { + continue; + } + if (villageGroupExcel.getIsDelete() == 1) { + continue; + } + departmentIndex++; + DepartmentVO departmentVO = new DepartmentVO(); + departmentVO.setDepartmentName(villageGroupExcel.getName()); + departmentVO.setDepartmentParentId("bb281ba2-7b98-496b-8180-33250c2c77e1"); + departmentVO.setDepartmentType(1); + departmentVO.setDepartmentState(0); + departmentVO.setDepartmentSummary(villageGroupExcel.getId()); + departmentVO.setDepartmentCode(String.format("0001%04d", departmentIndex)); + Map params = HashMapUtil.beanToMap(departmentVO); + params.put("departmentId", UUIDUtil.getUUID()); + params.put("gmtCreate", currentDate); + params.put("creator", "1"); + params.put("gmtModified", currentDate); + params.put("isDelete", 0); + dataDao.saveDepartment(params); + } + } + }).sheet().doRead(); + return new SuccessResult(); + } + + @Override + public SuccessResult saveVillageGroupOrgan() throws Exception { + File villageOrganFile = new File("C:\\Users\\Administrator\\Desktop\\jd_village_organ.xlsx"); + EasyExcel.read(villageOrganFile, VillageOrganExcel.class, new VillageOrganExcelListener() { + @Override + public void listVillageOrganExcel(List villageOrganExcels) throws Exception { + int departmentIndex = 0; + String currentDate = DateUtil.getTime(); + Map params = new HashMap<>(5); + for (VillageOrganExcel villageOrganExcel : villageOrganExcels) { + if (StringUtils.isBlank(villageOrganExcel.getName())) { + continue; + } + if (villageOrganExcel.getDeleted() == 1) { + continue; + } + params.put("departmentSummary", villageOrganExcel.getGroupId()); + DepartmentDTO parentDepartmentDTO = dataDao.getDepartment(params); + if (parentDepartmentDTO == null) { + LOG.debug("{}的上级单位不存在", villageOrganExcel.getName()); + continue; + } + departmentIndex++; + DepartmentVO departmentVO = new DepartmentVO(); + departmentVO.setDepartmentName(villageOrganExcel.getName()); + departmentVO.setDepartmentParentId(parentDepartmentDTO.getDepartmentId()); + departmentVO.setDepartmentType(2); + departmentVO.setDepartmentState(0); + departmentVO.setDepartmentSummary(villageOrganExcel.getId()); + departmentVO.setDepartmentCode(String.format("%s%04d", parentDepartmentDTO.getDepartmentCode(), departmentIndex)); + Map departmentMap = HashMapUtil.beanToMap(departmentVO); + departmentMap.put("departmentId", UUIDUtil.getUUID()); + departmentMap.put("gmtCreate", currentDate); + departmentMap.put("creator", "1"); + departmentMap.put("gmtModified", currentDate); + departmentMap.put("isDelete", 0); + dataDao.saveDepartment(departmentMap); + } + } + }).sheet().doRead(); + return new SuccessResult(); + } + + @Override + public SuccessResult saveVillageGroupPerson() throws Exception { + File villagePersonFile = new File("C:\\Users\\Administrator\\Desktop\\jd_village_person.xlsx"); + EasyExcel.read(villagePersonFile, VillagePerson.class, new VillagePersonListener() { + @Override + public void listVillagePerson(List villagePersons) throws Exception { + Map params = new HashMap<>(); + String currentDate = DateUtil.getTime(); + for (VillagePerson villagePerson : villagePersons) { + params.put("userUsername", villagePerson.getAccount()); + UserDTO userDTO = dataDao.getUser(params); + if (userDTO != null) { + continue; + } + UserVO userVO = new UserVO(); + userVO.setUserUsername(villagePerson.getAccount()); + userVO.setUserName(villagePerson.getName()); + userVO.setUserPhone(villagePerson.getHandset()); + userVO.setUserPassword(new BCryptPasswordEncoder().encode(MD5Util.toMD5String(MD5Util.toMD5String(MD5Util.toMD5String("123456"))))); + userVO.setUserState(1); + userVO.setLoginType(1); + userVO.setRemarks(villagePerson.getId()); + Map userParams = HashMapUtil.beanToMap(userVO); + userParams.put("userId", UUIDUtil.getUUID()); + userParams.put("creator", "1"); + userParams.put("gmtCreate", currentDate); + userParams.put("modifier", "1"); + userParams.put("gmtModified", currentDate); + userParams.put("isDelete", 0); + dataDao.saveUser(userParams); + } + } + }).sheet().doRead(); + return new SuccessResult(); + } + /** * 设置高风险 * diff --git a/src/main/resources/mybatis/mapper/data/data-mapper.xml b/src/main/resources/mybatis/mapper/data/data-mapper.xml new file mode 100644 index 0000000..10d2608 --- /dev/null +++ b/src/main/resources/mybatis/mapper/data/data-mapper.xml @@ -0,0 +1,106 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + INSERT INTO db_cloud_v2.sys_department( + department_id, + department_parent_id, + department_name, + department_summary, + department_code, + department_type, + department_state, + creator, + gmt_create, + modifier, + gmt_modified, + is_delete + ) VALUES( + #{departmentId}, + #{departmentParentId}, + #{departmentName}, + #{departmentSummary}, + #{departmentCode}, + #{departmentType}, + #{departmentState}, + #{creator}, + #{gmtCreate}, + #{modifier}, + #{gmtModified}, + #{isDelete} + ) + + + + + + INSERT INTO db_cloud_v2.sys_user( + user_id, + user_username, + user_password, + user_name, + user_phone, + user_email, + user_state, + remarks, + creator, + gmt_create, + modifier, + gmt_modified, + is_delete + ) VALUES( + #{userId}, + #{userUsername}, + #{userPassword}, + #{userName}, + #{userPhone}, + #{userEmail}, + #{userState}, + #{remarks}, + #{creator}, + #{gmtCreate}, + #{modifier}, + #{gmtModified}, + #{isDelete} + ) + + + + + \ No newline at end of file diff --git a/src/main/resources/mybatis/mapper/enterprise/enterprise-mapper.xml b/src/main/resources/mybatis/mapper/enterprise/enterprise-mapper.xml index c59aa20..7c92b95 100644 --- a/src/main/resources/mybatis/mapper/enterprise/enterprise-mapper.xml +++ b/src/main/resources/mybatis/mapper/enterprise/enterprise-mapper.xml @@ -38,6 +38,7 @@ + @@ -77,6 +78,7 @@ nature, nature_dictionary_name, is_log_off, + remarks, creator, gmt_create, modifier, @@ -117,6 +119,7 @@ #{nature}, #{natureDictionaryName}, #{isLogOff}, + #{remarks}, #{creator}, #{gmtCreate}, #{modifier}, @@ -303,6 +306,7 @@ t1.nature, t1.nature_dictionary_name, t1.is_log_off, + t1.remarks, t1.enterprise_id FROM gen_enterprise t1 @@ -342,6 +346,7 @@ t1.nature, t1.nature_dictionary_name, t1.is_log_off, + t1.remarks, t1.enterprise_id FROM gen_enterprise t1 @@ -387,6 +392,7 @@ t1.nature, t1.nature_dictionary_name, t1.is_log_off, + t1.remarks, t1.enterprise_id FROM gen_enterprise t1