diff --git a/blade-service-api/logpm-aftersales-api/src/main/java/com/logpm/aftersales/vo/AftersalesWorkOrderVO.java b/blade-service-api/logpm-aftersales-api/src/main/java/com/logpm/aftersales/vo/AftersalesWorkOrderVO.java index 9ed2ca948..23772c400 100644 --- a/blade-service-api/logpm-aftersales-api/src/main/java/com/logpm/aftersales/vo/AftersalesWorkOrderVO.java +++ b/blade-service-api/logpm-aftersales-api/src/main/java/com/logpm/aftersales/vo/AftersalesWorkOrderVO.java @@ -36,6 +36,10 @@ public class AftersalesWorkOrderVO extends AftersalesWorkOrderEntity { * 工单名称 */ private String workOrderTypeName; + /** + * 工单名称 + */ + private String workOrderStatusName; /** * 提货名称 diff --git a/blade-service/logpm-aftersales/src/main/java/com/logpm/aftersales/controller/AftersalesWorkOrderController.java b/blade-service/logpm-aftersales/src/main/java/com/logpm/aftersales/controller/AftersalesWorkOrderController.java index 4947723bf..2ae479ab5 100644 --- a/blade-service/logpm-aftersales/src/main/java/com/logpm/aftersales/controller/AftersalesWorkOrderController.java +++ b/blade-service/logpm-aftersales/src/main/java/com/logpm/aftersales/controller/AftersalesWorkOrderController.java @@ -16,14 +16,19 @@ */ package com.logpm.aftersales.controller; +import com.alibaba.excel.EasyExcel; +import com.alibaba.excel.ExcelWriter; +import com.alibaba.excel.write.metadata.WriteSheet; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.logpm.aftersales.dto.AftersalesWorkOrderDTO; import com.logpm.aftersales.dto.AftersalesWorkOrderListExcelDTO; -import com.logpm.aftersales.entity.AftersalesAppealEntity; -import com.logpm.aftersales.entity.AftersalesSettlementEntity; +import com.logpm.aftersales.entity.*; import com.logpm.aftersales.excel.AftersalesWorkOrderImporter; +import com.logpm.aftersales.service.IAftersaleSurveyRecordService; import com.logpm.aftersales.service.IAftersalesCompletionRecordService; +import com.logpm.aftersales.service.IAftersalesPersonResponsibleService; import com.logpm.basicdata.entity.BasicdataWarehouseEntity; import com.logpm.basicdata.feign.IBasicdataWarehouseClient; import io.swagger.annotations.Api; @@ -31,6 +36,8 @@ import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; import lombok.AllArgsConstructor; + +import javax.servlet.ServletOutputStream; import javax.validation.Valid; import lombok.extern.slf4j.Slf4j; @@ -43,7 +50,6 @@ import org.springblade.core.tool.utils.Func; import org.springblade.system.entity.User; import org.springframework.web.bind.annotation.*; import com.baomidou.mybatisplus.core.metadata.IPage; -import com.logpm.aftersales.entity.AftersalesWorkOrderEntity; import com.logpm.aftersales.vo.AftersalesWorkOrderVO; import com.logpm.aftersales.excel.AftersalesWorkOrderExcel; import com.logpm.aftersales.wrapper.AftersalesWorkOrderWrapper; @@ -54,7 +60,11 @@ import org.springblade.core.excel.util.ExcelUtil; import org.springframework.web.multipart.MultipartFile; import springfox.documentation.annotations.ApiIgnore; +import java.io.IOException; +import java.text.SimpleDateFormat; import java.util.*; +import java.util.concurrent.atomic.AtomicReference; +import java.util.stream.Collectors; import javax.servlet.http.HttpServletResponse; /** @@ -73,6 +83,8 @@ public class AftersalesWorkOrderController extends BladeController { private final IAftersalesWorkOrderService aftersalesWorkOrderService; private final IBasicdataWarehouseClient warehouseClient; private final IAftersalesCompletionRecordService aftersalesCompletionRecordService; + private final IAftersalesPersonResponsibleService aftersalesPersonResponsibleService; + private final IAftersaleSurveyRecordService aftersaleSurveyRecordService; /** * 客服异常工单 详情 @@ -719,6 +731,125 @@ public class AftersalesWorkOrderController extends BladeController { + /** + * 导出数据 + * + */ + @GetMapping("/exportWorkOrder1") + @ApiOperationSupport(order = 9) + @ApiOperation(value = "导出数据", notes = "传入aftersalesWorkOrder") + public void newExportWorkOrder(@ApiIgnore @RequestParam Map aftersalesWorkOrder, BladeUser bladeUser, HttpServletResponse response) { + List> basicTitle = aftersalesWorkOrderService.basicTitleBuild(); + //查询数据 + + List exportData = aftersalesWorkOrderService.getBasicExportData(aftersalesWorkOrder); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + if (!exportData.isEmpty()) { + List> dataList = new ArrayList<>(); + for (AftersalesWorkOrderVO exportDatum : exportData) { + List data = new ArrayList<>(); + data.add(0,exportDatum.getWorkOrderTypeName()); + data.add(1,exportDatum.getDiscoveryNodeName()); + data.add(2,exportDatum.getWarehouseName()); + data.add(3,exportDatum.getWorkOrderNumber()); + data.add(4,exportDatum.getWaybillNumber()); + data.add(5,exportDatum.getOrderCode()); + data.add(6,exportDatum.getPackageCode()); + data.add(7,exportDatum.getBrandName()); + data.add(8,exportDatum.getWaybillMall()); + data.add(9,exportDatum.getFirst()); + data.add(10,exportDatum.getWorkOrderStatusName()); + data.add(11,exportDatum.getBusinessName()); + data.add(12,sdf.format(exportDatum.getCreateTime())); + data.add(13,sdf.format(exportDatum.getEndCreateTime())); + data.add(14,Objects.isNull(exportDatum.getUpdateTime())?"":sdf.format(exportDatum.getUpdateTime())); + data.add(15,null); + data.add(16,null); + //查询此工单是否存在有责任方如果存在有责任方完善表头 + List entityList = aftersalesPersonResponsibleService.list(Wrappers.query().lambda() + .eq(AftersalesPersonResponsibleEntity::getWordOrderId, exportDatum.getId()) + .eq(AftersalesPersonResponsibleEntity::getTypesOf, "1") + ); + if (!entityList.isEmpty()) { + handleResponsibility(basicTitle,entityList,data); + } + dataList.add(data); + } + ServletOutputStream os = null; + try { + os = response.getOutputStream(); + ExcelWriter excelWriter = EasyExcel.write(os).build(); + + WriteSheet sheet = EasyExcel.writerSheet() + // 这里放入动态头 + .head(basicTitle) + // 当然这里数据也可以用 List> 去传入 + .build(); + excelWriter.write(dataList,sheet); + excelWriter.finish(); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + + } + + private void handleResponsibility(List> basicTitle, List entityList, List data) { + Long wordOrderId = entityList.get(0).getWordOrderId(); + //查询最新消息 + List recordEntities = aftersaleSurveyRecordService.list(Wrappers.query().lambda() + .eq(AftersaleSurveyRecordEntity::getWorkOrderId, wordOrderId) + .orderByDesc(AftersaleSurveyRecordEntity::getCreateTime) + ); + if (!recordEntities.isEmpty()) { + if (!basicTitle.contains(Arrays.asList("最新消息回复内容")) ){ + List head5 = new ArrayList<>(Arrays.asList("最新消息回复内容")); + basicTitle.add(basicTitle.size(),head5); + basicTitle.add(head5); + } + data.add(recordEntities.get(0).getContent()); + + } + int aa = 0; + Map> listMap = entityList.stream().collect(Collectors.groupingBy(AftersalesPersonResponsibleEntity::getWordOrderId)); + for (Long l : listMap.keySet()) { + + List aftersalesPersonResponsibleEntities = listMap.get(l); + aa = Math.max(aa, aftersalesPersonResponsibleEntities.size()); + } + for (int i = 0; i < aa; i++) { + if (!basicTitle.contains(Arrays.asList("责任方"+(i+1)))) { + List head1 = new ArrayList<>(Arrays.asList("责任方"+(i+1))); + basicTitle.add(basicTitle.size(),head1); + } + if (!basicTitle.contains(Arrays.asList("责任人"+(i+1)))) { + List head2 = new ArrayList<>(Arrays.asList("责任人"+(i+1))); + basicTitle.add(basicTitle.size(),head2); + } + if (!basicTitle.contains(Arrays.asList("三方责任人"+(i+1)))) { + List head3 = new ArrayList<>(Arrays.asList("三方责任人"+(i+1))); + basicTitle.add(basicTitle.size(),head3); + } + if (!basicTitle.contains(Arrays.asList("金额"+(i+1)))) { + List head4 = new ArrayList<>(Arrays.asList("金额"+(i+1))); + basicTitle.add(basicTitle.size(),head4); + } + + } + + + for (int i = 0; i < entityList.size(); i++) { + data.add(entityList.get(i).getBusinessName()); + data.add(entityList.get(i).getPersonResponsibleName()); + data.add(entityList.get(i).getTripartite()); + data.add(entityList.get(i).getResponsibilityRatio()); + } + + + + } + + @GetMapping("/exportAllWorkOrder") @ApiOperationSupport(order = 9) @ApiOperation(value = "导出数据", notes = "传入aftersalesWorkOrder") diff --git a/blade-service/logpm-aftersales/src/main/java/com/logpm/aftersales/excel/AftersalesWorkOrderExcel.java b/blade-service/logpm-aftersales/src/main/java/com/logpm/aftersales/excel/AftersalesWorkOrderExcel.java index 878f08b6d..3a482cc35 100644 --- a/blade-service/logpm-aftersales/src/main/java/com/logpm/aftersales/excel/AftersalesWorkOrderExcel.java +++ b/blade-service/logpm-aftersales/src/main/java/com/logpm/aftersales/excel/AftersalesWorkOrderExcel.java @@ -56,6 +56,14 @@ public class AftersalesWorkOrderExcel implements Serializable { @ColumnWidth(20) @ExcelProperty("发现节点") private String discoveryNodeName; + + + /** + * 工单发起仓 + */ + @ColumnWidth(20) + @ExcelProperty("工单发起仓") + private String warehouseName; @ExcelIgnore //发现节点 private String discoveryNode; /** @@ -83,6 +91,13 @@ public class AftersalesWorkOrderExcel implements Serializable { @ColumnWidth(20) @ExcelProperty("订单自编号") private String orderCode; + + /** + * 订单自编号 + */ + @ColumnWidth(20) + @ExcelProperty("包条码") + private String packageCode; /** * 一级品类 */ diff --git a/blade-service/logpm-aftersales/src/main/java/com/logpm/aftersales/mapper/AftersalesWorkOrderMapper.java b/blade-service/logpm-aftersales/src/main/java/com/logpm/aftersales/mapper/AftersalesWorkOrderMapper.java index 1454da6bc..1cc9d87f6 100644 --- a/blade-service/logpm-aftersales/src/main/java/com/logpm/aftersales/mapper/AftersalesWorkOrderMapper.java +++ b/blade-service/logpm-aftersales/src/main/java/com/logpm/aftersales/mapper/AftersalesWorkOrderMapper.java @@ -29,6 +29,7 @@ import org.apache.ibatis.annotations.Param; import java.util.Date; import java.util.List; +import java.util.Map; /** * 客服异常工单 Mapper 接口 @@ -117,4 +118,12 @@ public interface AftersalesWorkOrderMapper extends BaseMapper exportAllListOwn(@Param("param")AftersalesWorkOrderEntity workOrderEntity,@Param("ids")List ids); + + /** + * 查询导出基础部分数据 + * @param workOrderDTO + * @param ids + * @return + */ + List getBasicExportData(@Param("param") AftersalesWorkOrderDTO workOrderDTO, List ids); } diff --git a/blade-service/logpm-aftersales/src/main/java/com/logpm/aftersales/mapper/AftersalesWorkOrderMapper.xml b/blade-service/logpm-aftersales/src/main/java/com/logpm/aftersales/mapper/AftersalesWorkOrderMapper.xml index 9bd148bfc..522da72aa 100644 --- a/blade-service/logpm-aftersales/src/main/java/com/logpm/aftersales/mapper/AftersalesWorkOrderMapper.xml +++ b/blade-service/logpm-aftersales/src/main/java/com/logpm/aftersales/mapper/AftersalesWorkOrderMapper.xml @@ -1041,6 +1041,112 @@ group by lawo.id ORDER BY lawo.create_time DESC + diff --git a/blade-service/logpm-aftersales/src/main/java/com/logpm/aftersales/service/IAftersalesWorkOrderService.java b/blade-service/logpm-aftersales/src/main/java/com/logpm/aftersales/service/IAftersalesWorkOrderService.java index 3a04807ce..ce4d4c1fa 100644 --- a/blade-service/logpm-aftersales/src/main/java/com/logpm/aftersales/service/IAftersalesWorkOrderService.java +++ b/blade-service/logpm-aftersales/src/main/java/com/logpm/aftersales/service/IAftersalesWorkOrderService.java @@ -307,4 +307,16 @@ public interface IAftersalesWorkOrderService extends BaseService exportWorkOrder(Map aftersalesWorkOrder); + /** + * 构建导出基础字段 + * @return + */ + List> basicTitleBuild(); + + /** + * 查询导出基础数据 + * @param aftersalesWorkOrder + * @return + */ + List getBasicExportData(Map aftersalesWorkOrder); } diff --git a/blade-service/logpm-aftersales/src/main/java/com/logpm/aftersales/service/impl/AftersalesWorkOrderServiceImpl.java b/blade-service/logpm-aftersales/src/main/java/com/logpm/aftersales/service/impl/AftersalesWorkOrderServiceImpl.java index de5fe2c24..8c8d4a823 100644 --- a/blade-service/logpm-aftersales/src/main/java/com/logpm/aftersales/service/impl/AftersalesWorkOrderServiceImpl.java +++ b/blade-service/logpm-aftersales/src/main/java/com/logpm/aftersales/service/impl/AftersalesWorkOrderServiceImpl.java @@ -368,6 +368,16 @@ public class AftersalesWorkOrderServiceImpl extends BaseServiceImpl processorVOS = new ArrayList<>(); List list = aftersalesProcessorService.list(Wrappers.query().lambda() .eq(AftersalesProcessorEntity::getWorkOrderId, aftersalesWorkOrder.getId()) + .ne(AftersalesProcessorEntity::getTypesOf, "3") .apply("conditions in (1,2)") ); //需要待回复的处理方 @@ -2642,6 +2653,113 @@ public class AftersalesWorkOrderServiceImpl extends BaseServiceImpl> basicTitleBuild() { + List> title = new ArrayList<>(); + List head0 = new ArrayList<>(Arrays.asList("异常类型")); + title.add(0,head0); + List head1 = new ArrayList<>(Arrays.asList("发现节点")); + title.add(1,head1); + List head2 = new ArrayList<>(Arrays.asList("工单创建仓")); + title.add(2,head2); + + List head3 = new ArrayList<>(Arrays.asList("工单号")); + title.add(3,head3); + + List head4 = new ArrayList<>(Arrays.asList("运单号")); + title.add(4,head4); + + List head5 = new ArrayList<>(Arrays.asList("订单自编号")); + title.add(5,head5); + + List head6 = new ArrayList<>(Arrays.asList("包条码")); + title.add(6,head6); + + List head7 = new ArrayList<>(Arrays.asList("品牌")); + title.add(7,head7); + + List head8 = new ArrayList<>(Arrays.asList("运单商场")); + title.add(8,head8); + + List head9= new ArrayList<>(Arrays.asList("一级品类")); + title.add(9,head9); + + List head10 = new ArrayList<>(Arrays.asList("工单状态")); + title.add(10,head10); + + List head11 = new ArrayList<>(Arrays.asList("工单处理方")); + title.add(11,head11); + + List head12 = new ArrayList<>(Arrays.asList("工单创建时间")); + title.add(12,head12); + + List head13= new ArrayList<>(Arrays.asList("工单最晚处理时间")); + title.add(13,head13); + + List head14= new ArrayList<>(Arrays.asList("工单最新处理时间")); + title.add(14,head14); + + List head15= new ArrayList<>(Arrays.asList("是否超时")); + title.add(15,head15); + + List head16= new ArrayList<>(Arrays.asList("营业部处理客服")); + title.add(16,head16); + return title; + } + + @Override + public List getBasicExportData(Map aftersalesWorkOrder) { + String o = (String) aftersalesWorkOrder.get("ids"); + List ids = null; + if (!Objects.isNull(o)) { + ids = Func.toLongList((String) aftersalesWorkOrder.get("ids")); + } + //查询用户角色信息 + BladeUser user = AuthUtil.getUser(); + String roleName = user.getRoleName(); + + //查询客服岗位 + List warehouseType = DictBizCache.getList("after_sales_visits"); + if (warehouseType.isEmpty()) { + throw new ServiceException("注意,注意!售后访问字典未配置!请配置!"); + } + List roleList = Arrays.asList(user.getRoleName().split(",")); + BasicdataWarehouseEntity myCurrentWarehouse = warehouseClient.getMyCurrentWarehouse(); + if (!roleList.isEmpty()) { + Optional matchingDictBiz = warehouseType.stream() + .filter(i -> roleList.contains(i.getDictValue())) + .findFirst(); + Object workOrderStatus = aftersalesWorkOrder.get("workOrderStatus"); + if (matchingDictBiz.isPresent()) { + String dictValue = matchingDictBiz.get().getDictKey(); + switch (dictValue) { + case "1": // 客服经理 + updateWorkOrderForManager(aftersalesWorkOrder, workOrderStatus); + break; + case "2": // 营业部客服 + if (Objects.isNull(myCurrentWarehouse)){ + //营业部客服未选择仓库进行作业 + throw new ServiceException("请选择仓库"); + } + updateWorkOrderForSales(aftersalesWorkOrder, workOrderStatus); + break; + case "3": // 职能客服 + updateWorkOrderForFunctional(aftersalesWorkOrder, workOrderStatus, user.getUserId()); + break; + } + } else { + updateWorkOrderForOthers(aftersalesWorkOrder, workOrderStatus); + } + }else { + throw new CustomerException("当前登录人无工单操作权限!!!"); + } + + + AftersalesWorkOrderDTO workOrderDTO = JSONObject.parseObject(JSONObject.toJSONString(aftersalesWorkOrder), AftersalesWorkOrderDTO.class); + List exportData = baseMapper.getBasicExportData(workOrderDTO,ids); + return exportData; + } + /** * 判断是否是客服角色 * @param user diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionSignforServiceImpl.java b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionSignforServiceImpl.java index 6de7f430f..cfccde55e 100644 --- a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionSignforServiceImpl.java +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionSignforServiceImpl.java @@ -3290,6 +3290,7 @@ public class DistributionSignforServiceImpl extends BaseServiceImpl ids = parcelListEntities.stream().map(DistributionParcelListEntity::getId).collect(Collectors.toList()); List abnormalEntities = distributionLoadscanAbnormalService.list(Wrappers.query().lambda() .in(DistributionLoadscanAbnormalEntity::getPackageId, ids) + .eq(DistributionLoadscanAbnormalEntity::getAuditingStatus, "2") ); if (!abnormalEntities.isEmpty()) { //判断此包件的异常是否是当前扫描车次和客户