From c7ab79c0facc2161c1a7f9d03234cc1f295b14b0 Mon Sep 17 00:00:00 2001 From: zhenghaoyu Date: Tue, 19 Sep 2023 15:30:26 +0800 Subject: [PATCH] =?UTF-8?q?1.=E7=BB=84=E8=A3=85=E5=95=86=E9=85=8D=E9=85=8D?= =?UTF-8?q?=E9=80=81=E5=8D=95=E6=95=B0=E6=8D=AE=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../feign/IBasicdataCarrierClient.java | 3 +- .../feign/IBasicdataVehicleClient.java | 3 + .../feign/BasicdataVehicleClient.java | 5 + .../mapper/DistributionReservationMapper.java | 11 + .../mapper/DistributionReservationMapper.xml | 56 ++++++ .../IDistributionDeliveryListService.java | 2 + .../DistributionDeliveryListServiceImpl.java | 190 ++++++++++++++++-- .../test/com/logpm/distribution/MyTest.java | 18 +- .../com/logpm/distribution/TestService.java | 30 +++ 9 files changed, 289 insertions(+), 29 deletions(-) create mode 100644 blade-service/logpm-distribution/src/test/java/com/logpm/distribution/TestService.java diff --git a/blade-service-api/logpm-basicdata-api/src/main/java/com/logpm/basicdata/feign/IBasicdataCarrierClient.java b/blade-service-api/logpm-basicdata-api/src/main/java/com/logpm/basicdata/feign/IBasicdataCarrierClient.java index 7d6c0885d..546b5426b 100644 --- a/blade-service-api/logpm-basicdata-api/src/main/java/com/logpm/basicdata/feign/IBasicdataCarrierClient.java +++ b/blade-service-api/logpm-basicdata-api/src/main/java/com/logpm/basicdata/feign/IBasicdataCarrierClient.java @@ -46,5 +46,6 @@ public interface IBasicdataCarrierClient { */ @GetMapping(TOP) BladePage top(@RequestParam("current") Integer current, @RequestParam("size") Integer size); - + @GetMapping(API_PREFIX + "/getCarrierById") + BasicdataCarrierEntity getCarrierById(@RequestParam("current") Long carrierId); } diff --git a/blade-service-api/logpm-basicdata-api/src/main/java/com/logpm/basicdata/feign/IBasicdataVehicleClient.java b/blade-service-api/logpm-basicdata-api/src/main/java/com/logpm/basicdata/feign/IBasicdataVehicleClient.java index 5696f313f..f48e64e17 100644 --- a/blade-service-api/logpm-basicdata-api/src/main/java/com/logpm/basicdata/feign/IBasicdataVehicleClient.java +++ b/blade-service-api/logpm-basicdata-api/src/main/java/com/logpm/basicdata/feign/IBasicdataVehicleClient.java @@ -48,4 +48,7 @@ public interface IBasicdataVehicleClient { @GetMapping(TOP) BladePage top(@RequestParam("current") Integer current, @RequestParam("size") Integer size); + @GetMapping(API_PREFIX + "/getVehicleById") + BasicdataVehicleEntity getVehicleById(@RequestParam("id") Long id); + } diff --git a/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/feign/BasicdataVehicleClient.java b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/feign/BasicdataVehicleClient.java index b95753049..01c808e64 100644 --- a/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/feign/BasicdataVehicleClient.java +++ b/blade-service/logpm-basicdata/src/main/java/com/logpm/basicdata/feign/BasicdataVehicleClient.java @@ -50,4 +50,9 @@ public class BasicdataVehicleClient implements IBasicdataVehicleClient { return BladePage.of(page); } + @Override + public BasicdataVehicleEntity getVehicleById(Long id) { + return basicdataVehicleService.getOneById(id); + } + } diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionReservationMapper.java b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionReservationMapper.java index c17322033..5ec47eef3 100644 --- a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionReservationMapper.java +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionReservationMapper.java @@ -29,6 +29,7 @@ import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; import java.util.List; +import java.util.Map; /** * 预约列表 Mapper 接口 @@ -210,4 +211,14 @@ public interface DistributionReservationMapper extends BaseMapper findByDeliveryId(@Param("id")Long id); + + List> findAllCategoryNum(@Param("id") Long reservationId); + + List getAllocationByStockArticleIdAndReservationId(@Param("stockArticleId") Long stockArticleId, @Param("reservationId") Long reservationId); + + List getStockupAreaByStockArticleIdAndReservationId(@Param("stockArticleId") Long stockArticleId, @Param("reservationId") Long reservationId); + + List getMaterialNameByStockArticleIdAndReservationId(@Param("stockArticleId") Long stockArticleId, @Param("reservationId") Long reservationId); + + List> getCategoryByStockArticleIdAndReservationId(@Param("stockArticleId") Long stockArticleId, @Param("reservationId") Long reservationId); } diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionReservationMapper.xml b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionReservationMapper.xml index 1290f1480..77e843735 100644 --- a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionReservationMapper.xml +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionReservationMapper.xml @@ -916,4 +916,60 @@ + + + + + + + + + + diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/IDistributionDeliveryListService.java b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/IDistributionDeliveryListService.java index 683050b89..23c790824 100644 --- a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/IDistributionDeliveryListService.java +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/IDistributionDeliveryListService.java @@ -226,4 +226,6 @@ public interface IDistributionDeliveryListService extends BaseService printBatch(String ids,Integer type) throws Exception; + + void testData(String s) throws Exception; } diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionDeliveryListServiceImpl.java b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionDeliveryListServiceImpl.java index e3a1c2263..da02acd8c 100644 --- a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionDeliveryListServiceImpl.java +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionDeliveryListServiceImpl.java @@ -17,6 +17,8 @@ package com.logpm.distribution.service.impl; import cn.hutool.core.date.DateUtil; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; import com.baomidou.mybatisplus.core.conditions.Wrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; @@ -24,12 +26,13 @@ import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; import com.baomidou.mybatisplus.core.toolkit.Wrappers; -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.logpm.basic.entity.BasicPrintTemplateEntity; import com.logpm.basic.feign.IBasicPrintTemplateClient; import com.logpm.basicdata.entity.BasicdataDriverArteryEntity; import com.logpm.basicdata.entity.BasicdataWarehouseEntity; +import com.logpm.basicdata.feign.IBasicdataCarrierClient; import com.logpm.basicdata.feign.IBasicdataDriverArteryClient; +import com.logpm.basicdata.feign.IBasicdataVehicleClient; import com.logpm.basicdata.feign.IBasicdataWarehouseClient; import com.logpm.distribution.bean.Resp; import com.logpm.distribution.dto.*; @@ -88,6 +91,7 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Isolation; import org.springframework.transaction.annotation.Transactional; +import java.math.BigDecimal; import java.text.SimpleDateFormat; import java.util.*; import java.util.concurrent.atomic.AtomicInteger; @@ -141,6 +145,8 @@ public class DistributionDeliveryListServiceImpl extends BaseServiceImpl selectDistributionDeliveryListPage(IPage page, DistributionDeliveryListDTO distributionDeliveryList) { @@ -3196,17 +3202,168 @@ public class DistributionDeliveryListServiceImpl extends BaseServiceImpl handleShangPeiData(Long templateId, String[] idArray,String html) throws Exception { + List result = new ArrayList<>(); + List> test = new ArrayList<>(); + for (String id : idArray) { + + //查询对应配送单 + DistributionDeliveryListEntity deliveryListEntity = baseMapper.selectById(id);//配送单 + if(Objects.isNull(deliveryListEntity)){ + log.warn("#########handleShangPeiData: 配送单信息不存在 deliveryListEntityId={}",id); + throw new CustomerException(403,"配送单信息不存在"); + } + Long deliveryListEntityId = deliveryListEntity.getId(); + String taskTime = deliveryListEntity.getTaskTime();//配送时间 + String kind = deliveryListEntity.getKind(); + String dirverName = ""; + String dirverPhone = ""; + String carNumber = ""; + + if("1".equals(kind)){ + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("delivery_id",deliveryListEntityId); + DistributionDeliverySelfEntity deliverySelfEntity = distributionDeliverySelfService.getOne(queryWrapper); + dirverName = deliverySelfEntity.getDriverName(); + dirverPhone = deliverySelfEntity.getDriverPhone(); + carNumber = deliverySelfEntity.getVehicleNub(); + }else if("2".equals(kind)){ + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("delivery_id",deliveryListEntityId); + DistributionDeliveryTripartiteEntity deliveryTripartiteEntity = distributionDeliveryTripartiteService.getOne(queryWrapper); + dirverName = deliveryTripartiteEntity.getDriverName(); + dirverPhone = deliveryTripartiteEntity.getDriverPhone(); + carNumber = deliveryTripartiteEntity.getVehicleNum(); + } + + List distributionReservationEntityList = distributionReservationMapper.findByDeliveryId(deliveryListEntityId); + //循环查询出来的预约单 + for (DistributionReservationEntity reservationEntity:distributionReservationEntityList){ + Map map = new HashMap<>(); + map.put("配送单号", reservationEntity.getReservationCode()); + String fileTypeName = QRCodeUtil.createCodeToFile(reservationEntity.getReservationCode()); + map.put("配送单二维码",QRCodeUtil.getEmpAutograph(fileTypeName)); + map.put("收货单单位",reservationEntity.getReceivingUnit());//收货单单位 + map.put("商场名称",reservationEntity.getStoreName());//商场名称 + map.put("收货人",reservationEntity.getConsignee());//收货人 + map.put("收货人电话",reservationEntity.getDeliveryPhone());//收货人电话 + map.put("收货人地址",reservationEntity.getDeliveryAddress());//收货人地址 + map.put("配送时间",taskTime);//配送时间 + map.put("承运商",deliveryListEntity.getDistributionCompany()); + map.put("配送仓库",deliveryListEntity.getWarehouseName()); + map.put("出库时间",deliveryListEntity.getWarehouseName()); + map.put("送货司机",dirverName+"/"+dirverPhone); + map.put("车牌号",carNumber); + + Long reservationId = reservationEntity.getId();//预约id + //通过预约id查询所有包件并按三级品类分组 + List> categoryList = distributionReservationMapper.findAllCategoryNum(reservationId); + //计算一个总计 + Map total = new HashMap<>(); + Integer totalNum = 0; + for (Map m:categoryList){ + Set set = m.keySet(); + String categoryName = ""; + Long num = 0L; + for (String s:set){ + if("num".equals(s)){ + num = (Long)m.get(s); + totalNum = totalNum + num.intValue(); + }else{ + categoryName = (String)m.get(s); + } + } + total.put(categoryName,num); + } + total.put("合计件数",totalNum); + + + + //先查询预约单对应有哪些订单 + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("reservation_id",reservationId); + List reservationStockarticleList = distributionReservationStockarticleService.list(queryWrapper); + List> ls = new ArrayList<>(); + BigDecimal totalPrice = BigDecimal.ZERO; + for (int i = 0; i < reservationStockarticleList.size(); i++) { + DistributionReservationStockarticleEntity reservationStockarticleEntity = reservationStockarticleList.get(i); + Long stockArticleId = reservationStockarticleEntity.getStockArticleId();//订单id + DistributionStockArticleEntity stockArticleEntity = distributionStockArticleService.getById(stockArticleId); + if(Objects.isNull(stockArticleEntity)){ + log.warn("#########handleShangPeiData: 订单信息不存在 stockArticleId={}",stockArticleId); + throw new CustomerException(403,"订单信息不存在"); + } + Map orderMap = new HashMap<>(); + orderMap.put("序号",i+1); + orderMap.put("运单号",stockArticleEntity.getWaybillNumber()); + orderMap.put("合同号",stockArticleEntity.getOrderCode()); + + //通过订单id和预约id查询对应包件的库位信息 + List allocationStrList = distributionReservationMapper.getAllocationByStockArticleIdAndReservationId(stockArticleId,reservationId); + String allocationStr = StringUtils.join(allocationStrList, ","); + orderMap.put("货位",allocationStr); + //通过订单id和预约id查询对应包件的备货区信息 + List stockupAreaStrList = distributionReservationMapper.getStockupAreaByStockArticleIdAndReservationId(stockArticleId,reservationId); + String stockupAreaStr = StringUtils.join(stockupAreaStrList, ","); + orderMap.put("备货区",stockupAreaStr); + + //查询当前订单的品类数量 + List> mapList = distributionReservationMapper.getCategoryByStockArticleIdAndReservationId(stockArticleId,reservationId); + Map numObj = new HashMap<>(); + Integer tn = 0; + Set set = total.keySet(); + for (String key:set){ + if(!"合计件数".equals(key)){ + numObj.put(key,0); + for (Map m:mapList){ + String thirdProduct = (String)m.get("thirdProduct"); + Long num = (Long)m.get("num"); + if(thirdProduct.equals(key)){ + numObj.put(key,num); + tn = tn + num.intValue(); + } + } + } + } + numObj.put("合计数量",tn); + orderMap.put("产品明细",numObj); + + //通过订单id和预约id查询对应包件的物料信息 + List materialNameStrList = distributionReservationMapper.getMaterialNameByStockArticleIdAndReservationId(stockArticleId,reservationId); + String materialNameStr = StringUtils.join(materialNameStrList, ","); + orderMap.put("物料名称",materialNameStr); + orderMap.put("到付运费",0);//todo 需要累加到totalPrice上 + ls.add(orderMap); + } + total.put("到付费用",totalPrice); + map.put("明细",ls); + map.put("合计",total); + test.add(map); + String popHtml =TemplateUtil.popTemplate("商配配配送单",map,html); + PrintPreviewVO printPreviewVO = new PrintPreviewVO(); + printPreviewVO.setTemplateId(templateId); + printPreviewVO.setTemplateHtml(popHtml); + result.add(printPreviewVO); + } + } + log.info("#############test: test={}",test); + String s = JSON.toJSONString(test); + JSONArray array= JSONArray.parseArray(JSON.toJSONString(test)); + return result; } /** @@ -3225,8 +3382,6 @@ public class DistributionDeliveryListServiceImpl extends BaseServiceImpl map = new HashMap<>(); - DistributionDeliveryListEntity byId = this.getById(id); if (ObjectUtils.isNull(byId)) { @@ -3240,7 +3395,7 @@ public class DistributionDeliveryListServiceImpl extends BaseServiceImpl map = new HashMap<>(); log.debug(">>>> distributionReservationEntity {}",distributionReservationEntity); map.put("配送单号", distributionReservationEntity.getReservationCode()); String fileTypeName = QRCodeUtil.createCodeToFile(distributionReservationEntity.getReservationCode()); @@ -3264,21 +3419,16 @@ public class DistributionDeliveryListServiceImpl extends BaseServiceImpl params = new HashMap<>(); - params.put("ids","1686560469635727362"); - try { - OrderPackgeCodeDataVO orderPackgeCodeDataVO =distributionStockArticleService.showOrderPackgeCode(params); - System.out.println(orderPackgeCodeDataVO); - } catch (Exception e) { - e.printStackTrace(); - } +// Map params = new HashMap<>(); +// params.put("ids","1686560469635727362"); +// try { +// OrderPackgeCodeDataVO orderPackgeCodeDataVO =distributionStockArticleService.showOrderPackgeCode(params); +// System.out.println(orderPackgeCodeDataVO); +// } catch (Exception e) { +// e.printStackTrace(); +// } + List printPreviewVOS = distributionDeliveryListService.printBatch(ids,type); + } } diff --git a/blade-service/logpm-distribution/src/test/java/com/logpm/distribution/TestService.java b/blade-service/logpm-distribution/src/test/java/com/logpm/distribution/TestService.java new file mode 100644 index 000000000..d750cd869 --- /dev/null +++ b/blade-service/logpm-distribution/src/test/java/com/logpm/distribution/TestService.java @@ -0,0 +1,30 @@ +package com.logpm.distribution; + +import com.logpm.distribution.service.IDistributionDeliveryListService; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.springblade.core.test.BladeBootTest; +import org.springblade.core.test.BladeSpringExtension; +import org.springframework.beans.factory.annotation.Autowired; + +@ExtendWith(BladeSpringExtension.class) +@BladeBootTest(appName = "logpm-distribution", enableLoader = true) +public class TestService { + + @Autowired + private IDistributionDeliveryListService distributionDeliveryListService; + + @Test + public void test2() throws Exception { + +// List printPreviewVOS = distributionDeliveryListService.printBatch("1703958397055135745", 1); + + + distributionDeliveryListService.testData("1703958397055135745"); + + System.out.println(111111); + + } + +} +