Commit b2acdbbb by wangli

新增技术员技能&属性配置

1 parent 2dc7bc05
...@@ -4,10 +4,7 @@ import com.alibaba.cloud.integration.common.BusinessException; ...@@ -4,10 +4,7 @@ import com.alibaba.cloud.integration.common.BusinessException;
import com.alibaba.cloud.integration.common.Result; import com.alibaba.cloud.integration.common.Result;
import com.alibaba.cloud.integration.order.service.EngineerService; import com.alibaba.cloud.integration.order.service.EngineerService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
@RestController @RestController
public class EngineerController { public class EngineerController {
...@@ -38,4 +35,29 @@ public class EngineerController { ...@@ -38,4 +35,29 @@ public class EngineerController {
} }
return res; return res;
} }
@GetMapping("/engineer/business/list")
public Result<?> getEngineerBusinessList(@RequestParam long page, @RequestParam long size) {
// 技术员业务属性配置列表
Result<?> res = null;
try {
res = engineerService.getEngineerBusinessList(page, size);
} catch (BusinessException e) {
Result.failed(e.getMessage());
}
return res;
}
@PostMapping("/engineer/business/update")
public Result<?> engineerBusinessUpdate(@RequestBody String engineerCode, @RequestBody Integer maxNum,
@RequestBody Integer maxMinute, @RequestBody String departure, @RequestBody String priority) {
// 技术员业务属性配置更新
Result<?> res = null;
try {
res = engineerService.engineerBusinessUpdate(engineerCode, maxNum, maxMinute, departure, priority);
} catch (BusinessException e) {
Result.failed(e.getMessage());
}
return res;
}
} }
...@@ -7,6 +7,12 @@ public interface EngineerService { ...@@ -7,6 +7,12 @@ public interface EngineerService {
// 获取公司列表 // 获取公司列表
Result<?> getEngineerInfoList(long page, long size); Result<?> getEngineerInfoList(long page, long size);
//获取工程师技能列表 // 获取工程师技能列表
Result<?> getEngineerSkillList(long page, long size); Result<?> getEngineerSkillList(long page, long size);
// 工程师业务属性配置列表
Result<?> getEngineerBusinessList(long page, long size);
// 技术员业务属性配置修改
Result<?> engineerBusinessUpdate(String engineerCode, Integer maxNum, Integer maxMutine, String departure, String priority);
} }
package com.alibaba.cloud.integration.order.service.impl; package com.alibaba.cloud.integration.order.service.impl;
import com.alibaba.cloud.integration.common.Result; import com.alibaba.cloud.integration.common.Result;
import com.alibaba.cloud.integration.order.dao.EngineerBusinessDao;
import com.alibaba.cloud.integration.order.dao.EngineerInfoDao; import com.alibaba.cloud.integration.order.dao.EngineerInfoDao;
import com.alibaba.cloud.integration.order.dao.EngineerSkillDao; import com.alibaba.cloud.integration.order.dao.EngineerSkillDao;
import com.alibaba.cloud.integration.order.dao.OrgGroupDao; import com.alibaba.cloud.integration.order.dao.OrgGroupDao;
import com.alibaba.cloud.integration.order.dto.EngineerBusinessListResp;
import com.alibaba.cloud.integration.order.dto.EngineerInfoListResp; import com.alibaba.cloud.integration.order.dto.EngineerInfoListResp;
import com.alibaba.cloud.integration.order.entity.EngineerBusiness;
import com.alibaba.cloud.integration.order.entity.EngineerInfo; import com.alibaba.cloud.integration.order.entity.EngineerInfo;
import com.alibaba.cloud.integration.order.entity.OrgGroup; import com.alibaba.cloud.integration.order.entity.OrgGroup;
import com.alibaba.cloud.integration.order.service.EngineerService; import com.alibaba.cloud.integration.order.service.EngineerService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -17,6 +21,7 @@ import org.springframework.transaction.annotation.Transactional; ...@@ -17,6 +21,7 @@ import org.springframework.transaction.annotation.Transactional;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
import java.util.stream.Collectors;
@Service @Service
public class EngineerServiceImpl implements EngineerService { public class EngineerServiceImpl implements EngineerService {
...@@ -30,6 +35,9 @@ public class EngineerServiceImpl implements EngineerService { ...@@ -30,6 +35,9 @@ public class EngineerServiceImpl implements EngineerService {
@Autowired @Autowired
private OrgGroupDao orgGroupDao; private OrgGroupDao orgGroupDao;
@Autowired
private EngineerBusinessDao engineerBusinessDao;
@Transactional @Transactional
@Override @Override
public Result<?> getEngineerInfoList(long page, long size) { public Result<?> getEngineerInfoList(long page, long size) {
...@@ -60,9 +68,102 @@ public class EngineerServiceImpl implements EngineerService { ...@@ -60,9 +68,102 @@ public class EngineerServiceImpl implements EngineerService {
@Transactional @Transactional
@Override @Override
public Result<?> getEngineerSkillList(long page, long size) { public Result<?> getEngineerSkillList(long page, long size) {
// 获取技术员技能列表
return null; return null;
} }
@Transactional
@Override
public Result<?> getEngineerBusinessList(long page, long size) {
// 技术员业务属性配置列表
// 查询技术员列表
IPage<EngineerInfo> pg = this.queryEngineerInfo(page, size);
List<EngineerInfo> records = pg.getRecords();
// 获取技术员code列表
List<String> engineerCodes = records.stream().map(EngineerInfo::getEngineerCode).collect(Collectors.toList());
HashMap<String, EngineerBusiness> buss = this.queryEngineerBusiness(engineerCodes);
List<EngineerBusinessListResp.EngineerBusiness> items = new ArrayList<>();
EngineerBusiness b;
for(EngineerInfo e: records) {
EngineerBusinessListResp.EngineerBusiness item = new EngineerBusinessListResp.EngineerBusiness();
item.setEngineerCode(e.getEngineerCode());
item.setEngineerName(e.getName());
item.setWorkType((e.getKind() == 1) ? "fullJob": "partJob");
b = buss.getOrDefault(e.getEngineerCode(), null);
if (b == null) {
item.setAddress("");
item.setLocation("");
item.setDeparture("");
item.setMaxMinute(0);
item.setMaxNum(0);
item.setPriority("低");
} else {
item.setAddress(b.getAddress());
item.setLocation(String.format("%s,%s", b.getX(), b.getY()));
item.setDeparture((b.getDeparture() == 1) ? "配件仓" : "住址");
item.setMaxMinute(b.getMaxMinute());
item.setMaxNum(b.getMaxNum());
String priority;
if (b.getPriority() == 3) {
priority = "高";
} else if (b.getPriority() == 2) {
priority = "中";
} else {
priority = "低";
}
item.setPriority(priority);
}
items.add(item);
}
// 查询技术员业务属性
EngineerBusinessListResp res = new EngineerBusinessListResp();
res.setTotal(pg.getTotal());
res.setPages(pg.getPages());
res.setPageCurrent(pg.getCurrent());
res.setPageSize(pg.getSize());
res.setContent(items);
return Result.success(res);
}
@Transactional
@Override
public Result<?> engineerBusinessUpdate(String engineerCode, Integer maxNum, Integer maxMinute, String departure, String priority) {
// 技术员业务属性配置修改
LambdaUpdateWrapper<EngineerBusiness> wrapper = new LambdaUpdateWrapper<>();
wrapper.eq(EngineerBusiness::getEngineerCode, engineerCode);
wrapper.set(maxNum >= 0, EngineerBusiness::getMaxNum, maxNum);
wrapper.set(maxMinute >= 0, EngineerBusiness::getMaxMinute, maxMinute);
Integer dep = (departure.equals("配件仓")) ? 1 : 2;
wrapper.set(EngineerBusiness::getDeparture, dep);
Integer pri;
if (priority.equals("高")) {
pri = 3;
} else if (priority.equals("中")) {
pri = 2;
} else {
pri = 1;
}
wrapper.set(EngineerBusiness::getPriority, pri);
// 更新字段
engineerBusinessDao.update(null, wrapper);
return Result.success(null);
}
private IPage<EngineerInfo> queryEngineerInfo(long page, long size) { private IPage<EngineerInfo> queryEngineerInfo(long page, long size) {
// 分页查询工程师基础信息 // 分页查询工程师基础信息
LambdaQueryWrapper<EngineerInfo> lqw = new LambdaQueryWrapper<>(); LambdaQueryWrapper<EngineerInfo> lqw = new LambdaQueryWrapper<>();
...@@ -91,6 +192,20 @@ public class EngineerServiceImpl implements EngineerService { ...@@ -91,6 +192,20 @@ public class EngineerServiceImpl implements EngineerService {
return map; return map;
} }
private HashMap<String, EngineerBusiness> queryEngineerBusiness(List<String> engineerCodes) {
HashMap<String, EngineerBusiness> map = new HashMap<>();
if (engineerCodes.isEmpty()) {
return map;
}
LambdaQueryWrapper<EngineerBusiness> lqw = new LambdaQueryWrapper<>();
lqw.in(EngineerBusiness::getEngineerCode, engineerCodes);
List<EngineerBusiness> records = engineerBusinessDao.selectList(lqw);
for(EngineerBusiness r: records) {
map.put(r.getEngineerCode(), r);
}
return map;
}
private List<EngineerInfoListResp.EngineerInfo> packEngineerInfo(List<EngineerInfo> engineers, HashMap<String, String> groups) { private List<EngineerInfoListResp.EngineerInfo> packEngineerInfo(List<EngineerInfo> engineers, HashMap<String, String> groups) {
String groupName, age, workType; String groupName, age, workType;
......
...@@ -40,7 +40,7 @@ public class OrderServiceListServiceImpl implements OrderServiceListService { ...@@ -40,7 +40,7 @@ public class OrderServiceListServiceImpl implements OrderServiceListService {
String skill) throws BusinessException { String skill) throws BusinessException {
//分页 //分页
IPage<OrderRequest> pg = new Page(page, size); Page<OrderRequest> pg = new Page(page, size);
LambdaQueryWrapper<OrderRequest> lqw = new LambdaQueryWrapper<>(); LambdaQueryWrapper<OrderRequest> lqw = new LambdaQueryWrapper<>();
lqw.ge(OrderRequest::getExpectTimeBegin, this.getTimestampFromDate(startDate)); //预约开始日期 lqw.ge(OrderRequest::getExpectTimeBegin, this.getTimestampFromDate(startDate)); //预约开始日期
...@@ -108,7 +108,7 @@ public class OrderServiceListServiceImpl implements OrderServiceListService { ...@@ -108,7 +108,7 @@ public class OrderServiceListServiceImpl implements OrderServiceListService {
public List<OrderAppointment> getOrderAppointments(List<String> orderIds) { public List<OrderAppointment> getOrderAppointments(List<String> orderIds) {
// 获取指派单列表 // 获取指派单列表
if(CollectionUtil.isEmpty(orderIds)) { if(CollectionUtil.isEmpty(orderIds)) {
return new ArrayList<OrderAppointment>(); return new ArrayList<>();
} }
LambdaQueryWrapper<OrderAppointment> lqw = new LambdaQueryWrapper<>(); LambdaQueryWrapper<OrderAppointment> lqw = new LambdaQueryWrapper<>();
lqw.in(OrderAppointment::getOrderId, orderIds); lqw.in(OrderAppointment::getOrderId, orderIds);
...@@ -118,7 +118,7 @@ public class OrderServiceListServiceImpl implements OrderServiceListService { ...@@ -118,7 +118,7 @@ public class OrderServiceListServiceImpl implements OrderServiceListService {
public HashMap<String, List<String>> getEngineerNames(List<OrderAppointment> orders){ public HashMap<String, List<String>> getEngineerNames(List<OrderAppointment> orders){
// 获取orderId最新订单对应的工程师姓名列表 // 获取orderId最新订单对应的工程师姓名列表
HashMap<String, List<String>> enginnerNames = new HashMap<>(); HashMap<String, List<String>> engineerNames = new HashMap<>();
Map<String, List<OrderAppointment>> g =this.groupOrderAppointments(orders); Map<String, List<OrderAppointment>> g =this.groupOrderAppointments(orders);
for(String orderId: g.keySet()) { for(String orderId: g.keySet()) {
...@@ -126,9 +126,9 @@ public class OrderServiceListServiceImpl implements OrderServiceListService { ...@@ -126,9 +126,9 @@ public class OrderServiceListServiceImpl implements OrderServiceListService {
for(OrderAppointment o: g.get(orderId)) { for(OrderAppointment o: g.get(orderId)) {
names.add(o.getEngineerName()); names.add(o.getEngineerName());
} }
enginnerNames.put(orderId, names); engineerNames.put(orderId, names);
} }
return enginnerNames; return engineerNames;
} }
public Map<String, List<OrderAppointment>> groupOrderAppointments(List<OrderAppointment> orders){ public Map<String, List<OrderAppointment>> groupOrderAppointments(List<OrderAppointment> orders){
...@@ -145,13 +145,13 @@ public class OrderServiceListServiceImpl implements OrderServiceListService { ...@@ -145,13 +145,13 @@ public class OrderServiceListServiceImpl implements OrderServiceListService {
String subOrderId = ""; String subOrderId = "";
List<OrderAppointment> items = new ArrayList<>(); List<OrderAppointment> items = new ArrayList<>();
for (OrderAppointment o: results) { for (OrderAppointment o: results) {
if (orderId != o.getOrderId()) { if (!orderId.equals(o.getOrderId())) {
orderId = o.getOrderId(); orderId = o.getOrderId();
subOrderId = o.getSuborderId(); subOrderId = o.getSuborderId();
items.add(o); items.add(o);
continue; continue;
} }
if (subOrderId == o.getSuborderId()) { if (subOrderId.equals(o.getSuborderId())) {
items.add(o); items.add(o);
} }
} }
...@@ -179,7 +179,7 @@ public class OrderServiceListServiceImpl implements OrderServiceListService { ...@@ -179,7 +179,7 @@ public class OrderServiceListServiceImpl implements OrderServiceListService {
} }
private String Timestamp2Datetime(Timestamp t) { private String Timestamp2Datetime(Timestamp t) {
DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-mm-dd HH:MM:SS"); DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
return df.format(t.toLocalDateTime()); return df.format(t.toLocalDateTime());
} }
} }
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!