dev
parent
acf1fd9dea
commit
487b31b81a
|
|
@ -17,11 +17,11 @@ public class Const {
|
||||||
public static final String REDIS_CACHENAME = "mian"; // redis 默认 cache 对象别名
|
public static final String REDIS_CACHENAME = "mian"; // redis 默认 cache 对象别名
|
||||||
public static final String REDIS_JSON = "json"; // redis 按 json 存储对象
|
public static final String REDIS_JSON = "json"; // redis 按 json 存储对象
|
||||||
|
|
||||||
public static final String TEMP_CODE_PEIE = "SMS_203717953"; // 配额分配通知
|
public static final String TEMP_CODE_PEIE = "SMS_203673037"; // 配额分配通知
|
||||||
public static Map<String, String> SMS_TEMP_MAP;
|
public static Map<String, String> SMS_TEMP_MAP;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
SMS_TEMP_MAP = new HashMap<>();
|
SMS_TEMP_MAP = new HashMap<>();
|
||||||
SMS_TEMP_MAP.put("SMS_203717953", "已经在${supermarket_name}分配了${weight}吨配额,请在${date}安排车辆前去运输。");
|
SMS_TEMP_MAP.put("SMS_203673037", "已经在${supermarket_name}分配了${weight}吨配额,请在${date}安排车辆前去运输。");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ import com.jfinal.plugin.activerecord.IBean;
|
||||||
import com.alibaba.fastjson.annotation.JSONField;
|
import com.alibaba.fastjson.annotation.JSONField;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generated by COWR Mon Sep 21 13:04:24 CST 2020
|
* Generated by COWR Tue Sep 29 16:17:52 CST 2020
|
||||||
* TableName: invoice_log
|
* TableName: invoice_log
|
||||||
* Remarks: 发票管理 - 发票使用记录
|
* Remarks: 发票管理 - 发票使用记录
|
||||||
* PrimaryKey: id
|
* PrimaryKey: id
|
||||||
|
|
@ -45,7 +45,7 @@ public abstract class BaseInvoiceLog<M extends BaseInvoiceLog<M>> extends BaseMo
|
||||||
/**
|
/**
|
||||||
* name: invoice_receive_id
|
* name: invoice_receive_id
|
||||||
* type: INT(10)
|
* type: INT(10)
|
||||||
* isNullable: NO
|
* isNullable: YES
|
||||||
* isPrimaryKey: NO
|
* isPrimaryKey: NO
|
||||||
* defaultValue:
|
* defaultValue:
|
||||||
* @param invoiceReceiveId 领用记录id
|
* @param invoiceReceiveId 领用记录id
|
||||||
|
|
@ -158,7 +158,7 @@ public abstract class BaseInvoiceLog<M extends BaseInvoiceLog<M>> extends BaseMo
|
||||||
* isNullable: YES
|
* isNullable: YES
|
||||||
* isPrimaryKey: NO
|
* isPrimaryKey: NO
|
||||||
* defaultValue:
|
* defaultValue:
|
||||||
* @param settlementTime 结算时间
|
* @param settlementTime 开票时间
|
||||||
*/
|
*/
|
||||||
@JSONField(name="settlement_time")
|
@JSONField(name="settlement_time")
|
||||||
public void setSettlementTime(java.util.Date settlementTime) {
|
public void setSettlementTime(java.util.Date settlementTime) {
|
||||||
|
|
@ -167,7 +167,7 @@ public abstract class BaseInvoiceLog<M extends BaseInvoiceLog<M>> extends BaseMo
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return settlement_time 结算时间
|
* @return settlement_time 开票时间
|
||||||
*/
|
*/
|
||||||
@JSONField(name="settlement_time")
|
@JSONField(name="settlement_time")
|
||||||
public java.util.Date getSettlementTime() {
|
public java.util.Date getSettlementTime() {
|
||||||
|
|
@ -180,7 +180,7 @@ public abstract class BaseInvoiceLog<M extends BaseInvoiceLog<M>> extends BaseMo
|
||||||
* isNullable: YES
|
* isNullable: YES
|
||||||
* isPrimaryKey: NO
|
* isPrimaryKey: NO
|
||||||
* defaultValue:
|
* defaultValue:
|
||||||
* @param settlementUserId 结算用户id
|
* @param settlementUserId 开票用户id
|
||||||
*/
|
*/
|
||||||
@JSONField(name="settlement_user_id")
|
@JSONField(name="settlement_user_id")
|
||||||
public void setSettlementUserId(Integer settlementUserId) {
|
public void setSettlementUserId(Integer settlementUserId) {
|
||||||
|
|
@ -189,7 +189,7 @@ public abstract class BaseInvoiceLog<M extends BaseInvoiceLog<M>> extends BaseMo
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return settlement_user_id 结算用户id
|
* @return settlement_user_id 开票用户id
|
||||||
*/
|
*/
|
||||||
@JSONField(name="settlement_user_id")
|
@JSONField(name="settlement_user_id")
|
||||||
public Integer getSettlementUserId() {
|
public Integer getSettlementUserId() {
|
||||||
|
|
@ -202,7 +202,7 @@ public abstract class BaseInvoiceLog<M extends BaseInvoiceLog<M>> extends BaseMo
|
||||||
* isNullable: YES
|
* isNullable: YES
|
||||||
* isPrimaryKey: NO
|
* isPrimaryKey: NO
|
||||||
* defaultValue:
|
* defaultValue:
|
||||||
* @param settlementUserName 结算用户姓名
|
* @param settlementUserName 开票用户姓名
|
||||||
*/
|
*/
|
||||||
@JSONField(name="settlement_user_name")
|
@JSONField(name="settlement_user_name")
|
||||||
public void setSettlementUserName(String settlementUserName) {
|
public void setSettlementUserName(String settlementUserName) {
|
||||||
|
|
@ -211,7 +211,7 @@ public abstract class BaseInvoiceLog<M extends BaseInvoiceLog<M>> extends BaseMo
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return settlement_user_name 结算用户姓名
|
* @return settlement_user_name 开票用户姓名
|
||||||
*/
|
*/
|
||||||
@JSONField(name="settlement_user_name")
|
@JSONField(name="settlement_user_name")
|
||||||
public String getSettlementUserName() {
|
public String getSettlementUserName() {
|
||||||
|
|
|
||||||
|
|
@ -93,7 +93,8 @@ public class ActionCmdLogService {
|
||||||
JSONObject obj = JSONObject.parseObject(content);
|
JSONObject obj = JSONObject.parseObject(content);
|
||||||
|
|
||||||
String which = obj.getString("which");
|
String which = obj.getString("which");
|
||||||
record.set("content", "抬" + Enums.WhichEnum.getLabel(which) + (obj.getInteger("num") == 1 ? "前" : "后") + "闸" + (obj.getBoolean("rod") ? "成功" : "失败"));
|
record.set("content", "抬" + Enums.WhichEnum.getLabel(which) + (obj.getInteger("num") == 1 ? "前" : "后") + "闸");
|
||||||
|
record.set("status", obj.getBoolean("rod") ? "成功" : "失败");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error(e.getMessage(), e);
|
log.error(e.getMessage(), e);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -70,7 +70,9 @@ public class OrderTempService extends BaseService {
|
||||||
Integer isprepaid,
|
Integer isprepaid,
|
||||||
Integer state,
|
Integer state,
|
||||||
String invoice_code,
|
String invoice_code,
|
||||||
Integer product_id
|
Integer invoice_type,
|
||||||
|
Integer product_id,
|
||||||
|
Boolean invoice_code_is_null
|
||||||
) {
|
) {
|
||||||
String selectsql = "select t.* " +
|
String selectsql = "select t.* " +
|
||||||
", p.order_sn \n" +
|
", p.order_sn \n" +
|
||||||
|
|
@ -129,16 +131,25 @@ public class OrderTempService extends BaseService {
|
||||||
paraList.add(product_id);
|
paraList.add(product_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(invoice_code_is_null != null && invoice_code_is_null){
|
||||||
|
fromsql += " and t.invoice_code is null \n";
|
||||||
|
}else{
|
||||||
if (StrKit.notBlank(invoice_code)) {
|
if (StrKit.notBlank(invoice_code)) {
|
||||||
fromsql += " and t.invoice_code like ? \n";
|
fromsql += " and t.invoice_code like ? \n";
|
||||||
paraList.add("%" + invoice_code + "%");
|
paraList.add("%" + invoice_code + "%");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (state != null) {
|
if (state != null) {
|
||||||
fromsql += " and t.state = ? \n";
|
fromsql += " and t.state = ? \n";
|
||||||
paraList.add(state);
|
paraList.add(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (invoice_type != null) {
|
||||||
|
fromsql += " and t.invoice_type = ? \n";
|
||||||
|
paraList.add(invoice_type);
|
||||||
|
}
|
||||||
|
|
||||||
String totalRowSql = "select count(*) " + fromsql;
|
String totalRowSql = "select count(*) " + fromsql;
|
||||||
String findSql = selectsql + fromsql;
|
String findSql = selectsql + fromsql;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,13 @@ public abstract class AbsScale extends Device {
|
||||||
socket.connect(new InetSocketAddress(getIp(), getPort()), 5000);
|
socket.connect(new InetSocketAddress(getIp(), getPort()), 5000);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
}catch (Exception e){
|
||||||
|
if(e.getMessage().contains("connect timed out")){
|
||||||
|
log.error("Scale %s %s 连接超时", getId(), getIp());
|
||||||
|
}else{
|
||||||
|
log.error(e.getMessage(), e);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
} finally {
|
} finally {
|
||||||
lock.unlock();
|
lock.unlock();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -33,12 +33,16 @@ public class LEDThread extends Device implements Runnable {
|
||||||
this.license = license;
|
this.license = license;
|
||||||
this.text = text;
|
this.text = text;
|
||||||
this.format = LEDInfoFormat;
|
this.format = LEDInfoFormat;
|
||||||
|
|
||||||
|
screen(); // 更新属性后,马上刷新显示内容
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setWeightInfo(String license, String text) {
|
public void setWeightInfo(String license, String text) {
|
||||||
this.license = license;
|
this.license = license;
|
||||||
this.text = text;
|
this.text = text;
|
||||||
this.format = LEDWeightFormat;
|
this.format = LEDWeightFormat;
|
||||||
|
|
||||||
|
screen(); // 更新属性后,马上刷新显示内容
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final ThreadLocal<SimpleDateFormat> sdf = new ThreadLocal<SimpleDateFormat>() {
|
private static final ThreadLocal<SimpleDateFormat> sdf = new ThreadLocal<SimpleDateFormat>() {
|
||||||
|
|
@ -61,7 +65,7 @@ public class LEDThread extends Device implements Runnable {
|
||||||
this.thread.setDaemon(true);
|
this.thread.setDaemon(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void start(){
|
public void start() {
|
||||||
this.thread.start();
|
this.thread.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -69,14 +73,14 @@ public class LEDThread extends Device implements Runnable {
|
||||||
public void run() {
|
public void run() {
|
||||||
DateFormat df = new SimpleDateFormat("mm.ss");
|
DateFormat df = new SimpleDateFormat("mm.ss");
|
||||||
|
|
||||||
while (this.running){
|
while (this.running) {
|
||||||
try {
|
try {
|
||||||
// // 发送测试消息 setWeightInfo("鄂A7D1P1", df.format(new Date()));
|
// // 发送测试消息 setWeightInfo("鄂A7D1P1", df.format(new Date()));
|
||||||
|
|
||||||
screen();
|
screen();
|
||||||
|
|
||||||
Thread.sleep(5000);
|
Thread.sleep(5000);
|
||||||
}catch (Exception e){
|
} catch (Exception e) {
|
||||||
log.error(e.getMessage(), e);
|
log.error(e.getMessage(), e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -87,6 +91,7 @@ public class LEDThread extends Device implements Runnable {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void screen() {
|
public void screen() {
|
||||||
|
synchronized (lock) {
|
||||||
lock.lock();
|
lock.lock();
|
||||||
try {
|
try {
|
||||||
if (this.license == null) {
|
if (this.license == null) {
|
||||||
|
|
@ -96,6 +101,12 @@ public class LEDThread extends Device implements Runnable {
|
||||||
// 重连一次
|
// 重连一次
|
||||||
if (!isConnected()) {
|
if (!isConnected()) {
|
||||||
connect();
|
connect();
|
||||||
|
|
||||||
|
// 重连一次后还是连不上,就等下次连上再发送内容
|
||||||
|
if (!isConnected()) {
|
||||||
|
log.error("LED %s %s 连接失败", getId(), getIp());
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String date = sdf.get().format(new Date());
|
String date = sdf.get().format(new Date());
|
||||||
|
|
@ -146,13 +157,18 @@ public class LEDThread extends Device implements Runnable {
|
||||||
// System.out.println(getId() + " LED 返回数据:" + HexDump.toHex(z));
|
// System.out.println(getId() + " LED 返回数据:" + HexDump.toHex(z));
|
||||||
// socket.close();
|
// socket.close();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
if (e.getMessage().contains("Socket is not connected")) {
|
||||||
|
log.error("LED %s %s 连接已断开", getId(), getIp());
|
||||||
|
} else {
|
||||||
log.error(e.getMessage(), e);
|
log.error(e.getMessage(), e);
|
||||||
|
}
|
||||||
|
|
||||||
reconn();
|
reconn();
|
||||||
} finally {
|
} finally {
|
||||||
lock.unlock();
|
lock.unlock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static byte[] frameHead = new byte[]{(byte) 0xa5, (byte) 0xa5, (byte) 0xa5, (byte) 0xa5, (byte) 0xa5, (byte) 0xa5, (byte) 0xa5, (byte) 0xa5};
|
private static byte[] frameHead = new byte[]{(byte) 0xa5, (byte) 0xa5, (byte) 0xa5, (byte) 0xa5, (byte) 0xa5, (byte) 0xa5, (byte) 0xa5, (byte) 0xa5};
|
||||||
private static byte[] packetHead = new byte[]{
|
private static byte[] packetHead = new byte[]{
|
||||||
|
|
@ -231,6 +247,12 @@ public class LEDThread extends Device implements Runnable {
|
||||||
socket = new Socket();
|
socket = new Socket();
|
||||||
socket.setSoTimeout(1000);
|
socket.setSoTimeout(1000);
|
||||||
socket.connect(new InetSocketAddress(getIp(), getPort()), 5000);
|
socket.connect(new InetSocketAddress(getIp(), getPort()), 5000);
|
||||||
|
} catch (Exception e) {
|
||||||
|
if (e.getMessage().contains("connect timed out")) {
|
||||||
|
log.error("LED %s %s 连接超时", getId(), getIp());
|
||||||
|
} else {
|
||||||
|
log.error(e.getMessage(), e);
|
||||||
|
}
|
||||||
} finally {
|
} finally {
|
||||||
lock.unlock();
|
lock.unlock();
|
||||||
}
|
}
|
||||||
|
|
@ -260,7 +282,7 @@ public class LEDThread extends Device implements Runnable {
|
||||||
socket = null;
|
socket = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean reconn(){
|
public boolean reconn() {
|
||||||
try {
|
try {
|
||||||
log.debug("销毁LED连接");
|
log.debug("销毁LED连接");
|
||||||
if (socket != null) {
|
if (socket != null) {
|
||||||
|
|
@ -277,7 +299,11 @@ public class LEDThread extends Device implements Runnable {
|
||||||
socket.setSoTimeout(1000);
|
socket.setSoTimeout(1000);
|
||||||
socket.connect(new InetSocketAddress(getIp(), getPort()), 5000);
|
socket.connect(new InetSocketAddress(getIp(), getPort()), 5000);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
if (e.getMessage().contains("connect timed out")) {
|
||||||
|
log.error("LED %s %s 连接超时", getId(), getIp());
|
||||||
|
} else {
|
||||||
log.error(e.getMessage(), e);
|
log.error(e.getMessage(), e);
|
||||||
|
}
|
||||||
} finally {
|
} finally {
|
||||||
lock.unlock();
|
lock.unlock();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -85,6 +85,12 @@ public class PLC extends Device {
|
||||||
|
|
||||||
log.debug("plc连接成功");
|
log.debug("plc连接成功");
|
||||||
return true;
|
return true;
|
||||||
|
}catch (Exception e){
|
||||||
|
if(e.getMessage().contains("connect timed out")){
|
||||||
|
log.error("PLC %s %s 连接超时", getId(), getIp());
|
||||||
|
}else{
|
||||||
|
log.error(e.getMessage(), e);
|
||||||
|
}
|
||||||
} finally {
|
} finally {
|
||||||
lock.unlock();
|
lock.unlock();
|
||||||
}
|
}
|
||||||
|
|
@ -117,16 +123,11 @@ public class PLC extends Device {
|
||||||
log.debug("销毁PLC连接开始");
|
log.debug("销毁PLC连接开始");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
log.debug("销毁PLC 1 " + (socket != null));
|
|
||||||
log.debug("销毁PLC 2 " + (socket != null && socket.isConnected()));
|
|
||||||
log.debug("销毁PLC 3 " + (socket != null && !socket.isClosed()));
|
|
||||||
|
|
||||||
if (socket != null && socket.isConnected() && !socket.isClosed()) {
|
if (socket != null && socket.isConnected() && !socket.isClosed()) {
|
||||||
socket.close();
|
socket.close();
|
||||||
socket = null;
|
socket = null;
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
System.out.println("销毁PLC IOException");
|
|
||||||
log.error(e.getMessage(), e);
|
log.error(e.getMessage(), e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -143,6 +144,11 @@ public class PLC extends Device {
|
||||||
void plcWrite(String address, byte data, byte[] framePreset) throws IOException {
|
void plcWrite(String address, byte data, byte[] framePreset) throws IOException {
|
||||||
lock.lock();
|
lock.lock();
|
||||||
try {
|
try {
|
||||||
|
if (!isConnected()) {
|
||||||
|
log.debug("PLC %s %s 未连接", getId(), getIp());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (addressTable.containsKey(address)) {
|
if (addressTable.containsKey(address)) {
|
||||||
byte addr = addressTable.get(address);
|
byte addr = addressTable.get(address);
|
||||||
byte[] frame = new byte[framePreset.length];
|
byte[] frame = new byte[framePreset.length];
|
||||||
|
|
@ -166,6 +172,11 @@ public class PLC extends Device {
|
||||||
int plcRead() throws IOException {
|
int plcRead() throws IOException {
|
||||||
lock.lock();
|
lock.lock();
|
||||||
try {
|
try {
|
||||||
|
if (!isConnected()) {
|
||||||
|
log.debug("PLC %s %s 未连接", getId(), getIp());
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
InputStream in = socket.getInputStream();
|
InputStream in = socket.getInputStream();
|
||||||
if (in.available() >= 6) {
|
if (in.available() >= 6) {
|
||||||
byte[] buf = new byte[6];
|
byte[] buf = new byte[6];
|
||||||
|
|
@ -188,6 +199,11 @@ public class PLC extends Device {
|
||||||
int plcClear() throws IOException {
|
int plcClear() throws IOException {
|
||||||
lock.lock();
|
lock.lock();
|
||||||
try {
|
try {
|
||||||
|
if (!isConnected()) {
|
||||||
|
log.debug("PLC %s %s 未连接", getId(), getIp());
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
InputStream inputStream = socket.getInputStream();
|
InputStream inputStream = socket.getInputStream();
|
||||||
int available = inputStream.available();
|
int available = inputStream.available();
|
||||||
byte[] buf = new byte[available];
|
byte[] buf = new byte[available];
|
||||||
|
|
|
||||||
|
|
@ -88,6 +88,7 @@ public class Config extends JFinalConfig {
|
||||||
public static DeviceThread deviceThread = new DeviceThread();
|
public static DeviceThread deviceThread = new DeviceThread();
|
||||||
public static SocketIOService socketio = null;
|
public static SocketIOService socketio = null;
|
||||||
private static boolean client_run = true;
|
private static boolean client_run = true;
|
||||||
|
public static final String CLINET_VERSION = "20200929";
|
||||||
|
|
||||||
public static String getRootPath() {
|
public static String getRootPath() {
|
||||||
return PathKit.getWebRootPath()
|
return PathKit.getWebRootPath()
|
||||||
|
|
|
||||||
|
|
@ -186,7 +186,10 @@ public class NettyClient {
|
||||||
channel = ctx.channel();
|
channel = ctx.channel();
|
||||||
|
|
||||||
JSONObject json = new JSONObject();
|
JSONObject json = new JSONObject();
|
||||||
json.fluentPut("target", Enums.MsgTarget.LOGIN.name()).fluentPut("supermarket_id", supermarket_id);
|
json.fluentPut("target", Enums.MsgTarget.LOGIN.name())
|
||||||
|
.fluentPut("supermarket_id", supermarket_id)
|
||||||
|
.fluentPut("clinet_version", Config.CLINET_VERSION)
|
||||||
|
;
|
||||||
sendMsg(ctx, json.toJSONString());
|
sendMsg(ctx, json.toJSONString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -38,8 +38,10 @@ public class OrderTempController extends BaseController {
|
||||||
Integer supermarket_id = getInt("supermarket_id");
|
Integer supermarket_id = getInt("supermarket_id");
|
||||||
Integer isprepaid = getInt("isprepaid");
|
Integer isprepaid = getInt("isprepaid");
|
||||||
String invoice_code = get("invoice_code");
|
String invoice_code = get("invoice_code");
|
||||||
|
Integer invoice_type = getInt("invoice_type");
|
||||||
Integer customer_id = getInt("customer_id");
|
Integer customer_id = getInt("customer_id");
|
||||||
renderJson(Result.object(OrderTempService.me.find(pp, sn, truck_license, supermarket_id, customer_id, customer_name, stm, etm, isprepaid, state, invoice_code, product_id)));
|
Boolean invoice_code_is_null = getBoolean("invoice_code_is_null");
|
||||||
|
renderJson(Result.object(OrderTempService.me.find(pp, sn, truck_license, supermarket_id, customer_id, customer_name, stm, etm, isprepaid, state, invoice_code, invoice_type, product_id, invoice_code_is_null)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Before(OrderTempPayValidator.class)
|
@Before(OrderTempPayValidator.class)
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ import com.cowr.common.enums.OrderTypeEnum;
|
||||||
import com.cowr.common.utils.DateTimeUtil;
|
import com.cowr.common.utils.DateTimeUtil;
|
||||||
import com.cowr.common.view.Result;
|
import com.cowr.common.view.Result;
|
||||||
import com.cowr.local.ssjygl.actioncmdlog.ActionCmdLogSyncService;
|
import com.cowr.local.ssjygl.actioncmdlog.ActionCmdLogSyncService;
|
||||||
|
import com.cowr.local.ssjygl.main.CliCacheData;
|
||||||
import com.cowr.local.ssjygl.main.Config;
|
import com.cowr.local.ssjygl.main.Config;
|
||||||
import com.cowr.local.ssjygl.order.LocalOrderService;
|
import com.cowr.local.ssjygl.order.LocalOrderService;
|
||||||
import com.cowr.local.ssjygl.order.orderseq.OrderSeqService;
|
import com.cowr.local.ssjygl.order.orderseq.OrderSeqService;
|
||||||
|
|
@ -225,6 +226,13 @@ public class OrderTempSyncService {
|
||||||
Sysuser sysuser,
|
Sysuser sysuser,
|
||||||
int req_receipt
|
int req_receipt
|
||||||
) {
|
) {
|
||||||
|
OrderTemp order = new OrderTemp();
|
||||||
|
|
||||||
|
order.setUuid(uuid);
|
||||||
|
|
||||||
|
if (order.checkDuplicate("uuid")) {
|
||||||
|
return Result.failed("【%s】已经存在", uuid);
|
||||||
|
}
|
||||||
|
|
||||||
Transport transport = Transport.dao.findById(transport_id);
|
Transport transport = Transport.dao.findById(transport_id);
|
||||||
if (transport == null) {
|
if (transport == null) {
|
||||||
|
|
@ -235,52 +243,7 @@ public class OrderTempSyncService {
|
||||||
return Result.failed("进出场记录已完结或者已作废,不能使用");
|
return Result.failed("进出场记录已完结或者已作废,不能使用");
|
||||||
}
|
}
|
||||||
|
|
||||||
InvoiceReceive receive = InvoiceReceiveService.me.checkReceive(transport.getSupermarketId(), invoice_number, invoice_code);
|
BigDecimal min = new BigDecimal(0.0);
|
||||||
if (receive == null) {
|
|
||||||
return Result.failed("没有有效的发票领用记录,或者发票已经被使用");
|
|
||||||
}
|
|
||||||
|
|
||||||
Ordercluster ordercluster = Ordercluster.dao.findById(ordercluster_id);
|
|
||||||
if (ordercluster == null) {
|
|
||||||
return Result.failedstr("集团订单【%s】信息不存在", ordercluster_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!DateTimeUtil.isToday(ordercluster.getCutoffTime())) {
|
|
||||||
return Result.failedstr("集团订单只能在%s使用", DateTimeUtil.sdfymd.get().format(ordercluster.getCutoffTime()));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ordercluster.getState() == OrderStateEnum.INVALID.getStateid()) {
|
|
||||||
return Result.failedstr("集团订单【%s】已完结,请重新下单", ordercluster_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
BigDecimal up = SupermarketProductService.me.getUnitPrice(transport.getSupermarketId(), ordercluster.getProductId());
|
|
||||||
|
|
||||||
if (up == null) {
|
|
||||||
return Result.failedstr("未查到有效的单价信息");
|
|
||||||
}
|
|
||||||
|
|
||||||
OrderclusterTruck ot = OrderclusterTruck.dao.findFirst("select * from ordercluster_truck t \n" +
|
|
||||||
" where t.truck_license = ? \n" +
|
|
||||||
" and t.ordercluster_id = ? ",
|
|
||||||
transport.getTruckLicense(),
|
|
||||||
ordercluster_id
|
|
||||||
);
|
|
||||||
|
|
||||||
if (ot == null) {
|
|
||||||
return Result.failedstr("【%s】不是今日分配车辆", transport.getTruckLicense());
|
|
||||||
}
|
|
||||||
|
|
||||||
BigDecimal min = new BigDecimal(0.001);
|
|
||||||
Date now = new Date();
|
|
||||||
SyncTask synctask = new SyncTask();
|
|
||||||
OrderTemp order = new OrderTemp();
|
|
||||||
|
|
||||||
order.setUuid(uuid);
|
|
||||||
|
|
||||||
if (order.checkDuplicate("uuid")) {
|
|
||||||
return Result.failed("【%s】已经存在", uuid);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 验证重量
|
// 验证重量
|
||||||
if (transport.getFirstWeight() == null
|
if (transport.getFirstWeight() == null
|
||||||
|| transport.getSecondWeight() == null
|
|| transport.getSecondWeight() == null
|
||||||
|
|
@ -296,12 +259,51 @@ public class OrderTempSyncService {
|
||||||
}
|
}
|
||||||
|
|
||||||
BigDecimal net_weight = transport.getSecondWeight().subtract(transport.getFirstWeight()); // 销售的用第二次减第一次
|
BigDecimal net_weight = transport.getSecondWeight().subtract(transport.getFirstWeight()); // 销售的用第二次减第一次
|
||||||
|
|
||||||
|
OrderclusterTruck ot = OrderclusterTruck.dao.findFirst("select * from ordercluster_truck t \n" +
|
||||||
|
" where t.truck_license = ? \n" +
|
||||||
|
" and t.ordercluster_id = ? ",
|
||||||
|
transport.getTruckLicense(),
|
||||||
|
ordercluster_id
|
||||||
|
);
|
||||||
|
|
||||||
|
if (ot == null) {
|
||||||
|
return Result.failedstr("【%s】不是今日分配车辆", transport.getTruckLicense());
|
||||||
|
}
|
||||||
|
|
||||||
|
Ordercluster ordercluster = Ordercluster.dao.findById(ordercluster_id);
|
||||||
|
if (ordercluster == null) {
|
||||||
|
return Result.failedstr("集团订单【%s】信息不存在", ordercluster_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!DateTimeUtil.isToday(ordercluster.getCutoffTime())) {
|
||||||
|
return Result.failedstr("集团订单只能在%s使用", DateTimeUtil.sdfymd.get().format(ordercluster.getCutoffTime()));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ordercluster.getState() == OrderStateEnum.INVALID.getStateid()) {
|
||||||
|
return Result.failedstr("集团订单【%s】已完结,请重新下单", ordercluster_id);
|
||||||
|
}
|
||||||
|
|
||||||
BigDecimal overweight = OrderclusterService.me.getOverWeight(ordercluster_id); // 集团订单已完成量
|
BigDecimal overweight = OrderclusterService.me.getOverWeight(ordercluster_id); // 集团订单已完成量
|
||||||
// 不能超过集团订单剩余量
|
// 不能超过集团订单剩余量
|
||||||
if (net_weight.compareTo(ordercluster.getTotalWeight().subtract(overweight)) > 0) {
|
if (net_weight.compareTo(ordercluster.getTotalWeight().subtract(overweight)) > 0) {
|
||||||
return Result.failedstr("净重 %.2f 吨,超过了剩余的 %.2f 余量", net_weight, ordercluster.getTotalWeight().subtract(overweight));
|
return Result.failedstr("净重 %.2f 吨,超过了剩余的 %.2f 余量", net_weight, ordercluster.getTotalWeight().subtract(overweight));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
InvoiceReceive receive = InvoiceReceiveService.me.checkReceive(transport.getSupermarketId(), invoice_number, invoice_code);
|
||||||
|
if (receive == null) {
|
||||||
|
return Result.failed("没有有效的发票领用记录,或者发票已经被使用");
|
||||||
|
}
|
||||||
|
|
||||||
|
BigDecimal up = SupermarketProductService.me.getUnitPrice(transport.getSupermarketId(), ordercluster.getProductId());
|
||||||
|
|
||||||
|
if (up == null) {
|
||||||
|
return Result.failedstr("未查到有效的单价信息");
|
||||||
|
}
|
||||||
|
|
||||||
|
Date now = new Date();
|
||||||
|
SyncTask synctask = new SyncTask();
|
||||||
|
|
||||||
// if (req_receipt == 1) { // 需要同时开具发票
|
// if (req_receipt == 1) { // 需要同时开具发票
|
||||||
order.setInvoiceCode(invoice_code);
|
order.setInvoiceCode(invoice_code);
|
||||||
order.setInvoiceNumber(invoice_number);
|
order.setInvoiceNumber(invoice_number);
|
||||||
|
|
@ -335,6 +337,7 @@ public class OrderTempSyncService {
|
||||||
order.setCustomerTexpayerName(customer.getTexpayerName());
|
order.setCustomerTexpayerName(customer.getTexpayerName());
|
||||||
order.setCustomerTexpayerNum(customer.getTexpayerNum());
|
order.setCustomerTexpayerNum(customer.getTexpayerNum());
|
||||||
} else {
|
} else {
|
||||||
|
// 可能是零散购砂客户,没有对应的客户信息记录,但是有客户名称之类的信息
|
||||||
order.setCustomerId(ordercluster.getCustomerId());
|
order.setCustomerId(ordercluster.getCustomerId());
|
||||||
order.setCustomerAddress(ordercluster.getCustomerAddress());
|
order.setCustomerAddress(ordercluster.getCustomerAddress());
|
||||||
order.setCustomerBankAccount(ordercluster.getCustomerBankAccount());
|
order.setCustomerBankAccount(ordercluster.getCustomerBankAccount());
|
||||||
|
|
@ -345,7 +348,6 @@ public class OrderTempSyncService {
|
||||||
order.setCustomerTexpayerNum(ordercluster.getCustomerTexpayerNum());
|
order.setCustomerTexpayerNum(ordercluster.getCustomerTexpayerNum());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// 物流公司信息
|
// 物流公司信息
|
||||||
order.setTransCoId(ordercluster.getTransCoId());
|
order.setTransCoId(ordercluster.getTransCoId());
|
||||||
order.setTransCoAddress(ordercluster.getTransCoAddress());
|
order.setTransCoAddress(ordercluster.getTransCoAddress());
|
||||||
|
|
@ -496,34 +498,6 @@ public class OrderTempSyncService {
|
||||||
return Result.failed("进出场记录已完结或者已作废,不能使用");
|
return Result.failed("进出场记录已完结或者已作废,不能使用");
|
||||||
}
|
}
|
||||||
|
|
||||||
InvoiceReceive receive = InvoiceReceiveService.me.checkReceive(transport.getSupermarketId(), invoice_number, invoice_code);
|
|
||||||
if (receive == null) {
|
|
||||||
return Result.failed("没有有效的发票领用记录,或者发票已经被使用");
|
|
||||||
}
|
|
||||||
|
|
||||||
OrderclusterTruck ot = OrderclusterTruck.dao.findFirst("select * from ordercluster_truck t \n" +
|
|
||||||
" where t.truck_license = ? \n" +
|
|
||||||
" and t.ordercluster_id = ? ",
|
|
||||||
transport.getTruckLicense(),
|
|
||||||
ordercluster_id
|
|
||||||
);
|
|
||||||
|
|
||||||
if (ot == null) {
|
|
||||||
return Result.failedstr("【%s】不是今日预付费车辆", transport.getTruckLicense());
|
|
||||||
}
|
|
||||||
|
|
||||||
Customer customer;
|
|
||||||
Product product;
|
|
||||||
Ordercluster ordercluster = Ordercluster.dao.findById(ordercluster_id);
|
|
||||||
|
|
||||||
if (ordercluster == null) {
|
|
||||||
return Result.failedstr("集团订单【%s】信息不存在", ordercluster_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ordercluster.getState() == OrderStateEnum.INVALID.getStateid()) {
|
|
||||||
return Result.failedstr("集团订单【%s】已完结,请重新下单", ordercluster_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 验证重量
|
// 验证重量
|
||||||
if (transport.getFirstWeight() == null
|
if (transport.getFirstWeight() == null
|
||||||
|| transport.getSecondWeight() == null
|
|| transport.getSecondWeight() == null
|
||||||
|
|
@ -540,12 +514,87 @@ public class OrderTempSyncService {
|
||||||
|
|
||||||
BigDecimal net_weight = transport.getSecondWeight().subtract(transport.getFirstWeight()); // 销售的用第二次减第一次
|
BigDecimal net_weight = transport.getSecondWeight().subtract(transport.getFirstWeight()); // 销售的用第二次减第一次
|
||||||
|
|
||||||
|
OrderclusterTruck ot = OrderclusterTruck.dao.findFirst("select * from ordercluster_truck t \n" +
|
||||||
|
" where t.truck_license = ? \n" +
|
||||||
|
" and t.ordercluster_id = ? ",
|
||||||
|
transport.getTruckLicense(),
|
||||||
|
ordercluster_id
|
||||||
|
);
|
||||||
|
|
||||||
|
if (ot == null) {
|
||||||
|
return Result.failedstr("【%s】不是今日预付费车辆", transport.getTruckLicense());
|
||||||
|
}
|
||||||
|
|
||||||
|
Ordercluster ordercluster = Ordercluster.dao.findById(ordercluster_id);
|
||||||
|
|
||||||
|
if (ordercluster == null) {
|
||||||
|
return Result.failedstr("集团订单【%s】信息不存在", ordercluster_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ordercluster.getState() == OrderStateEnum.INVALID.getStateid()) {
|
||||||
|
return Result.failedstr("集团订单【%s】已完结,请重新下单", ordercluster_id);
|
||||||
|
}
|
||||||
|
|
||||||
if (!DateTimeUtil.isToday(ordercluster.getCutoffTime())) {
|
if (!DateTimeUtil.isToday(ordercluster.getCutoffTime())) {
|
||||||
return Result.failedstr("集团订单只能在%s使用", DateTimeUtil.sdfymd.get().format(ordercluster.getCutoffTime()));
|
return Result.failedstr("集团订单只能在%s使用", DateTimeUtil.sdfymd.get().format(ordercluster.getCutoffTime()));
|
||||||
}
|
}
|
||||||
|
|
||||||
customer = Customer.dao.findById(ordercluster.getCustomerId());
|
if (ordercluster.getSupermarketId() != CliCacheData.SUP.getId()) {
|
||||||
product = Product.dao.findById(ordercluster.getProductId());
|
return Result.failedstr("配额指定砂站(%s)和当前砂站不匹配(%s)", ordercluster.getSupermarketId(), CliCacheData.SUP.getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
BigDecimal overweight = OrderclusterService.me.getOverWeight(ordercluster_id); // 集团订单已完成量
|
||||||
|
// 不能超过集团订单剩余量
|
||||||
|
if (net_weight.compareTo(ordercluster.getTotalWeight().subtract(overweight)) > 0) {
|
||||||
|
return Result.failedstr("净重 %.2f 吨,超过了剩余的 %.2f 余量", net_weight, ordercluster.getTotalWeight().subtract(overweight));
|
||||||
|
}
|
||||||
|
|
||||||
|
Customer customer = Customer.dao.findById(ordercluster.getCustomerId());
|
||||||
|
|
||||||
|
if (customer == null) {
|
||||||
|
return Result.failedstr("未找到有效的客户信息");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (customer.getType() != 1) {
|
||||||
|
return Result.failed("不是预付费客户");
|
||||||
|
}
|
||||||
|
|
||||||
|
PrepayCustomer prepayCustomer = PrepayCustomerService.me.getPrepayCustomer(customer.getId());
|
||||||
|
|
||||||
|
if (prepayCustomer == null) {
|
||||||
|
return Result.failed("没有找到客户预付费信息");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (prepayCustomer.getSurplus() == null || prepayCustomer.getSurplus().compareTo(min) == 0) {
|
||||||
|
return Result.failed("客户余额不足");
|
||||||
|
}
|
||||||
|
|
||||||
|
InvoiceReceive receive = null;
|
||||||
|
|
||||||
|
// 2020-09-29 需要开具专票的,先开具结算单,不打发票
|
||||||
|
if (CliCacheData.SUP.getInvoiceType() == 2 && customer.getInvoiceType() == 2) {
|
||||||
|
order.setInvoiceType(2);
|
||||||
|
// 需要专票的,在结算开了专票之后,再修改 invoice_site 字段
|
||||||
|
} else {
|
||||||
|
receive = InvoiceReceiveService.me.checkReceive(transport.getSupermarketId(), invoice_number, invoice_code);
|
||||||
|
if (receive == null) {
|
||||||
|
return Result.failed("没有有效的发票领用记录,或者发票已经被使用");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 不满足开专票的条件的,就必须开具冠名发票
|
||||||
|
// if (req_receipt == 1) { // 需要同时开具发票
|
||||||
|
order.setInvoiceCode(invoice_code);
|
||||||
|
order.setInvoiceNumber(invoice_number);
|
||||||
|
order.setInvoiceType(1);
|
||||||
|
order.setInvoiceSite(1); // 在砂站开具冠名发票
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
Product product = Product.dao.findById(ordercluster.getProductId());
|
||||||
|
|
||||||
|
if (product == null) {
|
||||||
|
return Result.failedstr("未找到有效的品类信息");
|
||||||
|
}
|
||||||
|
|
||||||
// 物流公司信息
|
// 物流公司信息
|
||||||
order.setTransCoId(ordercluster.getTransCoId());
|
order.setTransCoId(ordercluster.getTransCoId());
|
||||||
|
|
@ -566,42 +615,15 @@ public class OrderTempSyncService {
|
||||||
transport.setTransCoTexpayerName(ordercluster.getTransCoTexpayerName());
|
transport.setTransCoTexpayerName(ordercluster.getTransCoTexpayerName());
|
||||||
transport.setTransCoTexpayerNum(ordercluster.getTransCoTexpayerNum());
|
transport.setTransCoTexpayerNum(ordercluster.getTransCoTexpayerNum());
|
||||||
|
|
||||||
if (product == null) {
|
|
||||||
return Result.failedstr("未找到有效的品类信息");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (customer == null) {
|
|
||||||
return Result.failedstr("未找到有效的客户信息");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (customer.getType() != 1) {
|
|
||||||
return Result.failed("不是预付费客户");
|
|
||||||
}
|
|
||||||
|
|
||||||
BigDecimal up = SupermarketProductService.me.getUnitPrice(transport.getSupermarketId(), product.getId());
|
BigDecimal up = SupermarketProductService.me.getUnitPrice(transport.getSupermarketId(), product.getId());
|
||||||
|
|
||||||
if (up == null) {
|
if (up == null) {
|
||||||
return Result.failedstr("未查到有效的单价信息");
|
return Result.failedstr("未查到有效的单价信息");
|
||||||
}
|
}
|
||||||
|
|
||||||
PrepayCustomer prepayCustomer = PrepayCustomerService.me.getPrepayCustomer(customer.getId());
|
|
||||||
|
|
||||||
if (prepayCustomer == null) {
|
|
||||||
return Result.failed("没有找到客户预付费信息");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (prepayCustomer.getSurplus() == null || prepayCustomer.getSurplus().compareTo(min) == 0) {
|
|
||||||
return Result.failed("客户余额不足");
|
|
||||||
}
|
|
||||||
|
|
||||||
Date now = new Date();
|
Date now = new Date();
|
||||||
SyncTask synctask = new SyncTask();
|
SyncTask synctask = new SyncTask();
|
||||||
|
|
||||||
// if (req_receipt == 1) { // 需要同时开具发票
|
|
||||||
order.setInvoiceCode(invoice_code);
|
|
||||||
order.setInvoiceNumber(invoice_number);
|
|
||||||
// }
|
|
||||||
|
|
||||||
order.setTransportId(transport.getId());
|
order.setTransportId(transport.getId());
|
||||||
order.setSupermarketId(transport.getSupermarketId());
|
order.setSupermarketId(transport.getSupermarketId());
|
||||||
order.setTruckLicense(transport.getTruckLicense());
|
order.setTruckLicense(transport.getTruckLicense());
|
||||||
|
|
@ -646,6 +668,7 @@ public class OrderTempSyncService {
|
||||||
return Result.failedstr("总价 %.2f,客户余额(%.2f)不足以支付");
|
return Result.failedstr("总价 %.2f,客户余额(%.2f)不足以支付");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
InvoiceReceive finalReceive = receive;
|
||||||
boolean ret = Db.tx(new IAtom() {
|
boolean ret = Db.tx(new IAtom() {
|
||||||
@Override
|
@Override
|
||||||
public boolean run() {
|
public boolean run() {
|
||||||
|
|
@ -704,12 +727,13 @@ public class OrderTempSyncService {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (finalReceive != null) {
|
||||||
// if (req_receipt == 1) { // 需要同时开具发票
|
// if (req_receipt == 1) { // 需要同时开具发票
|
||||||
// 这里的 finalReceive 在前面肯定验证过了
|
// 这里的 finalReceive 在前面肯定验证过了
|
||||||
receive.setSurplus(receive.getSurplus() - 1);
|
finalReceive.setSurplus(finalReceive.getSurplus() - 1);
|
||||||
receive.setCurrentCode(invoice_code);
|
finalReceive.setCurrentCode(invoice_code);
|
||||||
|
|
||||||
ret = receive.update();
|
ret = finalReceive.update();
|
||||||
|
|
||||||
if (!ret) {
|
if (!ret) {
|
||||||
log.error("发票领用信息更新失败", invoice_code);
|
log.error("发票领用信息更新失败", invoice_code);
|
||||||
|
|
@ -718,7 +742,7 @@ public class OrderTempSyncService {
|
||||||
|
|
||||||
InvoiceLog invoiceLog = new InvoiceLog();
|
InvoiceLog invoiceLog = new InvoiceLog();
|
||||||
invoiceLog.setId(StrKit.getRandomUUID());
|
invoiceLog.setId(StrKit.getRandomUUID());
|
||||||
invoiceLog.setInvoiceReceiveId(receive.getId());
|
invoiceLog.setInvoiceReceiveId(finalReceive.getId());
|
||||||
invoiceLog.setCode(invoice_code);
|
invoiceLog.setCode(invoice_code);
|
||||||
invoiceLog.setInvoiceNumber(invoice_number);
|
invoiceLog.setInvoiceNumber(invoice_number);
|
||||||
invoiceLog.setState(OrderStateEnum.RECEIVED.getStateid());
|
invoiceLog.setState(OrderStateEnum.RECEIVED.getStateid());
|
||||||
|
|
@ -735,7 +759,8 @@ public class OrderTempSyncService {
|
||||||
}
|
}
|
||||||
|
|
||||||
synctask.addSaveData(invoiceLog);
|
synctask.addSaveData(invoiceLog);
|
||||||
synctask.addUpdateData(receive);
|
synctask.addUpdateData(finalReceive);
|
||||||
|
}
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// 在这里更新sn字段之后存入
|
// 在这里更新sn字段之后存入
|
||||||
|
|
|
||||||
Binary file not shown.
|
|
@ -24,7 +24,7 @@ public class CustomerRegisterVerifyValidator extends CrudParamValidator {
|
||||||
validateRequired("id", "id", "id 必填");
|
validateRequired("id", "id", "id 必填");
|
||||||
validateLong("id", 1, 9223372036854775807L, "id", "id 范围 1~9223372036854775807L");
|
validateLong("id", 1, 9223372036854775807L, "id", "id 范围 1~9223372036854775807L");
|
||||||
validateInIntegerArray("state", chkstate, "state", "state 可选值 5、9");
|
validateInIntegerArray("state", chkstate, "state", "state 可选值 5、9");
|
||||||
validateString("verify_memo", 0, 255, "memo", "verify_memo 长度 0~255");
|
validateString("verify_memo", 0, 255, "verify_memo", "verify_memo 长度 0~255");
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void handleError(Controller c) {
|
protected void handleError(Controller c) {
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,18 @@
|
||||||
|
package com.cowr.service.ssjygl.invoice.log;
|
||||||
|
|
||||||
|
import com.cowr.common.validator.CrudParamValidator;
|
||||||
|
import com.cowr.common.view.Result;
|
||||||
|
import com.jfinal.core.Controller;
|
||||||
|
|
||||||
|
public class BatchSaveValidator extends CrudParamValidator {
|
||||||
|
@Override
|
||||||
|
protected void validate(Controller c) {
|
||||||
|
validateRequired("invoice_number", "invoice_number", "invoice_number 必填");
|
||||||
|
validateRequired("invoice_code", "invoice_code", "invoice_code 必填");
|
||||||
|
validateRequired("order_sns", "order_sns", "order_sns 必填");
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void handleError(Controller c) {
|
||||||
|
c.renderJson(Result.failed(getErrmsg()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -118,4 +118,23 @@ public class InvoiceLogController extends Controller {
|
||||||
|
|
||||||
renderJson(InvoiceLogSyncService.me.cancelByCode(invoice_number, code, invalid_memo, tokenuser));
|
renderJson(InvoiceLogSyncService.me.cancelByCode(invoice_number, code, invalid_memo, tokenuser));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Before(BatchSaveValidator.class)
|
||||||
|
public void batchSave() {
|
||||||
|
Sysuser tokenuser = SysuserSyncService.me.getSysuserByToken(get("token"));
|
||||||
|
|
||||||
|
if (tokenuser == null) {
|
||||||
|
renderJson(Result.noauth());
|
||||||
|
return;
|
||||||
|
} else if (!SysuserSyncService.me.isTreasurer(tokenuser.getRole())) { // 财务才能录入专票
|
||||||
|
renderJson(Result.permissionDenied());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
String invoice_number = get("invoice_number");
|
||||||
|
String invoice_code = get("invoice_code");
|
||||||
|
String order_sns = get("order_sns");
|
||||||
|
|
||||||
|
renderJson(InvoiceLogSyncService.me.batchSave(invoice_number, invoice_code, order_sns, tokenuser));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ package com.cowr.service.ssjygl.invoice.log;
|
||||||
import com.cowr.common.base.BaseModel;
|
import com.cowr.common.base.BaseModel;
|
||||||
import com.cowr.common.enums.Enums;
|
import com.cowr.common.enums.Enums;
|
||||||
import com.cowr.common.enums.OrderStateEnum;
|
import com.cowr.common.enums.OrderStateEnum;
|
||||||
|
import com.cowr.common.enums.OrderTypeEnum;
|
||||||
import com.cowr.common.view.Result;
|
import com.cowr.common.view.Result;
|
||||||
import com.cowr.model.*;
|
import com.cowr.model.*;
|
||||||
import com.cowr.service.ssjygl.base.BaseSyncService;
|
import com.cowr.service.ssjygl.base.BaseSyncService;
|
||||||
|
|
@ -16,12 +17,105 @@ import com.jfinal.plugin.activerecord.Db;
|
||||||
import com.jfinal.plugin.activerecord.IAtom;
|
import com.jfinal.plugin.activerecord.IAtom;
|
||||||
|
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class InvoiceLogSyncService extends BaseSyncService {
|
public class InvoiceLogSyncService extends BaseSyncService {
|
||||||
private static Log log = Log.getLog(InvoiceLogSyncService.class);
|
private static Log log = Log.getLog(InvoiceLogSyncService.class);
|
||||||
public static InvoiceLogSyncService me = new InvoiceLogSyncService();
|
public static InvoiceLogSyncService me = new InvoiceLogSyncService();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加专票
|
||||||
|
* @param invoice_number
|
||||||
|
* @param invoice_code
|
||||||
|
* @param order_sns
|
||||||
|
* @param sysuser
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public Result batchSave(String invoice_number, String invoice_code, String order_sns, Sysuser sysuser){
|
||||||
|
String[] snarr = order_sns.split(",");
|
||||||
|
List<String> question = new ArrayList<>();
|
||||||
|
List<String> ordersnlist = new ArrayList<>();
|
||||||
|
|
||||||
|
if(StrKit.isBlank(order_sns) || snarr.length == 0){
|
||||||
|
return Result.failed("订单号不能为空");
|
||||||
|
}
|
||||||
|
|
||||||
|
for(String sn : snarr){
|
||||||
|
question.add("?");
|
||||||
|
ordersnlist.add(sn);
|
||||||
|
}
|
||||||
|
|
||||||
|
List<OrderTemp> list = OrderTemp.dao.find("select * from order_temp t \n" +
|
||||||
|
" where t.invoice_code is null \n" +
|
||||||
|
" and t.sn in(" + StrKit.join(question, ", ") + ")", ordersnlist.toArray());
|
||||||
|
|
||||||
|
if(list.size() != snarr.length){
|
||||||
|
return Result.failed("部分订单号未找到,或者已开票");
|
||||||
|
}
|
||||||
|
|
||||||
|
List<InvoiceLog> logs = new ArrayList<>();
|
||||||
|
SyncTask synctask = new SyncTask();
|
||||||
|
|
||||||
|
for(OrderTemp o : list){
|
||||||
|
InvoiceLog invoiceLog = new InvoiceLog();
|
||||||
|
invoiceLog.setId(StrKit.getRandomUUID());
|
||||||
|
invoiceLog.setSettlementUserId(sysuser.getId());
|
||||||
|
invoiceLog.setSettlementUserName(sysuser.getName());
|
||||||
|
invoiceLog.setSettlementTime(new Date());
|
||||||
|
invoiceLog.setState(OrderStateEnum.RECEIVED.getStateid());
|
||||||
|
invoiceLog.setCode(invoice_code);
|
||||||
|
invoiceLog.setInvoiceNumber(invoice_number);
|
||||||
|
invoiceLog.setInvoiceType(2);
|
||||||
|
invoiceLog.setOrderSn(o.getSn());
|
||||||
|
invoiceLog.setType(OrderTypeEnum.TEMP.getTypeid());
|
||||||
|
|
||||||
|
logs.add(invoiceLog);
|
||||||
|
|
||||||
|
synctask.addSaveData(invoiceLog);
|
||||||
|
|
||||||
|
o.setInvoiceSite(2);
|
||||||
|
o.setInvoiceType(2);
|
||||||
|
o.setInvoiceNumber(invoice_number);
|
||||||
|
o.setInvoiceCode(invoice_code);
|
||||||
|
|
||||||
|
synctask.addUpdateData(o);
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean ret = Db.tx(new IAtom() {
|
||||||
|
@Override
|
||||||
|
public boolean run() {
|
||||||
|
try{
|
||||||
|
int[] saveret = Db.batchSave(logs, logs.size());
|
||||||
|
|
||||||
|
for (int i : saveret) {
|
||||||
|
// 必须是每条 sql 修改一条记录
|
||||||
|
if (i != 1) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int[] editret = Db.batchUpdate(list, list.size());
|
||||||
|
|
||||||
|
for (int i : editret) {
|
||||||
|
// 必须是每条 sql 修改一条记录
|
||||||
|
if (i != 1) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return SyncTaskService.me.save(synctask);
|
||||||
|
}catch (Exception e){
|
||||||
|
log.error(e.getMessage(), e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return ret ? Result.success() : Result.failed("保存失败");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 作废发票,未关联订单的(损毁等,不是正常开票使用的发票)
|
* 作废发票,未关联订单的(损毁等,不是正常开票使用的发票)
|
||||||
* @return
|
* @return
|
||||||
|
|
@ -90,7 +184,7 @@ public class InvoiceLogSyncService extends BaseSyncService {
|
||||||
|
|
||||||
synctask.addUpdateData(receive);
|
synctask.addUpdateData(receive);
|
||||||
|
|
||||||
return SyncTaskService.me.save(synctask)
|
return SyncTaskService.me.save(synctask, supermarket_id)
|
||||||
&& ModifyLogService.me.save(finalInvoiceLog, null, Enums.DataOpType.SAVE.getId(), sysuser);
|
&& ModifyLogService.me.save(finalInvoiceLog, null, Enums.DataOpType.SAVE.getId(), sysuser);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error(e.getMessage(), e);
|
log.error(e.getMessage(), e);
|
||||||
|
|
@ -153,6 +247,8 @@ public class InvoiceLogSyncService extends BaseSyncService {
|
||||||
try{
|
try{
|
||||||
order.set("invoice_code", null);
|
order.set("invoice_code", null);
|
||||||
order.set("invoice_number", null);
|
order.set("invoice_number", null);
|
||||||
|
order.set("invoice_type", null);
|
||||||
|
order.set("invoice_site", null);
|
||||||
boolean ret = order.update();
|
boolean ret = order.update();
|
||||||
|
|
||||||
if(!ret){
|
if(!ret){
|
||||||
|
|
@ -170,7 +266,7 @@ public class InvoiceLogSyncService extends BaseSyncService {
|
||||||
|
|
||||||
synctask.addUpdateData(invoiceLog);
|
synctask.addUpdateData(invoiceLog);
|
||||||
|
|
||||||
return SyncTaskService.me.save(synctask) && ModifyLogService.me.save(invoiceLog, old, Enums.DataOpType.UPDATE.getId(), sysuser);
|
return SyncTaskService.me.save(synctask, order.getInt("supermarket_id")) && ModifyLogService.me.save(invoiceLog, old, Enums.DataOpType.UPDATE.getId(), sysuser);
|
||||||
}catch (Exception e){
|
}catch (Exception e){
|
||||||
log.error(e.getMessage(), e);
|
log.error(e.getMessage(), e);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -183,7 +183,7 @@ public class NettyServer {
|
||||||
.toJSONString()
|
.toJSONString()
|
||||||
);
|
);
|
||||||
|
|
||||||
log.debug("supermarket_id " + supermarket_id + " 注册成功");
|
log.debug("supermarket_id %s 注册成功, client version %s", supermarket_id, json.get("clinet_version"));
|
||||||
} else if (Enums.MsgTarget.HEARTBEAT.name().equals(target)) {
|
} else if (Enums.MsgTarget.HEARTBEAT.name().equals(target)) {
|
||||||
printlog("收到心跳 supermarket " + map.get(ctx.channel()) + ", 已连接客户端总数: " + map.size());
|
printlog("收到心跳 supermarket " + map.get(ctx.channel()) + ", 已连接客户端总数: " + map.size());
|
||||||
} else if (Enums.MsgTarget.SYNCTASK.name().equals(target)) {
|
} else if (Enums.MsgTarget.SYNCTASK.name().equals(target)) {
|
||||||
|
|
@ -251,7 +251,7 @@ public class NettyServer {
|
||||||
}
|
}
|
||||||
|
|
||||||
return obj.containsKey("target");
|
return obj.containsKey("target");
|
||||||
}catch (Exception e){
|
} catch (Exception e) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -37,9 +37,11 @@ public class OrderTempController extends BaseController {
|
||||||
Integer state = getInt("state");
|
Integer state = getInt("state");
|
||||||
String invoice_code = get("invoice_code");
|
String invoice_code = get("invoice_code");
|
||||||
Integer product_id = getInt("product_id");
|
Integer product_id = getInt("product_id");
|
||||||
|
Integer invoice_type = getInt("invoice_type");
|
||||||
Integer supermarket_id = getInt("supermarket_id");
|
Integer supermarket_id = getInt("supermarket_id");
|
||||||
Integer isprepaid = getInt("isprepaid");
|
Integer isprepaid = getInt("isprepaid");
|
||||||
Integer customer_id = getInt("customer_id");
|
Integer customer_id = getInt("customer_id");
|
||||||
|
Boolean invoice_code_is_null = getBoolean("invoice_code_is_null");
|
||||||
|
|
||||||
Sysuser tokenuser = SysuserSyncService.me.getSysuserByToken(get("token"));
|
Sysuser tokenuser = SysuserSyncService.me.getSysuserByToken(get("token"));
|
||||||
|
|
||||||
|
|
@ -51,6 +53,6 @@ public class OrderTempController extends BaseController {
|
||||||
customer_id = tokenuser.getEntityId();
|
customer_id = tokenuser.getEntityId();
|
||||||
}
|
}
|
||||||
|
|
||||||
renderJson(Result.object(OrderTempService.me.find(pp, sn, truck_license, supermarket_id, customer_id, customer_name, stm, etm, isprepaid, state, invoice_code, product_id)));
|
renderJson(Result.object(OrderTempService.me.find(pp, sn, truck_license, supermarket_id, customer_id, customer_name, stm, etm, isprepaid, state, invoice_code, invoice_type, product_id, invoice_code_is_null)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue