Commit 2b878cf9 by huangjinxin

Merge branch 'develop' into develop-16542

# Conflicts:
#	project-order/pom.xml
2 parents 3943076f 15d180f2
......@@ -130,6 +130,12 @@
<artifactId>spring-kafka</artifactId>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.17</version>
</dependency>
</dependencies>
<build>
......
package com.dituhui.pea.order.controller;
import com.dituhui.pea.order.service.ImportEngineerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class ImportEngineerContrloller {
@Autowired
private ImportEngineerService importEngineerService;
@GetMapping("/importEngineer")
public void importEngineer(String excelUrl) {
importEngineerService.ImportEngineerByExcel(excelUrl);
}
@GetMapping("/ImportEngineerAndSkillByExcel")
public void ImportEngineerAndSkillByExcel(String excelUrl) {
importEngineerService.ImportEngineerAndSkillByExcel(excelUrl);
}
}
......@@ -7,10 +7,17 @@ import org.springframework.stereotype.Repository;
import java.util.List;
public interface EngineerSkillGroupDao extends JpaRepository<EngineerSkillGroupEntity, Integer> {
List<EngineerSkillGroupEntity> findByEngineerCode(String engineerCode);
List<EngineerSkillGroupEntity> findByEngineerCodeAndStatus(String engineerCode, boolean status);
List<EngineerSkillGroupEntity> findByEngineerCodeInAndStatus(List<String> engineerCodes, boolean status);
List<EngineerSkillGroupEntity> findByEngineerCodeInAndStatusIn(List<String> engineerCodes, List<Boolean> status);
List<EngineerSkillGroupEntity> findBySkillGroupCode(String skillGroupCode);
List<EngineerSkillGroupEntity> findBySkillGroupCodeAndStatus(String skillGroupCode, boolean status);
List<EngineerSkillGroupEntity> findByEngineerCode(String engineerCode);
EngineerSkillGroupEntity findByEngineerCodeAndSkillGroupCode(String engineerCode, String skillGroupCode);
List<EngineerSkillGroupEntity> findByEngineerCodeAndStatus(String engineerCode, boolean status);
List<EngineerSkillGroupEntity> findByEngineerCodeInAndStatus(List<String> engineerCodes, boolean status);
List<EngineerSkillGroupEntity> findByEngineerCodeInAndStatusIn(List<String> engineerCodes, List<Boolean> status);
List<EngineerSkillGroupEntity> findBySkillGroupCode(String skillGroupCode);
List<EngineerSkillGroupEntity> findBySkillGroupCodeAndStatus(String skillGroupCode, boolean status);
}
......@@ -4,4 +4,5 @@ import com.dituhui.pea.order.entity.SkillGroupEntity;
import org.springframework.data.jpa.repository.JpaRepository;
public interface SkillGroupDao extends JpaRepository<SkillGroupEntity, Long> {
SkillGroupEntity findBySkillGroup(String stringCellValue);
}
......@@ -29,14 +29,14 @@ public class EngineerSkillGroupEntity {
@Column(nullable = false)
private Boolean status;
@Column(length = 100, nullable = false)
@Column(length = 100, nullable = true)
private String memo;
@Column(name = "create_time", nullable = false, columnDefinition = "timestamp DEFAULT CURRENT_TIMESTAMP")
private LocalDateTime createTime;
private LocalDateTime createTime = LocalDateTime.now();
@Column(name = "update_time", nullable = false, columnDefinition = "timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP")
private LocalDateTime updateTime;
private LocalDateTime updateTime = LocalDateTime.now();
// Getters and Setters
// ...
......
package com.dituhui.pea.order.feign.bean;
import com.dituhui.pea.common.IResult;
/**
* boxi bean传输接口状态码枚举
* bean doc url https://publink-hz.feishu.cn/wiki/L4d1wwuGGiQcDqkGh3LcDJPon1i
*/
public enum BeanResultEnum implements IResult {
SUCCESS("0", "接口调用成功"),
SYSTEM_ERROR("-1", "系统错误"),
SERVICE_ERROR("2000", "业务异常"),
PARAM_ERROR("2002", "参数错误"),
TOKEN_FAILED("2005", "无效的token");
private String code;
private String message;
BeanResultEnum() {
}
BeanResultEnum(String code, String message) {
this.code = code;
this.message = message;
}
@Override
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
@Override
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
}
package com.dituhui.pea.order.service;
public interface ImportEngineerService {
void ImportEngineerByExcel(String excelurl);
void ImportEngineerAndSkillByExcel(String excelurl);
}
package com.dituhui.pea.order.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.dituhui.pea.order.dao.EngineerBusinessDao;
import com.dituhui.pea.order.dao.EngineerInfoDao;
import com.dituhui.pea.order.dao.EngineerSkillGroupDao;
import com.dituhui.pea.order.dao.SkillGroupDao;
import com.dituhui.pea.order.entity.EngineerBusinessEntity;
import com.dituhui.pea.order.entity.EngineerInfoEntity;
import com.dituhui.pea.order.entity.EngineerSkillGroupEntity;
import com.dituhui.pea.order.entity.SkillGroupEntity;
import com.dituhui.pea.order.service.ImportEngineerService;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.ss.usermodel.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.io.File;
import java.io.FileInputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Service
public class ImportEngineerServiceImpl implements ImportEngineerService {
public static String filePath = "C:\\Users\\hjx\\Documents\\WXWork\\1688854266489901\\Cache\\File\\2023-10\\副本网点技术员清单.xlsx";
//public static String filePath = "D:\\工作\\项目\\博西\\无锡分部工程师技能清单-20231011.xlsx";
private String group_id = "gsuzhou-wangdian";
private String wuxi_group_id = "379022fa9adb4b0eacdf9491c7d3c372";
private String changzhou_group_id = "6d151354073d4fb190bce2cb5f5eaef9";
@Autowired
private EngineerInfoDao engineerInfoDao;
@Autowired
private SkillGroupDao skillGroupDao;
@Autowired
private EngineerSkillGroupDao engineerSkillGroupDao;
@Autowired
private EngineerBusinessDao engineerBusinessDao;
private static Map<Integer, String> skillMap = new HashMap<>() {
{
//7嵌冰小修
put(7, "Built-inPRF_MediumRepair(B/S)");
//8嵌冰中修
put(8, "Built-inPRF_MediumRepair(B/S)");
//10嵌饮机小修
put(10, "WaterPurifier_MediumRepair(B/S)");
//11嵌饮机中修
put(11, "WaterPurifier_MediumRepair(B/S)");
//13清洗服务-冰洗
put(13, "CleanService(B/S)");
//14清洗服务-烟灶
put(14, "CleanService(B/S)");
//27嵌入式咖啡机安装(包含设计、调试)
put(27, "CoffeeMachine_Install(B/S)");
//30洗衣机小修
put(30, "Washer_MediumRepair(B/S)");
//31干衣机小修
put(31, "Dryer_MediumRepair(B/S)");
//32洗干一体机小修
put(32, "WasherDryer_MediumRepair(B/S)");
//33冰箱小修
put(33, "FreeStandingPRF_MediumRepair(B/S)");
//34洗碗机小修
put(34, "Dishcare_MediumRepair(B/S)");
//35吸油烟机小修
put(35, "Ventilation_MediumRepair(B/S)");
//36灶具小修
put(36, "Hob_MediumRepair(B/S)");
//37蒸烤微小修
put(37, "Cavity_MediumRepair(B/S)");
//38消毒柜小修
put(38, "Sterilizer_MediumRepair(B/S)");
//39嵌入式咖啡机小修
put(39, "CoffeeMachine_MediumRepair(B/S)");
//40洗衣机中修
put(40, "Washer_MediumRepair(B/S)");
//41干衣机中修
put(41, "Dryer_MediumRepair(B/S)");
//42洗干一体机中修
put(42, "WasherDryer_MediumRepair(B/S)");
//43冰箱中修
put(43, "FreeStandingPRF_MediumRepair(B/S)");
//44洗碗机中修
put(44, "Dishcare_MediumRepair(B/S)");
//45吸油烟机中修
put(45, "Ventilation_MediumRepair(B/S)");
//46灶具中修
put(46, "Hob_MediumRepair(B/S)");
//47蒸烤微中修
put(47, "Cavity_MediumRepair(B/S)");
//48消毒柜中修
put(48, "Sterilizer_MediumRepair(B/S)");
//49洗衣机大修
put(49, "Washer_MediumRepair(B/S)");
//50洗碗机大修
put(50, "Dishcare_MediumRepair(B/S)");
//51洗干一体机大修
put(51, "WasherDryer_MediumRepair(B/S)");
//52吸油烟机大修
put(52, "Ventilation_MediumRepair(B/S)");
//53消毒柜大修
put(53, "Sterilizer_MediumRepair(B/S)");
//54嵌入式咖啡机中修
put(54, "CoffeeMachine_MediumRepair(B/S)");
}
};
@Override
@Transactional
public void ImportEngineerByExcel(String excelurl) {
File file = new File(filePath);
FileInputStream fis = null;
Workbook workBook = null;
if (file.exists()) {
try {
fis = new FileInputStream(file);
workBook = WorkbookFactory.create(fis);
importEngineerByExcel(workBook, 0, 80);
} catch (Exception e) {
e.printStackTrace();
}
}
}
@Override
public void ImportEngineerAndSkillByExcel(String excelurl) {
File file = new File(filePath);
FileInputStream fis = null;
Workbook workBook = null;
if (file.exists()) {
try {
fis = new FileInputStream(file);
workBook = WorkbookFactory.create(fis);
ImportEngineerAndSkillByExcel(workBook, 0, 80);
} catch (Exception e) {
e.printStackTrace();
}
}
}
private void ImportEngineerAndSkillByExcel(Workbook workBook, int sheetNo, int rowNo) {
Sheet managerSheet = workBook.getSheetAt(sheetNo);
//获取工作表名称
String managerSheetName = managerSheet.getSheetName();
System.out.println("工作表名称:" + managerSheetName);
// 获取当前Sheet的总行数
// int rowsOfManagerSheet = managerSheet.getPhysicalNumberOfRows();
System.out.println("当前表格的总行数:" + rowNo);
try {
Row skillRow = managerSheet.getRow(2);
for (int i = 6; i < 55; i++) {
Cell shillCell = skillRow.getCell(i);
shillCell.setCellType(CellType.STRING);
SkillGroupEntity skillGroupEntity = skillGroupDao.findBySkillGroup(shillCell.getStringCellValue());
if (null != skillGroupEntity) {
skillMap.put(i, skillGroupEntity.getSkillGroupCode());
}
}
for (int i = 3; i < 90; i++) {
Row row = managerSheet.getRow(i);
EngineerInfoEntity engineerInfoEntity = makeEngineer(row);
for (int j = 6; j < 55; j++) {
Cell shillCell = row.getCell(j);
if (StringUtils.isBlank(shillCell.getStringCellValue())) {
continue;
}
String skillCode = skillMap.get(j);
EngineerSkillGroupEntity engineerSkillGroup = engineerSkillGroupDao.findByEngineerCodeAndSkillGroupCode(engineerInfoEntity.getEngineerCode(), skillCode);
if (null != engineerSkillGroup) {
continue;
}
engineerSkillGroup = new EngineerSkillGroupEntity();
engineerSkillGroup.setEngineerCode(engineerInfoEntity.getEngineerCode());
engineerSkillGroup.setSkillGroupCode(skillCode);
engineerSkillGroup.setBeanStatus(true);
engineerSkillGroup.setStatus(true);
engineerSkillGroup.setDescription("");
engineerSkillGroupDao.save(engineerSkillGroup);
}
System.out.println("工程师执行code:" + engineerInfoEntity.getEngineerCode());
System.out.println("当前row:" + i);
}
} finally {
}
}
private void importEngineerByExcel(Workbook workBook, int sheetNo, int rowNo) {
Sheet managerSheet = workBook.getSheetAt(sheetNo);
//获取工作表名称
String managerSheetName = managerSheet.getSheetName();
System.out.println("工作表名称:" + managerSheetName);
// 获取当前Sheet的总行数
// int rowsOfManagerSheet = managerSheet.getPhysicalNumberOfRows();
System.out.println("当前表格的总行数:" + rowNo);
try {
for (int i = 1; i < rowNo; i++) {
Row row = managerSheet.getRow(i);
Cell cellCode = row.getCell(1);
Cell cellName = row.getCell(2);
Cell cellPhone = row.getCell(3);
String phone = null;
String name = null;
String code = null;
try {
//设置单元格类型
cellCode.setCellType(CellType.STRING);
cellName.setCellType(CellType.STRING);
cellPhone.setCellType(CellType.STRING);
code = cellCode.getStringCellValue();
name = cellName.getStringCellValue();
phone = cellPhone.getStringCellValue();
} catch (Exception exception) {
System.out.println(exception.getMessage());
}
if (null == phone) {
continue;
}
EngineerInfoEntity byEngineerCode = getEngineerByCode(code, name, phone, "", "");
System.out.println("当前表格行数:" + i);
System.out.println("当前手机号:" + phone);
System.out.println();
}
} finally {
}
}
private EngineerInfoEntity makeEngineer(Row row) {
Cell cellCode = row.getCell(1);
Cell cellName = row.getCell(3);
Cell cityCell = row.getCell(4);
Cell categoryCell = row.getCell(0);
Cell levelCell = row.getCell(5);
String phone = "";
String group_id = "";
String name = null;
String code = null;
String category = null;
String city = null;
String level = null;
try {
//设置单元格类型
cellCode.setCellType(CellType.STRING);
cellName.setCellType(CellType.STRING);
cityCell.setCellType(CellType.STRING);
categoryCell.setCellType(CellType.STRING);
levelCell.setCellType(CellType.STRING);
code = cellCode.getStringCellValue();
name = cellName.getStringCellValue();
city = cityCell.getStringCellValue();
category = categoryCell.getStringCellValue();
level = levelCell.getStringCellValue();
if (category.equals("自有")) {
if (city.equals("无锡市")) {
group_id = "379022fa9adb4b0eacdf9491c7d3c372";
} else if (city.equals("常州市")) {
group_id = "6d151354073d4fb190bce2cb5f5eaef9";
}
} else if (category.equals("网点")) {
if (city.equals("无锡市")) {
group_id = "2a863286b3af4f5a962d1c17945485da";
} else if (city.equals("常州市")) {
group_id = "b5baf665de49421fb1b632f18de82c7a";
}
}
} catch (Exception exception) {
System.out.println(exception.getMessage());
}
EngineerInfoEntity byEngineerCode = getEngineerByCode(code, name, phone, city, level);
System.out.println("当前code:" + cellCode);
System.out.println();
return byEngineerCode;
}
private EngineerInfoEntity getEngineerByCode(String code, String name, String phone, String city, String level) {
EngineerInfoEntity byEngineerCode = engineerInfoDao.getByEngineerCode(code);
if (null == byEngineerCode) {
byEngineerCode = new EngineerInfoEntity();
byEngineerCode.setEngineerCode(code);
byEngineerCode.setName(name);
byEngineerCode.setPhone(phone);
byEngineerCode.setGroupId(group_id);
byEngineerCode.setCosmosId(code);
byEngineerCode.setGender("男");
byEngineerCode.setBirth("");
byEngineerCode.setAddress(city);
byEngineerCode.setKind(1);
byEngineerCode.setGrade(level);
byEngineerCode.setVehicle(1);
byEngineerCode.setMemo("无");
byEngineerCode.setBeanStatus(1);
engineerInfoDao.save(byEngineerCode);
}
EngineerBusinessEntity businessEntity = engineerBusinessDao.getByEngineerCode(byEngineerCode.getEngineerCode());
if (null == businessEntity) {
businessEntity = new EngineerBusinessEntity();
businessEntity.setEngineerCode(byEngineerCode.getEngineerCode());
businessEntity.setWorkOn("08:00");
businessEntity.setWorkOff("18:00");
businessEntity.setMaxNum(8);
businessEntity.setMaxMinute(600);
businessEntity.setMaxDistance(100);
businessEntity.setAddress("");
businessEntity.setX("");
businessEntity.setY("");
businessEntity.setPriority(1);
businessEntity.setDeparture(1);
businessEntity.setDispatchStrategy("CENTER");
businessEntity.setMemo("");
businessEntity.setVehicleNo("");
engineerBusinessDao.save(businessEntity);
}
return byEngineerCode;
}
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!