数据导入

This commit is contained in:
wenc000 2020-05-01 20:57:23 +08:00
parent 08abb69aff
commit 8f5d2a8f6a
19 changed files with 1096 additions and 61 deletions

View File

@ -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();
}
}

View File

@ -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<String, Object> params);
DepartmentDTO getDepartment(Map<String, Object> params);
UserDTO getUser(Map<String, Object> params);
void saveUser(Map<String, Object> userParams);
}

View File

@ -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();
}
}

View File

@ -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;
}
}

View File

@ -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<VillageGroupExcel> {
private static final Logger LOG = LoggerFactory.getLogger(VillageGroupExcelListener.class);
private List<VillageGroupExcel> 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<VillageGroupExcel> villageGroupExcels) throws Exception;
}

View File

@ -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;
}
}

View File

@ -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<VillageOrganExcel> {
private static final Logger LOG = LoggerFactory.getLogger(VillageOrganExcelListener.class);
private List<VillageOrganExcel> 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<VillageOrganExcel> villageOrganExcels) throws Exception;
}

View File

@ -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;
}
}

View File

@ -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<VillagePerson> {
private static final Logger LOG = LoggerFactory.getLogger(VillagePersonListener.class);
private List<VillagePerson> 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<VillagePerson> villagePersons) throws Exception;
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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();
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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();
}

View File

@ -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;
}

View File

@ -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<DataDictionaryDTO> 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<VillageGroupExcel> 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<String, Object> 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<VillageOrganExcel> villageOrganExcels) throws Exception {
int departmentIndex = 0;
String currentDate = DateUtil.getTime();
Map<String, Object> 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<String, Object> 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<VillagePerson> villagePersons) throws Exception {
Map<String, Object> 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<String, Object> 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();
}
/**
* 设置高风险
*

View File

@ -0,0 +1,106 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.cm.inspection.dao.data.IDataDao">
<resultMap id="departmentDTO" type="com.cm.inspection.pojo.dtos.data.DepartmentDTO">
<id column="department_id" property="departmentId"/>
<result column="department_parent_id" property="departmentParentId"/>
<result column="department_name" property="departmentName"/>
<result column="department_summary" property="departmentSummary"/>
<result column="department_code" property="departmentCode"/>
<result column="department_type" property="departmentType"/>
<result column="department_state" property="departmentState"/>
</resultMap>
<resultMap id="userDTO" type="com.cm.inspection.pojo.dtos.data.UserDTO">
<id property="userId" column="user_id"/>
<result property="userUsername" column="user_username"/>
<result property="userName" column="user_name"/>
<result property="userPhone" column="user_phone"/>
<result property="userEmail" column="user_email"/>
<result property="userState" column="user_state"/>
<result property="loginType" column="login_type"/>
<result property="remarks" column="remarks"/>
</resultMap>
<insert id="saveDepartment" parameterType="map">
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>
<select id="getDepartment" parameterType="map" resultMap="departmentDTO">
SELECT
*
FROM
db_cloud_v2.sys_department
WHERE
department_summary = #{departmentSummary}
</select>
<insert id="saveUser" parameterType="map">
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}
)
</insert>
<select id="getUser" parameterType="map" resultMap="userDTO">
SELECT
*
FROM
db_cloud_v2.sys_user
WHERE
user_username = #{userUsername}
</select>
</mapper>

View File

@ -38,6 +38,7 @@
<result column="nature" property="nature"/>
<result column="nature_dictionary_name" property="natureDictionaryName"/>
<result column="is_log_off" property="isLogOff"/>
<result column="remarks" property="remarks"/>
</resultMap>
<!-- 新增企业 -->
@ -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