dev
parent
8e73b1bb4a
commit
04f482c4da
|
|
@ -73,17 +73,20 @@ public class OrderclusterTruckSyncService extends BaseSyncService {
|
||||||
ts.add(0, ordercluster_id + ""); // 加到查询参数里面
|
ts.add(0, ordercluster_id + ""); // 加到查询参数里面
|
||||||
List<OrderclusterTruck> otlist = OrderclusterTruck.dao.find(
|
List<OrderclusterTruck> otlist = OrderclusterTruck.dao.find(
|
||||||
"select * from ordercluster_truck \n" +
|
"select * from ordercluster_truck \n" +
|
||||||
" where ordercluster_id = ? \n" +
|
" where ordercluster_id = ? \n", ordercluster_id);
|
||||||
" and truck_license in (" + StrKit.join(tsql, ",") + ")", ts.toArray());
|
|
||||||
|
|
||||||
if (otlist != null && !otlist.isEmpty()) {
|
List<String> dellist = new ArrayList<>();
|
||||||
ts = new ArrayList<>();
|
List<String> chkold = new ArrayList<>();
|
||||||
|
SyncTask synctask = new SyncTask();
|
||||||
|
|
||||||
for (OrderclusterTruck bl : otlist) {
|
for (OrderclusterTruck ot : otlist) {
|
||||||
ts.add(bl.getTruckLicense());
|
if(!chk.contains(ot.getTruckLicense())){
|
||||||
|
// 数据库中,提交上的数据中没有的,要删掉
|
||||||
|
dellist.add(ot.getTruckLicense());
|
||||||
|
synctask.addDeleteData(ot);
|
||||||
|
}else{
|
||||||
|
chkold.add(ot.getTruckLicense());
|
||||||
}
|
}
|
||||||
|
|
||||||
return Result.failed(StrKit.join(ts, ",") + " 车牌号已分配");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
List<OrderclusterTruck> oldot = OrderclusterTruck.dao.find("select * from ordercluster_truck where ordercluster_id = ? ", ordercluster_id);
|
List<OrderclusterTruck> oldot = OrderclusterTruck.dao.find("select * from ordercluster_truck where ordercluster_id = ? ", ordercluster_id);
|
||||||
|
|
@ -93,9 +96,13 @@ public class OrderclusterTruckSyncService extends BaseSyncService {
|
||||||
}
|
}
|
||||||
|
|
||||||
List<OrderclusterTruck> savelist = new ArrayList<>();
|
List<OrderclusterTruck> savelist = new ArrayList<>();
|
||||||
SyncTask synctask = new SyncTask();
|
|
||||||
|
|
||||||
for (String truck_license : truckarr) {
|
for (String truck_license : truckarr) {
|
||||||
|
// 已经在数据库中的,不再重复添加
|
||||||
|
if(chkold.contains(truck_license)){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
OrderclusterTruck oct = new OrderclusterTruck();
|
OrderclusterTruck oct = new OrderclusterTruck();
|
||||||
oct.setId(StrKit.getRandomUUID());
|
oct.setId(StrKit.getRandomUUID());
|
||||||
oct.setOrderclusterId(ordercluster_id);
|
oct.setOrderclusterId(ordercluster_id);
|
||||||
|
|
@ -105,8 +112,8 @@ public class OrderclusterTruckSyncService extends BaseSyncService {
|
||||||
savelist.add(oct);
|
savelist.add(oct);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (savelist.isEmpty()) {
|
if(savelist.isEmpty() && dellist.isEmpty()){
|
||||||
return Result.failed("truck_license 参数错误");
|
return Result.failed("trucks 参数错误");
|
||||||
}
|
}
|
||||||
|
|
||||||
Record logrecord = new Record();
|
Record logrecord = new Record();
|
||||||
|
|
@ -116,6 +123,14 @@ public class OrderclusterTruckSyncService extends BaseSyncService {
|
||||||
boolean ret = Db.tx(new IAtom() {
|
boolean ret = Db.tx(new IAtom() {
|
||||||
@Override
|
@Override
|
||||||
public boolean run() {
|
public boolean run() {
|
||||||
|
if (!dellist.isEmpty()) {
|
||||||
|
int delret = Db.delete("delete from ordercluster_truck where ordercluster_id = " + ordercluster_id +
|
||||||
|
" and truck_license in ('" + StrKit.join(dellist, "','") + "')");
|
||||||
|
|
||||||
|
log.debug("删除 ordercluster_truck %d", delret);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!savelist.isEmpty()) {
|
||||||
int[] ret = Db.batchSave(savelist, savelist.size());
|
int[] ret = Db.batchSave(savelist, savelist.size());
|
||||||
|
|
||||||
for (int i : ret) {
|
for (int i : ret) {
|
||||||
|
|
@ -124,6 +139,7 @@ public class OrderclusterTruckSyncService extends BaseSyncService {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return SyncTaskService.me.save(synctask, ordercluster.getSupermarketId())
|
return SyncTaskService.me.save(synctask, ordercluster.getSupermarketId())
|
||||||
&& ModifyLogService.me.save(OrderclusterTruck.tablename, "id", logrecord.toJson(), Enums.DataOpType.SAVE.getId(), sysuser);
|
&& ModifyLogService.me.save(OrderclusterTruck.tablename, "id", logrecord.toJson(), Enums.DataOpType.SAVE.getId(), sysuser);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue