This commit is contained in:
zc
2026-03-25 17:36:06 +08:00
parent c4f29d3ee5
commit 402d04294c
43 changed files with 16600 additions and 16581 deletions

View File

@@ -96,6 +96,18 @@
<scope>system</scope>
<systemPath>${project.basedir}/Library/MvCameraControlWrapper.jar</systemPath>
</dependency>
<dependency>
<groupId>com.sun.jna</groupId>
<artifactId>jna</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>${project.basedir}/src/main/resources/lib/jna.jar</systemPath>
</dependency>
<dependency>
<groupId>com.fazecast</groupId>
<artifactId>jSerialComm</artifactId>
<version>2.10.5</version>
</dependency>
</dependencies>
<build>
<finalName>${project.parent.name}</finalName>

View File

@@ -125,6 +125,13 @@
<systemPath>${project.basedir}/src/main/resources/lib/jna.jar</systemPath>
</dependency>
<!-- 串口通信依赖 -->
<dependency>
<groupId>com.fazecast</groupId>
<artifactId>jSerialComm</artifactId>
<version>2.10.5</version>
</dependency>
</dependencies>
<build>

View File

@@ -11,8 +11,6 @@ import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.constraints.NotNull;
import lombok.RequiredArgsConstructor;
import org.dromara.x.file.storage.core.FileInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

View File

@@ -26,6 +26,4 @@ import top.wms.admin.fullWorkOrder.service.FullWorkOrderService;
@CrudRequestMapping(value = "/fullWorkOrder/fullWorkOrder", api = {Api.PAGE, Api.ADD, Api.DELETE, Api.EXPORT})
public class FullWorkOrderController extends BaseController<FullWorkOrderService, FullWorkOrderResp, FullWorkOrderResp, FullWorkOrderQuery, FullWorkOrderReq> {
}

View File

@@ -2,7 +2,6 @@ package top.wms.admin.controller.meterial;
import cn.dev33.satoken.annotation.SaCheckPermission;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
import io.swagger.v3.oas.annotations.Operation;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.constraints.NotNull;
@@ -22,7 +21,6 @@ import top.continew.starter.extension.crud.annotation.CrudRequestMapping;
import top.continew.starter.log.annotation.Log;
import top.continew.starter.web.model.R;
import top.wms.admin.common.controller.BaseController;
import top.wms.admin.material.model.entity.MaterialInfoDO;
import top.wms.admin.material.model.query.MaterialInfoQuery;
import top.wms.admin.material.model.req.MaterialInfoImportReq;
import top.wms.admin.material.model.req.MaterialInfoReq;

View File

@@ -1,6 +1,5 @@
package top.wms.admin.controller.vm;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson2.JSONObject;
import io.netty.channel.Channel;
import lombok.extern.slf4j.Slf4j;

View File

