转运单结算保存结算单号;运输日志修改

dev
wany 2025-03-12 16:10:04 +08:00
parent 69e5619c30
commit 8c019d3b40
9 changed files with 242 additions and 10 deletions

View File

@ -700,4 +700,26 @@ public abstract class BaseOrderTransfer<M extends BaseOrderTransfer<M>> extends
return getStr("old_sn"); return getStr("old_sn");
} }
/**
* name: ticket_code
* type: VARCHAR(20)
* isNullable: YES
* isPrimaryKey: NO
* defaultValue:
* @param ticketCode
*/
@JSONField(name="ticket_code")
public void setTicketCode(String ticketCode) {
set("ticket_code", ticketCode);
}
/**
* @return ticket_code
*/
@JSONField(name="ticket_code")
public String getTicketCode() {
return getStr("ticket_code");
}
} }

View File

@ -101,13 +101,12 @@ public class OrderTempService extends BaseService {
Integer product_id, Integer product_id,
Boolean invoice_code_is_null Boolean invoice_code_is_null
) { ) {
String selectsql = "select t.* " + String selectsql = "select t.* ,t.sn as old_sn" +
", p.order_sn \n" +
", p.in_time, p.out_time, p.in_which, p.out_which, p.in_mode, p.out_mode \n" + ", p.in_time, p.out_time, p.in_which, p.out_which, p.in_mode, p.out_mode \n" +
", p.first_weight, p.second_weight, p.first_weigh_mode, p.second_weight_mode \n" + ", p.first_weight, p.second_weight, p.first_weigh_mode, p.second_weight_mode \n" +
", p.first_pic, p.first_weight_which, p.second_weight_which, p.second_pic \n" + ", p.first_pic, p.first_weight_which, p.second_weight_which, p.second_pic \n" +
", p.arrive_time, p.type, p.memo transport_memo, s.name supermarket_name \n" + ", p.arrive_time, p.type, p.memo transport_memo, s.name supermarket_name \n" +
", ot.sn in_sn, ot.trans_price in_trans_price, ot.weight in_weight \n"; ", ot.trans_price in_trans_price, ot.weight in_weight \n";
String fromsql = "from order_temp t \n" + String fromsql = "from order_temp t \n" +
" left join transport p on p.order_sn = t.sn \n" + " left join transport p on p.order_sn = t.sn \n" +
" left join supermarket s on s.id = t.supermarket_id \n" + " left join supermarket s on s.id = t.supermarket_id \n" +
@ -118,13 +117,12 @@ public class OrderTempService extends BaseService {
if (supermarket_type != null && supermarket_type == 1) { if (supermarket_type != null && supermarket_type == 1) {
selectsql = "select t.* " + selectsql = "select t.* " +
", p.order_sn \n" +
", p.in_time, p.out_time, p.in_which, p.out_which, p.in_mode, p.out_mode \n" + ", p.in_time, p.out_time, p.in_which, p.out_which, p.in_mode, p.out_mode \n" +
", p.first_weight, p.second_weight, p.first_weigh_mode, p.second_weight_mode \n" + ", p.first_weight, p.second_weight, p.first_weigh_mode, p.second_weight_mode \n" +
", p.first_pic, p.first_weight_which, p.second_weight_which, p.second_pic \n" + ", p.first_pic, p.first_weight_which, p.second_weight_which, p.second_pic \n" +
", p.arrive_time, p.type, p.memo transport_memo, s.name supermarket_name \n" + ", p.arrive_time, p.type, p.memo transport_memo, s.name supermarket_name \n" +
", s1.name customer_name \n" + ", s1.name customer_name \n" +
", t.sn in_sn, t.trans_price in_trans_price, t.weight in_weight \n"; ", t.trans_price in_trans_price, t.weight in_weight,ot.ticket_code as old_ticket_code \n";
fromsql = "from order_transfer t \n" + fromsql = "from order_transfer t \n" +
" left join transport p on p.order_sn = t.sn \n" + " left join transport p on p.order_sn = t.sn \n" +
" left join supermarket s on s.id = t.sandfarm_id \n" + " left join supermarket s on s.id = t.sandfarm_id \n" +

View File

@ -673,6 +673,7 @@ public class OrderStatService {
" ) t ON s.id = t.sandfarm_id \n" + " ) t ON s.id = t.sandfarm_id \n" +
"WHERE\n" + "WHERE\n" +
" s.type = 1 \n" + " s.type = 1 \n" +
" and s.isdeploy = 1 \n" +
"GROUP BY\n" + "GROUP BY\n" +
" s.id \n" + " s.id \n" +
"ORDER BY\n" + "ORDER BY\n" +

View File

@ -92,7 +92,7 @@ public class SupermarketSandfarmDistanceService extends BaseService {
" from supermarket_sandfarm_distance a\n" + " from supermarket_sandfarm_distance a\n" +
" group by a.sandfarm_id\n" + " group by a.sandfarm_id\n" +
" ) sr on sr.sandfarm_id = t.id \n" + " ) sr on sr.sandfarm_id = t.id \n" +
" where 1=1 AND t.TYPE = 1 "; " where 1=1 AND t.TYPE = 1 and t.isdeploy = 1";
List<Object> paraList = new ArrayList<>(); List<Object> paraList = new ArrayList<>();
if (customer_id != null) { if (customer_id != null) {

View File

@ -55,8 +55,8 @@ public class OrderTransferController extends BaseController {
Integer product_id = getInt("product_id",1); Integer product_id = getInt("product_id",1);
String printer = get("printer", Enums.PrinterIdEnum.printer1.name()); String printer = get("printer", Enums.PrinterIdEnum.printer1.name());
Double source_weight = getParaToDouble("source_weight"); Double source_weight = getParaToDouble("source_weight");
String ticket_code = get("ticket_code");
renderJson(OrderTransferSyncService.me.pay(uuid, transport_id, old_sn, product_id, printer, source_weight, tokenuser)); renderJson(OrderTransferSyncService.me.pay(uuid, transport_id, old_sn, product_id, printer, source_weight, tokenuser, ticket_code));
} }
/** /**

View File

@ -11,7 +11,10 @@ import com.cowr.local.ssjygl.synctask.SyncTaskService;
import com.cowr.local.ssjygl.system.sysuser.SysuserSyncService; import com.cowr.local.ssjygl.system.sysuser.SysuserSyncService;
import com.cowr.model.*; import com.cowr.model.*;
import com.cowr.ssjygl.supermarket.sandfarmdistance.SupermarketSandfarmDistanceService; import com.cowr.ssjygl.supermarket.sandfarmdistance.SupermarketSandfarmDistanceService;
import com.cowr.ssjygl.ticket.log.TicketLogService;
import com.cowr.ssjygl.ticket.receive.TicketReceiveService;
import com.cowr.ssjygl.transprice.TransPriceService; import com.cowr.ssjygl.transprice.TransPriceService;
import com.jfinal.kit.StrKit;
import com.jfinal.log.Log; import com.jfinal.log.Log;
import com.jfinal.plugin.activerecord.Db; import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.IAtom; import com.jfinal.plugin.activerecord.IAtom;
@ -28,7 +31,6 @@ public class OrderTransferSyncService {
/** /**
* @param uuid * @param uuid
* @param transport_id id * @param transport_id id
* @param sandfarm_id id
* @param product_id id * @param product_id id
* @param printerId id * @param printerId id
* @param source_weight * @param source_weight
@ -42,7 +44,8 @@ public class OrderTransferSyncService {
Integer product_id, Integer product_id,
String printerId, String printerId,
Double source_weight, Double source_weight,
Sysuser sysuser Sysuser sysuser,
String ticket_code
) { ) {
Transport transport = Transport.dao.findById(transport_id); Transport transport = Transport.dao.findById(transport_id);
if (transport == null) { if (transport == null) {
@ -113,6 +116,20 @@ public class OrderTransferSyncService {
order.setSourceWeight(new BigDecimal(source_weight)); order.setSourceWeight(new BigDecimal(source_weight));
} }
TicketReceive ticketReceive = TicketReceiveService.me.checkSurplusReceive(transport.getSupermarketId(), ticket_code);
if (ticketReceive == null) {
return Result.failed("没有有效的结算单领用记录,或者结算单已经被使用");
}
TicketLog ticketLog = TicketLogService.me.checkUseTicketLog(ticket_code);
if (ticketLog != null) {
return Result.failedstr("结算单 %s 已使用", ticket_code);
}
ticketReceive.setSurplus(ticketReceive.getSurplus() - 1);
ticketReceive.setCurrentCode(ticket_code);
order.setTicketCode(ticket_code);
order.setTransportId(transport.getId()); order.setTransportId(transport.getId());
order.setSupermarketId(transport.getSupermarketId()); order.setSupermarketId(transport.getSupermarketId());
order.setTruckLicense(transport.getTruckLicense()); order.setTruckLicense(transport.getTruckLicense());
@ -159,6 +176,8 @@ public class OrderTransferSyncService {
transport.setArriveTime(now); transport.setArriveTime(now);
transport.setType(OrderTypeEnum.TRANSFER.getTypeid()); transport.setType(OrderTypeEnum.TRANSFER.getTypeid());
TicketReceive finalTicketReceive = ticketReceive;
boolean ret = Db.tx(new IAtom() { boolean ret = Db.tx(new IAtom() {
@Override @Override
public boolean run() { public boolean run() {
@ -191,6 +210,33 @@ public class OrderTransferSyncService {
return false; return false;
} }
ret = finalTicketReceive.update();
if (!ret) {
log.error("结算单领用信息更新失败", ticket_code);
return false;
}
TicketLog ticketLog = new TicketLog();
ticketLog.setId(StrKit.getRandomUUID());
ticketLog.setTicketReceiveId(finalTicketReceive.getId());
ticketLog.setTicketCode(ticket_code);
ticketLog.setState(OrderStateEnum.RECEIVED.getStateid());
ticketLog.setSettlementTime(now);
ticketLog.setSettlementUserId(order.getSettlementUserId());
ticketLog.setSettlementUserName(order.getSettlementUserName());
ticketLog.setOrderSn(order.getSn());
ticketLog.setType(OrderTypeEnum.TEMP.getTypeid());
ret = ticketLog.save();
if (!ret) {
return false;
}
synctask.addSaveData(ticketLog);
synctask.addUpdateData(finalTicketReceive);
// 在这里更新sn字段之后存入 // 在这里更新sn字段之后存入
synctask.addSaveData(order); synctask.addSaveData(order);
synctask.addUpdateData(transport); synctask.addUpdateData(transport);

View File

@ -0,0 +1,35 @@
package com.cowr.service.ssjygl.init;
import com.cowr.common.view.Result;
import com.cowr.model.Sysuser;
import com.cowr.service.ssjygl.system.sysuser.SysuserSyncService;
import com.jfinal.core.Controller;
/**
* Description:
* Created by wanyan on 2025/2/20
*
* @author wanyan
* @version 1.0
*/
public class InitDataController extends Controller {
/**
*
*/
public void initData(){
Integer supermarket_id = getInt("supermarket_id");
Integer supermarket_type = getInt("supermarket_type",0);
Sysuser tokenuser = SysuserSyncService.me.getSysuserByToken(get("token"));
if (tokenuser == null) {
renderJson(Result.noauth());
return;
}
renderJson(InitDataSyncService.me.syncData(supermarket_id,supermarket_type));
}
}

View File

@ -0,0 +1,126 @@
package com.cowr.service.ssjygl.init;
import com.alibaba.fastjson.JSONObject;
import com.cowr.model.SyncTask;
import com.cowr.service.ssjygl.base.BaseSyncService;
import com.cowr.service.ssjygl.synctask.SyncTaskService;
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.sql.SQLException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
/**
* Generated by COWR Tue Dec 07 16:33:49 CST 2021
* TableName: product_price_modify
* Remarks:
* PrimaryKey: id
*/
public class InitDataSyncService extends BaseSyncService {
private static final Log log = Log.getLog(InitDataSyncService.class);
public static final InitDataSyncService me = new InitDataSyncService();
public static final String TIAO = "条\n";
private static Map<String, String> tableMap = new HashMap<>();
private static Map<String, String> tableIdMap = new HashMap<>();
static {
tableMap.put("blacklist", "基础配置 - 车辆黑名单");
tableMap.put("customer", "客户相关 - 客户");
tableMap.put("customer_contact", "客户相关 - 客户联系人");
tableMap.put("customer_contract_signed_log", "已签订合同的客户记录");
tableMap.put("customer_contract_template", "合同模板管理-管理客户签订的合同模板");
tableMap.put("customer_discount", "客户相关 - 客户折扣");
tableMap.put("customer_pact", "客户相关 - 签订合同");
tableMap.put("customer_receiver", "客户相关 - 客户收获地址");
tableMap.put("customer_register", "客户相关 - 客户注册");
tableMap.put("customer_supermarket_product", "客户相关 - 特殊客户购买单价");
tableMap.put("customer_type", "客户相关 - 客户分类定义");
tableMap.put("device_config", "出入控制 - 设备连接参数配置");
tableMap.put("driver", "基础配置 - 司机信息");
tableMap.put("prepay_customer", "客户相关 - 预付费客户余额信息,每个客户在每个超市有单独的余额");
tableMap.put("prepay_detail", "客户相关 - 客户预付费");
tableMap.put("presell_order", "预售单管理-创建预售单将客户设定为预售客户");
tableMap.put("product", "基础配置 - 商品信息");
tableMap.put("product_price_modify", "商品单价修改-包括砂站商品单价和客户自定义单价");
tableMap.put("stock", "订单相关 - 销售点库存量");
tableMap.put("stock_modify_log", "订单相关 - 手动修改库存记录");
tableMap.put("supermarket", "基础配置 - 销售点(超市)");
tableMap.put("supermarket_customer_distance", "基础配置 - 超市到客户的距离");
tableMap.put("supermarket_product", "基础配置 - 超市关联 product 表");
tableMap.put("supermarket_receiver_distance", "基础配置 - 客户收获地址到每个超市的距离");
tableMap.put("supermarket_sandfarm_distance", "基础配置 - 生产点到销售点的距离配置");
tableMap.put("supermarket_yield", "基础配置 - 超市计划产量");
tableMap.put("sysuser", "用户管理 - 系统登陆账号");
tableMap.put("trans_price_config_sale", "系统配置 - 销售运费配置信息");
tableMap.put("trans_price_config_transfer", "系统配置 - 转运运费配置信息");
tableMap.put("trans_price_config_trash", "系统配置 - 废料运费配置信息");
tableMap.put("transport_company", "基础配置 - 物流公司");
tableMap.put("truck", "基础配置 - 运输车辆信息");
tableMap.put("truck_weight_limit", "车辆限重管理");
tableIdMap.put("customer_supermarket_product", "customer_id,supermarket_id,product_id");
tableIdMap.put("device_config", "supermarket_id");
tableIdMap.put("stock", "supermarket_id,product_id");
tableIdMap.put("supermarket_customer_distance", "supermarket_id,customer_id");
tableIdMap.put("supermarket_product", "supermarket_id,product_id");
tableIdMap.put("supermarket_receiver_distance", "supermarket_id,customer_receiver_id");
tableIdMap.put("supermarket_sandfarm_distance", "supermarket_id,sandfarm_id");
tableIdMap.put("supermarket_yield", "supermarket_id,year");
tableIdMap.put("truck", "license");
tableIdMap.put("truck_weight_limit", "truck_license");
}
public String syncData(Integer supermarketId,Integer supermarket_type) {
log.info("超市%s开始初始化数据", supermarketId);
StringBuilder str = new StringBuilder();
try {
boolean ret = Db.tx(new IAtom() {
@Override
public boolean run() throws SQLException {
try {
// 需要查询的表名
Set<String> tables = tableMap.keySet();
StringBuilder str = new StringBuilder();
// 遍历每个表,查询数据
for (String table : tables) {
// 查询表中的数据
List<Record> records = Db.find("SELECT * FROM " + table);
JSONObject tableData = new JSONObject();
tableData.put("pks", tableIdMap.containsKey(table) ? tableIdMap.get(table) : "id");
tableData.put("data", records.stream().map(Record::getColumns).collect(Collectors.toList()));
JSONObject saveData = new JSONObject();
saveData.put(table, tableData);
// 创建 sync_task 记录
SyncTask syncTask = new SyncTask();
syncTask.setSupermarketId(supermarketId);
syncTask.setSaveData(saveData.toJSONString());
SyncTaskService.me.save(syncTask, supermarketId);
str.append("同步" + tableMap.get(table) + "数据" + records.size() + TIAO);
}
} catch (Exception e) {
log.error(e.getMessage(), e);
return false;
}
return true;
}
});
return str.toString();
} catch (Exception e) {
log.error(e.getMessage(), e);
return "同步失败";
}
}
}

View File

@ -26,6 +26,7 @@ import com.cowr.service.ssjygl.customer.receiver.CustomerReceiverController;
import com.cowr.service.ssjygl.customer.register.CustomerRegisterController; import com.cowr.service.ssjygl.customer.register.CustomerRegisterController;
import com.cowr.service.ssjygl.customer.supermarketproduct.CustomerSupermarketProductController; import com.cowr.service.ssjygl.customer.supermarketproduct.CustomerSupermarketProductController;
import com.cowr.service.ssjygl.driver.DriverController; import com.cowr.service.ssjygl.driver.DriverController;
import com.cowr.service.ssjygl.init.InitDataController;
import com.cowr.service.ssjygl.invoice.invalidverify.InvoiceInvalidVerifyController; import com.cowr.service.ssjygl.invoice.invalidverify.InvoiceInvalidVerifyController;
import com.cowr.service.ssjygl.invoice.log.InvoiceLogController; import com.cowr.service.ssjygl.invoice.log.InvoiceLogController;
import com.cowr.service.ssjygl.invoice.receive.InvoiceReceiveController; import com.cowr.service.ssjygl.invoice.receive.InvoiceReceiveController;
@ -257,6 +258,9 @@ public class Config extends JFinalConfig {
me.add("/job/sms", StatSmsJob.class); me.add("/job/sms", StatSmsJob.class);
// -- 数据初始化
me.add("/init", InitDataController.class);
} }
@Override @Override