|
@@ -1,6 +1,7 @@
|
|
|
package com.gree.mall.manager.logic.workorder;
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
+import cn.hutool.core.convert.Convert;
|
|
|
import cn.hutool.core.date.DateTime;
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
import com.google.common.collect.Lists;
|
|
@@ -23,6 +24,7 @@ import com.gree.mall.manager.logic.common.SysDictCompanyLogic;
|
|
|
import com.gree.mall.manager.plus.entity.*;
|
|
|
import com.gree.mall.manager.plus.service.*;
|
|
|
import com.gree.mall.manager.utils.CommonUtils;
|
|
|
+import com.gree.mall.manager.utils.StringUtil;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
@@ -64,14 +66,16 @@ public class OrderBaseExcelLogic {
|
|
|
private final RegionService regionService;
|
|
|
private final WebsitUserService websitUserService;
|
|
|
private final PgOrderProductDetailService pgOrderProductDetailService;
|
|
|
+ private final UserWaitService userWaitService;
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 导入工单
|
|
|
+ *
|
|
|
* @param rows
|
|
|
*/
|
|
|
@Transactional
|
|
|
- public void importOrder(List<Object> rows,String createWebsitId, String createWebsitName){
|
|
|
+ public void importOrder(List<Object> rows, String createWebsitId, String createWebsitName) {
|
|
|
AdminUserCom adminUser = commonLogic.getAdminUser();
|
|
|
//品牌map
|
|
|
Map<String, Brand> brandMap = sysDictCompanyLogic.brandMapOfName(adminUser.getCompanyWechatId());
|
|
@@ -79,7 +83,7 @@ public class OrderBaseExcelLogic {
|
|
|
Map<String, OrderSmallType> orderSmallTypeMap = sysDictCompanyLogic.orderSmallTypeMap(adminUser.getCompanyWechatId());
|
|
|
//产品大类,小类map
|
|
|
List<GoodsCategory> goodsCategoryList = goodsCategoryService.lambdaQuery()
|
|
|
- .eq(GoodsCategory::getCompanyWechatId,adminUser.getCompanyWechatId())
|
|
|
+ .eq(GoodsCategory::getCompanyWechatId, adminUser.getCompanyWechatId())
|
|
|
.eq(GoodsCategory::getType, 2).list();
|
|
|
Map<String, GoodsCategory> categoryMap1 = goodsCategoryList.stream().filter(v -> v.getLevel() == 1)
|
|
|
.collect(Collectors.toMap(GoodsCategory::getName, v -> v));
|
|
@@ -90,7 +94,7 @@ public class OrderBaseExcelLogic {
|
|
|
//网点名称
|
|
|
Map<String, AdminWebsit> adminWebsitMap = adminWebsitService.lambdaQuery()
|
|
|
.eq(AdminWebsit::getCompanyWechatId, adminUser.getCompanyWechatId())
|
|
|
- .in(adminUser.getType() == 0,AdminWebsit::getWebsitId,adminUser.getAdminWebsitIds())
|
|
|
+ .in(adminUser.getType() == 0, AdminWebsit::getWebsitId, adminUser.getAdminWebsitIds())
|
|
|
.eq(AdminWebsit::getType, AdminWebsitTypeEnum.C.getKey())
|
|
|
.list().stream().collect(Collectors.toMap(AdminWebsit::getName, Function.identity()));
|
|
|
//已完工标识
|
|
@@ -108,12 +112,12 @@ public class OrderBaseExcelLogic {
|
|
|
List<PgOrderProduct> pgOrderProducts = new ArrayList<>();
|
|
|
List<PgOrderWorker> pgOrderWorkers = new ArrayList<>();
|
|
|
int index = 0;
|
|
|
- for(Object o : rows){
|
|
|
+ for (Object o : rows) {
|
|
|
++index;
|
|
|
- String errPrefix = "第"+(index)+"行 ";
|
|
|
+ String errPrefix = "第" + (index) + "行 ";
|
|
|
OrderBaseStatusEnum orderBaseStatusEnum = OrderBaseStatusEnum.DSHPG;
|
|
|
- List<String> row = (List<String>)o;
|
|
|
- CommonUtils.initList(row,100);
|
|
|
+ List<String> row = (List<String>) o;
|
|
|
+ CommonUtils.initList(row, 100);
|
|
|
String websitName = row.get(0);
|
|
|
String orderBaseId = row.get(1);
|
|
|
String source = row.get(2);
|
|
@@ -132,28 +136,28 @@ public class OrderBaseExcelLogic {
|
|
|
String isQdText = row.get(15);
|
|
|
String remark = row.get(16);
|
|
|
|
|
|
- Boolean isQd = StringUtils.equals(isQdText,"是");
|
|
|
+ Boolean isQd = StringUtils.equals(isQdText, "是");
|
|
|
|
|
|
- if(StringUtils.isAnyBlank(orderBaseId,source,orderSmallType,source,userName,linkName,userMobile,address,createTime)){
|
|
|
- throw new RemoteServiceException(errPrefix+"黄色区域为必填项");
|
|
|
+ if (StringUtils.isAnyBlank(orderBaseId, source, orderSmallType, source, userName, linkName, userMobile, address, createTime)) {
|
|
|
+ throw new RemoteServiceException(errPrefix + "黄色区域为必填项");
|
|
|
}
|
|
|
- if(userMobile.length() > 11){
|
|
|
- throw new RemoteServiceException(errPrefix+"请输入正确的客户手机号");
|
|
|
+ if (userMobile.length() > 11) {
|
|
|
+ throw new RemoteServiceException(errPrefix + "请输入正确的客户手机号");
|
|
|
}
|
|
|
- if(StringUtils.isNotBlank(userMobile2) && userMobile2.length() > 11){
|
|
|
- throw new RemoteServiceException(errPrefix+"请输入正确的客户手机号2");
|
|
|
+ if (StringUtils.isNotBlank(userMobile2) && userMobile2.length() > 11) {
|
|
|
+ throw new RemoteServiceException(errPrefix + "请输入正确的客户手机号2");
|
|
|
}
|
|
|
oldOrderBaseIds.add(orderBaseId);
|
|
|
|
|
|
String location = lbsAmapLogic.getLocationByAddress(address);
|
|
|
RegionBean regionBean = lbsAmapLogic.getRegionByLngLat(location);
|
|
|
Region region = orderBaseLogic.getRegion(regionBean.getProvinceName(), regionBean.getCityName(), regionBean.getAreaName(), regionBean.getName());
|
|
|
- if(region == null){
|
|
|
+ if (region == null) {
|
|
|
//throw new RemoteServiceException(errPrefix+"地址【"+address+"】解析失败");
|
|
|
region = regionService.lambdaQuery()
|
|
|
- .eq(Region::getCityName,"广州市")
|
|
|
- .eq(Region::getAreaName,"天河区")
|
|
|
- .eq(Region::getName,"五山街道")
|
|
|
+ .eq(Region::getCityName, "广州市")
|
|
|
+ .eq(Region::getAreaName, "天河区")
|
|
|
+ .eq(Region::getName, "五山街道")
|
|
|
.last("limit 1").one();
|
|
|
location = "0,0";
|
|
|
}
|
|
@@ -164,49 +168,49 @@ public class OrderBaseExcelLogic {
|
|
|
if (dateTime == null) {
|
|
|
throw new RemoteServiceException(errPrefix + "创建时间请输入【2023-12-28 00:00:00】的格式");
|
|
|
}
|
|
|
- }catch(Exception e){
|
|
|
+ } catch (Exception e) {
|
|
|
throw new RemoteServiceException(errPrefix + "创建时间请输入【2023-12-28 00:00:00】的格式");
|
|
|
}
|
|
|
|
|
|
AdminWebsit adminWebsit = null;
|
|
|
- if(StringUtils.isNotBlank(websitName)){
|
|
|
+ if (StringUtils.isNotBlank(websitName)) {
|
|
|
adminWebsit = adminWebsitMap.get(websitName);
|
|
|
- if(adminWebsit == null){
|
|
|
- throw new RemoteServiceException(errPrefix+"网点名称不存在");
|
|
|
+ if (adminWebsit == null) {
|
|
|
+ throw new RemoteServiceException(errPrefix + "网点名称不存在");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
Boolean addFlag = true;
|
|
|
PgOrderBase old = oldOrderBaseMap.get(orderBaseId);
|
|
|
- if(old != null){
|
|
|
+ if (old != null) {
|
|
|
//throw new RemoteServiceException(errPrefix+"工单号已存在");
|
|
|
addFlag = false;
|
|
|
|
|
|
- if(OrderBaseStatusEnum.isOver().contains(old.getOrderStatus())){
|
|
|
- throw new RemoteServiceException(errPrefix+"工单号【"+orderBaseId+"】当前工单状态不可编辑");
|
|
|
+ if (OrderBaseStatusEnum.isOver().contains(old.getOrderStatus())) {
|
|
|
+ throw new RemoteServiceException(errPrefix + "工单号【" + orderBaseId + "】当前工单状态不可编辑");
|
|
|
}
|
|
|
}
|
|
|
OrderSmallType orderSmallType1 = orderSmallTypeMap.get(orderSmallType);
|
|
|
- if(orderSmallType1 == null){
|
|
|
- throw new RemoteServiceException(errPrefix+"工单类型不存在");
|
|
|
+ if (orderSmallType1 == null) {
|
|
|
+ throw new RemoteServiceException(errPrefix + "工单类型不存在");
|
|
|
}
|
|
|
SysDictCompany orderChannelDict = orderChannelMap.get(orderChannel);
|
|
|
- if(orderChannelDict == null){
|
|
|
- throw new RemoteServiceException(errPrefix+"工单渠道不存在");
|
|
|
+ if (orderChannelDict == null) {
|
|
|
+ throw new RemoteServiceException(errPrefix + "工单渠道不存在");
|
|
|
}
|
|
|
|
|
|
//工单状态
|
|
|
OrderBaseStatusEnum importBaseStatusEnum = null;
|
|
|
- if(StringUtils.isNotBlank(orderStatus)){
|
|
|
- importBaseStatusEnum = BaseEnum.valueToEnum(OrderBaseStatusEnum.class,orderStatus);
|
|
|
- if(importBaseStatusEnum == null){
|
|
|
- throw new RemoteServiceException(errPrefix+"工单状态不存在");
|
|
|
+ if (StringUtils.isNotBlank(orderStatus)) {
|
|
|
+ importBaseStatusEnum = BaseEnum.valueToEnum(OrderBaseStatusEnum.class, orderStatus);
|
|
|
+ if (importBaseStatusEnum == null) {
|
|
|
+ throw new RemoteServiceException(errPrefix + "工单状态不存在");
|
|
|
}
|
|
|
//如果已完工,师傅和网点不能为空
|
|
|
- if(OrderBaseStatusEnum.isOver().contains(importBaseStatusEnum.getKey())){
|
|
|
+ if (OrderBaseStatusEnum.isOver().contains(importBaseStatusEnum.getKey())) {
|
|
|
|
|
|
- if(StringUtils.isBlank(workerMobile) || StringUtils.isBlank(websitName)){
|
|
|
- throw new RemoteServiceException(errPrefix+"完工状态师傅和网点不能为空");
|
|
|
+ if (StringUtils.isBlank(workerMobile) || StringUtils.isBlank(websitName)) {
|
|
|
+ throw new RemoteServiceException(errPrefix + "完工状态师傅和网点不能为空");
|
|
|
}
|
|
|
overOrderIds.add(orderBaseId);
|
|
|
}
|
|
@@ -217,14 +221,14 @@ public class OrderBaseExcelLogic {
|
|
|
pgOrderBase.setId(orderBaseId);
|
|
|
pgOrderBase.setIsImport(true);
|
|
|
pgOrderBase.setOrderType(orderSmallType1.getOrderType());
|
|
|
- pgOrderBase.setOrderTypeText(BaseEnum.keyToEnum(OrderTypeEnum.class,orderSmallType1.getOrderType()).getRemark());
|
|
|
+ pgOrderBase.setOrderTypeText(BaseEnum.keyToEnum(OrderTypeEnum.class, orderSmallType1.getOrderType()).getRemark());
|
|
|
pgOrderBase.setOrderSmallType(orderSmallType1.getId());
|
|
|
pgOrderBase.setOrderSmallTypeText(orderSmallType1.getOrderSmallTypeText());
|
|
|
pgOrderBase.setCompanyWechatId(adminUser.getCompanyWechatId());
|
|
|
pgOrderBase.setCompanyWechatName(adminUser.getCompanyName());
|
|
|
- if(adminWebsit != null){
|
|
|
+ if (adminWebsit != null) {
|
|
|
orderBaseStatusEnum = OrderBaseStatusEnum.DWDPG;
|
|
|
- if(isQd){
|
|
|
+ if (isQd) {
|
|
|
orderBaseStatusEnum = OrderBaseStatusEnum.DQD;
|
|
|
}
|
|
|
|
|
@@ -236,15 +240,15 @@ public class OrderBaseExcelLogic {
|
|
|
|
|
|
//是否派对了师傅
|
|
|
User worker = null;
|
|
|
- if(StringUtils.isNotBlank(workerMobile)){
|
|
|
+ if (StringUtils.isNotBlank(workerMobile)) {
|
|
|
|
|
|
int workerIndex = 0;
|
|
|
String[] workerMobiles = StringUtils.split(workerMobile, ",");
|
|
|
long count1 = Lists.newArrayList(workerMobiles).stream().distinct().count();
|
|
|
- if(count1 != workerMobiles.length){
|
|
|
+ if (count1 != workerMobiles.length) {
|
|
|
throw new RemoteServiceException(errPrefix + "师傅手机号不可重复");
|
|
|
}
|
|
|
- for(String mobile : workerMobiles) {
|
|
|
+ for (String mobile : workerMobiles) {
|
|
|
worker = workerMap.get(mobile);
|
|
|
if (worker == null) {
|
|
|
throw new RemoteServiceException(errPrefix + " 师傅手机号【" + mobile + "】不存在网点【" + adminWebsit.getName() + "】");
|
|
@@ -259,7 +263,7 @@ public class OrderBaseExcelLogic {
|
|
|
|
|
|
orderBaseStatusEnum = OrderBaseStatusEnum.DJD;
|
|
|
|
|
|
- if(workerIndex == 0) {
|
|
|
+ if (workerIndex == 0) {
|
|
|
pgOrderBase.setWorkerId(worker.getUserId());
|
|
|
pgOrderBase.setWorkerIdcard(worker.getIdCard());
|
|
|
pgOrderBase.setWorkerIdList(worker.getUserId());
|
|
@@ -288,7 +292,7 @@ public class OrderBaseExcelLogic {
|
|
|
|
|
|
pgOrderBase.setOrderStatus(orderBaseStatusEnum.getKey());
|
|
|
pgOrderBase.setOrderStatusText(orderBaseStatusEnum.getRemark());
|
|
|
- if(OrderBaseStatusEnum.isOver().contains(pgOrderBase.getOrderStatus())){
|
|
|
+ if (OrderBaseStatusEnum.isOver().contains(pgOrderBase.getOrderStatus())) {
|
|
|
pgOrderBase.setOverTime(new Date());
|
|
|
pgOrderBase.setOverDate(new Date());
|
|
|
pgOrderBase.setWebsitOverTime(new Date());
|
|
@@ -311,7 +315,7 @@ public class OrderBaseExcelLogic {
|
|
|
try {
|
|
|
pgOrderBase.setLng(location.split(",")[0]);
|
|
|
pgOrderBase.setLat(location.split(",")[1]);
|
|
|
- }catch(Exception e){
|
|
|
+ } catch (Exception e) {
|
|
|
pgOrderBase.setLng("0");
|
|
|
pgOrderBase.setLat("0");
|
|
|
}
|
|
@@ -323,7 +327,7 @@ public class OrderBaseExcelLogic {
|
|
|
pgOrderBase.setOrderChannelText(orderChannelDict.getDictValue());
|
|
|
pgOrderBase.setCreateWebsitId(createWebsitId);
|
|
|
pgOrderBase.setCreateWebsitName(createWebsitName);
|
|
|
- if(importBaseStatusEnum != null){
|
|
|
+ if (importBaseStatusEnum != null) {
|
|
|
pgOrderBase.setOrderStatus(importBaseStatusEnum.getKey());
|
|
|
pgOrderBase.setOrderStatusText(importBaseStatusEnum.getRemark());
|
|
|
}
|
|
@@ -344,32 +348,32 @@ public class OrderBaseExcelLogic {
|
|
|
//orderBaseLogic.upOrderProduct(pgOrderBase.getId());
|
|
|
|
|
|
//生成待结算数据
|
|
|
- if(OrderBaseStatusEnum.isOver().contains(pgOrderBase.getOrderStatus())){
|
|
|
- if(old == null || !OrderBaseStatusEnum.isOver().contains(old.getOrderStatus())) {
|
|
|
+ if (OrderBaseStatusEnum.isOver().contains(pgOrderBase.getOrderStatus())) {
|
|
|
+ if (old == null || !OrderBaseStatusEnum.isOver().contains(old.getOrderStatus())) {
|
|
|
//生成待结算数据
|
|
|
settleOrderLogic.insertSettleOrderMethod(pgOrderBase, pgOrderProducts);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//保存日志
|
|
|
- if(addFlag) {
|
|
|
+ if (addFlag) {
|
|
|
addPgOrderBase.add(pgOrderBase);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//生成完工标识数据
|
|
|
- if(CollectionUtils.isNotEmpty(overOrderIds)) {
|
|
|
+ if (CollectionUtils.isNotEmpty(overOrderIds)) {
|
|
|
orderFlagLogic.saveOrderFlag(overOrderIds, OrderFlagEnum.YWG);
|
|
|
}
|
|
|
//生成师傅信息
|
|
|
- if(CollectionUtils.isNotEmpty(pgOrderWorkers)){
|
|
|
+ if (CollectionUtils.isNotEmpty(pgOrderWorkers)) {
|
|
|
pgOrderWorkerService.saveBatch(pgOrderWorkers);
|
|
|
}
|
|
|
//重新生成产品信息和待采集数据
|
|
|
doProductDetail(pgOrderProducts, oldOrderBaseIds);
|
|
|
//创建工单添加消息
|
|
|
- if(CollectionUtils.isNotEmpty(addPgOrderBase)){
|
|
|
- for(PgOrderBase pgOrderBase : addPgOrderBase){
|
|
|
+ if (CollectionUtils.isNotEmpty(addPgOrderBase)) {
|
|
|
+ for (PgOrderBase pgOrderBase : addPgOrderBase) {
|
|
|
orderBaseLogic.sendMaterialExamine(pgOrderBase.getId());
|
|
|
orderBaseLogic.addLog(pgOrderBase, pgOrderBase.getCreateWebsitName());
|
|
|
}
|
|
@@ -377,39 +381,38 @@ public class OrderBaseExcelLogic {
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
- private List<PgOrderProduct> importOrderProduct(List<String> row,String orderBaseId,int index,Map<String,Brand> brandMap,Map<String,GoodsCategory> mainMap,Map<String,GoodsCategory> smallMap){
|
|
|
+ private List<PgOrderProduct> importOrderProduct(List<String> row, String orderBaseId, int index, Map<String, Brand> brandMap, Map<String, GoodsCategory> mainMap, Map<String, GoodsCategory> smallMap) {
|
|
|
// pgOrderProductService.lambdaUpdate().eq(PgOrderProduct::getOrderBaseId,orderBaseId).remove();
|
|
|
// //删除旧的待采集数据
|
|
|
// pgOrderProductDetailService.lambdaUpdate().eq(PgOrderProductDetail::getOrderBaseId,orderBaseId).remove();
|
|
|
|
|
|
List<PgOrderProduct> pgOrderProducts = new ArrayList<>();
|
|
|
//默认最多10个机型
|
|
|
- for(int i = 0;i < 10; i++){
|
|
|
+ for (int i = 0; i < 10; i++) {
|
|
|
String brandName = row.get(6 * i + 17);
|
|
|
String mainName = row.get(6 * i + 18);
|
|
|
String smallName = row.get(6 * i + 19);
|
|
|
String productName = row.get(6 * i + 20);
|
|
|
String productNum = row.get(6 * i + 21);
|
|
|
String remark = row.get(6 * i + 22);
|
|
|
- if(StringUtils.isBlank(brandName)){
|
|
|
+ if (StringUtils.isBlank(brandName)) {
|
|
|
continue;
|
|
|
}
|
|
|
- if(StringUtils.isAnyBlank(mainName,smallName,productNum)){
|
|
|
- throw new RemoteServiceException("第"+(index)+"行 产品大类/产品小类/商品数量 不能为空");
|
|
|
+ if (StringUtils.isAnyBlank(mainName, smallName, productNum)) {
|
|
|
+ throw new RemoteServiceException("第" + (index) + "行 产品大类/产品小类/商品数量 不能为空");
|
|
|
}
|
|
|
|
|
|
GoodsCategory mainGoodsCategory = mainMap.get(mainName);
|
|
|
GoodsCategory smallGoodsCategory = smallMap.get(smallName);
|
|
|
Brand brand = brandMap.get(brandName);
|
|
|
- if(brand == null){
|
|
|
- throw new RemoteServiceException("第"+(index)+"行 品牌不存在");
|
|
|
+ if (brand == null) {
|
|
|
+ throw new RemoteServiceException("第" + (index) + "行 品牌不存在");
|
|
|
}
|
|
|
- if(mainGoodsCategory == null){
|
|
|
- throw new RemoteServiceException("第"+(index)+"行 产品大类不存在");
|
|
|
+ if (mainGoodsCategory == null) {
|
|
|
+ throw new RemoteServiceException("第" + (index) + "行 产品大类不存在");
|
|
|
}
|
|
|
- if(smallGoodsCategory == null){
|
|
|
- throw new RemoteServiceException("第"+(index)+"行 产品小类不存在");
|
|
|
+ if (smallGoodsCategory == null) {
|
|
|
+ throw new RemoteServiceException("第" + (index) + "行 产品小类不存在");
|
|
|
}
|
|
|
|
|
|
PgOrderProduct pgOrderProduct = new PgOrderProduct();
|
|
@@ -431,9 +434,10 @@ public class OrderBaseExcelLogic {
|
|
|
|
|
|
/**
|
|
|
* 导入工单2
|
|
|
+ *
|
|
|
* @param rows
|
|
|
*/
|
|
|
- public void importOrder2(List<Object> rows,String createWebsitId, String createWebsitName){
|
|
|
+ public void importOrder2(List<Object> rows, String createWebsitId, String createWebsitName) {
|
|
|
AdminUserCom adminUser = commonLogic.getAdminUser();
|
|
|
//品牌map
|
|
|
Map<String, Brand> brandMap = sysDictCompanyLogic.brandMapOfName(adminUser.getCompanyWechatId());
|
|
@@ -441,7 +445,7 @@ public class OrderBaseExcelLogic {
|
|
|
Map<String, OrderSmallType> orderSmallTypeMap = sysDictCompanyLogic.orderSmallTypeMap(adminUser.getCompanyWechatId());
|
|
|
//产品大类,小类map
|
|
|
List<GoodsCategory> goodsCategoryList = goodsCategoryService.lambdaQuery()
|
|
|
- .eq(GoodsCategory::getCompanyWechatId,adminUser.getCompanyWechatId())
|
|
|
+ .eq(GoodsCategory::getCompanyWechatId, adminUser.getCompanyWechatId())
|
|
|
.eq(GoodsCategory::getType, 2).list();
|
|
|
Map<String, GoodsCategory> mainMap = goodsCategoryList.stream().filter(v -> v.getLevel() == 1)
|
|
|
.collect(Collectors.toMap(GoodsCategory::getName, v -> v));
|
|
@@ -452,7 +456,7 @@ public class OrderBaseExcelLogic {
|
|
|
//网点名称
|
|
|
Map<String, AdminWebsit> adminWebsitMap = adminWebsitService.lambdaQuery()
|
|
|
.eq(AdminWebsit::getCompanyWechatId, adminUser.getCompanyWechatId())
|
|
|
- .in(adminUser.getType() == 0,AdminWebsit::getWebsitId,adminUser.getAdminWebsitIds())
|
|
|
+ .in(adminUser.getType() == 0, AdminWebsit::getWebsitId, adminUser.getAdminWebsitIds())
|
|
|
.eq(AdminWebsit::getType, AdminWebsitTypeEnum.C.getKey())
|
|
|
.list().stream().collect(Collectors.toMap(AdminWebsit::getName, Function.identity()));
|
|
|
//完工的工单集合
|
|
@@ -470,12 +474,12 @@ public class OrderBaseExcelLogic {
|
|
|
List<PgOrderWorker> pgOrderWorkers = new ArrayList<>();
|
|
|
|
|
|
int index = 0;
|
|
|
- for(Object o : rows){
|
|
|
+ for (Object o : rows) {
|
|
|
++index;
|
|
|
- String errPrefix = "第"+(index)+"行 ";
|
|
|
+ String errPrefix = "第" + (index) + "行 ";
|
|
|
OrderBaseStatusEnum orderBaseStatusEnum = OrderBaseStatusEnum.DSHPG;
|
|
|
- List<String> row = (List<String>)o;
|
|
|
- CommonUtils.initList(row,100);
|
|
|
+ List<String> row = (List<String>) o;
|
|
|
+ CommonUtils.initList(row, 100);
|
|
|
String websitName = row.get(0);
|
|
|
String orderChannel = row.get(1);
|
|
|
String orderBaseId = row.get(2);
|
|
@@ -492,17 +496,17 @@ public class OrderBaseExcelLogic {
|
|
|
String orderSmallType = row.get(13);
|
|
|
String brandName = row.get(14);
|
|
|
Integer num = StringUtils.isBlank(row.get(15)) ? 1 : Integer.parseInt(row.get(15));
|
|
|
- BigDecimal amount = StringUtils.isBlank(row.get(16))? BigDecimal.ZERO : new BigDecimal(row.get(16));
|
|
|
+ BigDecimal amount = StringUtils.isBlank(row.get(16)) ? BigDecimal.ZERO : new BigDecimal(row.get(16));
|
|
|
|
|
|
- if(StringUtils.isAnyBlank(orderBaseId,orderChannel,userName,userMobile,address,mainName,smallName,productName,orderSmallType,brandName)){
|
|
|
- throw new RemoteServiceException(errPrefix+"黄色区域为必填项");
|
|
|
+ if (StringUtils.isAnyBlank(orderBaseId, orderChannel, userName, userMobile, address, mainName, smallName, productName, orderSmallType, brandName)) {
|
|
|
+ throw new RemoteServiceException(errPrefix + "黄色区域为必填项");
|
|
|
}
|
|
|
|
|
|
- if(userMobile.length() > 11){
|
|
|
- throw new RemoteServiceException(errPrefix+"请输入正确的客户手机号");
|
|
|
+ if (userMobile.length() > 11) {
|
|
|
+ throw new RemoteServiceException(errPrefix + "请输入正确的客户手机号");
|
|
|
}
|
|
|
- if(StringUtils.isNotBlank(userMobile2) && userMobile2.length() > 11){
|
|
|
- throw new RemoteServiceException(errPrefix+"请输入正确的客户手机号2");
|
|
|
+ if (StringUtils.isNotBlank(userMobile2) && userMobile2.length() > 11) {
|
|
|
+ throw new RemoteServiceException(errPrefix + "请输入正确的客户手机号2");
|
|
|
}
|
|
|
|
|
|
oldOrderBaseIds.add(orderBaseId);
|
|
@@ -510,53 +514,53 @@ public class OrderBaseExcelLogic {
|
|
|
String location = lbsAmapLogic.getLocationByAddress(address);
|
|
|
RegionBean regionBean = lbsAmapLogic.getRegionByLngLat(location);
|
|
|
Region region = orderBaseLogic.getRegion(regionBean.getProvinceName(), regionBean.getCityName(), regionBean.getAreaName(), regionBean.getName());
|
|
|
- if(region == null){
|
|
|
+ if (region == null) {
|
|
|
//throw new RemoteServiceException(errPrefix+"地址【"+address+"】解析失败");
|
|
|
region = regionService.lambdaQuery()
|
|
|
- .eq(Region::getCityName,"广州市")
|
|
|
- .eq(Region::getAreaName,"天河区")
|
|
|
- .eq(Region::getName,"五山街道")
|
|
|
+ .eq(Region::getCityName, "广州市")
|
|
|
+ .eq(Region::getAreaName, "天河区")
|
|
|
+ .eq(Region::getName, "五山街道")
|
|
|
.last("limit 1").one();
|
|
|
location = "0,0";
|
|
|
}
|
|
|
|
|
|
AdminWebsit adminWebsit = null;
|
|
|
- if(StringUtils.isNotBlank(websitName)){
|
|
|
+ if (StringUtils.isNotBlank(websitName)) {
|
|
|
adminWebsit = adminWebsitMap.get(websitName);
|
|
|
- if(adminWebsit == null){
|
|
|
- throw new RemoteServiceException(errPrefix+"网点名称不存在");
|
|
|
+ if (adminWebsit == null) {
|
|
|
+ throw new RemoteServiceException(errPrefix + "网点名称不存在");
|
|
|
}
|
|
|
}
|
|
|
Boolean addFlag = true;
|
|
|
- PgOrderBase old = oldOrderBaseMap.get(orderBaseId);
|
|
|
- if(old != null){
|
|
|
+ PgOrderBase old = oldOrderBaseMap.get(orderBaseId);
|
|
|
+ if (old != null) {
|
|
|
addFlag = false;
|
|
|
|
|
|
- if(OrderBaseStatusEnum.isOver().contains(old.getOrderStatus())){
|
|
|
- throw new RemoteServiceException(errPrefix+"工单号【"+orderBaseId+"】当前工单状态不可编辑");
|
|
|
+ if (OrderBaseStatusEnum.isOver().contains(old.getOrderStatus())) {
|
|
|
+ throw new RemoteServiceException(errPrefix + "工单号【" + orderBaseId + "】当前工单状态不可编辑");
|
|
|
}
|
|
|
}
|
|
|
OrderSmallType orderSmallType1 = orderSmallTypeMap.get(orderSmallType);
|
|
|
- if(orderSmallType1 == null){
|
|
|
- throw new RemoteServiceException(errPrefix+"工单类型不存在");
|
|
|
+ if (orderSmallType1 == null) {
|
|
|
+ throw new RemoteServiceException(errPrefix + "工单类型不存在");
|
|
|
}
|
|
|
SysDictCompany orderChannelDict = orderChannelMap.get(orderChannel);
|
|
|
- if(orderChannelDict == null){
|
|
|
- throw new RemoteServiceException(errPrefix+"工单渠道不存在");
|
|
|
+ if (orderChannelDict == null) {
|
|
|
+ throw new RemoteServiceException(errPrefix + "工单渠道不存在");
|
|
|
}
|
|
|
|
|
|
//工单状态
|
|
|
OrderBaseStatusEnum importBaseStatusEnum = null;
|
|
|
- if(StringUtils.isNotBlank(orderStatus)){
|
|
|
- importBaseStatusEnum = BaseEnum.valueToEnum(OrderBaseStatusEnum.class,orderStatus);
|
|
|
- if(importBaseStatusEnum == null){
|
|
|
- throw new RemoteServiceException(errPrefix+"工单状态不存在");
|
|
|
+ if (StringUtils.isNotBlank(orderStatus)) {
|
|
|
+ importBaseStatusEnum = BaseEnum.valueToEnum(OrderBaseStatusEnum.class, orderStatus);
|
|
|
+ if (importBaseStatusEnum == null) {
|
|
|
+ throw new RemoteServiceException(errPrefix + "工单状态不存在");
|
|
|
}
|
|
|
//如果已完工,师傅和网点不能为空
|
|
|
- if(OrderBaseStatusEnum.isOver().contains(importBaseStatusEnum.getKey())){
|
|
|
+ if (OrderBaseStatusEnum.isOver().contains(importBaseStatusEnum.getKey())) {
|
|
|
|
|
|
- if(StringUtils.isBlank(workerMobile) || StringUtils.isBlank(websitName)){
|
|
|
- throw new RemoteServiceException(errPrefix+"完工状态师傅和网点不能为空");
|
|
|
+ if (StringUtils.isBlank(workerMobile) || StringUtils.isBlank(websitName)) {
|
|
|
+ throw new RemoteServiceException(errPrefix + "完工状态师傅和网点不能为空");
|
|
|
}
|
|
|
|
|
|
orderFlagLogic.saveOrderFlag(Lists.newArrayList(orderBaseId), OrderFlagEnum.YWG);
|
|
@@ -568,12 +572,12 @@ public class OrderBaseExcelLogic {
|
|
|
pgOrderBase.setId(orderBaseId);
|
|
|
pgOrderBase.setIsImport(true);
|
|
|
pgOrderBase.setOrderType(orderSmallType1.getOrderType());
|
|
|
- pgOrderBase.setOrderTypeText(BaseEnum.keyToEnum(OrderTypeEnum.class,orderSmallType1.getOrderType()).getRemark());
|
|
|
+ pgOrderBase.setOrderTypeText(BaseEnum.keyToEnum(OrderTypeEnum.class, orderSmallType1.getOrderType()).getRemark());
|
|
|
pgOrderBase.setOrderSmallType(orderSmallType1.getId());
|
|
|
pgOrderBase.setOrderSmallTypeText(orderSmallType1.getOrderSmallTypeText());
|
|
|
pgOrderBase.setCompanyWechatId(adminUser.getCompanyWechatId());
|
|
|
pgOrderBase.setCompanyWechatName(adminUser.getCompanyName());
|
|
|
- if(adminWebsit != null){
|
|
|
+ if (adminWebsit != null) {
|
|
|
orderBaseStatusEnum = OrderBaseStatusEnum.DWDPG;
|
|
|
|
|
|
|
|
@@ -584,15 +588,15 @@ public class OrderBaseExcelLogic {
|
|
|
|
|
|
//是否派对了师傅
|
|
|
User worker = null;
|
|
|
- if(StringUtils.isNotBlank(workerMobile)){
|
|
|
+ if (StringUtils.isNotBlank(workerMobile)) {
|
|
|
|
|
|
int workerIndex = 0;
|
|
|
String[] workerMobiles = StringUtils.split(workerMobile, ",");
|
|
|
long count1 = Lists.newArrayList(workerMobiles).stream().distinct().count();
|
|
|
- if(count1 != workerMobiles.length){
|
|
|
+ if (count1 != workerMobiles.length) {
|
|
|
throw new RemoteServiceException(errPrefix + "师傅手机号不可重复");
|
|
|
}
|
|
|
- for(String mobile : workerMobiles) {
|
|
|
+ for (String mobile : workerMobiles) {
|
|
|
worker = workerMap.get(mobile);
|
|
|
if (worker == null) {
|
|
|
throw new RemoteServiceException(errPrefix + " 师傅手机号【" + mobile + "】不存在网点【" + adminWebsit.getName() + "】");
|
|
@@ -607,7 +611,7 @@ public class OrderBaseExcelLogic {
|
|
|
|
|
|
orderBaseStatusEnum = OrderBaseStatusEnum.DJD;
|
|
|
|
|
|
- if(workerIndex == 0) {
|
|
|
+ if (workerIndex == 0) {
|
|
|
pgOrderBase.setWorkerId(worker.getUserId());
|
|
|
pgOrderBase.setWorkerIdcard(worker.getIdCard());
|
|
|
pgOrderBase.setWorkerIdList(worker.getUserId());
|
|
@@ -653,7 +657,7 @@ public class OrderBaseExcelLogic {
|
|
|
try {
|
|
|
pgOrderBase.setLng(location.split(",")[0]);
|
|
|
pgOrderBase.setLat(location.split(",")[1]);
|
|
|
- }catch(Exception e){
|
|
|
+ } catch (Exception e) {
|
|
|
pgOrderBase.setLng("0");
|
|
|
pgOrderBase.setLat("0");
|
|
|
}
|
|
@@ -664,11 +668,11 @@ public class OrderBaseExcelLogic {
|
|
|
pgOrderBase.setOrderChannelText(orderChannelDict.getDictValue());
|
|
|
pgOrderBase.setCreateWebsitId(createWebsitId);
|
|
|
pgOrderBase.setCreateWebsitName(createWebsitName);
|
|
|
- if(importBaseStatusEnum != null){
|
|
|
+ if (importBaseStatusEnum != null) {
|
|
|
pgOrderBase.setOrderStatus(importBaseStatusEnum.getKey());
|
|
|
pgOrderBase.setOrderStatusText(importBaseStatusEnum.getRemark());
|
|
|
}
|
|
|
- if(OrderBaseStatusEnum.isOver().contains(pgOrderBase.getOrderStatus())){
|
|
|
+ if (OrderBaseStatusEnum.isOver().contains(pgOrderBase.getOrderStatus())) {
|
|
|
pgOrderBase.setOverTime(new Date());
|
|
|
pgOrderBase.setOverDate(new Date());
|
|
|
pgOrderBase.setWebsitOverTime(new Date());
|
|
@@ -681,14 +685,14 @@ public class OrderBaseExcelLogic {
|
|
|
GoodsCategory mainGoodsCategory = mainMap.get(mainName);
|
|
|
GoodsCategory smallGoodsCategory = smallMap.get(smallName);
|
|
|
Brand brand = brandMap.get(brandName);
|
|
|
- if(brand == null){
|
|
|
- throw new RemoteServiceException("第"+(index)+"行 品牌不存在");
|
|
|
+ if (brand == null) {
|
|
|
+ throw new RemoteServiceException("第" + (index) + "行 品牌不存在");
|
|
|
}
|
|
|
- if(mainGoodsCategory == null){
|
|
|
- throw new RemoteServiceException("第"+(index)+"行 产品大类不存在");
|
|
|
+ if (mainGoodsCategory == null) {
|
|
|
+ throw new RemoteServiceException("第" + (index) + "行 产品大类不存在");
|
|
|
}
|
|
|
- if(smallGoodsCategory == null){
|
|
|
- throw new RemoteServiceException("第"+(index)+"行 产品小类不存在");
|
|
|
+ if (smallGoodsCategory == null) {
|
|
|
+ throw new RemoteServiceException("第" + (index) + "行 产品小类不存在");
|
|
|
}
|
|
|
PgOrderProduct pgOrderProduct = new PgOrderProduct();
|
|
|
pgOrderProduct.setOrderBaseId(orderBaseId);
|
|
@@ -709,7 +713,7 @@ public class OrderBaseExcelLogic {
|
|
|
pgOrderBase.setOrderTitle(orderBaseLogic.getOrderTitle(pgOrderProducts));
|
|
|
pgOrderBase.insertOrUpdate();
|
|
|
//保存日志
|
|
|
- if(addFlag) {
|
|
|
+ if (addFlag) {
|
|
|
//创建工单添加消息
|
|
|
// orderBaseLogic.sendMaterialExamine(pgOrderBase.getId());
|
|
|
// orderBaseLogic.addLog(pgOrderBase, pgOrderBase.getCreateWebsitName());
|
|
@@ -717,18 +721,18 @@ public class OrderBaseExcelLogic {
|
|
|
}
|
|
|
}
|
|
|
//生成完工标识数据
|
|
|
- if(CollectionUtils.isNotEmpty(overOrderIds)) {
|
|
|
+ if (CollectionUtils.isNotEmpty(overOrderIds)) {
|
|
|
orderFlagLogic.saveOrderFlag(overOrderIds, OrderFlagEnum.YWG);
|
|
|
}
|
|
|
//生成师傅信息
|
|
|
- if(CollectionUtils.isNotEmpty(pgOrderWorkers)){
|
|
|
+ if (CollectionUtils.isNotEmpty(pgOrderWorkers)) {
|
|
|
pgOrderWorkerService.saveBatch(pgOrderWorkers);
|
|
|
}
|
|
|
//重新生成产品信息和待采集数据
|
|
|
- doProductDetail(pgOrderProducts,oldOrderBaseIds);
|
|
|
+ doProductDetail(pgOrderProducts, oldOrderBaseIds);
|
|
|
//创建工单添加消息
|
|
|
- if(CollectionUtils.isNotEmpty(addPgOrderBase)){
|
|
|
- for(PgOrderBase pgOrderBase : addPgOrderBase){
|
|
|
+ if (CollectionUtils.isNotEmpty(addPgOrderBase)) {
|
|
|
+ for (PgOrderBase pgOrderBase : addPgOrderBase) {
|
|
|
orderBaseLogic.sendMaterialExamine(pgOrderBase.getId());
|
|
|
orderBaseLogic.addLog(pgOrderBase, pgOrderBase.getCreateWebsitName());
|
|
|
}
|
|
@@ -738,20 +742,21 @@ public class OrderBaseExcelLogic {
|
|
|
|
|
|
/**
|
|
|
* 获取旧的工单集
|
|
|
+ *
|
|
|
* @param rows
|
|
|
* @return
|
|
|
*/
|
|
|
- public Map<String, PgOrderBase> getOldOrderBase(List<Object> rows){
|
|
|
+ public Map<String, PgOrderBase> getOldOrderBase(List<Object> rows) {
|
|
|
List<String> orderBaseIds = new ArrayList<>();
|
|
|
//本次导入的所有工单号
|
|
|
- for(Object o : rows){
|
|
|
- List<String> row = (List<String>)o;
|
|
|
+ for (Object o : rows) {
|
|
|
+ List<String> row = (List<String>) o;
|
|
|
String orderBaseId = row.get(1);
|
|
|
orderBaseIds.add(orderBaseId);
|
|
|
}
|
|
|
|
|
|
//先清空师傅
|
|
|
- pgOrderWorkerService.lambdaUpdate().in(PgOrderWorker::getOrderBaseId,orderBaseIds).remove();
|
|
|
+ pgOrderWorkerService.lambdaUpdate().in(PgOrderWorker::getOrderBaseId, orderBaseIds).remove();
|
|
|
|
|
|
List<PgOrderBase> list = pgOrderBaseService.lambdaQuery().in(PgOrderBase::getId, orderBaseIds).list();
|
|
|
Map<String, PgOrderBase> oldOrderBaseMap = list.stream().collect(Collectors.toMap(v -> v.getId(), Function.identity()));
|
|
@@ -760,23 +765,24 @@ public class OrderBaseExcelLogic {
|
|
|
|
|
|
/**
|
|
|
* 获取旧的师傅集
|
|
|
+ *
|
|
|
* @param companyWechatId
|
|
|
* @return
|
|
|
*/
|
|
|
- public Map<String,User> getWorkers(String companyWechatId){
|
|
|
- List<User> workers = userService.lambdaQuery().eq(User::getCompanyWechatId, companyWechatId).ne(User::getMobile,"")
|
|
|
+ public Map<String, User> getWorkers(String companyWechatId) {
|
|
|
+ List<User> workers = userService.lambdaQuery().eq(User::getCompanyWechatId, companyWechatId).ne(User::getMobile, "")
|
|
|
.eq(User::getType, UserTypeEnum.WORKER.getKey()).list();
|
|
|
- Map<String, User> workerMap = workers.stream().collect(Collectors.toMap(v -> v.getMobile() , Function.identity()));
|
|
|
+ Map<String, User> workerMap = workers.stream().collect(Collectors.toMap(v -> v.getMobile(), Function.identity()));
|
|
|
return workerMap;
|
|
|
}
|
|
|
|
|
|
|
|
|
- private void doProductDetail(List<PgOrderProduct> pgOrderProducts,List<String> oldOrderBaseIds){
|
|
|
- if(CollectionUtils.isNotEmpty(pgOrderProducts)) {
|
|
|
+ private void doProductDetail(List<PgOrderProduct> pgOrderProducts, List<String> oldOrderBaseIds) {
|
|
|
+ if (CollectionUtils.isNotEmpty(pgOrderProducts)) {
|
|
|
//删除旧的产品数据
|
|
|
- pgOrderProductService.lambdaUpdate().in(PgOrderProduct::getOrderBaseId,oldOrderBaseIds).remove();
|
|
|
+ pgOrderProductService.lambdaUpdate().in(PgOrderProduct::getOrderBaseId, oldOrderBaseIds).remove();
|
|
|
//删除旧的待采集数据
|
|
|
- pgOrderProductDetailService.lambdaUpdate().in(PgOrderProductDetail::getOrderBaseId,oldOrderBaseIds).remove();
|
|
|
+ pgOrderProductDetailService.lambdaUpdate().in(PgOrderProductDetail::getOrderBaseId, oldOrderBaseIds).remove();
|
|
|
//生成新的产品数据
|
|
|
pgOrderProductService.saveBatch(pgOrderProducts);
|
|
|
//生成新的待采集数据
|
|
@@ -786,7 +792,7 @@ public class OrderBaseExcelLogic {
|
|
|
PgOrderProductDetail pgOrderProductDetail = BeanUtil.toBean(pgOrderProduct, PgOrderProductDetail.class);
|
|
|
pgOrderProductDetail.setId(null);
|
|
|
pgOrderProductDetail.setNum(1);
|
|
|
- pgOrderProductDetail.setSort(sort+1);
|
|
|
+ pgOrderProductDetail.setSort(sort + 1);
|
|
|
pgOrderProductDetail.setOrderProductId(pgOrderProduct.getId());
|
|
|
newProductDetail.add(pgOrderProductDetail);
|
|
|
sort++;
|
|
@@ -794,4 +800,306 @@ public class OrderBaseExcelLogic {
|
|
|
pgOrderProductDetailService.saveBatch(newProductDetail);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ public void import3(List<Object> rows) {
|
|
|
+
|
|
|
+ AdminUserCom adminUser = commonLogic.getAdminUser();
|
|
|
+ //品牌map
|
|
|
+ Map<String, Brand> brandMap = sysDictCompanyLogic.brandMapOfName(adminUser.getCompanyWechatId());
|
|
|
+ //工单类型map
|
|
|
+ Map<String, OrderSmallType> orderSmallTypeMap = sysDictCompanyLogic.orderSmallTypeMap(adminUser.getCompanyWechatId());
|
|
|
+ //产品大类,小类map
|
|
|
+ List<GoodsCategory> goodsCategoryList = goodsCategoryService.lambdaQuery()
|
|
|
+ .eq(GoodsCategory::getCompanyWechatId, adminUser.getCompanyWechatId())
|
|
|
+ .eq(GoodsCategory::getType, 2).list();
|
|
|
+ Map<String, GoodsCategory> categoryMap1 = goodsCategoryList.stream().filter(v -> v.getLevel() == 1)
|
|
|
+ .collect(Collectors.toMap(GoodsCategory::getName, v -> v));
|
|
|
+ Map<String, GoodsCategory> categoryMap2 = goodsCategoryList.stream().filter(v -> v.getLevel() == 2)
|
|
|
+ .collect(Collectors.toMap(GoodsCategory::getName, v -> v));
|
|
|
+ //工单渠道
|
|
|
+ Map<String, SysDictCompany> orderChannelMap = sysDictCompanyLogic.dictByTypeOfValue(SysDictConstant.ORDER_CHANNEL, adminUser.getCompanyWechatId());
|
|
|
+ //网点名称
|
|
|
+ Map<String, AdminWebsit> adminWebsitMap = adminWebsitService.lambdaQuery()
|
|
|
+ .eq(AdminWebsit::getCompanyWechatId, adminUser.getCompanyWechatId())
|
|
|
+ .in(adminUser.getType() == 0, AdminWebsit::getWebsitId, adminUser.getAdminWebsitIds())
|
|
|
+ .eq(AdminWebsit::getType, AdminWebsitTypeEnum.C.getKey())
|
|
|
+ .list().stream().collect(Collectors.toMap(AdminWebsit::getWebsitId, Function.identity()));
|
|
|
+ //已完工标识
|
|
|
+ List<String> overOrderIds = new ArrayList<>();
|
|
|
+
|
|
|
+ //本次导入的旧的工单集合 (并清空旧的师傅信息)
|
|
|
+ // Map<String, PgOrderBase> oldOrderBaseMap = getOldOrderBase(rows);
|
|
|
+ //本商户的所有师傅
|
|
|
+ Map<String, User> workerMap = getWorkers(adminUser.getCompanyWechatId());
|
|
|
+ //本次新增的工单
|
|
|
+ List<PgOrderBase> addPgOrderBase = new ArrayList<>();
|
|
|
+
|
|
|
+ //需要保存的集合
|
|
|
+ List<PgOrderProduct> pgOrderProducts = new ArrayList<>();
|
|
|
+ List<PgOrderWorker> pgOrderWorkers = new ArrayList<>();
|
|
|
+
|
|
|
+ int index = 0;
|
|
|
+ for (Object o : rows) {
|
|
|
+ ++index;
|
|
|
+ String errPrefix = "第" + (index) + "行 ";
|
|
|
+
|
|
|
+ List<String> row = (List<String>) o;
|
|
|
+
|
|
|
+ String pgOrderId = row.get(0);
|
|
|
+ String status = row.get(1);
|
|
|
+ String serviceStatus = row.get(2);
|
|
|
+ String orderType = row.get(3);
|
|
|
+ String categoryType = row.get(4);
|
|
|
+ String complaint = row.get(5);
|
|
|
+ String userName = row.get(6);
|
|
|
+ String userMobile = row.get(7);
|
|
|
+ String province = row.get(8);
|
|
|
+ String city = row.get(9);
|
|
|
+ String area = row.get(10);
|
|
|
+ String street = row.get(11);
|
|
|
+ String address = row.get(12);
|
|
|
+ String urgent = row.get(13);
|
|
|
+ String evaluate = row.get(14);
|
|
|
+ String source = row.get(15);
|
|
|
+ String salesSource = row.get(16);
|
|
|
+ String buyName = row.get(17);
|
|
|
+ String salesTypeName = row.get(18);
|
|
|
+ String totalNum = row.get(19);
|
|
|
+ String undoneNum = row.get(20);
|
|
|
+ String requirement = row.get(21);
|
|
|
+ String requirementType = row.get(22);
|
|
|
+ String requirementNotes = row.get(23);
|
|
|
+ String pSize = row.get(24);
|
|
|
+ String createWebsitName = row.get(25);
|
|
|
+ String createWebsitId = row.get(26);
|
|
|
+ String belongCompany = row.get(27);
|
|
|
+ String serviceOrderId = row.get(28);
|
|
|
+ String createTime = row.get(29);
|
|
|
+ String salesOrderId = row.get(30);
|
|
|
+ String appointmentTime = row.get(31);
|
|
|
+ String appointmentEndTime = row.get(32);
|
|
|
+ String overDate = row.get(33);
|
|
|
+ String websitId = row.get(34);
|
|
|
+ String websitName = row.get(35);
|
|
|
+ String workerId = row.get(36);
|
|
|
+ String workerName = row.get(37);
|
|
|
+ String managerGroup = row.get(38);
|
|
|
+ String operateEntity = row.get(39);
|
|
|
+
|
|
|
+ if (userMobile.length() > 11) {
|
|
|
+ throw new RemoteServiceException(errPrefix + "请输入正确的客户手机号");
|
|
|
+ }
|
|
|
+
|
|
|
+ DateTime dateTime = null;
|
|
|
+ try {
|
|
|
+ dateTime = DateUtil.parseDateTime(createTime);
|
|
|
+ if (dateTime == null) {
|
|
|
+ throw new RemoteServiceException(errPrefix + "创建时间请输入【2023-12-28 00:00:00】的格式");
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new RemoteServiceException(errPrefix + "创建时间请输入【2023-12-28 00:00:00】的格式");
|
|
|
+ }
|
|
|
+
|
|
|
+ AdminWebsit adminWebsit = null;
|
|
|
+ if (StringUtils.isNotBlank(createWebsitId)) {
|
|
|
+ adminWebsit = adminWebsitMap.get(createWebsitId);
|
|
|
+ if (adminWebsit == null) {
|
|
|
+ throw new RemoteServiceException(errPrefix + "网点不存在");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ AdminWebsit adminWebsitWorker = null;
|
|
|
+ if (StringUtils.isNotBlank(websitId)) {
|
|
|
+ adminWebsitWorker = adminWebsitMap.get(websitId);
|
|
|
+ if (adminWebsitWorker == null) {
|
|
|
+ throw new RemoteServiceException(errPrefix + "网点不存在");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ OrderSmallType orderSmallType1 = orderSmallTypeMap.get(orderType);
|
|
|
+ if (orderSmallType1 == null) {
|
|
|
+ throw new RemoteServiceException(errPrefix + "工单类型不存在");
|
|
|
+ }
|
|
|
+
|
|
|
+ //工单状态
|
|
|
+ OrderBaseStatusEnum importBaseStatusEnum = null;
|
|
|
+ if (StringUtils.isNotBlank(status)) {
|
|
|
+ importBaseStatusEnum = BaseEnum.valueToEnum(OrderBaseStatusEnum.class, status);
|
|
|
+ if (importBaseStatusEnum == null) {
|
|
|
+ throw new RemoteServiceException(errPrefix + "工单状态不存在");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ Region region = orderBaseLogic.getRegion(province, city, area, street);
|
|
|
+ if (region == null) {
|
|
|
+ throw new RemoteServiceException(errPrefix + "地址【" + province + city + area + street + "】解析失败");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ PgOrderBase pgOrderBase = new PgOrderBase();
|
|
|
+ pgOrderBase.setId(pgOrderId);
|
|
|
+ pgOrderBase.setIsImport(true);
|
|
|
+ pgOrderBase.setIsImportExcel(true);
|
|
|
+ pgOrderBase.setOrderStatus(importBaseStatusEnum == null ? null : importBaseStatusEnum.getKey());
|
|
|
+ pgOrderBase.setServiceStatus(serviceStatus);
|
|
|
+
|
|
|
+ pgOrderBase.setOrderType(orderSmallType1.getOrderType());
|
|
|
+ pgOrderBase.setOrderTypeText(BaseEnum.keyToEnum(OrderTypeEnum.class, orderSmallType1.getOrderType()).getRemark());
|
|
|
+
|
|
|
+
|
|
|
+ pgOrderBase.setOrderSmallType(orderSmallType1.getId());
|
|
|
+ pgOrderBase.setOrderSmallTypeText(orderSmallType1.getOrderSmallTypeText());
|
|
|
+
|
|
|
+ pgOrderBase.setCompanyWechatId(adminUser.getCompanyWechatId());
|
|
|
+ pgOrderBase.setCompanyWechatName(adminUser.getCompanyName());
|
|
|
+
|
|
|
+ pgOrderBase.setComplaint(complaint);
|
|
|
+ pgOrderBase.setUserName(userName);
|
|
|
+ pgOrderBase.setUserMobile(userMobile);
|
|
|
+
|
|
|
+
|
|
|
+ pgOrderBase.setProvinceId(region.getProvinceCode());
|
|
|
+ pgOrderBase.setProvince(region.getProvinceName());
|
|
|
+ pgOrderBase.setCity(region.getCityName());
|
|
|
+ pgOrderBase.setCityId(region.getCityCode());
|
|
|
+ pgOrderBase.setArea(region.getAreaName());
|
|
|
+ pgOrderBase.setAreaId(region.getAreaCode());
|
|
|
+ pgOrderBase.setStreet(region.getName());
|
|
|
+ pgOrderBase.setStreetId(region.getId());
|
|
|
+ pgOrderBase.setAddress(address);
|
|
|
+
|
|
|
+ pgOrderBase.setCreateWebsitId(adminWebsit.getWebsitId());
|
|
|
+ pgOrderBase.setCreateWebsitName(adminWebsit.getName());
|
|
|
+
|
|
|
+ pgOrderBase.setSource(source);
|
|
|
+ pgOrderBase.setUrgent(urgent);
|
|
|
+ pgOrderBase.setEvaluate(evaluate);
|
|
|
+ pgOrderBase.setSalesPlatform(salesSource);
|
|
|
+ pgOrderBase.setBuyName(buyName);
|
|
|
+ pgOrderBase.setSalesTypeName(salesTypeName);
|
|
|
+ pgOrderBase.setTotalNum(Convert.toInt(totalNum));
|
|
|
+ pgOrderBase.setUndoneNum(StringUtil.isEmpty(undoneNum) ? 0 : Convert.toInt(undoneNum));
|
|
|
+ pgOrderBase.setReqStatus(requirement);
|
|
|
+ pgOrderBase.setReqType(requirementType);
|
|
|
+ pgOrderBase.setReqText(requirementNotes);
|
|
|
+ pgOrderBase.setSaleCompany(belongCompany);
|
|
|
+ pgOrderBase.setCreateTime(dateTime);
|
|
|
+ pgOrderBase.setServiceOrderId(serviceOrderId);
|
|
|
+ pgOrderBase.setMainName(categoryType);
|
|
|
+
|
|
|
+ DateTime appointmentTimeN = null;
|
|
|
+ try {
|
|
|
+ appointmentTimeN = DateUtil.parseDateTime(appointmentTime);
|
|
|
+ if (dateTime == null) {
|
|
|
+ throw new RemoteServiceException(errPrefix + "预约开始时间请输入【2023-12-28 00:00:00】的格式");
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new RemoteServiceException(errPrefix + "预约开始时间请输入【2023-12-28 00:00:00】的格式");
|
|
|
+ }
|
|
|
+
|
|
|
+ DateTime appointmentEndTimeN = null;
|
|
|
+ try {
|
|
|
+ appointmentEndTimeN = DateUtil.parseDateTime(appointmentEndTime);
|
|
|
+ if (dateTime == null) {
|
|
|
+ throw new RemoteServiceException(errPrefix + "预约结束时间请输入【2023-12-28 00:00:00】的格式");
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new RemoteServiceException(errPrefix + "预约结束时间请输入【2023-12-28 00:00:00】的格式");
|
|
|
+ }
|
|
|
+ pgOrderBase.setAppointmentTime(appointmentTimeN);
|
|
|
+ pgOrderBase.setAppointmentEndTime(appointmentEndTimeN);
|
|
|
+ pgOrderBase.setSalesOrderId(salesOrderId);
|
|
|
+
|
|
|
+ DateTime overDateN = null;
|
|
|
+ try {
|
|
|
+ overDateN = DateUtil.parseDateTime(overDate);
|
|
|
+ if (dateTime == null) {
|
|
|
+ throw new RemoteServiceException(errPrefix + "完工时间请输入【2023-12-28 00:00:00】的格式");
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new RemoteServiceException(errPrefix + "完工时间请输入【2023-12-28 00:00:00】的格式");
|
|
|
+ }
|
|
|
+
|
|
|
+ pgOrderBase.setOverDate(overDateN);
|
|
|
+ pgOrderBase.setManagerName(managerGroup);
|
|
|
+ pgOrderBase.setOperateEntity(operateEntity);
|
|
|
+
|
|
|
+
|
|
|
+ if (adminWebsitWorker != null) {
|
|
|
+
|
|
|
+ pgOrderBase.setWebsitId(adminWebsitWorker.getWebsitId());
|
|
|
+ pgOrderBase.setWebsitName(adminWebsitWorker.getName());
|
|
|
+ pgOrderBase.setWebsitPhone(adminWebsitWorker.getWebsitPhone());
|
|
|
+
|
|
|
+
|
|
|
+ if (StringUtils.isNotBlank(workerId)) {
|
|
|
+
|
|
|
+
|
|
|
+ pgOrderBase.setWorkerNumber(workerId);
|
|
|
+ pgOrderBase.setWorkerName(workerName);
|
|
|
+ pgOrderBase.setWorkerReceTime(new Date());
|
|
|
+ pgOrderBase.setDispatchTime(new Date());
|
|
|
+
|
|
|
+
|
|
|
+ PgOrderWorker pgOrderWorker = new PgOrderWorker();
|
|
|
+ pgOrderWorker.setOrderBaseId(pgOrderId);
|
|
|
+ pgOrderWorker.setWorkerNumber(workerId);
|
|
|
+ pgOrderWorker.setWebsitId(pgOrderBase.getWebsitId());
|
|
|
+ pgOrderWorker.setWebsitName(pgOrderBase.getWebsitName());
|
|
|
+ pgOrderBase.setWorkerName(workerName);
|
|
|
+ pgOrderWorker.setIsMaster(true);
|
|
|
+ pgOrderWorkers.add(pgOrderWorker);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!StringUtil.isEmpty(pSize)) {
|
|
|
+
|
|
|
+ GoodsCategory mainGoodsCategory = categoryMap1.get(categoryType);
|
|
|
+
|
|
|
+ if (mainGoodsCategory == null) {
|
|
|
+ throw new RemoteServiceException("第" + (index) + "行 产品大类不存在");
|
|
|
+ }
|
|
|
+
|
|
|
+ PgOrderProduct pgOrderProduct = new PgOrderProduct();
|
|
|
+ pgOrderProduct.setOrderBaseId(pgOrderId);
|
|
|
+ pgOrderProduct.setNum(Convert.toInt(totalNum));
|
|
|
+ pgOrderProduct.setMainId(mainGoodsCategory.getCategoryId());
|
|
|
+ pgOrderProduct.setMainName(mainGoodsCategory.getMainName());
|
|
|
+
|
|
|
+ pgOrderProduct.setBrandName("格力");
|
|
|
+
|
|
|
+ pgOrderProduct.setProductName(pSize);
|
|
|
+ pgOrderProducts.add(pgOrderProduct);
|
|
|
+ }
|
|
|
+ pgOrderBase.insertOrUpdate();
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ //生成师傅信息
|
|
|
+ if (CollectionUtils.isNotEmpty(pgOrderWorkers)) {
|
|
|
+ pgOrderWorkerService.saveBatch(pgOrderWorkers);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (CollectionUtils.isNotEmpty(pgOrderProducts)) {
|
|
|
+ //删除旧的产品数据
|
|
|
+
|
|
|
+ List<String> collect = addPgOrderBase.stream().map(PgOrderBase::getId).collect(Collectors.toList());
|
|
|
+ pgOrderProductService.lambdaUpdate().in(PgOrderProduct::getOrderBaseId, collect).remove();
|
|
|
+
|
|
|
+ //生成新的产品数据
|
|
|
+ pgOrderProductService.saveBatch(pgOrderProducts);
|
|
|
+
|
|
|
+ //创建工单添加消息
|
|
|
+ if (CollectionUtils.isNotEmpty(addPgOrderBase)) {
|
|
|
+ for (PgOrderBase pgOrderBase : addPgOrderBase) {
|
|
|
+ orderBaseLogic.addLog(pgOrderBase, pgOrderBase.getCreateWebsitName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|