Browse Source

Merge remote-tracking branch 'origin/fix_bug_20231228' into fix_bug_20231228

single_db
caoyizhong 1 year ago
parent
commit
361ad6b02f
  1. 2
      blade-biz-common/src/main/java/org/springblade/common/constant/OldSystemDataPushConfig.java
  2. 29
      blade-biz-common/src/main/java/org/springblade/common/utils/FileLogsUtil.java
  3. 2
      blade-service-api/logpm-factory-api/src/main/java/com/logpm/factory/oupai/entity/FactoryPackageEntity.java
  4. 7
      blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionStockArticleMapper.xml
  5. 4
      blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionAsyncServiceImpl.java
  6. 187
      blade-service/logpm-factory/src/main/java/com/logpm/factory/jobhandler/FactoryXxlJob.java
  7. 4
      blade-service/logpm-factory/src/main/java/com/logpm/factory/mt/feign/MtOrderMainClinet.java
  8. 6
      blade-service/logpm-factory/src/main/java/com/logpm/factory/oupai/mapper/FactoryOrderMapper.java
  9. 10
      blade-service/logpm-factory/src/main/java/com/logpm/factory/oupai/mapper/FactoryOrderMapper.xml
  10. 3
      blade-service/logpm-factory/src/main/java/com/logpm/factory/oupai/mapper/ReceivingOrderMapper.java
  11. 6
      blade-service/logpm-factory/src/main/java/com/logpm/factory/oupai/mapper/ReceivingOrderMapper.xml
  12. 4
      blade-service/logpm-factory/src/main/java/com/logpm/factory/oupai/service/IOuPaiFactoryService.java
  13. 1
      blade-service/logpm-factory/src/main/java/com/logpm/factory/oupai/service/impl/FactoryOrderServiceImpl.java
  14. 590
      blade-service/logpm-factory/src/main/java/com/logpm/factory/oupai/service/impl/OuPaiFactoryServiceImpl.java

2
blade-biz-common/src/main/java/org/springblade/common/constant/OldSystemDataPushConfig.java

@ -17,6 +17,8 @@ public class OldSystemDataPushConfig {
warehourseIds.add("30");
warehourseIds.add("38");
warehourseIds.add("124");
// 上海
warehourseIds.add("149");
}

29
blade-biz-common/src/main/java/org/springblade/common/utils/FileLogsUtil.java

