dev
parent
003fc2a901
commit
3f7ab546dd
|
|
@ -89,7 +89,7 @@ public class Config extends JFinalConfig {
|
||||||
public static DeviceThread deviceThread = new DeviceThread();
|
public static DeviceThread deviceThread = new DeviceThread();
|
||||||
public static SocketIOService socketio = null;
|
public static SocketIOService socketio = null;
|
||||||
private static boolean client_run = true;
|
private static boolean client_run = true;
|
||||||
public static final String CLINET_VERSION = "20200929";
|
public static final String CLINET_VERSION = "20200930";
|
||||||
|
|
||||||
public static String getRootPath() {
|
public static String getRootPath() {
|
||||||
return PathKit.getWebRootPath()
|
return PathKit.getWebRootPath()
|
||||||
|
|
|
||||||
|
|
@ -5,12 +5,16 @@ import com.cowr.model.OssfileLog;
|
||||||
import com.jfinal.kit.StrKit;
|
import com.jfinal.kit.StrKit;
|
||||||
import com.jfinal.log.Log;
|
import com.jfinal.log.Log;
|
||||||
import com.jfinal.plugin.activerecord.Db;
|
import com.jfinal.plugin.activerecord.Db;
|
||||||
|
import net.coobird.thumbnailator.Thumbnails;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* https://cthb.static.cloudowr.cn/imgfile/68d6adcfb60549b0ba9d6d24178903a8.jpg?x-oss-process=style/128
|
||||||
|
*/
|
||||||
public class OssfileLogService {
|
public class OssfileLogService {
|
||||||
private static Log log = Log.getLog(OssfileLogService.class);
|
private static Log log = Log.getLog(OssfileLogService.class);
|
||||||
public static OssfileLogService me = new OssfileLogService();
|
public static OssfileLogService me = new OssfileLogService();
|
||||||
|
|
@ -27,21 +31,59 @@ public class OssfileLogService {
|
||||||
ossfile.save();
|
ossfile.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static File createThumbnail(File imageFile) {
|
||||||
|
if (imageFile == null || imageFile.isDirectory() || !imageFile.exists()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
String oldpath = imageFile.getAbsolutePath();
|
||||||
|
String suffix = oldpath.substring(oldpath.lastIndexOf("."), oldpath.length());
|
||||||
|
String outfmt = oldpath.substring(oldpath.lastIndexOf(".") + 1, oldpath.length()).toLowerCase();
|
||||||
|
String newpath = oldpath.substring(0, oldpath.lastIndexOf(".")) + "_thum_" + suffix;
|
||||||
|
|
||||||
|
Thumbnails.of(oldpath).scale(0.7f).outputFormat(outfmt).toFile(newpath);
|
||||||
|
|
||||||
|
File newfile = new File(newpath);
|
||||||
|
|
||||||
|
if (newfile != null && newfile.exists()) {
|
||||||
|
return newfile;
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.getMessage(), e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public void checkUploadStatus(){
|
public void checkUploadStatus(){
|
||||||
List<OssfileLog> logs = OssfileLog.dao.find("select * from ossfile_log t where t.state = 0 limit 10");
|
List<OssfileLog> logs = OssfileLog.dao.find("select * from ossfile_log t where t.state = 0 limit 10");
|
||||||
List<OssfileLog> ups = new ArrayList<>();
|
List<OssfileLog> ups = new ArrayList<>();
|
||||||
|
|
||||||
log.debug("上传 %s 张图片到 oss", logs.size());
|
log.debug("有 %s 张图片需要传到 oss", logs.size());
|
||||||
|
|
||||||
for(OssfileLog ossfile : logs){
|
for(OssfileLog ossfile : logs){
|
||||||
|
File thumfile = null;
|
||||||
try {
|
try {
|
||||||
if(OSSKit.putObject(ossfile.getOsskey(), new File(ossfile.getAbsolutepath()))){
|
File imgFile = new File(ossfile.getAbsolutepath());
|
||||||
|
|
||||||
|
if(!imgFile.exists()){
|
||||||
|
log.error("文件[%s]已不存在", ossfile.getAbsolutepath());
|
||||||
|
}
|
||||||
|
|
||||||
|
thumfile = createThumbnail(imgFile); // 先压缩,再上传
|
||||||
|
|
||||||
|
if(OSSKit.putObject(ossfile.getOsskey(), thumfile)){
|
||||||
ossfile.setState(1);
|
ossfile.setState(1);
|
||||||
|
|
||||||
ups.add(ossfile);
|
ups.add(ossfile);
|
||||||
}
|
}
|
||||||
}catch (Exception e){
|
}catch (Exception e){
|
||||||
log.error(e.getMessage(), e);
|
log.error(e.getMessage(), e);
|
||||||
|
}finally {
|
||||||
|
if(thumfile != null){
|
||||||
|
thumfile.delete(); // 删除压缩文件
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -192,24 +192,37 @@ public class TransportSyncService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private String saveImg(File file) {
|
public String getOssKey(String uuid, File file){
|
||||||
|
if (file == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
String fileName = file.getName();
|
||||||
|
String prefix = fileName.substring(fileName.lastIndexOf(".") + 1).toLowerCase();
|
||||||
|
String savefilename = uuid + "." + prefix;
|
||||||
|
String key = Const.LicenseImgTmpFolder + "/" + savefilename; // 存储路径, 这个斜杠是http用的,肯定是正斜杠
|
||||||
|
|
||||||
|
return key;
|
||||||
|
}
|
||||||
|
|
||||||
|
private File saveImg(String uuid, File file) {
|
||||||
try {
|
try {
|
||||||
if (file == null) {
|
if (file == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
String uuid = StrKit.getRandomUUID();
|
|
||||||
String fileName = file.getName();
|
String fileName = file.getName();
|
||||||
String prefix = fileName.substring(fileName.lastIndexOf(".") + 1).toLowerCase();
|
String prefix = fileName.substring(fileName.lastIndexOf(".") + 1).toLowerCase();
|
||||||
String savefilename = uuid + "." + prefix;
|
String savefilename = uuid + "." + prefix;
|
||||||
String savethumbnail = Config.getRootPath() + File.separator + Const.LicenseImgTmpFolder + File.separator + uuid + "_thumbnail." + prefix;
|
String savethumbnail = Config.getRootPath() + File.separator + Const.LicenseImgTmpFolder + File.separator + uuid + "_thumbnail." + prefix;
|
||||||
String key = Const.LicenseImgTmpFolder + "/" + savefilename; // 存储路径, 这个斜杠是http用的,肯定是正斜杠
|
|
||||||
|
|
||||||
Thumbnails.of(file.getAbsolutePath()).scale(0.5f).outputFormat(prefix).toFile(savethumbnail);
|
Thumbnails.of(file.getAbsolutePath()).scale(0.5f).outputFormat(prefix).toFile(savethumbnail);
|
||||||
|
|
||||||
file.renameTo(new File(Config.getRootPath() + File.separator + Const.LicenseImgTmpFolder + File.separator + savefilename)); // 重命名文件
|
File newfile = new File(Config.getRootPath() + File.separator + Const.LicenseImgTmpFolder + File.separator + savefilename);
|
||||||
|
|
||||||
return key;
|
file.renameTo(newfile); // 重命名文件
|
||||||
|
|
||||||
|
return newfile;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error(e.getMessage(), e);
|
log.error(e.getMessage(), e);
|
||||||
return null;
|
return null;
|
||||||
|
|
@ -247,6 +260,10 @@ public class TransportSyncService {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String fileuuid = StrKit.getRandomUUID();
|
||||||
|
String filekey = getOssKey(fileuuid, file);
|
||||||
|
File uploadfile = saveImg(fileuuid, file); // 压缩、重命名文件
|
||||||
|
|
||||||
Transport transport = new Transport();
|
Transport transport = new Transport();
|
||||||
transport.setId(StrKit.getRandomUUID());
|
transport.setId(StrKit.getRandomUUID());
|
||||||
transport.setSupermarketId(supermarket_id);
|
transport.setSupermarketId(supermarket_id);
|
||||||
|
|
@ -254,7 +271,7 @@ public class TransportSyncService {
|
||||||
transport.setInTime(new Date());
|
transport.setInTime(new Date());
|
||||||
transport.setInWhich(which);
|
transport.setInWhich(which);
|
||||||
transport.setState(OrderStateEnum.ENTERED.getStateid()); // 2,入场
|
transport.setState(OrderStateEnum.ENTERED.getStateid()); // 2,入场
|
||||||
transport.setFirstPic(saveImg(file));
|
transport.setFirstPic(filekey);
|
||||||
|
|
||||||
// 浠水只有外销
|
// 浠水只有外销
|
||||||
transport.setType(OrderTypeEnum.TEMP.getTypeid());
|
transport.setType(OrderTypeEnum.TEMP.getTypeid());
|
||||||
|
|
@ -266,7 +283,7 @@ public class TransportSyncService {
|
||||||
boolean ret = transport.save() && SyncTaskService.me.save(new SyncTask().addSaveData(transport));
|
boolean ret = transport.save() && SyncTaskService.me.save(new SyncTask().addSaveData(transport));
|
||||||
|
|
||||||
if(ret){
|
if(ret){
|
||||||
OssfileLogService.me.save(transport.getId(), transport.getFirstPic(), file.getAbsolutePath());
|
OssfileLogService.me.save(transport.getId(), transport.getFirstPic(), uploadfile.getAbsolutePath());
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
@ -309,9 +326,13 @@ public class TransportSyncService {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String fileuuid = StrKit.getRandomUUID();
|
||||||
|
String filekey = getOssKey(fileuuid, file);
|
||||||
|
File uploadfile = saveImg(fileuuid, file); // 压缩、重命名文件
|
||||||
|
|
||||||
transport.setOutTime(new Date());
|
transport.setOutTime(new Date());
|
||||||
transport.setOutWhich(which);
|
transport.setOutWhich(which);
|
||||||
transport.setSecondPic(saveImg(file));
|
transport.setSecondPic(filekey);
|
||||||
|
|
||||||
boolean ret = Db.tx(new IAtom() {
|
boolean ret = Db.tx(new IAtom() {
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -320,7 +341,7 @@ public class TransportSyncService {
|
||||||
boolean ret = transport.update() && SyncTaskService.me.save(new SyncTask().addUpdateData(transport));
|
boolean ret = transport.update() && SyncTaskService.me.save(new SyncTask().addUpdateData(transport));
|
||||||
|
|
||||||
if(ret){
|
if(ret){
|
||||||
OssfileLogService.me.save(transport.getId(), transport.getSecondPic(), file.getAbsolutePath());
|
OssfileLogService.me.save(transport.getId(), transport.getSecondPic(), uploadfile.getAbsolutePath());
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
@ -362,6 +383,10 @@ public class TransportSyncService {
|
||||||
Date now = new Date();
|
Date now = new Date();
|
||||||
boolean ret = false;
|
boolean ret = false;
|
||||||
|
|
||||||
|
String fileuuid = StrKit.getRandomUUID();
|
||||||
|
String filekey = getOssKey(fileuuid, file);
|
||||||
|
File uploadfile = saveImg(fileuuid, file); // 压缩、重命名文件
|
||||||
|
|
||||||
// 没有找到入场记录,就走入场流程
|
// 没有找到入场记录,就走入场流程
|
||||||
if (transport == null) {
|
if (transport == null) {
|
||||||
transport = new Transport();
|
transport = new Transport();
|
||||||
|
|
@ -371,7 +396,7 @@ public class TransportSyncService {
|
||||||
transport.setInTime(now);
|
transport.setInTime(now);
|
||||||
transport.setInWhich(which);
|
transport.setInWhich(which);
|
||||||
transport.setState(OrderStateEnum.ENTERED.getStateid());
|
transport.setState(OrderStateEnum.ENTERED.getStateid());
|
||||||
transport.setFirstPic(saveImg(file));
|
transport.setFirstPic(filekey);
|
||||||
|
|
||||||
// 浠水只有外销
|
// 浠水只有外销
|
||||||
transport.setType(OrderTypeEnum.TEMP.getTypeid());
|
transport.setType(OrderTypeEnum.TEMP.getTypeid());
|
||||||
|
|
@ -384,7 +409,7 @@ public class TransportSyncService {
|
||||||
boolean ret = finalTransport.save() && SyncTaskService.me.save(new SyncTask().addSaveData(finalTransport));
|
boolean ret = finalTransport.save() && SyncTaskService.me.save(new SyncTask().addSaveData(finalTransport));
|
||||||
|
|
||||||
if(ret){
|
if(ret){
|
||||||
OssfileLogService.me.save(finalTransport.getId(), finalTransport.getFirstPic(), file.getAbsolutePath());
|
OssfileLogService.me.save(finalTransport.getId(), finalTransport.getFirstPic(), uploadfile.getAbsolutePath());
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
@ -402,7 +427,7 @@ public class TransportSyncService {
|
||||||
|
|
||||||
transport.setOutTime(now);
|
transport.setOutTime(now);
|
||||||
transport.setOutWhich(which);
|
transport.setOutWhich(which);
|
||||||
transport.setSecondPic(saveImg(file));
|
transport.setSecondPic(filekey);
|
||||||
|
|
||||||
Transport finalTransport1 = transport;
|
Transport finalTransport1 = transport;
|
||||||
ret = Db.tx(new IAtom() {
|
ret = Db.tx(new IAtom() {
|
||||||
|
|
@ -412,7 +437,7 @@ public class TransportSyncService {
|
||||||
boolean ret = finalTransport1.update() && SyncTaskService.me.save(new SyncTask().addUpdateData(finalTransport1));
|
boolean ret = finalTransport1.update() && SyncTaskService.me.save(new SyncTask().addUpdateData(finalTransport1));
|
||||||
|
|
||||||
if(ret){
|
if(ret){
|
||||||
OssfileLogService.me.save(finalTransport1.getId(), finalTransport1.getSecondPic(), file.getAbsolutePath());
|
OssfileLogService.me.save(finalTransport1.getId(), finalTransport1.getSecondPic(), uploadfile.getAbsolutePath());
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
|
|
||||||
devMode=true
|
devMode=true
|
||||||
|
|
||||||
endpoint=oss-cn-shenzhen-internal.aliyuncs.com
|
endpoint=oss-cn-shenzhen.aliyuncs.com
|
||||||
#正式、测试的附件,都存入正式的 oss 中
|
#正式、测试的附件,都存入正式的 oss 中
|
||||||
bucketName=ssjygl-xsx-static
|
bucketName=ssjygl-xsx-static
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
|
|
||||||
devMode=true
|
devMode=true
|
||||||
|
|
||||||
endpoint=oss-cn-shenzhen.aliyuncs.com
|
endpoint=oss-cn-shenzhen-internal.aliyuncs.com
|
||||||
#正式、测试的附件,都存入正式的 oss 中
|
#正式、测试的附件,都存入正式的 oss 中
|
||||||
bucketName=ssjygl-xsx-static
|
bucketName=ssjygl-xsx-static
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,7 @@ import com.cowr.service.ssjygl.supermarket.sandfarmdistance.SupermarketSandfarmD
|
||||||
import com.cowr.service.ssjygl.supermarket.stock.StockController;
|
import com.cowr.service.ssjygl.supermarket.stock.StockController;
|
||||||
import com.cowr.service.ssjygl.synctask.SyncTaskService;
|
import com.cowr.service.ssjygl.synctask.SyncTaskService;
|
||||||
import com.cowr.service.ssjygl.system.sysuser.SysuserController;
|
import com.cowr.service.ssjygl.system.sysuser.SysuserController;
|
||||||
|
import com.cowr.service.ssjygl.transport.TransportQueryController;
|
||||||
import com.cowr.service.ssjygl.transportcompany.TransportCompanyController;
|
import com.cowr.service.ssjygl.transportcompany.TransportCompanyController;
|
||||||
import com.cowr.service.ssjygl.truck.TruckController;
|
import com.cowr.service.ssjygl.truck.TruckController;
|
||||||
import com.cowr.ssjygl.CacheData;
|
import com.cowr.ssjygl.CacheData;
|
||||||
|
|
@ -168,6 +169,8 @@ public class Config extends JFinalConfig {
|
||||||
me.add("/prepaytruck", PrepayTruckController.class);
|
me.add("/prepaytruck", PrepayTruckController.class);
|
||||||
me.add("/refunddetail", RefundDetailController.class);
|
me.add("/refunddetail", RefundDetailController.class);
|
||||||
|
|
||||||
|
me.add("/transport/query", TransportQueryController.class);
|
||||||
|
|
||||||
// -- 订单相关
|
// -- 订单相关
|
||||||
me.add("/order/ordercluster", OrderclusterController.class);
|
me.add("/order/ordercluster", OrderclusterController.class);
|
||||||
me.add("/order/sale", OrderSaleController.class);
|
me.add("/order/sale", OrderSaleController.class);
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,23 @@
|
||||||
|
package com.cowr.service.ssjygl.transport;
|
||||||
|
|
||||||
|
import com.cowr.common.base.BaseController;
|
||||||
|
import com.cowr.common.view.PageParam;
|
||||||
|
import com.cowr.common.view.Result;
|
||||||
|
import com.cowr.ssjygl.transport.TransportService;
|
||||||
|
|
||||||
|
public class TransportQueryController extends BaseController {
|
||||||
|
/**
|
||||||
|
* 分页查找 transport 场内运输记录
|
||||||
|
*/
|
||||||
|
public void find() {
|
||||||
|
PageParam pp = getBean(PageParam.class, "", true);
|
||||||
|
Integer supermarket_id = getInt("supermarket_id");
|
||||||
|
String order_sn = get("order_sn");
|
||||||
|
String stm = get("stm");
|
||||||
|
String etm = get("etm");
|
||||||
|
Integer trans_co_id = getInt("trans_co_id");
|
||||||
|
Integer state = getInt("state");
|
||||||
|
String truck_license = getUpperCaseVal("truck_license");
|
||||||
|
renderJson(Result.object(TransportService.me.find(pp, order_sn, stm, etm, truck_license, supermarket_id, trans_co_id, state)));
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue