Browse Source

feat(all): 增加林氏与老系统对接逻辑

dist.1.3.0
zhaoqiaobo 7 months ago
parent
commit
f57ea0b337
  1. 8
      blade-service-api/logpm-factory-data-base-api/src/main/java/com/logpm/factorydata/base/vo/FactoryWarehouseBindVO.java
  2. 10
      blade-service/logpm-factory-data/logpm-factory-data-base/src/main/java/com/logpm/factorydata/base/entity/FactoryWarehouseBindEntity.java
  3. 4
      blade-service/logpm-factory-data/logpm-factory-data-base/src/main/java/com/logpm/factorydata/base/feign/FactoryDataBaseClient.java
  4. 3
      blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/controller/OrderController.java
  5. 11
      blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/mq/FactoryOrderListener.java
  6. 15
      blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/pros/LinsyProperties.java
  7. 4
      blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/service/DeliveryNoteService.java
  8. 137
      blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/service/impl/DeliveryNoteServiceImpl.java

8
blade-service-api/logpm-factory-data-base-api/src/main/java/com/logpm/factorydata/base/vo/FactoryWarehouseBindVO.java

@ -21,6 +21,14 @@ public class FactoryWarehouseBindVO implements Serializable {
* 仓库名称
*/
private String warehouseName;
/**
* 老系统仓库id
*/
private Long oldWarehouseId;
/**
* 老系统仓库名称
*/
private String oldWarehouseName;
/**
* 租户id
*/

10
blade-service/logpm-factory-data/logpm-factory-data-base/src/main/java/com/logpm/factorydata/base/entity/FactoryWarehouseBindEntity.java

@ -40,6 +40,16 @@ public class FactoryWarehouseBindEntity extends BaseEntity {
*/
@ApiModelProperty(name = "仓库名称", notes = "")
private String warehouseName;
/**
* 老系统仓库id
*/
@ApiModelProperty(name = "老系统仓库id", notes = "")
private Long oldWarehouseId;
/**
* 老系统仓库名称
*/
@ApiModelProperty(name = "老系统仓库名称", notes = "")
private String oldWarehouseName;
/**
* 租户id
*/

4
blade-service/logpm-factory-data/logpm-factory-data-base/src/main/java/com/logpm/factorydata/base/feign/FactoryDataBaseClient.java

@ -35,7 +35,7 @@ public class FactoryDataBaseClient implements IFactoryDataBaseClient {
public R<FactoryWarehouseBindVO> getWarehouseByBrandAndSiteName(String brand, String siteName) {
String rediskey = FactoryDatabaseConstants.FACTORY_DATA_BASE_WAREHOUSE_BIND + ":" + brand + "_" + siteName;
String obj = bladeRedis.get(rediskey);
if(StrUtil.isNotBlank(obj)){
if (StrUtil.isNotBlank(obj)) {
FactoryWarehouseBindVO redisBindVO = JSONUtil.toBean(obj, FactoryWarehouseBindVO.class);
if (ObjectUtil.isNotNull(redisBindVO)) {
return R.data(redisBindVO);
@ -51,6 +51,8 @@ public class FactoryDataBaseClient implements IFactoryDataBaseClient {
FactoryWarehouseBindVO vo = new FactoryWarehouseBindVO();
vo.setWarehouseName(entity.getWarehouseName());
vo.setWarehouseId(entity.getWarehouseId());
vo.setOldWarehouseId(entity.getOldWarehouseId());
vo.setOldWarehouseName(entity.getOldWarehouseName());
vo.setTenantId(entity.getTenantId());
bladeRedis.setEx(rediskey, JSONUtil.toJsonStr(vo), Convert.toLong(60 * 60));
return R.data(vo);

3
blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/controller/OrderController.java

@ -13,6 +13,7 @@ import lombok.extern.slf4j.Slf4j;
import org.springblade.common.constant.factorydata.FactoryDataConstants;
import org.springblade.core.tool.api.R;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PatchMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
@ -70,7 +71,7 @@ public class OrderController {
@PatchMapping
@ApiOperationSupport(order = 2)
@ApiOperation(value = "取消订单", notes = "取消订单")
public R cancelOrder(@RequestBody CancelOrderVO vo) {
public R cancelOrder(@Validated @RequestBody CancelOrderVO vo) {
log.info("取消订单:{} ", JSONUtil.toJsonStr(vo));
Boolean res = deliveryNoteService.cancelOrder(vo);
if (res) {

11
blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/mq/FactoryOrderListener.java

@ -14,6 +14,7 @@ import com.logpm.factorydata.enums.SaxStatusEnums;
import com.logpm.factorydata.linsy.entity.DeliveryNoteEntity;
import com.logpm.factorydata.linsy.entity.FactoryOrderLogEntity;
import com.logpm.factorydata.linsy.entity.PackageInfoEntity;
import com.logpm.factorydata.linsy.pros.LinsyProperties;
import com.logpm.factorydata.linsy.service.DeliveryNoteService;
import com.logpm.factorydata.linsy.service.FactoryOrderLogService;
import com.logpm.factorydata.linsy.service.PackageInfoService;
@ -47,6 +48,7 @@ public class FactoryOrderListener {
private final DeliveryNoteService deliveryNoteService;
private final FactoryOrderLogService logService;
private final PackageInfoService packageInfoService;
private final LinsyProperties linsyProperties;
@RabbitListener(bindings = @QueueBinding(
value = @Queue(name = FactoryDataConstants.Mq.Queues.LINSY_FACTORY_ORDER),
@ -114,10 +116,13 @@ public class FactoryOrderListener {
logEntity1.setSaxStatus(SaxStatusEnums.SUCCESS.getCode());
logEntity1.setId(logId);
logService.saveOrUpdate(logEntity1);
// 结果回传
// 处理暂存单
deliveryNoteService.buildAdvance(vo);
if (linsyProperties.getNewAdvance()) {
deliveryNoteService.buildAdvance(vo);
}
if (linsyProperties.getOldAdvance()) {
deliveryNoteService.buildOldAdvance(vo);
}
}
}

15
blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/pros/LinsyProperties.java

@ -36,5 +36,20 @@ public class LinsyProperties {
*/
private Integer delayedTime = 30;
/** 生成老系统暂存单 */
private Boolean oldAdvance = false;
/** 生成新系统暂存单 */
private Boolean newAdvance = false;
/** 老系统host */
private String oldSystemHost;
/** 老系统暂存单url */
private String oldSystemAdvanceUrl;
/** 老系统取消暂存单url */
private String oldSystemCancelAdvanceUrl;
}

4
blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/service/DeliveryNoteService.java

@ -5,8 +5,6 @@ import com.logpm.factorydata.linsy.vo.CancelOrderVO;
import com.logpm.factorydata.linsy.vo.DeliveryNoteVO;
import org.springblade.core.mp.base.BaseService;
import java.util.List;
/**
* 索菲亚发货单 服务类
*
@ -19,4 +17,6 @@ public interface DeliveryNoteService extends BaseService<DeliveryNoteEntity> {
void buildAdvance(DeliveryNoteVO entities);
Boolean cancelOrder(CancelOrderVO vo);
void buildOldAdvance(DeliveryNoteVO vo);
}

137
blade-service/logpm-factory-data/logpm-factory-data-linsy/src/main/java/com/logpm/factorydata/linsy/service/impl/DeliveryNoteServiceImpl.java

@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.http.HttpUtil;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.logpm.factorydata.base.feign.IFactoryDataBaseClient;
@ -12,6 +13,7 @@ import com.logpm.factorydata.enums.BrandEnums;
import com.logpm.factorydata.feign.IFactoryDataClient;
import com.logpm.factorydata.linsy.entity.DeliveryNoteEntity;
import com.logpm.factorydata.linsy.mapper.DeliveryNoteMapper;
import com.logpm.factorydata.linsy.pros.LinsyProperties;
import com.logpm.factorydata.linsy.service.DeliveryNoteService;
import com.logpm.factorydata.linsy.vo.CancelOrderVO;
import com.logpm.factorydata.linsy.vo.DeliveryNoteVO;
@ -33,6 +35,7 @@ import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
@ -49,6 +52,7 @@ public class DeliveryNoteServiceImpl extends BaseServiceImpl<DeliveryNoteMapper,
private final IFactoryDataBaseClient baseClient;
private final IFactoryDataClient factoryDataClient;
private final ITrunklineAdvanceClient advanceClient;
private final LinsyProperties linsyProperties;
@Override
@LogpmAsync("asyncExecutor")
@ -123,9 +127,9 @@ public class DeliveryNoteServiceImpl extends BaseServiceImpl<DeliveryNoteMapper,
advanceDetailEntity.setBrand(BrandEnums.LINSY.getValue());
advanceDetailEntity.setSystemType("线上");
advanceDetailEntity.setFirstPackName(orderPackageDTO.getMaterialName());
//二级品类名称
// 二级品类名称
advanceDetailEntity.setSecondPackName(orderPackageDTO.getMaterialName());
//三级品类名称
// 三级品类名称
advanceDetailEntity.setThirdPackName(orderPackageDTO.getMaterialName());
advanceDetailEntity.setMaterialName(orderPackageDTO.getMaterialName());
advanceDetailEntity.setMaterialCode(orderPackageDTO.getMaterialCode());
@ -171,8 +175,133 @@ public class DeliveryNoteServiceImpl extends BaseServiceImpl<DeliveryNoteMapper,
log.info("工厂发起取消订单:{}", JSONUtil.toJsonStr(vo));
CancelOrderParamVO param = new CancelOrderParamVO();
param.setOrderCode(vo.getSourceCode());
Boolean result = advanceClient.cancelOrder(param);
return result;
if(linsyProperties.getNewAdvance()){
Boolean result = advanceClient.cancelOrder(param);
return result;
}
if(linsyProperties.getOldAdvance()){
String post = HttpUtil.post(linsyProperties.getOldSystemHost() + linsyProperties.getOldSystemCancelAdvanceUrl(), JSONUtil.toJsonStr(param));
// return result;
}
return false;
}
@Override
@LogpmAsync("asyncExecutor")
public void buildOldAdvance(DeliveryNoteVO vo) {
log.info("林氏老系统生成暂存单:{}", JSONUtil.toJsonStr(vo));
Long startWarehouseId = null;
String startWarehouseName = null;
// 获取工厂基地绑定的始发仓信息
R<FactoryWarehouseBindVO> warehouseByBrandAndSiteName = baseClient.getWarehouseByBrandAndSiteName(BrandEnums.LINSY.getValue(), vo.getSupplierName());
if (ObjectUtil.equal(HttpConstants.HTTP.HTTP_RESOURCE_CODE.SUCCESS_CODE, warehouseByBrandAndSiteName.getCode())) {
FactoryWarehouseBindVO data = warehouseByBrandAndSiteName.getData();
if (ObjectUtil.isNotNull(data)) {
startWarehouseId = data.getOldWarehouseId();
startWarehouseName = data.getOldWarehouseName();
}
}
JSONObject advance = new JSONObject();
List<PackageInfoVO> packages = vo.getPackages();
// 组装暂存单数据
advance.set("siteName", vo.getSupplierName());
advance.set("area", "");
advance.set("orderTypeName", "");
advance.set("orderClassName", "");
advance.set("type", BrandEnums.LINSY.getValue());
advance.set("total", CollUtil.isNotEmpty(packages) ? packages.size() : 0);
advance.set("mtdsNo", "");
advance.set("warehouse_id", startWarehouseId);
advance.set("mctsTruck", StrUtil.replace(DateUtil.today(), "-", ""));
advance.set("orderSelfNum", vo.getBillCode());
advance.set("dealerName", vo.getShopName());
advance.set("dealerCode", "");
advance.set("storeName", vo.getShopName());
advance.set("storeNo", "");
advance.set("old_id", "");
advance.set("serialKey", "");
advance.set("dueDate", "");
advance.set("delete_reason", "");
advance.set("delete_administrators_id", "");
advance.set("matingCode", "");
advance.set("leaveBehind", "N");
advance.set("contractNum", "");
advance.set("orderNum", "");
advance.set("waybill_no", "");
advance.set("waybill_status", 1);
advance.set("freeze", 1);
advance.set("cars_num", "");
advance.set("administrators_id", 1126);
advance.set("carrierName", "汇通");
advance.set("systemType", "线上");
advance.set("is_opai", 0);
advance.set("serviceNum", vo.getCustomizedBillCode());
advance.set("customerName", vo.getReceiverName());
advance.set("customerPhone", vo.getReceiverTelephone());
advance.set("customerRoad", vo.getReceiverDetailAddress());
advance.set("senderName", vo.getSenderName());
advance.set("senderMobile", vo.getSenderTelephone());
advance.set("senderAddress", vo.getSenderDetailAddress());
List<JSONObject> packageList = new ArrayList<>();
for (PackageInfoVO orderPackageDTO : packages) {
advance.set("firstPackName", orderPackageDTO.getMaterialName());
advance.set("firstPackCode", orderPackageDTO.getMaterialCode());
// 封装包件
JSONObject advanceDetailEntity = new JSONObject();
advanceDetailEntity.set("orderSelfNum", vo.getBillCode());
advanceDetailEntity.set("serviceNum", vo.getCustomizedBillCode());
advanceDetailEntity.set("type", BrandEnums.LINSY.getValue());
advanceDetailEntity.set("systemType", "线上");
advanceDetailEntity.set("firstPackName", orderPackageDTO.getMaterialName());
// 二级品类名称
advanceDetailEntity.set("secondPackName", orderPackageDTO.getMaterialName());
// 三级品类名称
advanceDetailEntity.set("thirdPackName", orderPackageDTO.getMaterialName());
advanceDetailEntity.set("firstPackCode", orderPackageDTO.getMaterialCode());
advanceDetailEntity.set("secondPackCode", orderPackageDTO.getMaterialCode());
advanceDetailEntity.set("thirdPackCode", orderPackageDTO.getMaterialCode());
advanceDetailEntity.set("siteName", vo.getSupplierName());
advanceDetailEntity.set("unitNo", orderPackageDTO.getBarcode());
advanceDetailEntity.set("mctsTruck", StrUtil.replace(DateUtil.today(), "-", ""));
advanceDetailEntity.set("volume", StrUtil.isNotBlank(orderPackageDTO.getVolume()) ? new BigDecimal(orderPackageDTO.getVolume()) : BigDecimal.ZERO);
advanceDetailEntity.set("is_pay", 0);
advanceDetailEntity.set("mtdsNum", 0);
advanceDetailEntity.set("lineID", "");
advanceDetailEntity.set("mctsTruckNo", "");
advanceDetailEntity.set("serialKey", "");
advanceDetailEntity.set("mscsNum", "1");
advanceDetailEntity.set("isAddin", "N");
advanceDetailEntity.set("isThirdAddin", "N");
advanceDetailEntity.set("isSuppin", "N");
advanceDetailEntity.set("productCode", "");
advanceDetailEntity.set("goodName", "");
advanceDetailEntity.set("admin", "");
advanceDetailEntity.set("siteCode", "");
advanceDetailEntity.set("area", "");
advanceDetailEntity.set("date2", "");
advanceDetailEntity.set("date3", "");
advanceDetailEntity.set("date4", "");
advanceDetailEntity.set("date5", "");
advanceDetailEntity.set("date6", "");
advanceDetailEntity.set("orderNum", "");
advanceDetailEntity.set("mtdsNo", "");
advanceDetailEntity.set("old_id", 0);
advanceDetailEntity.set("remark", "");
advanceDetailEntity.set("dueDate", "");
advanceDetailEntity.set("is_opai", 0);
advanceDetailEntity.set("administrators_id", 1126);
advanceDetailEntity.set("date100", new Date());
JSONObject entries = JSONUtil.parseObj(advanceDetailEntity);
packageList.add(entries);
}
advance.set("details", JSONUtil.toJsonStr(packageList));
if (ObjectUtil.isAllNotEmpty(linsyProperties.getOldSystemHost(), linsyProperties.getOldSystemAdvanceUrl())) {
log.info("推送老系统暂存单:{}", JSONUtil.toJsonStr(advance));
String post = HttpUtil.post(linsyProperties.getOldSystemHost() + linsyProperties.getOldSystemAdvanceUrl(), JSONUtil.toJsonStr(advance));
log.info("推送老系统暂存单结果:{}", post);
}
}
}

Loading…
Cancel
Save