数据导入

This commit is contained in:
wenc000 2020-05-03 18:37:33 +08:00
parent c894047ff9
commit 26dcc1ae71
8 changed files with 52 additions and 48 deletions

View File

@ -14,11 +14,11 @@ import com.alibaba.excel.annotation.ExcelProperty;
**/ **/
public class EnterprisePersonExcel { public class EnterprisePersonExcel {
@ExcelProperty(index = 2) @ExcelProperty(index = 1)
private Integer companyId; private Integer companyId;
@ExcelProperty(index = 4) @ExcelProperty(index = 3)
private Integer userId; private Integer userId;
@ExcelProperty(index = 5) @ExcelProperty(index = 4)
private Integer isDeleted; private Integer isDeleted;
public Integer getCompanyId() { public Integer getCompanyId() {

View File

@ -14,19 +14,19 @@ import com.alibaba.excel.annotation.ExcelProperty;
**/ **/
public class UserExcel { public class UserExcel {
@ExcelProperty(index = 2) @ExcelProperty(index = 1)
private String area1; private String area1;
@ExcelProperty(index = 3) @ExcelProperty(index = 2)
private String area2; private String area2;
@ExcelProperty(index = 4) @ExcelProperty(index = 3)
private String area3; private String area3;
@ExcelProperty(index = 5) @ExcelProperty(index = 4)
private String area4; private String area4;
@ExcelProperty(index = 15) @ExcelProperty(index = 14)
private String area5; private String area5;
@ExcelProperty(index = 6) @ExcelProperty(index = 5)
private String name; private String name;
@ExcelProperty(index = 11) @ExcelProperty(index = 10)
private String phone; private String phone;
public String getArea1() { public String getArea1() {

View File

@ -14,11 +14,11 @@ import com.alibaba.excel.annotation.ExcelProperty;
**/ **/
public class VillageGroupExcel { public class VillageGroupExcel {
@ExcelProperty(index = 1) @ExcelProperty(index = 0)
private String id; private String id;
@ExcelProperty(index = 2) @ExcelProperty(index = 1)
private String name; private String name;
@ExcelProperty(index = 9) @ExcelProperty(index = 8)
private Integer isDelete; private Integer isDelete;
public String getId() { public String getId() {

View File

@ -14,15 +14,15 @@ import com.alibaba.excel.annotation.ExcelProperty;
**/ **/
public class VillageOrganExcel { public class VillageOrganExcel {
@ExcelProperty(index = 1) @ExcelProperty(index = 0)
private String id; private String id;
@ExcelProperty(index = 2) @ExcelProperty(index = 1)
private String name; private String name;
@ExcelProperty(index = 3) @ExcelProperty(index = 2)
private String groupId; private String groupId;
@ExcelProperty(index = 9) @ExcelProperty(index = 8)
private Integer deleted; private Integer deleted;
@ExcelProperty(index = 10) @ExcelProperty(index = 9)
private String areaCode; private String areaCode;
public String getId() { public String getId() {

View File

@ -14,9 +14,9 @@ import com.alibaba.excel.annotation.ExcelProperty;
**/ **/
public class VillageOrganPersonExcel { public class VillageOrganPersonExcel {
@ExcelProperty(index = 1) @ExcelProperty(index = 0)
private Integer organId; private Integer organId;
@ExcelProperty(index = 2) @ExcelProperty(index = 1)
private Integer userId; private Integer userId;
public Integer getOrganId() { public Integer getOrganId() {

View File

@ -14,35 +14,35 @@ import com.alibaba.excel.annotation.ExcelProperty;
**/ **/
public class VillagePerson { public class VillagePerson {
@ExcelProperty(index = 1) @ExcelProperty(index = 0)
private Integer id; private Integer id;
@ExcelProperty(index = 2) @ExcelProperty(index = 1)
private String name; private String name;
@ExcelProperty(index = 3) @ExcelProperty(index = 2)
private String duty; private String duty;
@ExcelProperty(index = 4) @ExcelProperty(index = 3)
private String phone; private String phone;
@ExcelProperty(index = 6) @ExcelProperty(index = 5)
private String handset; private String handset;
@ExcelProperty(index = 10) @ExcelProperty(index = 9)
private String title; private String title;
@ExcelProperty(index = 16) @ExcelProperty(index = 15)
private String villageCaption; private String villageCaption;
@ExcelProperty(index = 22) @ExcelProperty(index = 21)
private Integer deleted; private Integer deleted;
@ExcelProperty(index = 24) @ExcelProperty(index = 23)
private String areaCode; private String areaCode;
@ExcelProperty(index = 26) @ExcelProperty(index = 25)
private String villageId; private String villageId;
@ExcelProperty(index = 28) @ExcelProperty(index = 27)
private String stafftyCheckId; private String stafftyCheckId;
@ExcelProperty(index = 29) @ExcelProperty(index = 28)
private Integer hasCheckId; private Integer hasCheckId;
@ExcelProperty(index = 30) @ExcelProperty(index = 29)
private String account; private String account;
@ExcelProperty(index = 31) @ExcelProperty(index = 30)
private String belongAreaCode; private String belongAreaCode;
@ExcelProperty(index = 32) @ExcelProperty(index = 31)
private String belongAreaName; private String belongAreaName;
public Integer getId() { public Integer getId() {

View File

@ -135,7 +135,7 @@ public class DataServiceImpl extends BaseService implements IDataService {
@Override @Override
public SuccessResult saveVillageGroup() throws Exception { public SuccessResult saveVillageGroup() throws Exception {
File villageGroupFile = new File("C:\\Users\\Administrator\\Desktop\\jd_village_group.xlsx"); File villageGroupFile = new File("/Users/wenc/Desktop/data/jd_village_group.xlsx");
EasyExcel.read(villageGroupFile, VillageGroupExcel.class, new VillageGroupExcelListener() { EasyExcel.read(villageGroupFile, VillageGroupExcel.class, new VillageGroupExcelListener() {
@Override @Override
public void listVillageGroupExcel(List<VillageGroupExcel> villageGroupExcels) throws Exception { public void listVillageGroupExcel(List<VillageGroupExcel> villageGroupExcels) throws Exception {
@ -171,7 +171,7 @@ public class DataServiceImpl extends BaseService implements IDataService {
@Override @Override
public SuccessResult saveVillageGroupOrgan() throws Exception { public SuccessResult saveVillageGroupOrgan() throws Exception {
File villageOrganFile = new File("C:\\Users\\Administrator\\Desktop\\jd_village_organ.xlsx"); File villageOrganFile = new File("/Users/wenc/Desktop/data/jd_village_organ.xlsx");
EasyExcel.read(villageOrganFile, VillageOrganExcel.class, new VillageOrganExcelListener() { EasyExcel.read(villageOrganFile, VillageOrganExcel.class, new VillageOrganExcelListener() {
@Override @Override
public void listVillageOrganExcel(List<VillageOrganExcel> villageOrganExcels) throws Exception { public void listVillageOrganExcel(List<VillageOrganExcel> villageOrganExcels) throws Exception {
@ -214,7 +214,7 @@ public class DataServiceImpl extends BaseService implements IDataService {
@Override @Override
public SuccessResult saveVillageGroupPerson() throws Exception { public SuccessResult saveVillageGroupPerson() throws Exception {
File villagePersonFile = new File("/Users/wenc/Desktop/包头应急局数据data/jd_village_person.xls"); File villagePersonFile = new File("/Users/wenc/Desktop/data/jd_village_person.xlsx");
EasyExcel.read(villagePersonFile, VillagePerson.class, new VillagePersonListener() { EasyExcel.read(villagePersonFile, VillagePerson.class, new VillagePersonListener() {
@Override @Override
public void listVillagePerson(List<VillagePerson> villagePersons) throws Exception { public void listVillagePerson(List<VillagePerson> villagePersons) throws Exception {
@ -250,7 +250,7 @@ public class DataServiceImpl extends BaseService implements IDataService {
@Override @Override
public SuccessResult saveVillageOrganPerson() throws Exception { public SuccessResult saveVillageOrganPerson() throws Exception {
File villageOrganPersonFile = new File("/Users/wenc/Desktop/包头应急局数据data/jd_village_organ_person_rel.xls"); File villageOrganPersonFile = new File("/Users/wenc/Desktop/data/jd_village_organ_person_rel.xlsx");
final int[] unExistUserCount = {0}; final int[] unExistUserCount = {0};
final int[] unExistDepartmentCount = {0}; final int[] unExistDepartmentCount = {0};
final List<String> unExistUserIds = new ArrayList<>(); final List<String> unExistUserIds = new ArrayList<>();
@ -292,7 +292,7 @@ public class DataServiceImpl extends BaseService implements IDataService {
@Override @Override
public SuccessResult saveCompanyPerson() throws Exception { public SuccessResult saveCompanyPerson() throws Exception {
File companyPersonFile = new File("/Users/wenc/Desktop/包头应急局数据data/jd_com_village_rel.xlsx"); File companyPersonFile = new File("/Users/wenc/Desktop/data/jd_com_village_rel.xlsx");
List<String> unExistEnterpriseIds = new ArrayList<>(); List<String> unExistEnterpriseIds = new ArrayList<>();
List<String> moreEnterpriseIds = new ArrayList<>(); List<String> moreEnterpriseIds = new ArrayList<>();
List<String> unExistPersonIds = new ArrayList<>(); List<String> unExistPersonIds = new ArrayList<>();
@ -342,7 +342,7 @@ public class DataServiceImpl extends BaseService implements IDataService {
@Override @Override
public SuccessResult saveUser() throws Exception { public SuccessResult saveUser() throws Exception {
File userFile = new File("/Users/wenc/Desktop/包头应急局数据data/jd_com_village_rel.xlsx"); File userFile = new File("/Users/wenc/Desktop/data/t_person.xlsx");
List<String> existUsers = new ArrayList<>(); List<String> existUsers = new ArrayList<>();
EasyExcel.read(userFile, UserExcel.class, new UserExcelListener() { EasyExcel.read(userFile, UserExcel.class, new UserExcelListener() {
@Override @Override
@ -350,6 +350,10 @@ public class DataServiceImpl extends BaseService implements IDataService {
Map<String, Object> params = getHashMap(1); Map<String, Object> params = getHashMap(1);
String currentDate = DateUtil.getTime(); String currentDate = DateUtil.getTime();
for (UserExcel userExcel : userExcels) { for (UserExcel userExcel : userExcels) {
if(StringUtils.isBlank(userExcel.getPhone())) {
existUsers.add(String.format("%s|%s", userExcel.getPhone(), userExcel.getName()));
continue;
}
params.put("userUsername", userExcel.getPhone()); params.put("userUsername", userExcel.getPhone());
UserDTO userDTO = dataDao.getUser(params); UserDTO userDTO = dataDao.getUser(params);
if (userDTO != null) { if (userDTO != null) {
@ -419,21 +423,21 @@ public class DataServiceImpl extends BaseService implements IDataService {
String gridUserId = String.format("%s|%s|%s|【%s】%s", userDTO.getUserId(), userDTO.getDepartmentId(), userDTO.getUserName(), userDTO.getDepartmentName(), userDTO.getUserName()); String gridUserId = String.format("%s|%s|%s|【%s】%s", userDTO.getUserId(), userDTO.getDepartmentId(), userDTO.getUserName(), userDTO.getDepartmentName(), userDTO.getUserName());
GridPersonnelVO gridPersonnelVO = new GridPersonnelVO(); GridPersonnelVO gridPersonnelVO = new GridPersonnelVO();
gridPersonnelVO.setLevel(dataDictionaryDTOs.size()); gridPersonnelVO.setLevel(dataDictionaryDTOs.size() - 1);
gridPersonnelVO.setIsGridOperator(1); gridPersonnelVO.setIsGridOperator(1);
gridPersonnelVO.setUserId(gridUserId); gridPersonnelVO.setUserId(gridUserId);
for (int i = dataDictionaryDTOs.size(); i > 0; i--) { for (int i = dataDictionaryDTOs.size(); i > 0; i--) {
String dictionaryId = dataDictionaryDTOs.get(i - 1).getDictionaryId(); String dictionaryId = dataDictionaryDTOs.get(i - 1).getDictionaryId();
if (i == 5) { if (i == 5) {
gridPersonnelVO.setArea5(dictionaryId); gridPersonnelVO.setArea1(dictionaryId);
} else if (i == 4) { } else if (i == 4) {
gridPersonnelVO.setArea4(dictionaryId); gridPersonnelVO.setArea2(dictionaryId);
} else if (i == 3) { } else if (i == 3) {
gridPersonnelVO.setArea4(dictionaryId); gridPersonnelVO.setArea3(dictionaryId);
} else if (i == 2) { } else if (i == 2) {
gridPersonnelVO.setArea4(dictionaryId); gridPersonnelVO.setArea4(dictionaryId);
} else if (i == 1) { } else if (i == 1) {
gridPersonnelVO.setArea4(dictionaryId); gridPersonnelVO.setArea5(dictionaryId);
} }
} }
gridPersonnelService.saveGridPersonnel(gridPersonnelVO); gridPersonnelService.saveGridPersonnel(gridPersonnelVO);

View File

@ -112,7 +112,7 @@
t2.department_name, t2.department_name,
t3.* t3.*
FROM FROM
db_cloud_v2.sys_department t1 db_cloud_v2.sys_department_user t1
INNER JOIN INNER JOIN
db_cloud_v2.sys_department t2 db_cloud_v2.sys_department t2
ON ON
@ -151,7 +151,7 @@
) )
</insert> </insert>
<select id="getArea" parameterType="map" resultMap="dataDictionaryDTO"> <select id="getArea" parameterType="map" resultMap="dictionaryDTO">
SELECT SELECT
* *
FROM FROM