Commit 01388fc1 authored by tangwei's avatar tangwei

修改扫描bug

parent f041fec9
...@@ -15,7 +15,7 @@ import lombok.experimental.Accessors; ...@@ -15,7 +15,7 @@ import lombok.experimental.Accessors;
@Data @Data
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@Accessors(chain = true) @Accessors(chain = true)
@TableName("asf_fire_rpn_change_log") @TableName("asf_fire_rpn_change_CODE)
public class FireRpnChangeLog extends BaseEntity { public class FireRpnChangeLog extends BaseEntity {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
......
//package com.yeejoin.equipmanage.common.annotation;
//
//import java.lang.annotation.*;
//
///**
// * @author DELL
// */
//@Retention(RetentionPolicy.RUNTIME)
//@Target({ElementType.TYPE})
//@Documented
//public @interface FillCommonUserField {
// boolean isAutoFill() default true;
//}
...@@ -22,5 +22,6 @@ public class GlobalCache { ...@@ -22,5 +22,6 @@ public class GlobalCache {
*/ */
public static Map<String, String> paramMap = new ConcurrentHashMap<>(1000); public static Map<String, String> paramMap = new ConcurrentHashMap<>(1000);
private GlobalCache() {
}
} }
...@@ -80,112 +80,6 @@ public interface Constant { ...@@ -80,112 +80,6 @@ public interface Constant {
String fourSmallTopicfireFoamMistSys = "fourSmallTopicfireFoamMistSys"; String fourSmallTopicfireFoamMistSys = "fourSmallTopicfireFoamMistSys";
// String SMALL_PRO_PRCODE = "SMALL_PRO_PRCODE_";
/**
* 任务-作业交底
*/
// Integer JOB_TYPE = 0;
/**
* 任务-三交三查
*/
// Integer HAND_QUERY = 1;
// String JSON_NULL = "[]";
/**
* 违规管理
*/
// Integer BAD_MANAGEMENT = 2;
// Charset DEFAULT_CHARSET = StandardCharsets.UTF_8;
// String FILE_SEPARATOR = System.getProperty("file.separator");
// DateTimeFormatter DATE_TIME_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
// String PAGE_NUM = "0";
//
// String SIZE_NUM = "20";
//
// String PAGE = "page";
//
// String SIZE = "size";
//
//
// String ZERO = "0";
//
// String ONE = "1";
//
// String TWO = "2";
//
// String THREE = "3";
//
// String FOUR = "4";
//
// String FIVE = "5";
/**
* 请求错误
*/
// String ERROR = "300";
/**
* 无权限
*/
// String PERMISSION = "401";
/**
* 请求成功,其他错误
*/
// String DATA_NULL = "402";
/**
* 请求失败
*/
// String FAILED = "999";
/**
* 最大值
*/
// Integer MAX = 32767;
/**
* 数据请求返回码
*/
//成功
// public static final int RESCODE_SUCCESS = 1000;
// //成功(有返回信息)
// public static final int RESCODE_SUCCESS_MSG = 1001;
// //请求抛出异常
// public static final int RESCODE_EXCEPTION = 1002;
// //未登陆状态
// public static final int RESCODE_NOLOGIN = 1003;
// //查询结果为空
// public static final int RESCODE_NOEXIST = 1004;
// //无操作权限
// public static final int RESCODE_NOAUTH = 1005;
// //登录过期
// public static final int RESCODE_LOGINEXPIRE = 1006;
/**
* token
*/
// //Token过期
// public static final int JWT_ERRCODE_EXPIRE = 1007;
// //验证不通过
// public static final int JWT_ERRCODE_FAIL = 1008;
/**
* jwt
*/
// public static final String JWT_ID = "jwt-black";//jwt签发者
// public static final String JWT_SECRET = "Isi5Ob9OfvJt+4IHoMJlHkS1ttg=";//密匙
// public static final int JWT_TTL = 60 * 60 * 1000; // 60*60*1000; //millisecond
// public static final int JWT_REFRESH_INTERVAL = 18 * 1000; //55*60*1000; //millisecond
// public static final int JWT_REFRESH_TTL = 60 * 1000; // 12*60*60*1000; //millisecond
} }
package com.yeejoin.equipmanage.common.datasync.enums; package com.yeejoin.equipmanage.common.datasync.enums;
import com.yeejoin.equipmanage.common.utils.finalString;
/** /**
* <h1>同步数据类型</h1> * <h1>同步数据类型</h1>
* *
...@@ -7,112 +9,112 @@ package com.yeejoin.equipmanage.common.datasync.enums; ...@@ -7,112 +9,112 @@ package com.yeejoin.equipmanage.common.datasync.enums;
* @Date 2021-04-01 09:20 * @Date 2021-04-01 09:20
*/ */
public enum SyncDataTypeEnum { public enum SyncDataTypeEnum {
/** /**
* 巡检项 * 巡检项
*/ */
ASF_FIRE_PATROL_ITEM("11", "cs/v1/fireASF/dataSync", "isNotIot"), ASF_FIRE_PATROL_ITEM("11", finalString.URL, finalString.ISNOTIOT),
/** /**
* 巡检点 * 巡检点
*/ */
ASF_FIRE_PATROL_POINT("12", "cs/v1/fireASF/dataSync", "isNotIot"), ASF_FIRE_PATROL_POINT("12", finalString.URL, finalString.ISNOTIOT),
/** /**
* 巡检点检查项 * 巡检点检查项
*/ */
ASF_FIRE_PATROL_POINT_ITEM("60", "cs/v1/fireASF/dataSync", "isNotIot"), ASF_FIRE_PATROL_POINT_ITEM("60", finalString.URL, finalString.ISNOTIOT),
/** /**
* 巡检路线 * 巡检路线
*/ */
ASF_FIRE_PATROL_ROUTE("61", "cs/v1/fireASF/dataSync", "isNotIot"), ASF_FIRE_PATROL_ROUTE("61", finalString.URL, finalString.ISNOTIOT),
/** /**
* 巡检路线点 * 巡检路线点
*/ */
ASF_FIRE_PATROL_ROUTE_POINT("62", "cs/v1/fireASF/dataSync", "isNotIot"), ASF_FIRE_PATROL_ROUTE_POINT("62", finalString.URL, finalString.ISNOTIOT),
/** /**
* 巡检路线点检查项 * 巡检路线点检查项
*/ */
ASF_FIRE_PATROL_ROUTE_POINT_ITEM("63", "cs/v1/fireASF/dataSync", "isNotIot"), ASF_FIRE_PATROL_ROUTE_POINT_ITEM("63", finalString.URL, finalString.ISNOTIOT),
/** /**
* 巡检计划 * 巡检计划
*/ */
ASF_FIRE_PATROL_PLAN("64", "cs/v1/fireASF/dataSync", "isNotIot"), ASF_FIRE_PATROL_PLAN("64", finalString.URL, finalString.ISNOTIOT),
/** /**
* 巡检任务 * 巡检任务
*/ */
ASF_FIRE_PATROL_PLAN_TASK("65", "cs/v1/fireASF/dataSync", "isNotIot"), ASF_FIRE_PATROL_PLAN_TASK("65", finalString.URL, finalString.ISNOTIOT),
/** /**
* 任务详情 * 任务详情
*/ */
ASF_FIRE_PATROL_PLAN_TASK_DETAIL("66", "cs/v1/fireASF/dataSync", "isNotIot"), ASF_FIRE_PATROL_PLAN_TASK_DETAIL("66", finalString.URL, finalString.ISNOTIOT),
/** /**
* 巡检记录 * 巡检记录
*/ */
ASF_FIRE_PATROL_CHECK_RECORD("67", "cs/v1/fireASF/dataSync", "isNotIot"), ASF_FIRE_PATROL_CHECK_RECORD("67", finalString.URL, finalString.ISNOTIOT),
/** /**
* 巡查记录详情 * 巡查记录详情
*/ */
ASF_FIRE_PATROL_CHECK_RECORD_DETAIL("68", "cs/v1/fireASF/dataSync", "isNotIot"), ASF_FIRE_PATROL_CHECK_RECORD_DETAIL("68", finalString.URL, finalString.ISNOTIOT),
/** /**
* 区域 * 区域
*/ */
AST_AREA("01", "cs/v1/fireAST/dataSync", "isNotIot"), AST_AREA("01", finalString.URLST, finalString.ISNOTIOT),
/** /**
* 建筑 * 建筑
*/ */
AST_BUILDING("02", "cs/v1/fireAST/dataSync", "building"), AST_BUILDING("02", finalString.URLST, "building"),
/** /**
* 围墙 * 围墙
*/ */
AST_WALL("03", "cs/v1/fireAST/dataSync", "isNotIot"), AST_WALL("03", finalString.URLST, finalString.ISNOTIOT),
/** /**
* 楼层 * 楼层
*/ */
AST_FLOOR("04", "cs/v1/fireAST/dataSync", "floor"), AST_FLOOR("04", finalString.URLST, "floor"),
/** /**
* 小室 * 小室
*/ */
AST_ROOM("05", "cs/v1/fireAST/dataSync", "room"), AST_ROOM("05", finalString.URLST, "room"),
/** /**
* 消防系统 * 消防系统
*/ */
AST_FIRE_FIGHTING("07", "cs/v1/fireAST/dataSync", "isNotIot"), AST_FIRE_FIGHTING("07", finalString.URLST, finalString.ISNOTIOT),
/** /**
* 消防设备 * 消防设备
*/ */
AST_FIRE_EQUIP("08", "cs/v1/fireAST/dataSync", "isNotIot"), AST_FIRE_EQUIP("08", finalString.URLST, finalString.ISNOTIOT),
/** /**
* 消防设备参数信息 * 消防设备参数信息
*/ */
AST_FIRE_EQUIP_INFO("0801", "cs/v1/fireAST/dataSync", "isNotIot"), AST_FIRE_EQUIP_INFO("0801", finalString.URLST, finalString.ISNOTIOT),
/** /**
* 消防设备量测信息 * 消防设备量测信息
*/ */
AST_FIRE_EQUIP_MEASUREMENT("0802", "cs/v1/fireAST/dataSync", "isIot"), AST_FIRE_EQUIP_MEASUREMENT("0802", finalString.URLST, "isIot"),
/** /**
* 消防设备火警 * 消防设备火警
*/ */
AST_FIRE_EQUIP_ALARM("0803", "cs/v1/fireASF/dataSync", "isNotIot"), AST_FIRE_EQUIP_ALARM("0803", finalString.URL, finalString.ISNOTIOT),
/** /**
* 消防设备故障 * 消防设备故障
*/ */
AST_FIRE_EQUIP_FAULT_ALARM("0804", "cs/v1/fireASF/dataSync", "isNotIot"), AST_FIRE_EQUIP_FAULT_ALARM("0804", finalString.URL, finalString.ISNOTIOT),
/** /**
* 消防设备缺陷 * 消防设备缺陷
*/ */
AST_FIRE_EQUIP_DEFECT_ALARM("0805", "cs/v1/fireASF/dataSync", "isNotIot"), AST_FIRE_EQUIP_DEFECT_ALARM("0805", finalString.URL, finalString.ISNOTIOT),
/** /**
* 消防车辆 * 消防车辆
*/ */
AST_FIRE_VEHICLE("09", "cs/v1/fireAST/dataSync", "isNotIot"), AST_FIRE_VEHICLE("09", finalString.URLST, finalString.ISNOTIOT),
/** /**
* 消防车辆参数信息 * 消防车辆参数信息
*/ */
AST_FIRE_VEHICLE_INFO("0901", "cs/v1/fireAST/dataSync", "isNotIot"), AST_FIRE_VEHICLE_INFO("0901", finalString.URLST, finalString.ISNOTIOT),
/** /**
* 消防车辆量测信息 * 消防车辆量测信息
*/ */
AST_FIRE_VEHICLE_MEASUREMENT("0902", "cs/v1/fireAST/dataSync", "isIot"), AST_FIRE_VEHICLE_MEASUREMENT("0902", finalString.URLST, "isIot");
;
/** /**
* 资源类型编码 * 资源类型编码
......
...@@ -37,7 +37,5 @@ public class MaintenanceResourceDto extends BaseTreeNode { ...@@ -37,7 +37,5 @@ public class MaintenanceResourceDto extends BaseTreeNode {
*/ */
private String contractId; private String contractId;
public MaintenanceResourceDto() {
}
} }
\ No newline at end of file
//package com.yeejoin.equipmanage.common.entity;
//
//import com.baomidou.mybatisplus.annotation.TableField;
//import com.baomidou.mybatisplus.annotation.TableName;
//import com.yeejoin.equipmanage.common.entity.publics.BaseEntity;
//import io.swagger.annotations.ApiModel;
//import io.swagger.annotations.ApiModelProperty;
//import lombok.Data;
//import lombok.EqualsAndHashCode;
//
//import java.util.Date;
//
///**
// * @author DELL
// */
//@Data
//@TableName("wl_equipment_specific_alarm")
//@EqualsAndHashCode(callSuper = true)
//@ApiModel(value = "wl_equipment_specific_alarm", description = "设备报警信息表")
//public class ConfirmEquipmentSpecificAlarm extends BaseEntity {
//
// @ApiModelProperty(value = "机构code")
// @TableField("org_code")
// private String orgCode;
//
// @ApiModelProperty(value = "装备名称")
// @TableField("equipment_specific_name")
// private String equipmentSpecificName;
//
// @ApiModelProperty(value = "消防设备id")
// @TableField("equipment_specific_id")
// private Long equipmentSpecificId;
//
// @ApiModelProperty(value = "iot编码")
// @TableField("iot_code")
// private String iotCode;
//
// @ApiModelProperty(value = "指标名称")
// @TableField("equipment_specific_index_name")
// private String equipmentSpecificIndexName;
//
// @ApiModelProperty(value = "指标编码")
// @TableField("equipment_specific_index_key")
// private String equipmentSpecificIndexKey;
//
// @ApiModelProperty(value = "报警值")
// @TableField("equipment_specific_index_value")
// private String equipmentSpecificIndexValue;
//
// @ApiModelProperty(value = "发生频次")
// @TableField("frequency")
// private int frequency;
//
// @ApiModelProperty(value = "报警状态:1报警0恢复")
// @TableField("status")
// private int status;
//
// @ApiModelProperty(value = "报警类型:alarm_type_fire(火灾报警)/alarm_type_trouble(故障告警)")
// @TableField("type")
// private String type;
//
// @ApiModelProperty(value = "更新时间")
// @TableField("update_date")
// private Date updateDate;
//
// @ApiModelProperty(value = "告警恢复时间")
// @TableField("recovery_date")
// private Date recoveryDate;
//
// @ApiModelProperty(value = "指标id")
// @TableField("equipment_index_id")
// private Long equipmentIndexId;
//
// @ApiModelProperty(value = "确认类型")
// @TableField("confirm_type")
// private String confirmType;
//
// @ApiModelProperty(value = "报警原因")
// @TableField("alam_reason")
// private String alamReason;
//
// @ApiModelProperty(value = "处理情况")
// @TableField("resolve_result")
// private String resolveResult;
//
// @ApiModelProperty(value = "确警人员")
// @TableField("confirm_user")
// private String confirmUser;
//
// @ApiModelProperty(value = "确警时间")
// @TableField("confirm_date")
// private Date confirmDate;
//
//
// @ApiModelProperty(value = "画布id")
// @TableField(exist = false)
// private Long sceneId;
//
// @ApiModelProperty(value = "告警内容")
// @TableField(exist = false)
// private String alamContent;
//
// @ApiModelProperty(value = "告警部位")
// @TableField(exist = false)
// private String alamPlace;
//
// @ApiModelProperty(value = "告警设备名称")
// @TableField(exist = false)
// private String equipmentName;
//
// @ApiModelProperty(value = "保护对象")
// @TableField(exist = false)
// private String protectName;
//
// @ApiModelProperty(value = "是否已处理")
// @TableField(exist = false)
// private String isConfirm;
//
// @ApiModelProperty(value = "是否批量")
// @TableField(exist = false)
// private int isBatch;
//
//
//}
...@@ -49,9 +49,7 @@ public class EquipmentCategory extends BaseEntity implements TreeNode<EquipmentC ...@@ -49,9 +49,7 @@ public class EquipmentCategory extends BaseEntity implements TreeNode<EquipmentC
@ApiModelProperty(value = "行业id") @ApiModelProperty(value = "行业id")
private String industryCode; private String industryCode;
// 此业务字段暂时不用,后期业务下发可放开
// @ApiModelProperty(value = "装备二级分类图片")
// private String img;
@ApiModelProperty(value = "行业名称") @ApiModelProperty(value = "行业名称")
@TableField(exist = false) @TableField(exist = false)
......
...@@ -103,8 +103,7 @@ public class EquipmentSpecificIndex extends BaseEntity { ...@@ -103,8 +103,7 @@ public class EquipmentSpecificIndex extends BaseEntity {
@TableField(exist = false) @TableField(exist = false)
private String indexName; private String indexName;
// @TableField(exist = false)
// private String equipmentSpecificName;
@TableField(exist = false) @TableField(exist = false)
private String equipmentSpecificIndexName; private String equipmentSpecificIndexName;
......
package com.yeejoin.equipmanage.common.entity; package com.yeejoin.equipmanage.common.entity;
import com.yeejoin.equipmanage.common.exception.BaseException;
import lombok.NonNull; import lombok.NonNull;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
...@@ -66,7 +67,9 @@ public class MyByteArrayMultipartFile implements MultipartFile { ...@@ -66,7 +67,9 @@ public class MyByteArrayMultipartFile implements MultipartFile {
try { try {
outputStream = new FileOutputStream(destination); outputStream = new FileOutputStream(destination);
outputStream.write(bytes); outputStream.write(bytes);
} finally { }catch(Exception e){
throw new BaseException("系统异常!");
}finally {
if (outputStream != null) { if (outputStream != null) {
outputStream.close(); outputStream.close();
} }
......
...@@ -9,7 +9,7 @@ import lombok.Data; ...@@ -9,7 +9,7 @@ import lombok.Data;
* @since v2.0 * @since v2.0
*/ */
@Data @Data
public class SourceNameListDTO extends BaseDTO { public class SourceNameListDTO extends BaseDTO<SourceNameListDTO> {
/** /**
* 建筑id * 建筑id
*/ */
......
...@@ -15,7 +15,7 @@ import java.util.Date; ...@@ -15,7 +15,7 @@ import java.util.Date;
* @version $Id: TopographyTreeDTO.java, v 0.1 2021年10月19日 下午1:46:23 gwb Exp $ * @version $Id: TopographyTreeDTO.java, v 0.1 2021年10月19日 下午1:46:23 gwb Exp $
*/ */
@Data @Data
public class TopographyTreeDTO implements TreeNode { public class TopographyTreeDTO implements TreeNode<TopographyTreeDTO,String> {
/** /**
...@@ -69,7 +69,7 @@ public class TopographyTreeDTO implements TreeNode { ...@@ -69,7 +69,7 @@ public class TopographyTreeDTO implements TreeNode {
*/ */
private String authOrg; private String authOrg;
private Collection children; private Collection<TopographyTreeDTO> children;
@Override @Override
public String getMyParentId() public String getMyParentId()
...@@ -83,11 +83,11 @@ public class TopographyTreeDTO implements TreeNode { ...@@ -83,11 +83,11 @@ public class TopographyTreeDTO implements TreeNode {
return this.code; return this.code;
} }
@Override
public int compareTo(Object o)
{
TreeNode node = (TreeNode) o;
return node.getMyId().equals(this.code)? 0 : 1;
}
@Override
public int compareTo(TopographyTreeDTO o) {
TopographyTreeDTO node = o;
return node.getMyId().equals(this.code)? 0 : 1;
}
} }
...@@ -35,8 +35,7 @@ public class BaseTreeNode { ...@@ -35,8 +35,7 @@ public class BaseTreeNode {
public BaseTreeNode() {
}
public String getId() { public String getId() {
return id; return id;
...@@ -83,8 +82,9 @@ public class BaseTreeNode { ...@@ -83,8 +82,9 @@ public class BaseTreeNode {
} }
public void addChild(BaseTreeNode baseTreeNode) { public void addChild(BaseTreeNode baseTreeNode) {
if (this.children == null) { if (this.children == null) {
this.setChildren(new ArrayList()); this.setChildren(new ArrayList<BaseTreeNode>());
} }
this.getChildren().add(baseTreeNode); this.getChildren().add(baseTreeNode);
} }
......
...@@ -27,28 +27,6 @@ public class DevOverviewVO { ...@@ -27,28 +27,6 @@ public class DevOverviewVO {
private String qrCode; private String qrCode;
// 图片名称 // 图片名称
private String picName; private String picName;
//'items': [
// { 'key': '设备名称', 'value': ''
// },
// { 'key': '器材分类', 'value': ''
// },
// { 'key': '设备名称', 'value': ''
// },
// { 'key': '安装位置', 'value': ''
// },
// { 'key': '运行状态', 'value': ''
// },
// { 'key': '维保状态', 'value': ''
// },
// { 'key': '巡检状态', 'value': ''
// },
// { 'key': '编码', 'value': ''
// },
// { 'key': '所属系统', 'value': ''
// },
// { 'key': '负责人', 'value': ''
// }
// ]
// }
private List<Map<String, Object>> items; private List<Map<String, Object>> items;
} }
...@@ -51,15 +51,7 @@ public class DownloadEquipmentDataVO { ...@@ -51,15 +51,7 @@ public class DownloadEquipmentDataVO {
*/ */
private Long equipmentId; private Long equipmentId;
/**
* 装备定义名
*/
// private String equipmentName;
/**
* 装备定义编码
*/
// private String equipmentCode;
/** /**
* 装备定义非核心性能指标 * 装备定义非核心性能指标
......
...@@ -17,28 +17,6 @@ public class ProductInfoVO { ...@@ -17,28 +17,6 @@ public class ProductInfoVO {
private List<String> pic; private List<String> pic;
// 图片名称 // 图片名称
private String picName; private String picName;
//'items': [
// { 'key': '名称', 'value': ''
// },
// { 'key': '规格型号', 'value': ''
// },
// { 'key': '进口/国产', 'value': ''
// },
// { 'key': '维保周期', 'value': ''
// },
// { 'key': '报废年限', 'value': ''
// },
// { 'key': '计量单位', 'value': ''
// },
// { 'key': '品牌', 'value': ''
// },
// { 'key': '国别', 'value': ''
// },
// { 'key': '巡检频率', 'value': ''
// },
// { 'key': '备注', 'value': ''
// }
// ]
// },
private List<Map<String,Object>> items; private List<Map<String,Object>> items;
} }
...@@ -20,13 +20,7 @@ public class EquipStatusChecker { ...@@ -20,13 +20,7 @@ public class EquipStatusChecker {
switch (status) { switch (status) {
case REPAIR: case REPAIR:
return createResult(false, "该装备正在维修中,不能重复维修!"); return createResult(false, "该装备正在维修中,不能重复维修!");
// case LOAN:
// return createResult(false, "该装备已借出,不能维修!");
// case BORROW:
// return createResult(false, "该装备是借用装备,不能维修!");
// case RETURN:
// return createResult(false, "该借用装备已归还借用方,不能维修!");
//
case SCRAP: case SCRAP:
return createResult(false, "该装备已报废,不能维修!"); return createResult(false, "该装备已报废,不能维修!");
case LOSS: case LOSS:
...@@ -48,12 +42,7 @@ public class EquipStatusChecker { ...@@ -48,12 +42,7 @@ public class EquipStatusChecker {
switch (status) { switch (status) {
case REPAIR: case REPAIR:
return createResult(false, "该装备正在维修中,不能保养!"); return createResult(false, "该装备正在维修中,不能保养!");
// case LOAN:
// return createResult(false, "该装备已借出,不能保养!");
// case BORROW:
// return createResult(false, "该装备是借用装备,不能保养!");
// case RETURN:
// return createResult(false, "该借用装备已归还借用方,不能保养!");
case SCRAP: case SCRAP:
return createResult(false, "该装备已报废,不能保养!"); return createResult(false, "该装备已报废,不能保养!");
case LOSS: case LOSS:
...@@ -75,12 +64,7 @@ public class EquipStatusChecker { ...@@ -75,12 +64,7 @@ public class EquipStatusChecker {
switch (status) { switch (status) {
case REPAIR: case REPAIR:
return createResult(false, "该装备正在维修中,不能调拨!"); return createResult(false, "该装备正在维修中,不能调拨!");
// case LOAN:
// return createResult(false, "该装备已借出,不能调拨!");
// case BORROW:
// return createResult(false, "该装备是借用装备,不能调拨!");
// case RETURN:
// return createResult(false, "该借用装备已归还借用方,不能调拨!");
case SCRAP: case SCRAP:
return createResult(false, "该装备已报废,不能调拨!"); return createResult(false, "该装备已报废,不能调拨!");
case LOSS: case LOSS:
...@@ -100,20 +84,14 @@ public class EquipStatusChecker { ...@@ -100,20 +84,14 @@ public class EquipStatusChecker {
switch (status) { switch (status) {
case REPAIR: case REPAIR:
return createResult(false, "该装备正在维修中,不能出库!"); return createResult(false, "该装备正在维修中,不能出库!");
// case LOAN:
// return createResult(false, "该装备已借出,不能执行出库操作!");
// case BORROW:
// return createResult(false, "该装备是借用装备,不能执行出库操作!");
// case RETURN:
// return createResult(false, "该借用装备已归还借用方,不能执行出库操作!");
case SCRAP: case SCRAP:
return createResult(false, "该装备已报废,不能执行出库操作!"); return createResult(false, "该装备已报废,不能执行出库操作!");
case LOAD: case LOAD:
return createResult(false, "该装备已配装,不能执行出库操作!"); return createResult(false, "该装备已配装,不能执行出库操作!");
// case ONDUTY:
// return createResult(false, "该装备正在执勤中,不能执行出库操作!");
default: default:
return createResult(true, ""); return createResult(true, "");
} }
...@@ -129,16 +107,10 @@ public class EquipStatusChecker { ...@@ -129,16 +107,10 @@ public class EquipStatusChecker {
switch (status) { switch (status) {
case REPAIR: case REPAIR:
return createResult(false, "该装备正在维修中,不能借出!"); return createResult(false, "该装备正在维修中,不能借出!");
// case LOAN:
// return createResult(false, "该装备已借出,不能再次借出!");
// case BORROW:
// return createResult(false, "该装备是借用装备,不能借出!");
// case RETURN:
// return createResult(false, "该借用装备已归还借用方,不能借用!");
case SCRAP: case SCRAP:
return createResult(false, "该装备已报废,不能借出!"); return createResult(false, "该装备已报废,不能借出!");
// case ONDUTY:
// return createResult(false, "该装备正在执勤中,不能借出!");
case LOSS: case LOSS:
return createResult(false, "该装备已损耗,不能借出!"); return createResult(false, "该装备已损耗,不能借出!");
default: default:
...@@ -156,16 +128,10 @@ public class EquipStatusChecker { ...@@ -156,16 +128,10 @@ public class EquipStatusChecker {
switch (status) { switch (status) {
case REPAIR: case REPAIR:
return createResult(false, "该装备正在维修中,不能转移货位!"); return createResult(false, "该装备正在维修中,不能转移货位!");
// case LOAN:
// return createResult(false, "该装备已借出,不能转移货位!");
// case BORROW:
// return createResult(false, "该装备是借用装备,不能转移货位!");
// case RETURN:
// return createResult(false, "该借用装备已归还借用方,不能转移货位!");
case SCRAP: case SCRAP:
return createResult(false, "该装备已报废,不能转移货位!"); return createResult(false, "该装备已报废,不能转移货位!");
// case ONDUTY:
// return createResult(false, "该装备正在执勤中,不能转移货位!");
case LOSS: case LOSS:
return createResult(false, "该装备已损耗,不能转移货位!"); return createResult(false, "该装备已损耗,不能转移货位!");
default: default:
...@@ -183,16 +149,10 @@ public class EquipStatusChecker { ...@@ -183,16 +149,10 @@ public class EquipStatusChecker {
switch (status) { switch (status) {
case REPAIR: case REPAIR:
return createResult(false, "该装备正在维修中,不能执勤!"); return createResult(false, "该装备正在维修中,不能执勤!");
// case LOAN:
// return createResult(false, "该装备已借出,不能执勤!");
// case BORROW:
// return createResult(false, "该装备是借用装备,不能执勤!");
// case RETURN:
// return createResult(false, "该借用装备已归还借用方,不能执勤!");
case SCRAP: case SCRAP:
return createResult(false, "该装备已报废,不能执勤!"); return createResult(false, "该装备已报废,不能执勤!");
// case ONDUTY:
// return createResult(false, "该装备正在执勤中,不能重复执勤!");
case LOSS: case LOSS:
return createResult(false, "该装备已损耗,不能执勤!"); return createResult(false, "该装备已损耗,不能执勤!");
default: default:
...@@ -208,12 +168,7 @@ public class EquipStatusChecker { ...@@ -208,12 +168,7 @@ public class EquipStatusChecker {
*/ */
public static Result isStockable(EquipStatusEnum status) { public static Result isStockable(EquipStatusEnum status) {
switch (status) { switch (status) {
// case LOAN:
// return createResult(false, "该装备已借出,不能变为在位状态!");
// case BORROW:
// return createResult(false, "该装备是借用装备,不能变为在位状态!");
// case RETURN:
// return createResult(false, "该借用装备已归还借用方,不能变为在位状态!");
case SCRAP: case SCRAP:
return createResult(false, "该装备已报废,不能变为在位状态!"); return createResult(false, "该装备已报废,不能变为在位状态!");
case LOSS: case LOSS:
...@@ -231,12 +186,7 @@ public class EquipStatusChecker { ...@@ -231,12 +186,7 @@ public class EquipStatusChecker {
*/ */
public static Result isRetirementable(EquipStatusEnum status) { public static Result isRetirementable(EquipStatusEnum status) {
switch (status) { switch (status) {
// case LOAN:
// return createResult(false, "该装备已借出,不能退役!");
// case BORROW:
// return createResult(false, "该装备是借用装备,不能退役!");
// case RETURN:
// return createResult(false, "该借用装备已归还借用方,不能退役!");
case SCRAP: case SCRAP:
return createResult(false, "该装备已报废,不能退役!"); return createResult(false, "该装备已报废,不能退役!");
case LOSS: case LOSS:
...@@ -254,18 +204,10 @@ public class EquipStatusChecker { ...@@ -254,18 +204,10 @@ public class EquipStatusChecker {
*/ */
public static Result isScrapable(EquipStatusEnum status) { public static Result isScrapable(EquipStatusEnum status) {
switch (status) { switch (status) {
// case LOAN:
// return createResult(false, "该装备已借出,不能报废!");
// case BORROW:
// return createResult(false, "该装备是借用装备,不能报废!");
// case RETURN:
// return createResult(false, "该借用装备已归还借用方,不能报废!");
case SCRAP: case SCRAP:
return createResult(false, "该装备已报废,不能再次报废!"); return createResult(false, "该装备已报废,不能再次报废!");
// case ONDUTY:
// return createResult(false, "该装备正在执勤中,请先退役后再进行报废操作!");
// case REPERTORY:
// return createResult(false, "该装备目前是库存状态,请先退役后再进行报废操作!");
case LOSS: case LOSS:
return createResult(false, "该装备目前是损耗状态,不能进行报废操作!"); return createResult(false, "该装备目前是损耗状态,不能进行报废操作!");
case LOAD: case LOAD:
...@@ -283,12 +225,7 @@ public class EquipStatusChecker { ...@@ -283,12 +225,7 @@ public class EquipStatusChecker {
*/ */
public static Result isLoadable(EquipStatusEnum status) { public static Result isLoadable(EquipStatusEnum status) {
switch (status) { switch (status) {
// case LOAN:
// return createResult(false, "该装备已借出,不能被装载!");
// case BORROW:
// return createResult(false, "该装备是借用装备,不能被装载!");
// case RETURN:
// return createResult(false, "该借用装备已归还借用方,不能被装载!");
case SCRAP: case SCRAP:
return createResult(false, "该装备已报废,不能被装载!"); return createResult(false, "该装备已报废,不能被装载!");
case REPAIR: case REPAIR:
...@@ -310,10 +247,7 @@ public class EquipStatusChecker { ...@@ -310,10 +247,7 @@ public class EquipStatusChecker {
*/ */
public static Result isReturnable(EquipStatusEnum status) { public static Result isReturnable(EquipStatusEnum status) {
switch (status) { switch (status) {
// case BORROW:
// return createResult(false, "该装备是借用装备,请让借出方执行归还操作!");
// case LOAN:
// return createResult(true, "");
default: default:
return createResult(false, "该装备未被借出,不能进行归还操作!"); return createResult(false, "该装备未被借出,不能进行归还操作!");
} }
...@@ -328,4 +262,6 @@ public class EquipStatusChecker { ...@@ -328,4 +262,6 @@ public class EquipStatusChecker {
return result; return result;
} }
private EquipStatusChecker() {
}
} }
...@@ -42,15 +42,5 @@ public enum EquipStatusEnum { ...@@ -42,15 +42,5 @@ public enum EquipStatusEnum {
return equipStatusEnum; return equipStatusEnum;
} }
// public static EquipStatusEnum getEnum(String describe) {
// EquipStatusEnum equipStatusEnum = null;
// for (EquipStatusEnum type : EquipStatusEnum.values()) {
// if (type.getDescribe().equals(describe)) {
// equipStatusEnum = type;
// break;
// }
// }
//
// return equipStatusEnum;
// }
} }
...@@ -7,12 +7,7 @@ package com.yeejoin.equipmanage.common.enums; ...@@ -7,12 +7,7 @@ package com.yeejoin.equipmanage.common.enums;
*/ */
public class TemperatureAlarm { public class TemperatureAlarm {
//规则温度
private Double ruleTemperature;
//当前温度
private Double currTemperature;
//测温单位
private String thermometryUnit;
public enum AlarmLevel { public enum AlarmLevel {
alarmLevel_0("0", "预警"), alarmLevel_0("0", "预警"),
......
...@@ -5,6 +5,7 @@ import org.slf4j.LoggerFactory; ...@@ -5,6 +5,7 @@ import org.slf4j.LoggerFactory;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice; import org.springframework.web.bind.annotation.RestControllerAdvice;
import org.springframework.web.context.request.RequestAttributes;
import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes; import org.springframework.web.context.request.ServletRequestAttributes;
import org.typroject.tyboot.core.foundation.context.RequestContext; import org.typroject.tyboot.core.foundation.context.RequestContext;
...@@ -23,12 +24,18 @@ public class GlobalExceptionHandler { ...@@ -23,12 +24,18 @@ public class GlobalExceptionHandler {
private Logger log = LoggerFactory.getLogger(this.getClass()); private Logger log = LoggerFactory.getLogger(this.getClass());
public GlobalExceptionHandler() { public GlobalExceptionHandler() {
log.info("开始");
} }
@ExceptionHandler({Exception.class}) @ExceptionHandler({Exception.class})
public ResponseModel<Object> MethodArgumentNotValidHandler(Exception exception) throws Exception { public ResponseModel<Object> MethodArgumentNotValidHandler(Exception exception) throws Exception {
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()) HttpServletRequest request =null;
.getRequest(); RequestAttributes re=RequestContextHolder.getRequestAttributes();
if(re!=null){
request = ((ServletRequestAttributes) re).getRequest();
}
ResponseModel<Object> response = new ResponseModel<>(); ResponseModel<Object> response = new ResponseModel<>();
//解析平台返回错误信息,统一返回403,app 端统一跳转到登录页面 //解析平台返回错误信息,统一返回403,app 端统一跳转到登录页面
...@@ -41,7 +48,7 @@ public class GlobalExceptionHandler { ...@@ -41,7 +48,7 @@ public class GlobalExceptionHandler {
response.setDevMessage("FAILED"); response.setDevMessage("FAILED");
response.setMessage(exception.getMessage()); response.setMessage(exception.getMessage());
response.setTraceId(RequestContext.getTraceId()); response.setTraceId(RequestContext.getTraceId());
response.setPath(request.getServletPath()); response.setPath(request!=null?request.getServletPath():null);
exception.printStackTrace(); exception.printStackTrace();
return response; return response;
} }
......
...@@ -30,7 +30,7 @@ public class GlobalResponseHandler implements ResponseBodyAdvice<Object> { ...@@ -30,7 +30,7 @@ public class GlobalResponseHandler implements ResponseBodyAdvice<Object> {
static LinkedList<String> filterUrl = new LinkedList<>(); static LinkedList<String> filterUrl = new LinkedList<>();
{ static{
filterUrl.add(SWAGGER_URL); filterUrl.add(SWAGGER_URL);
filterUrl.add(SWAGGER_RESOURCES); filterUrl.add(SWAGGER_RESOURCES);
filterUrl.add(CSRF); filterUrl.add(CSRF);
...@@ -45,12 +45,7 @@ public class GlobalResponseHandler implements ResponseBodyAdvice<Object> { ...@@ -45,12 +45,7 @@ public class GlobalResponseHandler implements ResponseBodyAdvice<Object> {
*/ */
@Override @Override
public boolean supports(MethodParameter methodParameter, Class<? extends HttpMessageConverter<?>> aClass) { public boolean supports(MethodParameter methodParameter, Class<? extends HttpMessageConverter<?>> aClass) {
// 获取当前处理请求的controller的方法
String methodName = methodParameter.getMethod().getName();
// 不拦截/不需要处理返回值 的方法 // 不拦截/不需要处理返回值 的方法
String method = "loginCheck";
// 拦截 false
// return !method.equals(methodName);
return true; return true;
} }
...@@ -73,13 +68,7 @@ public class GlobalResponseHandler implements ResponseBodyAdvice<Object> { ...@@ -73,13 +68,7 @@ public class GlobalResponseHandler implements ResponseBodyAdvice<Object> {
} }
} }
// 平台返回参数
// ResponseModel<T> response = new ResponseModel<>();
// HttpServletRequest request = ((ServletRequestAttributes)
// RequestContextHolder.getRequestAttributes()).getRequest();
// response.setResult(t);
// response.setDevMessage("SUCCESS");
// response.setStatus(HttpStatus.OK.value());
ResponseModel<Object> res = ResponseHelper.buildResponse(body); ResponseModel<Object> res = ResponseHelper.buildResponse(body);
......
...@@ -68,9 +68,7 @@ public class Common3dResponse { ...@@ -68,9 +68,7 @@ public class Common3dResponse {
this.message = message; this.message = message;
} }
// public Boolean isSuccess() {
// return "SUCCESS".equals(getCode());
// }
public Integer getId() { public Integer getId() {
return id; return id;
......
...@@ -12,11 +12,16 @@ import com.yeejoin.equipmanage.common.constant.Constant; ...@@ -12,11 +12,16 @@ import com.yeejoin.equipmanage.common.constant.Constant;
* @Version: 1.0 * @Version: 1.0
*/ */
public class Common3dResponseUtil { public class Common3dResponseUtil {
private static final String CODE="47100";
private Common3dResponseUtil() {
}
public static Common3dResponse success() public static Common3dResponse success()
{ {
Common3dResponse response = new Common3dResponse(); Common3dResponse response = new Common3dResponse();
response.setId(1); response.setId(1);
response.setCode("47100"); response.setCode(CODE);
response.setMessage(Constant.RESULT_SUCCESS); response.setMessage(Constant.RESULT_SUCCESS);
return response; return response;
} }
...@@ -25,7 +30,7 @@ public class Common3dResponseUtil { ...@@ -25,7 +30,7 @@ public class Common3dResponseUtil {
{ {
Common3dResponse response = new Common3dResponse(); Common3dResponse response = new Common3dResponse();
response.setId(1); response.setId(1);
response.setCode("47100"); response.setCode(CODE);
response.setMessage(Constant.RESULT_SUCCESS); response.setMessage(Constant.RESULT_SUCCESS);
response.setBody(obj); response.setBody(obj);
return response; return response;
...@@ -35,7 +40,7 @@ public class Common3dResponseUtil { ...@@ -35,7 +40,7 @@ public class Common3dResponseUtil {
{ {
Common3dResponse response = new Common3dResponse(); Common3dResponse response = new Common3dResponse();
response.setId(1); response.setId(1);
response.setCode("47100"); response.setCode(CODE);
response.setBody(obj); response.setBody(obj);
response.setMessage(message); response.setMessage(message);
return response; return response;
...@@ -45,7 +50,7 @@ public class Common3dResponseUtil { ...@@ -45,7 +50,7 @@ public class Common3dResponseUtil {
{ {
Common3dResponse response = new Common3dResponse(); Common3dResponse response = new Common3dResponse();
response.setId(0); response.setId(0);
response.setCode("47100"); response.setCode(CODE);
response.setMessage(Constant.RESULT_FAILURE); response.setMessage(Constant.RESULT_FAILURE);
return response; return response;
} }
...@@ -54,7 +59,7 @@ public class Common3dResponseUtil { ...@@ -54,7 +59,7 @@ public class Common3dResponseUtil {
{ {
Common3dResponse response = new Common3dResponse(); Common3dResponse response = new Common3dResponse();
response.setId(0); response.setId(0);
response.setCode("47100"); response.setCode(CODE);
response.setMessage(message); response.setMessage(message);
return response; return response;
} }
...@@ -63,7 +68,7 @@ public class Common3dResponseUtil { ...@@ -63,7 +68,7 @@ public class Common3dResponseUtil {
{ {
Common3dResponse response = new Common3dResponse(); Common3dResponse response = new Common3dResponse();
response.setId(0); response.setId(0);
response.setCode("47100"); response.setCode(CODE);
response.setBody(obj); response.setBody(obj);
response.setMessage(message); response.setMessage(message);
return response; return response;
......
...@@ -63,4 +63,7 @@ public class ArrayUtil { ...@@ -63,4 +63,7 @@ public class ArrayUtil {
public static <T, R> Set<R> collectSet(final List<T> arrayList, Function<T, R> function) { public static <T, R> Set<R> collectSet(final List<T> arrayList, Function<T, R> function) {
return arrayList.stream().map(function).collect(Collectors.toSet()); return arrayList.stream().map(function).collect(Collectors.toSet());
} }
private ArrayUtil() {
}
} }
...@@ -223,8 +223,7 @@ public class BillCodeManagerUtil { ...@@ -223,8 +223,7 @@ public class BillCodeManagerUtil {
if (null == prefix || null == code) { if (null == prefix || null == code) {
throw new IllegalArgumentException("未输入正确参数,编码前缀(prefix),编码(code)!"); throw new IllegalArgumentException("未输入正确参数,编码前缀(prefix),编码(code)!");
} }
System.out.println("生成code :" + code);
String tmp_prefix = prefix.toUpperCase(); String tmp_prefix = prefix.toUpperCase();
switch (tmp_prefix) { switch (tmp_prefix) {
case INBOUND: case INBOUND:
...@@ -252,7 +251,6 @@ public class BillCodeManagerUtil { ...@@ -252,7 +251,6 @@ public class BillCodeManagerUtil {
case LOSS: case LOSS:
return checkWastageCode(code); return checkWastageCode(code);
default: default:
System.out.println("由于未在本类中定义前缀,因此默认使用 DF !!!!!!!!!!!!!!!!!!!!");
return checkOtherCode(code); return checkOtherCode(code);
} }
} }
...@@ -305,5 +303,7 @@ public class BillCodeManagerUtil { ...@@ -305,5 +303,7 @@ public class BillCodeManagerUtil {
private static String getRecoedCode(String key) { private static String getRecoedCode(String key) {
return codes.get(key); return codes.get(key);
} }
private BillCodeManagerUtil() {
}
} }
...@@ -20,8 +20,6 @@ import org.springframework.util.ObjectUtils; ...@@ -20,8 +20,6 @@ import org.springframework.util.ObjectUtils;
import java.awt.*; import java.awt.*;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException; import java.io.IOException;
import java.util.List; import java.util.List;
import java.util.*; import java.util.*;
...@@ -32,6 +30,8 @@ import java.util.*; ...@@ -32,6 +30,8 @@ import java.util.*;
*/ */
public class ChartsUtils { public class ChartsUtils {
private ChartsUtils() {
}
public static String pieChart(List<Map<String, Object>> data, String title) { public static String pieChart(List<Map<String, Object>> data, String title) {
//如 果不使用Font,中文将显示不出来 //如 果不使用Font,中文将显示不出来
...@@ -40,9 +40,7 @@ public class ChartsUtils { ...@@ -40,9 +40,7 @@ public class ChartsUtils {
// 创建数据:饼状图就是名称和值(比例) // 创建数据:饼状图就是名称和值(比例)
Map<String, Double> map = new HashMap<String, Double>(); Map<String, Double> map = new HashMap<String, Double>();
// for (int i = 0; i < name.size(); i++) {
// map.put(name.get(i), value.get(i));
// }
for (Map<String, Object> item : data) { for (Map<String, Object> item : data) {
map.put(String.valueOf(item.get("type")),Double.parseDouble(ObjectUtils.isEmpty(item.get("value"))?"0":String.valueOf(item.get("value")))); map.put(String.valueOf(item.get("type")),Double.parseDouble(ObjectUtils.isEmpty(item.get("value"))?"0":String.valueOf(item.get("value"))));
...@@ -50,39 +48,19 @@ public class ChartsUtils { ...@@ -50,39 +48,19 @@ public class ChartsUtils {
} }
// 创建JFreeChart // 创建JFreeChart
JFreeChart chart = createPieChart(title, map, font); JFreeChart chart = createPieChart(title, map, font);
BufferedImage image = chart.createBufferedImage(600, 600); BufferedImage image = chart!=null?chart.createBufferedImage(600, 600):null;
byte[] bytes = null; byte[] bytes = null;
try { try {
bytes = ChartUtilities.encodeAsPNG(image); bytes = ChartUtilities.encodeAsPNG(image);
} catch (IOException e1) { } catch (IOException e1) {
System.out.println("生成饼图失败"); e1.printStackTrace();
} }
return Base64.getEncoder().encodeToString(bytes); return Base64.getEncoder().encodeToString(bytes);
} }
private static byte[] fileToByte(File file) {
byte[] fileBytes = null;
FileInputStream fis = null;
try {
fis = new FileInputStream(file);
fileBytes = new byte[(int) file.length()];
fis.read(fileBytes);
fis.close();
} catch (Exception e) {
e.printStackTrace();
} finally {
if (fis != null) {
try {
fis.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
return fileBytes;
}
/** /**
...@@ -97,8 +75,8 @@ public class ChartsUtils { ...@@ -97,8 +75,8 @@ public class ChartsUtils {
try { try {
Set<Map.Entry<String, Double>> set = data.entrySet(); Set<Map.Entry<String, Double>> set = data.entrySet();
DefaultPieDataset pds = new DefaultPieDataset(); DefaultPieDataset pds = new DefaultPieDataset();
Iterator iterator = set.iterator(); Iterator<Map.Entry<String, Double>> iterator = set.iterator();
Map.Entry entry; Map.Entry<String, Double> entry;
while (iterator.hasNext()) { while (iterator.hasNext()) {
entry = (Map.Entry) iterator.next(); entry = (Map.Entry) iterator.next();
pds.setValue(entry.getKey().toString(), Double.parseDouble(entry.getValue().toString())); pds.setValue(entry.getKey().toString(), Double.parseDouble(entry.getValue().toString()));
...@@ -123,11 +101,9 @@ public class ChartsUtils { ...@@ -123,11 +101,9 @@ public class ChartsUtils {
plot.setBackgroundAlpha(0.0f); plot.setBackgroundAlpha(0.0f);
//设置标签生成器(默认{0}) //设置标签生成器(默认{0})
//{0}:key {1}:value {2}:百分比 {3}:sum //{0}:key {1}:value {2}:百分比 {3}:sum
plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{0}({1})/{2}")); // 一般在{1}后面加单位,如:{0}({1}次)/{2} plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{0}({1})/{2}"));
//将内存中的图片写到本地硬盘 //将内存中的图片写到本地硬盘
// ChartUtilities.saveChartAsJPEG(new File("H:/a.png"), chart, 600, 300);
// 标注位于上侧 // 标注位于上侧
// chart.getLegend().setPosition(RectangleEdge.TOP);
// 设置标注无边框 // 设置标注无边框
chart.getLegend().setFrame(new BlockBorder(Color.WHITE)); chart.getLegend().setFrame(new BlockBorder(Color.WHITE));
return chart; return chart;
...@@ -156,7 +132,7 @@ public class ChartsUtils { ...@@ -156,7 +132,7 @@ public class ChartsUtils {
try { try {
bytes = ChartUtilities.encodeAsPNG(image); bytes = ChartUtilities.encodeAsPNG(image);
} catch (IOException e1) { } catch (IOException e1) {
System.out.println("生成折线图失败"); e1.printStackTrace();
} }
return Base64.getEncoder().encodeToString(bytes); return Base64.getEncoder().encodeToString(bytes);
......
...@@ -18,4 +18,6 @@ public class CodeGenerate { ...@@ -18,4 +18,6 @@ public class CodeGenerate {
return id; return id;
} }
private CodeGenerate() {
}
} }
...@@ -5,8 +5,10 @@ import org.springframework.util.CollectionUtils; ...@@ -5,8 +5,10 @@ import org.springframework.util.CollectionUtils;
import java.util.List; import java.util.List;
public class CommonPageParamUtil { public class CommonPageParamUtil {
private CommonPageParamUtil() {
}
public static CommonPageInfoParam fillCommonPageInfoParam(List<CommonRequest> queryRequests, CommonPageable commonPageable) { public static CommonPageInfoParam fillCommonPageInfoParam(List<CommonRequest> queryRequests, CommonPageable commonPageable) {
CommonPageInfoParam param = new CommonPageInfoParam(); CommonPageInfoParam param = new CommonPageInfoParam();
for(int i=0;i<queryRequests.size();i++){ for(int i=0;i<queryRequests.size();i++){
String name = queryRequests.get(i).getName(); String name = queryRequests.get(i).getName();
......
...@@ -6,53 +6,57 @@ import org.typroject.tyboot.core.restful.utils.ResponseModel; ...@@ -6,53 +6,57 @@ import org.typroject.tyboot.core.restful.utils.ResponseModel;
public class CommonResponseUtil public class CommonResponseUtil
{ {
public static ResponseModel success() private CommonResponseUtil() {
}
public static ResponseModel<Object> success()
{ {
ResponseModel res = new ResponseModel(); ResponseModel<Object> res = new ResponseModel<>();
res.setDevMessage(Constant.RESULT_SUCCESS); res.setDevMessage(Constant.RESULT_SUCCESS);
res.setStatus(HttpStatus.OK.value()); res.setStatus(HttpStatus.OK.value());
return res; return res;
} }
public static ResponseModel success(Object obj) public static ResponseModel<Object> success(Object obj)
{ {
ResponseModel res = new ResponseModel(); ResponseModel<Object> res = new ResponseModel<>();
res.setResult(obj); res.setResult(obj);
res.setDevMessage(Constant.RESULT_SUCCESS); res.setDevMessage(Constant.RESULT_SUCCESS);
res.setStatus(HttpStatus.OK.value()); res.setStatus(HttpStatus.OK.value());
return res; return res;
} }
public static ResponseModel success(Object obj, String message) public static ResponseModel<Object> success(Object obj, String message)
{ {
ResponseModel res = new ResponseModel(); ResponseModel<Object> res = new ResponseModel<>();
res.setResult(obj); res.setResult(obj);
res.setDevMessage(message); res.setDevMessage(message);
res.setStatus(HttpStatus.OK.value()); res.setStatus(HttpStatus.OK.value());
return res; return res;
} }
public static ResponseModel failure() public static ResponseModel<Object> failure()
{ {
ResponseModel res = new ResponseModel(); ResponseModel<Object> res = new ResponseModel<>();
res.setDevMessage(Constant.RESULT_FAILURE); res.setDevMessage(Constant.RESULT_FAILURE);
res.setStatus(HttpStatus.INTERNAL_SERVER_ERROR.value()); res.setStatus(HttpStatus.INTERNAL_SERVER_ERROR.value());
return res; return res;
} }
public static ResponseModel failure(String message) public static ResponseModel<Object> failure(String message)
{ {
ResponseModel res = new ResponseModel(); ResponseModel<Object> res = new ResponseModel<>();
res.setDevMessage(Constant.RESULT_FAILURE); res.setDevMessage(Constant.RESULT_FAILURE);
res.setMessage(message); res.setMessage(message);
res.setStatus(HttpStatus.INTERNAL_SERVER_ERROR.value()); res.setStatus(HttpStatus.INTERNAL_SERVER_ERROR.value());
return res; return res;
} }
public static ResponseModel failure(Object obj, String message) public static ResponseModel<Object> failure(Object obj, String message)
{ {
ResponseModel res = new ResponseModel(); ResponseModel<Object> res = new ResponseModel<>();
res.setResult(obj); res.setResult(obj);
res.setMessage(message);
res.setDevMessage(Constant.RESULT_FAILURE); res.setDevMessage(Constant.RESULT_FAILURE);
res.setStatus(HttpStatus.INTERNAL_SERVER_ERROR.value()); res.setStatus(HttpStatus.INTERNAL_SERVER_ERROR.value());
return res; return res;
......
...@@ -17,6 +17,9 @@ import java.text.ParseException; ...@@ -17,6 +17,9 @@ import java.text.ParseException;
public class ConverterUtil { public class ConverterUtil {
private ConverterUtil() {
}
/** /**
* Gets a String from a Object in a null-safe manner. * Gets a String from a Object in a null-safe manner.
* <p> * <p>
...@@ -113,6 +116,7 @@ public class ConverterUtil { ...@@ -113,6 +116,7 @@ public class ConverterUtil {
* @return the value of the Object as a Boolean, <code>null</code> if null object input * @return the value of the Object as a Boolean, <code>null</code> if null object input
*/ */
public static Boolean getAsBoolean(final Object obj) { public static Boolean getAsBoolean(final Object obj) {
Boolean fla=null;
if (obj != null) { if (obj != null) {
if (obj instanceof Boolean) { if (obj instanceof Boolean) {
return (Boolean) obj; return (Boolean) obj;
...@@ -125,7 +129,7 @@ public class ConverterUtil { ...@@ -125,7 +129,7 @@ public class ConverterUtil {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
} }
return null; return fla;
} }
/** /**
......
package com.yeejoin.equipmanage.common.utils; package com.yeejoin.equipmanage.common.utils;
public class CustomUtil { public class CustomUtil {
private CustomUtil() {
}
/** /**
* 去掉末尾的0 * 去掉末尾的0
......
package com.yeejoin.equipmanage.common.utils; package com.yeejoin.equipmanage.common.utils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.text.DateFormat; import java.text.DateFormat;
...@@ -15,7 +17,12 @@ import java.util.*; ...@@ -15,7 +17,12 @@ import java.util.*;
* @create: 2020-05-28 13:57 * @create: 2020-05-28 13:57
**/ **/
public class DateUtils { public class DateUtils {
private DateUtils() {
}
private static final Logger logs = LoggerFactory.getLogger(DateUtils.class);
public static final String DATE_TIME_PATTERN = "yyyy-MM-dd HH:mm:ss"; public static final String DATE_TIME_PATTERN = "yyyy-MM-dd HH:mm:ss";
public static final String MINUTE_PATTERN = "yyyy-MM-dd HH:mm"; public static final String MINUTE_PATTERN = "yyyy-MM-dd HH:mm";
public static final String HOUR_PATTERN = "yyyy-MM-dd HH"; public static final String HOUR_PATTERN = "yyyy-MM-dd HH";
...@@ -25,17 +32,17 @@ public class DateUtils { ...@@ -25,17 +32,17 @@ public class DateUtils {
public static final String MINUTE_ONLY_PATTERN = "mm"; public static final String MINUTE_ONLY_PATTERN = "mm";
public static final String HOUR_ONLY_PATTERN = "HH"; public static final String HOUR_ONLY_PATTERN = "HH";
public static final String DATE_TIME_T_PATTERN = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"; public static final String DATE_TIME_T_PATTERN = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'";
public static final String[] TWENTY_FOUR = new String[]{" 00:00:00"," 01:00:00"," 02:00:00", private static final String YMD00=" 00:00:00";
public static final String[] TWENTY_FOUR = new String[]{YMD00," 01:00:00"," 02:00:00",
" 03:00:00"," 04:00:00"," 05:00:00"," 06:00:00"," 07:00:00"," 08:00:00"," 09:00:00"," 10:00:00"," 11:00:00"," 12:00:00"," 13:00:00", " 03:00:00"," 04:00:00"," 05:00:00"," 06:00:00"," 07:00:00"," 08:00:00"," 09:00:00"," 10:00:00"," 11:00:00"," 12:00:00"," 13:00:00",
" 14:00:00"," 15:00:00"," 16:00:00"," 17:00:00"," 18:00:00"," 19:00:00"," 20:00:00"," 21:00:00"," 22:00:00"," 23:00:00"}; " 14:00:00"," 15:00:00"," 16:00:00"," 17:00:00"," 18:00:00"," 19:00:00"," 20:00:00"," 21:00:00"," 22:00:00"," 23:00:00"};
/** /**
* 获取 当前年、半年、季度、月、日、小时 开始结束时间 * 获取 当前年、半年、季度、月、日、小时 开始结束时间
*/ */
private static final SimpleDateFormat shortSdf = new SimpleDateFormat("yyyy-MM-dd"); private static final SimpleDateFormat shortSdf = new SimpleDateFormat(DATE_PATTERN);
private static final SimpleDateFormat longHourSdf = new SimpleDateFormat("yyyy-MM-dd HH"); private static final SimpleDateFormat longSdf = new SimpleDateFormat(DATE_TIME_PATTERN);
private static final SimpleDateFormat longSdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); private static final String YYYYMM="yyyy-MM";
private static final Calendar calendar = Calendar.getInstance(); private static final String YMD=" 23:59:59";
private static final SimpleDateFormat shortDateNew = new SimpleDateFormat("yyyy/M/d");
/** /**
* 获取当前时间 * 获取当前时间
...@@ -55,7 +62,7 @@ public class DateUtils { ...@@ -55,7 +62,7 @@ public class DateUtils {
} }
public static String date2LongStr(Date dateDate) public static String date2LongStr(Date dateDate)
{ {
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); SimpleDateFormat formatter = new SimpleDateFormat(DATE_TIME_PATTERN);
String dateString = formatter.format(dateDate); String dateString = formatter.format(dateDate);
return dateString; return dateString;
} }
...@@ -67,7 +74,7 @@ public class DateUtils { ...@@ -67,7 +74,7 @@ public class DateUtils {
public static String getNowStrLong() public static String getNowStrLong()
{ {
Date currentTime = new Date(); Date currentTime = new Date();
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); SimpleDateFormat formatter = new SimpleDateFormat(DATE_TIME_PATTERN);
String dateString = formatter.format(currentTime); String dateString = formatter.format(currentTime);
return dateString; return dateString;
} }
...@@ -134,7 +141,7 @@ public class DateUtils { ...@@ -134,7 +141,7 @@ public class DateUtils {
*/ */
public static Date longStr2Date(String strDate) public static Date longStr2Date(String strDate)
{ {
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); SimpleDateFormat formatter = new SimpleDateFormat(DATE_TIME_PATTERN);
ParsePosition pos = new ParsePosition(0); ParsePosition pos = new ParsePosition(0);
Date strtodate = formatter.parse(strDate, pos); Date strtodate = formatter.parse(strDate, pos);
return strtodate; return strtodate;
...@@ -163,7 +170,7 @@ public class DateUtils { ...@@ -163,7 +170,7 @@ public class DateUtils {
* @throws ParseException * @throws ParseException
*/ */
public static String dateToString(String str) { public static String dateToString(String str) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); SimpleDateFormat sdf = new SimpleDateFormat(DATE_PATTERN);
Date parse = null; Date parse = null;
String content = null; String content = null;
try { try {
...@@ -476,7 +483,9 @@ public class DateUtils { ...@@ -476,7 +483,9 @@ public class DateUtils {
Date dateStart = dateParse(dateFormat(startDate, DATE_TIME_PATTERN), DATE_TIME_PATTERN); Date dateStart = dateParse(dateFormat(startDate, DATE_TIME_PATTERN), DATE_TIME_PATTERN);
Date dateEnd = dateParse(dateFormat(endDate, DATE_TIME_PATTERN), DATE_TIME_PATTERN); Date dateEnd = dateParse(dateFormat(endDate, DATE_TIME_PATTERN), DATE_TIME_PATTERN);
double ceil = Math.ceil((dateEnd.getTime() - dateStart.getTime()) * 1.0 / 1000 / 60 / 60); double ceil = Math.ceil((dateEnd.getTime() - dateStart.getTime()) * 1.0 / 1000 / 60 / 60);
return new Double(ceil).intValue() ; Double dav= Double.valueOf(ceil) ;
int da=dav.intValue();
return da;
} }
/** /**
...@@ -491,7 +500,8 @@ public class DateUtils { ...@@ -491,7 +500,8 @@ public class DateUtils {
Date dateStart = dateParse(dateFormat(startDate, DATE_TIME_PATTERN), DATE_TIME_PATTERN); Date dateStart = dateParse(dateFormat(startDate, DATE_TIME_PATTERN), DATE_TIME_PATTERN);
Date dateEnd = dateParse(dateFormat(endDate, DATE_TIME_PATTERN), DATE_TIME_PATTERN); Date dateEnd = dateParse(dateFormat(endDate, DATE_TIME_PATTERN), DATE_TIME_PATTERN);
double ceil = Math.ceil((dateEnd.getTime() - dateStart.getTime()) * 1.0 / 1000 / 60 / 30); double ceil = Math.ceil((dateEnd.getTime() - dateStart.getTime()) * 1.0 / 1000 / 60 / 30);
return new Double(ceil).intValue() ; Double da = Double.valueOf(ceil);
return da.intValue() ;
} }
/** /**
...@@ -506,7 +516,8 @@ public class DateUtils { ...@@ -506,7 +516,8 @@ public class DateUtils {
Date dateStart = dateParse(dateFormat(startDate, DATE_TIME_PATTERN), DATE_TIME_PATTERN); Date dateStart = dateParse(dateFormat(startDate, DATE_TIME_PATTERN), DATE_TIME_PATTERN);
Date dateEnd = dateParse(dateFormat(endDate, DATE_TIME_PATTERN), DATE_TIME_PATTERN); Date dateEnd = dateParse(dateFormat(endDate, DATE_TIME_PATTERN), DATE_TIME_PATTERN);
double ceil = Math.ceil((dateEnd.getTime() - dateStart.getTime()) * 1.0 / 1000 / 60 / 120); double ceil = Math.ceil((dateEnd.getTime() - dateStart.getTime()) * 1.0 / 1000 / 60 / 120);
return new Double(ceil).intValue() ; Double da = Double.valueOf(ceil);
return da.intValue() ;
} }
/** /**
...@@ -521,7 +532,8 @@ public class DateUtils { ...@@ -521,7 +532,8 @@ public class DateUtils {
Date dateStart = dateParse(dateFormat(startDate, DATE_TIME_PATTERN), DATE_TIME_PATTERN); Date dateStart = dateParse(dateFormat(startDate, DATE_TIME_PATTERN), DATE_TIME_PATTERN);
Date dateEnd = dateParse(dateFormat(endDate, DATE_TIME_PATTERN), DATE_TIME_PATTERN); Date dateEnd = dateParse(dateFormat(endDate, DATE_TIME_PATTERN), DATE_TIME_PATTERN);
double ceil = Math.ceil((dateEnd.getTime() - dateStart.getTime()) * 1.0 / 1000 / 60 / 240); double ceil = Math.ceil((dateEnd.getTime() - dateStart.getTime()) * 1.0 / 1000 / 60 / 240);
return new Double(ceil).intValue() ; Double myDouble = Double.valueOf(ceil);
return myDouble.intValue();
} }
/** /**
...@@ -627,24 +639,7 @@ public class DateUtils { ...@@ -627,24 +639,7 @@ public class DateUtils {
return dateParse(dateFormat(date, MONTH_PATTERN) + "-" + value, null); return dateParse(dateFormat(date, MONTH_PATTERN) + "-" + value, null);
} }
public static void main(String[] args) throws Exception {
/*System.out.println(dateTimeToDate(new Date()));
System.out.println(dateParse("2017-02-04 14:58:20", null));
System.out.println(dateTimeToDateStringIfTimeEndZero(new Date()));
System.out.println(dateTimeToDateStringIfTimeEndZero(dateTimeToDate(new Date())));*/
//System.out.println(dateBetween(dateParse("2017-01-30", null), dateParse("2017-02-01", null)));
//System.out.println(dateBetweenIncludeToday(dateParse("2017-01-30", null), dateParse("2017-02-01", null)));
// System.out.println(getDate(dateParse("2017-01-17", null)));
System.out.println(dateTimeToDateString(getBeginDayOfWeek()));
System.out.println("getBeginDayOfWeek() = " + getBeginDayOfWeek());
System.out.println("11111111111111111"+getEndDayOfWeek());
/*
System.out.println(getDaysOfMonth(dateParse("2017-02-01", null)));
System.out.println(getDaysOfYear(dateParse("2017-01-30", null)));*/
//System.out.println(dateFormat(dateAddMonths(dateParse("2017-02-07", StrUtils.MONTH_PATTERN), -12), StrUtils.MONTH_PATTERN));
/*System.out.println(dateFormat(maxDateOfMonth(dateParse("2016-02", "yyyy-MM")), null));
System.out.println(dateFormat(minDateOfMonth(dateParse("2016-03-31", null)), null));*/
}
/** /**
* 获取日期星期一日期 * 获取日期星期一日期
...@@ -734,7 +729,7 @@ public class DateUtils { ...@@ -734,7 +729,7 @@ public class DateUtils {
*/ */
public static Date getCurrentDayStartTime(Date date) { public static Date getCurrentDayStartTime(Date date) {
try { try {
date = shortSdf.parse(shortSdf.format(date) + " 00:00:00"); date = shortSdf.parse(shortSdf.format(date) + YMD00);
} catch (ParseException e) { } catch (ParseException e) {
e.printStackTrace(); e.printStackTrace();
} }
...@@ -748,7 +743,7 @@ public class DateUtils { ...@@ -748,7 +743,7 @@ public class DateUtils {
*/ */
public static Date getCurrentDayEndTime(Date date) { public static Date getCurrentDayEndTime(Date date) {
try { try {
date = longSdf.parse(shortSdf.format(date) + " 23:59:59"); date = longSdf.parse(shortSdf.format(date) + YMD);
} catch (ParseException e) { } catch (ParseException e) {
e.printStackTrace(); e.printStackTrace();
} }
...@@ -788,12 +783,12 @@ public class DateUtils { ...@@ -788,12 +783,12 @@ public class DateUtils {
*/ */
public static List<String> getWeeks(String date){ public static List<String> getWeeks(String date){
List<String> dates = new ArrayList<>(); List<String> dates = new ArrayList<>();
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM"); DateFormat dateFormat = new SimpleDateFormat(YYYYMM);
Date date1 = null; Date date1 = null;
try { try {
date1 = dateFormat.parse(date); date1 = dateFormat.parse(date);
} catch (ParseException e) { } catch (ParseException e) {
System.out.println("获取当前月自然周,日期格式转换错误!11"); logs.info("获取当前月自然周,日期格式转换错误!111");
e.printStackTrace(); e.printStackTrace();
} }
Calendar calendar = new GregorianCalendar(); Calendar calendar = new GregorianCalendar();
...@@ -801,17 +796,17 @@ public class DateUtils { ...@@ -801,17 +796,17 @@ public class DateUtils {
int days = calendar.getActualMaximum(Calendar.DAY_OF_MONTH); int days = calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
int count = 0; int count = 0;
for (int i = 1; i <= days; i++) { for (int i = 1; i <= days; i++) {
DateFormat dateFormat1 = new SimpleDateFormat("yyyy-MM-dd"); DateFormat dateFormat1 = new SimpleDateFormat(DATE_PATTERN);
Date date2 = null; Date date2 = null;
try { try {
date2 = dateFormat1.parse(date + "-" + i); date2 = dateFormat1.parse(date + "-" + i);
} catch (ParseException e) { } catch (ParseException e) {
System.out.println("获取当前月自然周,日期格式转换错误!22"); logs.info("获取当前月自然周,日期格式转换错误!222");
e.printStackTrace(); e.printStackTrace();
} }
calendar.clear(); calendar.clear();
calendar.setTime(date2); calendar.setTime(date2);
int k = new Integer(calendar.get(Calendar.DAY_OF_WEEK)); int k = Integer.valueOf(calendar.get(Calendar.DAY_OF_WEEK));
int startDay = 0; int startDay = 0;
int endDay = 0; int endDay = 0;
// 若当天是周日 // 若当天是周日
...@@ -847,12 +842,12 @@ public class DateUtils { ...@@ -847,12 +842,12 @@ public class DateUtils {
public static List<String> getWeeksMap(String date){ public static List<String> getWeeksMap(String date){
List<String> dates = new ArrayList<>(); List<String> dates = new ArrayList<>();
String year = date.substring(0,4); String year = date.substring(0,4);
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM"); DateFormat dateFormat = new SimpleDateFormat(YYYYMM);
Date date1 = null; Date date1 = null;
try { try {
date1 = dateFormat.parse(date); date1 = dateFormat.parse(date);
} catch (ParseException e) { } catch (ParseException e) {
System.out.println("获取当前月自然周,日期格式转换错误!11"); logs.info("获取当前月自然周,日期格式转换错误!11");
e.printStackTrace(); e.printStackTrace();
} }
Calendar calendar = new GregorianCalendar(); Calendar calendar = new GregorianCalendar();
...@@ -860,17 +855,17 @@ public class DateUtils { ...@@ -860,17 +855,17 @@ public class DateUtils {
int days = calendar.getActualMaximum(Calendar.DAY_OF_MONTH); int days = calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
int count = 0; int count = 0;
for (int i = 1; i <= days; i++) { for (int i = 1; i <= days; i++) {
DateFormat dateFormat1 = new SimpleDateFormat("yyyy-MM-dd"); DateFormat dateFormat1 = new SimpleDateFormat(DATE_PATTERN);
Date date2 = null; Date date2 = null;
try { try {
date2 = dateFormat1.parse(date + "-" + i); date2 = dateFormat1.parse(date + "-" + i);
} catch (ParseException e) { } catch (ParseException e) {
System.out.println("获取当前月自然周,日期格式转换错误!22"); logs.info("获取当前月自然周,日期格式转换错误!22");
e.printStackTrace(); e.printStackTrace();
} }
calendar.clear(); calendar.clear();
calendar.setTime(date2); calendar.setTime(date2);
int k = new Integer(calendar.get(Calendar.DAY_OF_WEEK)); int k = Integer.valueOf(calendar.get(Calendar.DAY_OF_WEEK));
int startDay = 0; int startDay = 0;
int endDay = 0; int endDay = 0;
// 若当天是周日 // 若当天是周日
...@@ -903,12 +898,12 @@ public class DateUtils { ...@@ -903,12 +898,12 @@ public class DateUtils {
public static List<Map<String, String>> getWeeksMapInterval(String date){ public static List<Map<String, String>> getWeeksMapInterval(String date){
List<Map<String, String>> dates = new ArrayList<>(); List<Map<String, String>> dates = new ArrayList<>();
String year = date.substring(0,4); String year = date.substring(0,4);
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM"); DateFormat dateFormat = new SimpleDateFormat(YYYYMM);
Date date1 = null; Date date1 = null;
try { try {
date1 = dateFormat.parse(date); date1 = dateFormat.parse(date);
} catch (ParseException e) { } catch (ParseException e) {
System.out.println("获取当前月自然周,日期格式转换错误!11"); logs.info("获取当前月自然周,日期格式转换错误!11");
e.printStackTrace(); e.printStackTrace();
} }
Calendar calendar = new GregorianCalendar(); Calendar calendar = new GregorianCalendar();
...@@ -916,17 +911,18 @@ public class DateUtils { ...@@ -916,17 +911,18 @@ public class DateUtils {
int days = calendar.getActualMaximum(Calendar.DAY_OF_MONTH); int days = calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
int count = 0; int count = 0;
for (int i = 1; i <= days; i++) { for (int i = 1; i <= days; i++) {
DateFormat dateFormat1 = new SimpleDateFormat("yyyy-MM-dd"); DateFormat dateFormat1 = new SimpleDateFormat(DATE_PATTERN);
Date date2 = null; Date date2 = null;
try { try {
date2 = dateFormat1.parse(date + "-" + i); date2 = dateFormat1.parse(date + "-" + i);
} catch (ParseException e) { } catch (ParseException e) {
System.out.println("获取当前月自然周,日期格式转换错误!22"); logs.info("获取当前月自然周,日期格式转换错误!22");
e.printStackTrace(); e.printStackTrace();
} }
calendar.clear(); calendar.clear();
calendar.setTime(date2); calendar.setTime(date2);
int k = new Integer(calendar.get(Calendar.DAY_OF_WEEK)); int k = Integer.valueOf(calendar.get(Calendar.DAY_OF_WEEK));
int startDay = 0; int startDay = 0;
int endDay = 0; int endDay = 0;
// 若当天是周日 // 若当天是周日
...@@ -947,8 +943,8 @@ public class DateUtils { ...@@ -947,8 +943,8 @@ public class DateUtils {
} }
if(startDay != 0 && endDay != 0){ if(startDay != 0 && endDay != 0){
String s = ""; String s = "";
String weekStart = year + "-"+ date.substring(5) +"-" +startDay +" 00:00:00"; String weekStart = year + "-"+ date.substring(5) +"-" +startDay +YMD00;
String weekEnd = year + "-"+ date.substring(5) +"-" +endDay +" 23:59:59"; String weekEnd = year + "-"+ date.substring(5) +"-" +endDay +YMD;
if("12".equals(date.substring(5)) && weekOfYear(date2) == 1 ){ if("12".equals(date.substring(5)) && weekOfYear(date2) == 1 ){
long week = Long.valueOf(dates.get(dates.size()-1).get("name").substring(5,7)) + 1; long week = Long.valueOf(dates.get(dates.size()-1).get("name").substring(5,7)) + 1;
s = year + "第" + week + "周" + "(" + date.substring(5) + "月" + startDay + s = year + "第" + week + "周" + "(" + date.substring(5) + "月" + startDay +
...@@ -999,7 +995,7 @@ public class DateUtils { ...@@ -999,7 +995,7 @@ public class DateUtils {
c.setTime(date); c.setTime(date);
Date now = null; Date now = null;
c.set(Calendar.DATE, 1); c.set(Calendar.DATE, 1);
now = shortSdf.parse(shortSdf.format(c.getTime()) + " 00:00:00"); now = shortSdf.parse(shortSdf.format(c.getTime()) + YMD00);
return now; return now;
} }
...@@ -1015,15 +1011,13 @@ public class DateUtils { ...@@ -1015,15 +1011,13 @@ public class DateUtils {
c.set(Calendar.DATE, 1); c.set(Calendar.DATE, 1);
c.add(Calendar.MONTH, 1); c.add(Calendar.MONTH, 1);
c.add(Calendar.DATE, -1); c.add(Calendar.DATE, -1);
now = longSdf.parse(shortSdf.format(c.getTime()) + " 23:59:59"); now = longSdf.parse(shortSdf.format(c.getTime()) + YMD);
return now; return now;
} }
public static Date getBeginDayOfWeek() { public static Date getBeginDayOfWeek() {
Date date = new Date(); Date date = new Date();
if (date == null) {
return null;
}
Calendar cal = Calendar.getInstance(); Calendar cal = Calendar.getInstance();
cal.setTime(date); cal.setTime(date);
int dayofweek = cal.get(Calendar.DAY_OF_WEEK); int dayofweek = cal.get(Calendar.DAY_OF_WEEK);
......
...@@ -10,6 +10,8 @@ import org.jsoup.select.Elements; ...@@ -10,6 +10,8 @@ import org.jsoup.select.Elements;
import java.util.*; import java.util.*;
public class DocUtil { public class DocUtil {
private DocUtil() {
}
/** /**
* doc对应的html转换 * doc对应的html转换
...@@ -17,8 +19,7 @@ public class DocUtil { ...@@ -17,8 +19,7 @@ public class DocUtil {
* @return * @return
*/ */
public static Map<String, Object> processDoc(String html){ public static Map<String, Object> processDoc(String html){
String res = html.replaceAll("black", "white"); String res = html.replace("background-color:#ffffff","");
res = html.replaceAll("background-color:#ffffff","");
Document doc = Jsoup.parse(res); Document doc = Jsoup.parse(res);
updateStyle(doc); updateStyle(doc);
...@@ -36,12 +37,12 @@ public class DocUtil { ...@@ -36,12 +37,12 @@ public class DocUtil {
if(level>5){ if(level>5){
level = -1; level = -1;
} }
id = attr.getValue(); attr.getValue();
} }
} }
if(level>-1){ if(level>-1){
Elements children = element.children(); Elements children = element.children();
StringBuffer sb = new StringBuffer(); StringBuilder sb = new StringBuilder();
for (Element element2 : children) { for (Element element2 : children) {
sb.append(element2.text()); sb.append(element2.text());
} }
...@@ -77,8 +78,7 @@ public class DocUtil { ...@@ -77,8 +78,7 @@ public class DocUtil {
} }
lastlevel = level; lastlevel = level;
} }
// System.out.println(JSON.toJSONString(root.getChildren()));
// System.out.println(doc.toString());
Map<String,Object> map = new HashMap<>(); Map<String,Object> map = new HashMap<>();
map.put("nodes", root.getChildren()); map.put("nodes", root.getChildren());
map.put("html", doc.toString()); map.put("html", doc.toString());
...@@ -92,8 +92,7 @@ public class DocUtil { ...@@ -92,8 +92,7 @@ public class DocUtil {
* @return * @return
*/ */
public static Map<String, Object> processDocx(String html){ public static Map<String, Object> processDocx(String html){
String res = html.replaceAll("black", "white"); String res = html.replace("background-color:#ffffff","");
res = html.replaceAll("background-color:#ffffff","");
Document doc = Jsoup.parse(res); Document doc = Jsoup.parse(res);
updateStyle(doc); updateStyle(doc);
Elements head = doc.getElementsByTag("head"); Elements head = doc.getElementsByTag("head");
...@@ -113,6 +112,7 @@ public class DocUtil { ...@@ -113,6 +112,7 @@ public class DocUtil {
try { try {
level = Integer.parseInt(s.substring(1)); level = Integer.parseInt(s.substring(1));
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace();
} }
} }
} }
...@@ -120,7 +120,7 @@ public class DocUtil { ...@@ -120,7 +120,7 @@ public class DocUtil {
} }
if(level>-1){ if(level>-1){
Elements children = element.children(); Elements children = element.children();
StringBuffer sb = new StringBuffer(); StringBuilder sb = new StringBuilder();
for (Element element2 : children) { for (Element element2 : children) {
sb.append(element2.text()); sb.append(element2.text());
} }
...@@ -156,8 +156,7 @@ public class DocUtil { ...@@ -156,8 +156,7 @@ public class DocUtil {
} }
lastlevel = level; lastlevel = level;
} }
// System.out.println(JSON.toJSONString(root.getChildren()));
// System.out.println(doc.toString());
Map<String,Object> map = new HashMap<>(); Map<String,Object> map = new HashMap<>();
map.put("nodes", root.getChildren()); map.put("nodes", root.getChildren());
map.put("html", doc.toString()); map.put("html", doc.toString());
...@@ -166,18 +165,7 @@ public class DocUtil { ...@@ -166,18 +165,7 @@ public class DocUtil {
//修改样式为白色 //修改样式为白色
private static void updateStyle(Document doc) { private static void updateStyle(Document doc) {
// Elements styleEle = doc.getElementsByTag("style");
// styleEle.append("th{border:solid #FFFFFF}" +
// "td{border:solid #ffffff;border-top:solid #FFFFFF !important;border-bottom:solid #ffffff !important"
// + ",border-right:solid #ffffff !important;border-left:solid #ffffff !important}" +
// "table{border:solid ;background-color: transparent !important}"+
// "a{color:#FFFFFF}");
// Elements bodyEle = doc.getElementsByTag("body");
// bodyEle.attr("style", "color:#FFFFFF");
// Elements spans = doc.getElementsByTag("span");
// spans.attr("style", "color:#FFFFFF");
// Elements as = doc.getElementsByTag("a");
// as.attr("style", "color:#FFFFFF");
Elements table = doc.getElementsByTag("table"); Elements table = doc.getElementsByTag("table");
table.attr("style", "width: 100%"); table.attr("style", "width: 100%");
......
package com.yeejoin.equipmanage.common.utils; package com.yeejoin.equipmanage.common.utils;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.poi.ss.formula.functions.T;
import java.util.Arrays; import java.util.Arrays;
import java.util.Map; import java.util.Map;
...@@ -16,7 +17,10 @@ import java.util.function.Predicate; ...@@ -16,7 +17,10 @@ import java.util.function.Predicate;
*/ */
@Slf4j @Slf4j
public class EnumsUtils { public class EnumsUtils {
private static Map<Class,Object> map = new ConcurrentHashMap<>(); private EnumsUtils() {
}
private static Map<Class<T>,Object> map = new ConcurrentHashMap<>();
/** /**
* 根据条件获取枚举对象 * 根据条件获取枚举对象
...@@ -26,9 +30,10 @@ public class EnumsUtils { ...@@ -26,9 +30,10 @@ public class EnumsUtils {
* @return * @return
*/ */
public static <T> Optional<T> getEnumObject(Class<T> className, Predicate<T> predicate) { public static <T> Optional<T> getEnumObject(Class<T> className, Predicate<T> predicate) {
Optional<T> da=new Optional<>();
if(!className.isEnum()){ if(!className.isEnum()){
log.info("Class 不是枚举类"); log.info("Class 不是枚举类");
return null; return da;
} }
Object obj = map.get(className); Object obj = map.get(className);
T[] ts = null; T[] ts = null;
......
...@@ -21,6 +21,8 @@ import java.util.stream.Collectors; ...@@ -21,6 +21,8 @@ import java.util.stream.Collectors;
* @date 2021/1/8 09:32 * @date 2021/1/8 09:32
*/ */
public class EquipmentStateUtil { public class EquipmentStateUtil {
private EquipmentStateUtil() {
}
private final static Logger log = LoggerFactory.getLogger(EquipmentStateUtil.class); private final static Logger log = LoggerFactory.getLogger(EquipmentStateUtil.class);
...@@ -58,7 +60,7 @@ public class EquipmentStateUtil { ...@@ -58,7 +60,7 @@ public class EquipmentStateUtil {
} }
} }
String status = getStatus(stateVo); String status = getStatus(stateVo);
log.info("此装备的状态为: " + status + "(屏蔽-5, 火灾告警-4, 故障-3, 正常-2, 挂起-1)"); log.info("此装备的状态为(屏蔽-5, 火灾告警-4, 故障-3, 正常-2, 挂起-1): " );
return status; return status;
} }
...@@ -257,7 +259,7 @@ public class EquipmentStateUtil { ...@@ -257,7 +259,7 @@ public class EquipmentStateUtil {
break; break;
} }
} }
log.info("此装备"+index.getQrCode()+"的状态为: " + status + "(屏蔽-5, 火灾告警-4, 故障-3, 正常-2, 挂起-1)"); log.info("此装备状态为(屏蔽-5, 火灾告警-4, 故障-3, 正常-2, 挂起-1):" );
return status; return status;
} }
......
...@@ -26,7 +26,10 @@ import java.util.Map; ...@@ -26,7 +26,10 @@ import java.util.Map;
*/ */
public class ExcelUtil public class ExcelUtil
{ {
private ExcelUtil() {
}
private static final String TITLE="title";
/** /**
* *
* <pre> * <pre>
...@@ -65,7 +68,6 @@ public class ExcelUtil ...@@ -65,7 +68,6 @@ public class ExcelUtil
for (short j = 0; j < list.size(); j = (short) (j + 1)) for (short j = 0; j < list.size(); j = (short) (j + 1))
{ {
HSSFCell cell = row.createCell(j); HSSFCell cell = row.createCell(j);
// cell.setEncoding((short) 1);
if (i == 0) if (i == 0)
{ {
cell.setCellStyle(style); cell.setCellStyle(style);
...@@ -157,17 +159,13 @@ public class ExcelUtil ...@@ -157,17 +159,13 @@ public class ExcelUtil
{ {
String name = new String(fileName.getBytes("UTF-8"), "ISO8859_1"); String name = new String(fileName.getBytes("UTF-8"), "ISO8859_1");
OutputStream output = response.getOutputStream(); OutputStream output = response.getOutputStream();
// response.reset();
response.setHeader("Content-disposition", response.setHeader("Content-disposition",
"attachment; filename=" + name); "attachment; filename=" + name);
response.setContentType("application/vnd.ms-excel;charset=utf-8"); response.setContentType("application/vnd.ms-excel;charset=utf-8");
workbook.write(output); workbook.write(output);
output.flush(); output.flush();
output.close(); output.close();
// // 输出Excel文件--保存到本地
// OutputStream output = new FileOutputStream(new File("F:/"+fileName));
// workbook.write(output); // 输出
// output.close();
} }
catch (IOException e) catch (IOException e)
{ {
...@@ -241,11 +239,9 @@ public class ExcelUtil ...@@ -241,11 +239,9 @@ public class ExcelUtil
HSSFCellStyle style = workbook.createCellStyle(); HSSFCellStyle style = workbook.createCellStyle();
HSSFFont font = workbook.createFont(); HSSFFont font = workbook.createFont();
// font.setColor((short) 16);
font.setBold(true); font.setBold(true);
font.setFontHeightInPoints((short) 10); font.setFontHeightInPoints((short) 10);
style.setFont(font); style.setFont(font);
// style.setFillForegroundColor((short) 9);
style.setAlignment(HorizontalAlignment.CENTER); style.setAlignment(HorizontalAlignment.CENTER);
setBorderStyle(style); setBorderStyle(style);
...@@ -262,8 +258,6 @@ public class ExcelUtil ...@@ -262,8 +258,6 @@ public class ExcelUtil
font3.setFontHeightInPoints((short) 12); font3.setFontHeightInPoints((short) 12);
style3.setFont(font3); style3.setFont(font3);
style3.setWrapText(true); style3.setWrapText(true);
// style3.setFillForegroundColor((short) 13);
// style3.setAlignment(HorizontalAlignment.CENTER);
style3.setVerticalAlignment(VerticalAlignment.CENTER); style3.setVerticalAlignment(VerticalAlignment.CENTER);
HSSFRow statisticRow = sheet.createRow(0); HSSFRow statisticRow = sheet.createRow(0);
...@@ -331,10 +325,7 @@ public class ExcelUtil ...@@ -331,10 +325,7 @@ public class ExcelUtil
style.setWrapText(true); style.setWrapText(true);
style.setAlignment(HorizontalAlignment.CENTER);// 左右居中 style.setAlignment(HorizontalAlignment.CENTER);// 左右居中
style.setVerticalAlignment(VerticalAlignment.CENTER); style.setVerticalAlignment(VerticalAlignment.CENTER);
// style.setLeftBorderColor(HSSFColor.BLACK.index);// 左边框的颜色
// style.setRightBorderColor(HSSFColor.BLACK.index);// 右边框的颜色
// style.setBottomBorderColor(HSSFColor.BLACK.index); // 设置单元格的边框颜色
// style.setFillForegroundColor(HSSFColor.WHITE.index);
style.setBorderBottom(BorderStyle.THIN); style.setBorderBottom(BorderStyle.THIN);
style.setBorderLeft(BorderStyle.THIN); style.setBorderLeft(BorderStyle.THIN);
style.setBorderRight(BorderStyle.THIN); style.setBorderRight(BorderStyle.THIN);
...@@ -536,7 +527,7 @@ public class ExcelUtil ...@@ -536,7 +527,7 @@ public class ExcelUtil
CellStyle style3 = getTitleStyle(workbook); CellStyle style3 = getTitleStyle(workbook);
/********************标题行************************/ /********************标题行************************/
setTitleValue(headers.get("title"), style3, sheet); setTitleValue(headers.get(TITLE), style3, sheet);
/**********************一级表头**********************/ /**********************一级表头**********************/
List<CellRangeAddress> rangelist = new ArrayList<CellRangeAddress>();// 合并单元格集合 List<CellRangeAddress> rangelist = new ArrayList<CellRangeAddress>();// 合并单元格集合
...@@ -559,8 +550,7 @@ public class ExcelUtil ...@@ -559,8 +550,7 @@ public class ExcelUtil
//需要为合并的每个单元格都赋值,否则第二个合并后的单元格值无法显示 //需要为合并的每个单元格都赋值,否则第二个合并后的单元格值无法显示
firstHeadCell.setCellValue(firstHeadValue); firstHeadCell.setCellValue(firstHeadValue);
//设置单元格宽度自适应 //设置单元格宽度自适应
// sheet.setColumnWidth(j, firstHeadValue.getBytes().length*256);
} }
start=start+Integer.valueOf(firstHeadArray[1]);//计算下一个标题的单元格起始位置 start=start+Integer.valueOf(firstHeadArray[1]);//计算下一个标题的单元格起始位置
...@@ -611,7 +601,7 @@ public class ExcelUtil ...@@ -611,7 +601,7 @@ public class ExcelUtil
setMidContentValue(contents, style, sheet, 4); setMidContentValue(contents, style, sheet, 4);
/**********************填充表格内容最后一行**********************/ /**********************填充表格内容最后一行**********************/
int titleSize =Integer.valueOf(headers.get("title").get(0).split(":")[1]); int titleSize =Integer.valueOf(headers.get(TITLE).get(0).split(":")[1]);
Row endContentRow = sheet.createRow(4+contents.size()); Row endContentRow = sheet.createRow(4+contents.size());
endContentRow.setHeightInPoints(30); endContentRow.setHeightInPoints(30);
sheet.addMergedRegion(new CellRangeAddress sheet.addMergedRegion(new CellRangeAddress
...@@ -654,7 +644,7 @@ public class ExcelUtil ...@@ -654,7 +644,7 @@ public class ExcelUtil
CellStyle style3 = getTitleStyle(workbook); CellStyle style3 = getTitleStyle(workbook);
/********************填充标题行************************/ /********************填充标题行************************/
setTitleValue(headers.get("title"), style3, sheet); setTitleValue(headers.get(TITLE), style3, sheet);
/**********************填充表头**********************/ /**********************填充表头**********************/
Row headRow = sheet.createRow(1); Row headRow = sheet.createRow(1);
...@@ -670,7 +660,7 @@ public class ExcelUtil ...@@ -670,7 +660,7 @@ public class ExcelUtil
setMidContentValue(contents, style, sheet, 3); setMidContentValue(contents, style, sheet, 3);
/**********************填充表格内容最后一行**********************/ /**********************填充表格内容最后一行**********************/
int titleSize =Integer.valueOf(headers.get("title").get(0).split(":")[1]); int titleSize =Integer.valueOf(headers.get(TITLE).get(0).split(":")[1]);
Row endContentRow = sheet.createRow(3+contents.size()); Row endContentRow = sheet.createRow(3+contents.size());
endContentRow.setHeightInPoints(30); endContentRow.setHeightInPoints(30);
sheet.addMergedRegion(new CellRangeAddress sheet.addMergedRegion(new CellRangeAddress
...@@ -727,11 +717,9 @@ public class ExcelUtil ...@@ -727,11 +717,9 @@ public class ExcelUtil
{ {
CellStyle style = workbook.createCellStyle(); CellStyle style = workbook.createCellStyle();
Font font = workbook.createFont(); Font font = workbook.createFont();
// font.setColor((short) 16);
//font.setBold(true);
font.setFontHeightInPoints((short) 10); font.setFontHeightInPoints((short) 10);
style.setFont(font); style.setFont(font);
// style.setFillForegroundColor((short) 9);
style.setAlignment(HorizontalAlignment.CENTER); style.setAlignment(HorizontalAlignment.CENTER);
style.setVerticalAlignment(VerticalAlignment.CENTER); style.setVerticalAlignment(VerticalAlignment.CENTER);
setBorderStyle(style); setBorderStyle(style);
...@@ -807,8 +795,7 @@ public class ExcelUtil ...@@ -807,8 +795,7 @@ public class ExcelUtil
style.setAlignment(HorizontalAlignment.CENTER); style.setAlignment(HorizontalAlignment.CENTER);
style.setVerticalAlignment(VerticalAlignment.CENTER); style.setVerticalAlignment(VerticalAlignment.CENTER);
style.setVerticalAlignment(VerticalAlignment.CENTER); style.setVerticalAlignment(VerticalAlignment.CENTER);
// style3.setFillForegroundColor((short) 13);
return style; return style;
} }
......
...@@ -26,6 +26,8 @@ import java.util.regex.Pattern; ...@@ -26,6 +26,8 @@ import java.util.regex.Pattern;
* @create: 2020-05-28 13:57 * @create: 2020-05-28 13:57
**/ **/
public class ExcelUtils { public class ExcelUtils {
private ExcelUtils() {
}
/** /**
* excel 导出 * excel 导出
...@@ -104,7 +106,7 @@ public class ExcelUtils { ...@@ -104,7 +106,7 @@ public class ExcelUtils {
response.setHeader("Access-Control-Expose-Headers", "Content-Disposition"); response.setHeader("Access-Control-Expose-Headers", "Content-Disposition");
workbook.write(response.getOutputStream()); workbook.write(response.getOutputStream());
} catch (IOException e) { } catch (IOException e) {
//throw new NormalException(e.getMessage()); e.printStackTrace();
} }
} }
...@@ -133,8 +135,9 @@ public class ExcelUtils { ...@@ -133,8 +135,9 @@ public class ExcelUtils {
* @return * @return
*/ */
public static <T> List<T> importExcel(String filePath, Integer titleRows, Integer headerRows, Class<T> pojoClass) { public static <T> List<T> importExcel(String filePath, Integer titleRows, Integer headerRows, Class<T> pojoClass) {
List<T> da=null;
if (StringUtils.isBlank(filePath)) { if (StringUtils.isBlank(filePath)) {
return null; return da;
} }
ImportParams params = new ImportParams(); ImportParams params = new ImportParams();
params.setTitleRows(titleRows); params.setTitleRows(titleRows);
...@@ -143,10 +146,9 @@ public class ExcelUtils { ...@@ -143,10 +146,9 @@ public class ExcelUtils {
try { try {
list = ExcelImportUtil.importExcel(new File(filePath), pojoClass, params); list = ExcelImportUtil.importExcel(new File(filePath), pojoClass, params);
} catch (NoSuchElementException e) { } catch (NoSuchElementException e) {
//throw new NormalException("模板不能为空"); e.printStackTrace();
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
//throw new NormalException(e.getMessage());
} }
return list; return list;
} }
...@@ -162,8 +164,9 @@ public class ExcelUtils { ...@@ -162,8 +164,9 @@ public class ExcelUtils {
* @return * @return
*/ */
public static <T> List<T> importExcel(MultipartFile file, Integer titleRows, Integer headerRows, Class<T> pojoClass) { public static <T> List<T> importExcel(MultipartFile file, Integer titleRows, Integer headerRows, Class<T> pojoClass) {
List<T> da=null;
if (file == null) { if (file == null) {
return null; return da;
} }
ImportParams params = new ImportParams(); ImportParams params = new ImportParams();
params.setTitleRows(titleRows); params.setTitleRows(titleRows);
...@@ -172,10 +175,9 @@ public class ExcelUtils { ...@@ -172,10 +175,9 @@ public class ExcelUtils {
try { try {
list = ExcelImportUtil.importExcel(file.getInputStream(), pojoClass, params); list = ExcelImportUtil.importExcel(file.getInputStream(), pojoClass, params);
} catch (NoSuchElementException e) { } catch (NoSuchElementException e) {
// throw new NormalException("excel文件不能为空"); e.printStackTrace();
} catch (Exception e) { } catch (Exception e) {
//throw new NormalException(e.getMessage()); e.printStackTrace();
System.out.println(e.getMessage());
} }
return list; return list;
} }
......
...@@ -12,6 +12,8 @@ import java.io.IOException; ...@@ -12,6 +12,8 @@ import java.io.IOException;
* @since 2018/12/27 17:56 * @since 2018/12/27 17:56
*/ */
public class ExtendedIOUtils { public class ExtendedIOUtils {
private ExtendedIOUtils() {
}
public static void flush(Flushable... resources) throws IOException { public static void flush(Flushable... resources) throws IOException {
Assert.noNullElements(resources, "resources invalid"); Assert.noNullElements(resources, "resources invalid");
......
...@@ -49,45 +49,22 @@ public class FileHelper { ...@@ -49,45 +49,22 @@ public class FileHelper {
final static Logger log = LoggerFactory.getLogger(FreemarkerUtil.class); final static Logger log = LoggerFactory.getLogger(FreemarkerUtil.class);
/** private FileHelper() {
* @param file }
* @return
*/
// public static boolean isExcel2003(File file) {
// InputStream is = null;
// Workbook wb = null;
// try {
// is = new FileInputStream(file);
// wb = WorkbookFactory.create(is);
// if (wb instanceof XSSFWorkbook) {
// return false;
// } else if (wb instanceof HSSFWorkbook) {
// return true;
// }
// } catch (Exception e) {
// return false;
// } finally {
// try {
// if (null != is) {
// is.close();
// }
// if (null != wb) {
// wb.close();
// }
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
// return true;
// }
/** /**
* @param file * @param file
* @return * @return
*/ */
public static boolean isWord2003(File file) { public static boolean isWord2003(File file) {
try (InputStream is = new FileInputStream(file); try (
HWPFDocument hwpfDocument = new HWPFDocument(is)) { InputStream is = new FileInputStream(file);
HWPFDocument hwpfDocument = new HWPFDocument(is))
{
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
return false; return false;
...@@ -222,7 +199,6 @@ public class FileHelper { ...@@ -222,7 +199,6 @@ public class FileHelper {
buffer.append("<br />"); buffer.append("<br />");
} }
buffer.append("</body></html>"); buffer.append("</body></html>");
// System.out.println(buffer.toString());
writeFile(buffer.toString(), path + ".html"); writeFile(buffer.toString(), path + ".html");
} }
...@@ -247,7 +223,6 @@ public class FileHelper { ...@@ -247,7 +223,6 @@ public class FileHelper {
buffer.append("<br />"); buffer.append("<br />");
buffer.append("</body></html>"); buffer.append("</body></html>");
// System.out.println(buffer.toString());
writeFile(buffer.toString(), path + ".html"); writeFile(buffer.toString(), path + ".html");
} }
...@@ -258,7 +233,6 @@ public class FileHelper { ...@@ -258,7 +233,6 @@ public class FileHelper {
"<html><head><meta http-equiv=\"Access-Control-Allow-Origin\" content=\"*\"></head><body><div align=\"left\">"); "<html><head><meta http-equiv=\"Access-Control-Allow-Origin\" content=\"*\"></head><body><div align=\"left\">");
buffer.append("<p>" + content + "</p>"); buffer.append("<p>" + content + "</p>");
buffer.append("</div></body></html>"); buffer.append("</div></body></html>");
// System.out.println(buffer.toString());
writeFile(buffer.toString(), path + ".html"); writeFile(buffer.toString(), path + ".html");
} }
...@@ -331,7 +305,6 @@ public class FileHelper { ...@@ -331,7 +305,6 @@ public class FileHelper {
break; break;
} }
// 转换成utf-8编码的文件写入 // 转换成utf-8编码的文件写入
System.out.println(doc.html());
FileUtils.writeStringToFile(htmFile, doc.html(), "utf-8"); FileUtils.writeStringToFile(htmFile, doc.html(), "utf-8");
} }
...@@ -349,10 +322,7 @@ public class FileHelper { ...@@ -349,10 +322,7 @@ public class FileHelper {
} }
doc.getElementsByTag("html").removeAttr("xmlns"); doc.getElementsByTag("html").removeAttr("xmlns");
Element head = doc.head(); Element head = doc.head();
/*
* Elements headChildren = head.children(); for(Element children : headChildren) { Elements
* metas = children.getElementsByTag("meta"); for(Element meta : metas) { meta.remove(); } }
*/
head.appendElement("meta").attr("name", "viewport").attr("content", head.appendElement("meta").attr("name", "viewport").attr("content",
"width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no"); "width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no");
...@@ -384,10 +354,10 @@ public class FileHelper { ...@@ -384,10 +354,10 @@ public class FileHelper {
break; break;
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace();
} }
// 获取content节点,修改charset属性 // 获取content节点,修改charset属性
// meta.attr("content", "text/html; charset=utf-8");
break; break;
} }
...@@ -426,6 +396,7 @@ public class FileHelper { ...@@ -426,6 +396,7 @@ public class FileHelper {
element.text(""); element.text("");
} }
} catch (Exception w) { } catch (Exception w) {
w.printStackTrace();
} }
} }
} }
...@@ -470,6 +441,7 @@ public class FileHelper { ...@@ -470,6 +441,7 @@ public class FileHelper {
FileChannel out = null; FileChannel out = null;
FileInputStream inStream = null; FileInputStream inStream = null;
FileOutputStream outStream = null; FileOutputStream outStream = null;
try { try {
inStream = new FileInputStream(source); inStream = new FileInputStream(source);
outStream = new FileOutputStream(target); outStream = new FileOutputStream(target);
...@@ -614,9 +586,9 @@ public class FileHelper { ...@@ -614,9 +586,9 @@ public class FileHelper {
} }
} else { } else {
// 创建目的目录 // 创建目的目录
System.out.println("目的目录不存在,准备创建。。。"); log.info("目的目录不存在,准备创建。。。");
if (!destDir.mkdirs()) { if (!destDir.mkdirs()) {
System.out.println("复制目录失败:创建目的目录失败!"); log.info("复制目录失败:创建目的目录失败!");
return false; return false;
} }
} }
...@@ -665,7 +637,7 @@ public class FileHelper { ...@@ -665,7 +637,7 @@ public class FileHelper {
((Channel) object).close(); ((Channel) object).close();
} }
} catch (Exception exce) { } catch (Exception exce) {
System.err.println(exce.getMessage()); exce.printStackTrace();
} }
} }
...@@ -735,12 +707,12 @@ public class FileHelper { ...@@ -735,12 +707,12 @@ public class FileHelper {
* @return 文件css样式 * @return 文件css样式
* @throws IOException 打开文件异常 * @throws IOException 打开文件异常
*/ */
public static final StringBuffer getHtmlCss(String src) throws IOException { public static final StringBuilder getHtmlCss(String src) throws IOException {
File htmFile = new File(src); File htmFile = new File(src);
// 以GB2312读取文件 // 以GB2312读取文件
Document doc = Jsoup.parse(htmFile, "utf-8"); Document doc = Jsoup.parse(htmFile, "utf-8");
Elements styles = doc.getElementsByTag("style"); Elements styles = doc.getElementsByTag("style");
StringBuffer csStringBuffer = new StringBuffer(); StringBuilder csStringBuffer = new StringBuilder();
for (Element style : styles) { for (Element style : styles) {
csStringBuffer.append(style.toString().replace("<style>", "").replace("</style>", "")); csStringBuffer.append(style.toString().replace("<style>", "").replace("</style>", ""));
} }
...@@ -801,8 +773,9 @@ public class FileHelper { ...@@ -801,8 +773,9 @@ public class FileHelper {
} }
public static <T> List<T> importExcel(String filePath, Integer titleRows, Integer headerRows, Class<T> pojoClass) { public static <T> List<T> importExcel(String filePath, Integer titleRows, Integer headerRows, Class<T> pojoClass) {
List<T> da=null;
if (ObjectUtils.isEmpty(filePath)) { if (ObjectUtils.isEmpty(filePath)) {
return null; return da;
} }
ImportParams params = new ImportParams(); ImportParams params = new ImportParams();
params.setTitleRows(titleRows); params.setTitleRows(titleRows);
...@@ -820,8 +793,9 @@ public class FileHelper { ...@@ -820,8 +793,9 @@ public class FileHelper {
} }
public static <T> List<T> importExcel(MultipartFile file, Integer titleRows, Integer headerRows, Class<T> pojoClass) { public static <T> List<T> importExcel(MultipartFile file, Integer titleRows, Integer headerRows, Class<T> pojoClass) {
List<T> da=null;
if (file == null) { if (file == null) {
return null; return da;
} }
ImportParams params = new ImportParams(); ImportParams params = new ImportParams();
params.setTitleRows(titleRows); params.setTitleRows(titleRows);
...@@ -852,18 +826,23 @@ public class FileHelper { ...@@ -852,18 +826,23 @@ public class FileHelper {
zos = new ZipOutputStream(outputStream); zos = new ZipOutputStream(outputStream);
downloadZip(fileName.replace(".zip", ""), zos, list); downloadZip(fileName.replace(".zip", ""), zos, list);
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace();
} finally { } finally {
if (zos != null) { if (zos != null) {
try { try {
zos.close(); zos.close();
} catch (Exception e2) { } catch (Exception e2) {
e2.printStackTrace();
} }
} }
if (outputStream != null) { if (outputStream != null) {
try { try {
outputStream.close(); outputStream.close();
} catch (Exception e2) { } catch (Exception e2) {
e2.printStackTrace();
} }
} }
} }
...@@ -882,20 +861,22 @@ public class FileHelper { ...@@ -882,20 +861,22 @@ public class FileHelper {
try { try {
outputStream = response.getOutputStream(); outputStream = response.getOutputStream();
zos = new ZipOutputStream(outputStream); zos = new ZipOutputStream(outputStream);
//downloadQRCodeZip(fileNmae.replace(".zip", ""), zos, list);
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace();
} finally { } finally {
if (zos != null) { if (zos != null) {
try { try {
zos.close(); zos.close();
} catch (Exception e2) { } catch (Exception e2) {
e2.printStackTrace();
} }
} }
if (outputStream != null) { if (outputStream != null) {
try { try {
outputStream.close(); outputStream.close();
} catch (Exception e2) { } catch (Exception e2) {
e2.printStackTrace();
} }
} }
} }
...@@ -932,21 +913,21 @@ public class FileHelper { ...@@ -932,21 +913,21 @@ public class FileHelper {
try { try {
zos.closeEntry(); zos.closeEntry();
} catch (Exception e2) { } catch (Exception e2) {
e2.printStackTrace();
} }
} }
if (in != null) { if (in != null) {
try { try {
in.close(); in.close();
} catch (Exception e2) { } catch (Exception e2) {
e2.printStackTrace();
} }
} }
if (is != null) { if (is != null) {
try { try {
is.close(); is.close();
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace();
} }
} }
...@@ -954,158 +935,9 @@ public class FileHelper { ...@@ -954,158 +935,9 @@ public class FileHelper {
} }
} }
} }
//
// public static void downloadQRCodeZip(String baseDir, ZipOutputStream zos, List<T> pointList) {
// for (T map : pointList) {
// String pointName = map.getName();
// //文件名称(带后缀)
// String pointNo = map.getPointNo();
// InputStream is = null;
// BufferedInputStream in = null;
// //创建zip实体(一个文件对应一个ZipEntry)
// ZipEntry entry = new ZipEntry(baseDir + "/" + pointName + ".png");
// int width = 300;
// int height = 300;
// try {
// BitMatrix bitMatrix = new MultiFormatWriter().encode(/*"AMOS#PATROL#01#" + */pointNo, BarcodeFormat.QR_CODE, width, height);
// BufferedImage buffImg = MatrixToImageWriter.toBufferedImage(bitMatrix);
//
// /**
// * 给图片加文字描述
// */
// Graphics g = buffImg.createGraphics();
// g.drawImage(buffImg, 0, 0, buffImg.getWidth(), buffImg.getHeight(), null);
// g.setColor(Color.BLUE);
// g.setFont(new Font(null, 1, 20));
// //计算文字开始的位置
// //x开始的位置:(图片宽度-字体大小*字的个数)/2
// int nol = pointNo.length();
// int startX = (width-(12*nol))/2;//101
// //y开始的位置:图片高度-(图片高度-图片宽度)/2 x,y = 0,0 在图片的左上角位置
// int startY = 30;
// g.drawString(pointNo, startX, startY);
// g.dispose();
// buffImg.flush();
//
// zos.putNextEntry(entry);
// ImageIO.write(buffImg, "png", zos);
// zos.flush();
// } catch (Exception e) {
// e.printStackTrace();
// }finally {
// if(entry != null) {
// try {
// zos.closeEntry();
// } catch (Exception e2) {
//
// }
// }
// if(in != null) {
// try {
// in.close();
// } catch (Exception e2) {
//
// }
// }
// if(is != null) {
// try {
// is.close();
// }catch (Exception e) {
//
// }
// }
// }
// }
// }
/**
* @param @param filePath Excel文件路径
* @param @param handers Excel列标题(数组)
* @param @param downData 下拉框数据(数组)
* @param @param downRows 下拉列的序号(数组,序号从0开始)
* @return void
* @throws
* @Title: createExcelTemplate
* @Description: 生成Excel导入模板
*/
// public static void createExcelTemplate(String fileName, String[] handers,
// List<String[]> downData, String[] downRows, HttpServletResponse response) {
//
// HSSFWorkbook wb = new HSSFWorkbook();//创建工作薄
//
// //表头样式
// HSSFCellStyle style = wb.createCellStyle();
// style.setAlignment(HSSFCellStyle.ALIGN_CENTER); // 创建一个居中格式
// //字体样式
// HSSFFont fontStyle = wb.createFont();
// fontStyle.setFontName("微软雅黑");
// fontStyle.setFontHeightInPoints((short) 12);
// fontStyle.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
// style.setFont(fontStyle);
//
// //新建sheet
// HSSFSheet sheet1 = wb.createSheet("Sheet1");
// HSSFSheet sheet2 = wb.createSheet("Sheet2");
// HSSFSheet sheet3 = wb.createSheet("Sheet3");
//
// //生成sheet1内容
// HSSFRow rowFirst = sheet1.createRow(0);//第一个sheet的第一行为标题
// //写标题
// for (int i = 0; i < handers.length; i++) {
// HSSFCell cell = rowFirst.createCell(i); //获取第一行的每个单元格
// sheet1.setColumnWidth(i, 4000); //设置每列的列宽
// cell.setCellStyle(style); //加样式
// cell.setCellValue(handers[i]); //往单元格里写数据
// }
//
// //设置下拉框数据
// String[] arr = {"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"};
// int index = 0;
// HSSFRow row = null;
// for (int r = 0; r < downRows.length; r++) {
// String[] dlData = downData.get(r);//获取下拉对象
// int rownum = Integer.parseInt(downRows[r]);
//
// if (dlData.length < 5) { //255以内的下拉
// //255以内的下拉,参数分别是:作用的sheet、下拉内容数组、起始行、终止行、起始列、终止列
// sheet1.addValidationData(setDataValidation(sheet1, dlData, 1, 30000, rownum, rownum)); //超过255个报错
// } else { //255以上的下拉,即下拉列表元素很多的情况
//
// //1、设置有效性
// //String strFormula = "Sheet2!$A$1:$A$5000" ; //Sheet2第A1到A5000作为下拉列表来源数据
// String strFormula = "Sheet2!$" + arr[index] + "$1:$" + arr[index] + "$5000"; //Sheet2第A1到A5000作为下拉列表来源数据
// sheet2.setColumnWidth(r, 4000); //设置每列的列宽
// //设置数据有效性加载在哪个单元格上,参数分别是:从sheet2获取A1到A5000作为一个下拉的数据、起始行、终止行、起始列、终止列
// sheet1.addValidationData(SetDataValidation(strFormula, 1, 30000, rownum, rownum)); //下拉列表元素很多的情况
//
// //2、生成sheet2内容
// for (int j = 0; j < dlData.length; j++) {
// if (index == 0) { //第1个下拉选项,直接创建行、列
// row = sheet2.createRow(j); //创建数据行
// sheet2.setColumnWidth(j, 4000); //设置每列的列宽
// row.createCell(0).setCellValue(dlData[j]); //设置对应单元格的值
//
// } else { //非第1个下拉选项
//
// int rowCount = sheet2.getLastRowNum();
// //System.out.println("========== LastRowNum =========" + rowCount);
// if (j <= rowCount) { //前面创建过的行,直接获取行,创建列
// //获取行,创建列
// sheet2.getRow(j).createCell(index).setCellValue(dlData[j]); //设置对应单元格的值
//
// } else { //未创建过的行,直接创建行、创建列
// sheet2.setColumnWidth(j, 4000); //设置每列的列宽
// //创建行、创建列
// sheet2.createRow(j).createCell(index).setCellValue(dlData[j]); //设置对应单元格的值
// }
// }
// }
// index++;
// }
// }
//
// downLoadExcel(fileName, response, wb);
// }
/** /**
* @param @param strFormula * @param @param strFormula
...@@ -1152,7 +984,6 @@ public class FileHelper { ...@@ -1152,7 +984,6 @@ public class FileHelper {
DataValidationHelper helper = sheet.getDataValidationHelper(); DataValidationHelper helper = sheet.getDataValidationHelper();
//加载下拉列表内容 //加载下拉列表内容
DataValidationConstraint constraint = helper.createExplicitListConstraint(textList); DataValidationConstraint constraint = helper.createExplicitListConstraint(textList);
//DVConstraint constraint = new DVConstraint();
constraint.setExplicitListValues(textList); constraint.setExplicitListValues(textList);
//设置数据有效性加载在哪个单元格上。四个参数分别是:起始行、终止行、起始列、终止列 //设置数据有效性加载在哪个单元格上。四个参数分别是:起始行、终止行、起始列、终止列
...@@ -1160,7 +991,6 @@ public class FileHelper { ...@@ -1160,7 +991,6 @@ public class FileHelper {
//数据有效性对象 //数据有效性对象
DataValidation data_validation = helper.createValidation(constraint, regions); DataValidation data_validation = helper.createValidation(constraint, regions);
//DataValidation data_validation = new DataValidation(regions, constraint);
return data_validation; return data_validation;
} }
...@@ -1221,7 +1051,6 @@ public class FileHelper { ...@@ -1221,7 +1051,6 @@ public class FileHelper {
String filename = null; String filename = null;
String agent = request.getHeader("USER-AGENT"); String agent = request.getHeader("USER-AGENT");
//System.out.println("agent==========》"+agent);
if (null != agent) { if (null != agent) {
if (-1 != agent.indexOf("Firefox")) {//Firefox if (-1 != agent.indexOf("Firefox")) {//Firefox
......
package com.yeejoin.equipmanage.common.utils;
/**
* @description:
* @author: tw
* @createDate: 2023/3/15
*/
public class finalString {
public static final String URL="cs/v1/fireASF/dataSync";
public static final String ISNOTIOT="isNotIot";
public static final String URLST="cs/v1/fireAST/dataSync";
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment