车辆有效判断及商品价格类表
parent
7bbc73a5eb
commit
9830a774fd
|
|
@ -104,27 +104,20 @@ public class OrderclusterTruckService extends BaseService {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
Calendar c = Calendar.getInstance();
|
String tm = DateTimeUtil.sdfhms.get().format(new Date());
|
||||||
c.set(Calendar.HOUR_OF_DAY, 0);
|
|
||||||
c.set(Calendar.MINUTE, 0);
|
|
||||||
c.set(Calendar.SECOND, 0);
|
|
||||||
c.set(Calendar.MILLISECOND, 0);
|
|
||||||
Date start = c.getTime();
|
|
||||||
c.add(Calendar.HOUR_OF_DAY, 24);
|
|
||||||
Date end = c.getTime();
|
|
||||||
|
|
||||||
return OrderclusterTruck.dao.findFirst("select * from ordercluster_truck t\n" +
|
return OrderclusterTruck.dao.findFirst("select * from ordercluster_truck t\n" +
|
||||||
" left join ordercluster c on c.id = t.ordercluster_id \n" +
|
" left join ordercluster c on c.id = t.ordercluster_id \n" +
|
||||||
" where c.supermarket_id = ? \n" +
|
" where c.supermarket_id = ? \n" +
|
||||||
" and c.state < ?" +
|
" and c.state < ?" +
|
||||||
" and c.cutoff_time >= ? \n" +
|
" and c.start_time >= ? \n" +
|
||||||
" and c.cutoff_time < ? \n" +
|
" and c.cutoff_time <= ? \n" +
|
||||||
" and t.truck_license = ? \n" +
|
" and t.truck_license = ? \n" +
|
||||||
" limit 0,1",
|
" limit 0,1",
|
||||||
supermarket_id,
|
supermarket_id,
|
||||||
OrderStateEnum.RECEIVED.getStateid(), // 只有未完成的订单才有效
|
OrderStateEnum.RECEIVED.getStateid(), // 只有未完成的订单才有效
|
||||||
start,
|
tm,
|
||||||
end,
|
tm,
|
||||||
truck_license);
|
truck_license);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -140,27 +133,20 @@ public class OrderclusterTruckService extends BaseService {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
Calendar c = Calendar.getInstance();
|
String tm = DateTimeUtil.sdfhms.get().format(new Date());
|
||||||
c.set(Calendar.HOUR_OF_DAY, 0);
|
|
||||||
c.set(Calendar.MINUTE, 0);
|
|
||||||
c.set(Calendar.SECOND, 0);
|
|
||||||
c.set(Calendar.MILLISECOND, 0);
|
|
||||||
Date start = c.getTime();
|
|
||||||
c.add(Calendar.HOUR_OF_DAY, 24);
|
|
||||||
Date end = c.getTime();
|
|
||||||
|
|
||||||
OrderclusterTruck ot = OrderclusterTruck.dao.findFirst("select * from ordercluster_truck t\n" +
|
OrderclusterTruck ot = OrderclusterTruck.dao.findFirst("select * from ordercluster_truck t\n" +
|
||||||
" left join ordercluster c on c.id = t.ordercluster_id \n" +
|
" left join ordercluster c on c.id = t.ordercluster_id \n" +
|
||||||
" where c.supermarket_id = ? \n" +
|
" where c.supermarket_id = ? \n" +
|
||||||
" and c.state < ?" +
|
" and c.state < ?" +
|
||||||
" and c.cutoff_time >= ? \n" +
|
" and c.start_time >= ? \n" +
|
||||||
" and c.cutoff_time < ? \n" +
|
" and c.cutoff_time <= ? \n" +
|
||||||
" and t.truck_license = ? \n" +
|
" and t.truck_license = ? \n" +
|
||||||
" limit 0,1",
|
" limit 0,1",
|
||||||
supermarket_id,
|
supermarket_id,
|
||||||
OrderStateEnum.RECEIVED.getStateid(), // 只有未完成的订单才有效
|
OrderStateEnum.RECEIVED.getStateid(), // 只有未完成的订单才有效
|
||||||
start,
|
tm,
|
||||||
end,
|
tm,
|
||||||
truck_license);
|
truck_license);
|
||||||
|
|
||||||
if (ot == null) {
|
if (ot == null) {
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ import com.jfinal.plugin.activerecord.Db;
|
||||||
import com.jfinal.plugin.activerecord.Page;
|
import com.jfinal.plugin.activerecord.Page;
|
||||||
import com.jfinal.plugin.activerecord.Record;
|
import com.jfinal.plugin.activerecord.Record;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
@ -59,4 +60,12 @@ public class ProductService extends BaseService {
|
||||||
public List<Product> list() {
|
public List<Product> list() {
|
||||||
return Product.dao.find("select * from product t where t.del = 0 ");
|
return Product.dao.find("select * from product t where t.del = 0 ");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public BigDecimal getUnitPrice(Integer product_id, Integer supermarket_id) {
|
||||||
|
Record record = Db.findFirst("select unit_price from supermarket_product where product_id=? and supermarket_id=? limit 1", product_id, supermarket_id);
|
||||||
|
if (record == null || record.getBigDecimal("unit_price") == null) {
|
||||||
|
return new BigDecimal("0.00");
|
||||||
|
}
|
||||||
|
return record.getBigDecimal("unit_price");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -62,4 +62,10 @@ public class ProductController extends Controller {
|
||||||
public void list() {
|
public void list() {
|
||||||
renderJson(Result.object(ProductService.me.list()));
|
renderJson(Result.object(ProductService.me.list()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void getUnitPrice() {
|
||||||
|
Integer product_id =getInt("product_id");
|
||||||
|
Integer supermarket_id =getInt("supermarket_id");
|
||||||
|
renderJson(Result.object(ProductService.me.getUnitPrice(product_id,supermarket_id)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -79,6 +79,22 @@ public class TruckWeightLimitController extends Controller {
|
||||||
renderJson(TruckWeightLimitSyncService.me.delete(truck_license, tokenuser));
|
renderJson(TruckWeightLimitSyncService.me.delete(truck_license, tokenuser));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 恢复
|
||||||
|
*/
|
||||||
|
@Before(TruckWeightLimitPKValidator.class)
|
||||||
|
public void restore() {
|
||||||
|
Sysuser tokenuser = SysuserSyncService.me.getSysuserByToken(get("token"));
|
||||||
|
|
||||||
|
if (tokenuser == null) {
|
||||||
|
renderJson(Result.noauth());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
TruckWeightLimit model = getModel(TruckWeightLimit.class, "", true); // 忽略不在model中的字段
|
||||||
|
renderJson(TruckWeightLimitSyncService.me.restore(model, tokenuser));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 分页查找 truck_weight_limit
|
* 分页查找 truck_weight_limit
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,12 @@
|
||||||
package com.cowr.local.ssjygl.truck.truckweightlimit;
|
package com.cowr.local.ssjygl.truck.truckweightlimit;
|
||||||
|
|
||||||
import com.cowr.common.Const;
|
import com.cowr.common.Const;
|
||||||
import com.cowr.common.base.BaseModel;
|
|
||||||
import com.cowr.common.enums.Enums;
|
import com.cowr.common.enums.Enums;
|
||||||
import com.cowr.common.view.PageParam;
|
import com.cowr.common.view.PageParam;
|
||||||
import com.cowr.common.view.Result;
|
import com.cowr.common.view.Result;
|
||||||
import com.cowr.local.ssjygl.base.BaseSyncService;
|
import com.cowr.local.ssjygl.base.BaseSyncService;
|
||||||
import com.cowr.local.ssjygl.synctask.SyncTaskService;
|
import com.cowr.local.ssjygl.synctask.SyncTaskService;
|
||||||
import com.cowr.model.SyncTask;
|
import com.cowr.model.*;
|
||||||
import com.cowr.model.Sysuser;
|
|
||||||
import com.cowr.model.TruckWeightLimit;
|
|
||||||
import com.cowr.model.TruckWeightLimitModifyLog;
|
|
||||||
import com.cowr.ssjygl.modifylog.ModifyLogService;
|
import com.cowr.ssjygl.modifylog.ModifyLogService;
|
||||||
import com.jfinal.kit.StrKit;
|
import com.jfinal.kit.StrKit;
|
||||||
import com.jfinal.log.Log;
|
import com.jfinal.log.Log;
|
||||||
|
|
@ -36,7 +32,7 @@ public class TruckWeightLimitSyncService extends BaseSyncService {
|
||||||
if (obj.getDel() == Const.LOGIC_DEL_VALID) {
|
if (obj.getDel() == Const.LOGIC_DEL_VALID) {
|
||||||
return Result.failedstr("车牌 %s 限重值已设置", model.getTruckLicense());
|
return Result.failedstr("车牌 %s 限重值已设置", model.getTruckLicense());
|
||||||
} else if(obj.getDel() == Const.LOGIC_DEL_INVALID) {
|
} else if(obj.getDel() == Const.LOGIC_DEL_INVALID) {
|
||||||
return Result.failedstr("车牌 %s 已删除请恢复", model.getTruckLicense());
|
return Result.failedstr("车牌 %s 已删除请恢复后修改限重", model.getTruckLicense());
|
||||||
} else {
|
} else {
|
||||||
return Result.failedstr("车牌 %s 逻辑字段错误", model.getTruckLicense());
|
return Result.failedstr("车牌 %s 逻辑字段错误", model.getTruckLicense());
|
||||||
}
|
}
|
||||||
|
|
@ -162,7 +158,7 @@ public class TruckWeightLimitSyncService extends BaseSyncService {
|
||||||
@Override
|
@Override
|
||||||
public boolean run() {
|
public boolean run() {
|
||||||
try {
|
try {
|
||||||
List<TruckWeightLimitModifyLog> modifyLogList = TruckWeightLimitModifyLog.dao.find("select * from truck_weight_limit_modify_log where truck_license = ?", truck_license);
|
List<TruckWeightLimitModifyLog> modifyLogList = TruckWeightLimitModifyLog.dao.find("select * from truck_weight_limit_modify_log where state != 3 and truck_license = ?", truck_license);
|
||||||
if (modifyLogList.size() > 0) {
|
if (modifyLogList.size() > 0) {
|
||||||
List<TruckWeightLimitModifyLog> mdList = new ArrayList<>();
|
List<TruckWeightLimitModifyLog> mdList = new ArrayList<>();
|
||||||
for (TruckWeightLimitModifyLog md : modifyLogList) {
|
for (TruckWeightLimitModifyLog md : modifyLogList) {
|
||||||
|
|
@ -171,9 +167,9 @@ public class TruckWeightLimitSyncService extends BaseSyncService {
|
||||||
tlm.setWeightLimit(md.getWeightLimit());
|
tlm.setWeightLimit(md.getWeightLimit());
|
||||||
tlm.setAttachment(md.getAttachment());
|
tlm.setAttachment(md.getAttachment());
|
||||||
tlm.setState(3);
|
tlm.setState(3);
|
||||||
tlm.setChangeUserName(md.getChangeUserName());
|
tlm.setChangeUserName(sysuser.getName());
|
||||||
tlm.setChangeUserId(md.getChangeUserId());
|
tlm.setChangeUserId(sysuser.getId());
|
||||||
tlm.setChangeTime(md.getChangeTime());
|
tlm.setChangeTime(new Date());
|
||||||
mdList.add(tlm);
|
mdList.add(tlm);
|
||||||
}
|
}
|
||||||
int[] ret = Db.batchSave(mdList, mdList.size());
|
int[] ret = Db.batchSave(mdList, mdList.size());
|
||||||
|
|
@ -215,6 +211,48 @@ public class TruckWeightLimitSyncService extends BaseSyncService {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public Result restore(TruckWeightLimit model, Sysuser sysuser) {
|
||||||
|
try {
|
||||||
|
// 注意这里有 !,找到后才做 update 操作
|
||||||
|
TruckWeightLimit oldobj = model.findByPk();
|
||||||
|
|
||||||
|
if (oldobj == null) {
|
||||||
|
return Result.failed(false, "按主键未找到对应记录");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!model.hasDelKey()) {
|
||||||
|
return Result.failed(false, "不存在逻辑删除字段");
|
||||||
|
}
|
||||||
|
|
||||||
|
oldobj.set(Const.LOGIC_DEL_KEY, Const.LOGIC_DEL_VALID); // 逻辑删除字段统一用 del
|
||||||
|
|
||||||
|
SyncTask synctask = new SyncTask();
|
||||||
|
|
||||||
|
boolean ret = Db.tx(new IAtom() {
|
||||||
|
@Override
|
||||||
|
public boolean run() {
|
||||||
|
try {
|
||||||
|
boolean ret = oldobj.update();
|
||||||
|
if (!ret) return false;
|
||||||
|
|
||||||
|
synctask.addUpdateData(oldobj);
|
||||||
|
|
||||||
|
return SyncTaskService.me.save(synctask)
|
||||||
|
&& ModifyLogService.me.save(model, oldobj, Enums.DataOpType.UPDATE.getId(), sysuser);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.getMessage(), e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return ret ? Result.object(oldobj) : Result.failed(false, "恢复失败");
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.getMessage(), e);
|
||||||
|
return Result.failed(false, "恢复失败");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public Page<Record> find(PageParam pp, String truck_license, String stm, String etm, Integer del) {
|
public Page<Record> find(PageParam pp, String truck_license, String stm, String etm, Integer del) {
|
||||||
String selectsql = "select * ";
|
String selectsql = "select * ";
|
||||||
String fromsql = "from truck_weight_limit t where 1=1 ";
|
String fromsql = "from truck_weight_limit t where 1=1 ";
|
||||||
|
|
|
||||||
|
|
@ -129,4 +129,11 @@ public class ProductController extends Controller {
|
||||||
public void list() {
|
public void list() {
|
||||||
renderJson(Result.object(ProductService.me.list()));
|
renderJson(Result.object(ProductService.me.list()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void getUnitPrice() {
|
||||||
|
Integer product_id =getInt("product_id");
|
||||||
|
Integer supermarket_id =getInt("supermarket_id");
|
||||||
|
renderJson(Result.object(ProductService.me.getUnitPrice(product_id,supermarket_id)));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue