Browse Source

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

training
caoyizhong 2 years ago
parent
commit
207d69305c
  1. 34
      blade-service-api/logpm-factory-api/src/main/java/com/logpm/factory/jp/entity/JinpaiArrivalOrderEntity.java
  2. 18
      blade-service-api/logpm-factory-api/src/main/java/com/logpm/factory/jp/entity/JinpaiOrgIdEntity.java
  3. 35
      blade-service-api/logpm-factory-api/src/main/java/com/logpm/factory/jp/entity/JinpaiPushScanLogEntity.java
  4. 3
      blade-service-api/logpm-factory-api/src/main/java/com/logpm/factory/oupai/entity/FactoryPackageEntity.java
  5. 17
      blade-service/logpm-factory/src/main/java/com/logpm/factory/jp/bean/ApiResponse.java
  6. 107
      blade-service/logpm-factory/src/main/java/com/logpm/factory/jp/bean/LoginRes.java
  7. 15
      blade-service/logpm-factory/src/main/java/com/logpm/factory/jp/bean/NowOrg.java
  8. 16
      blade-service/logpm-factory/src/main/java/com/logpm/factory/jp/bean/OriginalOrg.java
  9. 16
      blade-service/logpm-factory/src/main/java/com/logpm/factory/jp/bean/OwnedOrgs.java
  10. 65
      blade-service/logpm-factory/src/main/java/com/logpm/factory/jp/bean/PushScanLog.java
  11. 9
      blade-service/logpm-factory/src/main/java/com/logpm/factory/jp/bean/RCookie.java
  12. 164
      blade-service/logpm-factory/src/main/java/com/logpm/factory/jp/bean/Tran.java
  13. 236
      blade-service/logpm-factory/src/main/java/com/logpm/factory/jp/jobhandler/PullJpDataJob.java
  14. 9
      blade-service/logpm-factory/src/main/java/com/logpm/factory/jp/mapper/JinpaiArrivalOrderMapper.java
  15. 10
      blade-service/logpm-factory/src/main/java/com/logpm/factory/jp/mapper/JinpaiOrgIdMapper.java
  16. 9
      blade-service/logpm-factory/src/main/java/com/logpm/factory/jp/mapper/JinpaiPushScanLogMapper.java
  17. 7
      blade-service/logpm-factory/src/main/java/com/logpm/factory/jp/service/IJinpaiArrivalOrderService.java
  18. 7
      blade-service/logpm-factory/src/main/java/com/logpm/factory/jp/service/IJinpaiOrgIdService.java
  19. 7
      blade-service/logpm-factory/src/main/java/com/logpm/factory/jp/service/IJinpaiPushScanLogService.java
  20. 15
      blade-service/logpm-factory/src/main/java/com/logpm/factory/jp/service/impl/JinpaiArrivalOrderServiceImpl.java
  21. 15
      blade-service/logpm-factory/src/main/java/com/logpm/factory/jp/service/impl/JinpaiOrgIdServiceImpl.java
  22. 15
      blade-service/logpm-factory/src/main/java/com/logpm/factory/jp/service/impl/JinpaiPushScanLogServiceImpl.java
  23. 63
      blade-service/logpm-factory/src/main/java/com/logpm/factory/jp/util/JsonUtil.java
  24. 55
      blade-service/logpm-factory/src/main/java/com/logpm/factory/oupai/receiver/OpOldReceivingDataHandler.java
  25. 51
      blade-service/logpm-factory/src/main/java/com/logpm/factory/oupai/service/impl/OuPaiFactoryServiceImpl.java
  26. 17
      blade-service/logpm-factory/src/test/java/com/logpm/factory/TestService.java

34
blade-service-api/logpm-factory-api/src/main/java/com/logpm/factory/jp/entity/JinpaiArrivalOrderEntity.java

@ -0,0 +1,34 @@
package com.logpm.factory.jp.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springblade.core.mp.base.BaseEntity;
import java.util.Date;
@Data
@TableName("jinpai_arrival_order")
@ApiModel(value = "JinpaiArrivalOrder对象", description = "金牌到达订单")
@EqualsAndHashCode(callSuper = true)
public class JinpaiArrivalOrderEntity extends BaseEntity {
private String warehouseName;
private String ddNum;
private String ysNum;
private String contractNumber;
private Date deliveryTime;
private String serviceType;
private String store;
private String storeCode;
private String arrivalStatus;
private Integer total;
private Date arrivalTime;
private String administrators;
private String truckNo;
private Date loadingTime;
private Date actualArrivalTime;
private String source;
}

18
blade-service-api/logpm-factory-api/src/main/java/com/logpm/factory/jp/entity/JinpaiOrgIdEntity.java

@ -0,0 +1,18 @@
package com.logpm.factory.jp.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springblade.core.mp.base.BaseEntity;
@Data
@TableName("jinpai_org_id")
@ApiModel(value = "JinpaiOrgId对象", description = "金牌组织id")
@EqualsAndHashCode(callSuper = true)
public class JinpaiOrgIdEntity extends BaseEntity {
private String orgId;
private String orgName;
}

35
blade-service-api/logpm-factory-api/src/main/java/com/logpm/factory/jp/entity/JinpaiPushScanLogEntity.java

@ -0,0 +1,35 @@
package com.logpm.factory.jp.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springblade.core.mp.base.BaseEntity;
import java.util.Date;
@Data
@TableName("jinpai_push_scan_log")
@ApiModel(value = "JinpaiPushScanLog对象", description = "金牌扫描记录")
@EqualsAndHashCode(callSuper = true)
public class JinpaiPushScanLogEntity extends BaseEntity {
private String warehouseName;
private String batchNumber;
private String ysNum;
private String contractNumber;
private String ddNum;
private String unitNo;
private String inStatus;
private String inType;
private String serviceType;
private Date deliveryTime;
private Date scanTime;
private Date arrivalTime;
private String store;
private String storeCode;
private String administrators;
private String source;
}

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

@ -62,6 +62,9 @@ public class FactoryPackageEntity extends BaseEntity {
/** 三级品类名称 */
@ApiModelProperty(name = "三级品类名称",notes = "")
private String thirdClassName ;
@ApiModelProperty(name = "物料名称合集",notes = "")
private String packageDetailNames ;
/** 补进 */
@ApiModelProperty(name = "补进",notes = "")
private Integer buyin ;

17
blade-service/logpm-factory/src/main/java/com/logpm/factory/jp/bean/ApiResponse.java

@ -0,0 +1,17 @@
package com.logpm.factory.jp.bean;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Data;
import java.util.List;
@Data
@JsonIgnoreProperties(ignoreUnknown = true)
public class ApiResponse<T> {
private int code;
private String message;
private T data;
private List<T> rows;
}

107
blade-service/logpm-factory/src/main/java/com/logpm/factory/jp/bean/LoginRes.java

@ -0,0 +1,107 @@
package com.logpm.factory.jp.bean;
import lombok.Data;
import java.util.List;
@Data
public class LoginRes implements RCookie {
private String userId;
private String account;
private String nickname;
private String passwordExpirationTime;
private String username;
private String password;
private int sex;
private int age;
private String phone;
private int status;
private String organizationId;
private String createTime;
private String creator;
private String syscode;
private String sysname;
private String orgId;
private String systemdef;
private String companyPid;
private String companyPname;
private String companyId;
private String orgName;
private boolean forceModifyPwd;
private String customerAuthority;
private String loginTime;
private String activeTime;
private String isEnable;
private String printFlag;
private String memberType;
private String logoUrl;
private String baseLine;
private String twoCodeFlag;
private String labelNewServerSwitch;
private String mongoBaselineSwitch;
private String switchConsignerCodeMust;
private String enterpriseName;
private int crmVisitSwitch;
private String switchUserConsignerAdd;
private String switchSmsCheckOpen;
private String orgType;
private String ucgn;
private String fydFlag;
private String email;
private OriginalOrg originalOrg;
private String originalOrgIndex;
private NowOrg nowOrg;
private int nowOrgIndex;
private List<OwnedOrgs> ownedOrgs;
public String cookie;
}

15
blade-service/logpm-factory/src/main/java/com/logpm/factory/jp/bean/NowOrg.java

@ -0,0 +1,15 @@
package com.logpm.factory.jp.bean;
import lombok.Data;
@Data
public class NowOrg {
private String id;
private String code;
private String name;
private String orgType;
}

16
blade-service/logpm-factory/src/main/java/com/logpm/factory/jp/bean/OriginalOrg.java

@ -0,0 +1,16 @@
package com.logpm.factory.jp.bean;
import lombok.Data;
@Data
public class OriginalOrg {
private String id;
private String code;
private String name;
private String orgType;
}

16
blade-service/logpm-factory/src/main/java/com/logpm/factory/jp/bean/OwnedOrgs.java

@ -0,0 +1,16 @@
package com.logpm.factory.jp.bean;
import lombok.Data;
@Data
public class OwnedOrgs {
private String id;
private String code;
private String name;
private String orgType;
}

65
blade-service/logpm-factory/src/main/java/com/logpm/factory/jp/bean/PushScanLog.java

@ -0,0 +1,65 @@
package com.logpm.factory.jp.bean;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import java.math.BigDecimal;
@Data
public class PushScanLog {
@JsonProperty("REMARK")
private String remark;
@JsonProperty("SYSCODE")
private String sysCode;
private String arriveOrgId;
private String arriveOrgName;
private Integer checkFlag;
private String containerId;
private String deliveryMode;
private String extBoxCode;
private String goodsName;
private Integer goodsNumber;
private Integer goodsNumberOrder;
private String goodsShelves;
private String goodsShelvesName;
private BigDecimal goodsVolume;
private BigDecimal goodsVolumeOrder;
private Integer inventoryStatus;
private String lastOutboundTime;
private String manualContractNo;
private String omsExtOrderNo;
private String omsExtYsId;
private String orgId;
private String orgName;
private String outStockTime;
private Integer outboundQuantities;
private String outboundTime;
private String realEndTime;
private Integer receiptQuantities;
private Integer receiptStatus;
private String receiptTime;
private String receiveType;
private String receivingBatchId;
private String recvSite;
private Integer rowId;
private String sendTime;
private String shopCode;
private String shopName;
private String storageLocLabel;
private String subLabel;
private Integer subLabelPrintFlag;
private String subLabelPrintSeq;
private String toContainerIdFlag;
private Integer toStorageLocFlag;
private String transportId;
private String updateName;
private String updateTime;
private String warehouseArea;
private String warehouseAreaName;
private String yjInstallAddr;
private String yjInstallLinker;
private String yjInstallPhone;
private String yjOrderNo;
}

9
blade-service/logpm-factory/src/main/java/com/logpm/factory/jp/bean/RCookie.java

@ -0,0 +1,9 @@
package com.logpm.factory.jp.bean;
public interface RCookie {
String getCookie();
void setCookie(String cookie);
}

164
blade-service/logpm-factory/src/main/java/com/logpm/factory/jp/bean/Tran.java

@ -0,0 +1,164 @@
package com.logpm.factory.jp.bean;
import lombok.Data;
@Data
public class Tran {
private String id;
private String orgId;
private String transportId;
private String shipId;
private String shipItemId;
private String startStockId;
private String writtenOrderId;
private String shipWrittenOrderId;
private String orderId;
private String customerOrderId;
private String transportType;
private String sendSite;
private String recvSite;
private String recvContactsId;
private String receContantsName;
private String revcMobile;
private String recvPhone;
private String recvAddress;
private String shareFee;
private String codAmount;
private String goodsNo;
private String goodsType;
private String goodsName;
private String goodsPack;
private String goodsNumber;
private String goodsWeight;
private String goodsGrossWeight;
private String goodsNetWeight;
private String goodsVolume;
private String goodsAmount;
private String customerNum;
private String goodsLength;
private String goodsWidth;
private String goodsHeigth;
private String creator;
private String createTime;
private String updateId;
private String updateTime;
private String arriveFlag;
private String arriveTime;
private String arriveUserId;
private String flag;
private String remark;
private String version;
private String transportWay;
private String carriageMode;
private String carrierName;
private String carrierContacts;
private String carrierMobile;
private String carrierPhone;
private String carNo;
private String driverName;
private String driverMobile;
private String driverPhone;
private String planBeginTime;
private String realBeginTime;
private String planEndTime;
private String isEnable;
private String arriveOrgId;
private String arriveOrgName;
private int isAlter;
private String omsExtYsId;
private String omsExtOrderNo;
private String sendTime;
private String manualContractNo;
private String shopCode;
private String shopName;
private String deliveryMode;
private String deliveryModeName;
private String transportStatus;
private String receiverName;
private String requireRecvTime;
private String yjOrderNo;
private String yjUrgentDate;
private String yjUrgentType;
private String arrivalAdvice;
private String arrivalAdviceName;
private String arrivalAdviceTime;
}

236
blade-service/logpm-factory/src/main/java/com/logpm/factory/jp/jobhandler/PullJpDataJob.java

@ -0,0 +1,236 @@
package com.logpm.factory.jp.jobhandler;
import cn.hutool.crypto.digest.DigestUtil;
import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse;
import cn.hutool.http.HttpUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.fasterxml.jackson.core.type.TypeReference;
import com.logpm.factory.jp.bean.*;
import com.logpm.factory.jp.entity.JinpaiArrivalOrderEntity;
import com.logpm.factory.jp.entity.JinpaiOrgIdEntity;
import com.logpm.factory.jp.entity.JinpaiPushScanLogEntity;
import com.logpm.factory.jp.service.IJinpaiArrivalOrderService;
import com.logpm.factory.jp.service.IJinpaiOrgIdService;
import com.logpm.factory.jp.service.IJinpaiPushScanLogService;
import com.logpm.factory.jp.util.JsonUtil;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.common.utils.CommonUtil;
import org.springblade.core.tool.utils.StringUtil;
import org.springframework.stereotype.Component;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import java.util.Objects;
@Slf4j
@AllArgsConstructor
@Component
public class PullJpDataJob {
private final IJinpaiOrgIdService jinpaiOrgIdService;
private final IJinpaiArrivalOrderService jinpaiArrivalOrderService;
private final IJinpaiPushScanLogService jinpaiPushScanLogService;
@XxlJob("pullJpData")
public ReturnT<String> pullJpData(String param) {
log.info("############pullJpData: 拉取金牌数据开始 param={}",param);
List<JinpaiOrgIdEntity> list = new ArrayList<>();
if(StringUtil.isBlank(param)){
list = jinpaiOrgIdService.list();
}else{
QueryWrapper<JinpaiOrgIdEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("org_id",param);
JinpaiOrgIdEntity orgIdEntity = jinpaiOrgIdService.getOne(queryWrapper);
if(Objects.isNull(orgIdEntity)){
log.warn("############pullJpData: 未查询到正确的key值");
return ReturnT.FAIL;
}
list.add(orgIdEntity);
}
try{
//获取昨天的日子
Calendar cal = Calendar.getInstance();
cal.add(Calendar.DATE, -1);
String yesterday = new SimpleDateFormat( "yyyy-MM-dd ").format(cal.getTime());
log.info("############pullJpData: 同步{}的数据开始",yesterday);
//登陆【登陆结果中有组织列表】
LoginRes loginRes = login("17340091775", "ht88888888", "3369");
for (JinpaiOrgIdEntity entity:list){
String key = entity.getOrgId();
String name = entity.getOrgName();
log.info("############pullJpData: 目前处理{}的数据",name);
//切换组织【组织切换后,loginRes单cookie会被覆盖】
if(!"成都仓".equals(name)){
swapOrga(loginRes, key);
}
int arrivePage = 1;
while(true){
//查询DD单 arriver
List<Tran> trans = arriveTrans(loginRes, arrivePage, yesterday,yesterday);
if(!Objects.isNull(trans) && trans.size() != 0){
List<JinpaiArrivalOrderEntity> arrivalOrderEntities = new ArrayList<>();
for (Tran tran:trans){
String omsExtOrderNo = tran.getOmsExtOrderNo();
log.info("############pullJpData: 目前处理{}的数据",omsExtOrderNo);
JinpaiArrivalOrderEntity jinpaiArrivalOrderEntity = new JinpaiArrivalOrderEntity();
jinpaiArrivalOrderEntity.setWarehouseName(tran.getArriveOrgName());
jinpaiArrivalOrderEntity.setYsNum(tran.getOmsExtYsId());
jinpaiArrivalOrderEntity.setContractNumber(tran.getManualContractNo());
jinpaiArrivalOrderEntity.setDdNum(tran.getOmsExtOrderNo());
jinpaiArrivalOrderEntity.setDeliveryTime(StringUtil.isBlank(tran.getSendTime())?null:CommonUtil.StringToDate(tran.getSendTime()));
jinpaiArrivalOrderEntity.setServiceType(tran.getDeliveryModeName());
jinpaiArrivalOrderEntity.setStore(tran.getShopName());
jinpaiArrivalOrderEntity.setStoreCode(tran.getShopCode());
jinpaiArrivalOrderEntity.setArrivalStatus(tran.getArriveFlag());
jinpaiArrivalOrderEntity.setTotal(Integer.parseInt(tran.getGoodsNumber()));
jinpaiArrivalOrderEntity.setArrivalTime(StringUtil.isBlank(tran.getPlanEndTime())?null:CommonUtil.StringToDate(tran.getPlanEndTime()));
jinpaiArrivalOrderEntity.setAdministrators(tran.getArrivalAdviceName());
jinpaiArrivalOrderEntity.setTruckNo(tran.getTransportId());
jinpaiArrivalOrderEntity.setLoadingTime(StringUtil.isBlank(tran.getCreateTime())?null:CommonUtil.StringToDate(tran.getCreateTime()));
jinpaiArrivalOrderEntity.setActualArrivalTime(StringUtil.isBlank(tran.getArriveTime())?null:CommonUtil.StringToDate(tran.getArriveTime()));
jinpaiArrivalOrderEntity.setSource("3369");
arrivalOrderEntities.add(jinpaiArrivalOrderEntity);
}
jinpaiArrivalOrderService.saveBatch(arrivalOrderEntities);
}else{
break;
}
arrivePage++;
}
//拉取推动数据
int pushPage = 1;
while(true){
//查询DD单 arriver
List<PushScanLog> pushScanLogs = pushScanLog(loginRes, pushPage, yesterday,yesterday);
if(!Objects.isNull(pushScanLogs) && pushScanLogs.size() != 0){
List<JinpaiPushScanLogEntity> pushScanLogEntities = new ArrayList<>();
for (PushScanLog pushScanLog:pushScanLogs){
String extBoxCode = pushScanLog.getExtBoxCode();
log.info("############pullJpData: 目前处理推送{}的数据",extBoxCode);
JinpaiPushScanLogEntity jinpaiPushScanLogEntity = new JinpaiPushScanLogEntity();
jinpaiPushScanLogEntity.setWarehouseName(pushScanLog.getOrgName());
jinpaiPushScanLogEntity.setBatchNumber(pushScanLog.getReceivingBatchId());
jinpaiPushScanLogEntity.setYsNum(pushScanLog.getOmsExtYsId());
jinpaiPushScanLogEntity.setContractNumber(pushScanLog.getManualContractNo());
jinpaiPushScanLogEntity.setDdNum(pushScanLog.getOmsExtOrderNo());
jinpaiPushScanLogEntity.setUnitNo(pushScanLog.getExtBoxCode());
jinpaiPushScanLogEntity.setInStatus(pushScanLog.getReceiptStatus()+"");
jinpaiPushScanLogEntity.setInType(pushScanLog.getReceiveType());
jinpaiPushScanLogEntity.setDeliveryTime(StringUtil.isBlank(pushScanLog.getSendTime())?null:CommonUtil.StringToDate(pushScanLog.getSendTime()));
jinpaiPushScanLogEntity.setScanTime(StringUtil.isBlank(pushScanLog.getReceiptTime())?null:CommonUtil.StringToDate(pushScanLog.getReceiptTime()));
jinpaiPushScanLogEntity.setArrivalTime(StringUtil.isBlank(pushScanLog.getRealEndTime())?null:CommonUtil.StringToDate(pushScanLog.getRealEndTime()));
jinpaiPushScanLogEntity.setStore(pushScanLog.getShopName());
jinpaiPushScanLogEntity.setStoreCode(pushScanLog.getShopCode());
jinpaiPushScanLogEntity.setAdministrators(pushScanLog.getUpdateName());
jinpaiPushScanLogEntity.setSource("3369");
pushScanLogEntities.add(jinpaiPushScanLogEntity);
}
jinpaiPushScanLogService.saveBatch(pushScanLogEntities);
}else{
break;
}
pushPage++;
}
}
}catch (Exception e){
log.error("系统问题",e);
return ReturnT.FAIL;
}
return ReturnT.SUCCESS;
}
private LoginRes login(String account,String password,String syscode){
HttpRequest httpRequest = HttpUtil.createPost("https://yjtms.yuanfusc.com/tms/system/loginIn.do");
httpRequest.body("account="+account+"&password="+ DigestUtil.sha256Hex(password)+"&syscode="+syscode);
httpRequest.header("User-Agent","Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36");
httpRequest.header("Referer","https://yjtms.yuanfusc.com/");
HttpResponse httpResponse = httpRequest.execute();
String cookie = httpResponse.header("Set-Cookie");
ApiResponse<LoginRes> apiResponse = JsonUtil.toBean(httpResponse.bodyBytes(), new TypeReference<ApiResponse<LoginRes>>() {
});
if (apiResponse.getCode() != 0)throw new RuntimeException(apiResponse.getMessage());
apiResponse.getData().setCookie(cookie);
return apiResponse.getData();
}
private List<Tran> arriveTrans(RCookie cookie, int page, String start, String end){
HttpRequest httpRequest = HttpUtil.createGet("https://yjtms.yuanfusc.com/tms/transport/arriveTrans/list.do?page="+page+"&rows=500&condition=%7B%22arrivalAdvice%22%3A1%2C%22realBeginTimeStart%22%3A%22"+start+"%2000%3A00%3A00%22%2C%22realBeginTimeEnd%22%3A%22"+end+"%2023%3A59%3A59%22%7D&sort=yjUrgentType&order=asc");
httpRequest.header("User-Agent","Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36");
httpRequest.header("Referer","https://yjtms.yuanfusc.com/");
httpRequest.cookie(cookie.getCookie());
log.info("################arriveTrans: httpRequest={}",httpRequest);
HttpResponse httpResponse = httpRequest.execute();
byte[] bytes = httpResponse.bodyBytes();
if(Objects.isNull(bytes)){
for (int i = 0; i < 3; i++) {
httpResponse = httpRequest.execute();
byte[] b = httpResponse.bodyBytes();
if(!Objects.isNull(b)){
bytes = b;
break;
}
}
}
log.info("################arriveTrans: httpResponse={}",httpResponse);
ApiResponse<Tran> apiResponse = JsonUtil.toBean(bytes, new TypeReference<ApiResponse<Tran>>() {
});
httpResponse.close();
if (apiResponse.getCode() != 0)throw new RuntimeException(apiResponse.getMessage());
return apiResponse.getRows();
}
private List<PushScanLog> pushScanLog(RCookie cookie, int page, String start, String end){
HttpRequest httpRequest = HttpUtil.createGet("https://yjtms.yuanfusc.com/i-report/stockreceive/scanreceivelist.do?page="+page+"&rows=500&condition=%7B%22queryType%22%3A2%2C%22orgIds%22%3A%22fbb8dd984b164150aaac1694cce41f8f%22%2C%22receiptTimeBegin%22%3A%22"+start+"%2000%3A00%3A00%22%2C%22receiptTimeEnd%22%3A%22"+end+"%2023%3A59%3A59%22%7D");
httpRequest.header("User-Agent","Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36");
httpRequest.header("Referer","https://yjtms.yuanfusc.com/");
httpRequest.cookie(cookie.getCookie());
log.info("################pushScanLog: httpRequest={}",httpRequest);
HttpResponse httpResponse = httpRequest.execute();
byte[] bytes = httpResponse.bodyBytes();
if(Objects.isNull(bytes)){
for (int i = 0; i < 3; i++) {
httpResponse = httpRequest.execute();
byte[] b = httpResponse.bodyBytes();
if(!Objects.isNull(b)){
bytes = b;
break;
}
}
}
log.info("################pushScanLog: httpResponse={}",httpResponse);
ApiResponse<PushScanLog> apiResponse = JsonUtil.toBean(bytes, new TypeReference<ApiResponse<PushScanLog>>() {
});
httpResponse.close();
if (apiResponse.getCode() != 0)throw new RuntimeException(apiResponse.getMessage());
return apiResponse.getRows();
}
private void swapOrga(RCookie cookie, String orgId){
HttpRequest httpRequest = HttpUtil.createGet("https://yjtms.yuanfusc.com/tms/system/swapOrga.do?swapOrgaId="+orgId);
httpRequest.header("User-Agent","Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36");
httpRequest.header("Referer","https://yjtms.yuanfusc.com/");
httpRequest.cookie(cookie.getCookie());
HttpResponse httpResponse = httpRequest.execute();
ApiResponse<?> apiResponse = JsonUtil.toBean(httpResponse.bodyBytes(), new TypeReference<ApiResponse<?>>() {
});
if (apiResponse.getCode() != 0)throw new RuntimeException(apiResponse.getMessage());
cookie.setCookie(httpResponse.header("Set-Cookie"));
}
}

9
blade-service/logpm-factory/src/main/java/com/logpm/factory/jp/mapper/JinpaiArrivalOrderMapper.java

@ -0,0 +1,9 @@
package com.logpm.factory.jp.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.logpm.factory.jp.entity.JinpaiArrivalOrderEntity;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface JinpaiArrivalOrderMapper extends BaseMapper<JinpaiArrivalOrderEntity> {
}

10
blade-service/logpm-factory/src/main/java/com/logpm/factory/jp/mapper/JinpaiOrgIdMapper.java

@ -0,0 +1,10 @@
package com.logpm.factory.jp.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.logpm.factory.jp.entity.JinpaiOrgIdEntity;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface JinpaiOrgIdMapper extends BaseMapper<JinpaiOrgIdEntity> {
}

9
blade-service/logpm-factory/src/main/java/com/logpm/factory/jp/mapper/JinpaiPushScanLogMapper.java

@ -0,0 +1,9 @@
package com.logpm.factory.jp.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.logpm.factory.jp.entity.JinpaiPushScanLogEntity;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface JinpaiPushScanLogMapper extends BaseMapper<JinpaiPushScanLogEntity> {
}

7
blade-service/logpm-factory/src/main/java/com/logpm/factory/jp/service/IJinpaiArrivalOrderService.java

@ -0,0 +1,7 @@
package com.logpm.factory.jp.service;
import com.logpm.factory.jp.entity.JinpaiArrivalOrderEntity;
import org.springblade.core.mp.base.BaseService;
public interface IJinpaiArrivalOrderService extends BaseService<JinpaiArrivalOrderEntity> {
}

7
blade-service/logpm-factory/src/main/java/com/logpm/factory/jp/service/IJinpaiOrgIdService.java

@ -0,0 +1,7 @@
package com.logpm.factory.jp.service;
import com.logpm.factory.jp.entity.JinpaiOrgIdEntity;
import org.springblade.core.mp.base.BaseService;
public interface IJinpaiOrgIdService extends BaseService<JinpaiOrgIdEntity> {
}

7
blade-service/logpm-factory/src/main/java/com/logpm/factory/jp/service/IJinpaiPushScanLogService.java

@ -0,0 +1,7 @@
package com.logpm.factory.jp.service;
import com.logpm.factory.jp.entity.JinpaiPushScanLogEntity;
import org.springblade.core.mp.base.BaseService;
public interface IJinpaiPushScanLogService extends BaseService<JinpaiPushScanLogEntity> {
}

15
blade-service/logpm-factory/src/main/java/com/logpm/factory/jp/service/impl/JinpaiArrivalOrderServiceImpl.java

@ -0,0 +1,15 @@
package com.logpm.factory.jp.service.impl;
import com.logpm.factory.jp.entity.JinpaiArrivalOrderEntity;
import com.logpm.factory.jp.mapper.JinpaiArrivalOrderMapper;
import com.logpm.factory.jp.service.IJinpaiArrivalOrderService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.springframework.stereotype.Service;
@Service
@AllArgsConstructor
@Slf4j
public class JinpaiArrivalOrderServiceImpl extends BaseServiceImpl<JinpaiArrivalOrderMapper, JinpaiArrivalOrderEntity> implements IJinpaiArrivalOrderService {
}

15
blade-service/logpm-factory/src/main/java/com/logpm/factory/jp/service/impl/JinpaiOrgIdServiceImpl.java

@ -0,0 +1,15 @@
package com.logpm.factory.jp.service.impl;
import com.logpm.factory.jp.entity.JinpaiOrgIdEntity;
import com.logpm.factory.jp.mapper.JinpaiOrgIdMapper;
import com.logpm.factory.jp.service.IJinpaiOrgIdService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.springframework.stereotype.Service;
@Service
@AllArgsConstructor
@Slf4j
public class JinpaiOrgIdServiceImpl extends BaseServiceImpl<JinpaiOrgIdMapper, JinpaiOrgIdEntity> implements IJinpaiOrgIdService {
}

15
blade-service/logpm-factory/src/main/java/com/logpm/factory/jp/service/impl/JinpaiPushScanLogServiceImpl.java

@ -0,0 +1,15 @@
package com.logpm.factory.jp.service.impl;
import com.logpm.factory.jp.entity.JinpaiPushScanLogEntity;
import com.logpm.factory.jp.mapper.JinpaiPushScanLogMapper;
import com.logpm.factory.jp.service.IJinpaiPushScanLogService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.springframework.stereotype.Service;
@Service
@AllArgsConstructor
@Slf4j
public class JinpaiPushScanLogServiceImpl extends BaseServiceImpl<JinpaiPushScanLogMapper, JinpaiPushScanLogEntity> implements IJinpaiPushScanLogService {
}

63
blade-service/logpm-factory/src/main/java/com/logpm/factory/jp/util/JsonUtil.java

@ -0,0 +1,63 @@
package com.logpm.factory.jp.util;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.extern.slf4j.Slf4j;
import org.springblade.common.exception.CustomerException;
import java.io.IOException;
@Slf4j
public class JsonUtil {
private static final ObjectMapper objectMapper = new ObjectMapper();
static {
//允许单引号
objectMapper.configure(JsonParser.Feature.ALLOW_SINGLE_QUOTES, true);
}
public static <T> T toBean(byte[] bytes, Class<T> tClass) {
try {
return objectMapper.readValue(bytes, tClass);
} catch (IOException e) {
throw new CustomerException(500,"处理失败");
}
}
public static <T> T toBean(String bytes, Class<T> tClass) {
try {
return objectMapper.readValue(bytes, tClass);
} catch (IOException e) {
throw new CustomerException(500,"处理失败");
}
}
public static <T> T toBean(String bytes, TypeReference<T> valueTypeRef) {
try {
return objectMapper.readValue(bytes, valueTypeRef);
} catch (IOException e) {
throw new CustomerException(500,"处理失败");
}
}
public static <T> T toBean(byte[] bytes, TypeReference<T> valueTypeRef) {
try {
log.info("###############toBean: bytes={} valueTypeRef={}",bytes,valueTypeRef);
return objectMapper.readValue(bytes, valueTypeRef);
} catch (IOException e) {
throw new CustomerException(500,"处理失败");
}
}
public static String toString(Object obj) {
try {
return objectMapper.writeValueAsString(obj);
} catch (JsonProcessingException e) {
throw new CustomerException(500,"处理失败");
}
}
}

55
blade-service/logpm-factory/src/main/java/com/logpm/factory/oupai/receiver/OpOldReceivingDataHandler.java

@ -25,6 +25,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.io.IOException;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
@ -63,6 +64,14 @@ public class OpOldReceivingDataHandler {
JSONObject object = JSONObject.parseObject(jsonStr);
String orderPackageCode = object.getString("orderPackageCode");
String warehouseName = object.getString("warehouse_name");
String opShipNo = object.getString("opShipNo");
String orderSelfNum = object.getString("orderSelfNum");
String carNumber = object.getString("carNumber");
String siteName = object.getString("siteName");
String packageDetailNames = object.getString("packageDetailNames");
String firstPackName = object.getString("firstPackName");
String secondPackName = object.getString("secondPackName");
String thirdPackName = object.getString("thirdPackName");
QueryWrapper warehouseQueryWrapper = new QueryWrapper();
@ -87,7 +96,35 @@ public class OpOldReceivingDataHandler {
String authCode = oldLogin(warehouseEntity.getId());
// 推送数据
if (StringUtil.isNotBlank(authCode)) {
boolean isSuccess = sendPackageData(authCode, orderPackageCode);
Map<String,Object> reqMap = new HashMap<>();
reqMap.put("authCode", authCode);
// 收货单
reqMap.put("op_shipNo", opShipNo);
//仓库ID
reqMap.put("warehouse_id", warehouseEntity.getId());
//订单自编号
reqMap.put("orderSelfNum", orderSelfNum);
//扫描时间
reqMap.put("scan_time", new Date());
//扫描人
reqMap.put("scan_user", "");
//车次号
reqMap.put("mctsTruck", carNumber);
//发货基地
reqMap.put("siteName", siteName);
//一级品类
reqMap.put("firstPackName", firstPackName);
//二级品类
reqMap.put("secondPackName", secondPackName);
//三级品类
reqMap.put("thirdPackName", thirdPackName);
//物料名称
reqMap.put("productname", packageDetailNames);
boolean isSuccess = sendPackageData(reqMap);
if (isSuccess) {
// 请求成功 修改推送数据的状态 修改未1
if (ObjectUtils.isNotNull(packageEntity)) {
@ -126,19 +163,15 @@ public class OpOldReceivingDataHandler {
}
private boolean sendPackageData(String authCode, String orderPackageCode) {
private boolean sendPackageData(Map<String,Object> map) {
// 构建请求头
Map<String, Object> map = new HashMap<>();
map.put("type", "1");
map.put("unitNo", orderPackageCode);
map.put("mctsTruckNo", "");
map.put("area", "");
map.put("user_id", oldSystemProperties.getUserId());
map.put("pick_up_id", "");
map.put("origin", "按件入库");
String authCode = map.get("authCode").toString();
log.info("##################sendPackageData: 请求老系统接口 start map {}", map);
String url = oldSystemProperties.getUrl() + "api/scan";
String url = oldSystemProperties.getUrl() + "openApi/newSystem.OptimsWarehouseScan/index";
String body = HttpRequest.post(url).form(map).header("token", authCode).execute().body();
log.info("##################sendPackageData: 请求老系统接口,url:{},body:{}", url, body);
if (StringUtil.isNotBlank(body)) {

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

@ -141,22 +141,49 @@ public class OuPaiFactoryServiceImpl implements IOuPaiFactoryService {
FactoryPackageEntity packageEntity = factoryPackageService.getOne(queryWrapper);
String code=null;
String endWarehouseName = null;
String opShipNo=null;
String orderSelfNum =null;
String carNumber=null;
String siteName = null;
String packageDetailNames = null;
String firstPackName,secondPackName,thirdPackName = null;
if (Objects.isNull(packageEntity)) {
log.error("############oid 查询数据失败: {}", key);
// 查询欧派系统的的数据
String url = ouPaiProperties.getUri() + "tims_odata_api/api/odata/Package(" + key + ")?select=Code,PackageStatus,FirstClassCode,FirstClassName,SecondClassCode,SecondClassName,ThirdClassCode,ThirdClassName,BuyIn,CosourcingCode,CosourcingUnit,Length,Width,Height,Weight,IsInventory,SendTime,ReceivingTime,CreateTime,ShipTime,CarNumber,DeliveryMethod&$expand=ReceivingOrders($select=Code,Type,Status,Plate,PackagesCount,ReceivePackageCount,PlateNum,CarNumber,CarrierCode,SendTime,ArrivalTime,ReceiveTime,CreateTime,ReturnNumber;$expand=EndWarehouse($select=Name,Code))";
OpOrderStatusLogEntity opOrderStatusLogEntity = sendRequestData(url, event);
String url = ouPaiProperties.getUri() + "tims_odata_api/api/odata/Package(" + key + ")?select=Code,PackageStatus,FirstClassCode,FirstClassName,SecondClassCode,SecondClassName,ThirdClassCode,ThirdClassName,BuyIn,CosourcingCode,CosourcingUnit,Length,Width,Height,Weight,IsInventory,SendTime,ReceivingTime,CreateTime,ShipTime,CarNumber,DeliveryMethod&$expand=ReceivingOrders($select=Code,Type,Status,Plate,PackagesCount,ReceivePackageCount,PlateNum,CarNumber,CarrierCode,SendTime,ArrivalTime,ReceiveTime,CreateTime,ReturnNumber;$expand=EndWarehouse($select=Name,Code))&$expand=Order($select=SelfCode,Code)"; OpOrderStatusLogEntity opOrderStatusLogEntity = sendRequestData(url, event);
JSONObject jsonObject = JSONObject.parseObject(opOrderStatusLogEntity.getResponseBody());
code = jsonObject.getString("Code");
Boolean isInventory = jsonObject.getBoolean("IsInventory");
carNumber = jsonObject.getString("CarNumber");
packageDetailNames = jsonObject.getString("PackageDetailNames");
firstPackName = jsonObject.getString("FirstPackName");
secondPackName = jsonObject.getString("SecondPackName");
thirdPackName = jsonObject.getString("ThirdPackName");
if(isInventory){
log.error("############库存品数据 不进行推送: {}", code);
return key;
}
JSONObject order = jsonObject.getJSONObject("Order");
if (order != null){
orderSelfNum = order.getString("SelfCode");
}
JSONArray ls = jsonObject.getJSONArray("ReceivingOrders");
if(ls!=null&& !ls.isEmpty()){
JSONObject t = ls.getJSONObject(0);
if(t!=null){
opShipNo = t.getString("Code");
JSONObject endWarehouse = t.getJSONObject("EndWarehouse");
endWarehouseName = endWarehouse.getString("Name");
JSONObject fromWarehouse = t.getJSONObject("FromWarehouse");
siteName = fromWarehouse.getString("Name");
}
}else{
log.error("############没有收货单oid:{}", key);
return key;
@ -166,18 +193,28 @@ public class OuPaiFactoryServiceImpl implements IOuPaiFactoryService {
packageEntity.setPackageStatus(5);
factoryPackageService.updateById(packageEntity);
code = packageEntity.getCode();
packageDetailNames =packageEntity.getPackageDetailNames();
firstPackName = packageEntity.getFirstClassName();
secondPackName = packageEntity.getSecondClassName();
thirdPackName = packageEntity.getThirdClassName();
Long orderId = packageEntity.getOrderId();
// 查询 订单
QueryWrapper<FactoryOrderEntity> queryWrapperFactoryOrderEntity = new QueryWrapper<>();
queryWrapperFactoryOrderEntity.eq("id", orderId);
FactoryOrderEntity orderEntity = factoryOrderService.getOne(queryWrapperFactoryOrderEntity);
orderSelfNum = orderEntity.getSelfCode();
// 查询 发货单
Long receivingId = orderEntity.getReceivingId();
ReceivingOrderEntity receivingEntity = receivingOrderMapper.selectById(receivingId);
endWarehouseName = receivingEntity.getEndWarehouseName();
}
opShipNo = receivingEntity.getCode();
carNumber = receivingEntity.getCarNumber();
// 发货基地
siteName = receivingEntity.getFromWarehouseName();
}
// 判断 作业仓库 和 收货仓库 是否一致
log.info(" >>>> 判断作业仓库 和 收货仓库 是否一致 >>>> 作业仓库:{},收货仓库:{}", warehouseName, endWarehouseName);
@ -189,6 +226,14 @@ public class OuPaiFactoryServiceImpl implements IOuPaiFactoryService {
JSONObject jo = new JSONObject();
jo.put("orderPackageCode", code);
jo.put("warehouse_name", warehouseName);
jo.put("opShipNo", opShipNo);
jo.put("orderSelfNum", orderSelfNum);
jo.put("carNumber", carNumber);
jo.put("siteName", siteName);
jo.put("packageDetailNames", packageDetailNames);
jo.put("firstPackName", firstPackName);
jo.put("secondPackName", secondPackName);
jo.put("thirdPackName", thirdPackName);
//真正的处理需要的数据
Map<String, Object> map = new HashMap<>();

17
blade-service/logpm-factory/src/test/java/com/logpm/factory/TestService.java

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save