@@ -51,8 +51,6 @@ public class NetCommon {
return true;
}
/**
* Launch the application.
*/
@@ -80,7 +78,6 @@ public class NetCommon {
System.out.println("程序执行完成");
}
/**
* 登录设备
*
@@ -129,13 +126,17 @@ public class NetCommon {
public static void queryChannels() {
int nMaxChlCount = 256;
IntByReference dwChlCount = new IntByReference(nMaxChlCount);
NetDEVSDKLib.NETDEV_VIDEO_CHL_DETAIL_INFO_EX_S[] stVideoChlList = (NetDEVSDKLib.NETDEV_VIDEO_CHL_DETAIL_INFO_EX_S[]) new NetDEVSDKLib.NETDEV_VIDEO_CHL_DETAIL_INFO_EX_S().toArray(nMaxChlCount);
NetDEVSDKLib.NETDEV_VIDEO_CHL_DETAIL_INFO_EX_S[] stVideoChlList = (NetDEVSDKLib.NETDEV_VIDEO_CHL_DETAIL_INFO_EX_S[])new NetDEVSDKLib.NETDEV_VIDEO_CHL_DETAIL_INFO_EX_S()
.toArray(nMaxChlCount);
boolean bRet = netdevsdk.NETDEV_QueryVideoChlDetailListEx(lpUserID, dwChlCount, stVideoChlList);
if (bRet) {
log.info("通道查询成功,通道数量: {}", dwChlCount.getValue());
for (int i = 0; i < dwChlCount.getValue(); i++) {
System.out.println("通道ID: " + stVideoChlList[i].dwChannelID + ", 状态: " + (stVideoChlList[i].enStatus == 1 ? "在线" : "离线") + ", 名称: " + new String(stVideoChlList[i].szChnName).trim());
System.out
.println("通道ID: " + stVideoChlList[i].dwChannelID + ", 状态: " + (stVideoChlList[i].enStatus == 1
? "在线"
: "离线") + ", 名称: " + new String(stVideoChlList[i].szChnName).trim());
}
} else {
log.error("通道查询失败, 错误码:{}", netdevsdk.NETDEV_GetLastError());
@@ -186,7 +187,7 @@ public class NetCommon {
if (captureTimer != null) {
stopCaptureTimer();
}
captureTimer = new Timer();
captureTimer.schedule(new TimerTask() {
@Override
@@ -214,7 +215,7 @@ public class NetCommon {
public static void logoutDevice() {
// 先停止定时抓拍
stopCaptureTimer();
if (null != lpUserID) {
log.info("正在登出设备...");
netdevsdk.NETDEV_Logout(lpUserID);
@@ -231,7 +232,7 @@ public class NetCommon {
public static void cleanupSDK() {
// 先停止定时抓拍
stopCaptureTimer();
log.info("正在释放SDK...");
netdevsdk.NETDEV_Cleanup();
// 清除SDK初始化标志

View File

@@ -3,55 +3,55 @@ package top.wms.admin.controller.ys.lib;
import com.sun.jna.Platform;
class BaseFun {
// 获取操作平台信息
public static String getOsArch() {
String arch = System.getProperty("os.arch").toLowerCase();
final String name = System.getProperty("os.name");
String osArch;
switch(Platform.getOSType()) {
case Platform.WINDOWS: {
if ("i386".equals(arch))
arch = "x86";
else if ("x86_64".equals(arch)) {
arch = "amd64";
}
osArch = "win32-" + arch;
}
break;
default: {
osArch = name.toLowerCase();
if ("x86".equals(arch)) {
arch = "i386";
}
if ("x86_64".equals(arch)) {
arch = "amd64";
}
int space = osArch.indexOf(" ");
if (space != -1) {
osArch = osArch.substring(0, space);
}
osArch += "-" + arch;
}
break;
}
// 获取操作平台信息
public static String getOsArch() {
String arch = System.getProperty("os.arch").toLowerCase();
final String name = System.getProperty("os.name");
String osArch;
switch (Platform.getOSType()) {
case Platform.WINDOWS: {
if ("i386".equals(arch))
arch = "x86";
else if ("x86_64".equals(arch)) {
arch = "amd64";
}
osArch = "win32-" + arch;
}
break;
default: {
osArch = name.toLowerCase();
if ("x86".equals(arch)) {
arch = "i386";
}
if ("x86_64".equals(arch)) {
arch = "amd64";
}
int space = osArch.indexOf(" ");
if (space != -1) {
osArch = osArch.substring(0, space);
}
osArch += "-" + arch;
}
break;
return osArch;
}
//获取加载SDK库
public static String LoadSDKLibrary() {
String filePath = System.getProperty("user.dir").replaceFirst("/","").replaceAll("%20"," ");
String loadLibrary = "";
String OsArch = getOsArch();
if(OsArch.toLowerCase().startsWith("win32-x86")) {
loadLibrary = filePath + "\\wms-webapi\\src\\main\\resources\\lib\\win32\\";
} else if(OsArch.toLowerCase().startsWith("win32-amd64") ) {
loadLibrary = filePath + "\\wms-webapi\\src\\main\\resources\\lib\\win64\\";
}
String loadSDKLibrary = loadLibrary + "NetDEVSDK";
System.out.printf("[Load SDKLibrary Path : %s]\n", loadSDKLibrary);
return loadSDKLibrary;
}
}
return osArch;
}
//获取加载SDK库
public static String LoadSDKLibrary() {
String filePath = System.getProperty("user.dir").replaceFirst("/", "").replaceAll("%20", " ");
String loadLibrary = "";
String OsArch = getOsArch();
if (OsArch.toLowerCase().startsWith("win32-x86")) {
loadLibrary = filePath + "\\wms-webapi\\src\\main\\resources\\lib\\win32\\";
} else if (OsArch.toLowerCase().startsWith("win32-amd64")) {
loadLibrary = filePath + "\\wms-webapi\\src\\main\\resources\\lib\\win64\\";
}
String loadSDKLibrary = loadLibrary + "NetDEVSDK";
System.out.printf("[Load SDKLibrary Path : %s]\n", loadSDKLibrary);
return loadSDKLibrary;
}
}

View File

@@ -4,22 +4,21 @@ import javax.swing.table.DefaultTableModel;
import java.util.Vector;
public class CheckTableModle extends DefaultTableModel {
public CheckTableModle(Vector data, Vector columnNames) {
super(data, columnNames);
}
public CheckTableModle(Vector data, Vector columnNames) {
super(data, columnNames);
}
// /**
// * 根据类型返回显示空间
// * 布尔类型返回显示checkbox
// */
public Class getColumnClass(int c) {
return getValueAt(0, c).getClass();
}
public void selectAllOrNull(boolean value) {
for (int i = 0; i < getRowCount(); i++) {
this.setValueAt(value, i, 0);
}
}
// /**
// * 根据类型返回显示空间
// * 布尔类型返回显示checkbox
// */
public Class getColumnClass(int c) {
return getValueAt(0, c).getClass();
}
public void selectAllOrNull(boolean value) {
for (int i = 0; i < getRowCount(); i++) {
this.setValueAt(value, i, 0);
}
}
}

View File

@@ -3,39 +3,38 @@ package top.wms.admin.controller.ys.utils;
import javax.swing.*;
import javax.swing.table.TableCellEditor;
public class ComboBoxTable extends JTable {
/**
* 序列化
*/
private static final long serialVersionUID = 1L;
private int myRow = -1, myCol = -1;
TableCellEditor myEditor;
/**
* 序列化
*/
private static final long serialVersionUID = 1L;
private int myRow = -1, myCol = -1;
TableCellEditor myEditor;
public void setComboCell(int r, int c, String[]items) {
this.myRow = r;
this.myCol = c;
TableCellEditor ce = new MyComboBoxEditor(items);
this.myEditor = ce;
}
public void setComboCell(int r, int c, String[] items) {
this.myRow = r;
this.myCol = c;
TableCellEditor ce = new MyComboBoxEditor(items);
this.myEditor = ce;
}
@Override
public TableCellEditor getCellEditor(int row, int column) {
System.out.println(row + "," + column + ";" + myRow + "," + myCol + "," + myEditor);
if (row == myRow && column == myCol && myEditor != null)
return myEditor;
return super.getCellEditor(row, column);
}
@Override
public TableCellEditor getCellEditor(int row, int column) {
System.out.println(row + "," + column + ";" + myRow + "," + myCol + "," + myEditor);
if (row == myRow && column == myCol && myEditor != null)
return myEditor;
return super.getCellEditor(row, column);
}
class MyComboBoxEditor extends DefaultCellEditor {
/**
*
*/
private static final long serialVersionUID = 1L;
class MyComboBoxEditor extends DefaultCellEditor {
/**
*
*/
private static final long serialVersionUID = 1L;
public MyComboBoxEditor(String[] items) {
super(new JComboBox(items));
}
}
public MyComboBoxEditor(String[] items) {
super(new JComboBox(items));
}
}
}

View File

@@ -1,6 +1,5 @@
package top.wms.admin.controller.ys.utils;
import javax.swing.*;
import javax.swing.border.LineBorder;
import javax.swing.event.ChangeEvent;
@@ -11,486 +10,459 @@ import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
public class DateChooser extends JPanel
{
private int width = 200 ; // 日期控件的
private int height = 220 ; // 日期控件的高度
public class DateChooser extends JPanel {
private int width = 200; // 日期控件的宽度
private int height = 220; // 日期控件的
private GridBagLayout gridBagLayout1 = new GridBagLayout();
public JTextField jTextFieldDate = new JTextField();
private DateChooserButton btnChoose = new DateChooserButton(""); // ▼是指▼下拉箭头的unicode码
private String parten;
private Container owner;
private int length = 140;
private GridBagLayout gridBagLayout1 = new GridBagLayout();
public JTextField jTextFieldDate = new JTextField();
private DateChooserButton btnChoose = new DateChooserButton( "" ); // ▼是指▼下拉箭头的unicode码
private String parten;
private Container owner;
private int length = 140 ;
/**
* @wbp.parser.constructor
*/
public DateChooser(Container owner, int length) {
this .owner = owner;
this .parten = " yyyy-MM-dd HH:mm:ss " ;
this .length = length;
try {
init();
}
catch (Exception ex) {
ex.printStackTrace();
}
}
public DateChooser(Container owner, int length) {
this.owner = owner;
this.parten = " yyyy-MM-dd HH:mm:ss ";
this.length = length;
try {
init();
} catch (Exception ex) {
ex.printStackTrace();
}
}
/* *
* 根据一个所有者和一个日期的显示格式构造一个DateChooser对象。
*/
public DateChooser(Container owner, String partten, int length) {
this .owner = owner;
this .parten = partten;
this .length = length;
try {
init();
}
catch (Exception ex) {
ex.printStackTrace();
}
}
public DateChooser(Container owner, String partten, int length) {
this.owner = owner;
this.parten = partten;
this.length = length;
try {
init();
} catch (Exception ex) {
ex.printStackTrace();
}
}
/* *
* 根据一个所有者和一个日期的显示格式构造一个DateChooser对象。
*/
public DateChooser(Container owner, String partten) {
this .owner = owner;
this .parten = partten;
try {
init();
}
catch (Exception ex) {
ex.printStackTrace();
}
this.owner = owner;
this.parten = partten;
try {
init();
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
/* *
* 以缺省的partten构建DateChooser对象
* 日期选择框的所有者必须是Frame或者是JFrame对象。
*/
public DateChooser(Container owner) {
this .owner = owner;
this .parten = " yyyy-MM-dd HH:mm:ss" ;
try {
init();
}
catch (Exception ex) {
ex.printStackTrace();
}
}
this.owner = owner;
this.parten = " yyyy-MM-dd HH:mm:ss";
try {
init();
} catch (Exception ex) {
ex.printStackTrace();
}
}
/* *
* 系统初始化
* @throws Exception
*/
private void init() throws Exception {
private void init() throws Exception {
jTextFieldDate.setColumns(10);
jTextFieldDate.setEditable(true);
jTextFieldDate.setEnabled(true);
jTextFieldDate.setToolTipText( " 单击右边的按钮即可选择日期 " );
btnChoose.setToolTipText( " 单击即可选择日期 " );
this .setLayout(gridBagLayout1);
// dateField.setEditable( false );
btnChoose.addActionListener( new ActionListener() {
public void actionPerformed(ActionEvent e) {
DateChooser. this .btnChoose_actionPerformed(e);
}
});
Date date = new Date();
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(parten);
this .setText(simpleDateFormat.format(date));
this .add(jTextFieldDate, new GridBagConstraints( 0 , 0 , 1 , 1 , 20.0 , 0.0
, GridBagConstraints.CENTER,
GridBagConstraints.NONE,
new Insets( 0 , 0 , 0 , 0 ), 60, 0 ));
this .add(btnChoose, new GridBagConstraints( 1 , 0 , 1 , 1 , 0.0 , 0.0
, GridBagConstraints.CENTER, GridBagConstraints.NONE,
new Insets( 0 , 0 , 0 , 0 ), 0 , 0 ));
}
public void setToolTipText(String text) {
jTextFieldDate.setToolTipText(" 单击右边的按钮即可选择日期 ");
btnChoose.setToolTipText(" 单击即可选择日期 ");
this.setLayout(gridBagLayout1);
// dateField.setEditable( false );
btnChoose.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
DateChooser.this.btnChoose_actionPerformed(e);
}
});
Date date = new Date();
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(parten);
this.setText(simpleDateFormat.format(date));
this.add(jTextFieldDate, new GridBagConstraints(0, 0, 1, 1, 20.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 60, 0));
this.add(btnChoose, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
}
public void setToolTipText(String text) {
jTextFieldDate.setToolTipText(text);
jTextFieldDate.setToolTipText(text);
}
}
/* *
* 下拉按钮的事件处理
* @param e ActionEvent
*/
public void btnChoose_actionPerformed(ActionEvent e) {
Rectangle r = jTextFieldDate.getBounds();
Point pOnScreen = jTextFieldDate.getLocationOnScreen();
public void btnChoose_actionPerformed(ActionEvent e) {
Rectangle r = jTextFieldDate.getBounds();
Point pOnScreen = jTextFieldDate.getLocationOnScreen();
Point result = new Point(pOnScreen.x, pOnScreen.y+20 );
// Point powner = owner.getLocation();
// int offsetX = (pOnScreen.x + width) - (powner.x + owner.getWidth());
// int offsetY = (pOnScreen.y + r.height + height) -
// (powner.y + owner.getHeight());
//
// if (offsetX > 0 ) {
// result.x -= offsetX;
// }
//
// if (offsetY > 0 ) {
// result.y -= height + r.height;
// }
Point result = new Point(pOnScreen.x, pOnScreen.y + 20);
// Point powner = owner.getLocation();
// int offsetX = (pOnScreen.x + width) - (powner.x + owner.getWidth());
// int offsetY = (pOnScreen.y + r.height + height) -
// (powner.y + owner.getHeight());
//
// if (offsetX > 0 ) {
// result.x -= offsetX;
// }
//
// if (offsetY > 0 ) {
// result.y -= height + r.height;
// }
JDialog dateFrame = new JDialog();
dateFrame.setModal( false );
dateFrame.setUndecorated( true );
dateFrame.setLocation(result);
dateFrame.setSize(width, height);
JDialog dateFrame = new JDialog();
dateFrame.setModal(false);
dateFrame.setUndecorated(true);
dateFrame.setLocation(result);
dateFrame.setSize(width, height);
dateFrame.addWindowListener( new WindowAdapter() {
dateFrame.addWindowListener(new WindowAdapter() {
// 在任意的非日期选择区单击,则日期选择组件将变为非活动状态,自动释放资源。
public void windowDeactivated(WindowEvent e) {
JDialog f = (JDialog) e.getSource();
f.dispose();
}
});
DatePanel datePanel = new DatePanel(dateFrame, parten);
dateFrame.getContentPane().setLayout( new BorderLayout());
dateFrame.getContentPane().add(datePanel);
dateFrame.setVisible( true );
}
public void windowDeactivated(WindowEvent e) {
JDialog f = (JDialog)e.getSource();
f.dispose();
}
});
DatePanel datePanel = new DatePanel(dateFrame, parten);
dateFrame.getContentPane().setLayout(new BorderLayout());
dateFrame.getContentPane().add(datePanel);
dateFrame.setVisible(true);
}
/* *
* 得到日期控件中的值
* @return String
*/
public String getText() {
return this .jTextFieldDate.getText();
}
public String getText() {
return this.jTextFieldDate.getText();
}
/* *
* 设置文本域的值
* @param text String
*/
public void setText(String text) {
this .jTextFieldDate.setText(text);
}
public void setText(String text) {
this.jTextFieldDate.setText(text);
}
/* *
* 该方法非常有用是外部直接访问的TextField对象。
* @return JTextField
*/
public JTextField getDateField() {
return jTextFieldDate;
}
public JTextField getDateField() {
return jTextFieldDate;
}
/* *
* 内部类日期选择控件的主体封装了所有日期选择的内容主要是一个Panel
*/
class DatePanel
extends JPanel implements MouseListener,
ChangeListener {
class DatePanel extends JPanel implements MouseListener, ChangeListener {
int startYear = 1970 ; // 默认【最小】显示年份
int lastYear = 2050 ; // 默认【最大】显示年份
int startYear = 1970; // 默认【最小】显示年份
int lastYear = 2050; // 默认【最大】显示年份
Color backGroundColor = Color.gray; // 底色
// 月历表格配色---------------- //
Color palletTableColor = Color.white; // 日历表底色
Color weekFontColor = Color.blue; // 星期文字色
Color dateFontColor = Color.black; // 日期文字色
Color weekendFontColor = Color.red; // 周末文字色
Color moveButtonColor = Color.GREEN; // 鼠标移动的日历底色
Color todayBtnColor = Color.pink; // 今天的日历底色
// 控制条配色------------------ //
Color controlLineColor = Color.pink; // 控制条底色
Color controlTextColor = Color.white; // 控制条标签文字色
Color backGroundColor = Color.gray; // 底色
// 月历表格配色---------------- //
Color palletTableColor = Color.white; // 日历表底色
Color weekFontColor = Color.blue; // 星期文字色
Color dateFontColor = Color.black; // 日期文字色
Color weekendFontColor = Color.red; // 周末文字色
Color moveButtonColor = Color.GREEN; // 鼠标移动的日历底色
Color todayBtnColor = Color.pink; // 今天的日历底色
// 控制条配色------------------ //
Color controlLineColor = Color.pink; // 控制条底色
Color controlTextColor = Color.white; // 控制条标签文字色
JSpinner yearSpin;
JSpinner monthSpin;
JSpinner hourSpin;
JButton[][] daysButton = new JButton[ 6 ][ 7 ];
JSpinner yearSpin;
JSpinner monthSpin;
JSpinner hourSpin;
JButton[][] daysButton = new JButton[6][7];
JDialog f;
JDialog f;
JPanel dayPanel = new JPanel(); // 日期panel
JPanel yearPanel = new JPanel();
JPanel dayPanel = new JPanel(); // 日期panel
JPanel yearPanel = new JPanel();
Calendar calendar = Calendar.getInstance();
String pattern;
Calendar calendar = Calendar.getInstance();
String pattern;
/* *
* 日期选择控件放在了非模态对话框中
*/
public DatePanel(JDialog target, String pattern) {
super();
public DatePanel(JDialog target, String pattern) {
super();
this .f = target;
this .pattern = pattern;
this.f = target;
this.pattern = pattern;
setLayout( new BorderLayout());
setBorder( new LineBorder(backGroundColor, 2 ));
setBackground(backGroundColor);
initButton(); // 初始化放置日期的按钮。
createYearAndMonthPanal(); //
this .flushWeekAndDayPanal(calendar); // 之前必须先保证放置日期的按钮已经初始化。
this .setLayout( new BorderLayout());
this .add(yearPanel, BorderLayout.NORTH);
this .add(dayPanel, BorderLayout.CENTER);
}
setLayout(new BorderLayout());
setBorder(new LineBorder(backGroundColor, 2));
setBackground(backGroundColor);
initButton(); // 初始化放置日期的按钮。
createYearAndMonthPanal(); //
this.flushWeekAndDayPanal(calendar); // 之前必须先保证放置日期的按钮已经初始化。
this.setLayout(new BorderLayout());
this.add(yearPanel, BorderLayout.NORTH);
this.add(dayPanel, BorderLayout.CENTER);
}
/* *
* 日期选择控件的按钮初始化
*/
private void initButton() {
int actionCommandId = 1 ;
for ( int i = 0 ; i < 6 ; i ++ ) {
for ( int j = 0 ; j < 7 ; j ++ ) {
JButton numberButton = new JButton();
numberButton.setBorder(BorderFactory.createEmptyBorder());
numberButton.setHorizontalAlignment(SwingConstants.CENTER);
numberButton.setActionCommand(String.valueOf(
actionCommandId));
private void initButton() {
int actionCommandId = 1;
for (int i = 0; i < 6; i++) {
for (int j = 0; j < 7; j++) {
JButton numberButton = new JButton();
numberButton.setBorder(BorderFactory.createEmptyBorder());
numberButton.setHorizontalAlignment(SwingConstants.CENTER);
numberButton.setActionCommand(String.valueOf(actionCommandId));
numberButton.addMouseListener( this );
numberButton.addMouseListener(this);
numberButton.setBackground(palletTableColor);
numberButton.setForeground(dateFontColor);
numberButton.setText(String.valueOf(actionCommandId));
numberButton.setPreferredSize( new Dimension( 25 , 25 ));
daysButton[i][j] = numberButton;
actionCommandId ++ ;
}
}
}
private Date getNowDate() {
return Calendar.getInstance().getTime();
}
private Calendar getNowCalendar() {
Calendar result = Calendar.getInstance();
return result;
}
private Date getSelectDate() {
return calendar.getTime();
}
numberButton.setBackground(palletTableColor);
numberButton.setForeground(dateFontColor);
numberButton.setText(String.valueOf(actionCommandId));
numberButton.setPreferredSize(new Dimension(25, 25));
daysButton[i][j] = numberButton;
actionCommandId++;
}
}
}
private Date getNowDate() {
return Calendar.getInstance().getTime();
}
private Calendar getNowCalendar() {
Calendar result = Calendar.getInstance();
return result;
}
private Date getSelectDate() {
return calendar.getTime();
}
/* *
* 创建年月日的面板
*/
private void createYearAndMonthPanal() {
Calendar c = getNowCalendar();
int currentYear = c. get (Calendar.YEAR);
int currentMonth = c. get (Calendar.MONTH) + 1 ;
int currentHour = c. get (Calendar.DAY_OF_MONTH);
yearSpin = new JSpinner( new SpinnerNumberModel(
currentYear,
startYear, lastYear, 1 ));
monthSpin = new JSpinner( new SpinnerNumberModel(
currentMonth, 1 , 12 ,
1 ));
// hourSpin = new JSpinner( new javax.swing.SpinnerNumberModel(
// currentHour, 0 , 23 ,
// 1 ));
private void createYearAndMonthPanal() {
Calendar c = getNowCalendar();
int currentYear = c.get(Calendar.YEAR);
int currentMonth = c.get(Calendar.MONTH) + 1;
int currentHour = c.get(Calendar.DAY_OF_MONTH);
yearSpin = new JSpinner(new SpinnerNumberModel(currentYear, startYear, lastYear, 1));
monthSpin = new JSpinner(new SpinnerNumberModel(currentMonth, 1, 12, 1));
// hourSpin = new JSpinner( new javax.swing.SpinnerNumberModel(
// currentHour, 0 , 23 ,
// 1 ));
yearPanel.setLayout( new FlowLayout());
yearPanel.setBackground(controlLineColor);
yearPanel.setLayout(new FlowLayout());
yearPanel.setBackground(controlLineColor);
yearSpin.setPreferredSize( new Dimension( 48 , 20 ));
yearSpin.setName( " Year " );
yearSpin.setEditor( new JSpinner.NumberEditor(yearSpin, " #### " ));
yearSpin.addChangeListener( this );
yearPanel.add(yearSpin);
yearSpin.setPreferredSize(new Dimension(48, 20));
yearSpin.setName(" Year ");
yearSpin.setEditor(new JSpinner.NumberEditor(yearSpin, " #### "));
yearSpin.addChangeListener(this);
yearPanel.add(yearSpin);
JLabel yearLabel = new JLabel( "" );
yearLabel.setForeground(controlTextColor);
yearPanel.add(yearLabel);
JLabel yearLabel = new JLabel("");
yearLabel.setForeground(controlTextColor);
yearPanel.add(yearLabel);
monthSpin.setPreferredSize( new Dimension( 35 , 20 ));
monthSpin.setName( " Month " );
monthSpin.addChangeListener( this );
yearPanel.add(monthSpin);
monthSpin.setPreferredSize(new Dimension(35, 20));
monthSpin.setName(" Month ");
monthSpin.addChangeListener(this);
yearPanel.add(monthSpin);
JLabel monthLabel = new JLabel( "" );
monthLabel.setForeground(controlTextColor);
yearPanel.add(monthLabel);
JLabel monthLabel = new JLabel("");
monthLabel.setForeground(controlTextColor);
yearPanel.add(monthLabel);
}
}
/* *
* 根据日期刷新显示面板
*/
private void flushWeekAndDayPanal(Calendar c) {
// c.set
c. set (Calendar.DAY_OF_MONTH, 1 );
c.setFirstDayOfWeek( 0 );
int firstdayofWeek = c. get (Calendar.DAY_OF_WEEK);
int lastdayofWeek = c.getActualMaximum(Calendar.DAY_OF_MONTH);
String colname[] = {
"" , "" , "" , "" , "" , "" , "" };
int today = getNowCalendar(). get (Calendar.DAY_OF_MONTH);
private void flushWeekAndDayPanal(Calendar c) {
// c.set
c.set(Calendar.DAY_OF_MONTH, 1);
c.setFirstDayOfWeek(0);
int firstdayofWeek = c.get(Calendar.DAY_OF_WEEK);
int lastdayofWeek = c.getActualMaximum(Calendar.DAY_OF_MONTH);
String colname[] = {"", "", "", "", "", "", ""};
int today = getNowCalendar().get(Calendar.DAY_OF_MONTH);
// 设置固定字体,以免调用环境改变影响界面美观
dayPanel.setFont( new Font( " 宋体 " , Font.PLAIN, 12 ));
dayPanel.setLayout( new GridBagLayout());
dayPanel.setBackground(Color.white);
dayPanel.setFont(new Font(" 宋体 ", Font.PLAIN, 12));
dayPanel.setLayout(new GridBagLayout());
dayPanel.setBackground(Color.white);
JLabel cell;
JLabel cell;
for ( int i = 0 ; i < 7 ; i ++ ) {
cell = new JLabel(colname[i]);
cell.setHorizontalAlignment(JLabel.CENTER);
cell.setPreferredSize( new Dimension( 25 , 25 ));
if (i == 0 || i == 6 ) {
cell.setForeground(weekendFontColor);
}
else {
cell.setForeground(weekFontColor);
}
dayPanel.add(cell, new GridBagConstraints(i, 0 , 1 , 1 , 0.0 , 0.0
, GridBagConstraints.CENTER,
GridBagConstraints.NONE,
new Insets( 0 , 0 , 0 , 0 ), 0 , 0 )
);
}
for (int i = 0; i < 7; i++) {
cell = new JLabel(colname[i]);
cell.setHorizontalAlignment(JLabel.CENTER);
cell.setPreferredSize(new Dimension(25, 25));
if (i == 0 || i == 6) {
cell.setForeground(weekendFontColor);
} else {
cell.setForeground(weekFontColor);
}
dayPanel
.add(cell, new GridBagConstraints(i, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
}
int actionCommandId = 1 ;
for ( int i = 0 ; i < 6 ; i ++ ) {
for ( int j = 0 ; j < 7 ; j ++ ) {
int actionCommandId = 1;
for (int i = 0; i < 6; i++) {
for (int j = 0; j < 7; j++) {
JButton numberButton = daysButton[i][j];
actionCommandId = Integer.parseInt(numberButton.
getActionCommand());
if (actionCommandId == today) {
numberButton.setBackground(todayBtnColor);
}
if ( (actionCommandId + firstdayofWeek - 2 ) % 7 == 6 ||
(actionCommandId + firstdayofWeek - 2 ) % 7 == 0 ) {
numberButton.setForeground(weekendFontColor);
}
else {
numberButton.setForeground(dateFontColor);
}
JButton numberButton = daysButton[i][j];
actionCommandId = Integer.parseInt(numberButton.getActionCommand());
if (actionCommandId == today) {
numberButton.setBackground(todayBtnColor);
}
if ((actionCommandId + firstdayofWeek - 2) % 7 == 6 || (actionCommandId + firstdayofWeek - 2) % 7 == 0) {
numberButton.setForeground(weekendFontColor);
} else {
numberButton.setForeground(dateFontColor);
}
if (actionCommandId <= lastdayofWeek) {
int y = 0 ;
if ( (firstdayofWeek - 1 ) <=
(j + firstdayofWeek - 1 ) % 7 ) {
y = i + 1 ;
}
else {
y = i + 2 ;
}
dayPanel.add(numberButton,
new GridBagConstraints( (j +
firstdayofWeek -
1 ) %
7 , y, 1 , 1 , 0.0 , 0.0
, GridBagConstraints.CENTER,
GridBagConstraints.NONE,
new Insets( 0 , 0 , 0 , 0 ), 0 , 0 )
);
}
}
}
}
if (actionCommandId <= lastdayofWeek) {
int y = 0;
if ((firstdayofWeek - 1) <= (j + firstdayofWeek - 1) % 7) {
y = i + 1;
} else {
y = i + 2;
}
dayPanel
.add(numberButton, new GridBagConstraints((j + firstdayofWeek - 1) % 7, y, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
}
}
}
}
private int getSelectedYear() {
return ( (Integer) yearSpin.getValue()).intValue();
}
private int getSelectedYear() {
return ((Integer)yearSpin.getValue()).intValue();
}
private int getSelectedMonth() {
return ( (Integer) monthSpin.getValue()).intValue();
}
private int getSelectedMonth() {
return ((Integer)monthSpin.getValue()).intValue();
}
/* *
* 年月小时的事件处理
* @param e ChangeEvent
*/
public void stateChanged(ChangeEvent e) {
JSpinner source = (JSpinner) e.getSource();
if (source.getName().equals( " Year " )) {
public void stateChanged(ChangeEvent e) {
JSpinner source = (JSpinner)e.getSource();
if (source.getName().equals(" Year ")) {
calendar. set (Calendar.YEAR, getSelectedYear());
dayPanel.removeAll();
this .flushWeekAndDayPanal(calendar);
dayPanel.revalidate();
dayPanel.updateUI();
return ;
}
if (source.getName().equals( " Month " )) {
calendar. set (Calendar.MONTH, getSelectedMonth() - 1 );
calendar.set(Calendar.YEAR, getSelectedYear());
dayPanel.removeAll();
this.flushWeekAndDayPanal(calendar);
dayPanel.revalidate();
dayPanel.updateUI();
return;
}
if (source.getName().equals(" Month ")) {
calendar.set(Calendar.MONTH, getSelectedMonth() - 1);
dayPanel.removeAll();
this .flushWeekAndDayPanal(calendar);
dayPanel.revalidate();
dayPanel.updateUI();
return ;
}
}
dayPanel.removeAll();
this.flushWeekAndDayPanal(calendar);
dayPanel.revalidate();
dayPanel.updateUI();
return;
}
}
/* *
* 日期按钮的鼠标事件处理
*/
public void mouseClicked(MouseEvent e) {
public void mouseClicked(MouseEvent e) {
jTextFieldDate.setColumns(10);
jTextFieldDate.setEnabled(true);
jTextFieldDate.setEditable(true);
if (e.getButton() == MouseEvent.BUTTON1 && e.getClickCount() == 1 ) {
JButton source = (JButton) e.getSource();
if (e.getButton() == MouseEvent.BUTTON1 && e.getClickCount() == 1) {
JButton source = (JButton)e.getSource();
String value = source.getText();
int day = Integer.parseInt(value);
calendar. set (Calendar.DAY_OF_MONTH, day);
Date selectDate = this .getSelectDate();
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(
pattern);
DateChooser. this .setText(simpleDateFormat.format(selectDate));
String value = source.getText();
int day = Integer.parseInt(value);
calendar.set(Calendar.DAY_OF_MONTH, day);
Date selectDate = this.getSelectDate();
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern);
DateChooser.this.setText(simpleDateFormat.format(selectDate));
int year = calendar. get (Calendar.YEAR);
int month = calendar. get (Calendar.MONTH) + 1 ;
// System.out.println(year + "年" + month + "月" + day + "日");
f.dispose();
}
}
int year = calendar.get(Calendar.YEAR);
int month = calendar.get(Calendar.MONTH) + 1;
// System.out.println(year + "年" + month + "月" + day + "日");
f.dispose();
}
}
public void mousePressed(MouseEvent e) {
public void mousePressed(MouseEvent e) {
// 空实现接口中的方法,不能删除
}
}
public void mouseReleased(MouseEvent e) {
public void mouseReleased(MouseEvent e) {
// 空实现接口中的方法,不能删除
}
}
/* *
* 鼠标移动到日历中的事件
* @param e MouseEvent
*/
public void mouseEntered(MouseEvent e) {
JButton jbutton = (JButton) e.getSource();
jbutton.setBackground(moveButtonColor);
public void mouseEntered(MouseEvent e) {
JButton jbutton = (JButton)e.getSource();
jbutton.setBackground(moveButtonColor);
}
}
/* *
* 鼠标移出日历中的事件
* @param e MouseEvent
*/
public void mouseExited(MouseEvent e) {
JButton jbutton = (JButton) e.getSource();
int comm = Integer.parseInt(jbutton.getActionCommand());
int today = getNowCalendar(). get (Calendar.DAY_OF_MONTH);
if (comm == today) {
jbutton.setBackground(todayBtnColor);
}
else {
jbutton.setBackground(palletTableColor);
}
}
}
public void mouseExited(MouseEvent e) {
JButton jbutton = (JButton)e.getSource();
int comm = Integer.parseInt(jbutton.getActionCommand());
int today = getNowCalendar().get(Calendar.DAY_OF_MONTH);
if (comm == today) {
jbutton.setBackground(todayBtnColor);
} else {
jbutton.setBackground(palletTableColor);
}
}
}
/* *
* 内部类,改变按钮的边框不可编辑区,使外观更加协调。
*/
class DateChooserButton
extends JButton {
public DateChooserButton(String text) {
super(text);
}
public Insets getInsets() {
return new Insets( 4 , 2 , 0 , 2 );
}
class DateChooserButton extends JButton {
public DateChooserButton(String text) {
super(text);
}
}
public Insets getInsets() {
return new Insets(4, 2, 0, 2);
}
}
}

View File

@@ -110,8 +110,9 @@ public class ysNetController {
boolean isSDKInitialized = NetCommon.isSDKInitialized();
boolean isDeviceLoggedIn = NetCommon.isDeviceLoggedIn();
return R.ok("SDK初始化状态" + (isSDKInitialized ? "已初始化" : "未初始化") + "" +
"设备登录状态:" + (isDeviceLoggedIn ? "已登录" : "未登录"));
return R.ok("SDK初始化状态" + (isSDKInitialized ? "已初始化" : "未初始化") + "" + "设备登录状态:" + (isDeviceLoggedIn
? "已登录"
: "未登录"));
} catch (Exception e) {
return R.fail("500", "检查状态失败:" + e.getMessage());
}