|
@@ -8,13 +8,17 @@ import com.gree.mall.manager.bean.SyncOrderDto;
|
|
import com.gree.mall.manager.bean.admin.AdminUserCom;
|
|
import com.gree.mall.manager.bean.admin.AdminUserCom;
|
|
import com.gree.mall.manager.bean.workorder.*;
|
|
import com.gree.mall.manager.bean.workorder.*;
|
|
import com.gree.mall.manager.commonmapper.workorder.IncreMapper;
|
|
import com.gree.mall.manager.commonmapper.workorder.IncreMapper;
|
|
|
|
+import com.gree.mall.manager.constant.SysDictConstant;
|
|
import com.gree.mall.manager.enums.PayStatusEnum;
|
|
import com.gree.mall.manager.enums.PayStatusEnum;
|
|
import com.gree.mall.manager.enums.admin.AdminWebsitTypeEnum;
|
|
import com.gree.mall.manager.enums.admin.AdminWebsitTypeEnum;
|
|
import com.gree.mall.manager.enums.workorder.OrderBaseStatusEnum;
|
|
import com.gree.mall.manager.enums.workorder.OrderBaseStatusEnum;
|
|
import com.gree.mall.manager.enums.workorder.OrderOperatorLogTypeEnum;
|
|
import com.gree.mall.manager.enums.workorder.OrderOperatorLogTypeEnum;
|
|
|
|
+import com.gree.mall.manager.exception.RemoteServiceException;
|
|
import com.gree.mall.manager.logic.common.CommonLogic;
|
|
import com.gree.mall.manager.logic.common.CommonLogic;
|
|
|
|
+import com.gree.mall.manager.logic.common.SysDictCompanyLogic;
|
|
import com.gree.mall.manager.plus.entity.*;
|
|
import com.gree.mall.manager.plus.entity.*;
|
|
import com.gree.mall.manager.plus.service.*;
|
|
import com.gree.mall.manager.plus.service.*;
|
|
|
|
+import com.gree.mall.manager.utils.excel.ExcelUtils;
|
|
import com.gree.mall.manager.zfire.bean.ZfireParamBean;
|
|
import com.gree.mall.manager.zfire.bean.ZfireParamBean;
|
|
import com.gree.mall.manager.zfire.util.FieldUtils;
|
|
import com.gree.mall.manager.zfire.util.FieldUtils;
|
|
import lombok.RequiredArgsConstructor;
|
|
import lombok.RequiredArgsConstructor;
|
|
@@ -22,8 +26,10 @@ import lombok.extern.slf4j.Slf4j;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
import org.thymeleaf.util.StringUtils;
|
|
import org.thymeleaf.util.StringUtils;
|
|
|
|
|
|
|
|
+import java.io.IOException;
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
import java.util.Date;
|
|
import java.util.Date;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
@@ -91,6 +97,15 @@ public class ChangeOrderLogic {
|
|
@Autowired
|
|
@Autowired
|
|
GoodsCategoryService goodsCategoryService;
|
|
GoodsCategoryService goodsCategoryService;
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ WebsitDispatchService websitDispatchService;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ SysDictCompanyLogic sysDictCompanyLogic;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ OrderBaseLogic orderBaseLogic;
|
|
|
|
+
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
public void changeAppointmentTime(String id, String appointmentTime, String appointmentEndTime,String remark) {
|
|
public void changeAppointmentTime(String id, String appointmentTime, String appointmentEndTime,String remark) {
|
|
@@ -340,6 +355,7 @@ public class ChangeOrderLogic {
|
|
return increMapper.sourceList(pId, cityCode, areaCode, streetCode, dictCode, orderSmallId, categoryId, orderSourceId,adminCompanyIds);
|
|
return increMapper.sourceList(pId, cityCode, areaCode, streetCode, dictCode, orderSmallId, categoryId, orderSourceId,adminCompanyIds);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
public void saveDispatch(WebsitDispatchAdd websitDispatchAdd) {
|
|
public void saveDispatch(WebsitDispatchAdd websitDispatchAdd) {
|
|
AdminWebsit adminWebsit = adminWebsitService.getById(websitDispatchAdd.getWebsitId());
|
|
AdminWebsit adminWebsit = adminWebsitService.getById(websitDispatchAdd.getWebsitId());
|
|
|
|
|
|
@@ -349,19 +365,169 @@ public class ChangeOrderLogic {
|
|
|
|
|
|
for (String orderSmallId : websitDispatchAdd.getOrderSmallIds()) {
|
|
for (String orderSmallId : websitDispatchAdd.getOrderSmallIds()) {
|
|
|
|
|
|
|
|
+ OrderSmallType orderSmallType = orderSmallTypeService.getById(orderSmallId);
|
|
|
|
+
|
|
for (String categoryId : websitDispatchAdd.getCategoryIds()) {
|
|
for (String categoryId : websitDispatchAdd.getCategoryIds()) {
|
|
|
|
|
|
|
|
+ GoodsCategory goodsCategory = goodsCategoryService.getById(categoryId);
|
|
|
|
+
|
|
for (String orderChannel : websitDispatchAdd.getOrderChannelIds()) {
|
|
for (String orderChannel : websitDispatchAdd.getOrderChannelIds()) {
|
|
|
|
|
|
|
|
+ SysDictCompany orderChanne = sysDictCompanyService.lambdaQuery().eq(SysDictCompany::getDictCode, orderChannel).last("limit 1").one();
|
|
|
|
+
|
|
for (String orderSourceId : websitDispatchAdd.getOrderSourceIds()) {
|
|
for (String orderSourceId : websitDispatchAdd.getOrderSourceIds()) {
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ SysDictCompany orderSource = sysDictCompanyService.lambdaQuery().eq(SysDictCompany::getDictCode, orderSourceId).last("limit 1").one();
|
|
|
|
+
|
|
WebsitDispatch websitDispatch = new WebsitDispatch();
|
|
WebsitDispatch websitDispatch = new WebsitDispatch();
|
|
websitDispatch.setWebsitId(adminWebsit.getWebsitId());
|
|
websitDispatch.setWebsitId(adminWebsit.getWebsitId());
|
|
websitDispatch.setWebsitName(adminWebsit.getName());
|
|
websitDispatch.setWebsitName(adminWebsit.getName());
|
|
- websitDispatch.setProvinceCode(adminWebsit.getName());
|
|
|
|
|
|
+ websitDispatch.setProvinceCode(region.getProvinceName());
|
|
|
|
+ websitDispatch.setProvinceName(region.getProvinceCode());
|
|
|
|
+ websitDispatch.setCityCode(region.getCityCode());
|
|
|
|
+ websitDispatch.setCityName(region.getCityName());
|
|
|
|
+ websitDispatch.setAreaCode(region.getAreaCode());
|
|
|
|
+ websitDispatch.setAreaName(region.getAreaName());
|
|
|
|
+ websitDispatch.setStreetCode(region.getId());
|
|
|
|
+ websitDispatch.setStreetName(region.getName());
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ websitDispatch.setOrderSmallTypeText(orderSmallType.getId());
|
|
|
|
+ websitDispatch.setOrderSmallId(orderSmallType.getOrderSmallTypeText());
|
|
|
|
+
|
|
|
|
+ websitDispatch.setCategoryId(goodsCategory.getCategoryId());
|
|
|
|
+ websitDispatch.setCategoryName(goodsCategory.getName());
|
|
|
|
+
|
|
|
|
+ websitDispatch.setDictCode(orderChanne.getDictCode());
|
|
|
|
+ websitDispatch.setDictValue(orderChanne.getDictValue());
|
|
|
|
+
|
|
|
|
+ websitDispatch.setOrderSource(orderSource.getDictValue());
|
|
|
|
+ websitDispatch.setOrderSourceId(orderSource.getDictCode());
|
|
|
|
+
|
|
|
|
+ if (websitDispatchService.lambdaQuery().eq(WebsitDispatch::getStreetCode,region.getId())
|
|
|
|
+ .eq(WebsitDispatch::getOrderSmallId,websitDispatch.getOrderSmallId())
|
|
|
|
+ .eq(WebsitDispatch::getCategoryId,websitDispatch.getCategoryId())
|
|
|
|
+ .eq(WebsitDispatch::getDictCode,websitDispatch.getDictCode())
|
|
|
|
+ .eq(WebsitDispatch::getOrderSourceId,websitDispatch.getOrderSourceId()).count() > 0) {
|
|
|
|
+ throw new RemoteServiceException("存在街道:"+websitDispatch.getStreetName()+",产品大类:"+websitDispatch.getCategoryName()+
|
|
|
|
+ ",工单渠道:"+websitDispatch.getDictValue()+",工单来源:"+websitDispatch.getOrderSource()+",工单类型:"+websitDispatch.getOrderSmallTypeText());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ websitDispatches.add(websitDispatch);
|
|
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ websitDispatchService.saveBatch(websitDispatches);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void delDispatch(List<String> id) {
|
|
|
|
+ websitDispatchService.removeByIds(id);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
|
+ public void importData(MultipartFile file) throws IOException {
|
|
|
|
+
|
|
|
|
+ AdminUserCom adminUser = commonLogic.getAdminUser();
|
|
|
|
+
|
|
|
|
+ List<Object> rows = ExcelUtils.importExcel(file);
|
|
|
|
+ if(org.apache.commons.collections4.CollectionUtils.isEmpty(rows)){
|
|
|
|
+ throw new RemoteServiceException("导入内容为空");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ //工单类型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, SysDictCompany> orderChannelMap = sysDictCompanyLogic.dictByTypeOfValue(SysDictConstant.ORDER_CHANNEL, adminUser.getCompanyWechatId());
|
|
|
|
+
|
|
|
|
+ //工单渠道
|
|
|
|
+ Map<String, SysDictCompany> orderSourceMap = sysDictCompanyLogic.dictByTypeOfValue(SysDictConstant.ORDER_SOURCE, 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<WebsitDispatch> websitDispatches = new ArrayList<>();
|
|
|
|
+ for(Object o : rows) {
|
|
|
|
+ List<Object> row = (List<Object>) o;
|
|
|
|
+
|
|
|
|
+ String websitName = (String)row.get(0);
|
|
|
|
+ String websitId = (String)row.get(1);
|
|
|
|
+ String pName = (String)row.get(2);
|
|
|
|
+ String cName = (String)row.get(3);
|
|
|
|
+ String aName = (String)row.get(4);
|
|
|
|
+ String sName = (String)row.get(5);
|
|
|
|
+ String channelName = (String)row.get(6);
|
|
|
|
+ String smallName = (String)row.get(7);
|
|
|
|
+ String categoryName = (String)row.get(8);
|
|
|
|
+ String sourceName = (String)row.get(9);
|
|
|
|
+
|
|
|
|
+ AdminWebsit adminWebsit = adminWebsitMap.get(websitId);
|
|
|
|
+
|
|
|
|
+ Region region = orderBaseLogic.getRegion(pName, cName, aName, sName);
|
|
|
|
+
|
|
|
|
+ SysDictCompany orderChanne = orderChannelMap.get(channelName);
|
|
|
|
+
|
|
|
|
+ GoodsCategory goodsCategory = categoryMap1.get(categoryName);
|
|
|
|
+
|
|
|
|
+ OrderSmallType orderSmallType = orderSmallTypeMap.get(smallName);
|
|
|
|
+
|
|
|
|
+ SysDictCompany orderSource = orderSourceMap.get(sourceName);
|
|
|
|
+
|
|
|
|
+ WebsitDispatch websitDispatch = new WebsitDispatch();
|
|
|
|
+ websitDispatch.setWebsitId(adminWebsit.getWebsitId());
|
|
|
|
+ websitDispatch.setWebsitName(adminWebsit.getName());
|
|
|
|
+ websitDispatch.setProvinceCode(region.getProvinceName());
|
|
|
|
+ websitDispatch.setProvinceName(region.getProvinceCode());
|
|
|
|
+ websitDispatch.setCityCode(region.getCityCode());
|
|
|
|
+ websitDispatch.setCityName(region.getCityName());
|
|
|
|
+ websitDispatch.setAreaCode(region.getAreaCode());
|
|
|
|
+ websitDispatch.setAreaName(region.getAreaName());
|
|
|
|
+ websitDispatch.setStreetCode(region.getId());
|
|
|
|
+ websitDispatch.setStreetName(region.getName());
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ websitDispatch.setOrderSmallTypeText(orderSmallType.getId());
|
|
|
|
+ websitDispatch.setOrderSmallId(orderSmallType.getOrderSmallTypeText());
|
|
|
|
+
|
|
|
|
+ websitDispatch.setCategoryId(goodsCategory.getCategoryId());
|
|
|
|
+ websitDispatch.setCategoryName(goodsCategory.getName());
|
|
|
|
+
|
|
|
|
+ websitDispatch.setDictCode(orderChanne.getDictCode());
|
|
|
|
+ websitDispatch.setDictValue(orderChanne.getDictValue());
|
|
|
|
+
|
|
|
|
+ websitDispatch.setOrderSource(orderSource.getDictValue());
|
|
|
|
+ websitDispatch.setOrderSourceId(orderSource.getDictCode());
|
|
|
|
+
|
|
|
|
+ if (websitDispatchService.lambdaQuery().eq(WebsitDispatch::getStreetCode,region.getId())
|
|
|
|
+ .eq(WebsitDispatch::getOrderSmallId,websitDispatch.getOrderSmallId())
|
|
|
|
+ .eq(WebsitDispatch::getCategoryId,websitDispatch.getCategoryId())
|
|
|
|
+ .eq(WebsitDispatch::getDictCode,websitDispatch.getDictCode())
|
|
|
|
+ .eq(WebsitDispatch::getOrderSourceId,websitDispatch.getOrderSourceId()).count() > 0) {
|
|
|
|
+ throw new RemoteServiceException("存在街道:"+websitDispatch.getStreetName()+",产品大类:"+websitDispatch.getCategoryName()+
|
|
|
|
+ ",工单渠道:"+websitDispatch.getDictValue()+",工单来源:"+websitDispatch.getOrderSource()+",工单类型:"+websitDispatch.getOrderSmallTypeText());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ websitDispatches.add(websitDispatch);
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ websitDispatchService.saveBatch(websitDispatches);
|
|
|
|
+
|
|
}
|
|
}
|
|
}
|
|
}
|