车辆限重添加逻辑删除字段-1
parent
a5a072b0bd
commit
7bbc73a5eb
|
|
@ -175,4 +175,26 @@ public abstract class BaseTruckWeightLimit<M extends BaseTruckWeightLimit<M>> ex
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* name: del
|
||||||
|
* type: INT(1)
|
||||||
|
* isNullable: NO
|
||||||
|
* isPrimaryKey: NO
|
||||||
|
* defaultValue: 0
|
||||||
|
* @param del
|
||||||
|
*/
|
||||||
|
@JSONField(name="del")
|
||||||
|
public void setDel(Integer del) {
|
||||||
|
set("del", del);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return del
|
||||||
|
*/
|
||||||
|
@JSONField(name="del")
|
||||||
|
public Integer getDel() {
|
||||||
|
return getInt("del");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -87,8 +87,9 @@ public class TruckWeightLimitController extends Controller {
|
||||||
String truck_license = get("truck_license");
|
String truck_license = get("truck_license");
|
||||||
String stm = get("stm");
|
String stm = get("stm");
|
||||||
String etm = get("etm");
|
String etm = get("etm");
|
||||||
|
Integer del = getInt("del");
|
||||||
|
|
||||||
renderJson(Result.object(TruckWeightLimitSyncService.me.find(pp, truck_license, stm, etm)));
|
renderJson(Result.object(TruckWeightLimitSyncService.me.find(pp, truck_license, stm, etm, del)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
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;
|
||||||
|
|
@ -32,7 +33,13 @@ public class TruckWeightLimitSyncService extends BaseSyncService {
|
||||||
TruckWeightLimit obj = model.findByPk();
|
TruckWeightLimit obj = model.findByPk();
|
||||||
|
|
||||||
if (obj != null) {
|
if (obj != null) {
|
||||||
|
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) {
|
||||||
|
return Result.failedstr("车牌 %s 已删除请恢复", model.getTruckLicense());
|
||||||
|
} else {
|
||||||
|
return Result.failedstr("车牌 %s 逻辑字段错误", model.getTruckLicense());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
model.setCreateUserId(sysuser.getId());
|
model.setCreateUserId(sysuser.getId());
|
||||||
|
|
@ -143,6 +150,13 @@ public class TruckWeightLimitSyncService extends BaseSyncService {
|
||||||
return Result.failed(false, "按主键未找到对应记录");
|
return Result.failed(false, "按主键未找到对应记录");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!model.hasDelKey()) {
|
||||||
|
return Result.failed(false, "不存在逻辑删除字段");
|
||||||
|
}
|
||||||
|
|
||||||
|
TruckWeightLimit oldobj = model.clone();
|
||||||
|
oldobj.set(Const.LOGIC_DEL_KEY, Const.LOGIC_DEL_INVALID); // 逻辑删除字段统一用 del
|
||||||
|
|
||||||
SyncTask synctask = new SyncTask();
|
SyncTask synctask = new SyncTask();
|
||||||
boolean ret = Db.tx(new IAtom() {
|
boolean ret = Db.tx(new IAtom() {
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -150,8 +164,19 @@ public class TruckWeightLimitSyncService extends BaseSyncService {
|
||||||
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 truck_license = ?", truck_license);
|
||||||
if (modifyLogList.size() > 0) {
|
if (modifyLogList.size() > 0) {
|
||||||
modifyLogList.stream().forEach(s -> s.setState(3));
|
List<TruckWeightLimitModifyLog> mdList = new ArrayList<>();
|
||||||
int[] ret = Db.batchUpdate(modifyLogList, modifyLogList.size());
|
for (TruckWeightLimitModifyLog md : modifyLogList) {
|
||||||
|
TruckWeightLimitModifyLog tlm = new TruckWeightLimitModifyLog();
|
||||||
|
tlm.setTruckLicense(md.getTruckLicense());
|
||||||
|
tlm.setWeightLimit(md.getWeightLimit());
|
||||||
|
tlm.setAttachment(md.getAttachment());
|
||||||
|
tlm.setState(3);
|
||||||
|
tlm.setChangeUserName(md.getChangeUserName());
|
||||||
|
tlm.setChangeUserId(md.getChangeUserId());
|
||||||
|
tlm.setChangeTime(md.getChangeTime());
|
||||||
|
mdList.add(tlm);
|
||||||
|
}
|
||||||
|
int[] ret = Db.batchSave(mdList, mdList.size());
|
||||||
|
|
||||||
// 没有的记录更新影响的行数应该是 0
|
// 没有的记录更新影响的行数应该是 0
|
||||||
if (ret.length != modifyLogList.size()) {
|
if (ret.length != modifyLogList.size()) {
|
||||||
|
|
@ -165,16 +190,16 @@ public class TruckWeightLimitSyncService extends BaseSyncService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
modifyLogList.stream().forEach(s -> synctask.addUpdateData(s));
|
modifyLogList.stream().forEach(s -> synctask.addSaveData(s));
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean ret = model.delete();
|
boolean ret = oldobj.update();
|
||||||
if (!ret) return false;
|
if (!ret) return false;
|
||||||
|
|
||||||
synctask.addDeleteData(model);
|
synctask.addUpdateData(oldobj);
|
||||||
|
|
||||||
return SyncTaskService.me.save(synctask)
|
return SyncTaskService.me.save(synctask)
|
||||||
&& ModifyLogService.me.save(model, model.findByPk(), Enums.DataOpType.DELETE.getId(), sysuser);
|
&& ModifyLogService.me.save(model, oldobj, Enums.DataOpType.UPDATE.getId(), sysuser);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error(e.getMessage(), e);
|
log.error(e.getMessage(), e);
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -186,14 +211,22 @@ public class TruckWeightLimitSyncService extends BaseSyncService {
|
||||||
SyncTaskService.me.send(synctask);
|
SyncTaskService.me.send(synctask);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret ? Result.object(true) : Result.failed(false, "删除失败");
|
return ret ? Result.object(oldobj) : Result.failed(false, "删除失败");
|
||||||
}
|
}
|
||||||
|
|
||||||
public Page<Record> find(PageParam pp, String truck_license, String stm, String etm) {
|
|
||||||
|
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 ";
|
||||||
List<Object> paraList = new ArrayList<>();
|
List<Object> paraList = new ArrayList<>();
|
||||||
|
|
||||||
|
if (del == null) {
|
||||||
|
fromsql += " and t.del = 0 \n";
|
||||||
|
} else if (del == Const.LOGIC_DEL_VALID || del == Const.LOGIC_DEL_INVALID) {
|
||||||
|
fromsql += " and t.del = ? \n";
|
||||||
|
paraList.add(del);
|
||||||
|
}
|
||||||
|
|
||||||
if (StrKit.notBlank(truck_license)) {
|
if (StrKit.notBlank(truck_license)) {
|
||||||
fromsql += " and t.truck_license like ? \n";
|
fromsql += " and t.truck_license like ? \n";
|
||||||
paraList.add("%" + truck_license.trim() + "%");
|
paraList.add("%" + truck_license.trim() + "%");
|
||||||
|
|
|
||||||
|
|
@ -69,11 +69,6 @@ public class OrderclusterSyncService extends BaseSyncService {
|
||||||
return Result.failed("不是预付费用户");
|
return Result.failed("不是预付费用户");
|
||||||
}
|
}
|
||||||
|
|
||||||
Product product = Product.dao.findById(Const.DEFAULT_PRODUCT_ID);
|
|
||||||
if (product == null) {
|
|
||||||
return Result.failedstr("商品信息配置错误");
|
|
||||||
}
|
|
||||||
|
|
||||||
List<Ordercluster> newlist = new ArrayList<>();
|
List<Ordercluster> newlist = new ArrayList<>();
|
||||||
Map<Integer, SyncTask> syncmap = new HashMap<>();
|
Map<Integer, SyncTask> syncmap = new HashMap<>();
|
||||||
List<Integer> chksup = new ArrayList<>();
|
List<Integer> chksup = new ArrayList<>();
|
||||||
|
|
@ -85,6 +80,7 @@ public class OrderclusterSyncService extends BaseSyncService {
|
||||||
int time_interval = obj.getIntValue("time_interval");
|
int time_interval = obj.getIntValue("time_interval");
|
||||||
int mini_truck = obj.getIntValue("mini_truck");
|
int mini_truck = obj.getIntValue("mini_truck");
|
||||||
int max_truck = obj.getIntValue("max_truck");
|
int max_truck = obj.getIntValue("max_truck");
|
||||||
|
int product_id = obj.getIntValue("product_id");
|
||||||
double total_weight = obj.getDouble("total_weight");
|
double total_weight = obj.getDouble("total_weight");
|
||||||
|
|
||||||
Supermarket supermarket = SvrCacheData.SUP_CACHE.get(supermarket_id);
|
Supermarket supermarket = SvrCacheData.SUP_CACHE.get(supermarket_id);
|
||||||
|
|
@ -118,6 +114,11 @@ public class OrderclusterSyncService extends BaseSyncService {
|
||||||
return Result.failed("最低运输车辆不能超过最高运输车辆数错误");
|
return Result.failed("最低运输车辆不能超过最高运输车辆数错误");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Product product = Product.dao.findById(product_id);
|
||||||
|
if (product == null) {
|
||||||
|
return Result.failedstr("商品信息配置错误");
|
||||||
|
}
|
||||||
|
|
||||||
if (total_weight == 0) {
|
if (total_weight == 0) {
|
||||||
log.debug("重量为 0 的砂站(id:%s)跳过", supermarket_id);
|
log.debug("重量为 0 的砂站(id:%s)跳过", supermarket_id);
|
||||||
continue;
|
continue;
|
||||||
|
|
@ -308,8 +309,8 @@ public class OrderclusterSyncService extends BaseSyncService {
|
||||||
"select * from ordercluster_truck t \n" +
|
"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.state < 5 \n" + // OrderStateEnum.RECEIVED.getStateid()
|
" where c.state < 5 \n" + // OrderStateEnum.RECEIVED.getStateid()
|
||||||
" and t.start_time <= ? \n" +
|
" and c.start_time <= ? \n" +
|
||||||
" and t.cutoff_time >= ? \n" +
|
" and c.cutoff_time >= ? \n" +
|
||||||
" and t.truck_license in (" + StrKit.join(tsql, ",") + ")", ts.toArray());
|
" and t.truck_license in (" + StrKit.join(tsql, ",") + ")", ts.toArray());
|
||||||
|
|
||||||
if (chkduk != null && !chkduk.isEmpty()) {
|
if (chkduk != null && !chkduk.isEmpty()) {
|
||||||
|
|
|
||||||
|
|
@ -86,8 +86,8 @@ public class OrderclusterTruckSyncService extends BaseSyncService {
|
||||||
" left join ordercluster o on o.id = t.ordercluster_id\n" +
|
" left join ordercluster o on o.id = t.ordercluster_id\n" +
|
||||||
" where t.ordercluster_id <> ? \n" +
|
" where t.ordercluster_id <> ? \n" +
|
||||||
" and o.state < 5 \n" +
|
" and o.state < 5 \n" +
|
||||||
" and t.start_time <= ? \n" +
|
" and o.start_time <= ? \n" +
|
||||||
" and t.cutoff_time >= ? \n" +
|
" and o.cutoff_time >= ? \n" +
|
||||||
" and t.truck_license in (" + StrKit.join(tsql, ",") + ")", ts.toArray());
|
" and t.truck_license in (" + StrKit.join(tsql, ",") + ")", ts.toArray());
|
||||||
|
|
||||||
if (chkduk != null && !chkduk.isEmpty()) {
|
if (chkduk != null && !chkduk.isEmpty()) {
|
||||||
|
|
|
||||||
|
|
@ -37,8 +37,9 @@ public class TruckWeightLimitController extends Controller {
|
||||||
String truck_license = get("truck_license");
|
String truck_license = get("truck_license");
|
||||||
String stm = get("stm");
|
String stm = get("stm");
|
||||||
String etm = get("etm");
|
String etm = get("etm");
|
||||||
|
Integer del = getInt("del");
|
||||||
|
|
||||||
renderJson(Result.object(TruckWeightLimitService.me.find(pp, truck_license, stm, etm)));
|
renderJson(Result.object(TruckWeightLimitService.me.find(pp, truck_license, stm, etm, del)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -18,11 +18,18 @@ public class TruckWeightLimitService extends BaseService {
|
||||||
private static final Log log = Log.getLog(TruckWeightLimitService.class);
|
private static final Log log = Log.getLog(TruckWeightLimitService.class);
|
||||||
public static final TruckWeightLimitService me = new TruckWeightLimitService();
|
public static final TruckWeightLimitService me = new TruckWeightLimitService();
|
||||||
|
|
||||||
public Page<Record> find(PageParam pp, String truck_license, String stm, String etm) {
|
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 ";
|
||||||
List<Object> paraList = new ArrayList<>();
|
List<Object> paraList = new ArrayList<>();
|
||||||
|
|
||||||
|
if (del == null) {
|
||||||
|
fromsql += " and t.del = 0 \n";
|
||||||
|
} else if (del == Const.LOGIC_DEL_VALID || del == Const.LOGIC_DEL_INVALID) {
|
||||||
|
fromsql += " and t.del = ? \n";
|
||||||
|
paraList.add(del);
|
||||||
|
}
|
||||||
|
|
||||||
if (StrKit.notBlank(truck_license)) {
|
if (StrKit.notBlank(truck_license)) {
|
||||||
fromsql += " and t.truck_license like ? \n";
|
fromsql += " and t.truck_license like ? \n";
|
||||||
paraList.add("%" + truck_license.trim() + "%");
|
paraList.add("%" + truck_license.trim() + "%");
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue