|
|
|
@ -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<Distrib
|
|
|
|
|
private final DistributionStockListMapper distributionStockListMapper; |
|
|
|
|
private final IWarehouseUpdownTypeClient warehouseUpdownTypeClient; |
|
|
|
|
private final IBasicPrintTemplateClient basicPrintTemplateClient; |
|
|
|
|
private final IBasicdataVehicleClient basicdataVehicleClient; |
|
|
|
|
private final IBasicdataCarrierClient basicdataCarrierClient; |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public IPage<DistributionDeliveryListEntity> selectDistributionDeliveryListPage(IPage<DistributionDeliveryListEntity> page, DistributionDeliveryListDTO distributionDeliveryList) { |
|
|
|
@ -3196,17 +3202,168 @@ public class DistributionDeliveryListServiceImpl extends BaseServiceImpl<Distrib
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} else if (1 == type) { |
|
|
|
|
handleShangPeiData(printPreviewVO, idArray); |
|
|
|
|
return handleShangPeiData(template.getId(), idArray,html); |
|
|
|
|
} else { |
|
|
|
|
log.warn("###########printBatch: 未知的打印类型"); |
|
|
|
|
throw new CustomerException(403, "未知的打印类型"); |
|
|
|
|
} |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void handleShangPeiData(PrintPreviewVO printPreviewVO, String[] idArray) { |
|
|
|
|
//TODO 商配配送单数据组装
|
|
|
|
|
@Override |
|
|
|
|
public void testData(String s) throws Exception { |
|
|
|
|
String[] split = s.split(","); |
|
|
|
|
handleShangPeiData(1111L, split,"111"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private List<PrintPreviewVO> handleShangPeiData(Long templateId, String[] idArray,String html) throws Exception { |
|
|
|
|
List<PrintPreviewVO> result = new ArrayList<>(); |
|
|
|
|
List<Map<String,Object>> 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<DistributionDeliverySelfEntity> 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<DistributionDeliveryTripartiteEntity> queryWrapper = new QueryWrapper<>(); |
|
|
|
|
queryWrapper.eq("delivery_id",deliveryListEntityId); |
|
|
|
|
DistributionDeliveryTripartiteEntity deliveryTripartiteEntity = distributionDeliveryTripartiteService.getOne(queryWrapper); |
|
|
|
|
dirverName = deliveryTripartiteEntity.getDriverName(); |
|
|
|
|
dirverPhone = deliveryTripartiteEntity.getDriverPhone(); |
|
|
|
|
carNumber = deliveryTripartiteEntity.getVehicleNum(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
List<DistributionReservationEntity> distributionReservationEntityList = distributionReservationMapper.findByDeliveryId(deliveryListEntityId); |
|
|
|
|
//循环查询出来的预约单
|
|
|
|
|
for (DistributionReservationEntity reservationEntity:distributionReservationEntityList){ |
|
|
|
|
Map<String,Object> 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<Map<String,Object>> categoryList = distributionReservationMapper.findAllCategoryNum(reservationId); |
|
|
|
|
//计算一个总计
|
|
|
|
|
Map<String,Object> total = new HashMap<>(); |
|
|
|
|
Integer totalNum = 0; |
|
|
|
|
for (Map<String,Object> m:categoryList){ |
|
|
|
|
Set<String> 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<DistributionReservationStockarticleEntity> queryWrapper = new QueryWrapper<>(); |
|
|
|
|
queryWrapper.eq("reservation_id",reservationId); |
|
|
|
|
List<DistributionReservationStockarticleEntity> reservationStockarticleList = distributionReservationStockarticleService.list(queryWrapper); |
|
|
|
|
List<Map<String,Object>> 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<String,Object> orderMap = new HashMap<>(); |
|
|
|
|
orderMap.put("序号",i+1); |
|
|
|
|
orderMap.put("运单号",stockArticleEntity.getWaybillNumber()); |
|
|
|
|
orderMap.put("合同号",stockArticleEntity.getOrderCode()); |
|
|
|
|
|
|
|
|
|
//通过订单id和预约id查询对应包件的库位信息
|
|
|
|
|
List<String> allocationStrList = distributionReservationMapper.getAllocationByStockArticleIdAndReservationId(stockArticleId,reservationId); |
|
|
|
|
String allocationStr = StringUtils.join(allocationStrList, ","); |
|
|
|
|
orderMap.put("货位",allocationStr); |
|
|
|
|
//通过订单id和预约id查询对应包件的备货区信息
|
|
|
|
|
List<String> stockupAreaStrList = distributionReservationMapper.getStockupAreaByStockArticleIdAndReservationId(stockArticleId,reservationId); |
|
|
|
|
String stockupAreaStr = StringUtils.join(stockupAreaStrList, ","); |
|
|
|
|
orderMap.put("备货区",stockupAreaStr); |
|
|
|
|
|
|
|
|
|
//查询当前订单的品类数量
|
|
|
|
|
List<Map<String,Object>> mapList = distributionReservationMapper.getCategoryByStockArticleIdAndReservationId(stockArticleId,reservationId); |
|
|
|
|
Map<String,Object> numObj = new HashMap<>(); |
|
|
|
|
Integer tn = 0; |
|
|
|
|
Set<String> set = total.keySet(); |
|
|
|
|
for (String key:set){ |
|
|
|
|
if(!"合计件数".equals(key)){ |
|
|
|
|
numObj.put(key,0); |
|
|
|
|
for (Map<String,Object> 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<String> 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<Distrib
|
|
|
|
|
|
|
|
|
|
// 获取需要的数据
|
|
|
|
|
|
|
|
|
|
Map<String, Object> map = new HashMap<>(); |
|
|
|
|
|
|
|
|
|
DistributionDeliveryListEntity byId = this.getById(id); |
|
|
|
|
|
|
|
|
|
if (ObjectUtils.isNull(byId)) { |
|
|
|
@ -3240,7 +3395,7 @@ public class DistributionDeliveryListServiceImpl extends BaseServiceImpl<Distrib
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
for (DistributionReservationEntity distributionReservationEntity : distributionReservationEntityList) { |
|
|
|
|
|
|
|
|
|
Map<String, Object> 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<Distrib
|
|
|
|
|
map.put("定制品集合", spaclOrderList); |
|
|
|
|
|
|
|
|
|
map.put("备注", distributionReservationEntity.getRemarks()); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
map.put("送货司机", byId.getVehicleName() + "/" + byId.getDriverName()); |
|
|
|
|
data.add(map); |
|
|
|
|
|
|
|
|
|
String popHtml =TemplateUtil.popTemplate("市配配送单",map,html); |
|
|
|
|
|
|
|
|
|
PrintPreviewVO printPreviewVO = new PrintPreviewVO(); |
|
|
|
|
printPreviewVO.setTemplateId(template.getId()); |
|
|
|
|
printPreviewVO.setTemplateHtml(popHtml); |
|
|
|
|
result.add(printPreviewVO); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
return result; |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|