|
|
@@ -1,23 +1,43 @@
|
|
|
package com.yr.warehouse.admin.web.driver.controller;
|
|
|
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import com.supplychain.api.response.areastaff.AreaStaffResponse;
|
|
|
+import com.yr.bluecat.common.entity.exception.MessageException;
|
|
|
import com.yr.bluecat.common.entity.response.PageResult;
|
|
|
import com.yr.bluecat.common.entity.response.Result;
|
|
|
+import com.yr.bluecat.common.entity.utils.StringUtils;
|
|
|
+import com.yr.bluecat.common.utils.excel.ExportClient;
|
|
|
import com.yr.prism.auth.core.user.AdminUserInfo;
|
|
|
-import com.yr.warehouse.admin.driver.bo.DriverIntervalCargoDamageDetailExportBo;
|
|
|
-import com.yr.warehouse.admin.driver.bo.DriverIntervalCargoDamageDetailPageBo;
|
|
|
-import com.yr.warehouse.admin.driver.bo.DriverIntervalCargoDamageGeneratorBo;
|
|
|
-import com.yr.warehouse.admin.driver.bo.DriverIntervalCargoDamagePageBo;
|
|
|
+import com.yr.warehouse.admin.component.areastaff.AreaStaffComponent;
|
|
|
+import com.yr.warehouse.admin.component.auth.OperatorComponent;
|
|
|
+import com.yr.warehouse.admin.component.auth.vo.OrgOperatorVo;
|
|
|
+import com.yr.warehouse.admin.driver.bo.*;
|
|
|
+import com.yr.warehouse.admin.driver.data.DriverGoodsLossIntervalMain;
|
|
|
+import com.yr.warehouse.admin.driver.face.DriverIntervalCargoDamageDetailSearchFace;
|
|
|
+import com.yr.warehouse.admin.driver.vo.DriverIntervalCargoDamageDetailVo;
|
|
|
+import com.yr.warehouse.admin.driver.vo.DriverIntervalCargoDamageVo;
|
|
|
+import com.yr.warehouse.admin.service.areastaff.AreaStaffService;
|
|
|
+import com.yr.warehouse.admin.service.driver.DriverGoodsLossIntervalDetailService;
|
|
|
+import com.yr.warehouse.admin.service.driver.DriverGoodsLossIntervalMainService;
|
|
|
+import com.yr.warehouse.admin.service.driver.DriverOnRouteAccountRecordService;
|
|
|
import com.yr.warehouse.admin.web.common.BaseController;
|
|
|
+import com.yr.warehouse.admin.web.driver.export.DriverIntervalCargoDamageDetailExport;
|
|
|
import com.yr.warehouse.admin.web.driver.mapstruct.DriverIntervalCargoDamageMapStruct;
|
|
|
import com.yr.warehouse.admin.web.driver.request.*;
|
|
|
-import com.yr.warehouse.admin.web.driver.response.DriverIntervalCargoDamageDetailPageResponse;
|
|
|
-import com.yr.warehouse.admin.web.driver.response.DriverIntervalCargoDamagePageResponse;
|
|
|
+import com.yr.warehouse.admin.web.driver.response.DriverIntervalCargoDamageDetailResponse;
|
|
|
+import com.yr.warehouse.admin.web.driver.response.DriverIntervalCargoDamageResponse;
|
|
|
import com.yr.warehouse.admin.web.driver.response.DriverRouteAccountRecordMainResponse;
|
|
|
import com.yr.warehouse.admin.web.driver.response.DriverRouteDetailResponse;
|
|
|
+import jakarta.annotation.Resource;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
+import java.time.LocalDateTime;
|
|
|
+import java.time.format.DateTimeFormatter;
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* 司机区间货损
|
|
|
@@ -26,87 +46,196 @@ import java.util.List;
|
|
|
@RequestMapping("/driver/interval/cargoDamage")
|
|
|
public class DriverIntervalCargoDamageController extends BaseController {
|
|
|
|
|
|
+ @Resource
|
|
|
+ private DriverGoodsLossIntervalMainService driverGoodsLossIntervalMainService;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private DriverGoodsLossIntervalDetailService driverGoodsLossIntervalDetailService;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private DriverOnRouteAccountRecordService driverOnRouteAccountRecordService;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private AreaStaffComponent areaStaffComponent;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private OperatorComponent operatorComponent;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private AreaStaffService areaStaffService;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private ExportClient exportClient;
|
|
|
+
|
|
|
/**
|
|
|
* 查询运营商对应的区间货损最后统计时间
|
|
|
- * @return
|
|
|
*/
|
|
|
@GetMapping("/searchLastTotalTime/{operatorId}")
|
|
|
@ResponseBody
|
|
|
- public Result<String> searchLastTotalTime(@PathVariable("operatorId") Long operatorId, AdminUserInfo adminUserInfo) {
|
|
|
- return null;
|
|
|
+ public Result<String> searchLastTotalTime(@PathVariable("operatorId") Long operatorId) {
|
|
|
+ LocalDateTime localDateTime = driverGoodsLossIntervalMainService.searchLastTotalTime(operatorId);
|
|
|
+ return Result.success(localDateTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 生成区间统计记录
|
|
|
- * @return
|
|
|
*/
|
|
|
@PostMapping("/generator")
|
|
|
@ResponseBody
|
|
|
public Result<String> generator(@Validated @RequestBody DriverIntervalCargoDamageGeneratorRequest request, AdminUserInfo adminUserInfo) {
|
|
|
DriverIntervalCargoDamageGeneratorBo bo = DriverIntervalCargoDamageMapStruct.MAPSTRUCT.generatorRequestToBo(request);
|
|
|
buildUserInfo(bo, adminUserInfo);
|
|
|
+
|
|
|
+
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 分页查询区间生成统计记录
|
|
|
- * @return
|
|
|
*/
|
|
|
@PostMapping("/page")
|
|
|
@ResponseBody
|
|
|
- public PageResult<DriverIntervalCargoDamagePageResponse> page(@Validated @RequestBody DriverIntervalCargoDamagePageRequest request, AdminUserInfo adminUserInfo) {
|
|
|
+ public PageResult<DriverIntervalCargoDamageResponse> page(@Validated @RequestBody DriverIntervalCargoDamagePageRequest request, AdminUserInfo adminUserInfo) {
|
|
|
DriverIntervalCargoDamagePageBo bo = DriverIntervalCargoDamageMapStruct.MAPSTRUCT.pageRequestToBo(request);
|
|
|
buildUserInfo(bo, adminUserInfo);
|
|
|
- return null;
|
|
|
+ if (StringUtils.isNotBlank(bo.getAreaStaffName())) {
|
|
|
+ List<AreaStaffResponse> areaStaffResponses = areaStaffComponent.searchByOperatorIdAndAreaStaffName(bo.getOperatorId(), bo.getAreaStaffName());
|
|
|
+ bo.setAreaStaffIds(areaStaffResponses.stream().map(AreaStaffResponse::getId).toList());
|
|
|
+ }
|
|
|
+ Page<DriverIntervalCargoDamageVo> page = driverGoodsLossIntervalMainService.searchForPage(bo);
|
|
|
+
|
|
|
+ PageResult<DriverIntervalCargoDamageResponse> pageResult = PageResult.newPageResult(request.getPageNum(), request.getPageSize());
|
|
|
+
|
|
|
+ List<DriverIntervalCargoDamageVo> driverIntervalCargoDamageVos = page.getRecords();
|
|
|
+ if (null == driverIntervalCargoDamageVos || driverIntervalCargoDamageVos.isEmpty()) {
|
|
|
+ return pageResult.success(0, new ArrayList<>());
|
|
|
+ }
|
|
|
+
|
|
|
+ List<Long> operatorIds = driverIntervalCargoDamageVos.stream().map(DriverIntervalCargoDamageVo::getOperatorId).collect(Collectors.toList());
|
|
|
+ Map<Long, OrgOperatorVo> operatorMap = operatorComponent.queryOperatorMapByIdList(operatorIds);
|
|
|
+ driverIntervalCargoDamageVos.forEach(driverIntervalCargoDamageVo -> {
|
|
|
+ OrgOperatorVo operatorVo = operatorMap.get(driverIntervalCargoDamageVo.getOperatorId());
|
|
|
+ if (null != operatorVo) {
|
|
|
+ driverIntervalCargoDamageVo.setOperatorName(operatorVo.getOperatorName());
|
|
|
+ driverIntervalCargoDamageVo.setOperatorChainName(operatorVo.getOperatorChainName());
|
|
|
+ }
|
|
|
+ });
|
|
|
+ List<DriverIntervalCargoDamageResponse> driverIntervalCargoDamageRespons = DriverIntervalCargoDamageMapStruct.MAPSTRUCT.voListToPageResponseList(driverIntervalCargoDamageVos);
|
|
|
+ return pageResult.success(page.getTotal(), driverIntervalCargoDamageRespons);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 区间生成统计记录详情分页查询
|
|
|
- * @return
|
|
|
*/
|
|
|
@PostMapping("/detail/page")
|
|
|
@ResponseBody
|
|
|
- public PageResult<DriverIntervalCargoDamageDetailPageResponse> detailPage(@Validated @RequestBody DriverIntervalCargoDamageDetailPageRequest request, AdminUserInfo adminUserInfo) {
|
|
|
+ public PageResult<DriverIntervalCargoDamageDetailResponse> detailPage(@Validated @RequestBody DriverIntervalCargoDamageDetailPageRequest request, AdminUserInfo adminUserInfo) {
|
|
|
DriverIntervalCargoDamageDetailPageBo bo = DriverIntervalCargoDamageMapStruct.MAPSTRUCT.detailPageRequestToBo(request);
|
|
|
buildUserInfo(bo, adminUserInfo);
|
|
|
- return null;
|
|
|
+
|
|
|
+ extractedAreaStaffSearchParam(bo);
|
|
|
+
|
|
|
+ PageResult<DriverIntervalCargoDamageDetailResponse> pageResult = PageResult.newPageResult(request.getPageNum(), request.getPageSize());
|
|
|
+
|
|
|
+ Page<DriverIntervalCargoDamageDetailVo> page = driverGoodsLossIntervalDetailService.searchForPage(bo);
|
|
|
+ List<DriverIntervalCargoDamageDetailVo> driverIntervalCargoDamageDetailVos = page.getRecords();
|
|
|
+ if (null == driverIntervalCargoDamageDetailVos || driverIntervalCargoDamageDetailVos.isEmpty()) {
|
|
|
+ return pageResult.success(0, new ArrayList<>());
|
|
|
+ }
|
|
|
+
|
|
|
+ Map<Long, AreaStaffResponse> areaStaffMap = areaStaffService.searchAreaStaffMap(driverIntervalCargoDamageDetailVos);
|
|
|
+ driverIntervalCargoDamageDetailVos.forEach(driverIntervalCargoDamageDetailVo -> {
|
|
|
+ AreaStaffResponse areaStaffResponse = areaStaffMap.get(driverIntervalCargoDamageDetailVo.getAreaStaffId());
|
|
|
+ if (null != areaStaffResponse) {
|
|
|
+ driverIntervalCargoDamageDetailVo.setAreaStaffName(areaStaffResponse.getEmployeeName());
|
|
|
+ }
|
|
|
+ });
|
|
|
+ List<DriverIntervalCargoDamageDetailResponse> driverIntervalCargoDamageDetailResponses = DriverIntervalCargoDamageMapStruct.MAPSTRUCT.detailVoListToDetailResponseList(driverIntervalCargoDamageDetailVos);
|
|
|
+ return pageResult.success(page.getTotal(), driverIntervalCargoDamageDetailResponses);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 导出区间生成统计记录详情
|
|
|
- * @return
|
|
|
*/
|
|
|
@PostMapping("/detail/export")
|
|
|
@ResponseBody
|
|
|
public Result<String> detailExport(@Validated @RequestBody DriverIntervalCargoDamageDetailExportRequest request, AdminUserInfo adminUserInfo) {
|
|
|
DriverIntervalCargoDamageDetailExportBo bo = DriverIntervalCargoDamageMapStruct.MAPSTRUCT.detailExportRequestToBo(request);
|
|
|
buildUserInfo(bo, adminUserInfo);
|
|
|
- return null;
|
|
|
+
|
|
|
+ extractedAreaStaffSearchParam(bo);
|
|
|
+ DriverIntervalCargoDamageDetailPageBo pageBo = DriverIntervalCargoDamageMapStruct.MAPSTRUCT.detailExportBoToPageBo(bo);
|
|
|
+ pageBo.setPageNum(1);
|
|
|
+ pageBo.setPageNum(1000);
|
|
|
+ List<DriverIntervalCargoDamageDetailVo> all = new ArrayList<>();
|
|
|
+ while (true) {
|
|
|
+ Page<DriverIntervalCargoDamageDetailVo> page = driverGoodsLossIntervalDetailService.searchForPage(pageBo);
|
|
|
+ List<DriverIntervalCargoDamageDetailVo> driverIntervalCargoDamageDetailVos = page.getRecords();
|
|
|
+ if (null == driverIntervalCargoDamageDetailVos || driverIntervalCargoDamageDetailVos.isEmpty()) {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ all.addAll(driverIntervalCargoDamageDetailVos);
|
|
|
+ pageBo.setPageNum(pageBo.getPageNum() + 1);
|
|
|
+ }
|
|
|
+
|
|
|
+ Map<Long, AreaStaffResponse> areaStaffMap = areaStaffService.searchAreaStaffMap(all);
|
|
|
+ all.forEach(driverIntervalCargoDamageDetailVo -> {
|
|
|
+ AreaStaffResponse areaStaffResponse = areaStaffMap.get(driverIntervalCargoDamageDetailVo.getAreaStaffId());
|
|
|
+ if (null != areaStaffResponse) {
|
|
|
+ driverIntervalCargoDamageDetailVo.setAreaStaffName(areaStaffResponse.getEmployeeName());
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ List<DriverIntervalCargoDamageDetailExport> driverIntervalCargoDamageDetailExports = DriverIntervalCargoDamageMapStruct.MAPSTRUCT.detailVoListToDetailExportList(all);
|
|
|
+ String uri = exportClient.export(driverIntervalCargoDamageDetailExports, "export/driver/interval/cargoDamage", "区间货损记录详情" + System.currentTimeMillis());
|
|
|
+ return Result.success(uri);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 提取区间生成统计记录详情搜索参数
|
|
|
+ */
|
|
|
+ private void extractedAreaStaffSearchParam(DriverIntervalCargoDamageDetailSearchFace bo) {
|
|
|
+ DriverGoodsLossIntervalMain driverGoodsLossIntervalMain = driverGoodsLossIntervalMainService.getById(bo.getGoodsLossMonthlyMainId());
|
|
|
+ if (null == driverGoodsLossIntervalMain) {
|
|
|
+ throw new MessageException("区间货损记录不存在");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (StringUtils.isNotBlank(bo.getAreaStaffName())) {
|
|
|
+ List<AreaStaffResponse> areaStaffResponses = areaStaffComponent.searchByOperatorIdAndAreaStaffName(driverGoodsLossIntervalMain.getOperatorId(), bo.getAreaStaffName());
|
|
|
+ bo.setAreaStaffIds(areaStaffResponses.stream().map(AreaStaffResponse::getId).toList());
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 添加司机在途核算记录
|
|
|
- * @return
|
|
|
*/
|
|
|
@PostMapping("/routeAccountRecord/add")
|
|
|
@ResponseBody
|
|
|
public Result<String> addRouteAccountRecord(@Validated @RequestBody DriverIntervalRouteAccountRecordCreateRequest request, AdminUserInfo adminUserInfo) {
|
|
|
- return null;
|
|
|
+ DriverIntervalRouteAccountRecordCreateBo bo = DriverIntervalCargoDamageMapStruct.MAPSTRUCT.routeAccountRecordCreateRequestToBo(request);
|
|
|
+ buildUserInfo(bo, adminUserInfo);
|
|
|
+ AreaStaffResponse areaStaffResponse = areaStaffComponent.searchByStaffId(bo.getAreaStaffId());
|
|
|
+ bo.setOperatorId(areaStaffResponse.getOperatorId());
|
|
|
+ bo.setOperatorChain(areaStaffResponse.getOperatorChain());
|
|
|
+ driverOnRouteAccountRecordService.create(bo);
|
|
|
+ return Result.success("success");
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 取消司机在途核算记录
|
|
|
- * @return
|
|
|
*/
|
|
|
@GetMapping("/routeAccountRecord/cancel/{routeAccountRecordMainId}")
|
|
|
@ResponseBody
|
|
|
public Result<String> cancelRouteAccountRecord(@PathVariable("routeAccountRecordMainId") Long routeAccountRecordMainId, AdminUserInfo adminUserInfo) {
|
|
|
- return null;
|
|
|
+ DriverIntervalRouteAccountRecordCancelBo bo = new DriverIntervalRouteAccountRecordCancelBo();
|
|
|
+ bo.setId(routeAccountRecordMainId);
|
|
|
+ buildUserInfo(bo, adminUserInfo);
|
|
|
+ driverOnRouteAccountRecordService.cancel(bo);
|
|
|
+ return Result.success("success");
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 导出司机在途核算记录
|
|
|
- * @return
|
|
|
*/
|
|
|
@PostMapping("/routeAccountRecord/export")
|
|
|
@ResponseBody
|
|
|
@@ -116,7 +245,6 @@ public class DriverIntervalCargoDamageController extends BaseController {
|
|
|
|
|
|
/**
|
|
|
* 分页查询司机在途核算记录
|
|
|
- * @return
|
|
|
*/
|
|
|
@PostMapping("/routeAccountRecord/page")
|
|
|
@ResponseBody
|
|
|
@@ -126,7 +254,6 @@ public class DriverIntervalCargoDamageController extends BaseController {
|
|
|
|
|
|
/**
|
|
|
* 查询司机在途核算记录明细
|
|
|
- * @return
|
|
|
*/
|
|
|
@GetMapping("/routeAccountRecord/detail/{routeAccountRecordMainId}")
|
|
|
@ResponseBody
|
|
|
@@ -136,7 +263,6 @@ public class DriverIntervalCargoDamageController extends BaseController {
|
|
|
|
|
|
/**
|
|
|
* 编辑司机在途明细
|
|
|
- * @return
|
|
|
*/
|
|
|
@PostMapping("/routeAccountRecord/detail/edit")
|
|
|
@ResponseBody
|
|
|
@@ -146,7 +272,6 @@ public class DriverIntervalCargoDamageController extends BaseController {
|
|
|
|
|
|
/**
|
|
|
* 导出司机在途明细
|
|
|
- * @return
|
|
|
*/
|
|
|
@GetMapping("/routeAccountRecord/detail/export/{routeAccountRecordMainId}")
|
|
|
@ResponseBody
|