@ -5,10 +5,9 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springblade.common.constant.CommonConstant;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.Writer;
import java.io.*;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Calendar;
import java.util.Date;
@ -65,6 +64,28 @@ public class FileLogsUtil {
return imgPath + fileName;
}
public static String loadFileContent(String urlString) {
try {
log.info(">>>> 开始下载 {}",urlString);
URL url = new URL(urlString);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("GET");
BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
String inputLine;
StringBuilder content = new StringBuilder();
while ((inputLine = in.readLine()) != null) {
content.append(inputLine);
}
in.close();
log.info(">>>> 结束下载 {}",urlString);
return content.toString();
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
private static String makeDateString(Date date) {
StringBuilder stringBuffer = new StringBuilder();

2
blade-service-api/logpm-factory-api/src/main/java/com/logpm/factory/oupai/entity/FactoryPackageEntity.java

@ -98,7 +98,7 @@ public class FactoryPackageEntity extends BaseEntity {
/** 入库单状态 0正常 1作废 */
@ApiModelProperty(name = "入库单状态 0正常 1作废",notes = "")
private Integer receiptStatus ;
/** 推送状态 1推送 0未推送 */
/** 推送欧派 推送状态 1推送 0未推送 3 收货推送完成 4 出库推送完成*/
@ApiModelProperty(name = "推送状态 1推送 0未推送",notes = "")
private Integer pushStatus ;
@ApiModelProperty(name = "老系统推送状态 1推送 0未推送 2 推送失败",notes = "")

7
blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionStockArticleMapper.xml

@ -671,6 +671,13 @@
<if test="par.consigneeUnit != null and par.consigneeUnit != '' ">
and ldsa.consignee_unit like concat('%',#{par.consigneeUnit},'%')
</if>
<if test="par.totalNumber !=null ">
and ldsa.total_number = #{par.totalNumber}
</if>
<if test="par.customerAddress !=null and par.customerAddress !=''">
and ldsa.customer_address like concat('%',#{par.customerAddress},'%')
</if>
</where>
</select>
<select id="selectListGrounding" resultType="com.logpm.distribution.vo.DistributionStockArticleGroundingVO">

4
blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionAsyncServiceImpl.java

@ -1500,6 +1500,10 @@ public class DistributionAsyncServiceImpl implements IDistributionAsyncService {
}
try {
log.info(">>>>>>>>>>>>>>> 文员复核推送 品牌 {} ",brand);
if (Func.isNotEmpty(brand.get("梦天"))){
mtReceiveDTO.setReceiveContentList(brand.get("梦天"));
orderMainClinet.sendReceiveInfoByNewSystem(mtReceiveDTO);

187
blade-service/logpm-factory/src/main/java/com/logpm/factory/jobhandler/FactoryXxlJob.java

@ -1,8 +1,14 @@
package com.logpm.factory.jobhandler;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.logpm.factory.comfac.dto.OrderStatusDTO;
import com.logpm.factory.oupai.mapper.FactoryOrderMapper;
import com.logpm.factory.oupai.service.IOuPaiFactoryService;
import com.logpm.factory.snm.dto.GroupByPackagesDTO;
import com.logpm.factory.snm.entity.OrderLogEntity;
import com.logpm.factory.snm.entity.StaorderPackagesEntity;
@ -23,6 +29,7 @@ import org.slf4j.LoggerFactory;
import org.springblade.common.constant.LogpmDataStatusEnum;
import org.springblade.common.constant.PackagesTypeEnum;
import org.springblade.common.utils.CommonUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.ObjectUtils;
@ -48,20 +55,24 @@ public class FactoryXxlJob {
private static final Logger logger = LoggerFactory.getLogger(FactoryXxlJob.class);
private IStationlinenumService stationlinenumService;
private final IStationlinenumService stationlinenumService;
private IOrderService orderService;
private final IOrderService orderService;
private IOrderLogService orderLogService;
private final IOrderLogService orderLogService;
private IStationOrderService stationOrderService;
private final IStationOrderService stationOrderService;
private IStaorderPackagesService staorderPackagesService;
private IAdvanceClient iAdvanceClient;
private IAdvanceDetailClient advanceDetailClient;
private IDetailProductClient detailProductClient;
private IServiceNumClient serviceNumClient;
private IWarehouseClient warehouseClient;
private final IStaorderPackagesService staorderPackagesService;
private final IAdvanceClient iAdvanceClient;
private final IAdvanceDetailClient advanceDetailClient;
private final IDetailProductClient detailProductClient;
private final IServiceNumClient serviceNumClient;
private final IWarehouseClient warehouseClient;
private final IOuPaiFactoryService ouPaiFactoryService;
private final FactoryOrderMapper factoryOrderMapper;
/**
@ -169,7 +180,8 @@ public class FactoryXxlJob {
resoveFactoryData();
return ReturnT.SUCCESS;
}
private Timestamp initTimestamp(){
private Timestamp initTimestamp() {
Calendar calendar = Calendar.getInstance();
return new Timestamp(calendar.get(Calendar.YEAR),
@ -177,8 +189,9 @@ public class FactoryXxlJob {
calendar.get(Calendar.DAY_OF_MONTH),
calendar.get(Calendar.HOUR),
calendar.get(Calendar.MINUTE),
calendar.get(Calendar.SECOND),calendar.get(Calendar.MILLISECOND));
calendar.get(Calendar.SECOND), calendar.get(Calendar.MILLISECOND));
}
@Transactional(rollbackFor = Exception.class)
public Boolean resoveFactoryData() {
Map<Long, List<StaorderPackagesEntity>> map = new HashMap<>();
@ -393,7 +406,7 @@ public class FactoryXxlJob {
String tcWlb008 = stationOrderEntity.getTcWlb008();//Log中对应的客户单号
String tcWlb007 = stationOrderEntity.getTcWlb007();//Log中对应的系统单号
Integer tcWlb009 = stationOrderEntity.getTcWlb009();//Log中对应的包件数量
if (otcWla001.equals(tcWla001)&&otcWla002.equals(tcWla002)&&otcWlb008.equals(tcWlb008)&&otcWlb007.equals(tcWlb007)&&otcWlb009.equals(tcWlb009)) {
if (otcWla001.equals(tcWla001) && otcWla002.equals(tcWla002) && otcWlb008.equals(tcWlb008) && otcWlb007.equals(tcWlb007) && otcWlb009.equals(tcWlb009)) {
dataList.remove(i);
break;
}
@ -403,4 +416,152 @@ public class FactoryXxlJob {
}
// 还需要增加根据欧派收货单获取数据的方法
/**
* 欧派工程数据回推
* 启动参数格式
* "123,f12334,gt3545"
*/
@XxlJob("factoryByOpOrderPackageCodeJobHandlerIn")
public ReturnT<String> factoryByOpOrderPackageCodeJobHandlerIn(String param) throws Exception {
if (StringUtils.isBlank(param)) {
return ReturnT.FAIL;
}
String[] split = param.split(",");
try {
for (String orderPackageCode : split) {
OrderStatusDTO orderStatusDTO = new OrderStatusDTO();
orderStatusDTO.setUnitNo(orderPackageCode);
orderStatusDTO.setStatus("1");
// 查询老系统的操作人
orderStatusDTO.setUsername("zhangsna ");// 操作人
ouPaiFactoryService.handleStatusData(orderStatusDTO);
}
return ReturnT.SUCCESS;
} catch (Exception e) {
XxlJobLogger.log(e);
logger.error(">>>> 执行失败");
return ReturnT.FAIL;
}
}
@XxlJob("factoryByOpOrderPackageCodeJobHandlerOut")
public ReturnT<String> factoryByOpOrderPackageCodeJobHandlerOut(String param) throws Exception {
if (StringUtils.isBlank(param)) {
return ReturnT.FAIL;
}
String[] split = param.split(",");
try {
for (String orderPackageCode : split) {
OrderStatusDTO orderStatusDTO = new OrderStatusDTO();
orderStatusDTO.setUnitNo(orderPackageCode);
orderStatusDTO.setStatus("7");
// 查询老系统的操作人
orderStatusDTO.setUsername("zhangsna");// 操作人
ouPaiFactoryService.handleStatusData(orderStatusDTO);
}
return ReturnT.SUCCESS;
} catch (Exception e) {
XxlJobLogger.log(e);
logger.error(">>>> 执行失败");
return ReturnT.FAIL;
}
}
@XxlJob("factory2OpReplayGetOrderInforByReceivCode")
public ReturnT<String> factory2OpReplayGetOrderInforByReceivCode(String param) throws Exception {
// todo 需要拆分方法
if (StringUtils.isBlank(param)) {
return ReturnT.FAIL;
}
String[] split = param.split(",");
try {
for (String receivCode : split) {
XxlJobLogger.log(">>>>> 收货单执行单号 开始 {}",receivCode);
ouPaiFactoryService.saveOuPaiFactoryOrderDTOByCarCarNumberAgain(receivCode);
XxlJobLogger.log(">>>>> 收货单执行单号 结束 {}",receivCode);
}
return ReturnT.SUCCESS;
} catch (Exception e) {
XxlJobLogger.log(e);
return ReturnT.FAIL;
}
}
/**
* 修复欧派工厂订单数据重复
* @param param
* @return
* @throws Exception
*/
@XxlJob("factory2OpReplayOrderDataRepeat")
public ReturnT<String> factory2OpReplayOrderDataRepeat(String param) throws Exception {
// todo 需要拆分方法
if (StringUtils.isBlank(param)) {
return ReturnT.FAIL;
}
String[] split = param.split(",");
try {
List<Map<String, Object>> dataRepeat = factoryOrderMapper.findDataRepeat();
for (Map<String, Object> stringObjectMap : dataRepeat) {
Long receiving_id = (Long)stringObjectMap.get("receiving_id");
String self_code = (String)stringObjectMap.get("self_code");
/**
* select id from op_factory_order where is_deleted = 0 and (self_code = 'OPLCZ绵阳市231200002CA1-1' and receiving_id = 1736591024500776962) ORDER BY create_time
*/
List<Long> orderInforIdBySelfCodeAndReceivingid = factoryOrderMapper.findOrderInforIdBySelfCodeAndReceivingid(self_code, receiving_id);
}
} catch (Exception e) {
XxlJobLogger.log(e);
}
return ReturnT.FAIL;
}
}

4
blade-service/logpm-factory/src/main/java/com/logpm/factory/mt/feign/MtOrderMainClinet.java

@ -5,6 +5,7 @@ import com.logpm.factory.mt.dto.MtReceiveDTO;
import com.logpm.factory.mt.service.IMtFactoryDataService;
import com.logpm.factory.mt.service.IMtFactoryOrderMainService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.tenant.annotation.NonDS;
import org.springblade.core.tool.api.R;
import org.springframework.web.bind.annotation.GetMapping;
@ -18,6 +19,7 @@ import java.security.NoSuchAlgorithmException;
@ApiIgnore
@RestController
@AllArgsConstructor
@Slf4j
public class MtOrderMainClinet implements IMtOrderMainClinet {
private final IMtFactoryOrderMainService mtFactoryOrderMainService;
@ -27,6 +29,7 @@ public class MtOrderMainClinet implements IMtOrderMainClinet {
@Override
@GetMapping(TOP)
public R sendOrderPackageScan(String orderPackageCode, String operationTime, String distributionContactId, String distributionContactCode, String destinationWarehouse) throws NoSuchAlgorithmException, JsonProcessingException {
log.info(">>>>>>> 签收扫描 start");
// return mtFactoryDataService.qianshouScanForNewSystem(orderPackageCode,operationTime,distributionContactId,destinationWarehouse);
return null;
}
@ -35,6 +38,7 @@ public class MtOrderMainClinet implements IMtOrderMainClinet {
@Override
@PostMapping(SENDRECEIVEINFOBYNEWSYSTEM)
public R sendReceiveInfoByNewSystem(MtReceiveDTO mtReceiveDTO) throws NoSuchAlgorithmException, JsonProcessingException {
log.info(">>>>>>> 文员复核 start");
// return mtFactoryDataService.sendReceiveInfoByNewSystem(mtReceiveDTO);
return null;
}

6
blade-service/logpm-factory/src/main/java/com/logpm/factory/oupai/mapper/FactoryOrderMapper.java

@ -23,6 +23,7 @@ import com.logpm.factory.oupai.vo.FactoryOrderVO;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
/**
* 欧派工厂订单 Mapper 接口
@ -43,4 +44,9 @@ public interface FactoryOrderMapper extends BaseMapper<FactoryOrderEntity> {
FactoryOrderEntity selectEntityByOrderPackageCode(@Param("unitNo") String unitNo);
List<Map<String,Object>> findDataRepeat();
List<Long> findOrderInforIdBySelfCodeAndReceivingid(@Param("selfCode") String selfCode,@Param("receivingId") Long receivingId);
}

10
blade-service/logpm-factory/src/main/java/com/logpm/factory/oupai/mapper/FactoryOrderMapper.xml

@ -21,5 +21,15 @@
ofp.CODE = #{unitNo}
</select>
<select id="findDataRepeat" resultType="map">
SELECT receiving_id,self_code,COUNT(1) num from op_factory_order GROUP BY receiving_id,self_code HAVING COUNT(1)>1;
</select>
<select id="findOrderInforIdBySelfCodeAndReceivingid" resultType="long">
select id from op_factory_order where is_deleted = 0 and (self_code = #{selfCode} and receiving_id = #{receivingId}) ORDER BY create_time
</select>
</mapper>

3
blade-service/logpm-factory/src/main/java/com/logpm/factory/oupai/mapper/ReceivingOrderMapper.java

@ -44,6 +44,9 @@ public interface ReceivingOrderMapper extends BaseMapper<ReceivingOrderEntity> {
List<ReceivingOrderVO> selectReceivingOrderPage(IPage page, ReceivingOrderVO receivingOrder);
String selectReceivingOrderByOrderId (@Param("orderId") Long orderId);

6
blade-service/logpm-factory/src/main/java/com/logpm/factory/oupai/mapper/ReceivingOrderMapper.xml

@ -11,7 +11,11 @@
select * from op_receiving_order where is_deleted = 0
</select>
<select id="selectReceivingOrderByOrderId" resultType="string">
SELECT code from op_receiving_order where id =(
SELECT receiving_id from op_factory_order where id=#{orderId}
)
</select>

4
blade-service/logpm-factory/src/main/java/com/logpm/factory/oupai/service/IOuPaiFactoryService.java

@ -14,7 +14,9 @@ public interface IOuPaiFactoryService {
String saveOuPaiFactoryOrderDTOByCarCarNumber(String carNumber);
String saveOuPaiPackageStatusByCode(String orderPackageCode,Integer event);
String saveOuPaiFactoryOrderDTOByCarCarNumberAgain(String code);
String saveOuPaiPackageStatusByCode(String orderPackageCode, Integer event);
Boolean checkReceivingOrder(String code);

1
blade-service/logpm-factory/src/main/java/com/logpm/factory/oupai/service/impl/FactoryOrderServiceImpl.java

@ -45,6 +45,7 @@ public class FactoryOrderServiceImpl extends BaseServiceImpl<FactoryOrderMapper,
queryWrapper.select("self_code","id");
queryWrapper.eq("self_code",selfCode);
queryWrapper.eq("receiving_id",receivingId);
queryWrapper.last("limit 1");
return baseMapper.selectOne(queryWrapper);
}

590
blade-service/logpm-factory/src/main/java/com/logpm/factory/oupai/service/impl/OuPaiFactoryServiceImpl.java

@ -8,7 +8,6 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.logpm.factory.comfac.constant.FactoryConstant;
import com.logpm.factory.comfac.dto.OrderStatusDTO;
import com.logpm.factory.comfac.service.IAsyncDataService;
import com.logpm.factory.oupai.entity.*;
@ -111,6 +110,52 @@ public class OuPaiFactoryServiceImpl implements IOuPaiFactoryService {
}
@Override
public String saveOuPaiFactoryOrderDTOByCarCarNumberAgain(String code) {
log.info("数据重新获取 start {}", code);
OpOrderStatusLogEntity opOrderStatusLogEntity = findOurPaiDataByCarNumberByLoal(code);
// 保存需要解析的数据
// 获取返回内容
try {
// 需要下载 数据中的内容
String responseUrl = opOrderStatusLogEntity.getResponseUrl();
// 下载这个数据
opOrderStatusLogEntity.setResponseBody(FileLogsUtil.loadFileContent(responseUrl));
JSONObject jsonObject = JSONObject.parseObject(opOrderStatusLogEntity.getResponseBody());
JSONArray resultArray = jsonObject.getJSONArray("value");
log.info("############handleData: 数据处理开始");
analyzeData(resultArray);
opOrderStatusLogEntity.setDataStatus(1);
} catch (Exception e) {
log.error(">>>> 欧派数据解析报错", e);
opOrderStatusLogEntity.setDataStatus(2);
}
opOrderStatusLogService.saveOrUpdate(opOrderStatusLogEntity);
log.info("数据重新获取 end {}", code);
return code;
}
private OpOrderStatusLogEntity findOurPaiDataByCarNumberByLoal(String code) {
// 查询自己数据 判断这个收货单号是否存在
LambdaQueryWrapper<OpOrderStatusLogEntity> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(OpOrderStatusLogEntity::getType, 3);
lambdaQueryWrapper.like(OpOrderStatusLogEntity::getArgs, code);
lambdaQueryWrapper.orderByAsc(OpOrderStatusLogEntity::getCreateTime);
lambdaQueryWrapper.last("limit 1");
return opOrderStatusLogService.getOne(lambdaQueryWrapper);
}
@Override
public String saveOuPaiPackageStatusByCode(String orderPackageCode, Integer event) {
//
@ -372,20 +417,20 @@ public class OuPaiFactoryServiceImpl implements IOuPaiFactoryService {
String currentWarehouseId = orderStatusDTO.getCurrentWarehouse();//当前仓Id
//查询destinationWarehouse logiBillNo plantId数据
log.info("oupai-handleStatusData >>> unitNo={}", unitNo);
Map<String, String> supplyData = advanceDetailClient.getSupplyData(unitNo);
if (ObjectUtils.isEmpty(supplyData)) {
return Resp.fail(400, "未查询到该单据信息");
}
String destinationWarehouseId = supplyData.get("destinationWarehouseId");//目的仓id
if (StringUtil.isBlank(currentWarehouseId) || StringUtil.isBlank(destinationWarehouseId)) {
log.warn("##############oupai-handleStatusData: 仓库数据有问题currentWarehouseId={} destinationWarehouseId={}", currentWarehouseId, destinationWarehouseId);
return Resp.fail(400, "仓库数据有误");
}
if (!currentWarehouseId.equals(destinationWarehouseId)) {
log.info("##############oupai-handleStatusData: 不用处理的状态 currentWarehouseId={} destinationWarehouseId={}", currentWarehouseId, destinationWarehouseId);
return Resp.fail(400, "不是目的仓");
}
// Map<String, String> supplyData = advanceDetailClient.getSupplyData(unitNo);
// if (ObjectUtils.isEmpty(supplyData)) {
// return Resp.fail(400, "未查询到该单据信息");
// }
// String destinationWarehouseId = supplyData.get("destinationWarehouseId");//目的仓id
// if (StringUtil.isBlank(currentWarehouseId) || StringUtil.isBlank(destinationWarehouseId)) {
// log.warn("##############oupai-handleStatusData: 仓库数据有问题currentWarehouseId={} destinationWarehouseId={}", currentWarehouseId, destinationWarehouseId);
// return Resp.fail(400, "仓库数据有误");
// }
//
// if (!currentWarehouseId.equals(destinationWarehouseId)) {
// log.info("##############oupai-handleStatusData: 不用处理的状态 currentWarehouseId={} destinationWarehouseId={}", currentWarehouseId, destinationWarehouseId);
// return Resp.fail(400, "不是目的仓");
// }
// 查询这个包件对应到新系统的订单
FactoryOrderEntity factoryOrder = factoryOrderService.selectEntityByOrderPackageCode(unitNo);
@ -451,21 +496,51 @@ public class OuPaiFactoryServiceImpl implements IOuPaiFactoryService {
if (opPackagePushLogEntity == null) {
log.info(" >>>>>>>>>>>>>>>>>>>>>>> 包件 {} 已推送欧派 状态 {}", unitNo, detailObject.get("Operate"));
} else {
// 需要盘点这个对象的
String resp = opPackagePushLogEntity.getResp();
// 转换为json
// JSONObject respJson = JSONObject.parseObject(resp);
log.info(" >>>>>>>>>>>>>>>>>>>>>>> 推送欧派返回数据 {}", resp);
// TODO: 2023/10/25 不知道返回成功的状态是多少
// 需要修改包件对应的状态
factoryPackageEntity.setPushStatus(1);
factoryPackageService.updateById(factoryPackageEntity);
checkOpFactoryPackagePushStatus(factoryPackageEntity);
}
}
return Resp.success("物流状态传递成功");
}
/**
* 根据推送类型修改包件上的状态
*
* @param factoryPackageEntity
*/
void checkOpFactoryPackagePushStatus(FactoryPackageEntity factoryPackageEntity) {
// 查询推送记录 师傅包含 已收货 已出库
LambdaQueryWrapper<OpPackagePushLogEntity> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(OpPackagePushLogEntity::getRefId, factoryPackageEntity.getId());
lambdaQueryWrapper.eq(OpPackagePushLogEntity::getPushType, 1);// 查询包件
List<OpPackagePushLogEntity> list = opPackagePushLogService.list(lambdaQueryWrapper);
if (list != null && !list.isEmpty()) {
for (OpPackagePushLogEntity opPackagePushLogEntity : list) {
if ("收货".equals(opPackagePushLogEntity.getPushOupaiNode())) {
factoryPackageEntity.setPushStatus(3);
}
if ("发货".equals(opPackagePushLogEntity.getPushOupaiNode())) {
factoryPackageEntity.setPushStatus(4);
}
}
factoryPackageService.updateById(factoryPackageEntity);
} else {
log.info("包件推送记录未null 包条码{}", factoryPackageEntity.getCode());
}
}
/**
* 根据汇通业务提供是否操作欧派系统的商场 来决定是否会推数据
* 如果需要使用欧派系统 这里就需要不进行回传
@ -594,6 +669,7 @@ public class OuPaiFactoryServiceImpl implements IOuPaiFactoryService {
LambdaQueryWrapper<OpPackagePushLogEntity> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(OpPackagePushLogEntity::getRefId, refId);
lambdaQueryWrapper.eq(OpPackagePushLogEntity::getPushOupaiNode, data.getString("Operate"));
lambdaQueryWrapper.eq(OpPackagePushLogEntity::getPushType, pushType);// 查询包件
List<OpPackagePushLogEntity> list = opPackagePushLogService.list(lambdaQueryWrapper);
if (ObjectUtils.isNull(list) || list.isEmpty()) {
OpPackagePushLogEntity opPackagePushLogEntity = new OpPackagePushLogEntity();
@ -669,7 +745,8 @@ public class OuPaiFactoryServiceImpl implements IOuPaiFactoryService {
lambdaQueryWrapper.eq(ReceivingOrderEntity::getCode, code);
List<ReceivingOrderEntity> receivingOrderEntities = receivingOrderMapper.selectList(lambdaQueryWrapper);
if (ObjectUtils.isNotNull(receivingOrderEntities)) {
log.info(">>>>>>>>>>>>>>>>>>>>>>> 收货单已存在 {} ", code);
log.info(">>>>>>>>>>>>>>>>>>>>>>> 收货单已存在 收货单下面的订单是否存在 包件是否存在{} ", code);
extractedOuPaiOrderPackageInfor(valueObject, receivingOrderEntities.get(0).getId(), code);
return;
}
@ -729,246 +806,270 @@ public class OuPaiFactoryServiceImpl implements IOuPaiFactoryService {
if (row == 1) {
log.info("############handleData: 保存发货单数据 成功成功成功成功 code={}", code);
Long receivingId = receivingOrderEntity.getId();//发货单id
JSONArray packages = valueObject.getJSONArray("Packages");
for (int j = 0; j < packages.size(); j++) {
JSONObject packageEntity = packages.getJSONObject(j);//包件信息
JSONObject orderEntity = packageEntity.getJSONObject("Order");//订单信息
if (orderEntity == null) {
log.info("包件数据没有订单信息 packageCode {}", packageEntity.getString("Code"));
continue;
}
String selfCode = orderEntity.getString("SelfCode");//订单自编码
//先查询是否存在订单自编码
//
FactoryOrderEntity factoryOrderEntity = factoryOrderService.selectEntityBySelfCode(selfCode, receivingId);
if(Objects.isNull(factoryOrderEntity)){
factoryOrderEntity = new FactoryOrderEntity();
factoryOrderEntity.setCode(orderEntity.getString("Code"));
factoryOrderEntity.setSelfCode(selfCode);
factoryOrderEntity.setContractNumber(orderEntity.getString("ContractNumber"));
factoryOrderEntity.setServiceNumber(orderEntity.getString("ServiceNumber"));
factoryOrderEntity.setOrderClass(orderEntity.getString("OrderClass"));
factoryOrderEntity.setOrderType(orderEntity.getString("OrderType"));
String factoryStatus = orderEntity.getString("Status");
if ("待送货".equals(factoryStatus)) {
factoryOrderEntity.setFactoryStatus(0);
} else if ("已签收".equals(factoryStatus)) {
factoryOrderEntity.setFactoryStatus(2);
} else if ("已取消".equals(factoryStatus)) {
factoryOrderEntity.setFactoryStatus(3);
} else if ("部分签收".equals(factoryStatus)) {
factoryOrderEntity.setFactoryStatus(6);
}
extractedOuPaiOrderPackageInfor(valueObject, receivingId, code);
} else {
log.error("############handleData: 保存发货单数据失败 code={}", code);
throw new CustomerException(403, "保存发货单数据失败");
}
Date end = new Date();
long startLong = start.getTime();
long endLong = end.getTime();
long l = endLong - startLong;
log.info("############handleData: 数据处理完成 耗时 {} 毫秒", l);
}
String factoryShipStatus = orderEntity.getString("FactoryShipStatus");
if ("工厂未发货".equals(factoryShipStatus)) {
factoryOrderEntity.setFactoryShipStatus(0);
} else if ("工厂部分发货".equals(factoryShipStatus)) {
factoryOrderEntity.setFactoryShipStatus(1);
} else if ("工厂齐套发货".equals(factoryShipStatus)) {
factoryOrderEntity.setFactoryShipStatus(2);
}
factoryOrderEntity.setFactorySendQty(orderEntity.getInteger("FactorySendQty"));
String warehouseReceiveStatus = orderEntity.getString("WarehouseReceiveStatus");
if ("仓库未收货".equals(warehouseReceiveStatus)) {
factoryOrderEntity.setWarehouseReceiveStatus(0);
} else if ("仓库部分收货".equals(warehouseReceiveStatus)) {
factoryOrderEntity.setWarehouseReceiveStatus(1);
} else if ("仓库全部收货".equals(warehouseReceiveStatus)) {
factoryOrderEntity.setWarehouseReceiveStatus(2);
}
factoryOrderEntity.setWarehouseReceiveQty(orderEntity.getInteger("WarehouseReceiveQty"));
}
String reservationStatus = orderEntity.getString("ReservationStatus");
if ("不可预约".equals(reservationStatus)) {
factoryOrderEntity.setReservationStatus(0);
} else if ("可预约".equals(reservationStatus)) {
factoryOrderEntity.setReservationStatus(1);
}
/**
* 欧派入库方法
*
* @param valueObject
* @param receivingId
* @param code
*/
private void extractedOuPaiOrderPackageInfor(JSONObject valueObject, Long receivingId, String code) {
JSONArray packages = valueObject.getJSONArray("Packages");
log.info(">>> 获取的包件长度 {}", packages.size());
for (int j = 0; j < packages.size(); j++) {
JSONObject packageEntity = packages.getJSONObject(j);//包件信息
log.info(">>>>> 解析出欧派的包件信息 {}", packageEntity.getString("Code"));
JSONObject orderEntity = packageEntity.getJSONObject("Order");//订单信息
if (orderEntity == null) {
log.info("包件数据没有订单信息 packageCode {}", packageEntity.getString("Code"));
continue;
}
String selfCode = orderEntity.getString("SelfCode");//订单自编码
//先查询是否存在订单自编码
//
FactoryOrderEntity factoryOrderEntity = factoryOrderService.selectEntityBySelfCode(selfCode, receivingId);
if (Objects.isNull(factoryOrderEntity)) {
log.info(" oupai 收货单ID{} 收货单下面的订单不存在 进行新增订单 {}", receivingId, selfCode);
factoryOrderEntity = new FactoryOrderEntity();
factoryOrderEntity.setCode(orderEntity.getString("Code"));
factoryOrderEntity.setSelfCode(selfCode);
factoryOrderEntity.setContractNumber(orderEntity.getString("ContractNumber"));
factoryOrderEntity.setServiceNumber(orderEntity.getString("ServiceNumber"));
factoryOrderEntity.setOrderClass(orderEntity.getString("OrderClass"));
factoryOrderEntity.setOrderType(orderEntity.getString("OrderType"));
String factoryStatus = orderEntity.getString("Status");
if ("待送货".equals(factoryStatus)) {
factoryOrderEntity.setFactoryStatus(0);
} else if ("已签收".equals(factoryStatus)) {
factoryOrderEntity.setFactoryStatus(2);
} else if ("已取消".equals(factoryStatus)) {
factoryOrderEntity.setFactoryStatus(3);
} else if ("部分签收".equals(factoryStatus)) {
factoryOrderEntity.setFactoryStatus(6);
}
JSONObject store = orderEntity.getJSONObject("Store");
if (!Objects.isNull(store)) {
factoryOrderEntity.setStoreCode(store.getString("Code"));
factoryOrderEntity.setStoreName(store.getString("Name"));
JSONObject shop = store.getJSONObject("Shop");
if (!Objects.isNull(shop)) {
factoryOrderEntity.setShopCode(shop.getString("Code"));
factoryOrderEntity.setShopName(shop.getString("Name"));
factoryOrderEntity.setBusinessModel(shop.getString("BusinessModel"));
}
String factoryShipStatus = orderEntity.getString("FactoryShipStatus");
if ("工厂未发货".equals(factoryShipStatus)) {
factoryOrderEntity.setFactoryShipStatus(0);
} else if ("工厂部分发货".equals(factoryShipStatus)) {
factoryOrderEntity.setFactoryShipStatus(1);
} else if ("工厂齐套发货".equals(factoryShipStatus)) {
factoryOrderEntity.setFactoryShipStatus(2);
}
factoryOrderEntity.setFactorySendQty(orderEntity.getInteger("FactorySendQty"));
String warehouseReceiveStatus = orderEntity.getString("WarehouseReceiveStatus");
if ("仓库未收货".equals(warehouseReceiveStatus)) {
factoryOrderEntity.setWarehouseReceiveStatus(0);
} else if ("仓库部分收货".equals(warehouseReceiveStatus)) {
factoryOrderEntity.setWarehouseReceiveStatus(1);
} else if ("仓库全部收货".equals(warehouseReceiveStatus)) {
factoryOrderEntity.setWarehouseReceiveStatus(2);
}
factoryOrderEntity.setWarehouseReceiveQty(orderEntity.getInteger("WarehouseReceiveQty"));
}
String reservationStatus = orderEntity.getString("ReservationStatus");
if ("不可预约".equals(reservationStatus)) {
factoryOrderEntity.setReservationStatus(0);
} else if ("可预约".equals(reservationStatus)) {
factoryOrderEntity.setReservationStatus(1);
}
factoryOrderEntity.setMatingCode(orderEntity.getString("MatingCode"));
Boolean isMating = orderEntity.getBoolean("IsMating");
if (isMating) {
factoryOrderEntity.setIsMating(1);
} else {
factoryOrderEntity.setIsMating(0);
}
factoryOrderEntity.setFirstClassCode(orderEntity.getString("FirstClassCode"));
Boolean leave = orderEntity.getBoolean("Leave");
if (leave) {
factoryOrderEntity.setLeaveStatus(1);
} else {
factoryOrderEntity.setLeaveStatus(0);
}
factoryOrderEntity.setCustomer(orderEntity.getString("Customer"));
factoryOrderEntity.setProvince(orderEntity.getString("Province"));
factoryOrderEntity.setCity(orderEntity.getString("City"));
factoryOrderEntity.setCustomerAddress(orderEntity.getString("CustomerAddress"));
factoryOrderEntity.setCustomerPhone(orderEntity.getString("CustomerPhone"));
factoryOrderEntity.setShopReceiver(orderEntity.getString("ShopReceiver"));
factoryOrderEntity.setBrandCode(orderEntity.getString("BrandCode"));
factoryOrderEntity.setBrandName(orderEntity.getString("BrandName"));
factoryOrderEntity.setFirstShipTime(CommonUtil.StringToDateByT(orderEntity.getString("FirstShipTime")));
factoryOrderEntity.setMatingShipTime(CommonUtil.StringToDateByT(orderEntity.getString("MatingShipTime")));
factoryOrderEntity.setFirstReceiveTime(CommonUtil.StringToDateByT(orderEntity.getString("FirstReceiveTime")));
factoryOrderEntity.setMatingReceiveTime(CommonUtil.StringToDateByT(orderEntity.getString("MatingReceiveTime")));
Boolean freeze = orderEntity.getBoolean("Freeze");
if (freeze) {
factoryOrderEntity.setFreeze(1);
} else {
factoryOrderEntity.setFreeze(0);
}
factoryOrderEntity.setOutGoingTime(CommonUtil.StringToDateByT(orderEntity.getString("OutGoingTime")));
factoryOrderEntity.setStatus(0);
factoryOrderEntity.setReceivingId(receivingId);
factoryOrderEntity.setReceiptStatus(0);
factoryOrderEntity.setPushStatus(0);
factoryOrderEntity.setTurnStatus(0);
//
boolean save = factoryOrderService.save(factoryOrderEntity);
if (!save) {
log.error("############handleData: 保存订单失败 selfCode={}", selfCode);
throw new CustomerException(403, "保存订单失败");
}
JSONObject store = orderEntity.getJSONObject("Store");
if (!Objects.isNull(store)) {
factoryOrderEntity.setStoreCode(store.getString("Code"));
factoryOrderEntity.setStoreName(store.getString("Name"));
JSONObject shop = store.getJSONObject("Shop");
if (!Objects.isNull(shop)) {
factoryOrderEntity.setShopCode(shop.getString("Code"));
factoryOrderEntity.setShopName(shop.getString("Name"));
factoryOrderEntity.setBusinessModel(shop.getString("BusinessModel"));
}
//保存订单成功,继续保存包件
Long orderId = factoryOrderEntity.getId();
String packageCode = packageEntity.getString("Code");
LambdaQueryWrapper<FactoryPackageEntity> packageEntityQueryWrapper = new LambdaQueryWrapper<>();
packageEntityQueryWrapper.eq(FactoryPackageEntity::getCode, packageCode);
FactoryPackageEntity factoryPackageEntity = factoryPackageService.getOne(packageEntityQueryWrapper);
if (Objects.isNull(factoryPackageEntity)) {
factoryPackageEntity = new FactoryPackageEntity();
factoryPackageEntity.setOrderId(orderId);
factoryPackageEntity.setCode(packageCode);
factoryPackageEntity.setOid(packageEntity.getString("Oid"));
factoryPackageEntity.setFirstClassCode(packageEntity.getString("FirstClassCode"));
factoryPackageEntity.setFirstClassName(packageEntity.getString("FirstClassName"));
factoryPackageEntity.setSecondClassCode(packageEntity.getString("SecondClassCode"));
factoryPackageEntity.setSecondClassName(packageEntity.getString("SecondClassName"));
factoryPackageEntity.setThirdClassCode(packageEntity.getString("ThirdClassCode"));
factoryPackageEntity.setThirdClassName(packageEntity.getString("ThirdClassName"));
factoryPackageEntity.setPackageDetailNames(packageEntity.getString("PackageDetailNames"));
factoryPackageEntity.setCarNumber(packageEntity.getString("CarNumber"));
factoryPackageEntity.setReserve1(factoryOrderEntity.getCode());
Boolean buyIn = packageEntity.getBoolean("BuyIn");
if (buyIn) {
factoryPackageEntity.setBuyin(1);
} else {
factoryPackageEntity.setBuyin(0);
}
factoryPackageEntity.setCosourcingCode(packageEntity.getString("CosourcingCode"));
factoryPackageEntity.setCosourcingUnit(packageEntity.getString("CosourcingUnit"));
String packageStatus = packageEntity.getString("PackageStatus");
//未知:0 已调度:1 已装车:2 待收货:3 已收货:4 已在库:5 待理货:6 待上架:7 已上架:8 已下架:9 已发运:10 已签收:11 待返货:12 已提件:13 已拒收:14 异常:-1
if ("已调度".equals(packageStatus)) {
factoryPackageEntity.setPackageStatus(1);
} else if ("已装车".equals(packageStatus)) {
factoryPackageEntity.setPackageStatus(2);
} else if ("待收货".equals(packageStatus)) {
factoryPackageEntity.setPackageStatus(3);
} else if ("已收货".equals(packageStatus)) {
factoryPackageEntity.setPackageStatus(4);
} else if ("已在库".equals(packageStatus)) {
factoryPackageEntity.setPackageStatus(5);
} else if ("待理货".equals(packageStatus)) {
factoryPackageEntity.setPackageStatus(6);
} else if ("待上架".equals(packageStatus)) {
factoryPackageEntity.setPackageStatus(7);
} else if ("已上架".equals(packageStatus)) {
factoryPackageEntity.setPackageStatus(8);
} else if ("已下架".equals(packageStatus)) {
factoryPackageEntity.setPackageStatus(9);
} else if ("已发运".equals(packageStatus)) {
factoryPackageEntity.setPackageStatus(10);
} else if ("已签收".equals(packageStatus)) {
factoryPackageEntity.setPackageStatus(11);
} else if ("待返货".equals(packageStatus)) {
factoryPackageEntity.setPackageStatus(12);
} else if ("已提件".equals(packageStatus)) {
factoryPackageEntity.setPackageStatus(13);
} else if ("已拒收".equals(packageStatus)) {
factoryPackageEntity.setPackageStatus(14);
} else if ("异常".equals(packageStatus)) {
factoryPackageEntity.setPackageStatus(-1);
} else {
factoryPackageEntity.setPackageStatus(0);
}
factoryPackageEntity.setLength(packageEntity.getBigDecimal("Length"));
factoryPackageEntity.setWidth(packageEntity.getBigDecimal("Width"));
factoryPackageEntity.setHeight(packageEntity.getBigDecimal("Height"));
factoryPackageEntity.setWeight(packageEntity.getBigDecimal("Weight"));
Boolean isInventory = packageEntity.getBoolean("IsInventory");
if (isInventory) {
factoryPackageEntity.setIsInventory(1);
} else {
factoryPackageEntity.setIsInventory(0);
}
Boolean packageFreeze = packageEntity.getBoolean("Freeze");
if (packageFreeze) {
factoryPackageEntity.setFreeze(1);
} else {
factoryPackageEntity.setFreeze(0);
}
}
//保存包件信息
factoryPackageEntity.setReceiptStatus(0);
factoryPackageEntity.setPushStatus(0);
factoryPackageEntity.setTurnStatus(0);
boolean packageSave = factoryPackageService.save(factoryPackageEntity);
if (packageSave) {
Long packageId = factoryPackageEntity.getId();
//保存物料信息
JSONArray packageDetails = packageEntity.getJSONArray("PackageDetails");
if (!Objects.isNull(packageDetails)) {
for (int k = 0; k < packageDetails.size(); k++) {
JSONObject packageDetailsJSONObject = packageDetails.getJSONObject(k);
FactoryPackageDetailEntity factoryPackageDetailEntity = new FactoryPackageDetailEntity();
factoryPackageDetailEntity.setPackageId(packageId);
factoryPackageDetailEntity.setCode(packageDetailsJSONObject.getString("Code"));
factoryPackageDetailEntity.setName(packageDetailsJSONObject.getString("Name"));
factoryPackageDetailEntity.setType(packageDetailsJSONObject.getString("Type"));
factoryPackageDetailEntity.setUnit(packageDetailsJSONObject.getString("Unit"));
factoryPackageDetailEntity.setOrgCode(packageDetailsJSONObject.getString("OrgCode"));
factoryPackageDetailService.save(factoryPackageDetailEntity);
}
}
}
} else {
factoryOrderEntity.setMatingCode(orderEntity.getString("MatingCode"));
Boolean isMating = orderEntity.getBoolean("IsMating");
if (isMating) {
factoryOrderEntity.setIsMating(1);
} else {
factoryOrderEntity.setIsMating(0);
}
factoryOrderEntity.setFirstClassCode(orderEntity.getString("FirstClassCode"));
Boolean leave = orderEntity.getBoolean("Leave");
if (leave) {
factoryOrderEntity.setLeaveStatus(1);
} else {
factoryOrderEntity.setLeaveStatus(0);
}
factoryOrderEntity.setCustomer(orderEntity.getString("Customer"));
factoryOrderEntity.setProvince(orderEntity.getString("Province"));
factoryOrderEntity.setCity(orderEntity.getString("City"));
factoryOrderEntity.setCustomerAddress(orderEntity.getString("CustomerAddress"));
factoryOrderEntity.setCustomerPhone(orderEntity.getString("CustomerPhone"));
factoryOrderEntity.setShopReceiver(orderEntity.getString("ShopReceiver"));
factoryOrderEntity.setBrandCode(orderEntity.getString("BrandCode"));
factoryOrderEntity.setBrandName(orderEntity.getString("BrandName"));
factoryOrderEntity.setFirstShipTime(CommonUtil.StringToDateByT(orderEntity.getString("FirstShipTime")));
factoryOrderEntity.setMatingShipTime(CommonUtil.StringToDateByT(orderEntity.getString("MatingShipTime")));
factoryOrderEntity.setFirstReceiveTime(CommonUtil.StringToDateByT(orderEntity.getString("FirstReceiveTime")));
factoryOrderEntity.setMatingReceiveTime(CommonUtil.StringToDateByT(orderEntity.getString("MatingReceiveTime")));
Boolean freeze = orderEntity.getBoolean("Freeze");
if (freeze) {
factoryOrderEntity.setFreeze(1);
} else {
factoryOrderEntity.setFreeze(0);
}
factoryOrderEntity.setOutGoingTime(CommonUtil.StringToDateByT(orderEntity.getString("OutGoingTime")));
factoryOrderEntity.setStatus(0);
factoryOrderEntity.setReceivingId(receivingId);
factoryOrderEntity.setReceiptStatus(0);
factoryOrderEntity.setPushStatus(0);
factoryOrderEntity.setTurnStatus(0);
//
boolean save = factoryOrderService.save(factoryOrderEntity);
if (!save) {
log.error("############handleData: 保存订单失败 selfCode={}", selfCode);
throw new CustomerException(403, "保存订单失败");
}
}
log.error("############handleData: 包件码已存在 packageCode={} 收货单号 {}", packageCode,code);
//保存订单成功,继续保存包件
Long orderId = factoryOrderEntity.getId();
String packageCode = packageEntity.getString("Code");
LambdaQueryWrapper<FactoryPackageEntity> packageEntityQueryWrapper = new LambdaQueryWrapper<>();
packageEntityQueryWrapper.eq(FactoryPackageEntity::getCode, packageCode);
FactoryPackageEntity factoryPackageEntity = factoryPackageService.getOne(packageEntityQueryWrapper);
if (Objects.isNull(factoryPackageEntity)) {
log.info(" oupai 收货单ID{} 收货单下面的包件不存在 进行新增订单 {} 关联包件 {}", receivingId, selfCode, packageCode);
factoryPackageEntity = new FactoryPackageEntity();
factoryPackageEntity.setOrderId(orderId);
factoryPackageEntity.setCode(packageCode);
factoryPackageEntity.setOid(packageEntity.getString("Oid"));
factoryPackageEntity.setFirstClassCode(packageEntity.getString("FirstClassCode"));
factoryPackageEntity.setFirstClassName(packageEntity.getString("FirstClassName"));
factoryPackageEntity.setSecondClassCode(packageEntity.getString("SecondClassCode"));
factoryPackageEntity.setSecondClassName(packageEntity.getString("SecondClassName"));
factoryPackageEntity.setThirdClassCode(packageEntity.getString("ThirdClassCode"));
factoryPackageEntity.setThirdClassName(packageEntity.getString("ThirdClassName"));
factoryPackageEntity.setPackageDetailNames(packageEntity.getString("PackageDetailNames"));
factoryPackageEntity.setCarNumber(packageEntity.getString("CarNumber"));
factoryPackageEntity.setReserve1(factoryOrderEntity.getCode());
Boolean buyIn = packageEntity.getBoolean("BuyIn");
if (buyIn) {
factoryPackageEntity.setBuyin(1);
} else {
factoryPackageEntity.setBuyin(0);
}
factoryPackageEntity.setCosourcingCode(packageEntity.getString("CosourcingCode"));
factoryPackageEntity.setCosourcingUnit(packageEntity.getString("CosourcingUnit"));
String packageStatus = packageEntity.getString("PackageStatus");
//未知:0 已调度:1 已装车:2 待收货:3 已收货:4 已在库:5 待理货:6 待上架:7 已上架:8 已下架:9 已发运:10 已签收:11 待返货:12 已提件:13 已拒收:14 异常:-1
if ("已调度".equals(packageStatus)) {
factoryPackageEntity.setPackageStatus(1);
} else if ("已装车".equals(packageStatus)) {
factoryPackageEntity.setPackageStatus(2);
} else if ("待收货".equals(packageStatus)) {
factoryPackageEntity.setPackageStatus(3);
} else if ("已收货".equals(packageStatus)) {
factoryPackageEntity.setPackageStatus(4);
} else if ("已在库".equals(packageStatus)) {
factoryPackageEntity.setPackageStatus(5);
} else if ("待理货".equals(packageStatus)) {
factoryPackageEntity.setPackageStatus(6);
} else if ("待上架".equals(packageStatus)) {
factoryPackageEntity.setPackageStatus(7);
} else if ("已上架".equals(packageStatus)) {
factoryPackageEntity.setPackageStatus(8);
} else if ("已下架".equals(packageStatus)) {
factoryPackageEntity.setPackageStatus(9);
} else if ("已发运".equals(packageStatus)) {
factoryPackageEntity.setPackageStatus(10);
} else if ("已签收".equals(packageStatus)) {
factoryPackageEntity.setPackageStatus(11);
} else if ("待返货".equals(packageStatus)) {
factoryPackageEntity.setPackageStatus(12);
} else if ("已提件".equals(packageStatus)) {
factoryPackageEntity.setPackageStatus(13);
} else if ("已拒收".equals(packageStatus)) {
factoryPackageEntity.setPackageStatus(14);
} else if ("异常".equals(packageStatus)) {
factoryPackageEntity.setPackageStatus(-1);
} else {
factoryPackageEntity.setPackageStatus(0);
}
factoryPackageEntity.setLength(packageEntity.getBigDecimal("Length"));
factoryPackageEntity.setWidth(packageEntity.getBigDecimal("Width"));
factoryPackageEntity.setHeight(packageEntity.getBigDecimal("Height"));
factoryPackageEntity.setWeight(packageEntity.getBigDecimal("Weight"));
Boolean isInventory = packageEntity.getBoolean("IsInventory");
if (isInventory) {
factoryPackageEntity.setIsInventory(1);
} else {
factoryPackageEntity.setIsInventory(0);
}
Boolean packageFreeze = packageEntity.getBoolean("Freeze");
if (packageFreeze) {
factoryPackageEntity.setFreeze(1);
} else {
factoryPackageEntity.setFreeze(0);
}
//throw new CustomerException(403, "包件码已存在");
//保存包件信息
factoryPackageEntity.setReceiptStatus(0);
factoryPackageEntity.setPushStatus(0);
factoryPackageEntity.setTurnStatus(0);
boolean packageSave = factoryPackageService.save(factoryPackageEntity);
if (packageSave) {
Long packageId = factoryPackageEntity.getId();
//保存物料信息
JSONArray packageDetails = packageEntity.getJSONArray("PackageDetails");
if (!Objects.isNull(packageDetails)) {
for (int k = 0; k < packageDetails.size(); k++) {
JSONObject packageDetailsJSONObject = packageDetails.getJSONObject(k);
FactoryPackageDetailEntity factoryPackageDetailEntity = new FactoryPackageDetailEntity();
factoryPackageDetailEntity.setPackageId(packageId);
factoryPackageDetailEntity.setCode(packageDetailsJSONObject.getString("Code"));
factoryPackageDetailEntity.setName(packageDetailsJSONObject.getString("Name"));
factoryPackageDetailEntity.setType(packageDetailsJSONObject.getString("Type"));
factoryPackageDetailEntity.setUnit(packageDetailsJSONObject.getString("Unit"));
factoryPackageDetailEntity.setOrgCode(packageDetailsJSONObject.getString("OrgCode"));
factoryPackageDetailService.save(factoryPackageDetailEntity);
}
}
}
} else {
log.error("############handleData: 保存发货单数据失败 code={}", code);
throw new CustomerException(403, "保存发货单数据失败");
String receiveCode = receivingOrderMapper.selectReceivingOrderByOrderId(factoryPackageEntity.getOrderId());
if(receiveCode.equals(code)){
log.error("############handleData: 包件码已存在 packageCode={} ,订单 id {} 收货单号 {}", packageCode, factoryPackageEntity.getOrderId(), code);
}else{
log.error("############handleData: 该包件存在于其它收货单 packageCode={} 订单ID {} 收货单号 {}", packageCode,factoryPackageEntity.getOrderId(), receiveCode);
}
//throw new CustomerException(403, "包件码已存在");
}
Date end = new Date();
long startLong = start.getTime();
long endLong = end.getTime();
long l = endLong - startLong;
log.info("############handleData: 数据处理完成 耗时 {} 毫秒", l);
}
}
@ -980,6 +1081,7 @@ public class OuPaiFactoryServiceImpl implements IOuPaiFactoryService {
*/
private OpOrderStatusLogEntity findOurPaiDataByCarNumber(String code) {
String url = ouPaiProperties.getUri() + "tims_odata_api/api/odata/ReceivingOrder?$filter=Code eq '" + code + "'&select=Code,Type,Status,Plate,PackagesCount,ReceivePackageCount,PlateNum,CarNumber,CarrierCode,SendTime,ArrivalTime,ReceiveTime,CreateTime,ReturnNumber\n" +
"&$expand=" +
"Packages($select=Oid,Code,PdaNumber,FirstClassCode,FirstClassName,SecondClassCode,SecondClassName,ThirdClassCode,ThirdClassName,BuyIn,CosourcingCode,CosourcingUnit,SortingCenter,DistributionCenter,Length,Width,Height,Weight,OrderDetail,Order,PathIndex,PathDetail,DeliveryOrders,ReceivingOrders,LPN,LpnSerialNum,IsEntruck,ReservationOrder,OutGoingOrderDetail,SignBill,IsInventory,Inventories,InventoryInDetails,Freeze,OutGoingOrderDetailInventoryDetail,From,Creator,CreateTime,ShipTime,CarNumber,DeliveryMethod,DeliveryReceiver,DeliveryReceiverPhone,ReturnNumber,GroupType,CarrierCode,CarrierName,PackageDetailNames,ReceivingTime,SendTime,ExceptionSignRemark,Descript,SignTime,OutOrder,IsReceiveByHand,PackageStatus,PackageDetailNames;" +

Loading…
Cancel
Save