物流追踪

This commit is contained in:
zt
2025-08-15 16:54:30 +08:00
parent 8326c3110f
commit f44904a5f1
10 changed files with 244 additions and 9 deletions

View File

@ -85,14 +85,14 @@ public class Ys7Test {
// busFormalitiesAreConsolidatedBo.setProjectId(1555L); // busFormalitiesAreConsolidatedBo.setProjectId(1555L);
// Boolean b = formalitiesAreConsolidatedService.insertByBo(busFormalitiesAreConsolidatedBo); // Boolean b = formalitiesAreConsolidatedService.insertByBo(busFormalitiesAreConsolidatedBo);
// System.out.println(b); // System.out.println(b);
busFormalitiesAreConsolidatedBo.setId(1956013379818409985L); // busFormalitiesAreConsolidatedBo.setId(1956013379818409985L);
busFormalitiesAreConsolidatedBo.setHead("舟山"); // busFormalitiesAreConsolidatedBo.setHead("舟山");
busFormalitiesAreConsolidatedBo.setPlanTheStartTime(new Date()); // busFormalitiesAreConsolidatedBo.setPlanTheStartTime(new Date());
busFormalitiesAreConsolidatedBo.setRemark("asdasd"); // busFormalitiesAreConsolidatedBo.setRemark("asdasd");
busFormalitiesAreConsolidatedBo.setStatus(0); // busFormalitiesAreConsolidatedBo.setStatus(0);
MultipartFile[] files = {}; // MultipartFile[] files = {};
Boolean b = formalitiesAreConsolidatedService.updateByBo(busFormalitiesAreConsolidatedBo, files); // Boolean b = formalitiesAreConsolidatedService.updateByBo(busFormalitiesAreConsolidatedBo, files);
System.out.println(b); // System.out.println(b);
} }
} }

View File

@ -7,6 +7,8 @@ import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.constraints.*; import jakarta.validation.constraints.*;
import cn.dev33.satoken.annotation.SaCheckPermission; import cn.dev33.satoken.annotation.SaCheckPermission;
import org.dromara.cailiaoshebei.domain.dto.BusLtnDto; import org.dromara.cailiaoshebei.domain.dto.BusLtnDto;
import org.dromara.common.utils.logistics.LogisticsInquiryDemo;
import org.dromara.common.utils.logistics.LogisticsInquiryUtil;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.dromara.common.idempotent.annotation.RepeatSubmit; import org.dromara.common.idempotent.annotation.RepeatSubmit;
@ -114,4 +116,16 @@ public class BusLtnController extends BaseController {
public R<Void> linkAdd(@RequestBody BusLtnDto dto) { public R<Void> linkAdd(@RequestBody BusLtnDto dto) {
return toAjax(busLtnService.linkAdd(dto)); return toAjax(busLtnService.linkAdd(dto));
} }
/**
* 获取物流信息
*
* @param ltn 物流单号
*/
@GetMapping("/logistics/{ltn}")
public R<LogisticsInquiryDemo> getInfo(@NotNull(message = "物流单号不能为空")
@PathVariable String ltn) {
return R.ok(LogisticsInquiryUtil.aLiLogisticsInquiry(ltn));
}
} }

View File

@ -0,0 +1,42 @@
package org.dromara.common.utils.logistics;
import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serial;
import java.io.Serializable;
import java.util.List;
/**
* 测试单表对象 test_demo
*
* @author Lion Li
* @date 2021-07-26
*/
@Data
@EqualsAndHashCode(callSuper = false)
//@TableName("test_demo")
public class LogisticsInquiryDemo implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
/**
* 主键
*/
private String number;
private String type;
private List<LogisticsInquiryListDemo> list;
private String deliverystatus;
private String issign;
private String expName;
private String expSite;
private String expPhone;
private String logo;
private String courier;
private String courierPhone;
private String updateTime;
private String takeTime;
}

View File

@ -0,0 +1,27 @@
package org.dromara.common.utils.logistics;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serial;
import java.io.Serializable;
/**
* 测试单表对象 test_demo
*
* @author Lion Li
* @date 2021-07-26
*/
@Data
@EqualsAndHashCode(callSuper = false)
public class LogisticsInquiryListDemo implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
/**
* 主键
*/
private String time;
private String status;
}

View File

@ -0,0 +1,90 @@
package org.dromara.common.utils.logistics;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.UnknownHostException;
import java.util.List;
import java.util.Map;
public class LogisticsInquiryUtil {
/*
* 读取返回结果
*/
private static String read(InputStream is) throws IOException {
StringBuffer sb = new StringBuffer();
BufferedReader br = new BufferedReader(new InputStreamReader(is));
String line = null;
while ((line = br.readLine()) != null) {
line = new String(line.getBytes(), "utf-8");
sb.append(line);
}
br.close();
return sb.toString();
}
public static LogisticsInquiryDemo aLiLogisticsInquiry(String orderNumber){
String host = "https://wuliu.market.alicloudapi.com";// 【1】请求地址 支持http 和 https 及 WEBSOCKET
String path = "/kdi"; // 【2】后缀
String appcode = "9401b50f65304a4f8b6d083790f45658"; // 【3】开通服务后 买家中心-查看AppCode
String no = orderNumber;// 【4】请求参数详见文档描述
String type = ""; // 【4】请求参数不知道可不填 95%能自动识别
String urlSend = host + path + "?no=" + no +"&type="+type; // 【5】拼接请求链接
try {
URL url = new URL(urlSend);
HttpURLConnection httpURLCon = (HttpURLConnection) url.openConnection();
httpURLCon .setRequestProperty("Authorization", "APPCODE " + appcode);// 格式Authorization:APPCODE (中间是英文空格)
int httpCode = httpURLCon.getResponseCode();
if (httpCode == 200) {
String json = read(httpURLCon.getInputStream());
JSONObject jsonObject = JSONUtil.parseObj(json);
LogisticsInquiryDemo inquiryDemo = jsonObject.getBean("result", LogisticsInquiryDemo.class);
// System.out.println("正常请求计费(其他均不计费)");
// System.out.println("获取返回的json:");
// System.out.println(json);
// System.out.println(inquiryDemo1);
return inquiryDemo;
} else {
Map<String, List<String>> map = httpURLCon.getHeaderFields();
String error = map.get("X-Ca-Error-Message").get(0);
if (httpCode == 400 && error.equals("Invalid AppCode `not exists`")) {
System.out.println("AppCode错误 ");
} else if (httpCode == 400 && error.equals("Invalid Url")) {
System.out.println("请求的 Method、Path 或者环境错误");
} else if (httpCode == 400 && error.equals("Invalid Param Location")) {
System.out.println("参数错误");
} else if (httpCode == 403 && error.equals("Unauthorized")) {
System.out.println("服务未被授权或URL和Path不正确");
} else if (httpCode == 403 && error.equals("Quota Exhausted")) {
System.out.println("套餐包次数用完 ");
} else if (httpCode == 403 && error.equals("Api Market Subscription quota exhausted")) {
System.out.println("套餐包次数用完,请续购套餐");
} else {
System.out.println("参数名错误 或 其他错误");
System.out.println(error);
}
}
} catch (MalformedURLException e) {
System.out.println("URL格式错误");
} catch (UnknownHostException e) {
System.out.println("URL地址错误");
} catch (Exception e) {
// 打开注释查看详细报错异常信息
// e.printStackTrace();
}
return null;
}
// public static void main(String[] args) {
// aLiLogisticsInquiry("434719283706463");
// }
}

View File

@ -113,7 +113,8 @@ public class DesCollectFileController extends BaseController {
@Log(title = "收资文件", businessType = BusinessType.INSERT) @Log(title = "收资文件", businessType = BusinessType.INSERT)
@RepeatSubmit() @RepeatSubmit()
@PostMapping("/upload") @PostMapping("/upload")
public R<Void> addFile(MultipartFile file,Long catalogueId,Long projectId) { public R<Void> addFile(MultipartFile file,@NotNull(message = "请先选择目录") Long catalogueId,
@NotNull(message = "请先选择项目")Long projectId) {
return toAjax(desCollectFileService.addFile(file, catalogueId, projectId)); return toAjax(desCollectFileService.addFile(file, catalogueId, projectId));
} }
} }

View File

@ -103,4 +103,12 @@ public interface IDesDrawingService extends IService<DesDrawing> {
* @return 是否添加成功 * @return 是否添加成功
*/ */
CompletableFuture<Boolean> addQRCodeToPDF(DesDrawing drawing); CompletableFuture<Boolean> addQRCodeToPDF(DesDrawing drawing);
/**
* 异步添加二维码到PDF
*
* @param volumeFileId 文件id
* @return 是否添加成功
*/
CompletableFuture<Boolean> addQRCodeToPDF(Long volumeFileId);
} }

View File

@ -50,6 +50,7 @@ import org.dromara.project.service.IBusProjectService;
import org.dromara.system.domain.vo.SysOssVo; import org.dromara.system.domain.vo.SysOssVo;
import org.dromara.system.service.ISysOssService; import org.dromara.system.service.ISysOssService;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.context.annotation.Lazy;
import org.springframework.context.event.EventListener; import org.springframework.context.event.EventListener;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -93,6 +94,9 @@ public class DesDesignChangeServiceImpl extends ServiceImpl<DesDesignChangeMappe
@Resource @Resource
protected IDesDrawingService drawingService; protected IDesDrawingService drawingService;
@Lazy
@Resource
private IDesDrawingService self;
/** /**
* 查询设计变更管理 * 查询设计变更管理
@ -640,6 +644,16 @@ public class DesDesignChangeServiceImpl extends ServiceImpl<DesDesignChangeMappe
desDrawing.setVolumeCatalogId(volumeCatalog.getDesign()); desDrawing.setVolumeCatalogId(volumeCatalog.getDesign());
desDrawing.setVolumeFileId(desVolumeFile.getId()); desDrawing.setVolumeFileId(desVolumeFile.getId());
drawingService.save(desDrawing); drawingService.save(desDrawing);
//异步处理二维码
self.addQRCodeToPDF(desVolumeFile.getId())
.thenAccept(result -> log.info("图纸[{}-{} ]添加二维码成功", desVolumeFile.getFileName(), desVolumeFile.getId()))
.exceptionally(ex -> {
log.error("图纸[{}-{}]添加二维码失败", desVolumeFile.getFileName(), desVolumeFile.getId(), ex);
return null;
});
} }
} }
} }

View File

@ -427,4 +427,29 @@ public class DesDrawingServiceImpl extends ServiceImpl<DesDrawingMapper, DesDraw
return CompletableFuture.completedFuture(true); return CompletableFuture.completedFuture(true);
} }
@Override
public CompletableFuture<Boolean> addQRCodeToPDF(Long volumeFileId) {
DesVolumeFile byId = volumeFilesService.getById(volumeFileId);
Long fileUrl = byId.getFileId();
if (fileUrl == null) {
return CompletableFuture.completedFuture(false);
}
SysOssVo ossVo = ossService.getById(fileUrl);
// 整合二维码需要显示的数据
String params = "ID[" + byId.getId() + "] finish";
byte[] bytes = PdfBoxQrCodeGenerator.generateQRCodeBytes(params);
try {
ByteArrayOutputStream baos = PdfBoxQrCodeGenerator.addQRCodeToPDFOnAllPages(ossVo.getUrl(), bytes,1510, 900);
FileNameMap fileNameMap = URLConnection.getFileNameMap();
String originalName = ossVo.getOriginalName();
String contentType = fileNameMap.getContentTypeFor(originalName);
SysOssVo upload = ossService.upload(new ByteArrayInputStream(baos.toByteArray()), originalName, contentType, baos.size());
byId.setFileId(upload.getOssId());
} catch (IOException | DocumentException e) {
log.error("图纸管理 => 审核结束,向文件添加二维码失败", e);
return CompletableFuture.completedFuture(false);
}
volumeFilesService.updateById(byId);
return CompletableFuture.completedFuture(true);
}
} }

View File

@ -70,6 +70,12 @@ public class DesVolumeCatalogServiceImpl extends ServiceImpl<DesVolumeCatalogMap
@Resource @Resource
protected IDesDrawingService drawingService; protected IDesDrawingService drawingService;
@Lazy
@Resource
private IDesDrawingService self;
/** /**
* 查询卷册目录 * 查询卷册目录
* *
@ -358,7 +364,15 @@ public class DesVolumeCatalogServiceImpl extends ServiceImpl<DesVolumeCatalogMap
desDrawing.setProjectId(desVolumeCatalog.getProjectId()); desDrawing.setProjectId(desVolumeCatalog.getProjectId());
desDrawing.setVolumeCatalogId(desVolumeCatalog.getDesign()); desDrawing.setVolumeCatalogId(desVolumeCatalog.getDesign());
desDrawing.setVolumeFileId(desVolumeFile.getId()); desDrawing.setVolumeFileId(desVolumeFile.getId());
desDrawings.add(desDrawing); desDrawings.add(desDrawing);
//异步处理二维码
self.addQRCodeToPDF(desVolumeFile.getId())
.thenAccept(result -> log.info("图纸[{}-{} ]添加二维码成功", desVolumeFile.getFileName(), desVolumeFile.getId()))
.exceptionally(ex -> {
log.error("图纸[{}-{}]添加二维码失败", desVolumeFile.getFileName(), desVolumeFile.getId(), ex);
return null;
});
} }
drawingService.saveBatch(desDrawings); drawingService.saveBatch(desDrawings);
} }