订单取消申请添加附件上传功能
parent
0dfc68352b
commit
84b1b466fd
|
|
@ -290,6 +290,30 @@ public abstract class BaseOrderInvalidVerify<M extends BaseOrderInvalidVerify<M>
|
|||
return getStr("invalid_memo");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* name: attachment
|
||||
* type: text
|
||||
* isNullable: YES
|
||||
* isPrimaryKey: NO
|
||||
* defaultValue:
|
||||
* @param attachment 附件路径等信息
|
||||
*/
|
||||
@JSONField(name="attachment")
|
||||
public void setAttachment(String attachment) {
|
||||
set("attachment", attachment);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return attachment 附件路径等信息
|
||||
*/
|
||||
@JSONField(name="attachment")
|
||||
public String getAttachment() {
|
||||
return getStr("attachment");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* name: memo
|
||||
* type: VARCHAR(255)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,122 @@
|
|||
package com.cowr.ssjygl.file;
|
||||
|
||||
import com.cowr.common.oss.OSSKit;
|
||||
import com.cowr.common.utils.DateTimeUtil;
|
||||
import com.cowr.common.view.Result;
|
||||
import com.jfinal.core.Controller;
|
||||
import com.jfinal.kit.StrKit;
|
||||
import com.jfinal.log.Log;
|
||||
import com.jfinal.plugin.activerecord.Record;
|
||||
import com.jfinal.upload.UploadFile;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
public class OssFileControler extends Controller {
|
||||
private static Log log = Log.getLog(OssFileControler.class);
|
||||
|
||||
public void upload() {
|
||||
List<UploadFile> fileList = this.getFiles();
|
||||
if (fileList == null || fileList.size() == 0) {
|
||||
renderJson(Result.failed("文件不能为空"));
|
||||
return;
|
||||
}
|
||||
|
||||
List<Record> ret = new ArrayList<>();
|
||||
|
||||
for (UploadFile upload : fileList) {
|
||||
File file = null;
|
||||
String fileName = "";
|
||||
try {
|
||||
String key = StrKit.getRandomUUID();
|
||||
file = upload.getFile();
|
||||
fileName = file.getName();
|
||||
String suffix = fileName.substring(fileName.lastIndexOf("."), fileName.length()).toLowerCase();
|
||||
OSSKit.putObject(key + suffix, file);
|
||||
|
||||
Record r = new Record();
|
||||
r.set("fileName", fileName);
|
||||
r.set("ossKey", key + suffix);
|
||||
r.set("tm", DateTimeUtil.sdfhms.get().format(new Date(file.lastModified())));
|
||||
ret.add(r);
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
renderJson(Result.failed(fileName + "上传失败"));
|
||||
return;
|
||||
} finally {
|
||||
if (file != null) {
|
||||
file.delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
renderJson(Result.object(ret));
|
||||
}
|
||||
|
||||
public void del() {
|
||||
String ossKey = get("ossKey");
|
||||
if (StrKit.isBlank(ossKey)) {
|
||||
renderJson(Result.failed("ossKey不能为空"));
|
||||
return;
|
||||
}
|
||||
|
||||
boolean flag;
|
||||
try {
|
||||
flag = OSSKit.delObject(ossKey);
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
renderJson(Result.failed("删除失败!"));
|
||||
return;
|
||||
}
|
||||
|
||||
renderJson(Result.object(flag));
|
||||
}
|
||||
|
||||
public void uploadCancelOrder() {
|
||||
List<UploadFile> fileList = this.getFiles();
|
||||
String order_sn = get("order_sn");
|
||||
|
||||
if (StrKit.isBlank(order_sn)) {
|
||||
renderJson(Result.failed("订单号不能为空"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (fileList == null || fileList.size() == 0) {
|
||||
renderJson(Result.failed("文件不能为空"));
|
||||
return;
|
||||
}
|
||||
|
||||
List<Record> ret = new ArrayList<>();
|
||||
|
||||
for (UploadFile upload : fileList) {
|
||||
File file = null;
|
||||
String fileName = "";
|
||||
try {
|
||||
file = upload.getFile();
|
||||
fileName = file.getName();
|
||||
String uuid = StrKit.getRandomUUID();
|
||||
String suffix = fileName.substring(fileName.lastIndexOf("."), fileName.length()).toLowerCase();
|
||||
String key = "attachment/" + order_sn + "/" + uuid + suffix;
|
||||
OSSKit.putObject(key, file);
|
||||
|
||||
Record r = new Record();
|
||||
r.set("fileName", fileName);
|
||||
r.set("ossKey", key);
|
||||
r.set("tm", DateTimeUtil.sdfhms.get().format(new Date(file.lastModified())));
|
||||
ret.add(r);
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
renderJson(Result.failed(fileName + "上传失败"));
|
||||
return;
|
||||
} finally {
|
||||
if (file != null) {
|
||||
file.delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
renderJson(Result.object(ret));
|
||||
}
|
||||
}
|
||||
|
|
@ -64,6 +64,7 @@ import com.cowr.model._MappingKit;
|
|||
import com.cowr.ssjygl.CacheData;
|
||||
import com.cowr.ssjygl.actioncmdlog.ActionCmdLogController;
|
||||
import com.cowr.ssjygl.cctv.CctvController;
|
||||
import com.cowr.ssjygl.file.OssFileControler;
|
||||
import com.cowr.ssjygl.modifylog.ModifyLogController;
|
||||
import com.cowr.ssjygl.stat.invoice.InvoiceUseController;
|
||||
import com.cowr.ssjygl.stat.purchase.OrderPurchaseStatController;
|
||||
|
|
@ -177,6 +178,7 @@ public class Config extends JFinalConfig {
|
|||
me.add("/camera", CameraController.class);
|
||||
me.add("/supcctv", CctvController.class);
|
||||
me.add("/overall", OverallController.class);
|
||||
me.add("/ossFile", OssFileControler.class);
|
||||
|
||||
// -- 权限系统
|
||||
me.add("/sysuser", SysuserController.class);
|
||||
|
|
|
|||
|
|
@ -32,8 +32,9 @@ public class OrderInvalidVerifyController extends Controller {
|
|||
|
||||
String order_sn = get("order_sn");
|
||||
String invalid_memo = get("invalid_memo");
|
||||
String attachment = get("attachment");
|
||||
|
||||
renderJson(OrderInvalidVerifySyncService.me.save(order_sn, invalid_memo, tokenuser));
|
||||
renderJson(OrderInvalidVerifySyncService.me.save(order_sn, attachment, invalid_memo, tokenuser));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ public class OrderInvalidVerifySyncService {
|
|||
private static Log log = Log.getLog(OrderInvalidVerifySyncService.class);
|
||||
public static OrderInvalidVerifySyncService me = new OrderInvalidVerifySyncService();
|
||||
|
||||
public Result save(String order_sn, String invalid_memo, Sysuser sysuser) {
|
||||
public Result save(String order_sn, String attachment, String invalid_memo, Sysuser sysuser) {
|
||||
OrderTemp order = OrderTemp.dao.findById(order_sn);
|
||||
|
||||
if (order == null) {
|
||||
|
|
@ -48,6 +48,7 @@ public class OrderInvalidVerifySyncService {
|
|||
model.setCreateUserName(sysuser.getName());
|
||||
model.setOrderSn(order.getSn());
|
||||
model.setType(OrderTypeEnum.TEMP.getTypeid());
|
||||
model.setAttachment(attachment);
|
||||
model.setInvalidMemo(invalid_memo);
|
||||
|
||||
SyncTask synctask = new SyncTask();
|
||||
|
|
|
|||
|
|
@ -61,6 +61,7 @@ import com.cowr.ssjygl.CacheData;
|
|||
import com.cowr.ssjygl.actioncmdlog.ActionCmdLogController;
|
||||
import com.cowr.ssjygl.cctv.CctvController;
|
||||
import com.cowr.ssjygl.customer.type.CustomerTypeController;
|
||||
import com.cowr.ssjygl.file.OssFileControler;
|
||||
import com.cowr.ssjygl.modifylog.ModifyLogController;
|
||||
import com.cowr.ssjygl.stat.invoice.InvoiceUseController;
|
||||
import com.cowr.ssjygl.stat.purchase.OrderPurchaseStatController;
|
||||
|
|
@ -155,6 +156,7 @@ public class Config extends JFinalConfig {
|
|||
me.add("/cache", CacheController.class);
|
||||
me.add("/supcctv", CctvController.class);
|
||||
me.add("/overall", OverallController.class);
|
||||
me.add("/ossFile", OssFileControler.class);
|
||||
|
||||
// -- 权限系统
|
||||
me.add("/sysuser", SysuserController.class);
|
||||
|
|
|
|||
Loading…
Reference in New Issue