lisai17@sina.com 2020-09-16 23:30:17 +08:00
parent b701afcbfd
commit ec1244d27a
21 changed files with 156 additions and 67 deletions

View File

@ -21,19 +21,26 @@ import java.util.List;
public class InvoiceLogService extends BaseService { public class InvoiceLogService extends BaseService {
public static final InvoiceLogService me = new InvoiceLogService(); public static final InvoiceLogService me = new InvoiceLogService();
public Page<Record> find(PageParam pp, Integer state, String order_sn, String stm, String etm, String code, Integer invoice_type) { public Page<Record> find(PageParam pp, Integer supermarket_id, Integer state, String order_sn, String stm, String etm, String code, Integer invoice_type) {
String selectsql = "select t.*, \n" + String selectsql = "select t.*, r.supermarket_id, s.name supermarket_name, \n" +
" case when t.type = 1 then s.weight when t.type = 3 then p.weight end weight, \n" + " case when t.type = 1 then s.weight when t.type = 3 then p.weight end weight, \n" +
" case when t.type = 1 then s.total_price when t.type = 3 then p.total_price end total_price, \n" + " case when t.type = 1 then s.total_price when t.type = 3 then p.total_price end total_price, \n" +
" case when t.type = 1 then s.create_time when t.type = 3 then p.create_time end create_time, \n" + " case when t.type = 1 then s.create_time when t.type = 3 then p.create_time end create_time, \n" +
" case when t.type = 1 then s.settlement_user_name when t.type = 3 then p.settlement_user_name end settlement_user_name, \n" + " case when t.type = 1 then s.settlement_user_name when t.type = 3 then p.settlement_user_name end settlement_user_name, \n" +
" case when t.type = 1 then s.customer_name when t.type = 3 then p.customer_name end customer_name "; " case when t.type = 1 then s.customer_name when t.type = 3 then p.customer_name end customer_name ";
String fromsql = "from invoice_log t \n" + String fromsql = "from invoice_log t \n" +
" left join invoice_receive r on r.id = t.invoice_receive_id \n" +
" left join supermarket s on s.id = r.supermarket_id \n" +
" left join order_sale s on s.sn = t.order_sn \n" + " left join order_sale s on s.sn = t.order_sn \n" +
" left join order_temp p on p.sn = t.order_sn \n" + " left join order_temp p on p.sn = t.order_sn \n" +
" where 1=1 \n"; " where 1=1 \n";
List<Object> paraList = new ArrayList<>(); List<Object> paraList = new ArrayList<>();
if (supermarket_id != null) {
fromsql += " and r.supermarket_id = ? \n";
paraList.add(supermarket_id);
}
if (state != null) { if (state != null) {
fromsql += " and t.state = ? \n"; fromsql += " and t.state = ? \n";
paraList.add(state); paraList.add(state);

View File

@ -58,6 +58,7 @@ public class InvoiceReceiveService extends BaseService {
/** /**
* *
* TODO: * TODO:
*
* @param supermarket_id * @param supermarket_id
* @return * @return
*/ */
@ -67,13 +68,38 @@ public class InvoiceReceiveService extends BaseService {
return nextInvoice(receive); return nextInvoice(receive);
} }
public Page<Record> find(PageParam pp) { public Page<Record> find(PageParam pp, Integer supermarket_id, String reveiver_user_name, String stm, String etm, Integer invoice_type) {
String selectsql = "select t.*, s.name supermarket_name, s.name2 supermarket_name2 "; String selectsql = "select t.*, s.name supermarket_name, s.name2 supermarket_name2 ";
String fromsql = "from invoice_receive t \n" + String fromsql = "from invoice_receive t \n" +
" left join supermarket s on s.id = t.supermarket_id" + " left join supermarket s on s.id = t.supermarket_id" +
" where 1=1 "; " where 1=1 ";
List<Object> paraList = new ArrayList<>(); List<Object> paraList = new ArrayList<>();
if (supermarket_id != null) {
fromsql += " and t.supermarket_id = ? \n";
paraList.add(supermarket_id);
}
if(StrKit.notBlank(reveiver_user_name)){
fromsql += " and t.receive_user_name like ? \n";
paraList.add("%" + reveiver_user_name + "%");
}
if(StrKit.notBlank(stm)){
fromsql += " and t.create_time >= ? \n";
paraList.add(stm);
}
if(StrKit.notBlank(etm)){
fromsql += " and t.create_time <= ? \n";
paraList.add(etm);
}
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;

View File

@ -110,7 +110,7 @@ public class OrderclusterService extends BaseService {
findSql += " " + Const.ORDER_BY_DESC; findSql += " " + Const.ORDER_BY_DESC;
} }
} else { } else {
findSql += " order by t.cutoff_time desc"; findSql += " order by t.create_time desc";
} }
Page<Record> page = Db.paginateByFullSql(pp.getPage(), pp.getSize(), totalRowSql, findSql, paraList.toArray()); Page<Record> page = Db.paginateByFullSql(pp.getPage(), pp.getSize(), totalRowSql, findSql, paraList.toArray());
@ -191,7 +191,7 @@ public class OrderclusterService extends BaseService {
findSql += " " + Const.ORDER_BY_DESC; findSql += " " + Const.ORDER_BY_DESC;
} }
} else { } else {
findSql += " order by t.cutoff_time desc"; findSql += " order by t.create_time desc";
} }
Page<Record> page = Db.paginateByFullSql(pp.getPage(), pp.getSize(), totalRowSql, findSql, paraList.toArray()); Page<Record> page = Db.paginateByFullSql(pp.getPage(), pp.getSize(), totalRowSql, findSql, paraList.toArray());
@ -271,6 +271,8 @@ public class OrderclusterService extends BaseService {
} else { } else {
findSql += " " + Const.ORDER_BY_DESC; findSql += " " + Const.ORDER_BY_DESC;
} }
} else {
findSql += " order by t.create_time desc ";
} }
Page<Record> page = Db.paginateByFullSql(pp.getPage(), pp.getSize(), totalRowSql, findSql, paraList.toArray()); Page<Record> page = Db.paginateByFullSql(pp.getPage(), pp.getSize(), totalRowSql, findSql, paraList.toArray());
@ -569,6 +571,7 @@ public class OrderclusterService extends BaseService {
/** /**
* *
*
* @param ordercluster_id * @param ordercluster_id
* @return * @return
*/ */

View File

@ -211,7 +211,7 @@ public class DeviceThread extends Thread {
throw new IllegalArgumentException(scaleId + " does not exist"); throw new IllegalArgumentException(scaleId + " does not exist");
} }
return this.scaleMap.get(scaleId).weigh(); return this.scaleMap.get(scaleId).weigh15();
} }
public void print(String printerId, File file) throws IOException { public void print(String printerId, File file) throws IOException {

View File

@ -23,7 +23,7 @@ public abstract class AbsScale extends Device {
try { try {
socket = new Socket(); socket = new Socket();
socket.setSoTimeout(1000); socket.setSoTimeout(1000);
socket.connect(new InetSocketAddress(getIp(), getPort()), 3000); socket.connect(new InetSocketAddress(getIp(), getPort()), 5000);
return true; return true;
} finally { } finally {

View File

@ -175,7 +175,7 @@ public class LED extends Device {
try { try {
socket = new Socket(); socket = new Socket();
socket.setSoTimeout(1000); socket.setSoTimeout(1000);
socket.connect(new InetSocketAddress(getIp(), getPort()), 3000); socket.connect(new InetSocketAddress(getIp(), getPort()), 5000);
} finally { } finally {
lock.unlock(); lock.unlock();
} }

View File

@ -71,16 +71,16 @@ public class LEDThread extends Device implements Runnable {
while (this.running){ while (this.running){
try { try {
setWeightInfo("鄂A7D1P1", df.format(new Date())); // // 发送测试消息 setWeightInfo("鄂A7D1P1", df.format(new Date()));
screen(); screen();
Thread.sleep(1000); Thread.sleep(5000);
}catch (Exception e){ }catch (Exception e){
log.error(e.getMessage(), e); log.error(e.getMessage(), e);
} }
System.out.println("running" + running); // System.out.println("running" + running);
} }
System.out.println("led 线程退出"); System.out.println("led 线程退出");
@ -126,7 +126,7 @@ public class LEDThread extends Device implements Runnable {
msgCrc[msgCrc.length - 3] = (byte) crc; msgCrc[msgCrc.length - 3] = (byte) crc;
msgCrc[msgCrc.length - 1] = frameTail; msgCrc[msgCrc.length - 1] = frameTail;
System.out.println("LED 发送数据:" + HexDump.toHex(msgCrc)); // System.out.println(getId() + " LED 发送数据:" + HexDump.toHex(msgCrc));
socket.getOutputStream().write(msgCrc); socket.getOutputStream().write(msgCrc);
socket.getOutputStream().flush(); socket.getOutputStream().flush();
@ -143,7 +143,7 @@ public class LEDThread extends Device implements Runnable {
} }
byte[] z = new byte[read]; byte[] z = new byte[read];
System.arraycopy(y, 0, z, 0, read); System.arraycopy(y, 0, z, 0, read);
System.out.println("LED 返回数据:" + HexDump.toHex(z)); // System.out.println(getId() + " LED 返回数据:" + HexDump.toHex(z));
// socket.close(); // socket.close();
} catch (Exception e) { } catch (Exception e) {
log.error(e.getMessage(), e); log.error(e.getMessage(), e);
@ -230,7 +230,7 @@ public class LEDThread extends Device implements Runnable {
try { try {
socket = new Socket(); socket = new Socket();
socket.setSoTimeout(1000); socket.setSoTimeout(1000);
socket.connect(new InetSocketAddress(getIp(), getPort()), 3000); socket.connect(new InetSocketAddress(getIp(), getPort()), 5000);
} finally { } finally {
lock.unlock(); lock.unlock();
} }
@ -275,7 +275,7 @@ public class LEDThread extends Device implements Runnable {
try { try {
socket = new Socket(); socket = new Socket();
socket.setSoTimeout(1000); socket.setSoTimeout(1000);
socket.connect(new InetSocketAddress(getIp(), getPort()), 3000); socket.connect(new InetSocketAddress(getIp(), getPort()), 5000);
} catch (Exception e) { } catch (Exception e) {
log.error(e.getMessage(), e); log.error(e.getMessage(), e);
} finally { } finally {
@ -287,7 +287,7 @@ public class LEDThread extends Device implements Runnable {
public static void main(String[] args) { public static void main(String[] args) {
try { try {
LEDThread led = new LEDThread("", "192.168.30.205", 5005); LEDThread led = new LEDThread("", "192.168.20.52", 5005);
Thread thread = new Thread(led); Thread thread = new Thread(led);
thread.setDaemon(true); thread.setDaemon(true);
thread.start(); thread.start();

View File

@ -64,7 +64,7 @@ public class PLC extends Device {
socket.setSoLinger(false, 0); socket.setSoLinger(false, 0);
socket.setKeepAlive(true); socket.setKeepAlive(true);
socket.setSoTimeout(3000); socket.setSoTimeout(3000);
socket.connect(new InetSocketAddress(getIp(), getPort()), 3000); socket.connect(new InetSocketAddress(getIp(), getPort()), 5000);
int crc = CRC16.calcCrc16(presetRead); int crc = CRC16.calcCrc16(presetRead);
byte[] data = new byte[presetRead.length + 2]; byte[] data = new byte[presetRead.length + 2];
@ -259,7 +259,7 @@ public class PLC extends Device {
PLC plc = new PLC("_plc", "192.168.20.20", 502, com.cowr.local.ssjygl.devicectrl.common.DeviceThread.defaultAddressTable); PLC plc = new PLC("_plc", "192.168.20.20", 502, com.cowr.local.ssjygl.devicectrl.common.DeviceThread.defaultAddressTable);
plc.connect(); plc.connect();
plc.isConnected(); plc.isConnected();
plc.write("rodIn2Up"); plc.write("rodIn2Down");
// plc.write("rodOut2Up"); // plc.write("rodOut2Up");
// plc.write("sensorIn2Reset"); // plc.write("sensorIn2Reset");

View File

@ -28,7 +28,7 @@ public class Printer {
socket.setSoLinger(false, 0); socket.setSoLinger(false, 0);
socket.setKeepAlive(false); socket.setKeepAlive(false);
socket.setSoTimeout(15000); socket.setSoTimeout(15000);
socket.connect(new InetSocketAddress(ip, port), 3000); socket.connect(new InetSocketAddress(ip, port), 5000);
FileInputStream fis = new FileInputStream(file); FileInputStream fis = new FileInputStream(file);
OutputStream out = socket.getOutputStream(); OutputStream out = socket.getOutputStream();

View File

@ -35,13 +35,14 @@ public class InvoiceLogController extends Controller {
*/ */
public void find() { public void find() {
PageParam pp = getBean(PageParam.class, "", true); PageParam pp = getBean(PageParam.class, "", true);
Integer supermarket_id = getInt("supermarket_id");
Integer state = getInt("state"); Integer state = getInt("state");
String order_sn = get("order_sn"); String order_sn = get("order_sn");
String stm = get("stm"); String stm = get("stm");
String etm = get("etm"); String etm = get("etm");
String code = get("code"); String code = get("code");
Integer invoice_type = getInt("invoice_type"); Integer invoice_type = getInt("invoice_type");
renderJson(Result.object(InvoiceLogService.me.find(pp, state, order_sn, stm, etm, code, invoice_type))); renderJson(Result.object(InvoiceLogService.me.find(pp, supermarket_id, state, order_sn, stm, etm, code, invoice_type)));
} }
/** /**

View File

@ -33,7 +33,12 @@ public class InvoiceReceiveController extends Controller {
*/ */
public void find() { public void find() {
PageParam pp = getBean(PageParam.class, "", true); PageParam pp = getBean(PageParam.class, "", true);
renderJson(Result.object(InvoiceReceiveService.me.find(pp))); Integer supermarket_id = getInt("supermarket_id");
String reveiver_user_name = get("reveiver_user_name");
String stm = get("stm");
String etm = get("etm");
Integer invoice_type = getInt("invoice_type");
renderJson(Result.object(InvoiceReceiveService.me.find(pp, supermarket_id, reveiver_user_name, stm, etm, invoice_type)));
} }
/** /**

View File

@ -141,7 +141,7 @@ public class OrderService {
out.set("pay", ret); // 支付结果 out.set("pay", ret); // 支付结果
if (ret) { if (ret) {
if (req_receipt == 1) { // if (req_receipt == 1) {
try { try {
printdata.set("first_weight", transport.getFirstWeight()); printdata.set("first_weight", transport.getFirstWeight());
printdata.set("second_weight", transport.getSecondWeight()); printdata.set("second_weight", transport.getSecondWeight());
@ -152,7 +152,7 @@ public class OrderService {
out.set("print", "打印指令发送失败"); out.set("print", "打印指令发送失败");
log.error(e.getMessage(), e); log.error(e.getMessage(), e);
} }
} // }
try { try {
if (transport.getTruckLicense().equals(Config.deviceThread.getCtrlCurrentLicense(transport.getOutWhich()))) { if (transport.getTruckLicense().equals(Config.deviceThread.getCtrlCurrentLicense(transport.getOutWhich()))) {

View File

@ -251,11 +251,6 @@ public class OrderTempSyncService {
return Result.failedstr("集团订单【%s】信息不存在", ordercluster_id); return Result.failedstr("集团订单【%s】信息不存在", ordercluster_id);
} }
Customer customer = Customer.dao.findById(ordercluster.getCustomerId());
if (customer == null) {
return Result.failed("未找到关联客户信息");
}
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()));
} }
@ -310,7 +305,7 @@ public class OrderTempSyncService {
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, overweight); return Result.failedstr("净重 %.2f 吨,超过了剩余的 %.2f 余量", net_weight, ordercluster.getTotalWeight().subtract(overweight));
} }
// if (req_receipt == 1) { // 需要同时开具发票 // if (req_receipt == 1) { // 需要同时开具发票
@ -334,6 +329,8 @@ public class OrderTempSyncService {
order.setOrderclusterId(ordercluster_id); order.setOrderclusterId(ordercluster_id);
// 客户信息 // 客户信息
Customer customer = Customer.dao.findById(ordercluster.getCustomerId());
if (customer != null) {
order.setCustomerId(customer.getId()); order.setCustomerId(customer.getId());
order.setCustomerAddress(customer.getAddress()); order.setCustomerAddress(customer.getAddress());
order.setCustomerBankAccount(customer.getBankAccount()); order.setCustomerBankAccount(customer.getBankAccount());
@ -342,6 +339,17 @@ public class OrderTempSyncService {
order.setCustomerPhone(customer.getPhone()); order.setCustomerPhone(customer.getPhone());
order.setCustomerTexpayerName(customer.getTexpayerName()); order.setCustomerTexpayerName(customer.getTexpayerName());
order.setCustomerTexpayerNum(customer.getTexpayerNum()); order.setCustomerTexpayerNum(customer.getTexpayerNum());
} else {
order.setCustomerId(ordercluster.getCustomerId());
order.setCustomerAddress(ordercluster.getCustomerAddress());
order.setCustomerBankAccount(ordercluster.getCustomerBankAccount());
order.setCustomerBankName(ordercluster.getCustomerBankName());
order.setCustomerName(ordercluster.getCustomerName());
order.setCustomerPhone(ordercluster.getCustomerPhone());
order.setCustomerTexpayerName(ordercluster.getCustomerTexpayerName());
order.setCustomerTexpayerNum(ordercluster.getCustomerTexpayerNum());
}
// 物流公司信息 // 物流公司信息
order.setTransCoId(ordercluster.getTransCoId()); order.setTransCoId(ordercluster.getTransCoId());

View File

@ -269,6 +269,24 @@ public class TransportController extends BaseController {
renderJson(result ? Result.success(true) : Result.failed("抬闸失败")); renderJson(result ? Result.success(true) : Result.failed("抬闸失败"));
} }
public void cmdScale() {
Sysuser tokenuser = SysuserSyncService.me.getSysuserByToken(get("token"));
if (tokenuser == null) {
renderJson(Result.permissionDenied());
return;
}
String which = get("which"); // Enums.WhichEnum R01 入场流程 C01 出场流程
if (StrKit.notBlank(which)) {
which = which.toUpperCase();
}
double result = TransportDeviceService.me.cmdScale(which, tokenuser);
renderJson(Result.success(result));
}
@Before(TransportIdValidator.class) @Before(TransportIdValidator.class)
public void cancel() { public void cancel() {
Sysuser tokenuser = SysuserSyncService.me.getSysuserByToken(get("token")); Sysuser tokenuser = SysuserSyncService.me.getSysuserByToken(get("token"));

View File

@ -249,6 +249,21 @@ public class TransportDeviceService {
} }
} }
public double cmdScale(String which, Sysuser sysuser){
Record cmdlog = new Record();
cmdlog.set("cmd", "scale");
cmdlog.set("which", which);
try{
ActionCmdLogService.me.save(cmdlog.toJson(), sysuser);
return Config.deviceThread.scale(which);
}catch (Exception e){
log.error(e.getMessage(), e);
return 0.0;
}
}
/** /**
* *
* @param which * @param which

View File

@ -10,7 +10,7 @@ socketserver.port=21002
socketio.port=12002 socketio.port=12002
#当前部署本地程序的砂站id #当前部署本地程序的砂站id
current.supermarket_id=6 current.supermarket_id=2
#打印用到的配置信息 #打印用到的配置信息
print.vendor=浠水县长投环保有限公司 print.vendor=浠水县长投环保有限公司

View File

@ -1,12 +1,12 @@
# mysql # mysql
# GRANT ALL PRIVILEGES ON *.* TO 'root'@'192.168.1.119' IDENTIFIED BY 'Local_1' WITH GRANT OPTION; # GRANT ALL PRIVILEGES ON *.* TO 'root'@'192.168.1.119' IDENTIFIED BY 'Local_1' WITH GRANT OPTION;
jdbcUrl=jdbc:mysql://rm-wz9wa070076b2uge2ro.mysql.rds.aliyuncs.com:3306/ssjy_xsx_dev?characterEncoding=utf8&useSSL=false&zeroDateTimeBehavior=convertToNull&useInformationSchema=true&serverTimezone=GMT%2B8&autoReconnect=true #jdbcUrl=jdbc:mysql://rm-wz9wa070076b2uge2ro.mysql.rds.aliyuncs.com:3306/ssjy_xsx_dev?characterEncoding=utf8&useSSL=false&zeroDateTimeBehavior=convertToNull&useInformationSchema=true&serverTimezone=GMT%2B8&autoReconnect=true
user=dev_ssjy_xsx #user=dev_ssjy_xsx
password=Ssjy_xs_890 #password=Ssjy_xs_890
#jdbcUrl=jdbc:mysql://localhost:3306/ssjy_xsx_dev?characterEncoding=utf8&useSSL=false&zeroDateTimeBehavior=convertToNull&useInformationSchema=true&serverTimezone=GMT%2B8&autoReconnect=true jdbcUrl=jdbc:mysql://192.168.20.2:3306/ssjy_xsx_dev?characterEncoding=utf8&useSSL=false&zeroDateTimeBehavior=convertToNull&useInformationSchema=true&serverTimezone=GMT%2B8&autoReconnect=true
#user=root user=root
#password=Ssjy_xsx_890 password=Ssjy_xsx_890
# redis # redis
redis.basekey=ssjcgl_xsx_dev redis.basekey=ssjcgl_xsx_dev

View File

@ -34,13 +34,14 @@ public class InvoiceLogController extends Controller {
*/ */
public void find() { public void find() {
PageParam pp = getBean(PageParam.class, "", true); PageParam pp = getBean(PageParam.class, "", true);
Integer supermarket_id = getInt("supermarket_id");
Integer state = getInt("state"); Integer state = getInt("state");
String order_sn = get("order_sn"); String order_sn = get("order_sn");
String stm = get("stm"); String stm = get("stm");
String etm = get("etm"); String etm = get("etm");
String code = get("code"); String code = get("code");
Integer invoice_type = getInt("invoice_type"); Integer invoice_type = getInt("invoice_type");
renderJson(Result.object(InvoiceLogService.me.find(pp, state, order_sn, stm, etm, code, invoice_type))); renderJson(Result.object(InvoiceLogService.me.find(pp, supermarket_id, state, order_sn, stm, etm, code, invoice_type)));
} }
/** /**

View File

@ -100,7 +100,12 @@ public class InvoiceReceiveController extends Controller {
*/ */
public void find(){ public void find(){
PageParam pp = getBean(PageParam.class, "", true); PageParam pp = getBean(PageParam.class, "", true);
renderJson(Result.object(InvoiceReceiveService.me.find(pp))); Integer supermarket_id = getInt("supermarket_id");
String reveiver_user_name = get("reveiver_user_name");
String stm = get("stm");
String etm = get("etm");
Integer invoice_type = getInt("invoice_type");
renderJson(Result.object(InvoiceReceiveService.me.find(pp, supermarket_id, reveiver_user_name, stm, etm, invoice_type)));
} }
/** /**

View File

@ -297,9 +297,9 @@ public class OrderclusterSyncService extends BaseSyncService {
model.setCustomerName(customer_name); model.setCustomerName(customer_name);
// 判断是否需要开具发票 // 判断是否需要开具发票
if (req_receipt == 1) { // if (req_receipt == 1) {
model.setCustomerTexpayerNum(customer_texpayer_num); model.setCustomerTexpayerNum(customer_texpayer_num);
} // }
model.setTransDistance(new BigDecimal(0)); model.setTransDistance(new BigDecimal(0));