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

@@ -1,24 +0,0 @@
package top.wms.admin.common.enums;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import top.continew.starter.core.enums.BaseEnum;
/**
* 交易状态枚举
*
* @author Charles7c
* @since 2022/12/29 22:38
*/
@Getter
@RequiredArgsConstructor
public enum ConsumeOrderTypeEnum implements BaseEnum<Integer> {
/**
* 在线消费
*/
CONSUME(0, "消费");
private final Integer value;
private final String description;
}

View File

@@ -1,49 +0,0 @@
package top.wms.admin.common.enums;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import top.continew.starter.core.enums.BaseEnum;
/**
* 支付方式枚举
*
* @author Charles7c
* @since 2022/12/29 22:38
*/
@Getter
@RequiredArgsConstructor
public enum ConsumePayModeEnum implements BaseEnum<Integer> {
/**
* 人脸
*/
FACE(0, "人脸"),
/**
* 云卡
*/
CLOUD_CARD(1, "云卡"),
/**
* 刷卡
*/
SWIPE_CARD(2, "刷卡"),
/**
* 支付宝
*/
ALIPAY(3, "支付宝"),
/**
* 微信
*/
WECHAT(4, "微信"),
/**
* 取餐码
*/
MEAL_CODE(5, "取餐码");
private final Integer value;
private final String description;
}

View File

@@ -1,39 +0,0 @@
package top.wms.admin.common.enums;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import top.continew.starter.core.enums.BaseEnum;
/**
* 消费-充值方式
*
* @author Charles7c
* @since 2022/12/29 22:38
*/
@Getter
@RequiredArgsConstructor
public enum ConsumeRechargeModeEnum implements BaseEnum<Integer> {
/**
* 现金
*/
CASH(0, "现金"),
/**
* 支付宝
*/
ALIPAY(1, "支付宝"),
/**
* 微信
*/
WECHAT(2, "微信"),
/**
* 网银
*/
ONLINE_BANKING(3, "网银");
private final Integer value;
private final String description;
}

View File

@@ -1,49 +0,0 @@
package top.wms.admin.common.enums;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import top.continew.starter.core.enums.BaseEnum;
/**
* 消费-操作类型
*
* @author Charles7c
* @since 2022/12/29 22:38
*/
@Getter
@RequiredArgsConstructor
public enum ConsumeRechargeTypeEnum implements BaseEnum<Integer> {
/**
* 补贴
*/
SUBSIDY(0, "补贴"),
/**
* 充值
*/
RECHARGE(1, "充值"),
/**
* 退款
*/
REFUND(2, "退款"),
/**
* 清零(全部)
*/
CLEAR(3, "清零(全部)"),
/**
* 清零(充值)
*/
CLEAR_CZ(4, "清零(充值)"),
/**
* 清零(补贴)
*/
CLEAR_BT(5, "清零(补贴)");
private final Integer value;
private final String description;
}

View File

@@ -1,29 +0,0 @@
package top.wms.admin.common.enums;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import top.continew.starter.core.enums.BaseEnum;
/**
* 消费-充值来源
*
* @author Charles7c
* @since 2022/12/29 22:38
*/
@Getter
@RequiredArgsConstructor
public enum ConsumeRechargeWayEnum implements BaseEnum<Integer> {
/**
* 在线消费
*/
WEB(0, "平台"),
/**
* 离线消费
*/
PHONE(1, "手机");
private final Integer value;
private final String description;
}

View File

@@ -1,44 +0,0 @@
package top.wms.admin.common.enums;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import top.continew.starter.core.enums.BaseEnum;
/**
* 交易状态枚举
*
* @author Charles7c
* @since 2022/12/29 22:38
*/
@Getter
@RequiredArgsConstructor
public enum ConsumeResultEnum implements BaseEnum<Integer> {
/**
* 在线消费
*/
ONLINE_CONSUME(0, "在线消费"),
/**
* 离线消费
*/
OFFLINE_CONSUME(1, "离线消费"),
/**
* 超时
*/
TIMEOUT(2, "超时"),
/**
* 消费异常
*/
CONSUMPTION_EXCEPTION(3, "消费异常"),
/**
* 异常消费
*/
EXCEPTION_CONSUMPTION(4, "异常消费");
private final Integer value;
private final String description;
}

View File

@@ -1,38 +0,0 @@
package top.wms.admin.common.enums;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import top.continew.starter.core.enums.BaseEnum;
/**
* 消费-充值来源
*
* @author Charles7c
* @since 2022/12/29 22:38
*/
@Getter
@RequiredArgsConstructor
public enum ConsumeTmrtypeEnum implements BaseEnum<Integer> {
/**
* 早餐
*/
BREAKFAST(0, "早餐"),
/**
* 中餐
*/
LUNCH(1, "中餐"),
/**
* 午餐
*/
DINNER(2, "午餐"),
/**
* 夜餐
*/
NIGHT(3, "夜餐");
private final Integer value;
private final String description;
}

View File

@@ -1,49 +0,0 @@
package top.wms.admin.common.enums;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import top.continew.starter.core.enums.BaseEnum;
/**
* 消费类型枚举
*
* @author Charles7c
* @since 2022/12/29 22:38
*/
@Getter
@RequiredArgsConstructor
public enum ConsumeTypeConverter implements BaseEnum<Integer> {
/**
* 单价
*/
UNIT_PRICE(0, "单价"),
/**
* 定额
*/
FIXED_PRICE(1, "定额"),
/**
* 时段模式
*/
TIME_PERIOD(2, "时段模式"),
/**
* 计次
*/
COUNTING(3, "计次"),
/**
* 点餐机模式
*/
ORDERING_MACHINE(5, "点餐机模式"),
/**
* 身份模式
*/
IDENTITY(9, "身份模式");
private final Integer value;
private final String description;
}

View File

@@ -1,34 +0,0 @@
package top.wms.admin.common.enums;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import top.continew.starter.core.enums.BaseEnum;
/**
* 钱包消费模式枚举
*
* @author Charles7c
* @since 2022/12/29 22:38
*/
@Getter
@RequiredArgsConstructor
public enum ConsumeWalletModeEnum implements BaseEnum<Integer> {
/**
* 先消费补贴再个人
*/
SUBSIDY_THEN_PERSONAL(0, "先消费补贴再个人"),
/**
* 仅现金
*/
ONLY_CASH(1, "仅现金"),
/**
* 仅补贴
*/
ONLY_SUBSIDY(2, "仅补贴");
private final Integer value;
private final String description;
}

View File

@@ -1,29 +0,0 @@
package top.wms.admin.common.enums;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import top.continew.starter.core.enums.BaseEnum;
/**
* 启用禁用
*
* @author Charles7c
* @since 2022/12/29 22:38
*/
@Getter
@RequiredArgsConstructor
public enum EnableEnum implements BaseEnum<Integer> {
/**
* 禁用
*/
DISABLE(0, "禁用"),
/**
* 在线消费
*/
ENABLE(1, "启用");
private final Integer value;
private final String description;
}

View File

@@ -0,0 +1,49 @@
package top.wms.admin.common.enums;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import top.continew.starter.core.enums.BaseEnum;
/**
*
*
* @author Charles7c
* @since 2023/2/26 21:35
*/
@Getter
@RequiredArgsConstructor
public enum LightLevelEnum implements BaseEnum<Integer> {
/**
* 一级
*/
LEVEL1(1, "一级"),
/**
* 二级
*/
LEVEL2(2, "二级"),
/**
* 三级
*/
LEVEL3(3, "三级");
private final Integer value;
private final String description;
/**
* 根据描述获取值
*
* @param description 描述
* @return 值,如果找不到则返回 null
*/
public static Integer getValueByDescription(String description) {
for (LightLevelEnum enumValue : values()) {
if (enumValue.getDescription().equals(description)) {
return enumValue.getValue();
}
}
return null;
}
}

View File

@@ -0,0 +1,55 @@
package top.wms.admin.common.enums;
import com.alibaba.excel.converters.Converter;
import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.metadata.GlobalConfiguration;
import com.alibaba.excel.metadata.data.ReadCellData;
import com.alibaba.excel.metadata.data.WriteCellData;
import com.alibaba.excel.metadata.property.ExcelContentProperty;
import java.util.HashMap;
import java.util.Map;
public class LightLevelEnumConverter implements Converter<Integer> {
private static final Map<Integer, String> LIGHT_LEVEL_MAP = new HashMap<>();
static {
LIGHT_LEVEL_MAP.put(1, "一级");
LIGHT_LEVEL_MAP.put(2, "二级");
LIGHT_LEVEL_MAP.put(3, "三级");
}
@Override
public Class<?> supportJavaTypeKey() {
return Integer.class; // 支持的 Java 类型
}
@Override
public CellDataTypeEnum supportExcelTypeKey() {
return CellDataTypeEnum.STRING; // 写入 Excel 时用字符串
}
@Override
public WriteCellData<String> convertToExcelData(Integer value,
ExcelContentProperty contentProperty,
GlobalConfiguration globalConfiguration) {
if (value == null) {
return new WriteCellData<>("");
}
String label = LIGHT_LEVEL_MAP.getOrDefault(value, "");
return new WriteCellData<>(label);
}
@Override
public Integer convertToJavaData(ReadCellData<?> cellData,
ExcelContentProperty contentProperty,
GlobalConfiguration globalConfiguration) {
String stringValue = cellData.getStringValue();
for (Map.Entry<Integer, String> entry : LIGHT_LEVEL_MAP.entrySet()) {
if (entry.getValue().equals(stringValue)) {
return entry.getKey();
}
}
return null;
}
}

View File

@@ -1,33 +0,0 @@
package top.wms.admin.common.enums;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import top.continew.starter.core.enums.BaseEnum;
@Getter
@RequiredArgsConstructor
public enum OperTypeEnum implements BaseEnum<Integer> {
/**
* 新增
*/
ADD(0, "新增"),
/**
* 修改
*/
UPDATE(1, "修改"),
/**
* 下发
*/
DOWN(2, "下发"),
/**
* 删除
*/
DEL(3, "删除");
private final Integer value;
private final String description;
}

View File

@@ -5,11 +5,11 @@ import top.wms.admin.fullWorkOrder.model.entity.FullWorkOrderDO;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
/** /**
* 整箱领取记录 Mapper * 整箱领取记录 Mapper
* *
* @author zc * @author zc
* @since 2026/03/24 09:36 * @since 2026/03/24 09:36
*/ */
@Repository @Repository
public interface FullWorkOrderMapper extends BaseMapper<FullWorkOrderDO> { public interface FullWorkOrderMapper extends BaseMapper<FullWorkOrderDO> {

View File

@@ -3,7 +3,6 @@ package top.wms.admin.fullWorkOrder.service;
import top.continew.starter.extension.crud.service.BaseService; import top.continew.starter.extension.crud.service.BaseService;
import top.wms.admin.fullWorkOrder.model.query.FullWorkOrderQuery; import top.wms.admin.fullWorkOrder.model.query.FullWorkOrderQuery;
import top.wms.admin.fullWorkOrder.model.req.FullWorkOrderReq; import top.wms.admin.fullWorkOrder.model.req.FullWorkOrderReq;
import top.wms.admin.fullWorkOrder.model.resp.FullWorkOrderDetailResp;
import top.wms.admin.fullWorkOrder.model.resp.FullWorkOrderResp; import top.wms.admin.fullWorkOrder.model.resp.FullWorkOrderResp;
/** /**

View File

@@ -15,8 +15,6 @@ import top.wms.admin.fullWorkOrder.model.query.FullWorkOrderQuery;
import top.wms.admin.fullWorkOrder.model.req.FullWorkOrderReq; import top.wms.admin.fullWorkOrder.model.req.FullWorkOrderReq;
import top.wms.admin.fullWorkOrder.model.resp.FullWorkOrderResp; import top.wms.admin.fullWorkOrder.model.resp.FullWorkOrderResp;
import top.wms.admin.fullWorkOrder.service.FullWorkOrderService; import top.wms.admin.fullWorkOrder.service.FullWorkOrderService;
import top.wms.admin.materialProcess.model.query.MaterialProcessQuery;
import top.wms.admin.materialProcess.model.resp.MaterialProcessResp;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
@@ -41,8 +39,6 @@ public class FullWorkOrderServiceImpl extends BaseServiceImpl<FullWorkOrderMappe
req.setTitle(title); req.setTitle(title);
} }
@Override @Override
public void export(FullWorkOrderQuery query, SortQuery sortQuery, HttpServletResponse response) { public void export(FullWorkOrderQuery query, SortQuery sortQuery, HttpServletResponse response) {
List<FullWorkOrderResp> list = super.list(query, sortQuery, this.getDetailClass()); List<FullWorkOrderResp> list = super.list(query, sortQuery, this.getDetailClass());
@@ -50,5 +46,4 @@ public class FullWorkOrderServiceImpl extends BaseServiceImpl<FullWorkOrderMappe
ExcelUtils.export(list, "整箱领取导出记录", FullWorkOrderResp.class, response); ExcelUtils.export(list, "整箱领取导出记录", FullWorkOrderResp.class, response);
} }
} }

View File

@@ -4,6 +4,7 @@ import lombok.Data;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import top.wms.admin.common.enums.LightLevelEnum;
import top.wms.admin.common.model.entity.BaseDO; import top.wms.admin.common.model.entity.BaseDO;
import java.io.Serial; import java.io.Serial;
@@ -56,4 +57,9 @@ public class MaterialInfoDO extends BaseDO {
* 流程ID * 流程ID
*/ */
private Long materialProcessId; private Long materialProcessId;
/**
* 灯光等级
*/
private Integer lightLevel;
} }

View File

@@ -1,6 +1,5 @@
package top.wms.admin.material.model.req; package top.wms.admin.material.model.req;
import com.alibaba.excel.annotation.ExcelProperty;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull; import jakarta.validation.constraints.NotNull;
@@ -40,6 +39,12 @@ public class MaterialImportRowReq implements Serializable {
@NotNull(message = "物料单位重量不能为空") @NotNull(message = "物料单位重量不能为空")
private BigDecimal unitWeight; private BigDecimal unitWeight;
/**
* 灯光等级
*/
@Schema(description = "灯光等级")
private String lightLevelName;
/* /*
* 物料规格 * 物料规格
* */ * */

View File

@@ -73,4 +73,10 @@ public class MaterialInfoReq implements Serializable {
@Schema(description = "流程ID") @Schema(description = "流程ID")
@NotNull(message = "流程ID不能为空") @NotNull(message = "流程ID不能为空")
private Long materialProcessId; private Long materialProcessId;
/**
* 灯光等级
*/
@Schema(description = "灯光等级")
private Integer lightLevel;
} }

View File

@@ -2,10 +2,9 @@ package top.wms.admin.material.model.resp;
import com.alibaba.excel.annotation.ExcelIgnore; import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty; import com.alibaba.excel.annotation.ExcelProperty;
import lombok.Data;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import top.wms.admin.common.enums.LightLevelEnumConverter;
import top.wms.admin.common.model.resp.BaseDetailResp; import top.wms.admin.common.model.resp.BaseDetailResp;
import java.io.Serial; import java.io.Serial;
@@ -28,28 +27,28 @@ public class MaterialInfoResp extends BaseDetailResp {
* 物料名称 * 物料名称
*/ */
@Schema(description = "物料名称") @Schema(description = "物料名称")
@ExcelProperty(value = "物料名称") @ExcelProperty(value = "物料名称", order = 1)
private String materialName; private String materialName;
/** /**
* 物料编码 * 物料编码
*/ */
@Schema(description = "物料编码") @Schema(description = "物料编码")
@ExcelProperty(value = "物料编码") @ExcelProperty(value = "物料编码", order = 2)
private String encoding; private String encoding;
/** /**
* 物料单位重量(g) * 物料单位重量(g)
*/ */
@Schema(description = "物料单位重量(g)") @Schema(description = "物料单位重量(g)")
@ExcelProperty(value = "物料单位重量(g)") @ExcelProperty(value = "物料单位重量(g)", order = 3)
private Double unitWeight; private Double unitWeight;
/** /**
* 物料规格 * 物料规格
*/ */
@Schema(description = "物料规格") @Schema(description = "物料规格")
@ExcelProperty(value = "物料规格") @ExcelProperty(value = "物料规格", order = 5)
private String materialSpec; private String materialSpec;
/** /**
@@ -87,7 +86,6 @@ public class MaterialInfoResp extends BaseDetailResp {
@ExcelIgnore @ExcelIgnore
private Long materialProcessId; private Long materialProcessId;
/** /**
* 品类下行浮动范围(% * 品类下行浮动范围(%
*/ */
@@ -102,4 +100,11 @@ public class MaterialInfoResp extends BaseDetailResp {
@ExcelIgnore @ExcelIgnore
private BigDecimal upFloatRatio; private BigDecimal upFloatRatio;
/**
* 颜色灯光值
*/
@Schema(description = "灯光等级")
@ExcelProperty(value = "灯光等级", converter = LightLevelEnumConverter.class, order = 4)
private Integer lightLevel;
} }

View File

@@ -3,7 +3,6 @@ package top.wms.admin.material.service;
import jakarta.servlet.http.HttpServletResponse; import jakarta.servlet.http.HttpServletResponse;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import top.continew.starter.extension.crud.service.BaseService; import top.continew.starter.extension.crud.service.BaseService;
import top.wms.admin.material.model.entity.MaterialInfoDO;
import top.wms.admin.material.model.query.MaterialInfoQuery; import top.wms.admin.material.model.query.MaterialInfoQuery;
import top.wms.admin.material.model.req.MaterialInfoImportReq; import top.wms.admin.material.model.req.MaterialInfoImportReq;
import top.wms.admin.material.model.req.MaterialInfoReq; import top.wms.admin.material.model.req.MaterialInfoReq;

View File

@@ -39,6 +39,8 @@ import top.continew.starter.file.excel.util.ExcelUtils;
import top.continew.starter.web.util.FileUploadUtils; import top.continew.starter.web.util.FileUploadUtils;
import top.wms.admin.common.constant.CacheConstants; import top.wms.admin.common.constant.CacheConstants;
import top.wms.admin.common.context.UserContextHolder; import top.wms.admin.common.context.UserContextHolder;
import top.wms.admin.common.enums.LightLevelEnum;
import top.wms.admin.common.enums.LightLevelEnumConverter;
import top.wms.admin.common.util.SecureUtils; import top.wms.admin.common.util.SecureUtils;
import top.wms.admin.material.mapper.MaterialInfoMapper; import top.wms.admin.material.mapper.MaterialInfoMapper;
import top.wms.admin.material.model.entity.MaterialInfoDO; import top.wms.admin.material.model.entity.MaterialInfoDO;
@@ -204,17 +206,34 @@ public class MaterialInfoServiceImpl extends BaseServiceImpl<MaterialInfoMapper,
//查询物料类型 //查询物料类型
List<String> collect = importMaterialList.stream().map(MaterialImportRowReq::getTypeName).distinct().toList(); List<String> collect = importMaterialList.stream().map(MaterialImportRowReq::getTypeName).distinct().toList();
Map<String, Long> materialTypeMap = new HashMap<>(); Map<String, Long> materialTypeMap = new HashMap<>();
if(CollUtil.isNotEmpty(collect)){ if (CollUtil.isNotEmpty(collect)) {
List<MaterialTypeDO> materialTypeList = materialTypeMapper.selectList(new LambdaQueryWrapper<MaterialTypeDO>().in(MaterialTypeDO::getTypeName, collect)); List<MaterialTypeDO> materialTypeList = materialTypeMapper
materialTypeMap = materialTypeList.stream().collect(Collectors.toMap(MaterialTypeDO::getTypeName, MaterialTypeDO::getId, (k1, v1) -> v1)); .selectList(new LambdaQueryWrapper<MaterialTypeDO>().in(MaterialTypeDO::getTypeName, collect));
materialTypeMap = materialTypeList.stream()
.collect(Collectors.toMap(MaterialTypeDO::getTypeName, MaterialTypeDO::getId, (k1, v1) -> v1));
} }
//查询物料流程 //查询物料流程
List<String> collect1 = importMaterialList.stream().map(MaterialImportRowReq::getProcessName).distinct().toList(); List<String> collect1 = importMaterialList.stream()
List<MaterialProcessDO> materialProcessList = materialProcessMapper.selectList(new LambdaQueryWrapper<MaterialProcessDO>().in(MaterialProcessDO::getProcessName, collect1)); .map(MaterialImportRowReq::getProcessName)
.distinct()
.toList();
List<MaterialProcessDO> materialProcessList = materialProcessMapper
.selectList(new LambdaQueryWrapper<MaterialProcessDO>().in(MaterialProcessDO::getProcessName, collect1));
Map<String, Long> materialProcessMap = new HashMap<>(); Map<String, Long> materialProcessMap = new HashMap<>();
if(CollUtil.isNotEmpty(materialProcessList)) { if (CollUtil.isNotEmpty(materialProcessList)) {
materialProcessMap = materialProcessList.stream().collect(Collectors.toMap(MaterialProcessDO::getProcessName, MaterialProcessDO::getId, (k1, v1) -> v1)); materialProcessMap = materialProcessList.stream()
.collect(Collectors.toMap(MaterialProcessDO::getProcessName, MaterialProcessDO::getId, (k1, v1) -> v1));
} }
//处理灯光等级
Map<String, Integer> lightLevelMap = new HashMap<>();
importMaterialList.forEach(row -> {
if (row.getLightLevelName() != null) {
Integer valueByDescription = LightLevelEnum.getValueByDescription(row.getLightLevelName());
if(null != valueByDescription){
lightLevelMap.put(row.getLightLevelName(), valueByDescription);
}
}
});
// 批量操作数据库集合 // 批量操作数据库集合
List<MaterialInfoDO> insertList = new ArrayList<>(); List<MaterialInfoDO> insertList = new ArrayList<>();
@@ -230,6 +249,7 @@ public class MaterialInfoServiceImpl extends BaseServiceImpl<MaterialInfoMapper,
materialDO.setMaterialSpec(StrUtil.isNotBlank(row.getMaterialSpec()) ? row.getMaterialSpec() : null); materialDO.setMaterialSpec(StrUtil.isNotBlank(row.getMaterialSpec()) ? row.getMaterialSpec() : null);
materialDO.setMaterialProcessId(materialProcessMap.get(row.getProcessName())); materialDO.setMaterialProcessId(materialProcessMap.get(row.getProcessName()));
materialDO.setMaterialTypeId(materialTypeMap.get(row.getTypeName())); materialDO.setMaterialTypeId(materialTypeMap.get(row.getTypeName()));
materialDO.setLightLevel(lightLevelMap.get(row.getLightLevelName()));
// 修改 or 新增 // 修改 or 新增
if (UPDATE.validate(req.getDuplicateName(), row.getMaterialName(), existName)) { if (UPDATE.validate(req.getDuplicateName(), row.getMaterialName(), existName)) {
materialDO.setMaterialName(row.getMaterialName()); materialDO.setMaterialName(row.getMaterialName());
@@ -283,9 +303,7 @@ public class MaterialInfoServiceImpl extends BaseServiceImpl<MaterialInfoMapper,
*/ */
private List<MaterialImportRowReq> filterImportData(List<MaterialImportRowReq> importRowList) { private List<MaterialImportRowReq> filterImportData(List<MaterialImportRowReq> importRowList) {
// 校验过滤 // 校验过滤
return importRowList.stream() return importRowList.stream().filter(row -> ValidationUtil.validate(row).isEmpty()).toList();
.filter(row -> ValidationUtil.validate(row).isEmpty())
.toList();
} }
/** /**

View File

@@ -1,7 +1,6 @@
package top.wms.admin.materialProcess.model.req; package top.wms.admin.materialProcess.model.req;
import lombok.Data; import lombok.Data;
import lombok.experimental.Accessors;
import top.wms.admin.system.enums.ImportPolicyEnum; import top.wms.admin.system.enums.ImportPolicyEnum;
import java.io.Serial; import java.io.Serial;

View File

@@ -2,12 +2,10 @@ package top.wms.admin.materialProcess.model.req;
import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotBlank;
import lombok.Data; import lombok.Data;
import lombok.experimental.Accessors;
import java.io.Serial; import java.io.Serial;
import java.io.Serializable; import java.io.Serializable;
/** /**
* 物料流程导入行数据 * 物料流程导入行数据
* *

View File

@@ -1,7 +1,6 @@
package top.wms.admin.materialProcess.model.resp; package top.wms.admin.materialProcess.model.resp;
import lombok.Data; import lombok.Data;
import lombok.experimental.Accessors;
import java.io.Serial; import java.io.Serial;
import java.io.Serializable; import java.io.Serializable;

View File

@@ -23,18 +23,21 @@ public interface MaterialProcessService extends BaseService<MaterialProcessResp,
/** /**
* 获取流程下拉列表 * 获取流程下拉列表
*
* @return 流程下拉列表 * @return 流程下拉列表
*/ */
List<LabelValueResp> getSelectList(); List<LabelValueResp> getSelectList();
/** /**
* 下载导入模板 * 下载导入模板
*
* @param response 响应对象 * @param response 响应对象
*/ */
void downloadImportTemplate(HttpServletResponse response) throws Exception; void downloadImportTemplate(HttpServletResponse response) throws Exception;
/** /**
* 解析导入文件 * 解析导入文件
*
* @param file 导入文件 * @param file 导入文件
* @return 解析响应 * @return 解析响应
*/ */
@@ -42,6 +45,7 @@ public interface MaterialProcessService extends BaseService<MaterialProcessResp,
/** /**
* 导入物料流程 * 导入物料流程
*
* @param req 导入请求 * @param req 导入请求
* @return 导入响应 * @return 导入响应
*/ */

View File

@@ -25,7 +25,6 @@ import top.continew.starter.file.excel.util.ExcelUtils;
import top.continew.starter.web.util.FileUploadUtils; import top.continew.starter.web.util.FileUploadUtils;
import top.wms.admin.common.constant.CacheConstants; import top.wms.admin.common.constant.CacheConstants;
import top.wms.admin.common.context.UserContextHolder; import top.wms.admin.common.context.UserContextHolder;
import top.wms.admin.material.model.resp.MaterialInfoResp;
import top.wms.admin.materialProcess.mapper.MaterialProcessMapper; import top.wms.admin.materialProcess.mapper.MaterialProcessMapper;
import top.wms.admin.materialProcess.mapstruct.MaterialProcessConvert; import top.wms.admin.materialProcess.mapstruct.MaterialProcessConvert;
import top.wms.admin.materialProcess.model.entity.MaterialProcessDO; import top.wms.admin.materialProcess.model.entity.MaterialProcessDO;
@@ -56,7 +55,6 @@ public class MaterialProcessServiceImpl extends BaseServiceImpl<MaterialProcessM
private final MaterialProcessConvert materialProcessConvert; private final MaterialProcessConvert materialProcessConvert;
@Override @Override
public void beforeAdd(MaterialProcessReq req) { public void beforeAdd(MaterialProcessReq req) {
// 校验流程名称是否重复 // 校验流程名称是否重复
@@ -73,15 +71,16 @@ public class MaterialProcessServiceImpl extends BaseServiceImpl<MaterialProcessM
public void beforeUpdate(MaterialProcessReq req, Long id) { public void beforeUpdate(MaterialProcessReq req, Long id) {
// 校验流程名称是否重复 // 校验流程名称是否重复
MaterialProcessDO processDO = baseMapper.selectOne(Wrappers.lambdaQuery(MaterialProcessDO.class) MaterialProcessDO processDO = baseMapper.selectOne(Wrappers.lambdaQuery(MaterialProcessDO.class)
.eq(MaterialProcessDO::getProcessName, req.getProcessName()).ne(MaterialProcessDO::getId, id)); .eq(MaterialProcessDO::getProcessName, req.getProcessName())
.ne(MaterialProcessDO::getId, id));
CheckUtils.throwIf(ObjectUtil.isNotEmpty(processDO), "流程名称已存在"); CheckUtils.throwIf(ObjectUtil.isNotEmpty(processDO), "流程名称已存在");
// 校验流程编码是否重复 // 校验流程编码是否重复
processDO = baseMapper.selectOne(Wrappers.lambdaQuery(MaterialProcessDO.class) processDO = baseMapper.selectOne(Wrappers.lambdaQuery(MaterialProcessDO.class)
.eq(MaterialProcessDO::getProcessCode, req.getProcessCode()).ne(MaterialProcessDO::getId, id)); .eq(MaterialProcessDO::getProcessCode, req.getProcessCode())
.ne(MaterialProcessDO::getId, id));
CheckUtils.throwIf(ObjectUtil.isNotEmpty(processDO), "流程编码已存在"); CheckUtils.throwIf(ObjectUtil.isNotEmpty(processDO), "流程编码已存在");
} }
@Override @Override
public void export(MaterialProcessQuery query, SortQuery sortQuery, HttpServletResponse response) { public void export(MaterialProcessQuery query, SortQuery sortQuery, HttpServletResponse response) {
List<MaterialProcessResp> list = super.list(query, sortQuery, this.getDetailClass()); List<MaterialProcessResp> list = super.list(query, sortQuery, this.getDetailClass());
@@ -223,8 +222,7 @@ public class MaterialProcessServiceImpl extends BaseServiceImpl<MaterialProcessM
if (fieldValues.isEmpty()) { if (fieldValues.isEmpty()) {
return 0; return 0;
} }
return (int)this.count(Wrappers.<MaterialProcessDO>lambdaQuery() return (int)this.count(Wrappers.<MaterialProcessDO>lambdaQuery().in(dbField, fieldValues));
.in(dbField, fieldValues));
} }
/** /**
@@ -234,9 +232,7 @@ public class MaterialProcessServiceImpl extends BaseServiceImpl<MaterialProcessM
*/ */
private List<MaterialProcessImportRowReq> filterImportData(List<MaterialProcessImportRowReq> importRowList) { private List<MaterialProcessImportRowReq> filterImportData(List<MaterialProcessImportRowReq> importRowList) {
// 校验过滤 // 校验过滤
return importRowList.stream() return importRowList.stream().filter(row -> ValidationUtil.validate(row).isEmpty()).toList();
.filter(row -> ValidationUtil.validate(row).isEmpty())
.toList();
} }
/** /**
@@ -274,8 +270,8 @@ public class MaterialProcessServiceImpl extends BaseServiceImpl<MaterialProcessM
List<String> existName, List<String> existName,
List<String> existCode) { List<String> existCode) {
return list.stream() return list.stream()
.anyMatch(row -> EXIT.validate(req.getDuplicateName(), row.getProcessName(), existName) || EXIT .anyMatch(row -> EXIT.validate(req.getDuplicateName(), row.getProcessName(), existName) || EXIT.validate(req
.validate(req.getDuplicateCode(), row.getProcessCode(), existCode)); .getDuplicateCode(), row.getProcessCode(), existCode));
} }
/** /**

View File

@@ -10,7 +10,6 @@ import top.continew.starter.data.core.enums.QueryType;
import java.io.Serial; import java.io.Serial;
import java.io.Serializable; import java.io.Serializable;
import java.time.*; import java.time.*;
import java.math.BigDecimal;
/** /**
* 物料品类查询条件 * 物料品类查询条件

View File

@@ -139,7 +139,8 @@ public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkO
MaterialInfoDO materialInfoDO = materialInfoMapper.selectById(req.getMaterialId()); MaterialInfoDO materialInfoDO = materialInfoMapper.selectById(req.getMaterialId());
CheckUtils.throwIf((materialInfoDO == null || null == materialInfoDO.getMaterialTypeId()), "该物料信息不全,请先维护!"); CheckUtils.throwIf((materialInfoDO == null || null == materialInfoDO.getMaterialTypeId()), "该物料信息不全,请先维护!");
MaterialTypeDO materialTypeDO = materialTypeMapper.selectById(materialInfoDO.getMaterialTypeId()); MaterialTypeDO materialTypeDO = materialTypeMapper.selectById(materialInfoDO.getMaterialTypeId());
CheckUtils.throwIf((materialTypeDO == null || null == materialTypeDO.getDownFloatRatio() || null == materialTypeDO.getUpFloatRatio()), "该物料品类信息不全,请先维护!"); CheckUtils.throwIf((materialTypeDO == null || null == materialTypeDO
.getDownFloatRatio() || null == materialTypeDO.getUpFloatRatio()), "该物料品类信息不全,请先维护!");
//下行浮动范围 //下行浮动范围
BigDecimal downFloatRatio = materialTypeDO.getDownFloatRatio(); BigDecimal downFloatRatio = materialTypeDO.getDownFloatRatio();
@@ -152,7 +153,8 @@ public class WorkOrderServiceImpl extends BaseServiceImpl<WorkOrderMapper, WorkO
// 计算比值:(实重 - 标重) / 标重 // 计算比值:(实重 - 标重) / 标重
BigDecimal weightDifference = electronicWeight.subtract(standardWeight); BigDecimal weightDifference = electronicWeight.subtract(standardWeight);
BigDecimal ratio = weightDifference.divide(standardWeight, 4, BigDecimal.ROUND_HALF_UP).multiply(BigDecimal.valueOf(100)); BigDecimal ratio = weightDifference.divide(standardWeight, 4, BigDecimal.ROUND_HALF_UP)
.multiply(BigDecimal.valueOf(100));
log.info("ratio当前比值:{}%", ratio); log.info("ratio当前比值:{}%", ratio);
// 检查比值是否超过上行浮动范围 // 检查比值是否超过上行浮动范围

View File

@@ -96,6 +96,18 @@
<scope>system</scope> <scope>system</scope>
<systemPath>${project.basedir}/Library/MvCameraControlWrapper.jar</systemPath> <systemPath>${project.basedir}/Library/MvCameraControlWrapper.jar</systemPath>
</dependency> </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> </dependencies>
<build> <build>
<finalName>${project.parent.name}</finalName> <finalName>${project.parent.name}</finalName>

View File

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

View File

@@ -11,8 +11,6 @@ import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.constraints.NotNull; import jakarta.validation.constraints.NotNull;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.dromara.x.file.storage.core.FileInfo; 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.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile; 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}) @CrudRequestMapping(value = "/fullWorkOrder/fullWorkOrder", api = {Api.PAGE, Api.ADD, Api.DELETE, Api.EXPORT})
public class FullWorkOrderController extends BaseController<FullWorkOrderService, FullWorkOrderResp, FullWorkOrderResp, FullWorkOrderQuery, FullWorkOrderReq> { 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.dev33.satoken.annotation.SaCheckPermission;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import jakarta.servlet.http.HttpServletResponse; import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.constraints.NotNull; 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.log.annotation.Log;
import top.continew.starter.web.model.R; import top.continew.starter.web.model.R;
import top.wms.admin.common.controller.BaseController; 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.query.MaterialInfoQuery;
import top.wms.admin.material.model.req.MaterialInfoImportReq; import top.wms.admin.material.model.req.MaterialInfoImportReq;
import top.wms.admin.material.model.req.MaterialInfoReq; import top.wms.admin.material.model.req.MaterialInfoReq;

View File

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

View File

@@ -51,8 +51,6 @@ public class NetCommon {
return true; return true;
} }
/** /**
* Launch the application. * Launch the application.
*/ */
@@ -80,7 +78,6 @@ public class NetCommon {
System.out.println("程序执行完成"); System.out.println("程序执行完成");
} }
/** /**
* 登录设备 * 登录设备
* *
@@ -129,13 +126,17 @@ public class NetCommon {
public static void queryChannels() { public static void queryChannels() {
int nMaxChlCount = 256; int nMaxChlCount = 256;
IntByReference dwChlCount = new IntByReference(nMaxChlCount); 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); boolean bRet = netdevsdk.NETDEV_QueryVideoChlDetailListEx(lpUserID, dwChlCount, stVideoChlList);
if (bRet) { if (bRet) {
log.info("通道查询成功,通道数量: {}", dwChlCount.getValue()); log.info("通道查询成功,通道数量: {}", dwChlCount.getValue());
for (int i = 0; i < dwChlCount.getValue(); i++) { 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 { } else {
log.error("通道查询失败, 错误码:{}", netdevsdk.NETDEV_GetLastError()); log.error("通道查询失败, 错误码:{}", netdevsdk.NETDEV_GetLastError());

View File

@@ -8,7 +8,7 @@ class BaseFun {
String arch = System.getProperty("os.arch").toLowerCase(); String arch = System.getProperty("os.arch").toLowerCase();
final String name = System.getProperty("os.name"); final String name = System.getProperty("os.name");
String osArch; String osArch;
switch(Platform.getOSType()) { switch (Platform.getOSType()) {
case Platform.WINDOWS: { case Platform.WINDOWS: {
if ("i386".equals(arch)) if ("i386".equals(arch))
arch = "x86"; arch = "x86";
@@ -41,13 +41,13 @@ class BaseFun {
//获取加载SDK库 //获取加载SDK库
public static String LoadSDKLibrary() { public static String LoadSDKLibrary() {
String filePath = System.getProperty("user.dir").replaceFirst("/","").replaceAll("%20"," "); String filePath = System.getProperty("user.dir").replaceFirst("/", "").replaceAll("%20", " ");
String loadLibrary = ""; String loadLibrary = "";
String OsArch = getOsArch(); String OsArch = getOsArch();
if(OsArch.toLowerCase().startsWith("win32-x86")) { if (OsArch.toLowerCase().startsWith("win32-x86")) {
loadLibrary = filePath + "\\wms-webapi\\src\\main\\resources\\lib\\win32\\"; loadLibrary = filePath + "\\wms-webapi\\src\\main\\resources\\lib\\win32\\";
} else if(OsArch.toLowerCase().startsWith("win32-amd64") ) { } else if (OsArch.toLowerCase().startsWith("win32-amd64")) {
loadLibrary = filePath + "\\wms-webapi\\src\\main\\resources\\lib\\win64\\"; loadLibrary = filePath + "\\wms-webapi\\src\\main\\resources\\lib\\win64\\";
} }
String loadSDKLibrary = loadLibrary + "NetDEVSDK"; String loadSDKLibrary = loadLibrary + "NetDEVSDK";

View File

@@ -22,4 +22,3 @@ public class CheckTableModle extends DefaultTableModel {
} }
} }
} }

View File

@@ -3,7 +3,6 @@ package top.wms.admin.controller.ys.utils;
import javax.swing.*; import javax.swing.*;
import javax.swing.table.TableCellEditor; import javax.swing.table.TableCellEditor;
public class ComboBoxTable extends JTable { public class ComboBoxTable extends JTable {
/** /**
* 序列化 * 序列化
@@ -12,7 +11,7 @@ public class ComboBoxTable extends JTable {
private int myRow = -1, myCol = -1; private int myRow = -1, myCol = -1;
TableCellEditor myEditor; TableCellEditor myEditor;
public void setComboCell(int r, int c, String[]items) { public void setComboCell(int r, int c, String[] items) {
this.myRow = r; this.myRow = r;
this.myCol = c; this.myCol = c;
TableCellEditor ce = new MyComboBoxEditor(items); TableCellEditor ce = new MyComboBoxEditor(items);

View File

@@ -24,10 +24,8 @@ public class Common {
public static final int NETDEMO_PICTURE_SIZE = 1048576; /* 图片内存建议分配大小 */ public static final int NETDEMO_PICTURE_SIZE = 1048576; /* 图片内存建议分配大小 */
public static boolean isIP(String addr) public static boolean isIP(String addr) {
{ if (addr.length() < 7 || addr.length() > 15 || "".equals(addr)) {
if(addr.length() < 7 || addr.length() > 15 || "".equals(addr))
{
return false; return false;
} }
/** /**
@@ -61,7 +59,7 @@ public class Common {
public static String DevideTypeToString(int nDevideType) { public static String DevideTypeToString(int nDevideType) {
String strDevideType = ""; String strDevideType = "";
switch(nDevideType){ switch (nDevideType) {
case NetDEVSDKLib.NETDEV_DEVICE_TYPE_E.NETDEV_DTYPE_UNKNOWN: case NetDEVSDKLib.NETDEV_DEVICE_TYPE_E.NETDEV_DTYPE_UNKNOWN:
strDevideType = "UNKNOWN"; strDevideType = "UNKNOWN";
break; break;
@@ -107,7 +105,7 @@ public class Common {
public static String DevideStatusToString(int nStatus) { public static String DevideStatusToString(int nStatus) {
String strStatus = ""; String strStatus = "";
switch(nStatus){ switch (nStatus) {
case NetDEVSDKLib.NETDEV_CHANNEL_STATUS_E.NETDEV_CHL_STATUS_OFFLINE: case NetDEVSDKLib.NETDEV_CHANNEL_STATUS_E.NETDEV_CHL_STATUS_OFFLINE:
strStatus = "offline"; strStatus = "offline";
break; break;
@@ -126,7 +124,7 @@ public class Common {
public static String CHNStatusToString(int nStatus) { public static String CHNStatusToString(int nStatus) {
String strStatus = ""; String strStatus = "";
switch(nStatus){ switch (nStatus) {
case NetDEVSDKLib.NETDEV_CHN_STATUS_E.NETDEV_CHN_STATUS_OFFLINE: case NetDEVSDKLib.NETDEV_CHN_STATUS_E.NETDEV_CHN_STATUS_OFFLINE:
strStatus = "offline"; strStatus = "offline";
break; break;
@@ -143,18 +141,14 @@ public class Common {
return strStatus; return strStatus;
} }
public static boolean isValidDate(String seconds,String format) public static boolean isValidDate(String seconds, String format) {
{
SimpleDateFormat dateFormat = null; SimpleDateFormat dateFormat = null;
dateFormat = new SimpleDateFormat(format); dateFormat = new SimpleDateFormat(format);
dateFormat.setLenient(false); dateFormat.setLenient(false);
try try {
{
dateFormat.parse(seconds); dateFormat.parse(seconds);
return true; return true;
} } catch (Exception e) {
catch (Exception e)
{
// 如果throw java.text.ParseException或者NullPointerException就说明格式不对 // 如果throw java.text.ParseException或者NullPointerException就说明格式不对
return false; return false;
} }
@@ -162,28 +156,32 @@ public class Common {
/** /**
* 时间戳转换成日期格式字符串 * 时间戳转换成日期格式字符串
*
* @param seconds 精确到秒的字符串 * @param seconds 精确到秒的字符串
* @param formatStr * @param formatStr
* @return * @return
*/ */
public static String timeStamp2Date(String seconds,String format) { public static String timeStamp2Date(String seconds, String format) {
if(seconds == null || seconds.isEmpty() || seconds.equals("null")){ if (seconds == null || seconds.isEmpty() || seconds.equals("null")) {
return ""; return "";
} }
if(format == null || format.isEmpty()) format = "yyyy-MM-dd HH:mm:ss"; if (format == null || format.isEmpty())
format = "yyyy-MM-dd HH:mm:ss";
SimpleDateFormat sdf = new SimpleDateFormat(format); SimpleDateFormat sdf = new SimpleDateFormat(format);
return sdf.format(new Date(Long.valueOf(seconds+"000"))); return sdf.format(new Date(Long.valueOf(seconds + "000")));
} }
/** /**
* 日期格式字符串转换成时间戳 * 日期格式字符串转换成时间戳
*
* @param date 字符串日期 * @param date 字符串日期
* @param format 如yyyy-MM-dd HH:mm:ss * @param format 如yyyy-MM-dd HH:mm:ss
* @return * @return
*/ */
public static long date2TimeStamp(String date_str,String format){ public static long date2TimeStamp(String date_str, String format) {
try { try {
SimpleDateFormat sdf = new SimpleDateFormat(format); SimpleDateFormat sdf = new SimpleDateFormat(format);
return sdf.parse(date_str).getTime()/1000; return sdf.parse(date_str).getTime() / 1000;
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
@@ -192,11 +190,12 @@ public class Common {
/** /**
* 取得当前时间戳(精确到秒) * 取得当前时间戳(精确到秒)
*
* @return * @return
*/ */
public static long timeStamp(){ public static long timeStamp() {
long time = System.currentTimeMillis(); long time = System.currentTimeMillis();
return time/1000; return time / 1000;
} }
public static String AlarmTypeToString(int nAlarmType) { public static String AlarmTypeToString(int nAlarmType) {
@@ -646,27 +645,25 @@ public class Common {
pJavaStu.read(); pJavaStu.read();
} }
public static void GetPointerData(Pointer pNativeData, Structure pJavaStu) public static void GetPointerData(Pointer pNativeData, Structure pJavaStu) {
{
GetPointerDataToStruct(pNativeData, 0, pJavaStu); GetPointerDataToStruct(pNativeData, 0, pJavaStu);
} }
public static void GetPointerDataToStructArr(Pointer pNativeData, Structure []pJavaStuArr) { public static void GetPointerDataToStructArr(Pointer pNativeData, Structure[] pJavaStuArr) {
long offset = 0; long offset = 0;
for (int i=0; i<pJavaStuArr.length; ++i) for (int i = 0; i < pJavaStuArr.length; ++i) {
{
GetPointerDataToStruct(pNativeData, offset, pJavaStuArr[i]); GetPointerDataToStruct(pNativeData, offset, pJavaStuArr[i]);
offset += pJavaStuArr[i].size(); offset += pJavaStuArr[i].size();
} }
} }
public static void SetStructDataToPointer(Structure pJavaStu, Pointer pNativeData, long OffsetOfpNativeData){ public static void SetStructDataToPointer(Structure pJavaStu, Pointer pNativeData, long OffsetOfpNativeData) {
pJavaStu.write(); pJavaStu.write();
Pointer pJavaMem = pJavaStu.getPointer(); Pointer pJavaMem = pJavaStu.getPointer();
pNativeData.write(OffsetOfpNativeData, pJavaMem.getByteArray(0, pJavaStu.size()), 0, pJavaStu.size()); pNativeData.write(OffsetOfpNativeData, pJavaMem.getByteArray(0, pJavaStu.size()), 0, pJavaStu.size());
} }
public static void SetStructArrToPointerData(Structure []pJavaStuArr, Pointer pNativeData) { public static void SetStructArrToPointerData(Structure[] pJavaStuArr, Pointer pNativeData) {
long offset = 0; long offset = 0;
for (int i = 0; i < pJavaStuArr.length; ++i) { for (int i = 0; i < pJavaStuArr.length; ++i) {
SetStructDataToPointer(pJavaStuArr[i], pNativeData, offset); SetStructDataToPointer(pJavaStuArr[i], pNativeData, offset);
@@ -674,7 +671,6 @@ public class Common {
} }
} }
// 获取当前时间 // 获取当前时间
public static String getDate() { public static String getDate() {
SimpleDateFormat simpleDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss SSS"); SimpleDateFormat simpleDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss SSS");
@@ -684,27 +680,23 @@ public class Common {
} }
//Point类型转byte数组写文件 //Point类型转byte数组写文件
public static void savePicture(Pointer pBuf, int dwBufSize, String strFileName) public static void savePicture(Pointer pBuf, int dwBufSize, String strFileName) {
{ try {
try
{
FileOutputStream fos = new FileOutputStream(strFileName); FileOutputStream fos = new FileOutputStream(strFileName);
fos.write(pBuf.getByteArray(0, dwBufSize), 0, dwBufSize); fos.write(pBuf.getByteArray(0, dwBufSize), 0, dwBufSize);
fos.close(); fos.close();
} catch (Exception e){ } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
//byte数组写文件 //byte数组写文件
public static void savePicture(byte[] pBuf, int dwBufOffset, int dwBufSize, String sDstFile) public static void savePicture(byte[] pBuf, int dwBufOffset, int dwBufSize, String sDstFile) {
{ try {
try
{
FileOutputStream fos = new FileOutputStream(sDstFile); FileOutputStream fos = new FileOutputStream(sDstFile);
fos.write(pBuf, dwBufOffset, dwBufSize); fos.write(pBuf, dwBufOffset, dwBufSize);
fos.close(); fos.close();
} catch (Exception e){ } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
@@ -728,8 +720,7 @@ public class Common {
} }
try { try {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked") T[] array = (T[])Array.newInstance(clazz, size);
T[] array = (T[]) Array.newInstance(clazz, size);
for (int i = 0; i < size; i++) { for (int i = 0; i < size; i++) {
T t = clazz.newInstance(); T t = clazz.newInstance();
Pointer offsetPointer = pointer.share(t.size() * i); Pointer offsetPointer = pointer.share(t.size() * i);
@@ -747,11 +738,11 @@ public class Common {
return; return;
} }
for(int i = 0; i < dst.length; i++) { for (int i = 0; i < dst.length; i++) {
dst[i] = 0; dst[i] = 0;
} }
byte []szSrc; byte[] szSrc;
try { try {
szSrc = src.getBytes("utf-8"); szSrc = src.getBytes("utf-8");
@@ -760,7 +751,7 @@ public class Common {
} }
if (szSrc != null) { if (szSrc != null) {
int len = szSrc.length >= dst.length ? dst.length-1:szSrc.length; int len = szSrc.length >= dst.length ? dst.length - 1 : szSrc.length;
System.arraycopy(szSrc, 0, dst, 0, len); System.arraycopy(szSrc, 0, dst, 0, len);
} }
} }
@@ -780,33 +771,29 @@ public class Common {
} }
} }
/** /**
* 读取图片数据 * 读取图片数据
*
* @param file 图片路径 * @param file 图片路径
* @param memory 图片数据缓存 * @param memory 图片数据缓存
* @return * @return
*/ */
public static boolean ReadAllFileToMemory(String file, Memory memory) { public static boolean ReadAllFileToMemory(String file, Memory memory) {
if (memory != Memory.NULL) if (memory != Memory.NULL) {
{
long fileLen = GetFileSize(file); long fileLen = GetFileSize(file);
if (fileLen <= 0) if (fileLen <= 0) {
{
return false; return false;
} }
try { try {
File infile = new File(file); File infile = new File(file);
if (infile.canRead()) if (infile.canRead()) {
{
FileInputStream in = new FileInputStream(infile); FileInputStream in = new FileInputStream(infile);
int buffLen = 1024; int buffLen = 1024;
byte[] buffer = new byte[buffLen]; byte[] buffer = new byte[buffLen];
long currFileLen = 0; long currFileLen = 0;
int readLen = 0; int readLen = 0;
while (currFileLen < fileLen) while (currFileLen < fileLen) {
{
readLen = in.read(buffer); readLen = in.read(buffer);
memory.write(currFileLen, buffer, 0, readLen); memory.write(currFileLen, buffer, 0, readLen);
currFileLen += readLen; currFileLen += readLen;
@@ -814,14 +801,11 @@ public class Common {
in.close(); in.close();
return true; return true;
} } else {
else
{
System.err.println("Failed to open file %s for read!!!\n"); System.err.println("Failed to open file %s for read!!!\n");
return false; return false;
} }
}catch (Exception e) } catch (Exception e) {
{
System.err.println("Failed to open file %s for read!!!\n"); System.err.println("Failed to open file %s for read!!!\n");
e.printStackTrace(); e.printStackTrace();
} }
@@ -834,9 +818,7 @@ public class Common {
File f = new File(filePath); File f = new File(filePath);
if (f.exists() && f.isFile()) { if (f.exists() && f.isFile()) {
return f.length(); return f.length();
} } else {
else
{
return 0; return 0;
} }
} }
@@ -870,8 +852,7 @@ public class Common {
return memory; return memory;
} }
public static String EnumNETDEV_PLATE_COLOR_EConventToString(int dwEnum) public static String EnumNETDEV_PLATE_COLOR_EConventToString(int dwEnum) {
{
String strTempString = ""; String strTempString = "";
switch (dwEnum) { switch (dwEnum) {
case NETDEV_PLATE_COLOR_E.NETDEV_PLATE_COLOR_BLACK_E: case NETDEV_PLATE_COLOR_E.NETDEV_PLATE_COLOR_BLACK_E:
@@ -950,8 +931,7 @@ public class Common {
return strTempString; return strTempString;
} }
public static int StringConventToEnumNETDEV_PLATE_COLOR_E(String strColor) public static int StringConventToEnumNETDEV_PLATE_COLOR_E(String strColor) {
{
int dwTemp = 0; int dwTemp = 0;
switch (strColor) { switch (strColor) {
case "BLACK": case "BLACK":
@@ -1030,8 +1010,7 @@ public class Common {
return dwTemp; return dwTemp;
} }
public static String EnumNETDEV_PLATE_TYPE_EConventToString(int dwEnum) public static String EnumNETDEV_PLATE_TYPE_EConventToString(int dwEnum) {
{
String strTempString = ""; String strTempString = "";
switch (dwEnum) { switch (dwEnum) {
case NETDEV_PLATE_TYPE_E.NETDEV_PLATE_TYPE_BIG_CAR_E: case NETDEV_PLATE_TYPE_E.NETDEV_PLATE_TYPE_BIG_CAR_E:
@@ -1124,8 +1103,7 @@ public class Common {
return strTempString; return strTempString;
} }
public static int StringConventToEnumNETDEV_PLATE_TYPE_E(String strEnum) public static int StringConventToEnumNETDEV_PLATE_TYPE_E(String strEnum) {
{
int dwRet = 0; int dwRet = 0;
switch (strEnum) { switch (strEnum) {
case "BIG_CAR": case "BIG_CAR":
@@ -1218,8 +1196,7 @@ public class Common {
return dwRet; return dwRet;
} }
public static int StringConventToEnumNETDEV_VEHICLE_MONITOR_TYPE_E(String strMonitorType) public static int StringConventToEnumNETDEV_VEHICLE_MONITOR_TYPE_E(String strMonitorType) {
{
int dwTemp = 0; int dwTemp = 0;
switch (strMonitorType) { switch (strMonitorType) {
case "Robbed car": case "Robbed car":
@@ -1245,8 +1222,7 @@ public class Common {
return dwTemp; return dwTemp;
} }
public static String EnumNETDEV_DISK_WORK_STATUS_EConventToString(int dwEnum) public static String EnumNETDEV_DISK_WORK_STATUS_EConventToString(int dwEnum) {
{
String strTempString = ""; String strTempString = "";
switch (dwEnum) { switch (dwEnum) {
case NETDEV_DISK_WORK_STATUS_E.NETDEV_DISK_WORK_STATUS_EMPTY: case NETDEV_DISK_WORK_STATUS_E.NETDEV_DISK_WORK_STATUS_EMPTY:
@@ -1276,8 +1252,7 @@ public class Common {
return strTempString; return strTempString;
} }
public static String EnumNETDEV_VIDEO_QUALITY_EConventToString(int dwEnum) public static String EnumNETDEV_VIDEO_QUALITY_EConventToString(int dwEnum) {
{
String strTempString = ""; String strTempString = "";
switch (dwEnum) { switch (dwEnum) {
case NETDEV_VIDEO_QUALITY_E.NETDEV_VQ_L0: case NETDEV_VIDEO_QUALITY_E.NETDEV_VQ_L0:
@@ -1319,8 +1294,7 @@ public class Common {
return strTempString; return strTempString;
} }
public static int StringConventToEnumNETDEV_VIDEO_QUALITY_E(String strVideoQuality) public static int StringConventToEnumNETDEV_VIDEO_QUALITY_E(String strVideoQuality) {
{
int dwTemp = 0; int dwTemp = 0;
switch (strVideoQuality) { switch (strVideoQuality) {
case "L0": case "L0":

View File

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

View File

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