调整集团订单
parent
8238df866d
commit
d6ba1b0793
|
|
@ -0,0 +1,14 @@
|
|||
package com.cowr.model;
|
||||
|
||||
import com.cowr.model.base.BaseOrderclusterTruck;
|
||||
|
||||
/**
|
||||
* Generated by COWR Mon Aug 24 16:29:49 CST 2020
|
||||
* TableName: ordercluster_truck
|
||||
* Remarks: 订单相关 - 订单派车
|
||||
* PrimaryKey: id
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class OrderclusterTruck extends BaseOrderclusterTruck<OrderclusterTruck> {
|
||||
public static final OrderclusterTruck dao = new OrderclusterTruck().dao();
|
||||
}
|
||||
|
|
@ -62,6 +62,7 @@ public class _MappingKit {
|
|||
arp.addMapping("order_seq", "tm,supermarket_id,type", OrderSeq.class);
|
||||
arp.addMapping("order_trash", "sn", OrderTrash.class);
|
||||
arp.addMapping("stock_modify_log", "id", StockModifyLog.class);
|
||||
arp.addMapping("ordercluster_truck", "id", OrderclusterTruck.class);
|
||||
arp.addMapping("ordercluster", "id", Ordercluster.class);
|
||||
arp.addMapping("order_transfer", "sn", OrderTransfer.class);
|
||||
arp.addMapping("order_sale", "sn", OrderSale.class);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,112 @@
|
|||
package com.cowr.model.base;
|
||||
|
||||
import com.cowr.common.base.BaseModel;
|
||||
import com.jfinal.plugin.activerecord.IBean;
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
|
||||
/**
|
||||
* Generated by COWR Mon Aug 24 16:29:49 CST 2020
|
||||
* TableName: ordercluster_truck
|
||||
* Remarks: 订单相关 - 订单派车
|
||||
* PrimaryKey: id
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public abstract class BaseOrderclusterTruck<M extends BaseOrderclusterTruck<M>> extends BaseModel<M> implements IBean {
|
||||
|
||||
public static final String tablename = "ordercluster_truck";
|
||||
|
||||
@JSONField(serialize=false)
|
||||
public String getTablename(){
|
||||
return tablename;
|
||||
}
|
||||
|
||||
/**
|
||||
* name: id
|
||||
* type: CHAR(1)
|
||||
* isNullable: NO
|
||||
* isPrimaryKey: YES
|
||||
* defaultValue:
|
||||
* @param id uuid
|
||||
*/
|
||||
@JSONField(name="id")
|
||||
public void setId(String id) {
|
||||
set("id", id);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return id uuid
|
||||
*/
|
||||
@JSONField(name="id")
|
||||
public String getId() {
|
||||
return getStr("id");
|
||||
}
|
||||
|
||||
/**
|
||||
* name: ordercluster_id
|
||||
* type: INT(10)
|
||||
* isNullable: NO
|
||||
* isPrimaryKey: NO
|
||||
* defaultValue:
|
||||
* @param orderclusterId
|
||||
*/
|
||||
@JSONField(name="ordercluster_id")
|
||||
public void setOrderclusterId(Integer orderclusterId) {
|
||||
set("ordercluster_id", orderclusterId);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return ordercluster_id
|
||||
*/
|
||||
@JSONField(name="ordercluster_id")
|
||||
public Integer getOrderclusterId() {
|
||||
return getInt("ordercluster_id");
|
||||
}
|
||||
|
||||
/**
|
||||
* name: truck_license
|
||||
* type: VARCHAR(20)
|
||||
* isNullable: NO
|
||||
* isPrimaryKey: NO
|
||||
* defaultValue:
|
||||
* @param truckLicense
|
||||
*/
|
||||
@JSONField(name="truck_license")
|
||||
public void setTruckLicense(String truckLicense) {
|
||||
set("truck_license", truckLicense);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return truck_license
|
||||
*/
|
||||
@JSONField(name="truck_license")
|
||||
public String getTruckLicense() {
|
||||
return getStr("truck_license");
|
||||
}
|
||||
|
||||
/**
|
||||
* name: change_time
|
||||
* type: TIMESTAMP(19)
|
||||
* isNullable: NO
|
||||
* isPrimaryKey: NO
|
||||
* defaultValue: CURRENT_TIMESTAMP
|
||||
* @param changeTime 最后修改时间
|
||||
*/
|
||||
@JSONField(name="change_time")
|
||||
public void setChangeTime(java.util.Date changeTime) {
|
||||
set("change_time", changeTime);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return change_time 最后修改时间
|
||||
*/
|
||||
@JSONField(name="change_time")
|
||||
public java.util.Date getChangeTime() {
|
||||
return get("change_time");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
package com.cowr.ssjygl.order.ordercluster.truck;
|
||||
|
||||
|
||||
import com.cowr.common.validator.CrudParamValidator;
|
||||
import com.cowr.common.view.Result;
|
||||
import com.cowr.model.OrderclusterTruck;
|
||||
import com.jfinal.core.Controller;
|
||||
|
||||
/**
|
||||
* Generated by COWR Mon Aug 24 16:29:54 CST 2020
|
||||
* TableName: ordercluster_truck
|
||||
* Remarks: 订单相关 - 订单派车
|
||||
* PrimaryKey: id
|
||||
*/
|
||||
public class OrderclusterTruckPKValidator extends CrudParamValidator {
|
||||
@Override
|
||||
protected void validate(Controller c) {
|
||||
validateRequired("id", "id", "id 必填");
|
||||
validateString("id", 1, 1, "id", "id 长度 1~1");
|
||||
}
|
||||
|
||||
protected void handleError(Controller c) {
|
||||
c.renderJson(Result.failed(getErrmsg()));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
package com.cowr.ssjygl.order.ordercluster.truck;
|
||||
|
||||
import com.cowr.common.Const;
|
||||
import com.cowr.common.base.BaseService;
|
||||
import com.cowr.common.view.PageParam;
|
||||
import com.cowr.model.OrderclusterTruck;
|
||||
import com.jfinal.kit.StrKit;
|
||||
import com.jfinal.plugin.activerecord.Db;
|
||||
import com.jfinal.plugin.activerecord.Page;
|
||||
import com.jfinal.plugin.activerecord.Record;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Generated by COWR Mon Aug 24 16:29:54 CST 2020
|
||||
* TableName: ordercluster_truck
|
||||
* Remarks: 订单相关 - 订单派车
|
||||
* PrimaryKey: id
|
||||
*/
|
||||
public class OrderclusterTruckService extends BaseService {
|
||||
public static final OrderclusterTruckService me = new OrderclusterTruckService();
|
||||
|
||||
public Page<Record> find(PageParam pp) {
|
||||
String selectsql = "select * ";
|
||||
String fromsql = "from ordercluster_truck t where 1=1 ";
|
||||
List<Object> paraList = new ArrayList<>();
|
||||
|
||||
String totalRowSql = "select count(*) " + fromsql;
|
||||
String findSql = selectsql + fromsql;
|
||||
|
||||
// 前端传了排序字段,并且排序字段存在相关表中
|
||||
if (StrKit.notBlank(pp.getSort_field()) && OrderclusterTruck.dao.hasColunm(pp.getSort_field())) {
|
||||
findSql += " order by t." + pp.getSort_field() + " is null, t." + pp.getSort_field();
|
||||
|
||||
if (Const.ORDER_BY_ASC.equals(pp.getSort_order())) {
|
||||
findSql += " " + Const.ORDER_BY_ASC;
|
||||
} else {
|
||||
findSql += " " + Const.ORDER_BY_DESC;
|
||||
}
|
||||
}
|
||||
|
||||
return Db.paginateByFullSql(pp.getPage(), pp.getSize(), totalRowSql, findSql, paraList.toArray());
|
||||
}
|
||||
|
||||
public List<OrderclusterTruck> list() {
|
||||
return OrderclusterTruck.dao.find("select * from ordercluster_truck");
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
package com.cowr.ssjygl.order.ordercluster.truck;
|
||||
|
||||
import com.jfinal.core.Controller;
|
||||
import com.jfinal.kit.StrKit;
|
||||
import com.cowr.common.validator.CrudParamValidator;
|
||||
import com.cowr.common.view.Result;
|
||||
import com.cowr.model.OrderclusterTruck;
|
||||
|
||||
/**
|
||||
* Generated by COWR Mon Aug 24 16:29:54 CST 2020
|
||||
* TableName: ordercluster_truck
|
||||
* Remarks: 订单相关 - 订单派车
|
||||
* PrimaryKey: id
|
||||
*/
|
||||
public class OrderclusterTruckValidator extends CrudParamValidator {
|
||||
@Override
|
||||
protected void validate(Controller c) {
|
||||
// 默认新增时,前端不需要传主键。若需要前端传主键,需要去掉这个判断
|
||||
if (!"save".equals(getActionMethodName())) {
|
||||
validateRequired("id", "id", "id 必填");
|
||||
|
||||
validateString("id", 1, 1, "id", "id 长度 1~1");
|
||||
}
|
||||
|
||||
validateInteger("ordercluster_id", 1, 2147483647, "ordercluster_id", "ordercluster_id 范围 1~2147483647");
|
||||
validateString("truck_license", 1, 20, "truck_license", "truck_license 长度 1~20");
|
||||
|
||||
// 使用 model 更新时,model 不能只有主键有值
|
||||
// 这里用 getActionMethodName 写死,判断是 update 时,才做验证
|
||||
// 如果确实是需要将主键外的字段置为 null,可以在代码生成后删掉这段
|
||||
if ("edit".equals(getActionMethodName())) {
|
||||
validateUpdateModel(OrderclusterTruck.class, "", true); // 忽略不在model中的字段
|
||||
}
|
||||
}
|
||||
|
||||
protected void handleError(Controller c) {
|
||||
c.renderJson(Result.failed(getErrmsg()));
|
||||
}
|
||||
}
|
||||
|
|
@ -47,6 +47,7 @@ public class Main {
|
|||
"cctv",
|
||||
"cctv_channels",
|
||||
"ordercluster",
|
||||
"ordercluster_truck",
|
||||
"supermarket_product",
|
||||
"blacklist",
|
||||
"order_transfer",
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ import com.cowr.local.ssjygl.invoice.receive.InvoiceReceiveController;
|
|||
import com.cowr.local.ssjygl.netty.NettyClient;
|
||||
import com.cowr.local.ssjygl.netty.SocketIOService;
|
||||
import com.cowr.local.ssjygl.order.ordercluster.OrderclusterController;
|
||||
import com.cowr.local.ssjygl.order.ordercluster.truck.OrderclusterTruckController;
|
||||
import com.cowr.local.ssjygl.order.orderpurchase.OrderPurchaseController;
|
||||
import com.cowr.local.ssjygl.order.ordersale.OrderSaleController;
|
||||
import com.cowr.local.ssjygl.order.ordertemp.OrderTempController;
|
||||
|
|
@ -201,6 +202,7 @@ public class Config extends JFinalConfig {
|
|||
me.add("/order/transfer", OrderTransferController.class);
|
||||
me.add("/order/trash", OrderTrashController.class);
|
||||
me.add("/order/purchase", OrderPurchaseController.class);
|
||||
me.add("/orderclustertruck", OrderclusterTruckController.class);
|
||||
|
||||
// -- 统计
|
||||
me.add("/stat/sale", OrderStatController.class);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,64 @@
|
|||
package com.cowr.local.ssjygl.order.ordercluster.truck;
|
||||
|
||||
import com.cowr.common.view.PageParam;
|
||||
import com.cowr.common.view.Result;
|
||||
import com.cowr.model.OrderclusterTruck;
|
||||
import com.cowr.ssjygl.order.ordercluster.truck.OrderclusterTruckPKValidator;
|
||||
import com.cowr.ssjygl.order.ordercluster.truck.OrderclusterTruckService;
|
||||
import com.cowr.ssjygl.order.ordercluster.truck.OrderclusterTruckValidator;
|
||||
import com.jfinal.aop.Before;
|
||||
import com.jfinal.core.Controller;
|
||||
|
||||
/**
|
||||
* Generated by COWR Mon Aug 24 16:29:54 CST 2020
|
||||
* TableName: ordercluster_truck
|
||||
* Remarks: 订单相关 - 订单派车
|
||||
* PrimaryKey: id
|
||||
*/
|
||||
public class OrderclusterTruckController extends Controller {
|
||||
|
||||
/**
|
||||
* 按主键检查对象是否存在
|
||||
* 返回 code = 200
|
||||
* 存在时 data = true
|
||||
* 不存在 data = false
|
||||
*/
|
||||
@Before(OrderclusterTruckPKValidator.class)
|
||||
public void checkExistsByPk(){
|
||||
OrderclusterTruck model = getModel(OrderclusterTruck.class, "", true); // 忽略不在model中的字段
|
||||
renderJson(OrderclusterTruckService.me.checkExistsByPk(model));
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查找 ordercluster_truck 订单相关 - 订单派车
|
||||
*/
|
||||
public void find(){
|
||||
PageParam pp = getBean(PageParam.class, "", true);
|
||||
renderJson(Result.object(OrderclusterTruckService.me.find(pp)));
|
||||
}
|
||||
|
||||
/**
|
||||
* 按主键查找单个对象 ordercluster_truck 订单相关 - 订单派车
|
||||
*/
|
||||
@Before(OrderclusterTruckPKValidator.class)
|
||||
public void findByPk(){
|
||||
OrderclusterTruck model = getModel(OrderclusterTruck.class, "", true); // 忽略不在model中的字段
|
||||
renderJson(OrderclusterTruckService.me.findByPk(model));
|
||||
}
|
||||
|
||||
/**
|
||||
* 按主键查找单个对象 ordercluster_truck 订单相关 - 订单派车
|
||||
*/
|
||||
@Before(OrderclusterTruckPKValidator.class)
|
||||
public void get(){
|
||||
OrderclusterTruck model = getModel(OrderclusterTruck.class, "", true); // 忽略不在model中的字段
|
||||
renderJson(OrderclusterTruckService.me.findByPk(model));
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回所有 ordercluster_truck 订单相关 - 订单派车
|
||||
*/
|
||||
public void list(){
|
||||
renderJson(Result.object(OrderclusterTruckService.me.list()));
|
||||
}
|
||||
}
|
||||
|
|
@ -14,6 +14,7 @@ import com.cowr.service.ssjygl.invoice.log.InvoiceLogController;
|
|||
import com.cowr.service.ssjygl.invoice.receive.InvoiceReceiveController;
|
||||
import com.cowr.service.ssjygl.netty.NettyServer;
|
||||
import com.cowr.service.ssjygl.order.ordercluster.OrderclusterController;
|
||||
import com.cowr.service.ssjygl.order.ordercluster.truck.OrderclusterTruckController;
|
||||
import com.cowr.service.ssjygl.order.orderpurchase.OrderPurchaseController;
|
||||
import com.cowr.service.ssjygl.order.ordersale.OrderSaleController;
|
||||
import com.cowr.service.ssjygl.order.ordertemp.OrderTempController;
|
||||
|
|
@ -167,6 +168,7 @@ public class Config extends JFinalConfig {
|
|||
me.add("/order/transfer", OrderTransferController.class);
|
||||
me.add("/order/trash", OrderTrashController.class);
|
||||
me.add("/order/purchase", OrderPurchaseController.class);
|
||||
me.add("/orderclustertruck", OrderclusterTruckController.class);
|
||||
|
||||
// -- 统计
|
||||
me.add("/stat/sale", OrderStatController.class);
|
||||
|
|
|
|||
|
|
@ -54,13 +54,22 @@ public class OrderclusterSyncService extends BaseSyncService {
|
|||
}
|
||||
|
||||
Customer customerObj = Customer.dao.findById(model.getCustomerId());
|
||||
if (customerObj == null) {
|
||||
return Result.failed(false, "新增失败, 客户信息验证失败");
|
||||
// 传了客户id时,用后端客户信息填充,否则用前端传的
|
||||
if (customerObj != null) {
|
||||
// 客户信息
|
||||
model.setCustomerId(customerObj.getId());
|
||||
model.setCustomerAddress(customerObj.getAddress());
|
||||
model.setCustomerBankAccount(customerObj.getBankAccount());
|
||||
model.setCustomerBankName(customerObj.getBankName());
|
||||
model.setCustomerName(customerObj.getName());
|
||||
model.setCustomerPhone(customerObj.getPhone());
|
||||
model.setCustomerTexpayerName(customerObj.getTexpayerName());
|
||||
model.setCustomerTexpayerNum(customerObj.getTexpayerNum());
|
||||
}
|
||||
|
||||
List<Record> list = OrderclusterService.me.undonlist(model.getSupermarketId(), model.getCustomerId());
|
||||
|
||||
if(list != null && !list.isEmpty()){
|
||||
if (list != null && !list.isEmpty()) {
|
||||
return Result.failed("还有未完成的集团订单");
|
||||
}
|
||||
|
||||
|
|
@ -79,7 +88,7 @@ public class OrderclusterSyncService extends BaseSyncService {
|
|||
return Result.failed("未配置商品单价");
|
||||
}
|
||||
|
||||
if(unitprice.multiply(model.getTotalWeight()).compareTo(prepayCustomer.getSurplus()) > 0){
|
||||
if (unitprice.multiply(model.getTotalWeight()).compareTo(prepayCustomer.getSurplus()) > 0) {
|
||||
return Result.failedstr("余额 %.2f 不足以购买 %.2f 吨 %s", prepayCustomer.getSurplus(), model.getTotalWeight(), product.getName());
|
||||
}
|
||||
|
||||
|
|
@ -87,16 +96,6 @@ public class OrderclusterSyncService extends BaseSyncService {
|
|||
|
||||
model.setProductName(product.getName());
|
||||
|
||||
// 客户信息
|
||||
model.setCustomerId(customerObj.getId());
|
||||
model.setCustomerAddress(customerObj.getAddress());
|
||||
model.setCustomerBankAccount(customerObj.getBankAccount());
|
||||
model.setCustomerBankName(customerObj.getBankName());
|
||||
model.setCustomerName(customerObj.getName());
|
||||
model.setCustomerPhone(customerObj.getPhone());
|
||||
model.setCustomerTexpayerName(customerObj.getTexpayerName());
|
||||
model.setCustomerTexpayerNum(customerObj.getTexpayerNum());
|
||||
|
||||
model.setUnitPrice(unitprice); // 后端获取数据库中单价
|
||||
model.setCreateTime(new Date()); // 当前系统时间
|
||||
model.setCreateUserId(sysuser.getId()); // 当前用户id
|
||||
|
|
@ -141,9 +140,12 @@ public class OrderclusterSyncService extends BaseSyncService {
|
|||
return Result.failed(false, "订单已完成,不能修改");
|
||||
}
|
||||
|
||||
if (model.getCutoffTime() != null) {
|
||||
if (oldobj.getState() > OrderStateEnum.INITIAL.getStateid() && !oldobj.getCutoffTime().equals(model.getCutoffTime())) {
|
||||
return Result.failed(false, "已经开始执行的订单不能修改完成时间");
|
||||
} else if (model.getCutoffTime() != null) {
|
||||
oldobj.setCutoffTime(model.getCutoffTime());
|
||||
}
|
||||
|
||||
if (model.getAvgWeight() != null) {
|
||||
oldobj.setAvgWeight(model.getAvgWeight());
|
||||
}
|
||||
|
|
@ -172,8 +174,13 @@ public class OrderclusterSyncService extends BaseSyncService {
|
|||
}
|
||||
}
|
||||
|
||||
oldobj.setCutoffTime(model.getCutoffTime());
|
||||
oldobj.setAvgWeight(model.getAvgWeight());
|
||||
if (model.getTimeInterval() != null) {
|
||||
oldobj.setTimeInterval(model.getTimeInterval());
|
||||
}
|
||||
|
||||
if (model.getMiniTruck() != null) {
|
||||
oldobj.setMiniTruck(model.getMiniTruck());
|
||||
}
|
||||
|
||||
if (model.getTransDistance() != null) {
|
||||
oldobj.setTransDistance(model.getTransDistance());
|
||||
|
|
@ -276,8 +283,8 @@ public class OrderclusterSyncService extends BaseSyncService {
|
|||
return Result.failed(false, "按主键未找到对应记录");
|
||||
}
|
||||
|
||||
if (oldobj.getState() == OrderStateEnum.RECEIVED.getStateid()) {
|
||||
return Result.failed("已经完结的,不能再修改");
|
||||
if (oldobj.getState() >= OrderStateEnum.RECEIVED.getStateid()) {
|
||||
return Result.failed("已经完结或者取消的,不能再修改");
|
||||
}
|
||||
|
||||
oldobj.setState(OrderStateEnum.RECEIVED.getStateid()); // 将订单状态置为 5
|
||||
|
|
|
|||
|
|
@ -0,0 +1,82 @@
|
|||
package com.cowr.service.ssjygl.order.ordercluster.truck;
|
||||
|
||||
import com.cowr.common.view.PageParam;
|
||||
import com.cowr.common.view.Result;
|
||||
import com.cowr.model.OrderclusterTruck;
|
||||
import com.cowr.ssjygl.order.ordercluster.truck.OrderclusterTruckPKValidator;
|
||||
import com.cowr.ssjygl.order.ordercluster.truck.OrderclusterTruckService;
|
||||
import com.cowr.ssjygl.order.ordercluster.truck.OrderclusterTruckValidator;
|
||||
import com.jfinal.aop.Before;
|
||||
import com.jfinal.core.Controller;
|
||||
|
||||
/**
|
||||
* Generated by COWR Mon Aug 24 16:29:54 CST 2020
|
||||
* TableName: ordercluster_truck
|
||||
* Remarks: 订单相关 - 订单派车
|
||||
* PrimaryKey: id
|
||||
*/
|
||||
public class OrderclusterTruckController extends Controller {
|
||||
|
||||
/**
|
||||
* 按主键检查对象是否存在
|
||||
* 返回 code = 200
|
||||
* 存在时 data = true
|
||||
* 不存在 data = false
|
||||
*/
|
||||
@Before(OrderclusterTruckPKValidator.class)
|
||||
public void checkExistsByPk(){
|
||||
OrderclusterTruck model = getModel(OrderclusterTruck.class, "", true); // 忽略不在model中的字段
|
||||
renderJson(OrderclusterTruckService.me.checkExistsByPk(model));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增 ordercluster_truck 订单相关 - 订单派车
|
||||
*/
|
||||
@Before(OrderclusterTruckValidator.class)
|
||||
public void save(){
|
||||
OrderclusterTruck model = getModel(OrderclusterTruck.class, "", true); // 忽略不在model中的字段
|
||||
renderJson(OrderclusterTruckService.me.save(model));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除 ordercluster_truck 订单相关 - 订单派车
|
||||
*/
|
||||
@Before(OrderclusterTruckPKValidator.class)
|
||||
public void del(){
|
||||
OrderclusterTruck model = getModel(OrderclusterTruck.class, "", true); // 忽略不在model中的字段
|
||||
renderJson(OrderclusterTruckService.me.delete(model));
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查找 ordercluster_truck 订单相关 - 订单派车
|
||||
*/
|
||||
public void find(){
|
||||
PageParam pp = getBean(PageParam.class, "", true);
|
||||
renderJson(Result.object(OrderclusterTruckService.me.find(pp)));
|
||||
}
|
||||
|
||||
/**
|
||||
* 按主键查找单个对象 ordercluster_truck 订单相关 - 订单派车
|
||||
*/
|
||||
@Before(OrderclusterTruckPKValidator.class)
|
||||
public void findByPk(){
|
||||
OrderclusterTruck model = getModel(OrderclusterTruck.class, "", true); // 忽略不在model中的字段
|
||||
renderJson(OrderclusterTruckService.me.findByPk(model));
|
||||
}
|
||||
|
||||
/**
|
||||
* 按主键查找单个对象 ordercluster_truck 订单相关 - 订单派车
|
||||
*/
|
||||
@Before(OrderclusterTruckPKValidator.class)
|
||||
public void get(){
|
||||
OrderclusterTruck model = getModel(OrderclusterTruck.class, "", true); // 忽略不在model中的字段
|
||||
renderJson(OrderclusterTruckService.me.findByPk(model));
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回所有 ordercluster_truck 订单相关 - 订单派车
|
||||
*/
|
||||
public void list(){
|
||||
renderJson(Result.object(OrderclusterTruckService.me.list()));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,155 @@
|
|||
package com.cowr.service.ssjygl.order.ordercluster.truck;
|
||||
|
||||
import com.cowr.common.enums.Enums;
|
||||
import com.cowr.common.enums.UserTypeEnum;
|
||||
import com.cowr.common.view.Result;
|
||||
import com.cowr.model.*;
|
||||
import com.cowr.service.ssjygl.base.BaseSyncService;
|
||||
import com.cowr.service.ssjygl.synctask.SyncTaskService;
|
||||
import com.cowr.ssjygl.modifylog.ModifyLogService;
|
||||
import com.jfinal.kit.StrKit;
|
||||
import com.jfinal.log.Log;
|
||||
import com.jfinal.plugin.activerecord.Db;
|
||||
import com.jfinal.plugin.activerecord.IAtom;
|
||||
import com.jfinal.plugin.activerecord.Record;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class OrderclusterTruckSyncService extends BaseSyncService {
|
||||
private static Log log = Log.getLog(OrderclusterTruckSyncService.class);
|
||||
public static OrderclusterTruckSyncService me = new OrderclusterTruckSyncService();
|
||||
|
||||
public Result save(int ordercluster_id, String trucks, Sysuser sysuser) {
|
||||
Ordercluster ordercluster = Ordercluster.dao.findById(ordercluster_id);
|
||||
|
||||
if (ordercluster == null) {
|
||||
return Result.failed("未找到集团订单信息");
|
||||
}
|
||||
|
||||
List<String> chk = new ArrayList<>();
|
||||
String[] truckarr = trucks.split(",");
|
||||
List<String> ts = new ArrayList<>();
|
||||
List<String> tsql = new ArrayList<>();
|
||||
|
||||
for (String truck_license : truckarr) {
|
||||
if (chk.contains(truck_license)) {
|
||||
return Result.failedstr("车牌号 %s 重复", truck_license);
|
||||
}
|
||||
|
||||
chk.add(truck_license);
|
||||
|
||||
ts.add(truck_license);
|
||||
tsql.add("?");
|
||||
}
|
||||
|
||||
List<Blacklist> list = Blacklist.dao.find(
|
||||
"select * from blacklist \n" +
|
||||
" where remove_user_id is null \n" +
|
||||
" and truck_license in (" + StrKit.join(tsql, ",") + ")", ts.toArray());
|
||||
|
||||
if (list != null && !list.isEmpty()) {
|
||||
ts = new ArrayList<>();
|
||||
|
||||
for (Blacklist bl : list) {
|
||||
ts.add(bl.getTruckLicense());
|
||||
}
|
||||
|
||||
return Result.failed(StrKit.join(ts, ",") + " 车牌号在黑名单中");
|
||||
}
|
||||
|
||||
List<OrderclusterTruck> otlist = OrderclusterTruck.dao.find(
|
||||
"select * from ordercluster_truck \n" +
|
||||
" where ordercluster_id = ? \n" +
|
||||
" and truck_license in (" + StrKit.join(tsql, ",") + ")", ts.toArray());
|
||||
|
||||
if (otlist != null && !otlist.isEmpty()) {
|
||||
ts = new ArrayList<>();
|
||||
|
||||
for (OrderclusterTruck bl : otlist) {
|
||||
ts.add(bl.getTruckLicense());
|
||||
}
|
||||
|
||||
return Result.failed(StrKit.join(ts, ",") + " 车牌号已分配");
|
||||
}
|
||||
|
||||
List<OrderclusterTruck> oldot = OrderclusterTruck.dao.find("select * from ordercluster_truck where ordercluster_id = ? ", ordercluster_id);
|
||||
|
||||
if (truckarr.length + oldot.size() < ordercluster.getMiniTruck()) {
|
||||
return Result.failedstr("安排车辆总数不能小于 %d", ordercluster.getMiniTruck());
|
||||
}
|
||||
|
||||
List<OrderclusterTruck> savelist = new ArrayList<>();
|
||||
SyncTask synctask = new SyncTask();
|
||||
|
||||
for (String truck_license : truckarr) {
|
||||
OrderclusterTruck oct = new OrderclusterTruck();
|
||||
oct.setId(StrKit.getRandomUUID());
|
||||
oct.setOrderclusterId(ordercluster_id);
|
||||
oct.setTruckLicense(truck_license);
|
||||
|
||||
synctask.addUpdateData(oct);
|
||||
savelist.add(oct);
|
||||
}
|
||||
|
||||
if (savelist.isEmpty()) {
|
||||
return Result.failed("truck_license 参数错误");
|
||||
}
|
||||
|
||||
Record logrecord = new Record();
|
||||
logrecord.set("customer_id", ordercluster_id);
|
||||
logrecord.set("truckstr", trucks);
|
||||
|
||||
boolean ret = Db.tx(new IAtom() {
|
||||
@Override
|
||||
public boolean run() {
|
||||
int[] ret = Db.batchSave(savelist, savelist.size());
|
||||
|
||||
for (int i : ret) {
|
||||
// 必须是每条 sql 修改一条记录
|
||||
if (i != 1) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return SyncTaskService.me.save(synctask, ordercluster.getSupermarketId())
|
||||
&& ModifyLogService.me.save(OrderclusterTruck.tablename, "id", logrecord.toJson(), Enums.DataOpType.SAVE.getId(), sysuser);
|
||||
}
|
||||
});
|
||||
|
||||
return ret ? Result.success() : Result.failed(false, "新增失败");
|
||||
}
|
||||
|
||||
public Result delete(OrderclusterTruck model, Sysuser sysuser) {
|
||||
OrderclusterTruck oldtruck = model.findByPk();
|
||||
|
||||
if (oldtruck == null) {
|
||||
return Result.failed("未找到记录");
|
||||
}
|
||||
|
||||
Ordercluster old = Ordercluster.dao.findById(oldtruck.getOrderclusterId());
|
||||
if (old == null) {
|
||||
return Result.failed("未找到关联集团订单信息");
|
||||
}
|
||||
|
||||
// 限制只能删除自己的
|
||||
if (sysuser.getType() == UserTypeEnum.CUSTOMER.getTypeid()) {
|
||||
if (old.getCustomerId() == null) {
|
||||
return Result.failed("关联集团订单信息错误,没有关联客户信息");
|
||||
} else if (sysuser.getEntityId() == null) {
|
||||
return Result.failed("当前登录用户不是客户账户");
|
||||
} else if (sysuser.getEntityId().equals(old.getCustomerId())) {
|
||||
log.error("登录用户 entity_id: %s 和集团订单 customer_id: %s 不一致", sysuser.getEntityId(), old.getCustomerId());
|
||||
return Result.failed("操作失败");
|
||||
}
|
||||
}
|
||||
|
||||
List<OrderclusterTruck> list = OrderclusterTruck.dao.find("select * from ordercluster_truck where ordercluster_id = ? ", oldtruck.getOrderclusterId());
|
||||
|
||||
if (list.size() - 1 < old.getMiniTruck()) {
|
||||
return Result.failedstr("安排车辆总数不能小于 %d", old.getMiniTruck());
|
||||
}
|
||||
|
||||
return super.delete(model, sysuser);
|
||||
}
|
||||
}
|
||||
|
|
@ -40,7 +40,7 @@ public class SysuserSyncService extends BaseSyncService {
|
|||
public static final SysuserSyncService me = new SysuserSyncService();
|
||||
private static final Pattern rolepattern = Pattern.compile("[0-2]{3}");
|
||||
private static int expireAt = 24 * 60 * 60; // 超时时间,单位秒
|
||||
private static int customerExpireAt = 30 * 60; // 超时时间,单位秒,客户账户 token 有效时间
|
||||
private static int customerExpireAt = 60 * 60; // 超时时间,单位秒,客户账户 token 有效时间
|
||||
|
||||
public String redisbasekey() {
|
||||
return Config.dbprop.get("redis.basekey") + Const.REDIS_SEPARATE + tablename + Const.REDIS_SEPARATE;
|
||||
|
|
|
|||
Loading…
Reference in New Issue