|
|
|
@ -26,9 +26,7 @@ import com.logpm.aftersales.dto.AftersalesWorkOrderDTO;
|
|
|
|
|
import com.logpm.aftersales.dto.AftersalesWorkOrderListExcelDTO; |
|
|
|
|
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.aftersales.service.*; |
|
|
|
|
import com.logpm.basicdata.entity.BasicdataWarehouseEntity; |
|
|
|
|
import com.logpm.basicdata.feign.IBasicdataWarehouseClient; |
|
|
|
|
import io.swagger.annotations.Api; |
|
|
|
@ -54,7 +52,6 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
|
|
import com.logpm.aftersales.vo.AftersalesWorkOrderVO; |
|
|
|
|
import com.logpm.aftersales.excel.AftersalesWorkOrderExcel; |
|
|
|
|
import com.logpm.aftersales.wrapper.AftersalesWorkOrderWrapper; |
|
|
|
|
import com.logpm.aftersales.service.IAftersalesWorkOrderService; |
|
|
|
|
import org.springblade.core.boot.ctrl.BladeController; |
|
|
|
|
import org.springblade.core.tool.utils.DateUtil; |
|
|
|
|
import org.springblade.core.excel.util.ExcelUtil; |
|
|
|
@ -62,12 +59,17 @@ import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
import springfox.documentation.annotations.ApiIgnore; |
|
|
|
|
|
|
|
|
|
import java.io.IOException; |
|
|
|
|
import java.math.BigDecimal; |
|
|
|
|
import java.text.SimpleDateFormat; |
|
|
|
|
import java.time.LocalDate; |
|
|
|
|
import java.time.temporal.ChronoUnit; |
|
|
|
|
import java.util.*; |
|
|
|
|
import java.util.concurrent.atomic.AtomicReference; |
|
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
|
|
|
|
|
|
|
import static io.vertx.sqlclient.data.NullValue.LocalDateTime; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 客服异常工单 控制器 |
|
|
|
|
* |
|
|
|
@ -86,6 +88,7 @@ public class AftersalesWorkOrderController extends BladeController {
|
|
|
|
|
private final IAftersalesCompletionRecordService aftersalesCompletionRecordService; |
|
|
|
|
private final IAftersalesPersonResponsibleService aftersalesPersonResponsibleService; |
|
|
|
|
private final IAftersaleSurveyRecordService aftersaleSurveyRecordService; |
|
|
|
|
private final IAftersalesCompletionRecipientService aftersalesCompletionRecipientService; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 客服异常工单 详情 |
|
|
|
@ -97,6 +100,7 @@ public class AftersalesWorkOrderController extends BladeController {
|
|
|
|
|
AftersalesWorkOrderEntity detail = aftersalesWorkOrderService.getOne(Condition.getQueryWrapper(aftersalesWorkOrder)); |
|
|
|
|
return R.data(AftersalesWorkOrderWrapper.build().entityVO(detail)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 客服异常工单 分页 |
|
|
|
|
*/ |
|
|
|
@ -228,8 +232,7 @@ public class AftersalesWorkOrderController extends BladeController {
|
|
|
|
|
} catch (ServiceException s) { |
|
|
|
|
log.error("查询客服人员信息>>>>{}", s.getMessage()); |
|
|
|
|
return R.fail(s.getMessage()); |
|
|
|
|
} |
|
|
|
|
catch(Exception e){ |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
log.error("查询客服人员信息>>>>{}", e.getMessage()); |
|
|
|
|
return R.fail("系统异常!!"); |
|
|
|
|
} |
|
|
|
@ -379,7 +382,6 @@ public class AftersalesWorkOrderController extends BladeController {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 客服异常工单 自定义分页 |
|
|
|
|
*/ |
|
|
|
@ -665,7 +667,6 @@ public class AftersalesWorkOrderController extends BladeController {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 客服异常工单 仓库查询待处理的异常工单 |
|
|
|
|
*/ |
|
|
|
@ -705,7 +706,6 @@ public class AftersalesWorkOrderController extends BladeController {
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 导出数据 |
|
|
|
|
* |
|
|
|
|
*/ |
|
|
|
|
@GetMapping("/export-aftersalesWorkOrder") |
|
|
|
|
@ApiOperationSupport(order = 9) |
|
|
|
@ -718,7 +718,6 @@ public class AftersalesWorkOrderController extends BladeController {
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 导出数据 |
|
|
|
|
* |
|
|
|
|
*/ |
|
|
|
|
@GetMapping("/exportWorkOrder") |
|
|
|
|
@ApiOperationSupport(order = 9) |
|
|
|
@ -731,19 +730,14 @@ public class AftersalesWorkOrderController extends BladeController {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 处理中导出数据 |
|
|
|
|
* |
|
|
|
|
*/ |
|
|
|
|
@GetMapping("/exportWorkOrder0") |
|
|
|
|
@ApiOperationSupport(order = 9) |
|
|
|
|
@ApiOperation(value = "导出数据", notes = "传入aftersalesWorkOrder") |
|
|
|
|
public void allExportWorkOrder(@ApiIgnore @RequestParam Map<String, Object> aftersalesWorkOrder, BladeUser bladeUser, HttpServletResponse response) { |
|
|
|
|
List<List<String>> basicTitle = aftersalesWorkOrderService.basicTitleBuild(); |
|
|
|
|
//查询数据
|
|
|
|
|
List<String> head1 = new ArrayList<>(Arrays.asList("总部处理客服")); |
|
|
|
|
basicTitle.add(head1); |
|
|
|
|
List<String> head2 = new ArrayList<>(Arrays.asList("处理结果")); |
|
|
|
|
basicTitle.add(head2); |
|
|
|
|
List<String> head3 = new ArrayList<>(Arrays.asList("理赔金额")); |
|
|
|
@ -756,6 +750,7 @@ public class AftersalesWorkOrderController extends BladeController {
|
|
|
|
|
basicTitle.add(head6); |
|
|
|
|
List<String> head7 = new ArrayList<>(Arrays.asList("钉钉号")); |
|
|
|
|
basicTitle.add(head7); |
|
|
|
|
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
|
|
|
|
|
|
|
|
|
List<AftersalesWorkOrderVO> exportData = aftersalesWorkOrderService.getBasicExportData(aftersalesWorkOrder); |
|
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
|
|
|
@ -778,7 +773,10 @@ public class AftersalesWorkOrderController extends BladeController {
|
|
|
|
|
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,""); |
|
|
|
|
Date createTime = exportDatum.getCreateTime(); |
|
|
|
|
Date updateTime = Objects.isNull(exportDatum.getUpdateTime()) ? new Date() : exportDatum.getUpdateTime(); |
|
|
|
|
int a = (int) ((updateTime.getTime() - createTime.getTime()) / (1000 * 3600 * 24)); |
|
|
|
|
data.add(15, a > 2 ? "是" : "否"); |
|
|
|
|
data.add(16, exportDatum.getCustomerServiceName()); |
|
|
|
|
data.add(17, exportDatum.getHeadquartersName()); |
|
|
|
|
data.add(18, exportDatum.getResultTypes()); |
|
|
|
@ -819,7 +817,6 @@ public class AftersalesWorkOrderController extends BladeController {
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 处理中导出数据 |
|
|
|
|
* |
|
|
|
|
*/ |
|
|
|
|
@GetMapping("/exportWorkOrder1") |
|
|
|
|
@ApiOperationSupport(order = 9) |
|
|
|
@ -831,6 +828,15 @@ public class AftersalesWorkOrderController extends BladeController {
|
|
|
|
|
List<AftersalesWorkOrderVO> exportData = aftersalesWorkOrderService.getBasicExportData(aftersalesWorkOrder); |
|
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
|
|
|
|
if (!exportData.isEmpty()) { |
|
|
|
|
List<AftersalesPersonResponsibleEntity> entityList = aftersalesPersonResponsibleService.list(Wrappers.<AftersalesPersonResponsibleEntity>query().lambda() |
|
|
|
|
.in(AftersalesPersonResponsibleEntity::getWordOrderId, exportData.stream().map(AftersalesWorkOrderVO::getId).collect(Collectors.toList())) |
|
|
|
|
.eq(AftersalesPersonResponsibleEntity::getTypesOf, "1") |
|
|
|
|
); |
|
|
|
|
Map<Long, List<AftersalesPersonResponsibleEntity>> personResponsibleMap = null; |
|
|
|
|
if (!entityList.isEmpty()) { |
|
|
|
|
personResponsibleMap = entityList.stream().collect(Collectors.groupingBy(AftersalesPersonResponsibleEntity::getWordOrderId)); |
|
|
|
|
handlePersonResponsibleTitle(basicTitle, personResponsibleMap); |
|
|
|
|
} |
|
|
|
|
List<List<String>> dataList = new ArrayList<>(); |
|
|
|
|
for (AftersalesWorkOrderVO exportDatum : exportData) { |
|
|
|
|
List<String> data = new ArrayList<>(); |
|
|
|
@ -849,14 +855,12 @@ public class AftersalesWorkOrderController extends BladeController {
|
|
|
|
|
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,""); |
|
|
|
|
data.add(16,""); |
|
|
|
|
//查询此工单是否存在有责任方如果存在有责任方完善表头
|
|
|
|
|
List<AftersalesPersonResponsibleEntity> entityList = aftersalesPersonResponsibleService.list(Wrappers.<AftersalesPersonResponsibleEntity>query().lambda() |
|
|
|
|
.eq(AftersalesPersonResponsibleEntity::getWordOrderId, exportDatum.getId()) |
|
|
|
|
.eq(AftersalesPersonResponsibleEntity::getTypesOf, "1") |
|
|
|
|
); |
|
|
|
|
if (!entityList.isEmpty()) { |
|
|
|
|
Date createTime = exportDatum.getCreateTime(); |
|
|
|
|
Date updateTime = Objects.isNull(exportDatum.getUpdateTime()) ? new Date() : exportDatum.getUpdateTime(); |
|
|
|
|
int a = (int) ((updateTime.getTime() - createTime.getTime()) / (1000 * 3600 * 24)); |
|
|
|
|
data.add(15, a > 2 ? "是" : "否"); |
|
|
|
|
data.add(16, exportDatum.getCustomerServiceName()); |
|
|
|
|
if (personResponsibleMap!= null && Objects.isNull(personResponsibleMap.get(exportDatum.getId()))) { |
|
|
|
|
handleResponsibility(basicTitle, entityList, data); |
|
|
|
|
} |
|
|
|
|
dataList.add(data); |
|
|
|
@ -883,7 +887,6 @@ public class AftersalesWorkOrderController extends BladeController {
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 处理中导出数据 |
|
|
|
|
* |
|
|
|
|
*/ |
|
|
|
|
@GetMapping("/exportWorkOrder2") |
|
|
|
|
@ApiOperationSupport(order = 9) |
|
|
|
@ -898,6 +901,15 @@ public class AftersalesWorkOrderController extends BladeController {
|
|
|
|
|
List<AftersalesWorkOrderVO> exportData = aftersalesWorkOrderService.getBasicExportData(aftersalesWorkOrder); |
|
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
|
|
|
|
if (!exportData.isEmpty()) { |
|
|
|
|
List<AftersalesPersonResponsibleEntity> entityList = aftersalesPersonResponsibleService.list(Wrappers.<AftersalesPersonResponsibleEntity>query().lambda() |
|
|
|
|
.in(AftersalesPersonResponsibleEntity::getWordOrderId, exportData.stream().map(AftersalesWorkOrderVO::getId).collect(Collectors.toList())) |
|
|
|
|
.eq(AftersalesPersonResponsibleEntity::getTypesOf, "1") |
|
|
|
|
); |
|
|
|
|
Map<Long, List<AftersalesPersonResponsibleEntity>> personResponsibleMap = null; |
|
|
|
|
if (!entityList.isEmpty()) { |
|
|
|
|
personResponsibleMap = entityList.stream().collect(Collectors.groupingBy(AftersalesPersonResponsibleEntity::getWordOrderId)); |
|
|
|
|
handlePersonResponsibleTitle(basicTitle, personResponsibleMap); |
|
|
|
|
} |
|
|
|
|
List<List<String>> dataList = new ArrayList<>(); |
|
|
|
|
for (AftersalesWorkOrderVO exportDatum : exportData) { |
|
|
|
|
List<String> data = new ArrayList<>(); |
|
|
|
@ -916,17 +928,17 @@ public class AftersalesWorkOrderController extends BladeController {
|
|
|
|
|
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,""); |
|
|
|
|
Date createTime = exportDatum.getCreateTime(); |
|
|
|
|
Date updateTime = Objects.isNull(exportDatum.getUpdateTime()) ? new Date() : exportDatum.getUpdateTime(); |
|
|
|
|
int a = (int) ((updateTime.getTime() - createTime.getTime()) / (1000 * 3600 * 24)); |
|
|
|
|
data.add(15, a > 2 ? "是" : "否"); |
|
|
|
|
data.add(16, ""); |
|
|
|
|
data.add(17, exportDatum.getResultTypes()); |
|
|
|
|
data.add(18, exportDatum.getTotalAmountNum()); |
|
|
|
|
//查询此工单是否存在有责任方如果存在有责任方完善表头
|
|
|
|
|
List<AftersalesPersonResponsibleEntity> entityList = aftersalesPersonResponsibleService.list(Wrappers.<AftersalesPersonResponsibleEntity>query().lambda() |
|
|
|
|
.eq(AftersalesPersonResponsibleEntity::getWordOrderId, exportDatum.getId()) |
|
|
|
|
.eq(AftersalesPersonResponsibleEntity::getTypesOf, "1") |
|
|
|
|
); |
|
|
|
|
if (!entityList.isEmpty()) { |
|
|
|
|
handleResponsibility(basicTitle,entityList,data); |
|
|
|
|
|
|
|
|
|
if (personResponsibleMap!= null && !Objects.isNull(personResponsibleMap.get(exportDatum.getId()))) { |
|
|
|
|
handleResponsibility(basicTitle, personResponsibleMap.get(exportDatum.getId()), data); |
|
|
|
|
} |
|
|
|
|
dataList.add(data); |
|
|
|
|
} |
|
|
|
@ -950,19 +962,14 @@ public class AftersalesWorkOrderController extends BladeController {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 处理中导出数据 |
|
|
|
|
* |
|
|
|
|
*/ |
|
|
|
|
@GetMapping("/exportWorkOrder3") |
|
|
|
|
@ApiOperationSupport(order = 9) |
|
|
|
|
@ApiOperation(value = "导出数据", notes = "传入aftersalesWorkOrder") |
|
|
|
|
public void processingCompletedExportWorkOrder(@ApiIgnore @RequestParam Map<String, Object> aftersalesWorkOrder, BladeUser bladeUser, HttpServletResponse response) { |
|
|
|
|
List<List<String>> basicTitle = aftersalesWorkOrderService.basicTitleBuild(); |
|
|
|
|
//查询数据
|
|
|
|
|
List<String> head1 = new ArrayList<>(Arrays.asList("营业部处理客服")); |
|
|
|
|
basicTitle.add(head1); |
|
|
|
|
List<String> head2 = new ArrayList<>(Arrays.asList("处理结果")); |
|
|
|
|
basicTitle.add(head2); |
|
|
|
|
List<String> head3 = new ArrayList<>(Arrays.asList("理赔金额")); |
|
|
|
@ -970,6 +977,15 @@ public class AftersalesWorkOrderController extends BladeController {
|
|
|
|
|
List<AftersalesWorkOrderVO> exportData = aftersalesWorkOrderService.getBasicExportData(aftersalesWorkOrder); |
|
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
|
|
|
|
if (!exportData.isEmpty()) { |
|
|
|
|
List<AftersalesPersonResponsibleEntity> entityList = aftersalesPersonResponsibleService.list(Wrappers.<AftersalesPersonResponsibleEntity>query().lambda() |
|
|
|
|
.in(AftersalesPersonResponsibleEntity::getWordOrderId, exportData.stream().map(AftersalesWorkOrderVO::getId).collect(Collectors.toList())) |
|
|
|
|
.eq(AftersalesPersonResponsibleEntity::getTypesOf, "1") |
|
|
|
|
); |
|
|
|
|
Map<Long, List<AftersalesPersonResponsibleEntity>> personResponsibleMap = null; |
|
|
|
|
if (!entityList.isEmpty()) { |
|
|
|
|
personResponsibleMap = entityList.stream().collect(Collectors.groupingBy(AftersalesPersonResponsibleEntity::getWordOrderId)); |
|
|
|
|
handlePersonResponsibleTitle(basicTitle, personResponsibleMap); |
|
|
|
|
} |
|
|
|
|
List<List<String>> dataList = new ArrayList<>(); |
|
|
|
|
for (AftersalesWorkOrderVO exportDatum : exportData) { |
|
|
|
|
List<String> data = new ArrayList<>(); |
|
|
|
@ -988,18 +1004,18 @@ public class AftersalesWorkOrderController extends BladeController {
|
|
|
|
|
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,""); |
|
|
|
|
Date createTime = exportDatum.getCreateTime(); |
|
|
|
|
Date updateTime = Objects.isNull(exportDatum.getUpdateTime()) ? new Date() : exportDatum.getUpdateTime(); |
|
|
|
|
int a = (int) ((updateTime.getTime() - createTime.getTime()) / (1000 * 3600 * 24)); |
|
|
|
|
data.add(15, a > 2 ? "是" : "否"); |
|
|
|
|
data.add(16, exportDatum.getCustomerServiceName()); |
|
|
|
|
data.add(17, exportDatum.getHeadquartersName()); |
|
|
|
|
data.add(18, exportDatum.getResultTypes()); |
|
|
|
|
data.add(19, exportDatum.getTotalAmountNum()); |
|
|
|
|
//查询此工单是否存在有责任方如果存在有责任方完善表头
|
|
|
|
|
List<AftersalesPersonResponsibleEntity> entityList = aftersalesPersonResponsibleService.list(Wrappers.<AftersalesPersonResponsibleEntity>query().lambda() |
|
|
|
|
.eq(AftersalesPersonResponsibleEntity::getWordOrderId, exportDatum.getId()) |
|
|
|
|
.eq(AftersalesPersonResponsibleEntity::getTypesOf, "1") |
|
|
|
|
); |
|
|
|
|
if (!entityList.isEmpty()) { |
|
|
|
|
handleResponsibility(basicTitle,entityList,data); |
|
|
|
|
|
|
|
|
|
if (personResponsibleMap!= null && !Objects.isNull(personResponsibleMap.get(exportDatum.getId()))) { |
|
|
|
|
handleResponsibility(basicTitle, personResponsibleMap.get(exportDatum.getId()), data); |
|
|
|
|
} |
|
|
|
|
dataList.add(data); |
|
|
|
|
} |
|
|
|
@ -1022,30 +1038,184 @@ public class AftersalesWorkOrderController extends BladeController {
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void handleResponsibility(List<List<String>> basicTitle, List<AftersalesPersonResponsibleEntity> entityList, List<String> data) { |
|
|
|
|
Long wordOrderId = entityList.get(0).getWordOrderId(); |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 完结导出 |
|
|
|
|
*/ |
|
|
|
|
@GetMapping("/exportWorkOrder4") |
|
|
|
|
@ApiOperationSupport(order = 9) |
|
|
|
|
@ApiOperation(value = "导出数据", notes = "传入aftersalesWorkOrder") |
|
|
|
|
public void endExportWorkOrder(@ApiIgnore @RequestParam Map<String, Object> aftersalesWorkOrder, BladeUser bladeUser, HttpServletResponse response) { |
|
|
|
|
List<List<String>> basicTitle = aftersalesWorkOrderService.basicTitleBuild(); |
|
|
|
|
//查询数据
|
|
|
|
|
List<String> head2 = new ArrayList<>(Arrays.asList("处理结果")); |
|
|
|
|
basicTitle.add(head2); |
|
|
|
|
List<String> head3 = new ArrayList<>(Arrays.asList("理赔金额")); |
|
|
|
|
basicTitle.add(head3); |
|
|
|
|
basicTitle.add(Arrays.asList("最新消息回复内容")); |
|
|
|
|
List<AftersalesWorkOrderVO> exportData = aftersalesWorkOrderService.getBasicExportData(aftersalesWorkOrder); |
|
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
|
|
|
|
if (!exportData.isEmpty()) { |
|
|
|
|
//查询最新消息
|
|
|
|
|
List<AftersaleSurveyRecordEntity> recordEntities = aftersaleSurveyRecordService.list(Wrappers.<AftersaleSurveyRecordEntity>query().lambda() |
|
|
|
|
.eq(AftersaleSurveyRecordEntity::getWorkOrderId, wordOrderId) |
|
|
|
|
.eq(AftersaleSurveyRecordEntity::getWorkOrderId, exportData.stream().map(AftersalesWorkOrderVO::getId).collect(Collectors.toList())) |
|
|
|
|
.orderByDesc(AftersaleSurveyRecordEntity::getCreateTime) |
|
|
|
|
); |
|
|
|
|
if (!recordEntities.isEmpty()) { |
|
|
|
|
int size = 0; |
|
|
|
|
if (!basicTitle.contains(Arrays.asList("最新消息回复内容")) ){ |
|
|
|
|
List<String> head5 = new ArrayList<>(Arrays.asList("最新消息回复内容")); |
|
|
|
|
size = basicTitle.size(); |
|
|
|
|
basicTitle.add(size,head5); |
|
|
|
|
//查询此工单是否存在有责任方如果存在有责任方完善表头
|
|
|
|
|
List<AftersalesPersonResponsibleEntity> entityList = aftersalesPersonResponsibleService.list(Wrappers.<AftersalesPersonResponsibleEntity>query().lambda() |
|
|
|
|
.in(AftersalesPersonResponsibleEntity::getWordOrderId, exportData.stream().map(AftersalesWorkOrderVO::getId).collect(Collectors.toList())) |
|
|
|
|
.eq(AftersalesPersonResponsibleEntity::getTypesOf, "1") |
|
|
|
|
); |
|
|
|
|
Map<Long, List<AftersalesPersonResponsibleEntity>> personResponsibleMap = null; |
|
|
|
|
Map<Long, List<AftersalesCompletionRecordEntity>> completionRecordleMap = null; |
|
|
|
|
Map<Long, List<AftersalesCompletionRecipientEntity>> completionRecipientleMap = null; |
|
|
|
|
if (!entityList.isEmpty()) { |
|
|
|
|
personResponsibleMap = entityList.stream().collect(Collectors.groupingBy(AftersalesPersonResponsibleEntity::getWordOrderId)); |
|
|
|
|
handlePersonResponsibleTitle(basicTitle, personResponsibleMap); |
|
|
|
|
} |
|
|
|
|
//查询赔款方
|
|
|
|
|
List<AftersalesCompletionRecordEntity> aftersalesCompletionRecordEntityList = aftersalesCompletionRecordService.list(Wrappers.<AftersalesCompletionRecordEntity>query().lambda() |
|
|
|
|
.in(AftersalesCompletionRecordEntity::getWorkOrderId, exportData.stream().map(AftersalesWorkOrderVO::getId).collect(Collectors.toList())) |
|
|
|
|
); |
|
|
|
|
if (!aftersalesCompletionRecordEntityList.isEmpty()) { |
|
|
|
|
completionRecordleMap = aftersalesCompletionRecordEntityList.stream().collect(Collectors.groupingBy(AftersalesCompletionRecordEntity::getWorkOrderId)); |
|
|
|
|
handlePersonCompletionRecordTitle(basicTitle, completionRecordleMap); |
|
|
|
|
} |
|
|
|
|
List<AftersalesCompletionRecipientEntity> aftersalesCompletionRecipientEntityList = aftersalesCompletionRecipientService.list(Wrappers.<AftersalesCompletionRecipientEntity>query().lambda() |
|
|
|
|
.in(AftersalesCompletionRecipientEntity::getWorkOrderId, exportData.stream().map(AftersalesWorkOrderVO::getId).collect(Collectors.toList())) |
|
|
|
|
); |
|
|
|
|
if (!aftersalesCompletionRecipientEntityList.isEmpty()) { |
|
|
|
|
completionRecipientleMap = aftersalesCompletionRecipientEntityList.stream().collect(Collectors.groupingBy(AftersalesCompletionRecipientEntity::getWorkOrderId)); |
|
|
|
|
handlePersonCompletionRecipientTitle(basicTitle, completionRecipientleMap); |
|
|
|
|
|
|
|
|
|
}else { |
|
|
|
|
size = basicTitle.indexOf(Arrays.asList("最新消息回复内容")); |
|
|
|
|
} |
|
|
|
|
data.add(size,recordEntities.get(0).getContent()); |
|
|
|
|
|
|
|
|
|
List<List<String>> dataList = new ArrayList<>(); |
|
|
|
|
for (AftersalesWorkOrderVO exportDatum : exportData) { |
|
|
|
|
List<String> 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())); |
|
|
|
|
Date createTime = exportDatum.getCreateTime(); |
|
|
|
|
Date updateTime = Objects.isNull(exportDatum.getUpdateTime()) ? new Date() : exportDatum.getUpdateTime(); |
|
|
|
|
int a = (int) ((updateTime.getTime() - createTime.getTime()) / (1000 * 3600 * 24)); |
|
|
|
|
data.add(15, a > 2 ? "是" : "否"); |
|
|
|
|
data.add(16, exportDatum.getCustomerServiceName()); |
|
|
|
|
data.add(17, exportDatum.getHeadquartersName()); |
|
|
|
|
data.add(18, exportDatum.getResultTypes()); |
|
|
|
|
data.add(19, exportDatum.getTotalAmountNum()); |
|
|
|
|
|
|
|
|
|
if (personResponsibleMap!=null){ |
|
|
|
|
if (!Objects.isNull(personResponsibleMap.get(exportDatum.getId()))) { |
|
|
|
|
handleResponsibility(basicTitle, personResponsibleMap.get(exportDatum.getId()), data); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if (completionRecordleMap!=null){ |
|
|
|
|
if (!Objects.isNull(completionRecordleMap.get(exportDatum.getId()))) { |
|
|
|
|
handleCompletionRecord(basicTitle, completionRecordleMap.get(exportDatum.getId()), data); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (completionRecipientleMap!=null){ |
|
|
|
|
if (!Objects.isNull(completionRecipientleMap.get(exportDatum.getId()))) { |
|
|
|
|
handleCompletionRecipientEntity(basicTitle, completionRecipientleMap.get(exportDatum.getId()), data); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
dataList.add(data); |
|
|
|
|
} |
|
|
|
|
ServletOutputStream os = null; |
|
|
|
|
try { |
|
|
|
|
os = response.getOutputStream(); |
|
|
|
|
ExcelWriter excelWriter = EasyExcel.write(os).build(); |
|
|
|
|
|
|
|
|
|
WriteSheet sheet = EasyExcel.writerSheet() |
|
|
|
|
// 这里放入动态头
|
|
|
|
|
.head(basicTitle) |
|
|
|
|
// 当然这里数据也可以用 List<List<String>> 去传入
|
|
|
|
|
.build(); |
|
|
|
|
excelWriter.write(dataList, sheet); |
|
|
|
|
excelWriter.finish(); |
|
|
|
|
} catch (IOException e) { |
|
|
|
|
throw new RuntimeException(e); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void handlePersonCompletionRecipientTitle(List<List<String>> basicTitle, Map<Long, List<AftersalesCompletionRecipientEntity>> listMap) { |
|
|
|
|
|
|
|
|
|
int aa = 0; |
|
|
|
|
Map<Long, List<AftersalesPersonResponsibleEntity>> listMap = entityList.stream().collect(Collectors.groupingBy(AftersalesPersonResponsibleEntity::getWordOrderId)); |
|
|
|
|
for (Long l : listMap.keySet()) { |
|
|
|
|
List<AftersalesCompletionRecipientEntity> aftersalesCompletionRecipientEntities = listMap.get(l); |
|
|
|
|
aa = Math.max(aa, aftersalesCompletionRecipientEntities.size()); |
|
|
|
|
} |
|
|
|
|
for (int i = 0; i < aa; i++) { |
|
|
|
|
if (!basicTitle.contains(Arrays.asList("受款方" + (i + 1)))) { |
|
|
|
|
List<String> head1 = new ArrayList<>(Arrays.asList("受款方" + (i + 1))); |
|
|
|
|
basicTitle.add(basicTitle.size(), head1); |
|
|
|
|
} |
|
|
|
|
if (!basicTitle.contains(Arrays.asList("受款原因" + (i + 1)))) { |
|
|
|
|
List<String> head2 = new ArrayList<>(Arrays.asList("受款原因" + (i + 1))); |
|
|
|
|
basicTitle.add(basicTitle.size(), head2); |
|
|
|
|
} |
|
|
|
|
if (!basicTitle.contains(Arrays.asList("受款金额" + (i + 1)))) { |
|
|
|
|
List<String> head3 = new ArrayList<>(Arrays.asList("受款金额" + (i + 1))); |
|
|
|
|
basicTitle.add(basicTitle.size(), head3); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
if (!basicTitle.contains(Arrays.asList("受款方金额总和"))) { |
|
|
|
|
List<String> head4 = new ArrayList<>(Arrays.asList("受款方金额总和")); |
|
|
|
|
basicTitle.add(basicTitle.size(), head4); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void handlePersonCompletionRecordTitle(List<List<String>> basicTitle, Map<Long, List<AftersalesCompletionRecordEntity>> listMap) { |
|
|
|
|
int aa = 0; |
|
|
|
|
for (Long l : listMap.keySet()) { |
|
|
|
|
|
|
|
|
|
List<AftersalesCompletionRecordEntity> aftersalesCompletionRecordEntities = listMap.get(l); |
|
|
|
|
aa = Math.max(aa, aftersalesCompletionRecordEntities.size()); |
|
|
|
|
} |
|
|
|
|
for (int i = 0; i < aa; i++) { |
|
|
|
|
if (!basicTitle.contains(Arrays.asList("赔款方" + (i + 1)))) { |
|
|
|
|
List<String> head1 = new ArrayList<>(Arrays.asList("赔款方" + (i + 1))); |
|
|
|
|
basicTitle.add(basicTitle.size(), head1); |
|
|
|
|
} |
|
|
|
|
if (!basicTitle.contains(Arrays.asList("赔款原因" + (i + 1)))) { |
|
|
|
|
List<String> head2 = new ArrayList<>(Arrays.asList("赔款原因" + (i + 1))); |
|
|
|
|
basicTitle.add(basicTitle.size(), head2); |
|
|
|
|
} |
|
|
|
|
if (!basicTitle.contains(Arrays.asList("赔款金额" + (i + 1)))) { |
|
|
|
|
List<String> head3 = new ArrayList<>(Arrays.asList("赔款金额" + (i + 1))); |
|
|
|
|
basicTitle.add(basicTitle.size(), head3); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
if (!basicTitle.contains(Arrays.asList("赔款方金额总和"))) { |
|
|
|
|
List<String> head4 = new ArrayList<>(Arrays.asList("赔款方金额总和")); |
|
|
|
|
basicTitle.add(basicTitle.size(), head4); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void handlePersonResponsibleTitle(List<List<String>> basicTitle, Map<Long, List<AftersalesPersonResponsibleEntity>> listMap) { |
|
|
|
|
int aa = 0; |
|
|
|
|
for (Long l : listMap.keySet()) { |
|
|
|
|
List<AftersalesPersonResponsibleEntity> aftersalesPersonResponsibleEntities = listMap.get(l); |
|
|
|
|
aa = Math.max(aa, aftersalesPersonResponsibleEntities.size()); |
|
|
|
|
} |
|
|
|
@ -1066,18 +1236,93 @@ public class AftersalesWorkOrderController extends BladeController {
|
|
|
|
|
List<String> head4 = new ArrayList<>(Arrays.asList("金额" + (i + 1))); |
|
|
|
|
basicTitle.add(basicTitle.size(), head4); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if (!basicTitle.contains(Arrays.asList("责任方金额总和"))) { |
|
|
|
|
List<String> head4 = new ArrayList<>(Arrays.asList("责任方金额总和")); |
|
|
|
|
basicTitle.add(basicTitle.size(), head4); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void handleResponsibility(List<List<String>> basicTitle, List<AftersalesPersonResponsibleEntity> entityList, List<String> data) { |
|
|
|
|
// Long wordOrderId = entityList.get(0).getWordOrderId();
|
|
|
|
|
BigDecimal bigDecimal = BigDecimal.ZERO; |
|
|
|
|
for (int i = 0; i < entityList.size(); i++) { |
|
|
|
|
int index = basicTitle.indexOf(Arrays.asList("责任方"+ (i + 1))); |
|
|
|
|
int i1 = index - data.size(); |
|
|
|
|
for (int i2 = 0; i2 < i1; i2++) { |
|
|
|
|
data.add(""); |
|
|
|
|
} |
|
|
|
|
data.add(basicTitle.indexOf(Arrays.asList("责任方" + (i + 1))), entityList.get(i).getBusinessName()); |
|
|
|
|
data.add(basicTitle.indexOf(Arrays.asList("责任人" + (i + 1))), entityList.get(i).getPersonResponsibleName()); |
|
|
|
|
data.add(basicTitle.indexOf(Arrays.asList("三方责任人" + (i + 1))), entityList.get(i).getTripartite()); |
|
|
|
|
data.add(basicTitle.indexOf(Arrays.asList("金额" + (i + 1))), entityList.get(i).getResponsibilityRatio()); |
|
|
|
|
bigDecimal = bigDecimal.add(new BigDecimal(entityList.get(i).getResponsibilityRatio())); |
|
|
|
|
} |
|
|
|
|
int index = basicTitle.indexOf(Arrays.asList("责任方金额总和")); |
|
|
|
|
int i1 = index - data.size(); |
|
|
|
|
if (index > data.size()) { |
|
|
|
|
for (int i = 0; i < i1; i++) { |
|
|
|
|
data.add(""); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
data.add(basicTitle.indexOf(Arrays.asList("责任方金额总和")), String.valueOf(bigDecimal)); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void handleCompletionRecord(List<List<String>> basicTitle, List<AftersalesCompletionRecordEntity> entityList, List<String> data) { |
|
|
|
|
|
|
|
|
|
BigDecimal responsibleMoney = BigDecimal.ZERO; |
|
|
|
|
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()); |
|
|
|
|
int i1 = basicTitle.indexOf(Arrays.asList("赔款方" + (i + 1))); |
|
|
|
|
if (i1>data.size()){ |
|
|
|
|
int i2 = i1 - data.size(); |
|
|
|
|
for (int i3 = 0; i3 < i2; i3++) { |
|
|
|
|
data.add(""); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
data.add(basicTitle.indexOf(Arrays.asList("赔款方" + (i + 1))), entityList.get(i).getIndemnitor()); |
|
|
|
|
data.add(basicTitle.indexOf(Arrays.asList("赔款原因" + (i + 1))), entityList.get(i).getReason()); |
|
|
|
|
BigDecimal money = entityList.get(i).getMoney(); |
|
|
|
|
data.add(basicTitle.indexOf(Arrays.asList("赔款金额" + (i + 1))), String.valueOf(responsibleMoney)); |
|
|
|
|
responsibleMoney = responsibleMoney.add(money); |
|
|
|
|
} |
|
|
|
|
int i1 = basicTitle.indexOf(Arrays.asList("赔款方金额总和" )); |
|
|
|
|
if (i1>data.size()){ |
|
|
|
|
int i2 = i1 - data.size(); |
|
|
|
|
for (int i3 = 0; i3 < i2; i3++) { |
|
|
|
|
data.add(""); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
data.add(basicTitle.indexOf(Arrays.asList("赔款方金额总和")), String.valueOf(responsibleMoney)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void handleCompletionRecipientEntity(List<List<String>> basicTitle, List<AftersalesCompletionRecipientEntity> entityList, List<String> data) { |
|
|
|
|
BigDecimal recipientMoney = BigDecimal.ZERO; |
|
|
|
|
for (int i = 0; i < entityList.size(); i++) { |
|
|
|
|
int i1 = basicTitle.indexOf(Arrays.asList("受款方" + (i + 1))); |
|
|
|
|
if (i1>data.size()){ |
|
|
|
|
int i2 = i1 - data.size(); |
|
|
|
|
for (int i3 = 0; i3 < i2; i3++) { |
|
|
|
|
data.add(""); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
data.add(basicTitle.indexOf(Arrays.asList("受款方" + (i + 1))), entityList.get(i).getRecipient()); |
|
|
|
|
data.add(basicTitle.indexOf(Arrays.asList("受款原因" + (i + 1))), entityList.get(i).getReasonReceivingPayment()); |
|
|
|
|
BigDecimal money = entityList.get(i).getMoney(); |
|
|
|
|
recipientMoney = recipientMoney.add(money); |
|
|
|
|
data.add(basicTitle.indexOf(Arrays.asList("受款金额" + (i + 1))), String.valueOf(recipientMoney)); |
|
|
|
|
} |
|
|
|
|
int i1 = basicTitle.indexOf(Arrays.asList("受款方金额总和" )); |
|
|
|
|
if (i1>data.size()){ |
|
|
|
|
int i2 = i1 - data.size(); |
|
|
|
|
for (int i3 = 0; i3 < i2; i3++) { |
|
|
|
|
data.add(""); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
data.add(basicTitle.indexOf(Arrays.asList("受款方金额总和")), String.valueOf(recipientMoney)); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|