Commit 64a9506e authored by 李成龙's avatar 李成龙

调整代码结构

parent da360a83
...@@ -15,6 +15,18 @@ ...@@ -15,6 +15,18 @@
</parent> </parent>
<dependencies> <dependencies>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-generator</artifactId>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
</dependency>
<!-- knife4j --> <!-- knife4j -->
<dependency> <dependency>
<groupId>com.github.xiaoymin</groupId> <groupId>com.github.xiaoymin</groupId>
......
...@@ -8,11 +8,6 @@ ...@@ -8,11 +8,6 @@
</parent> </parent>
<artifactId>amos-boot-module-common-api</artifactId> <artifactId>amos-boot-module-common-api</artifactId>
<dependencies> <dependencies>
<dependency>
<groupId>com.amosframework.boot</groupId>
<artifactId>amos-boot-biz-common</artifactId>
<version>${amos-biz-boot.version}</version>
</dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-elasticsearch</artifactId> <artifactId>spring-boot-starter-data-elasticsearch</artifactId>
......
...@@ -13,11 +13,6 @@ ...@@ -13,11 +13,6 @@
<dependencies> <dependencies>
<dependency>
<groupId>com.amosframework.boot</groupId>
<artifactId>amos-boot-biz-common</artifactId>
<version>${amos-biz-boot.version}</version>
</dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId> <artifactId>spring-boot-starter-data-jpa</artifactId>
......
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <project xmlns="http://maven.apache.org/POM/4.0.0"
<modelVersion>4.0.0</modelVersion> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<parent> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<artifactId>amos-boot-module-api</artifactId> <modelVersion>4.0.0</modelVersion>
<groupId>com.amosframework.boot</groupId> <parent>
<version>1.0.0</version> <artifactId>amos-boot-module-api</artifactId>
</parent> <groupId>com.amosframework.boot</groupId>
<version>1.0.0</version>
</parent>
<artifactId>amos-boot-module-jcs-api</artifactId> <artifactId>amos-boot-module-jcs-api</artifactId>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>com.amosframework.boot</groupId> <groupId>com.amosframework.boot</groupId>
<artifactId>amos-boot-biz-common</artifactId> <artifactId>amos-boot-module-common-api</artifactId>
<version>${amos-biz-boot.version}</version> <version>${amos-biz-boot.version}</version>
</dependency> </dependency>
<dependency>
<dependency> <groupId>com.yeejoin</groupId>
<groupId>com.amosframework.boot</groupId> <artifactId>amos-component-rule</artifactId>
<artifactId>amos-boot-module-common-api</artifactId> <exclusions>
<version>${amos-biz-boot.version}</version> <exclusion>
</dependency> <groupId>org.typroject</groupId>
<artifactId>tyboot-core-auth</artifactId>
</dependencies> </exclusion>
</exclusions>
</dependency>
</dependencies>
</project> </project>
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>amos-boot-module-api</artifactId>
<groupId>com.amosframework.boot</groupId>
<version>1.0.0</version>
</parent>
<artifactId>amos-boot-module-jpush-api</artifactId>
<dependencies>
<dependency>
<groupId>com.amosframework.boot</groupId>
<artifactId>amos-boot-biz-common</artifactId>
<version>${amos-biz-boot.version}</version>
<exclusions>
<exclusion>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-generator</artifactId>
</exclusion>
<exclusion>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
</exclusion>
<exclusion>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</project>
package com.yeejoin.amos.jpush.common.core.request;
import java.util.List;
import java.util.Map;
public class CheckResultPushSpcRequest {
private String riskSourceId;
private String riskSourceName;//危险源名称
private String pointName; //名称
private String nodeState;//巡检状态
private String executorName;//执行人名称
private String executeStatus;//执行状态
private String executorTime;//执行时间 yyyy-MM-dd HH:mm:ss
private Map<String, List<String>> riskFactorMap ;//危险因素和管控措施
//新加巡检点id
private int pointID;
//新建点公司code
private String code;
//点楼层
private String num;
//三维坐标
private String coordinates;
//巡检点明称
private String name;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getNum() {
return num;
}
public void setNum(String num) {
this.num = num;
}
public String getCoordinates() {
return coordinates;
}
public void setCoordinates(String coordinates) {
this.coordinates = coordinates;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public int getPointID() {
return pointID;
}
public void setPointID(int pointID) {
this.pointID = pointID;
}
public String getRiskSourceName() {
return riskSourceName;
}
public void setRiskSourceName(String riskSourceName) {
this.riskSourceName = riskSourceName;
}
public String getPointName() {
return pointName;
}
public void setPointName(String pointName) {
this.pointName = pointName;
}
public String getNodeState() {
return nodeState;
}
public void setNodeState(String nodeState) {
this.nodeState = nodeState;
}
public String getExecutorName() {
return executorName;
}
public void setExecutorName(String executorName) {
this.executorName = executorName;
}
public String getExecuteStatus() {
return executeStatus;
}
public void setExecuteStatus(String executeStatus) {
this.executeStatus = executeStatus;
}
public String getExecutorTime() {
return executorTime;
}
public void setExecutorTime(String executorTime) {
this.executorTime = executorTime;
}
public Map<String, List<String>> getRiskFactorMap() {
return riskFactorMap;
}
public void setRiskFactorMap(Map<String, List<String>> riskFactorMap) {
this.riskFactorMap = riskFactorMap;
}
public String getRiskSourceId() {
return riskSourceId;
}
public void setRiskSourceId(String riskSourceId) {
this.riskSourceId = riskSourceId;
}
}
package com.yeejoin.amos.jpush.common.core.request;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
/**
*
* <pre>
* 公共请求对象
* </pre>
*
* @author as-shibaobao
* @version $Id: CommonRequest.java, v 0.1 2018年1月26日 上午10:59:19 as-shibaobao Exp $
*/
@ApiModel
public class CommonRequest {
/**
* 字段名称
*/
@ApiModelProperty(value="字段名称",required=true)
private String name;
/**
* 字段值
*/
@ApiModelProperty(value="字段值",required=true)
private Object value;
/**
* 查询类型
*/
@ApiModelProperty(value="查询类型",notes="空值时,默认为等于;其它类型按QueryOperatorEnum",required=false)
private String type;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Object getValue() {
return value;
}
public void setValue(Object value) {
this.value = value;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
}
package com.yeejoin.amos.jpush.common.core.request;
public class LatentDangerResultPushSpcRequest {
private String hiddenTroubleStatus;//隐患状态
private String processingTime;//处理时间
private String hiddenTroubleName;//隐患名称
private String riskSourceId;//风险点id
public String getHiddenTroubleStatus() {
return hiddenTroubleStatus;
}
public void setHiddenTroubleStatus(String hiddenTroubleStatus) {
this.hiddenTroubleStatus = hiddenTroubleStatus;
}
public String getProcessingTime() {
return processingTime;
}
public void setProcessingTime(String processingTime) {
this.processingTime = processingTime;
}
public String getHiddenTroubleName() {
return hiddenTroubleName;
}
public void setHiddenTroubleName(String hiddenTroubleName) {
this.hiddenTroubleName = hiddenTroubleName;
}
public String getRiskSourceId() {
return riskSourceId;
}
public void setRiskSourceId(String riskSourceId) {
this.riskSourceId = riskSourceId;
}
}
package com.yeejoin.amos.jpush.common.core.request;
/**
* 线路巡检点巡检项查询条件
* @author Administrator
*
*/
public class RoutePointInputItemRequest {
/**
* 巡检点id
*/
private Long pointId;
/**
* 是否绑定
*/
private String isBound;
/**
* 路线id
*/
private Long routeId;
/**
* 分类id
*/
private Long classifyId;
/**
* 巡检项等级
*/
private String level;
/**
* 巡检项名称
*/
private String inputName;
public Long getPointId() {
return pointId;
}
public void setPointId(Long pointId) {
this.pointId = pointId;
}
public Long getRouteId() {
return routeId;
}
public void setRouteId(Long routeId) {
this.routeId = routeId;
}
public Long getClassifyId() {
return classifyId;
}
public void setClassifyId(Long classifyId) {
this.classifyId = classifyId;
}
public String getLevel() {
return level;
}
public void setLevel(String level) {
this.level = level;
}
public String getInputName() {
return inputName;
}
public void setInputName(String inputName) {
this.inputName = inputName;
}
public String getIsBound() {
return isBound;
}
public void setIsBound(String isBound) {
this.isBound = isBound;
}
}
package com.yeejoin.amos.jpush.common.entity;
import java.io.Serializable;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializerFeature;
import io.swagger.annotations.ApiModelProperty;
/**
* <pre>
* 返回封装对象
* </pre>
*
* @author mincx
* @version CommonReponse.java v0.1
* @time 2017-9-19 15:43:32
*/
public class CommonResponse implements Serializable {
private static final long serialVersionUID = -8737351878134480646L;
/**
* 操作状态
*/
@ApiModelProperty(required=true,value="操作状态")
private String result;
/**
* 数据
*/
@ApiModelProperty(required=false,value="数据")
private Object dataList;
/**
* 操作详细信息
*/
@ApiModelProperty(required=false,value="操作详细信息")
private String message;
public CommonResponse(){
}
public CommonResponse(String result) {
this.result = result;
}
public CommonResponse(Object dataList) {
this.dataList = dataList;
this.result = "";
}
public CommonResponse(String result, Object dataList) {
this.dataList = dataList;
this.result = result;
}
public CommonResponse(String result, String message) {
this.result = result;
this.message = message;
}
public CommonResponse(String result, Object dataList, String message) {
this.dataList = dataList;
this.result = result;
this.message = message;
}
public Boolean isSuccess(){
return "SUCCESS".equals(getResult());
}
public String getResult() {
return result;
}
public void setResult(String result) {
this.result = result;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public Object getDataList() {
return dataList;
}
public void setDataList(Object dataList) {
this.dataList = dataList;
}
public String toJsonStr() throws Exception {
return JSON.toJSONString(this,SerializerFeature.WriteMapNullValue,SerializerFeature.DisableCircularReferenceDetect,SerializerFeature.SkipTransientField);
}
}
package com.yeejoin.amos.jpush.common.entity;
public class CommonResponseUtil
{
public static CommonResponse success()
{
CommonResponse response = new CommonResponse();
response.setResult(Constants.RESULT_SUCCESS);
return response;
}
public static CommonResponse success(Object obj)
{
CommonResponse response = new CommonResponse();
response.setResult(Constants.RESULT_SUCCESS);
response.setDataList(obj);
return response;
}
public static CommonResponse success(Object obj, String message)
{
CommonResponse response = new CommonResponse();
response.setResult(Constants.RESULT_SUCCESS);
response.setDataList(obj);
response.setMessage(message);
return response;
}
public static CommonResponse failure()
{
CommonResponse response = new CommonResponse();
response.setResult(Constants.RESULT_FAILURE);
return response;
}
public static CommonResponse failure(String message)
{
CommonResponse response = new CommonResponse();
response.setResult(Constants.RESULT_FAILURE);
response.setMessage(message);
return response;
}
public static CommonResponse failure(Object obj, String message)
{
CommonResponse response = new CommonResponse();
response.setResult(Constants.RESULT_FAILURE);
response.setDataList(obj);
response.setMessage(message);
return response;
}
}
package com.yeejoin.amos.jpush.common.entity;
/**
* <pre>
* 系统常量
* </pre>
*
* @author mincx
* @version Constants.java v0.1
* @time 2017-9-19 15:43:32
*/
public class Constants {
public static final String ERROR_MESSAGE = "系统异常";
public static final String RESULT_SUCCESS = "SUCCESS";
public static final String RESULT_FAILURE = "FAILURE";
public static final String RULE_FACT_PREFIX = "rule_";
public static final String RULE_COMPILATION_ERROR = "规则编译异常";
public static final String NEW_LINE= "\r\n";
public static final String POSITION_LATITUDE = "latitude";
public static final String POSITION_LONGITUDE = "longitude";
public static final double PI = 3.1415;
public static final double EARTH_RADIUS = 6370.996;
public static final String RULE_CONDITION_AND = "&&";
public static final String RULE_CONDITION_OR = "||";
/**
* DES加密解密默认key
*/
public static final String XSS_KEY = "qaz";
/**
* 灾情状态
*/
public static final String FireHappenStateID = "90db70b7-49a4-4a72-b54b-0fabbed9bec7";//发生
public static final String FireDevelopStateID = "1f7fe7d7-b30c-4518-8c95-6e3bc506ca86";//猛烈
/**
* 车辆状态
*/
public static final String CarArrivedStateID = "ad55748a-1206-4507-8831-95b7f2ad804f";//到达
public static final String CarDispatchingStateID = "43a23576-3d0f-4c3d-a46b-555391a4d870";//待出动
public static final String CarOnDutyStateID = "21cc717f-60b4-46ae-942e-9efd63d13415";//执勤
public static final String CarOnSiteStateID = "d7eddc16-4c55-4de0-b726-3547c7b0b980";//在位
public static final String CarOnTheWayStateID = "5e1b6e98-d1dc-4c49-a7ad-b959d2278dba";//在途
public static final String CarRepairStateID = "e86d455b-e9fd-4938-9826-38ca46623287";//维修
/**
* 战斗力量编队状态
*/
public static final String RescuePowerArrivedStateID = "0951f770-7f75-43d8-bcec-47d7559be727";//到达
public static final String RescuePowerDispatchedStateID = "ec4afc56-6cec-41a3-95f5-20c735f052d4";//已调派
public static final String RescuePowerEnhanceStateID = "3d6cf113-b69d-47c3-a3a8-ded448cc4636";//增援
public static final String RescuePowerFightingStateID = "4bacd4b4-b07d-454e-b737-431e7c997cde";//战斗
public static final String RescuePowerStandByStateID = "4fc6e4d6-c6a8-453c-b554-ce7de0b828b2";//待命
/**
* sql注入关键字
*/
public static String badStr = "'|and|exec|execute|insert|select|delete|update|count|drop|%|chr|mid|master|truncate|" +
"char|declare|sitename|net user|xp_cmdshell|;|or|-|+|,|like'|and|exec|execute|insert|create|drop|" +
"table|from|grant|use|group_concat|column_name|" +
"information_schema.columns|table_schema|union|where|select|delete|update|order|by|count|" +
"chr|mid|master|truncate|char|declare|or|;|-|--|,|like|//|/|%|#";
}
package com.yeejoin.amos.jpush.common.entity;
import java.io.Serializable;
import org.apache.commons.lang3.builder.ToStringBuilder;
/**
*
* <pre>
* 查询条件封装类
* </pre>
*
* @author as-hanshipeng
* @version $Id: DaoCriteria.java, v 0.1 2016-12-9 下午12:22:03 as-hanshipeng Exp $
*/
public class DaoCriteria implements Serializable
{
private static final long serialVersionUID = 812759366580443779L;
//属性名称
private String propertyName;
//操作符
private String operator;
//属性值
private Object value;
public String getOperator()
{
return operator;
}
public void setOperator(String operator)
{
this.operator = operator;
}
public String getPropertyName()
{
return propertyName;
}
public void setPropertyName(String propertyName)
{
this.propertyName = propertyName;
}
public Object getValue()
{
return value;
}
public void setValue(Object value)
{
this.value = value;
}
public DaoCriteria()
{
}
public DaoCriteria(String property, String operator, Object value)
{
propertyName = property;
this.operator = operator;
this.value = value;
}
public String toString()
{
return (new ToStringBuilder(this)).append("Property", propertyName).append(operator).append("Value", value).toString();
}
}
package com.yeejoin.amos.jpush.common.entity;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.ParsePosition;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.List;
import java.util.Locale;
import java.util.Random;
import org.apache.commons.lang.StringUtils;
/**
* 日期工具类
*
*/
public class DateUtil {
// 默认日期格式
public static final String DATE_DEFAULT_FORMAT = "yyyy-MM-dd";
// 默认日期格式
public static final String DATE_YEARANDMONTH_FORMAT = "yyyy-MM";
// 默认时间格式
public static final String DATETIME_DEFAULT_FORMAT = "yyyy-MM-dd HH:mm:ss";
public static final String TIME_DEFAULT_FORMAT = "HH:mm:ss";
// 日期格式化
private static DateFormat dateFormat = null;
// 时间格式化
private static DateFormat dateTimeFormat = null;
// 年月格式化
private static DateFormat dateYearAndMonthFormat = null;
private static DateFormat timeFormat = null;
private static Calendar gregorianCalendar = null;
static {
dateFormat = new SimpleDateFormat(DATE_DEFAULT_FORMAT);
dateYearAndMonthFormat = new SimpleDateFormat(DATE_YEARANDMONTH_FORMAT);
dateTimeFormat = new SimpleDateFormat(DATETIME_DEFAULT_FORMAT);
timeFormat = new SimpleDateFormat(TIME_DEFAULT_FORMAT);
gregorianCalendar = new GregorianCalendar();
}
/**
* 日期格式化yyyy-MM-dd
*
* @param date
* @return
*/
public static Date formatDate(String date, String format) {
try {
return new SimpleDateFormat(format).parse(date);
} catch (ParseException e) {
e.printStackTrace();
}
return null;
}
/**
* 日期格式化yyyy-MM-dd
*
* @param date
* @return
*/
public static String getDateFormat(Date date) {
return dateFormat.format(date);
}
/**
* 日期格式化yyyy-MM
*
* @param date
* @return
*/
public static String getDateYearAndMonthFormat(Date date) {
return dateYearAndMonthFormat.format(date);
}
/**
* 日期格式化yyyy-MM-dd HH:mm:ss
*
* @param date
* @return
*/
public static String getDateTimeFormat(Date date) {
return dateTimeFormat.format(date);
}
/**
* 时间格式化
*
* @param date
* @return HH:mm:ss
*/
public static String getTimeFormat(Date date) {
return timeFormat.format(date);
}
/**
* 日期格式化
*
* @param date
* @param 格式类型
* @return
*/
public static String getDateFormat(Date date, String formatStr) {
if (StringUtils.isNotBlank(formatStr)) {
return new SimpleDateFormat(formatStr).format(date);
}
return null;
}
/**
* 日期格式化
*
* @param date
* @return
*/
public static Date getDateFormat(String date) {
try {
return dateFormat.parse(date);
} catch (ParseException e) {
e.printStackTrace();
}
return null;
}
/**
* 时间格式化
*
* @param date
* @return
*/
public static Date getDateTimeFormat(String date) {
try {
return dateTimeFormat.parse(date);
} catch (ParseException e) {
e.printStackTrace();
}
return null;
}
/**
* 获取当前日期(yyyy-MM-dd)
*
* @param date
* @return
*/
public static Date getNowDate() {
return DateUtil.getDateFormat(dateFormat.format(new Date()));
}
/**
* 获取当前日期星期一日期
*
* @return date
*/
public static Date getFirstDayOfWeek() {
gregorianCalendar.setFirstDayOfWeek(Calendar.MONDAY);
gregorianCalendar.setTime(new Date());
gregorianCalendar.set(Calendar.DAY_OF_WEEK, gregorianCalendar.getFirstDayOfWeek()); // Monday
return gregorianCalendar.getTime();
}
/**
* 获取当前日期星期日日期
*
* @return date
*/
public static Date getLastDayOfWeek() {
gregorianCalendar.setFirstDayOfWeek(Calendar.MONDAY);
gregorianCalendar.setTime(new Date());
gregorianCalendar.set(Calendar.DAY_OF_WEEK, gregorianCalendar.getFirstDayOfWeek() + 6); // Monday
return gregorianCalendar.getTime();
}
/**
* 获取日期星期一日期
*
* @param 指定日期
* @return date
*/
public static Date getFirstDayOfWeek(Date date) {
if (date == null) {
return null;
}
gregorianCalendar.setFirstDayOfWeek(Calendar.MONDAY);
gregorianCalendar.setTime(date);
gregorianCalendar.set(Calendar.DAY_OF_WEEK, gregorianCalendar.getFirstDayOfWeek()); // Monday
return gregorianCalendar.getTime();
}
/**
* 获取日期星期一日期
*
* @param 指定日期
* @return date
*/
public static Date getLastDayOfWeek(Date date) {
if (date == null) {
return null;
}
gregorianCalendar.setFirstDayOfWeek(Calendar.MONDAY);
gregorianCalendar.setTime(date);
gregorianCalendar.set(Calendar.DAY_OF_WEEK, gregorianCalendar.getFirstDayOfWeek() + 6); // Monday
return gregorianCalendar.getTime();
}
/**
* 获取当前月的第一天
*
* @return date
*/
public static Date getFirstDayOfMonth() {
gregorianCalendar.setTime(new Date());
gregorianCalendar.set(Calendar.DAY_OF_MONTH, 1);
return gregorianCalendar.getTime();
}
/**
* 获取当前月的最后一天
*
* @return
*/
public static Date getLastDayOfMonth() {
gregorianCalendar.setTime(new Date());
gregorianCalendar.set(Calendar.DAY_OF_MONTH, 1);
gregorianCalendar.add(Calendar.MONTH, 1);
gregorianCalendar.add(Calendar.DAY_OF_MONTH, -1);
return gregorianCalendar.getTime();
}
/**
* 获取指定月的第一天
*
* @param date
* @return
*/
public static Date getFirstDayOfMonth(Date date) {
gregorianCalendar.setTime(date);
gregorianCalendar.set(Calendar.DAY_OF_MONTH, 1);
return gregorianCalendar.getTime();
}
/**
* 获取指定月的最后一天
*
* @param date
* @return
*/
public static Date getLastDayOfMonth(Date date) {
gregorianCalendar.setTime(date);
gregorianCalendar.set(Calendar.DAY_OF_MONTH, 1);
gregorianCalendar.add(Calendar.MONTH, 1);
gregorianCalendar.add(Calendar.DAY_OF_MONTH, -1);
return gregorianCalendar.getTime();
}
/**
* 获取日期前一天
*
* @param date
* @return
*/
public static Date getDayBefore(Date date) {
gregorianCalendar.setTime(date);
int day = gregorianCalendar.get(Calendar.DATE);
gregorianCalendar.set(Calendar.DATE, day - 1);
return gregorianCalendar.getTime();
}
/**
* 获取日期后一天
*
* @param date
* @return
*/
public static Date getDayAfter(Date date) {
gregorianCalendar.setTime(date);
int day = gregorianCalendar.get(Calendar.DATE);
gregorianCalendar.set(Calendar.DATE, day + 1);
return gregorianCalendar.getTime();
}
/**
* 获取当前年
*
* @return
*/
public static int getNowYear() {
Calendar d = Calendar.getInstance();
return d.get(Calendar.YEAR);
}
/**
* 获取当前月份
*
* @return
*/
public static int getNowMonth() {
Calendar d = Calendar.getInstance();
return d.get(Calendar.MONTH) + 1;
}
/**
* 获取date的年
*
* @return
*/
public static int getDateYear(Date date) {
Calendar d = Calendar.getInstance();
d.setTime(date);
return d.get(Calendar.YEAR);
}
/**
* 获取date的月份
*
* @return
*/
public static int getDateMonth(Date date) {
Calendar d = Calendar.getInstance();
d.setTime(date);
return d.get(Calendar.MONTH) + 1;
}
/**
* 获取当月天数
*
* @return
*/
public static int getNowMonthDay() {
Calendar d = Calendar.getInstance();
return d.getActualMaximum(Calendar.DATE);
}
/**
* 获取时间段的每一天
*
* @param 开始日期
* @param 结算日期
* @return 日期列表
*/
public static List<Date> getEveryDay(Date startDate, Date endDate) {
if (startDate == null || endDate == null) {
return null;
}
// 格式化日期(yy-MM-dd)
startDate = DateUtil.getDateFormat(DateUtil.getDateFormat(startDate));
endDate = DateUtil.getDateFormat(DateUtil.getDateFormat(endDate));
List<Date> dates = new ArrayList<Date>();
gregorianCalendar.setTime(startDate);
dates.add(gregorianCalendar.getTime());
while (gregorianCalendar.getTime().compareTo(endDate) < 0) {
// 加1天
gregorianCalendar.add(Calendar.DAY_OF_MONTH, 1);
dates.add(gregorianCalendar.getTime());
}
return dates;
}
/**
* 获取提前多少个月
*
* @param monty
* @return
*/
public static Date getFirstMonth(int monty) {
Calendar c = Calendar.getInstance();
c.add(Calendar.MONTH, -monty);
return c.getTime();
}
/**
* 得到现在时间
*
* @return
*/
public static Date getNow()
{
Date currentTime = new Date();
return currentTime;
}
/**
* 获取现在时间
*
* @return 返回时间类型 yyyy-MM-dd HH:mm:ss
*/
public static String getNowDateLongForHandset()
{
Date currentTime = new Date();
SimpleDateFormat formatter = new SimpleDateFormat("yyyy:MM:dd-HH:mm:ss");
String dateString = formatter.format(currentTime);
return dateString;
}
public static String getDateLongForHandset(java.util.Date dateDate){
SimpleDateFormat formatter = new SimpleDateFormat("yyyy:MM:dd HH:mm:ss");
String dateString = formatter.format(dateDate);
return dateString;
}
public static String getDateStr(String formatterstr) {
Date currentTime = new Date();
SimpleDateFormat formatter = new SimpleDateFormat(formatterstr);
String dateString = formatter.format(currentTime);
return dateString;
}
/**
* 获取现在时间
*
* @return 返回时间类型 yyyy-MM-dd HH:mm:ss
*/
public static Date getNowDateLong()
{
Date currentTime = new Date();
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String dateString = formatter.format(currentTime);
ParsePosition pos = new ParsePosition(0);
Date currentTime_2 = formatter.parse(dateString, pos);
return currentTime_2;
}
/**
* 获取现在时间
*
* @return返回短时间格式 yyyy-MM-dd
*/
public static Date getNowDateShort()
{
Date currentTime = new Date();
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
String dateString = formatter.format(currentTime);
ParsePosition pos = new ParsePosition(8);
Date currentTime_2 = formatter.parse(dateString, pos);
return currentTime_2;
}
/**
* 获取现在时间字符串
*
* @return返回字符串格式 yyyy-MM-dd HH:mm:ss
*/
public static String getNowStrLong()
{
Date currentTime = new Date();
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String dateString = formatter.format(currentTime);
return dateString;
}
/**
* 获取现在时间字符串
*
* @return 返回短时间字符串格式yyyy-MM-dd
*/
public static String getNowStrShort()
{
Date currentTime = new Date();
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
String dateString = formatter.format(currentTime);
return dateString;
}
/**
* 获取时间 小时:分;秒 HH:mm:ss
*
* @return
*/
public static String getNowHHMMSS()
{
SimpleDateFormat formatter = new SimpleDateFormat("HH:mm:ss");
Date currentTime = new Date();
String dateString = formatter.format(currentTime);
return dateString;
}
/**
*
* <pre>
*
* </pre>
*
* @param strDate
* @param dateFormat
* @return
*/
public static Date str2Date(String strDate, String dateFormat)
{
SimpleDateFormat formatter = new SimpleDateFormat(dateFormat);
ParsePosition pos = new ParsePosition(0);
Date strtodate = formatter.parse(strDate, pos);
return strtodate;
}
/**
*
* <pre>
* e.g localDateStr ="2017-03-30T06:28:12.803Z";
* </pre>
*
* @param strDate
* @param dateFormat
* @return
*/
public static Date localDateStr2Date(String localDateStr)
{
LocalDateTime localDate = LocalDateTime.parse(localDateStr,DateTimeFormatter.ISO_ZONED_DATE_TIME);
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String formatLocalDate2Str = localDate.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
ParsePosition pos = new ParsePosition(0);
Date strtodate = formatter.parse(formatLocalDate2Str, pos);
return strtodate;
}
/**
* 将长时间格式字符串转换为时间 yyyy-MM-dd HH:mm:ss
*
* @param strDate
* @return
*/
public static Date longStr2Date(String strDate)
{
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
ParsePosition pos = new ParsePosition(0);
Date strtodate = formatter.parse(strDate, pos);
return strtodate;
}
/**
* 将长时间格式字符串转换为时间 yyyy-MM-dd HH:mm
*
* @param strDate
* @return
*/
public static Date longStr3Date(String strDate)
{
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm");
ParsePosition pos = new ParsePosition(0);
Date strtodate = formatter.parse(strDate, pos);
return strtodate;
}
/**
* 将长时间格式字符串转换为long型数据
*
* @param strDate
* @return
*/
public static Long longStr2Long(String strDate)
{
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
ParsePosition pos = new ParsePosition(0);
Date strtodate = formatter.parse(strDate, pos);
return strtodate.getTime();
}
/**
* 将长时间格式时间转换为字符串 yyyy-MM-dd HH:mm:ss
*
* @param dateDate
* @return
*/
public static String date2LongStr(Date dateDate)
{
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String dateString = formatter.format(dateDate);
return dateString;
}
/**
* 将短时间格式时间转换为字符串 yyyy-MM-dd
*
* @param dateDate
* @param k
* @return
*/
public static String date2ShortStr(java.util.Date dateDate)
{
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
String dateString = formatter.format(dateDate);
return dateString;
}
/**
*
* <pre>
*
* </pre>
*
* @param l
* @param dateFormat
* @return
*/
public static String long2Str(long l, String dateFormat)
{
if (l == 0)
{
return "";
}
try
{
Date dateDate = new Date(l);
SimpleDateFormat formatter = new SimpleDateFormat(dateFormat);
String dateString = formatter.format(dateDate);
return dateString;
}
catch (Exception e)
{
return "";
}
}
/**
* 把LONG数据类型转换为字符串
*
* @param l
* @return
*/
public static String long2LongStr(long l)
{
if (l == 0)
{
return "";
}
try
{
Date dateDate = new Date(l);
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String dateString = formatter.format(dateDate);
return dateString;
}
catch (Exception e)
{
return "";
}
}
/**
* 把LONG数据类型转换为字符串
*
* <pre>
*
* </pre>
*
* @param l
* @return
*/
public static String long2ShortStr(long l)
{
if (l == 0)
{
return "";
}
try
{
Date dateDate = new Date(l);
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
String dateString = formatter.format(dateDate);
return dateString;
}
catch (Exception e)
{
return "";
}
}
/**
* 将短时间格式字符串转换为时间 yyyy-MM-dd
*
* @param strDate
* @return
*/
public static Date shortStr2ShortDate(String strDate)
{
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
ParsePosition pos = new ParsePosition(0);
Date strtodate = formatter.parse(strDate, pos);
return strtodate;
}
/**
* 提取一个月中的最后一天
*
* @param day
* @return
*/
public static Date getLastDateOfThisMonth(long day)
{
Date date = new Date();
long date_3_hm = date.getTime() - 3600000 * 34 * day;
Date date_3_hm_date = new Date(date_3_hm);
return date_3_hm_date;
}
/**
* 获取日期中的年
*
* @param date
* @return
*/
public static String getYear(Date date) {
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String dateString = formatter.format(date);
String year;
year = dateString.substring(0, 4);
return year;
}
/**
* 得到现在小时
*/
public static String getHour()
{
Date currentTime = new Date();
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String dateString = formatter.format(currentTime);
String hour;
hour = dateString.substring(11, 13);
return hour;
}
/**
* 得到现在分钟
*
* @return
*/
public static String getMinute()
{
Date currentTime = new Date();
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String dateString = formatter.format(currentTime);
String min;
min = dateString.substring(14, 16);
return min;
}
/**
* 根据用户传入的时间表示格式,返回当前时间的格式 如果是yyyyMMdd,注意字母y不能大写。
*
* @param sformat
* yyyyMMddhhmmss
* @return
*/
public static String parseDate(String sformat)
{
Date currentTime = new Date();
SimpleDateFormat formatter = new SimpleDateFormat(sformat);
String dateString = formatter.format(currentTime);
return dateString;
}
/**
* 二个小时时间间的差值,必须保证二个时间都是"HH:MM"的格式,返回字符型的分钟
*/
public static String getTwoHour(String st1, String st2)
{
String[] kk = null;
String[] jj = null;
kk = st1.split(":");
jj = st2.split(":");
if (Integer.parseInt(kk[0]) < Integer.parseInt(jj[0])) return "0";
else
{
double y = Double.parseDouble(kk[0]) + Double.parseDouble(kk[1]) / 60;
double u = Double.parseDouble(jj[0]) + Double.parseDouble(jj[1]) / 60;
if ((y - u) > 0) return y - u + "";
else
return "0";
}
}
/**
* 得到二个日期间的间隔天数
*/
public static String getTwoDay(String sj1, String sj2)
{
SimpleDateFormat myFormatter = new SimpleDateFormat("yyyy-MM-dd");
long day = 0;
try
{
java.util.Date date = myFormatter.parse(sj1);
java.util.Date mydate = myFormatter.parse(sj2);
day = (date.getTime() - mydate.getTime()) / (24 * 60 * 60 * 1000);
}
catch (Exception e)
{
return "";
}
return day + "";
}
/**
* 时间前推或后推分钟,其中JJ表示分钟.
*/
public static String getPreTime(String sj1, String jj)
{
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String mydate1 = "";
try
{
Date date1 = format.parse(sj1);
long Time = (date1.getTime() / 1000) + Integer.parseInt(jj) * 60;
date1.setTime(Time * 1000);
mydate1 = format.format(date1);
}
catch (Exception e)
{
mydate1 = "";
}
return mydate1;
}
/**
* 得到一个时间延后或前移几天的时间,nowdate为时间,delay为前移或后延的天数
*/
public static String getNextDay(String nowdate, String delay)
{
try
{
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
String mdate = "";
Date d = shortStr2ShortDate(nowdate);
long myTime = (d.getTime() / 1000) + Integer.parseInt(delay) * 24 * 60 * 60;
d.setTime(myTime * 1000);
mdate = format.format(d);
return mdate;
}
catch (Exception e)
{
return "";
}
}
/**
* 判断是否润年
*
* @param ddate
* @return
*/
public static boolean isLeapYear(String ddate)
{
/**
* 详细设计: 1.被400整除是闰年,否则: 2.不能被4整除则不是闰年 3.能被4整除同时不能被100整除则是闰年
* 3.能被4整除同时能被100整除则不是闰年
*/
Date d = shortStr2ShortDate(ddate);
GregorianCalendar gc = (GregorianCalendar) Calendar.getInstance();
gc.setTime(d);
int year = gc.get(Calendar.YEAR);
if ((year % 400) == 0) return true;
else if ((year % 4) == 0)
{
if ((year % 100) == 0) return false;
else
return true;
}
else
return false;
}
/**
* 返回美国时间格式 26 Apr 2006
*
* @param str
* @return
*/
public static String getEDate(String str)
{
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
ParsePosition pos = new ParsePosition(0);
Date strtodate = formatter.parse(str, pos);
String j = strtodate.toString();
String[] k = j.split(" ");
return k[2] + k[1].toUpperCase() + k[5].substring(2, 4);
}
/**
* 获取一个月的最后一天
*
* @param dat
* @return
*/
public static String getEndDateOfMonth(String dat)
{// yyyy-MM-dd
String str = dat.substring(0, 8);
String month = dat.substring(5, 7);
int mon = Integer.parseInt(month);
if (mon == 1 || mon == 3 || mon == 5 || mon == 7 || mon == 8 || mon == 10 || mon == 12)
{
str += "31";
}
else if (mon == 4 || mon == 6 || mon == 9 || mon == 11)
{
str += "30";
}
else
{
if (isLeapYear(dat))
{
str += "29";
}
else
{
str += "28";
}
}
return str;
}
/**
* 判断二个时间是否在同一个周
*
* @param date1
* @param date2
* @return
*/
public static boolean isSameWeekDates(Date date1, Date date2)
{
Calendar cal1 = Calendar.getInstance();
Calendar cal2 = Calendar.getInstance();
cal1.setTime(date1);
cal2.setTime(date2);
int subYear = cal1.get(Calendar.YEAR) - cal2.get(Calendar.YEAR);
if (0 == subYear)
{
if (cal1.get(Calendar.WEEK_OF_YEAR) == cal2.get(Calendar.WEEK_OF_YEAR)) return true;
}
else if (1 == subYear && 11 == cal2.get(Calendar.MONTH))
{
// 如果12月的最后一周横跨来年第一周的话则最后一周即算做来年的第一周
if (cal1.get(Calendar.WEEK_OF_YEAR) == cal2.get(Calendar.WEEK_OF_YEAR)) return true;
}
else if (-1 == subYear && 11 == cal1.get(Calendar.MONTH))
{
if (cal1.get(Calendar.WEEK_OF_YEAR) == cal2.get(Calendar.WEEK_OF_YEAR)) return true;
}
return false;
}
/**
* 产生周序列,即得到当前时间所在的年度是第几周
*
* @return
*/
public static String getSeqWeek()
{
Calendar c = Calendar.getInstance(Locale.CHINA);
String week = Integer.toString(c.get(Calendar.WEEK_OF_YEAR));
if (week.length() == 1) week = "0" + week;
String year = Integer.toString(c.get(Calendar.YEAR));
return year + week;
}
/**
* 获得一个日期所在的周的星期几的日期,如要找出2002年2月3日所在周的星期一是几号
*
* @param sdate
* @param num
* @return
*/
public static String getWeek(String sdate, String num)
{
// 再转换为时间
Date dd = shortStr2ShortDate(sdate);
Calendar c = Calendar.getInstance();
c.setTime(dd);
if (num.equals("1")) // 返回星期一所在的日期
c.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
else if (num.equals("2")) // 返回星期二所在的日期
c.set(Calendar.DAY_OF_WEEK, Calendar.TUESDAY);
else if (num.equals("3")) // 返回星期三所在的日期
c.set(Calendar.DAY_OF_WEEK, Calendar.WEDNESDAY);
else if (num.equals("4")) // 返回星期四所在的日期
c.set(Calendar.DAY_OF_WEEK, Calendar.THURSDAY);
else if (num.equals("5")) // 返回星期五所在的日期
c.set(Calendar.DAY_OF_WEEK, Calendar.FRIDAY);
else if (num.equals("6")) // 返回星期六所在的日期
c.set(Calendar.DAY_OF_WEEK, Calendar.SATURDAY);
else if (num.equals("0")) // 返回星期日所在的日期
c.set(Calendar.DAY_OF_WEEK, Calendar.SUNDAY);
return new SimpleDateFormat("yyyy-MM-dd").format(c.getTime());
}
/**
* 根据一个日期,返回是星期几的字符串
*
* @param sdate
* @return
*/
public static String getWeek(String sdate)
{
// 再转换为时间
Date date = shortStr2ShortDate(sdate);
Calendar c = Calendar.getInstance();
c.setTime(date);
// int hour=c.get(Calendar.DAY_OF_WEEK);
// hour中存的就是星期几了,其范围 1~7
// 1=星期日 7=星期六,其他类推
return new SimpleDateFormat("EEEE").format(c.getTime());
}
public static String getWeekStr(String sdate)
{
String str = "";
str = getWeek(sdate);
if ("1".equals(str))
{
str = "星期日";
}
else if ("2".equals(str))
{
str = "星期一";
}
else if ("3".equals(str))
{
str = "星期二";
}
else if ("4".equals(str))
{
str = "星期三";
}
else if ("5".equals(str))
{
str = "星期四";
}
else if ("6".equals(str))
{
str = "星期五";
}
else if ("7".equals(str))
{
str = "星期六";
}
return str;
}
/**
* 两个时间之间的天数
*
* @param date1
* @param date2
* @return
*/
public static long getDays(String date1, String date2)
{
if (date1 == null || date1.equals("")) return 0;
if (date2 == null || date2.equals("")) return 0;
// 转换为标准时间
SimpleDateFormat myFormatter = new SimpleDateFormat("yyyy-MM-dd");
java.util.Date date = null;
java.util.Date mydate = null;
try
{
date = myFormatter.parse(date1);
mydate = myFormatter.parse(date2);
}
catch (Exception e)
{
;
}
long day = (date.getTime() - mydate.getTime()) / (24 * 60 * 60 * 1000);
return day;
}
/**
* 形成如下的日历 , 根据传入的一个时间返回一个结构 星期日 星期一 星期二 星期三 星期四 星期五 星期六 下面是当月的各个时间
* 此函数返回该日历第一行星期日所在的日期
*
* @param sdate
* @return
*/
public static String getNowMonth(String sdate)
{
// 取该时间所在月的一号
sdate = sdate.substring(0, 8) + "01";
// 得到这个月的1号是星期几
Date date = shortStr2ShortDate(sdate);
Calendar c = Calendar.getInstance();
c.setTime(date);
int u = c.get(Calendar.DAY_OF_WEEK);
String newday = DateUtil.getNextDay(sdate, (1 - u) + "");
return newday;
}
/**
* 取得数据库主键 生成格式为yyyymmddhhmmss+k位随机数
*
* @param k
* 表示是取几位随机数,可以自己定
*/
public static String getNo(int k)
{
return parseDate("yyyyMMddhhmmss") + getRandom(k);
}
/**
* 返回一个随机数
*
* @param i
* @return
*/
private static String getRandom(int i)
{
Random jjj = new Random();
// int suiJiShu = jjj.nextInt(9);
if (i == 0) return "";
String jj = "";
for (int k = 0; k < i; k++)
{
jj = jj + jjj.nextInt(9);
}
return jj;
}
/**
*
* @param args
*/
public static boolean rightDate(String date)
{
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
if (date == null) return false;
if (date.length() > 10)
{
sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
}
else
{
sdf = new SimpleDateFormat("yyyy-MM-dd");
}
try
{
sdf.parse(date);
}
catch (ParseException e)
{
return false;
}
return true;
}
public static void main(String[] args)
{
//
}
/**
* 将date 按照指定 的 格式 formatStr 转换成 字符串
*
* @param date
* @param formatStr
* @return
*/
public static String date2Str(Date date, String formatStr)
{
SimpleDateFormat formatter = new SimpleDateFormat(formatStr);
String dateString = formatter.format(date);
return dateString;
}
/**
* 增加hours小時
*
* @param date
* @param hours
* @return
*/
public static Date addHours(Date date, int hours)
{
if (date == null) return null;
Calendar cal = Calendar.getInstance();
cal.setTime(date);
cal.add(Calendar.HOUR_OF_DAY, hours);// 24小时制
// cal.add(Calendar.HOUR, x);12小时制
date = cal.getTime();
return date;
}
/**
* 增加minutes分鐘
*
* @param date
* @param minutes
* @return
*/
public static Date addMinutes(Date date, int minutes)
{
if (date == null) return null;
Calendar cal = Calendar.getInstance();
cal.setTime(date);
cal.add(Calendar.MINUTE, minutes);//
date = cal.getTime();
return date;
}
/**
* 功能描述:格式化日期
*
* @param dateStr
* String 字符型日期
* @param format
* String 格式
* @return Date 日期
*/
public static Date parseDate(String dateStr, String format) {
Date date=null;
try {
DateFormat dateFormat = new SimpleDateFormat(format);
date = (Date) dateFormat.parse(dateStr);
} catch (Exception e) {
}
return date;
}
// 指定模式的时间格式
private static SimpleDateFormat getSDFormat(String pattern) {
return new SimpleDateFormat(pattern);
}
/**
* 当前日历,这里用中国时间表示
*
* @return 以当地时区表示的系统当前日历
*/
public static Calendar getCalendar() {
return Calendar.getInstance();
}
/**
* 默认日期按指定格式显示
*
* @param pattern
* 指定的格式
* @return 默认日期按指定格式显示
*/
public static String formatDate(String pattern) {
return getSDFormat(pattern).format(getCalendar().getTime());
}
/**
* 获取当前时间任意
* @return
*/
public static String get(int field) {
return String.valueOf(getCalendar().get(field));
}
/**
* 获取今日的开始时间
* @return
*/
public static Date getTodayBeginTime(){
Calendar calendar = Calendar.getInstance();
calendar.setTime(new Date());
calendar.set(Calendar.HOUR_OF_DAY, 0);
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.SECOND, 0);
Date today = calendar.getTime();
return today;
}
/**
* 获取今日的结束时间
* @return
*/
public static Date getTodayEndTime(){
Calendar calendar = Calendar.getInstance();
calendar.setTime(new Date());
calendar.set(Calendar.HOUR_OF_DAY, 23);
calendar.set(Calendar.MINUTE, 59);
calendar.set(Calendar.SECOND, 59);
Date today = calendar.getTime();
return today;
}
/**
* 获取两个时间相差的 *小时*分钟
* @param endDate
* @param nowDate
* @return
*/
public static String getDatePoorToMin(Date endDate, Date nowDate) {
// long nd = 1000 * 24 * 60 * 60;
long nh = 1000 * 60 * 60;
long nm = 1000 * 60;
// long ns = 1000;
// 获得两个时间的毫秒时间差异
long diff = endDate.getTime() - nowDate.getTime();
// 计算差多少天
// long day = diff / nd;
// 计算差多少小时
long hour = diff / nh;
// 计算差多少分钟
long min = diff % nh / nm;
// 计算差多少秒//输出结果
// long sec = diff % nd % nh % nm / ns;
return hour + "小时" + min + "分钟";
}
public static String getDatePoorToSec(Date endDate, Date nowDate) {
long nd = 1000 * 24 * 60 * 60;
long nh = 1000 * 60 * 60;
long nm = 1000 * 60;
long ss = 1000;
// long ns = 1000;
// 获得两个时间的毫秒时间差异
long diff = endDate.getTime() - nowDate.getTime();
// 计算差多少天
long day = diff / nd;
// 计算差多少小时
long hour = diff % nd / nh;
// 计算差多少分钟
long min = diff % nd % nh / nm;
long sen = diff % nd % nh % nm / ss;
// 计算差多少秒//输出结果
// long sec = diff % nd % nh % nm / ns;
return day + "天" + hour + "小时" + min + "分钟"+ sen + "秒";
}
}
\ No newline at end of file
package com.yeejoin.amos.jpush.common.entity;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.google.gson.Gson;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.google.gson.reflect.TypeToken;
/**
*
* <pre>
* JSON工具类
* </pre>
*
* @author dell
* @version $Id: JSONUtil.java, v 0.1 2017年3月28日 下午9:04:47 dell Exp $
*/
public class JSONUtil
{
private static Gson gson = null;
static
{
gson = new Gson();
}
public static synchronized Gson newInstance()
{
if (gson == null)
{
gson = new Gson();
}
return gson;
}
public static String toJson(Object obj)
{
return gson.toJson(obj);
}
public static <T> T toBean(String json, Class<T> clz)
{
return gson.fromJson(json, clz);
}
public static <T> Map<String, T> toMap(String json, Class<T> clz)
{
Map<String, JsonObject> map = gson.fromJson(json,
new TypeToken<Map<String, JsonObject>>() {
}.getType());
Map<String, T> result = new HashMap<>();
for (String key : map.keySet())
{
result.put(key, gson.fromJson(map.get(key), clz));
}
return result;
}
public static Map<String, Object> toMap(String json)
{
Map<String, Object> map = gson.fromJson(json,
new TypeToken<Map<String, Object>>() {
}.getType());
return map;
}
public static <T> List<T> toList(String json, Class<T> clz)
{
JsonArray array = new JsonParser().parse(json).getAsJsonArray();
List<T> list = new ArrayList<>();
for (final JsonElement elem : array)
{
list.add(gson.fromJson(elem, clz));
}
return list;
}
}
package com.yeejoin.amos.jpush.common.entity;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.apache.commons.lang.enums.ValuedEnum;
/**
*
* <pre>
* 操作枚举
* </pre>
*
* @author as-hanshipeng
* @version $Id: QueryOperatorEnum.java, v 0.1 2016-12-10 下午03:07:33 as-hanshipeng Exp $
*/
public final class QueryOperatorEnum extends ValuedEnum
{
private static final long serialVersionUID = -375127751242109017L;
public static final int LESS_VALUE = 1; //小于
public static final int BIGGER_VALUE = 2; //大于
public static final int EQUAL_VALUE = 3; //等于
public static final int LESS_EQUAL_VALUE = 4; // 小于等于
public static final int BIGGER_EQUAL_VALUE = 5; //大于等于
public static final int NOT_EQUAL_VALUE = 6; //不等于
public static final int IN_VALUE = 7; //包含
public static final int LIKE_VALUE = 8; //like
public static final int OR_VALUE = 9; // 或者
public static final int ORDER_VALUE = 10; // 排序
public static final int NOT_IN_VALUE = 11; // 不包含
public static final int IS_VALUE= 12; //是
public static final QueryOperatorEnum LESS = new QueryOperatorEnum("LESS",
1, "<");
public static final QueryOperatorEnum BIGGER = new QueryOperatorEnum(
"BIGGER", 2, ">");
public static final QueryOperatorEnum EQUAL = new QueryOperatorEnum(
"EQUAL", 3, "=");
public static final QueryOperatorEnum LESS_EQUAL = new QueryOperatorEnum(
"LESS_EQUAL", 4, "<=");
public static final QueryOperatorEnum BIGGER_EQUAL = new QueryOperatorEnum(
"BIGGER_EQUAL", 5, ">=");
public static final QueryOperatorEnum NOT_EQUAL = new QueryOperatorEnum(
"NOT_EQUAL", 6, "<>");
public static final QueryOperatorEnum IN = new QueryOperatorEnum("IN", 7,
"IN");
public static final QueryOperatorEnum LIKE = new QueryOperatorEnum("LIKE",
8, "LIKE");
public static final QueryOperatorEnum OR = new QueryOperatorEnum("OR", 9,
"OR");
public static final QueryOperatorEnum ORDER_BY = new QueryOperatorEnum(
"ORDER BY", 10, "ORDER BY");
public static final QueryOperatorEnum NOT_IN = new QueryOperatorEnum(
"NOT IN", 11, "NOT IN");
public static final QueryOperatorEnum IS = new QueryOperatorEnum(
"IS", 12, "IS");
public String condition;
public String getCondition() {
return condition;
}
public void setCondition(String condition) {
this.condition = condition;
}
protected QueryOperatorEnum(String arg0, int arg1,String condition)
{
super(arg0, arg1);
this.condition = condition;
}
public static QueryOperatorEnum getEnum(String name)
{
try{
return ((QueryOperatorEnum)getEnum(QueryOperatorEnum.class, name));
}catch(Exception ex){return null;}
}
public static QueryOperatorEnum getEnum(int name)
{
try{
return ((QueryOperatorEnum)getEnum(QueryOperatorEnum.class, name));
}catch(Exception ex){return null;}
}
public static Map getMap()
{
try{
return getEnumMap(QueryOperatorEnum.class);
}catch(Exception ex){return null;}
}
public static List getList()
{
try{
return getEnumList(QueryOperatorEnum.class);
}catch(Exception ex){return null;}
}
public static Iterator iterator()
{
try{
return iterator(QueryOperatorEnum.class);
}catch(Exception ex){return null;}
}
}
package com.yeejoin.amos.jpush.common.entity;
import java.math.BigDecimal;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class StringUtil {
private static Pattern NOT_ZERO_AT_THE_END = Pattern.compile("[1-9]+\\d*[1-9]+");
private static Pattern numericPattern = Pattern.compile("-?[0-9]+\\.?[0-9]*");
/**
* 鍒ゆ柇瀵硅薄鏄惁涓虹┖
*
* @param str
* @return
*/
public static boolean isNotEmpty(Object str) {
boolean flag = true;
if (str != null && !str.equals("")) {
if (str.toString().length() > 0) {
flag = true;
}
} else {
flag = false;
}
return flag;
}
/***************************************************************************
* repeat - 閫氳繃婧愬瓧绗︿覆閲嶅鐢熸垚N娆$粍鎴愭柊鐨勫瓧绗︿覆銆�
*
* @param src
* - 婧愬瓧绗︿覆 渚嬪: 绌烘牸(" "), 鏄熷彿("*"), "娴欐睙" 绛夌瓑...
* @param num
* - 閲嶅鐢熸垚娆℃暟
* @return 杩斿洖宸茬敓鎴愮殑閲嶅瀛楃涓�
* @version 1.0 (2006.10.10) Wilson Lin
**************************************************************************/
public static String repeat(String src, int num) {
StringBuffer s = new StringBuffer();
for (int i = 0; i < num; i++)
s.append(src);
return s.toString();
}
/**
* 鍒ゆ柇鏄惁鏁板瓧琛ㄧず
*
* @param
* @return 鏄惁鏁板瓧鐨勬爣蹇�
*/
public static boolean isNumeric(String str) {
// 璇ユ鍒欒〃杈惧紡鍙互鍖归厤鎵�鏈夌殑鏁板瓧 鍖呮嫭璐熸暟
String bigStr;
try {
bigStr = new BigDecimal(str).toString();
} catch (Exception e) {
return false;//寮傚父 璇存槑鍖呭惈闈炴暟瀛椼��
}
Matcher isNum = numericPattern.matcher(bigStr); // matcher鏄叏鍖归厤
if (!isNum.matches()) {
return false;
}
return true;
}
public static int toInt(String s) {
if (s != null && !"".equals(s.trim())) {
try {
return Integer.parseInt(s);
} catch (Exception e) {
return 0;
}
}
return 0;
}
/**
* 鎴彇鍓嶅悗閮戒笉鏄�0鐨勬暟瀛楀瓧绗︿覆
* <p>
* 12010102 => 12010102
* 12010100 => 120101
* ab1201100b => 12011
*
* @param str
* @return
*/
public static String delEndZero(String str) {
Matcher mat = NOT_ZERO_AT_THE_END.matcher(str);
boolean rs = mat.find();
if (rs) {
return mat.group(0);
}
return null;
}
/**
* <pre>
* 绉婚櫎瀛楃涓插悗闈㈢殑0
* </pre>
*
* @param s
* @return
*/
public static String removeSufixZero(String s) {
if (s == null) {
return "";
}
while (s.endsWith("0")) {
if (s.equals("0")) {
s = "";
break;
}
s = s.substring(0, s.length() - 1);
}
return s;
}
public static String notNull(String s){
return s!=null?s:"";
}
public static boolean isStartWithDigit(String str){
char firstCharacter = str.charAt(0);
return Character.isDigit(firstCharacter);
}
public static void main(String[] args){
System.out.println(isStartWithDigit("a3730e937-17e5-4720-8f69-99e8d87d2ee7"));
}
}
package com.yeejoin.amos.jpush.common.entity;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
*
* <pre>
* 鐢ㄦ埛淇℃伅
* </pre>
*
* @author amos
* @version $Id: UserModel.java, v 0.1 2019骞�7鏈�31鏃� 涓嬪崍8:07:53 amos Exp $
*/
public class UserModel implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 鐗╃悊涓婚敭
*/
protected Long sequenceNbr;
/**
* 鍒涘缓鏃ユ湡
*/
protected Date recDate;
/**
* 鍒涘缓浜�
*/
protected String recUserId;
/**
* 绯荤粺鐢ㄦ埛ID
*/
private String userId;
private String agencyCode;
/**
* 鏁版嵁閿佸畾鐘舵��: N :闈為攣瀹� / Y: 閿佸畾
*/
private String lockStatus;
/**
* 鏁版嵁閿佸畾鏃堕棿
*/
private Date lockDate;
/**
* 閿佸畾浜篒D澶栭敭
*/
private String lockUserId;
/**
* 鐪熷疄濮撳悕
*/
private String realName;
/**
* 鎵嬫満鍙�
*/
private String mobile;
/**
* 閭
*/
private String email;
/**
* 鐧婚檰鐢ㄦ埛鍚�
*/
private String userName;
/**
* 鍒涘缓鏃堕棿
*/
private Date createTime;
/**
* 鍥哄畾鐢佃瘽
*/
private String landlinePhone;
private String password;
private String rePassword;
private String originalPassword;
private String verifyCode;
private String originalMobile;
private List<Map<String, Object>> companys;//鍗曚綅闆嗗悎
private Map<Long, List<Map<String, Object>>> companyDepartments;//key涓哄崟浣峣d锛寁alue涓洪儴闂ㄩ泦鍚�
private Map<Long, List<Map<String, Object>>> orgRoles;//key涓虹粍缁囨満鏋刬d锛堝崟浣�/閮ㄩ棬锛夛紝value涓鸿鑹查泦鍚�
public String getOriginalPassword() {
return originalPassword;
}
public void setOriginalPassword(String originalPassword) {
this.originalPassword = originalPassword;
}
public String getOriginalMobile() {
return originalMobile;
}
public void setOriginalMobile(String originalMobile) {
this.originalMobile = originalMobile;
}
public String getVerifyCode() {
return verifyCode;
}
public void setVerifyCode(String verifyCode) {
this.verifyCode = verifyCode;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getRePassword() {
return rePassword;
}
public void setRePassword(String rePassword) {
this.rePassword = rePassword;
}
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
public String getAgencyCode() {
return agencyCode;
}
public void setAgencyCode(String agencyCode) {
this.agencyCode = agencyCode;
}
public String getLockStatus() {
return lockStatus;
}
public void setLockStatus(String lockStatus) {
this.lockStatus = lockStatus;
}
public Date getLockDate() {
return lockDate;
}
public void setLockDate(Date lockDate) {
this.lockDate = lockDate;
}
public String getLockUserId() {
return lockUserId;
}
public void setLockUserId(String lockUserId) {
this.lockUserId = lockUserId;
}
public String getRealName() {
return realName;
}
public void setRealName(String realName) {
this.realName = realName;
}
public String getMobile() {
return mobile;
}
public void setMobile(String mobile) {
this.mobile = mobile;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public String getLandlinePhone() {
return landlinePhone;
}
public void setLandlinePhone(String landlinePhone) {
this.landlinePhone = landlinePhone;
}
public List<Map<String, Object>> getCompanys()
{
return companys;
}
public void setCompanys(List<Map<String, Object>> companys)
{
this.companys = companys;
}
public Map<Long, List<Map<String, Object>>> getCompanyDepartments()
{
return companyDepartments;
}
public void setCompanyDepartments(
Map<Long, List<Map<String, Object>>> companyDepartments)
{
this.companyDepartments = companyDepartments;
}
public Map<Long, List<Map<String, Object>>> getOrgRoles()
{
return orgRoles;
}
public void setOrgRoles(Map<Long, List<Map<String, Object>>> orgRoles)
{
this.orgRoles = orgRoles;
}
public Long getSequenceNbr()
{
return sequenceNbr;
}
public void setSequenceNbr(Long sequenceNbr)
{
this.sequenceNbr = sequenceNbr;
}
public Date getRecDate()
{
return recDate;
}
public void setRecDate(Date recDate)
{
this.recDate = recDate;
}
public String getRecUserId()
{
return recUserId;
}
public void setRecUserId(String recUserId)
{
this.recUserId = recUserId;
}
public String getEmail()
{
return email;
}
public void setEmail(String email)
{
this.email = email;
}
}
package com.yeejoin.amos.jpush.common.enums;
/**
* JPush 推送类型
* @author maoying
*
*/
public enum JPushTypeEnum {
ALL("广播","1"),
TAG("标签","2" ),
ALIAS("别名", "3");
/**
* 名称,描述
*/
private String name;
/**
* 编码
*/
private String code;
private JPushTypeEnum(String name,String code){
this.name = name;
this.code = code;
}
public static JPushTypeEnum getEnum(String code) {
JPushTypeEnum jPushTypeEnum = null;
for(JPushTypeEnum type: JPushTypeEnum.values()) {
if (type.getCode().equals(code)) {
jPushTypeEnum = type;
break;
}
}
return jPushTypeEnum;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
}
package com.yeejoin.amos.jpush.common.vo;
/**
* 用于请求和返回数据使用
*
*/
public class BaseParam {
Long id;
/**
* 页码,默认值1
*/
protected Integer current = 1;
/**
* 每页记录数
*/
private Integer pageSize;
/**
* 设备名称
*/
private String name;
/**
* 是否叶子节点,默认true
*/
private Boolean isLeaf = true;
/**
* 从第几条记录开始查
* @return
*/
public Integer getStartPage(){
if(current!=null && current==0) {
return 0;
}
return (current - 1) * pageSize;
}
public Integer getCurrent() {
return current;
}
public void setCurrent(Integer current) {
this.current = current;
}
public void setPageNum(Integer current) {
this.current = current;
}
public Integer getPageSize() {
if(current!=null && current==0) {
return Integer.MAX_VALUE;
}
return pageSize;
}
public void setPageSize(Integer pageSize) {
this.pageSize = pageSize;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Boolean getIsLeaf() {
return isLeaf;
}
public void setIsLeaf(Boolean isLeaf) {
this.isLeaf = isLeaf;
}
}
package com.yeejoin.amos.jpush.common.vo;
import com.google.common.collect.Lists;
import java.util.List;
import java.util.Map;
public class DepartmentUserTreeAppVo {
private String name;
private String id;
private String type;
private Map<String, String> object;
private List<DepartmentUserTreeAppVo> children = Lists.newArrayList();
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public Map<String, String> getObject() {
return object;
}
public void setObject(Map<String, String> object) {
this.object = object;
}
public List<DepartmentUserTreeAppVo> getChildren() {
return children;
}
public void setChildren(List<DepartmentUserTreeAppVo> children) {
this.children = children;
}
}
package com.yeejoin.amos.jpush.common.vo;
import com.google.common.collect.Lists;
import java.util.List;
public class DepartmentUserTreeWebVo {
private String key;
private String label;
private String title;
private String type;
private String value;
private List<DepartmentUserTreeWebVo> children = Lists.newArrayList();
private List<DepartmentUserTreeWebVo> userModelList = Lists.newArrayList();
public List<DepartmentUserTreeWebVo> getUserModelList() {
return userModelList;
}
public void setUserModelList(List<DepartmentUserTreeWebVo> userModelList) {
this.userModelList = userModelList;
}
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
public List<DepartmentUserTreeWebVo> getChildren() {
return children;
}
public void setChildren(List<DepartmentUserTreeWebVo> children) {
this.children = children;
}
}
\ No newline at end of file
package com.yeejoin.amos.jpush.common.vo;
/**
* @Author: xinglei
* @Description: TODO()
* @Date: 2019/11/27 17:31
*/
public class MonitorParam extends BaseParam {
/**
* 父ID
*/
private Long parentId;
public Long getParentId() {
return parentId;
}
public void setParentId(Long parentId) {
this.parentId = parentId;
}
}
package com.yeejoin.amos.jpush.util;
import com.yeejoin.amos.jpush.common.entity.CommonResponse;
import com.yeejoin.amos.jpush.common.entity.Constants;
public class CommonResponseUtil
{
public static CommonResponse success()
{
CommonResponse response = new CommonResponse();
response.setResult(Constants.RESULT_SUCCESS);
return response;
}
public static CommonResponse success(Object obj)
{
CommonResponse response = new CommonResponse();
response.setResult(Constants.RESULT_SUCCESS);
response.setDataList(obj);
return response;
}
public static CommonResponse success(Object obj, String message)
{
CommonResponse response = new CommonResponse();
response.setResult(Constants.RESULT_SUCCESS);
response.setDataList(obj);
response.setMessage(message);
return response;
}
public static CommonResponse failure()
{
CommonResponse response = new CommonResponse();
response.setResult(Constants.RESULT_FAILURE);
return response;
}
public static CommonResponse failure(String message)
{
CommonResponse response = new CommonResponse();
response.setResult(Constants.RESULT_FAILURE);
response.setMessage(message);
return response;
}
public static CommonResponse failure(Object obj, String message)
{
CommonResponse response = new CommonResponse();
response.setResult(Constants.RESULT_FAILURE);
response.setDataList(obj);
response.setMessage(message);
return response;
}
}
package com.yeejoin.amos.jpush.util;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.ParsePosition;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.List;
import java.util.Locale;
import java.util.Random;
import org.apache.commons.lang.StringUtils;
/**
* 日期工具类
*
*/
public class DateUtil {
// 默认日期格式
public static final String DATE_DEFAULT_FORMAT = "yyyy-MM-dd";
// 默认日期格式
public static final String DATE_YEARANDMONTH_FORMAT = "yyyy-MM";
// 默认时间格式
public static final String DATETIME_DEFAULT_FORMAT = "yyyy-MM-dd HH:mm:ss";
public static final String TIME_DEFAULT_FORMAT = "HH:mm:ss";
// 日期格式化
private static DateFormat dateFormat = null;
// 时间格式化
private static DateFormat dateTimeFormat = null;
// 年月格式化
private static DateFormat dateYearAndMonthFormat = null;
private static DateFormat timeFormat = null;
private static Calendar gregorianCalendar = null;
static {
dateFormat = new SimpleDateFormat(DATE_DEFAULT_FORMAT);
dateYearAndMonthFormat = new SimpleDateFormat(DATE_YEARANDMONTH_FORMAT);
dateTimeFormat = new SimpleDateFormat(DATETIME_DEFAULT_FORMAT);
timeFormat = new SimpleDateFormat(TIME_DEFAULT_FORMAT);
gregorianCalendar = new GregorianCalendar();
}
/**
* 日期格式化yyyy-MM-dd
*
* @param date
* @return
*/
public static Date formatDate(String date, String format) {
try {
return new SimpleDateFormat(format).parse(date);
} catch (ParseException e) {
e.printStackTrace();
}
return null;
}
/**
* 日期格式化yyyy-MM-dd
*
* @param date
* @return
*/
public static String getDateFormat(Date date) {
return dateFormat.format(date);
}
/**
* 日期格式化yyyy-MM
*
* @param date
* @return
*/
public static String getDateYearAndMonthFormat(Date date) {
return dateYearAndMonthFormat.format(date);
}
/**
* 日期格式化yyyy-MM-dd HH:mm:ss
*
* @param date
* @return
*/
public static String getDateTimeFormat(Date date) {
return dateTimeFormat.format(date);
}
/**
* 时间格式化
*
* @param date
* @return HH:mm:ss
*/
public static String getTimeFormat(Date date) {
return timeFormat.format(date);
}
/**
* 日期格式化
*
* @param date
* @param 格式类型
* @return
*/
public static String getDateFormat(Date date, String formatStr) {
if (StringUtils.isNotBlank(formatStr)) {
return new SimpleDateFormat(formatStr).format(date);
}
return null;
}
/**
* 日期格式化
*
* @param date
* @return
*/
public static Date getDateFormat(String date) {
try {
return dateFormat.parse(date);
} catch (ParseException e) {
e.printStackTrace();
}
return null;
}
/**
* 时间格式化
*
* @param date
* @return
*/
public static Date getDateTimeFormat(String date) {
try {
return dateTimeFormat.parse(date);
} catch (ParseException e) {
e.printStackTrace();
}
return null;
}
/**
* 获取当前日期(yyyy-MM-dd)
*
* @param date
* @return
*/
public static Date getNowDate() {
return DateUtil.getDateFormat(dateFormat.format(new Date()));
}
/**
* 获取当前日期星期一日期
*
* @return date
*/
public static Date getFirstDayOfWeek() {
gregorianCalendar.setFirstDayOfWeek(Calendar.MONDAY);
gregorianCalendar.setTime(new Date());
gregorianCalendar.set(Calendar.DAY_OF_WEEK, gregorianCalendar.getFirstDayOfWeek()); // Monday
return gregorianCalendar.getTime();
}
/**
* 获取当前日期星期日日期
*
* @return date
*/
public static Date getLastDayOfWeek() {
gregorianCalendar.setFirstDayOfWeek(Calendar.MONDAY);
gregorianCalendar.setTime(new Date());
gregorianCalendar.set(Calendar.DAY_OF_WEEK, gregorianCalendar.getFirstDayOfWeek() + 6); // Monday
return gregorianCalendar.getTime();
}
/**
* 获取日期星期一日期
*
* @param 指定日期
* @return date
*/
public static Date getFirstDayOfWeek(Date date) {
if (date == null) {
return null;
}
gregorianCalendar.setFirstDayOfWeek(Calendar.MONDAY);
gregorianCalendar.setTime(date);
gregorianCalendar.set(Calendar.DAY_OF_WEEK, gregorianCalendar.getFirstDayOfWeek()); // Monday
return gregorianCalendar.getTime();
}
/**
* 获取日期星期一日期
*
* @param 指定日期
* @return date
*/
public static Date getLastDayOfWeek(Date date) {
if (date == null) {
return null;
}
gregorianCalendar.setFirstDayOfWeek(Calendar.MONDAY);
gregorianCalendar.setTime(date);
gregorianCalendar.set(Calendar.DAY_OF_WEEK, gregorianCalendar.getFirstDayOfWeek() + 6); // Monday
return gregorianCalendar.getTime();
}
/**
* 获取当前月的第一天
*
* @return date
*/
public static Date getFirstDayOfMonth() {
gregorianCalendar.setTime(new Date());
gregorianCalendar.set(Calendar.DAY_OF_MONTH, 1);
return gregorianCalendar.getTime();
}
/**
* 获取当前月的最后一天
*
* @return
*/
public static Date getLastDayOfMonth() {
gregorianCalendar.setTime(new Date());
gregorianCalendar.set(Calendar.DAY_OF_MONTH, 1);
gregorianCalendar.add(Calendar.MONTH, 1);
gregorianCalendar.add(Calendar.DAY_OF_MONTH, -1);
return gregorianCalendar.getTime();
}
/**
* 获取指定月的第一天
*
* @param date
* @return
*/
public static Date getFirstDayOfMonth(Date date) {
gregorianCalendar.setTime(date);
gregorianCalendar.set(Calendar.DAY_OF_MONTH, 1);
return gregorianCalendar.getTime();
}
/**
* 获取指定月的最后一天
*
* @param date
* @return
*/
public static Date getLastDayOfMonth(Date date) {
gregorianCalendar.setTime(date);
gregorianCalendar.set(Calendar.DAY_OF_MONTH, 1);
gregorianCalendar.add(Calendar.MONTH, 1);
gregorianCalendar.add(Calendar.DAY_OF_MONTH, -1);
return gregorianCalendar.getTime();
}
/**
* 获取日期前一天
*
* @param date
* @return
*/
public static Date getDayBefore(Date date) {
gregorianCalendar.setTime(date);
int day = gregorianCalendar.get(Calendar.DATE);
gregorianCalendar.set(Calendar.DATE, day - 1);
return gregorianCalendar.getTime();
}
/**
* 获取日期后一天
*
* @param date
* @return
*/
public static Date getDayAfter(Date date) {
gregorianCalendar.setTime(date);
int day = gregorianCalendar.get(Calendar.DATE);
gregorianCalendar.set(Calendar.DATE, day + 1);
return gregorianCalendar.getTime();
}
/**
* 获取当前年
*
* @return
*/
public static int getNowYear() {
Calendar d = Calendar.getInstance();
return d.get(Calendar.YEAR);
}
/**
* 获取当前月份
*
* @return
*/
public static int getNowMonth() {
Calendar d = Calendar.getInstance();
return d.get(Calendar.MONTH) + 1;
}
/**
* 获取date的年
*
* @return
*/
public static int getDateYear(Date date) {
Calendar d = Calendar.getInstance();
d.setTime(date);
return d.get(Calendar.YEAR);
}
/**
* 获取date的月份
*
* @return
*/
public static int getDateMonth(Date date) {
Calendar d = Calendar.getInstance();
d.setTime(date);
return d.get(Calendar.MONTH) + 1;
}
/**
* 获取当月天数
*
* @return
*/
public static int getNowMonthDay() {
Calendar d = Calendar.getInstance();
return d.getActualMaximum(Calendar.DATE);
}
/**
* 获取时间段的每一天
*
* @param 开始日期
* @param 结算日期
* @return 日期列表
*/
public static List<Date> getEveryDay(Date startDate, Date endDate) {
if (startDate == null || endDate == null) {
return null;
}
// 格式化日期(yy-MM-dd)
startDate = DateUtil.getDateFormat(DateUtil.getDateFormat(startDate));
endDate = DateUtil.getDateFormat(DateUtil.getDateFormat(endDate));
List<Date> dates = new ArrayList<Date>();
gregorianCalendar.setTime(startDate);
dates.add(gregorianCalendar.getTime());
while (gregorianCalendar.getTime().compareTo(endDate) < 0) {
// 加1天
gregorianCalendar.add(Calendar.DAY_OF_MONTH, 1);
dates.add(gregorianCalendar.getTime());
}
return dates;
}
/**
* 获取提前多少个月
*
* @param monty
* @return
*/
public static Date getFirstMonth(int monty) {
Calendar c = Calendar.getInstance();
c.add(Calendar.MONTH, -monty);
return c.getTime();
}
/**
* 得到现在时间
*
* @return
*/
public static Date getNow()
{
Date currentTime = new Date();
return currentTime;
}
/**
* 获取现在时间
*
* @return 返回时间类型 yyyy-MM-dd HH:mm:ss
*/
public static String getNowDateLongForHandset()
{
Date currentTime = new Date();
SimpleDateFormat formatter = new SimpleDateFormat("yyyy:MM:dd-HH:mm:ss");
String dateString = formatter.format(currentTime);
return dateString;
}
public static String getDateLongForHandset(java.util.Date dateDate){
SimpleDateFormat formatter = new SimpleDateFormat("yyyy:MM:dd HH:mm:ss");
String dateString = formatter.format(dateDate);
return dateString;
}
public static String getDateStr(String formatterstr) {
Date currentTime = new Date();
SimpleDateFormat formatter = new SimpleDateFormat(formatterstr);
String dateString = formatter.format(currentTime);
return dateString;
}
/**
* 获取现在时间
*
* @return 返回时间类型 yyyy-MM-dd HH:mm:ss
*/
public static Date getNowDateLong()
{
Date currentTime = new Date();
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String dateString = formatter.format(currentTime);
ParsePosition pos = new ParsePosition(0);
Date currentTime_2 = formatter.parse(dateString, pos);
return currentTime_2;
}
/**
* 获取现在时间
*
* @return返回短时间格式 yyyy-MM-dd
*/
public static Date getNowDateShort()
{
Date currentTime = new Date();
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
String dateString = formatter.format(currentTime);
ParsePosition pos = new ParsePosition(8);
Date currentTime_2 = formatter.parse(dateString, pos);
return currentTime_2;
}
/**
* 获取现在时间字符串
*
* @return返回字符串格式 yyyy-MM-dd HH:mm:ss
*/
public static String getNowStrLong()
{
Date currentTime = new Date();
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String dateString = formatter.format(currentTime);
return dateString;
}
/**
* 获取现在时间字符串
*
* @return 返回短时间字符串格式yyyy-MM-dd
*/
public static String getNowStrShort()
{
Date currentTime = new Date();
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
String dateString = formatter.format(currentTime);
return dateString;
}
/**
* 获取时间 小时:分;秒 HH:mm:ss
*
* @return
*/
public static String getNowHHMMSS()
{
SimpleDateFormat formatter = new SimpleDateFormat("HH:mm:ss");
Date currentTime = new Date();
String dateString = formatter.format(currentTime);
return dateString;
}
/**
*
* <pre>
*
* </pre>
*
* @param strDate
* @param dateFormat
* @return
*/
public static Date str2Date(String strDate, String dateFormat)
{
SimpleDateFormat formatter = new SimpleDateFormat(dateFormat);
ParsePosition pos = new ParsePosition(0);
Date strtodate = formatter.parse(strDate, pos);
return strtodate;
}
/**
*
* <pre>
* e.g localDateStr ="2017-03-30T06:28:12.803Z";
* </pre>
*
* @param strDate
* @param dateFormat
* @return
*/
public static Date localDateStr2Date(String localDateStr)
{
LocalDateTime localDate = LocalDateTime.parse(localDateStr,DateTimeFormatter.ISO_ZONED_DATE_TIME);
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String formatLocalDate2Str = localDate.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
ParsePosition pos = new ParsePosition(0);
Date strtodate = formatter.parse(formatLocalDate2Str, pos);
return strtodate;
}
/**
* 将长时间格式字符串转换为时间 yyyy-MM-dd HH:mm:ss
*
* @param strDate
* @return
*/
public static Date longStr2Date(String strDate)
{
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
ParsePosition pos = new ParsePosition(0);
Date strtodate = formatter.parse(strDate, pos);
return strtodate;
}
/**
* 将长时间格式字符串转换为时间 yyyy-MM-dd HH:mm
*
* @param strDate
* @return
*/
public static Date longStr3Date(String strDate)
{
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm");
ParsePosition pos = new ParsePosition(0);
Date strtodate = formatter.parse(strDate, pos);
return strtodate;
}
/**
* 将长时间格式字符串转换为long型数据
*
* @param strDate
* @return
*/
public static Long longStr2Long(String strDate)
{
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
ParsePosition pos = new ParsePosition(0);
Date strtodate = formatter.parse(strDate, pos);
return strtodate.getTime();
}
/**
* 将长时间格式时间转换为字符串 yyyy-MM-dd HH:mm:ss
*
* @param dateDate
* @return
*/
public static String date2LongStr(Date dateDate)
{
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String dateString = formatter.format(dateDate);
return dateString;
}
/**
* 将短时间格式时间转换为字符串 yyyy-MM-dd
*
* @param dateDate
* @param k
* @return
*/
public static String date2ShortStr(java.util.Date dateDate)
{
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
String dateString = formatter.format(dateDate);
return dateString;
}
/**
*
* <pre>
*
* </pre>
*
* @param l
* @param dateFormat
* @return
*/
public static String long2Str(long l, String dateFormat)
{
if (l == 0)
{
return "";
}
try
{
Date dateDate = new Date(l);
SimpleDateFormat formatter = new SimpleDateFormat(dateFormat);
String dateString = formatter.format(dateDate);
return dateString;
}
catch (Exception e)
{
return "";
}
}
/**
* 把LONG数据类型转换为字符串
*
* @param l
* @return
*/
public static String long2LongStr(long l)
{
if (l == 0)
{
return "";
}
try
{
Date dateDate = new Date(l);
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String dateString = formatter.format(dateDate);
return dateString;
}
catch (Exception e)
{
return "";
}
}
/**
* 把LONG数据类型转换为字符串
*
* <pre>
*
* </pre>
*
* @param l
* @return
*/
public static String long2ShortStr(long l)
{
if (l == 0)
{
return "";
}
try
{
Date dateDate = new Date(l);
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
String dateString = formatter.format(dateDate);
return dateString;
}
catch (Exception e)
{
return "";
}
}
/**
* 将短时间格式字符串转换为时间 yyyy-MM-dd
*
* @param strDate
* @return
*/
public static Date shortStr2ShortDate(String strDate)
{
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
ParsePosition pos = new ParsePosition(0);
Date strtodate = formatter.parse(strDate, pos);
return strtodate;
}
/**
* 提取一个月中的最后一天
*
* @param day
* @return
*/
public static Date getLastDateOfThisMonth(long day)
{
Date date = new Date();
long date_3_hm = date.getTime() - 3600000 * 34 * day;
Date date_3_hm_date = new Date(date_3_hm);
return date_3_hm_date;
}
/**
* 获取日期中的年
*
* @param date
* @return
*/
public static String getYear(Date date) {
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String dateString = formatter.format(date);
String year;
year = dateString.substring(0, 4);
return year;
}
/**
* 得到现在小时
*/
public static String getHour()
{
Date currentTime = new Date();
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String dateString = formatter.format(currentTime);
String hour;
hour = dateString.substring(11, 13);
return hour;
}
/**
* 得到现在分钟
*
* @return
*/
public static String getMinute()
{
Date currentTime = new Date();
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String dateString = formatter.format(currentTime);
String min;
min = dateString.substring(14, 16);
return min;
}
/**
* 根据用户传入的时间表示格式,返回当前时间的格式 如果是yyyyMMdd,注意字母y不能大写。
*
* @param sformat
* yyyyMMddhhmmss
* @return
*/
public static String parseDate(String sformat)
{
Date currentTime = new Date();
SimpleDateFormat formatter = new SimpleDateFormat(sformat);
String dateString = formatter.format(currentTime);
return dateString;
}
/**
* 二个小时时间间的差值,必须保证二个时间都是"HH:MM"的格式,返回字符型的分钟
*/
public static String getTwoHour(String st1, String st2)
{
String[] kk = null;
String[] jj = null;
kk = st1.split(":");
jj = st2.split(":");
if (Integer.parseInt(kk[0]) < Integer.parseInt(jj[0])) return "0";
else
{
double y = Double.parseDouble(kk[0]) + Double.parseDouble(kk[1]) / 60;
double u = Double.parseDouble(jj[0]) + Double.parseDouble(jj[1]) / 60;
if ((y - u) > 0) return y - u + "";
else
return "0";
}
}
/**
* 得到二个日期间的间隔天数
*/
public static String getTwoDay(String sj1, String sj2)
{
SimpleDateFormat myFormatter = new SimpleDateFormat("yyyy-MM-dd");
long day = 0;
try
{
java.util.Date date = myFormatter.parse(sj1);
java.util.Date mydate = myFormatter.parse(sj2);
day = (date.getTime() - mydate.getTime()) / (24 * 60 * 60 * 1000);
}
catch (Exception e)
{
return "";
}
return day + "";
}
/**
* 时间前推或后推分钟,其中JJ表示分钟.
*/
public static String getPreTime(String sj1, String jj)
{
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String mydate1 = "";
try
{
Date date1 = format.parse(sj1);
long Time = (date1.getTime() / 1000) + Integer.parseInt(jj) * 60;
date1.setTime(Time * 1000);
mydate1 = format.format(date1);
}
catch (Exception e)
{
mydate1 = "";
}
return mydate1;
}
/**
* 得到一个时间延后或前移几天的时间,nowdate为时间,delay为前移或后延的天数
*/
public static String getNextDay(String nowdate, String delay)
{
try
{
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
String mdate = "";
Date d = shortStr2ShortDate(nowdate);
long myTime = (d.getTime() / 1000) + Integer.parseInt(delay) * 24 * 60 * 60;
d.setTime(myTime * 1000);
mdate = format.format(d);
return mdate;
}
catch (Exception e)
{
return "";
}
}
/**
* 判断是否润年
*
* @param ddate
* @return
*/
public static boolean isLeapYear(String ddate)
{
/**
* 详细设计: 1.被400整除是闰年,否则: 2.不能被4整除则不是闰年 3.能被4整除同时不能被100整除则是闰年
* 3.能被4整除同时能被100整除则不是闰年
*/
Date d = shortStr2ShortDate(ddate);
GregorianCalendar gc = (GregorianCalendar) Calendar.getInstance();
gc.setTime(d);
int year = gc.get(Calendar.YEAR);
if ((year % 400) == 0) return true;
else if ((year % 4) == 0)
{
if ((year % 100) == 0) return false;
else
return true;
}
else
return false;
}
/**
* 返回美国时间格式 26 Apr 2006
*
* @param str
* @return
*/
public static String getEDate(String str)
{
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
ParsePosition pos = new ParsePosition(0);
Date strtodate = formatter.parse(str, pos);
String j = strtodate.toString();
String[] k = j.split(" ");
return k[2] + k[1].toUpperCase() + k[5].substring(2, 4);
}
/**
* 获取一个月的最后一天
*
* @param dat
* @return
*/
public static String getEndDateOfMonth(String dat)
{// yyyy-MM-dd
String str = dat.substring(0, 8);
String month = dat.substring(5, 7);
int mon = Integer.parseInt(month);
if (mon == 1 || mon == 3 || mon == 5 || mon == 7 || mon == 8 || mon == 10 || mon == 12)
{
str += "31";
}
else if (mon == 4 || mon == 6 || mon == 9 || mon == 11)
{
str += "30";
}
else
{
if (isLeapYear(dat))
{
str += "29";
}
else
{
str += "28";
}
}
return str;
}
/**
* 判断二个时间是否在同一个周
*
* @param date1
* @param date2
* @return
*/
public static boolean isSameWeekDates(Date date1, Date date2)
{
Calendar cal1 = Calendar.getInstance();
Calendar cal2 = Calendar.getInstance();
cal1.setTime(date1);
cal2.setTime(date2);
int subYear = cal1.get(Calendar.YEAR) - cal2.get(Calendar.YEAR);
if (0 == subYear)
{
if (cal1.get(Calendar.WEEK_OF_YEAR) == cal2.get(Calendar.WEEK_OF_YEAR)) return true;
}
else if (1 == subYear && 11 == cal2.get(Calendar.MONTH))
{
// 如果12月的最后一周横跨来年第一周的话则最后一周即算做来年的第一周
if (cal1.get(Calendar.WEEK_OF_YEAR) == cal2.get(Calendar.WEEK_OF_YEAR)) return true;
}
else if (-1 == subYear && 11 == cal1.get(Calendar.MONTH))
{
if (cal1.get(Calendar.WEEK_OF_YEAR) == cal2.get(Calendar.WEEK_OF_YEAR)) return true;
}
return false;
}
/**
* 产生周序列,即得到当前时间所在的年度是第几周
*
* @return
*/
public static String getSeqWeek()
{
Calendar c = Calendar.getInstance(Locale.CHINA);
String week = Integer.toString(c.get(Calendar.WEEK_OF_YEAR));
if (week.length() == 1) week = "0" + week;
String year = Integer.toString(c.get(Calendar.YEAR));
return year + week;
}
/**
* 获得一个日期所在的周的星期几的日期,如要找出2002年2月3日所在周的星期一是几号
*
* @param sdate
* @param num
* @return
*/
public static String getWeek(String sdate, String num)
{
// 再转换为时间
Date dd = shortStr2ShortDate(sdate);
Calendar c = Calendar.getInstance();
c.setTime(dd);
if (num.equals("1")) // 返回星期一所在的日期
c.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
else if (num.equals("2")) // 返回星期二所在的日期
c.set(Calendar.DAY_OF_WEEK, Calendar.TUESDAY);
else if (num.equals("3")) // 返回星期三所在的日期
c.set(Calendar.DAY_OF_WEEK, Calendar.WEDNESDAY);
else if (num.equals("4")) // 返回星期四所在的日期
c.set(Calendar.DAY_OF_WEEK, Calendar.THURSDAY);
else if (num.equals("5")) // 返回星期五所在的日期
c.set(Calendar.DAY_OF_WEEK, Calendar.FRIDAY);
else if (num.equals("6")) // 返回星期六所在的日期
c.set(Calendar.DAY_OF_WEEK, Calendar.SATURDAY);
else if (num.equals("0")) // 返回星期日所在的日期
c.set(Calendar.DAY_OF_WEEK, Calendar.SUNDAY);
return new SimpleDateFormat("yyyy-MM-dd").format(c.getTime());
}
/**
* 根据一个日期,返回是星期几的字符串
*
* @param sdate
* @return
*/
public static String getWeek(String sdate)
{
// 再转换为时间
Date date = shortStr2ShortDate(sdate);
Calendar c = Calendar.getInstance();
c.setTime(date);
// int hour=c.get(Calendar.DAY_OF_WEEK);
// hour中存的就是星期几了,其范围 1~7
// 1=星期日 7=星期六,其他类推
return new SimpleDateFormat("EEEE").format(c.getTime());
}
public static String getWeekStr(String sdate)
{
String str = "";
str = getWeek(sdate);
if ("1".equals(str))
{
str = "星期日";
}
else if ("2".equals(str))
{
str = "星期一";
}
else if ("3".equals(str))
{
str = "星期二";
}
else if ("4".equals(str))
{
str = "星期三";
}
else if ("5".equals(str))
{
str = "星期四";
}
else if ("6".equals(str))
{
str = "星期五";
}
else if ("7".equals(str))
{
str = "星期六";
}
return str;
}
/**
* 两个时间之间的天数
*
* @param date1
* @param date2
* @return
*/
public static long getDays(String date1, String date2)
{
if (date1 == null || date1.equals("")) return 0;
if (date2 == null || date2.equals("")) return 0;
// 转换为标准时间
SimpleDateFormat myFormatter = new SimpleDateFormat("yyyy-MM-dd");
java.util.Date date = null;
java.util.Date mydate = null;
try
{
date = myFormatter.parse(date1);
mydate = myFormatter.parse(date2);
}
catch (Exception e)
{
;
}
long day = (date.getTime() - mydate.getTime()) / (24 * 60 * 60 * 1000);
return day;
}
/**
* 形成如下的日历 , 根据传入的一个时间返回一个结构 星期日 星期一 星期二 星期三 星期四 星期五 星期六 下面是当月的各个时间
* 此函数返回该日历第一行星期日所在的日期
*
* @param sdate
* @return
*/
public static String getNowMonth(String sdate)
{
// 取该时间所在月的一号
sdate = sdate.substring(0, 8) + "01";
// 得到这个月的1号是星期几
Date date = shortStr2ShortDate(sdate);
Calendar c = Calendar.getInstance();
c.setTime(date);
int u = c.get(Calendar.DAY_OF_WEEK);
String newday = DateUtil.getNextDay(sdate, (1 - u) + "");
return newday;
}
/**
* 取得数据库主键 生成格式为yyyymmddhhmmss+k位随机数
*
* @param k
* 表示是取几位随机数,可以自己定
*/
public static String getNo(int k)
{
return parseDate("yyyyMMddhhmmss") + getRandom(k);
}
/**
* 返回一个随机数
*
* @param i
* @return
*/
private static String getRandom(int i)
{
Random jjj = new Random();
// int suiJiShu = jjj.nextInt(9);
if (i == 0) return "";
String jj = "";
for (int k = 0; k < i; k++)
{
jj = jj + jjj.nextInt(9);
}
return jj;
}
/**
*
* @param args
*/
public static boolean rightDate(String date)
{
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
if (date == null) return false;
if (date.length() > 10)
{
sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
}
else
{
sdf = new SimpleDateFormat("yyyy-MM-dd");
}
try
{
sdf.parse(date);
}
catch (ParseException e)
{
return false;
}
return true;
}
public static void main(String[] args)
{
//
}
/**
* 将date 按照指定 的 格式 formatStr 转换成 字符串
*
* @param date
* @param formatStr
* @return
*/
public static String date2Str(Date date, String formatStr)
{
SimpleDateFormat formatter = new SimpleDateFormat(formatStr);
String dateString = formatter.format(date);
return dateString;
}
/**
* 增加hours小時
*
* @param date
* @param hours
* @return
*/
public static Date addHours(Date date, int hours)
{
if (date == null) return null;
Calendar cal = Calendar.getInstance();
cal.setTime(date);
cal.add(Calendar.HOUR_OF_DAY, hours);// 24小时制
// cal.add(Calendar.HOUR, x);12小时制
date = cal.getTime();
return date;
}
/**
* 增加minutes分鐘
*
* @param date
* @param minutes
* @return
*/
public static Date addMinutes(Date date, int minutes)
{
if (date == null) return null;
Calendar cal = Calendar.getInstance();
cal.setTime(date);
cal.add(Calendar.MINUTE, minutes);//
date = cal.getTime();
return date;
}
/**
* 功能描述:格式化日期
*
* @param dateStr
* String 字符型日期
* @param format
* String 格式
* @return Date 日期
*/
public static Date parseDate(String dateStr, String format) {
Date date=null;
try {
DateFormat dateFormat = new SimpleDateFormat(format);
date = (Date) dateFormat.parse(dateStr);
} catch (Exception e) {
}
return date;
}
// 指定模式的时间格式
private static SimpleDateFormat getSDFormat(String pattern) {
return new SimpleDateFormat(pattern);
}
/**
* 当前日历,这里用中国时间表示
*
* @return 以当地时区表示的系统当前日历
*/
public static Calendar getCalendar() {
return Calendar.getInstance();
}
/**
* 默认日期按指定格式显示
*
* @param pattern
* 指定的格式
* @return 默认日期按指定格式显示
*/
public static String formatDate(String pattern) {
return getSDFormat(pattern).format(getCalendar().getTime());
}
/**
* 获取当前时间任意
* @return
*/
public static String get(int field) {
return String.valueOf(getCalendar().get(field));
}
/**
* 获取今日的开始时间
* @return
*/
public static Date getTodayBeginTime(){
Calendar calendar = Calendar.getInstance();
calendar.setTime(new Date());
calendar.set(Calendar.HOUR_OF_DAY, 0);
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.SECOND, 0);
Date today = calendar.getTime();
return today;
}
/**
* 获取今日的结束时间
* @return
*/
public static Date getTodayEndTime(){
Calendar calendar = Calendar.getInstance();
calendar.setTime(new Date());
calendar.set(Calendar.HOUR_OF_DAY, 23);
calendar.set(Calendar.MINUTE, 59);
calendar.set(Calendar.SECOND, 59);
Date today = calendar.getTime();
return today;
}
/**
* 获取两个时间相差的 *小时*分钟
* @param endDate
* @param nowDate
* @return
*/
public static String getDatePoorToMin(Date endDate, Date nowDate) {
// long nd = 1000 * 24 * 60 * 60;
long nh = 1000 * 60 * 60;
long nm = 1000 * 60;
// long ns = 1000;
// 获得两个时间的毫秒时间差异
long diff = endDate.getTime() - nowDate.getTime();
// 计算差多少天
// long day = diff / nd;
// 计算差多少小时
long hour = diff / nh;
// 计算差多少分钟
long min = diff % nh / nm;
// 计算差多少秒//输出结果
// long sec = diff % nd % nh % nm / ns;
return hour + "小时" + min + "分钟";
}
public static String getDatePoorToSec(Date endDate, Date nowDate) {
long nd = 1000 * 24 * 60 * 60;
long nh = 1000 * 60 * 60;
long nm = 1000 * 60;
long ss = 1000;
// long ns = 1000;
// 获得两个时间的毫秒时间差异
long diff = endDate.getTime() - nowDate.getTime();
// 计算差多少天
long day = diff / nd;
// 计算差多少小时
long hour = diff % nd / nh;
// 计算差多少分钟
long min = diff % nd % nh / nm;
long sen = diff % nd % nh % nm / ss;
// 计算差多少秒//输出结果
// long sec = diff % nd % nh % nm / ns;
return day + "天" + hour + "小时" + min + "分钟"+ sen + "秒";
}
}
\ No newline at end of file
package com.yeejoin.amos.jpush.util;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.google.gson.Gson;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.google.gson.reflect.TypeToken;
/**
*
* <pre>
* JSON工具类
* </pre>
*
* @author dell
* @version $Id: JSONUtil.java, v 0.1 2017年3月28日 下午9:04:47 dell Exp $
*/
public class JSONUtil
{
private static Gson gson = null;
static
{
gson = new Gson();
}
public static synchronized Gson newInstance()
{
if (gson == null)
{
gson = new Gson();
}
return gson;
}
public static String toJson(Object obj)
{
return gson.toJson(obj);
}
public static <T> T toBean(String json, Class<T> clz)
{
return gson.fromJson(json, clz);
}
public static <T> Map<String, T> toMap(String json, Class<T> clz)
{
Map<String, JsonObject> map = gson.fromJson(json,
new TypeToken<Map<String, JsonObject>>() {
}.getType());
Map<String, T> result = new HashMap<>();
for (String key : map.keySet())
{
result.put(key, gson.fromJson(map.get(key), clz));
}
return result;
}
public static Map<String, Object> toMap(String json)
{
Map<String, Object> map = gson.fromJson(json,
new TypeToken<Map<String, Object>>() {
}.getType());
return map;
}
public static <T> List<T> toList(String json, Class<T> clz)
{
JsonArray array = new JsonParser().parse(json).getAsJsonArray();
List<T> list = new ArrayList<>();
for (final JsonElement elem : array)
{
list.add(gson.fromJson(elem, clz));
}
return list;
}
}
package com.yeejoin.amos.jpush.util;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.apache.commons.lang.enums.ValuedEnum;
/**
*
* <pre>
* 操作枚举
* </pre>
*
* @author as-hanshipeng
* @version $Id: QueryOperatorEnum.java, v 0.1 2016-12-10 下午03:07:33 as-hanshipeng Exp $
*/
public final class QueryOperatorEnum extends ValuedEnum
{
private static final long serialVersionUID = -375127751242109017L;
public static final int LESS_VALUE = 1; //小于
public static final int BIGGER_VALUE = 2; //大于
public static final int EQUAL_VALUE = 3; //等于
public static final int LESS_EQUAL_VALUE = 4; // 小于等于
public static final int BIGGER_EQUAL_VALUE = 5; //大于等于
public static final int NOT_EQUAL_VALUE = 6; //不等于
public static final int IN_VALUE = 7; //包含
public static final int LIKE_VALUE = 8; //like
public static final int OR_VALUE = 9; // 或者
public static final int ORDER_VALUE = 10; // 排序
public static final int NOT_IN_VALUE = 11; // 不包含
public static final int IS_VALUE= 12; //是
public static final QueryOperatorEnum LESS = new QueryOperatorEnum("LESS",
1, "<");
public static final QueryOperatorEnum BIGGER = new QueryOperatorEnum(
"BIGGER", 2, ">");
public static final QueryOperatorEnum EQUAL = new QueryOperatorEnum(
"EQUAL", 3, "=");
public static final QueryOperatorEnum LESS_EQUAL = new QueryOperatorEnum(
"LESS_EQUAL", 4, "<=");
public static final QueryOperatorEnum BIGGER_EQUAL = new QueryOperatorEnum(
"BIGGER_EQUAL", 5, ">=");
public static final QueryOperatorEnum NOT_EQUAL = new QueryOperatorEnum(
"NOT_EQUAL", 6, "<>");
public static final QueryOperatorEnum IN = new QueryOperatorEnum("IN", 7,
"IN");
public static final QueryOperatorEnum LIKE = new QueryOperatorEnum("LIKE",
8, "LIKE");
public static final QueryOperatorEnum OR = new QueryOperatorEnum("OR", 9,
"OR");
public static final QueryOperatorEnum ORDER_BY = new QueryOperatorEnum(
"ORDER BY", 10, "ORDER BY");
public static final QueryOperatorEnum NOT_IN = new QueryOperatorEnum(
"NOT IN", 11, "NOT IN");
public static final QueryOperatorEnum IS = new QueryOperatorEnum(
"IS", 12, "IS");
public String condition;
public String getCondition() {
return condition;
}
public void setCondition(String condition) {
this.condition = condition;
}
protected QueryOperatorEnum(String arg0, int arg1,String condition)
{
super(arg0, arg1);
this.condition = condition;
}
public static QueryOperatorEnum getEnum(String name)
{
try{
return ((QueryOperatorEnum)getEnum(QueryOperatorEnum.class, name));
}catch(Exception ex){return null;}
}
public static QueryOperatorEnum getEnum(int name)
{
try{
return ((QueryOperatorEnum)getEnum(QueryOperatorEnum.class, name));
}catch(Exception ex){return null;}
}
public static Map getMap()
{
try{
return getEnumMap(QueryOperatorEnum.class);
}catch(Exception ex){return null;}
}
public static List getList()
{
try{
return getEnumList(QueryOperatorEnum.class);
}catch(Exception ex){return null;}
}
public static Iterator iterator()
{
try{
return iterator(QueryOperatorEnum.class);
}catch(Exception ex){return null;}
}
}
package com.yeejoin.amos.jpush.util;
import java.math.BigDecimal;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class StringUtil {
private static Pattern NOT_ZERO_AT_THE_END = Pattern.compile("[1-9]+\\d*[1-9]+");
private static Pattern numericPattern = Pattern.compile("-?[0-9]+\\.?[0-9]*");
/**
* 鍒ゆ柇瀵硅薄鏄惁涓虹┖
*
* @param str
* @return
*/
public static boolean isNotEmpty(Object str) {
boolean flag = true;
if (str != null && !str.equals("")) {
if (str.toString().length() > 0) {
flag = true;
}
} else {
flag = false;
}
return flag;
}
/***************************************************************************
* repeat - 閫氳繃婧愬瓧绗︿覆閲嶅鐢熸垚N娆$粍鎴愭柊鐨勫瓧绗︿覆銆�
*
* @param src
* - 婧愬瓧绗︿覆 渚嬪: 绌烘牸(" "), 鏄熷彿("*"), "娴欐睙" 绛夌瓑...
* @param num
* - 閲嶅鐢熸垚娆℃暟
* @return 杩斿洖宸茬敓鎴愮殑閲嶅瀛楃涓�
* @version 1.0 (2006.10.10) Wilson Lin
**************************************************************************/
public static String repeat(String src, int num) {
StringBuffer s = new StringBuffer();
for (int i = 0; i < num; i++)
s.append(src);
return s.toString();
}
/**
* 鍒ゆ柇鏄惁鏁板瓧琛ㄧず
*
* @param
* @return 鏄惁鏁板瓧鐨勬爣蹇�
*/
public static boolean isNumeric(String str) {
// 璇ユ鍒欒〃杈惧紡鍙互鍖归厤鎵�鏈夌殑鏁板瓧 鍖呮嫭璐熸暟
String bigStr;
try {
bigStr = new BigDecimal(str).toString();
} catch (Exception e) {
return false;//寮傚父 璇存槑鍖呭惈闈炴暟瀛椼��
}
Matcher isNum = numericPattern.matcher(bigStr); // matcher鏄叏鍖归厤
if (!isNum.matches()) {
return false;
}
return true;
}
public static int toInt(String s) {
if (s != null && !"".equals(s.trim())) {
try {
return Integer.parseInt(s);
} catch (Exception e) {
return 0;
}
}
return 0;
}
/**
* 鎴彇鍓嶅悗閮戒笉鏄�0鐨勬暟瀛楀瓧绗︿覆
* <p>
* 12010102 => 12010102
* 12010100 => 120101
* ab1201100b => 12011
*
* @param str
* @return
*/
public static String delEndZero(String str) {
Matcher mat = NOT_ZERO_AT_THE_END.matcher(str);
boolean rs = mat.find();
if (rs) {
return mat.group(0);
}
return null;
}
/**
* <pre>
* 绉婚櫎瀛楃涓插悗闈㈢殑0
* </pre>
*
* @param s
* @return
*/
public static String removeSufixZero(String s) {
if (s == null) {
return "";
}
while (s.endsWith("0")) {
if (s.equals("0")) {
s = "";
break;
}
s = s.substring(0, s.length() - 1);
}
return s;
}
public static String notNull(String s){
return s!=null?s:"";
}
public static boolean isStartWithDigit(String str){
char firstCharacter = str.charAt(0);
return Character.isDigit(firstCharacter);
}
public static void main(String[] args){
System.out.println(isStartWithDigit("a3730e937-17e5-4720-8f69-99e8d87d2ee7"));
}
}
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>amos-boot-module-api</artifactId>
<groupId>com.amosframework.boot</groupId>
<version>1.0.0</version>
</parent>
<artifactId>amos-boot-module-knowledgebase-api</artifactId>
<dependencies>
<dependency>
<groupId>org.typroject</groupId>
<artifactId>tyboot-component-emq</artifactId>
<version>${tyboot-version}</version>
<exclusions>
<exclusion>
<groupId>org.typroject</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- 规则模块 -->
<dependency>
<groupId>com.yeejoin</groupId>
<artifactId>amos-component-rule</artifactId>
</dependency>
<!-- 解析word -->
<dependency>
<groupId>org.docx4j</groupId>
<artifactId>docx4j</artifactId>
<version>3.3.6</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.docx4j</groupId>
<artifactId>docx4j-ImportXHTML</artifactId>
<version>3.3.6</version>
</dependency>
<dependency>
<groupId>org.docx4j</groupId>
<artifactId>docx4j-export-fo</artifactId>
<version>3.3.6</version>
</dependency>
<!-- 解析html -->
<dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<version>1.11.2</version>
</dependency>
<!-- 解析pdf -->
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>kernel</artifactId>
<version>${itext.version}</version>
</dependency>
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>layout</artifactId>
<version>${itext.version}</version>
</dependency>
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>html2pdf</artifactId>
<version>2.0.1</version>
</dependency>
<!-- 解析excel -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>4.0.1</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>4.0.1</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-elasticsearch</artifactId>
</dependency>
</dependencies>
</project>
package com.yeejoin.amos.knowledgebase.face.model;
import lombok.Data;
/**
* @author 杨博超
* @ClassName AttachmentModel
**/
@Data
public class AttachmentModel {
private String fileType;
private String filename;
private String originalFileName;
private String fileUrl;
}
package com.yeejoin.amos.knowledgebase.face.model;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.typroject.tyboot.core.rdbms.model.BaseModel;
import java.util.Date;
/**
* <p>
* 知识库文档注释信息
* </p>
*
* @author ningtianqing
* @since 2020-09-16
*/
@EqualsAndHashCode(callSuper = true)
@Data
public class KnowledgeDocAnnotateModel extends BaseModel {
/**
* 文档id
*/
private Long docSeq;
/**
* 添加注释的用户id
*/
private String userId;
/**
* 添加注释的用户名称
*/
private String username;
/**
* 是否是当前用户添加的注释
*/
private Boolean isCurrentUser;
/**
* 添加注释后文档内容
*/
private String htmlContent;
/**
* 注释内容
*/
private String annotateContent;
/**
* 注释位置信息(前端定义和使用的内容)
*/
private String positionInfo;
/**
* 机构编号
*/
private String agencyCode;
private Date createTime;
private Date updateTime;
public Date getUpdateTime() {
return recDate;
}
}
package com.yeejoin.amos.knowledgebase.face.model;
import org.typroject.tyboot.core.foundation.utils.TreeNode;
import org.typroject.tyboot.core.rdbms.model.BaseModel;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.Collection;
/**
* <p>
* 知识库文档分类
* </p>
*
* @author 子杨
* @since 2020-08-05
*/
@EqualsAndHashCode(callSuper = true)
@Data
public class KnowledgeDocCategoryModel extends BaseModel implements TreeNode<KnowledgeDocCategoryModel,Long> {
/**
* 分组名称
*/
private String categoryName;
private Long parentId;
/**
* 机构编号
*/
private String agencyCode;
private Collection<KnowledgeDocCategoryModel> children;
@Override
public Long getMyParentId() {
return this.parentId;
}
@Override
public Long getMyId() {
return this.sequenceNbr;
}
@Override
public Collection<KnowledgeDocCategoryModel> getChildren() {
return children;
}
@Override
public void setChildren(Collection<KnowledgeDocCategoryModel> children) {
this.children = children;
}
@Override
public int compareTo(KnowledgeDocCategoryModel groupModel) {
return this.getMyId().compareTo(groupModel.getMyId());
}
}
package com.yeejoin.amos.knowledgebase.face.model;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.typroject.tyboot.core.rdbms.model.BaseModel;
import java.util.Date;
/**
* <p>
* 知识库评论信息
* </p>
*
* @author 子杨
* @since 2020-08-05
*/
@EqualsAndHashCode(callSuper = true)
@Data
public class KnowledgeDocCommentsModel extends BaseModel {
/**
* 文档id
*/
private Long docSeq;
/**
* 发表评论的用户id
*/
private String userId;
private String username;
/**
* 评论内容
*/
private String commentsContent;
/**
* 父级评论id
*/
private Long parentId;
/**
* 机构编号
*/
private String agencyCode;
/**
* 是否点赞
*/
private Boolean like;
/**
* 总点赞数量
*/
private Integer likedNum;
private Date createTime;
public Date getCreateTime() {
return recDate;
}
}
package com.yeejoin.amos.knowledgebase.face.model;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.typroject.tyboot.core.rdbms.model.BaseModel;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
* <p>
* 知识库文档存储
* </p>
*
* @author 子杨
* @since 2020-08-05
*/
@EqualsAndHashCode(callSuper = true)
@Data
public class KnowledgeDocContentModel extends BaseModel {
/**
* 富文本内容存储
*/
private String htmlContent;
/**
* 文档状态:发布,未发布
*/
private String docStatus;
/**
* 录入者id
*/
private String userId;
/**
* 录入者姓名
*/
private String userName;
/**
* 创建时间
*/
private Date createTime;
/**
* 是否有附件
*/
private Boolean haveAttachment;
/**
* 摘要
*/
private String summary;
/**
* 机构编号
*/
private String agencyCode;
/**
* 审核状态:通过,驳回,待审核,待提交
**/
private String auditStatus;
/**
* 驳回意见
**/
private String rejectionComment;
/**
* 审核人id
**/
private String auditorUserId;
private String orgCode;
/**
* 纯文本内容
*/
private String textContent;
/**
* 排序内容
*/
private String sortStr;
/**
* 所属目录
*/
private Long directoryId;
/**
* 文档标题
*/
private String docTitle;
private String directoryName; // 目录名称
private Date lastUpdateTime;
private Map<String, Object> docBaseInfo; // 文档基础信息<feildName,value>
private List<KnowledgeTagInstanceModel> docTags; // 文档标签<tagInstanceModel,>
private List<KnowledgeTagInstanceModel> docContentTags; // 文档内容标签<tagInstanceModel>
private List<KnowledgeTagInstanceModel> tagsToShow; // 只能搜索列表显示的标签信息
private List<AttachmentModel> attachments; // 附件信息;<附件id,附件原始名称>
private Boolean collected; // 收藏标识
public Date getLastUpdateTime() {
return recDate;
}
}
package com.yeejoin.amos.knowledgebase.face.model;
import com.baomidou.mybatisplus.annotation.TableField;
import org.typroject.tyboot.core.rdbms.model.BaseModel;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* <p>
* 知识库系统动态选项配置的分组,用于区分不同功能的字段列表
* </p>
*
* @author 子杨
* @since 2020-08-05
*/
@EqualsAndHashCode(callSuper = true)
@Data
public class KnowledgeDynamicsGroupModel extends BaseModel {
/**
* 分组名称
*/
private String groupName;
/**
* 前端配置
*/
private String frontEndConfig;
/**
* 机构编号
*/
private String agencyCode;
/**
* 功能标识
*/
private String functional;
/**
* 业务项目标识
*/
private String appKey;
}
package com.yeejoin.amos.knowledgebase.face.model;
import org.typroject.tyboot.core.rdbms.model.BaseModel;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* <p>
* 知识库系统动态选项配置,多用于动态字段配置
* </p>
*
* @author 子杨
* @since 2020-08-05
*/
@EqualsAndHashCode(callSuper = true)
@Data
public class KnowledgeDynamicsOptionModel extends BaseModel {
/**
* 字段名
*/
private String fieldName;
/**
* 中文名
*/
private String fieldLabel;
/**
* 数据类型:文本,数字,枚举,日期
*/
private String dataType;
/**
* 功能标识
*/
private String functional;
/**
* 业务项目标识
*/
private String appKey;
private String frontEndConfig;
/**
* 机构编号
*/
private String agencyCode;
/**
* 字段分组主键
**/
private Long groupSeq;
private String queryStrategy;
}
package com.yeejoin.amos.knowledgebase.face.model;
import org.typroject.tyboot.core.rdbms.model.BaseModel;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* <p>
* 知识库系统动态选项配置的实例值
* </p>
*
* @author 子杨
* @since 2020-08-05
*/
@EqualsAndHashCode(callSuper = true)
@Data
public class KnowledgeDynamicsValueModel extends BaseModel {
/**
* 字段名
*/
private String fieldName;
/**
* 中文名
*/
private String fieldLabel;
/**
* 数据类型:文本,数字,枚举,日期
*/
private String dataType;
/**
* 字段分组id
*/
private Long groupSeq;
/**
* 动态配置字段的值
*/
private String fieldValue;
/**
* 关联的对象id,即文档id
*/
private Long instanceId;
/**
* 机构编号
*/
private String agencyCode;
private Long optionSeq;
private String queryStrategy;
}
package com.yeejoin.amos.knowledgebase.face.model;
import org.typroject.tyboot.core.rdbms.model.BaseModel;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* <p>
* 知识库内容交互计数表
* </p>
*
* @author 子杨
* @since 2020-08-05
*/
@EqualsAndHashCode(callSuper = true)
@Data
public class KnowledgeInteractionCountModel extends BaseModel {
/**
* 操作类型(标签所有情况引用,标签被已审核/已发布文档引用,文档引用)
*/
private String operateType;
/**
* 关联对象类型
*/
private String entityType;
/**
* 关联对象id
*/
private String entityId;
/**
* 计数
*/
private Integer operateCount;
/**
* 机构编号
*/
private String agencyCode;
}
package com.yeejoin.amos.knowledgebase.face.model;
import org.typroject.tyboot.core.rdbms.model.BaseModel;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* <p>
* 知识库内容交互记录
* </p>
*
* @author 子杨
* @since 2020-08-05
*/
@EqualsAndHashCode(callSuper = true)
@Data
public class KnowledgeInteractionRecordModel extends BaseModel {
/**
* 用户id
*/
private String userId;
/**
* 操作类型(点赞,吐槽,收藏)
*/
private String operateType;
/**
* 关联对象类型
*/
private String entityType;
/**
* 关联对象id
*/
private String entityId;
/**
* 机构编号
*/
private String agencyCode;
}
package com.yeejoin.amos.knowledgebase.face.model;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.typroject.tyboot.core.rdbms.model.BaseModel;
/**
* <p>
* 消息
* </p>
*
* @author 子杨
* @since 2020-08-05
*/
@EqualsAndHashCode(callSuper = true)
@Data
public class KnowledgeMessageModel extends BaseModel {
/**
* 消息类型
*/
private String messageType;
/**
* 消息标题
*/
private String messageTitle;
/**
* 消息内容
*/
private String messageContent;
/**
* 相关文档ID
*/
private Long targetSeq;
}
package com.yeejoin.amos.knowledgebase.face.model;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.typroject.tyboot.core.rdbms.model.BaseModel;
/**
* <p>
* 个人消息
* </p>
*
* @author 子杨
* @since 2020-08-05
*/
@EqualsAndHashCode(callSuper = true)
@Data
public class KnowledgeMessagePersonalModel extends BaseModel {
/**
* 接收人
*/
private String messageOwner;
/**
* 消息ID
*/
private Long messageSeq;
/**
* 消息状态
*/
private Integer messageStatus;
}
package com.yeejoin.amos.knowledgebase.face.model;
import org.typroject.tyboot.core.foundation.utils.TreeNode;
import org.typroject.tyboot.core.rdbms.model.BaseModel;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.Collection;
/**
* <p>
* 标签分组
* </p>
*
* @author 子杨
* @since 2020-08-05
*/
@EqualsAndHashCode(callSuper = true)
@Data
public class KnowledgeTagGroupModel extends BaseModel implements TreeNode<KnowledgeTagGroupModel,Long> {
/**
* 标签分类名称
*/
private String groupName;
/**
* 父级分类id
*/
private Long parentId;
/**
* 机构编号
*/
private String agencyCode;
private Collection<KnowledgeTagGroupModel> children;
@Override
public Long getMyParentId() {
return this.parentId;
}
@Override
public Long getMyId() {
return this.sequenceNbr;
}
@Override
public Collection<KnowledgeTagGroupModel> getChildren() {
return children;
}
@Override
public void setChildren(Collection<KnowledgeTagGroupModel> children) {
this.children = children;
}
@Override
public int compareTo(KnowledgeTagGroupModel groupModel) {
return this.getMyId().compareTo(groupModel.getMyId());
}
}
package com.yeejoin.amos.knowledgebase.face.model;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.typroject.tyboot.core.rdbms.model.BaseModel;
/**
* <p>
* 标签分组
* </p>
*
* @author 子杨
* @since 2020-08-05
*/
@EqualsAndHashCode(callSuper = true)
@Data
public class KnowledgeTagGroupRefModel extends BaseModel {
/**
* 标签分组id
*/
private Long groupSeq;
/**
* 标签id
*/
private Long tagSeq;
}
package com.yeejoin.amos.knowledgebase.face.model;
import org.typroject.tyboot.core.rdbms.model.BaseModel;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.List;
/**
* <p>
* 标签实例
* </p>
*
* @author 子杨
* @since 2020-08-05
*/
@EqualsAndHashCode(callSuper = true)
@Data
public class KnowledgeTagInstanceModel extends BaseModel {
/**
* 标签id
*/
private Long tagSeq;
/**
* 标签标记的目标id
*/
private Long targetSeq;
/**
* 标签名称
*/
private String tagName;
/**
* 标记方式:文档,内容
*/
private String markingType;
/**
* 机构编号
*/
private String agencyCode;
private String tagType;
private String frontEndConfig;
private List<KnowledgeTagValueModel> tagValues;//值标签的具体值
}
package com.yeejoin.amos.knowledgebase.face.model;
import org.typroject.tyboot.core.rdbms.model.BaseModel;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.List;
import java.util.Map;
/**
* <p>
* 标签库
* </p>
*
* @author 子杨
* @since 2020-08-05
*/
@EqualsAndHashCode(callSuper = true)
@Data
public class KnowledgeTagModel extends BaseModel {
/**
* 标签名称
*/
private String tagName;
/**
* 标签编码
*/
private String tagCode;
/**
* 标签分类:文本标签,值标签,
*/
private String tagType;
/**
* 标签状态:启用,禁用
*/
private String tagStatus;
/**
* 标签备注
*/
private String tagRemark;
/**
* 机构编号
*/
private String agencyCode;
/**
* 被引用数量(所有文档)
*/
private Integer referenceNumber;
/**
* 动态值
*/
private Map<String, Object> tagValues;
/**
* 标签分类
*/
private List<Long> tagGroup;
/**
* 创建人姓名
*/
private String creator;
}
package com.yeejoin.amos.knowledgebase.face.model;
import org.typroject.tyboot.core.rdbms.model.BaseModel;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* <p>
* 值标签的实例值
* </p>
*
* @author 子杨
* @since 2020-08-05
*/
@EqualsAndHashCode(callSuper = true)
@Data
public class KnowledgeTagValueModel extends BaseModel {
/**
* 标签实例id
*/
private Long instanceSeq;
/**
* 值标签的扩展字段名,内容标签文本位置,值标签文本内容/单值/日期,值标签范围最大值-最小值
*/
private String fieldName;
/**
* 值标签扩展字段的值
*/
private String tagValue;
/**
* 机构编号
*/
private String agencyCode;
private String unit;
}
package com.yeejoin.amos.knowledgebase.face.model;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.typroject.tyboot.core.rdbms.model.BaseModel;
import java.util.Date;
/**
* <p>
* 标签分组
* </p>
*/
@EqualsAndHashCode(callSuper = true)
@Data
@TableName("knowlege_statistics_record")
public class KnowlegeStatisticsRecordModel extends BaseModel {
/**
* 文档ID
*/
@TableField("DOC_SEQ")
private Long docSeq;
/**
* 警情发生时间
*/
@TableField("DISASTER_TIME")
private Date disasterTime;
/**
* 记录类型
*/
@TableField("RECORD_NAME")
private String recordName;
/**
* 分类字段值
*/
@TableField("CATEGORY_VALUE")
private String categoryValue;
/**
* 统计数值
*/
@TableField("COUNT_VALUE")
private Long countValue;
/**
* 值放大倍数
*/
@TableField("VALUE_WEIGHT")
private Integer valueWeight;
/**
* 数值单位
*/
@TableField("UNIT")
private Long unit;
}
package com.yeejoin.amos.knowledgebase.face.model;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.typroject.tyboot.core.foundation.utils.TreeNode;
import java.util.Collection;
/**
* <h1><h1>
*
* @author tiantao
* @date 2021/1/18 11:36
*/
@EqualsAndHashCode
@Data
public class MultipleNodeModel implements TreeNode<MultipleNodeModel, Long> {
private String nodeType;
private Long nodeKey;
private String nodeTitle;
private Long nodeParent;
private Collection<MultipleNodeModel> nodeChildren;
private Object nodeExtraInfo;
@Override
public Long getMyParentId() {
return this.nodeParent;
}
@Override
public Long getMyId() {
return this.nodeKey;
}
@Override
public Collection<MultipleNodeModel> getChildren() {
return this.nodeChildren;
}
@Override
public void setChildren(Collection<MultipleNodeModel> collection) {
this.setNodeChildren(collection);
}
@Override
public int compareTo(MultipleNodeModel o) {
return this.getNodeKey().compareTo(o.getNodeKey());
}
}
package com.yeejoin.amos.knowledgebase.face.orm.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.amos.knowledgebase.face.orm.entity.KnowledgeDocAnnotate;
/**
* <p>
* 知识库文档注释 Mapper 接口
* </p>
*
* @author ningtianqing
* @since 2020-09-16
*/
public interface DocAnnotateMapper extends BaseMapper<KnowledgeDocAnnotate> {
}
package com.yeejoin.amos.knowledgebase.face.orm.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.amos.knowledgebase.face.model.MultipleNodeModel;
import com.yeejoin.amos.knowledgebase.face.orm.entity.KnowledgeDocCategory;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* <p>
* 知识库文档分类 Mapper 接口
* </p>
*
* @author 子杨
* @since 2020-08-05
*/
public interface DocCategoryMapper extends BaseMapper<KnowledgeDocCategory> {
List<MultipleNodeModel> queryDocAndCategoryTree(@Param("categoryIds") List<Long> categoryIds, @Param("docStatus") String docStatus);
}
\ No newline at end of file
package com.yeejoin.amos.knowledgebase.face.orm.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.amos.knowledgebase.face.orm.entity.KnowledgeDocComments;
/**
* <p>
* 知识库评论信息 Mapper 接口
* </p>
*
* @author 子杨
* @since 2020-08-05
*/
public interface DocCommentsMapper extends BaseMapper<KnowledgeDocComments> {
}
\ No newline at end of file
package com.yeejoin.amos.knowledgebase.face.orm.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.amos.knowledgebase.face.orm.entity.KnowledgeDocContent;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
/**
* <p>
* 知识库文档存储 Mapper 接口
* </p>
*
* @author 子杨
* @since 2020-08-05
*/
public interface DocContentMapper extends BaseMapper<KnowledgeDocContent> {
List<Map<String,Long>> searchForDocIds(@Param("agencyCode") String agencyCode,
@Param("queryStr") String queryStr,
@Param("docStatus")String []docStatus,
@Param("auditStatus")String [] auditStatus,
@Param("userId")String userId,
@Param("orgCode")String orgCode,
@Param("offset") long offset,
@Param("length") long length);
List<Map<String,Object>> queryDocBaseInfoList(Map<String, Object> paramMap);
int queryDocBaseInfoTotal(Map<String, Object> paramMap);
List<Long> getAllPublishedDocIds();
}
\ No newline at end of file
package com.yeejoin.amos.knowledgebase.face.orm.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.amos.knowledgebase.face.orm.entity.KnowledgeDynamicsGroup;
/**
* <p>
* 知识库系统动态选项配置的分组,用于区分不同功能的字段列表 Mapper 接口
* </p>
*
* @author 子杨
* @since 2020-08-05
*/
public interface DynamicsGroupMapper extends BaseMapper<KnowledgeDynamicsGroup> {
}
\ No newline at end of file
package com.yeejoin.amos.knowledgebase.face.orm.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.amos.knowledgebase.face.orm.entity.KnowledgeDynamicsOption;
/**
* <p>
* 知识库系统动态选项配置,多用于动态字段配置 Mapper 接口
* </p>
*
* @author 子杨
* @since 2020-08-05
*/
public interface DynamicsOptionMapper extends BaseMapper<KnowledgeDynamicsOption> {
}
\ No newline at end of file
package com.yeejoin.amos.knowledgebase.face.orm.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.amos.knowledgebase.face.orm.entity.KnowledgeDynamicsValue;
/**
* <p>
* 知识库系统动态选项配置的实例值 Mapper 接口
* </p>
*
* @author 子杨
* @since 2020-08-05
*/
public interface DynamicsValueMapper extends BaseMapper<KnowledgeDynamicsValue> {
}
\ No newline at end of file
package com.yeejoin.amos.knowledgebase.face.orm.dao;
import com.yeejoin.amos.knowledgebase.face.orm.entity.ESDocEntity;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.elasticsearch.annotations.Query;
import org.springframework.data.elasticsearch.repository.ElasticsearchCrudRepository;
public interface ESDocRepository extends ElasticsearchCrudRepository<ESDocEntity, Long> {
}
package com.yeejoin.amos.knowledgebase.face.orm.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.amos.knowledgebase.face.orm.entity.KnowledgeInteractionCount;
import java.util.List;
/**
* <p>
* 知识库内容交互计数表 Mapper 接口
* </p>
*
* @author 子杨
* @since 2020-08-05
*/
public interface InteractionCountMapper extends BaseMapper<KnowledgeInteractionCount> {
/**
* 查询标签被所有文档的引用状况
* @return
*/
List<KnowledgeInteractionCount> queryTagQuoteAll();
/**
* 查询标签被发布文档的引用状况
* @return
*/
List<KnowledgeInteractionCount> queryTagQuotePublish();
/**
* 根据实体类型删除记录
* @param entityType 类型
* @return
*/
int deleteByEntityType(String entityType);
}
\ No newline at end of file
package com.yeejoin.amos.knowledgebase.face.orm.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.amos.knowledgebase.face.orm.entity.KnowledgeInteractionRecord;
/**
* <p>
* 知识库内容交互记录 Mapper 接口
* </p>
*
* @author 子杨
* @since 2020-08-05
*/
public interface InteractionRecordMapper extends BaseMapper<KnowledgeInteractionRecord> {
}
\ No newline at end of file
package com.yeejoin.amos.knowledgebase.face.orm.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.amos.knowledgebase.face.orm.entity.KnowledgeMessage;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
@Mapper
public interface MessageMapper extends BaseMapper<KnowledgeMessage> {
List<Map> selectMessageListByOwner(@Param("owner") String owner, @Param("messageType")String messageType);
Map selectMessageBySeq(Long sequenceNbr);
List<Map> selectMessageListByPage(Map<String,Object> param );
Integer selectMessageListByCount(Map<String,Object> param);
}
package com.yeejoin.amos.knowledgebase.face.orm.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.amos.knowledgebase.face.orm.entity.KnowledgeMessagePersonal;
/**
* <p>
* 标签库 Mapper 接口
* </p>
*
* @author 子杨
* @since 2020-08-05
*/
public interface MessagePersonalMapper extends BaseMapper<KnowledgeMessagePersonal> {
}
\ No newline at end of file
package com.yeejoin.amos.knowledgebase.face.orm.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.amos.knowledgebase.face.orm.entity.KnowlegeStatisticsRecord;
import java.util.List;
import java.util.Map;
/**
* <p>
* 标签分组 Mapper 接口
* </p>
*
* @author 子杨
* @since 2020-08-05
*/
public interface StatisticsRecordMapper extends BaseMapper<KnowlegeStatisticsRecord> {
/**
* 表清空
* @return
*/
void deleteAll();
/**
* 查询灾情总计
* @return
*/
Map<String, Object> selectDisasterCount();
/**
* 按类型分组查询
*/
List<Map<String, Object>> selectCategoryByName(String recordName);
/**
* 按类型查询/按时间分段总计
*/
List<Map<String, Object>> selectCountByNameAndDateRange(Map<String, Object> queryMap);
}
\ No newline at end of file
package com.yeejoin.amos.knowledgebase.face.orm.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.amos.knowledgebase.face.orm.entity.KnowledgeTagGroup;
/**
* <p>
* 标签分组 Mapper 接口
* </p>
*
* @author 子杨
* @since 2020-08-05
*/
public interface TagGroupMapper extends BaseMapper<KnowledgeTagGroup> {
}
\ No newline at end of file
package com.yeejoin.amos.knowledgebase.face.orm.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.amos.knowledgebase.face.orm.entity.KnowledgeTagGroupRef;
/**
* <p>
* 标签分组 Mapper 接口
* </p>
*
* @author 子杨
* @since 2020-08-05
*/
public interface TagGroupRefMapper extends BaseMapper<KnowledgeTagGroupRef> {
}
\ No newline at end of file
package com.yeejoin.amos.knowledgebase.face.orm.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.amos.knowledgebase.face.orm.entity.KnowledgeTagInstance;
/**
* <p>
* 标签实例 Mapper 接口
* </p>
*
* @author 子杨
* @since 2020-08-05
*/
public interface TagInstanceMapper extends BaseMapper<KnowledgeTagInstance> {
}
\ No newline at end of file
package com.yeejoin.amos.knowledgebase.face.orm.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.amos.knowledgebase.face.orm.entity.KnowledgeTag;
import java.util.List;
/**
* <p>
* 标签库 Mapper 接口
* </p>
*
* @author 子杨
* @since 2020-08-05
*/
public interface TagMapper extends BaseMapper<KnowledgeTag> {
List<KnowledgeTag> queryTagByNameInPublishedDoc(String tagName);
}
\ No newline at end of file
package com.yeejoin.amos.knowledgebase.face.orm.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.amos.knowledgebase.face.model.KnowledgeTagValueModel;
import com.yeejoin.amos.knowledgebase.face.orm.entity.KnowledgeTagValue;
import org.apache.ibatis.annotations.Param;
import java.util.Collection;
import java.util.List;
/**
* <p>
* 值标签的实例值 Mapper 接口
* </p>
*
* @author 子杨
* @since 2020-08-05
*/
public interface TagValueMapper extends BaseMapper<KnowledgeTagValue> {
/**
* 根据文档id查询标签值列表
* @param docSeq 文档id
* @return
*/
List<KnowledgeTagValue> queryTagValuesByDocId(Long docSeq);
/**
* 根据文档id查询标签值列表
* @param docIds 文档id列表
* @return
*/
List<KnowledgeTagValue> queryTagValuesByDocIds(@Param("docIds") Collection<Long> docIds);
}
\ No newline at end of file
package com.yeejoin.amos.knowledgebase.face.util;
public class Constants {
public static final String VALUE_TAG_FIELD_SINGLEVALUE = "singleValue";//单值字段名
public static final String VALUE_TAG_FIELD_RANGE_MAX = "rangeMax";//范围值 上界
public static final String VALUE_TAG_FIELD_RANGE_MIN = "rangeMin";//范围值 下界
public static final String VALUE_TAG_FIELD_TEXT = "text";//文本值
public static final String VALUE_TAG_FIELD_DATE_H = "dateH";//时间,年月日时分秒
public static final String VALUE_TAG_FIELD_ENUM_NAME = "enumName";// 枚举类型字段名
public static final String DOC_STATUS_UNPUBLISHED = "UNPUBLISHED";//文档发布状态--未发布
public static final String DOC_STATUS_PUBLISHED = "PUBLISHED"; //文档发布状态--已发布
public static final String MARKING_TYPE_DOC = "DOC"; // 标记类型--文档标签
public static final String MARKING_TYPE_CONTENT = "CONTENT";// 标记类型--内容标签
/**
* 审核状态--待提交
*/
public static final String DOC_AUDIT_STATUS_SAVED = "SAVED";
/**
* 审核状态--待审核
*/
public static final String DOC_AUDIT_STATUS_SUBMITTED = "SUBMITTED";
/**
* 审核状态--通过
*/
public static final String DOC_AUDIT_STATUS_PASSED = "PASSED";
/**
* 审核状态--驳回
*/
public static final String DOC_AUDIT_STATUS_REJECTED = "REJECTED";
public static final String TAG_INSTANCE_LABEL = "label";
public static final String DELETE_SYNC_PLAN_TOPIC = "DELETE_SYNC_PLAN_DOC";
/**
* 消息类型-要点推送
*/
public static final String MESSAGE_TYPE_PUSH = "ESSENTIAL_PUSH";
/**
* 消息类型-战例分享
*/
public static final String MESSAGE_TYPE_SHARE = "DOC_SHARE";
/**
* 消息主题前缀
*/
public static final String TOPIC_PREFIX = "knowledge_message_";
public static final String SHARE_WAY_APP = "app";
/**
* 标签状态-激活
*/
public static final String TAG_STATUS_ACTIVATE = "ACTIVATED";
/**
* 标签状态-禁用
*/
public static final String TAG_STATUS_DEACTIVATE = "DEACTIVATED";
/**
* 标签类型-文本标签
*/
public static final String TAG_TYPE_TEXT = "TEXT_TAG";
/**
* 标签类型-值标签
*/
public static final String TAG_TYPE_VALUE = "VALUE_TAG";
public static final String APPKEY_ALL = "ALL";
}
...@@ -3,7 +3,6 @@ package com.yeejoin.amos.knowledgebase.face.util; ...@@ -3,7 +3,6 @@ package com.yeejoin.amos.knowledgebase.face.util;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.yeejoin.amos.knowledgebase.face.model.KnowledgeTagInstanceModel; import com.yeejoin.amos.knowledgebase.face.model.KnowledgeTagInstanceModel;
import com.yeejoin.amos.knowledgebase.face.model.KnowledgeTagValueModel; import com.yeejoin.amos.knowledgebase.face.model.KnowledgeTagValueModel;
import com.yeejoin.amos.knowledgebase.face.service.TagValueService;
import lombok.Data; import lombok.Data;
import org.typroject.tyboot.core.foundation.exception.BaseException; import org.typroject.tyboot.core.foundation.exception.BaseException;
import org.typroject.tyboot.core.foundation.utils.Bean; import org.typroject.tyboot.core.foundation.utils.Bean;
...@@ -163,10 +162,10 @@ public class DocSortUtil { ...@@ -163,10 +162,10 @@ public class DocSortUtil {
String fieldName = tagValues.get(0).getFieldName(); String fieldName = tagValues.get(0).getFieldName();
String tagValue = tagValues.get(0).getTagValue(); String tagValue = tagValues.get(0).getTagValue();
switch (fieldName) { switch (fieldName) {
case TagValueService.VALUE_TAG_FIELD_DATE_H: case Constants.VALUE_TAG_FIELD_DATE_H:
res = DateUtil.formatStringToDate(tagValue, null).getTime(); res = DateUtil.formatStringToDate(tagValue, null).getTime();
break; break;
case TagValueService.VALUE_TAG_FIELD_SINGLEVALUE: case Constants.VALUE_TAG_FIELD_SINGLEVALUE:
res = Long.valueOf(tagValue); res = Long.valueOf(tagValue);
break; break;
default: default:
......
...@@ -9,10 +9,7 @@ import com.yeejoin.amos.knowledgebase.face.orm.entity.KnowledgeDocContent; ...@@ -9,10 +9,7 @@ import com.yeejoin.amos.knowledgebase.face.orm.entity.KnowledgeDocContent;
import com.yeejoin.amos.knowledgebase.face.orm.entity.KnowledgeDynamicsValue; import com.yeejoin.amos.knowledgebase.face.orm.entity.KnowledgeDynamicsValue;
import com.yeejoin.amos.knowledgebase.face.orm.entity.KnowledgeTagInstance; import com.yeejoin.amos.knowledgebase.face.orm.entity.KnowledgeTagInstance;
import com.yeejoin.amos.knowledgebase.face.orm.entity.KnowledgeTagValue; import com.yeejoin.amos.knowledgebase.face.orm.entity.KnowledgeTagValue;
import com.yeejoin.amos.knowledgebase.face.service.DocAuditService; import com.yeejoin.amos.knowledgebase.face.util.Constants;
import com.yeejoin.amos.knowledgebase.face.service.DocContentService;
import com.yeejoin.amos.knowledgebase.face.service.TagInstanceService;
import com.yeejoin.amos.knowledgebase.face.service.TagValueService;
import com.yeejoin.amos.knowledgebase.face.util.DocSortUtil; import com.yeejoin.amos.knowledgebase.face.util.DocSortUtil;
import lombok.Data; import lombok.Data;
import lombok.Getter; import lombok.Getter;
...@@ -154,7 +151,7 @@ public class ExcelParser { ...@@ -154,7 +151,7 @@ public class ExcelParser {
if (ValidationUtil.isEmpty(cellValue) || !NUMBER_STRING_PATTEN.matcher(cellValue).matches()) { if (ValidationUtil.isEmpty(cellValue) || !NUMBER_STRING_PATTEN.matcher(cellValue).matches()) {
continue; continue;
} }
tagValues.add(getTagValue(tagInstance, TagValueService.VALUE_TAG_FIELD_SINGLEVALUE, cellValue)); tagValues.add(getTagValue(tagInstance, Constants.VALUE_TAG_FIELD_SINGLEVALUE, cellValue));
replaceHtmlHolder(docContent, valueColIndex, cellValue, cellValue); replaceHtmlHolder(docContent, valueColIndex, cellValue, cellValue);
break; break;
} }
...@@ -168,7 +165,7 @@ public class ExcelParser { ...@@ -168,7 +165,7 @@ public class ExcelParser {
Date date = DateUtil.formatStringToDate(cellValue, formatMap.get(valueColIndex)); Date date = DateUtil.formatStringToDate(cellValue, formatMap.get(valueColIndex));
cellValue = DateUtil.formatDate(date, DATE_FORMAT); cellValue = DateUtil.formatDate(date, DATE_FORMAT);
String htmlDateStr = DateUtil.formatDate(date, DATE_FORMAT4_HTML); String htmlDateStr = DateUtil.formatDate(date, DATE_FORMAT4_HTML);
tagValues.add(getTagValue(tagInstance, TagValueService.VALUE_TAG_FIELD_DATE_H, cellValue)); tagValues.add(getTagValue(tagInstance, Constants.VALUE_TAG_FIELD_DATE_H, cellValue));
replaceHtmlHolder(docContent, valueColIndex, htmlDateStr, cellValue); replaceHtmlHolder(docContent, valueColIndex, htmlDateStr, cellValue);
} catch (Exception e) { } catch (Exception e) {
continue; continue;
...@@ -181,7 +178,7 @@ public class ExcelParser { ...@@ -181,7 +178,7 @@ public class ExcelParser {
if (ValidationUtil.isEmpty(cellValue)) { if (ValidationUtil.isEmpty(cellValue)) {
continue; continue;
} }
tagValues.add(getTagValue(tagInstance, TagValueService.VALUE_TAG_FIELD_TEXT, cellValue)); tagValues.add(getTagValue(tagInstance, Constants.VALUE_TAG_FIELD_TEXT, cellValue));
replaceHtmlHolder(docContent, valueColIndex, cellValue, cellValue); replaceHtmlHolder(docContent, valueColIndex, cellValue, cellValue);
break; break;
} }
...@@ -196,11 +193,11 @@ public class ExcelParser { ...@@ -196,11 +193,11 @@ public class ExcelParser {
continue; continue;
} }
if (!ValidationUtil.isEmpty(cellValue1)) { if (!ValidationUtil.isEmpty(cellValue1)) {
tagValues.add(getTagValue(tagInstance, TagValueService.VALUE_TAG_FIELD_RANGE_MIN, cellValue1)); tagValues.add(getTagValue(tagInstance, Constants.VALUE_TAG_FIELD_RANGE_MIN, cellValue1));
replaceHtmlHolder(docContent, valueColIndex1, cellValue1, cellValue1); replaceHtmlHolder(docContent, valueColIndex1, cellValue1, cellValue1);
} }
if (!ValidationUtil.isEmpty(cellValue2)) { if (!ValidationUtil.isEmpty(cellValue2)) {
tagValues.add(getTagValue(tagInstance, TagValueService.VALUE_TAG_FIELD_RANGE_MAX, cellValue2)); tagValues.add(getTagValue(tagInstance, Constants.VALUE_TAG_FIELD_RANGE_MAX, cellValue2));
replaceHtmlHolder(docContent, valueColIndex2, cellValue2, cellValue2); replaceHtmlHolder(docContent, valueColIndex2, cellValue2, cellValue2);
} }
} else { } else {
...@@ -289,8 +286,8 @@ public class ExcelParser { ...@@ -289,8 +286,8 @@ public class ExcelParser {
docContent.setOrgCode(this.orgCode); docContent.setOrgCode(this.orgCode);
docContent.setHtmlContent(excelConfig.getHtmlModule()); docContent.setHtmlContent(excelConfig.getHtmlModule());
docContent.setTextContent(excelConfig.getSummaryModule()); docContent.setTextContent(excelConfig.getSummaryModule());
docContent.setDocStatus(DocContentService.DOC_STATUS_UNPUBLISHED); docContent.setDocStatus(Constants.DOC_STATUS_UNPUBLISHED);
docContent.setAuditStatus(DocAuditService.DOC_AUDIT_STATUS_SAVED); docContent.setAuditStatus(Constants.DOC_AUDIT_STATUS_SAVED);
docContent.setHaveAttachment(false); docContent.setHaveAttachment(false);
return docContent; return docContent;
} }
...@@ -349,7 +346,7 @@ public class ExcelParser { ...@@ -349,7 +346,7 @@ public class ExcelParser {
tagInstance.setTargetSeq(docSequenceNbr); tagInstance.setTargetSeq(docSequenceNbr);
tagInstance.setTagType(tagModel.getTagType()); tagInstance.setTagType(tagModel.getTagType());
tagInstance.setTagName(tagModel.getTagName()); tagInstance.setTagName(tagModel.getTagName());
tagInstance.setMarkingType(TagInstanceService.MARKING_TYPE_DOC); tagInstance.setMarkingType(Constants.MARKING_TYPE_DOC);
return tagInstance; return tagInstance;
} }
......
...@@ -9,11 +9,6 @@ ...@@ -9,11 +9,6 @@
<artifactId>amos-boot-module-maintenance-api</artifactId> <artifactId>amos-boot-module-maintenance-api</artifactId>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>com.amosframework.boot</groupId>
<artifactId>amos-boot-biz-common</artifactId>
<version>${amos-biz-boot.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId> <artifactId>spring-boot-starter-data-jpa</artifactId>
<exclusions> <exclusions>
......
...@@ -11,14 +11,8 @@ ...@@ -11,14 +11,8 @@
<artifactId>amos-boot-module-patrol-api</artifactId> <artifactId>amos-boot-module-patrol-api</artifactId>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>com.amosframework.boot</groupId>
<artifactId>amos-boot-biz-common</artifactId>
<version>${amos-biz-boot.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId> <artifactId>spring-boot-starter-data-jpa</artifactId>
<exclusions> <exclusions>
......
...@@ -9,11 +9,6 @@ ...@@ -9,11 +9,6 @@
<artifactId>amos-boot-module-supervision-api</artifactId> <artifactId>amos-boot-module-supervision-api</artifactId>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>com.amosframework.boot</groupId>
<artifactId>amos-boot-biz-common</artifactId>
<version>${amos-biz-boot.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId> <artifactId>spring-boot-starter-data-jpa</artifactId>
<exclusions> <exclusions>
......
...@@ -10,15 +10,9 @@ ...@@ -10,15 +10,9 @@
<artifactId>amos-boot-module-tzs-api</artifactId> <artifactId>amos-boot-module-tzs-api</artifactId>
<dependencies> <dependencies>
<dependency>
<groupId>com.amosframework.boot</groupId>
<artifactId>amos-boot-biz-common</artifactId>
<version>${amos-biz-boot.version}</version>
</dependency>
<dependency> <dependency>
<groupId>org.springframework.data</groupId> <groupId>org.springframework.data</groupId>
<artifactId>spring-data-elasticsearch</artifactId> <artifactId>spring-data-elasticsearch</artifactId>
<version>4.0.9.RELEASE</version>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
<dependency> <dependency>
......
...@@ -23,5 +23,7 @@ ...@@ -23,5 +23,7 @@
<module>amos-boot-module-fas-api</module> <module>amos-boot-module-fas-api</module>
<module>amos-boot-module-maintenance-api</module> <module>amos-boot-module-maintenance-api</module>
<module>amos-boot-module-supervision-api</module> <module>amos-boot-module-supervision-api</module>
<module>amos-boot-module-jpush-api</module>
<module>amos-boot-module-knowledgebase-api</module>
</modules> </modules>
</project> </project>
\ No newline at end of file
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
<dependency> <dependency>
<groupId>com.amosframework.boot</groupId> <groupId>com.amosframework.boot</groupId>
<artifactId>amos-boot-module-jcs-api</artifactId> <artifactId>amos-boot-module-jcs-api</artifactId>
<version>1.0.0</version> <version>${amos-biz-boot.version}</version>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
</dependencies> </dependencies>
......
...@@ -19,6 +19,16 @@ ...@@ -19,6 +19,16 @@
<version>${amos-biz-boot.version}</version> <version>${amos-biz-boot.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.yeejoin</groupId>
<artifactId>amos-component-rule</artifactId>
<exclusions>
<exclusion>
<groupId>org.typroject</groupId>
<artifactId>tyboot-core-auth</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId> <groupId>org.apache.poi</groupId>
<artifactId>poi-scratchpad</artifactId> <artifactId>poi-scratchpad</artifactId>
<version>3.15</version> <version>3.15</version>
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
<groupId>com.amosframework.boot</groupId> <groupId>com.amosframework.boot</groupId>
<artifactId>amos-boot-module-common-biz</artifactId> <artifactId>amos-boot-module-common-biz</artifactId>
<version>${amos-biz-boot.version}</version> <version>${amos-biz-boot.version}</version>
</dependency> <!-- ES--> </dependency>
</dependencies> </dependencies>
</project> </project>
...@@ -88,9 +88,7 @@ public class AlertCalledController extends BaseController { ...@@ -88,9 +88,7 @@ public class AlertCalledController extends BaseController {
if (ValidationUtil.isEmpty(alertCalledObjsDto) if (ValidationUtil.isEmpty(alertCalledObjsDto)
|| ValidationUtil.isEmpty(alertCalledObjsDto.getAlertCalled())) || ValidationUtil.isEmpty(alertCalledObjsDto.getAlertCalled()))
throw new BadRequest("参数校验失败."); throw new BadRequest("参数校验失败.");
ReginParams reginParams = ReginParams reginParams =getSelectedOrgInfo();
JSONObject.parseObject(null != redisUtils.get(getToken()) ?
redisUtils.get(getToken()).toString() : null, ReginParams.class);
//获取当前登录人公司 //获取当前登录人公司
String name= reginParams.getCompany().getCompanyName(); String name= reginParams.getCompany().getCompanyName();
AlertCalled alertCalled = alertCalledObjsDto.getAlertCalled(); AlertCalled alertCalled = alertCalledObjsDto.getAlertCalled();
......
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>amos-boot-module-biz</artifactId>
<groupId>com.amosframework.boot</groupId>
<version>1.0.0</version>
</parent>
<artifactId>amos-boot-module-jpush-biz</artifactId>
<dependencies>
<dependency>
<groupId>com.amosframework.boot</groupId>
<artifactId>amos-boot-module-jpush-api</artifactId>
<version>${amos-biz-boot.version}</version>
</dependency>
<dependency>
<groupId>com.amosframework.boot</groupId>
<artifactId>amos-boot-biz-common</artifactId>
<version>${amos-biz-boot.version}</version>
<exclusions>
<exclusion>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-generator</artifactId>
</exclusion>
<exclusion>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</project>
package com.yeejoin.amos.jpush.service.business.controller;
import com.yeejoin.amos.jpush.common.entity.CommonResponse;
import com.yeejoin.amos.jpush.common.entity.CommonResponseUtil;
import com.yeejoin.amos.jpush.service.business.param.PushMsgParam;
import com.yeejoin.amos.jpush.service.jpush.AppMessagePushService;
import cn.jpush.api.push.model.PushPayload;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
/**
* 获取用户信息
*
* @author gaodongdong
*/
@RestController
@RequestMapping(value = "/api/user")
@Api(tags = "用户信息api")
public class UserController {
private final Logger logger = LoggerFactory.getLogger(UserController.class);
@Autowired
private AppMessagePushService appMessagePushService;
//极光推送
@ApiOperation(value = "发送消息", notes = "发送消息")
@RequestMapping(value = "/sendMessage", method = RequestMethod.POST)
public CommonResponse sendMessage(@RequestBody List<PushMsgParam> responses) {
try {
appMessagePushService.sendMessage( responses);
return CommonResponseUtil.success("发送成功");
} catch (Exception e) {
return CommonResponseUtil.failure("发送失败");
}
}
@ApiOperation(value = "发送消息", notes = "发送消息")
@RequestMapping(value = "/sendMessageone", method = RequestMethod.POST)
public CommonResponse sendMessageone(@RequestBody PushMsgParam responses) {
try {
appMessagePushService.sendMessage( responses);
return CommonResponseUtil.success("发送成功");
} catch (Exception e) {
return CommonResponseUtil.failure("发送失败");
}
}
@ApiOperation(value = "发送消息", notes = "发送消息")
@RequestMapping(value = "/pushNoticeMany", method = RequestMethod.POST)
public CommonResponse pushNoticeMany(@RequestBody PushMsgParam responses) {
try {
appMessagePushService.pushNoticeMany( responses);
return CommonResponseUtil.success("发送成功");
} catch (Exception e) {
return CommonResponseUtil.failure("发送失败");
}
}
@ApiOperation(value = "发送消息", notes = "发送消息")
@RequestMapping(value = "/buildPushPayload", method = RequestMethod.POST)
public CommonResponse buildPushPayload(@RequestBody PushMsgParam responses) {
try {
PushPayload pushPayload =appMessagePushService.buildPushPayload( responses);
return CommonResponseUtil.success(pushPayload);
} catch (Exception e) {
return CommonResponseUtil.failure("发送失败");
}
}
@ApiOperation(value = "删除别名关联设备", notes = "删除别名关联设备")
@RequestMapping(value = "/pushDevice", method = RequestMethod.GET)
public CommonResponse pushDevice(@RequestParam("alias") String alias) {
try {
boolean falg =appMessagePushService.PushDevice( alias);
if(falg){
return CommonResponseUtil.failure();
}else{
return CommonResponseUtil.success();
}
} catch (Exception e) {
return CommonResponseUtil.failure();
}
}
@ApiOperation(value = "别名关联设备", notes = "别名关联设备")
@RequestMapping(value = "/PushDeviceRegistration", method = RequestMethod.GET)
public CommonResponse PushDeviceRegistration(@RequestParam("registrationId") String registrationId,@RequestParam("alias") String alias) {
try {
boolean falg =appMessagePushService.PushDeviceRegistration( registrationId,alias);
if(falg){
return CommonResponseUtil.success();
}else{
return CommonResponseUtil.failure();
}
} catch (Exception e) {
return CommonResponseUtil.failure();
}
}
}
\ No newline at end of file
package com.yeejoin.amos.jpush.service.business.param;
import java.util.List;
import java.util.Map;
public class PushMsgParam {
/**
* 标题
*/
private String subject;
/**
* 消息内容
*/
private String content;
/**
* 邮件地址
*/
private String[] emails;
/**
* jpush接收人
*/
private List<String> recivers;
//
/**
* jpush参数传递
*/
Map<String, String> extras;
/**
* jpush发送类型:1:广播;2:标签;3:别名
*/
private String type = "3";
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
public List<String> getRecivers() {
return recivers;
}
public void setRecivers(List<String> recivers) {
this.recivers = recivers;
}
public Map<String, String> getExtras() {
return extras;
}
public void setExtras(Map<String, String> extras) {
this.extras = extras;
}
public String getSubject() {
return subject;
}
public void setSubject(String subject) {
this.subject = subject;
}
public String[] getEmails() {
return emails;
}
public void setEmails(String[] emails) {
this.emails = emails;
}
}
/**
*
*/
package com.yeejoin.amos.jpush.service.constants;
import java.text.SimpleDateFormat;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* 常量
*/
public class XJConstant {
private static final Logger logger = LoggerFactory.getLogger(XJConstant.class);
/**
* 构造方法
*/
private XJConstant() {
logger.debug(XJConstant.CONSTRUCTOR);
}
public static final String CM_CATEGORY_DIC_CODE = "CM_CATEGORY";
public static final String CM_TYPE_DIC_CODE = "CM_TYPE";
public static final String JPUSH_USER_KEY ="CONVERTER_STATION";
/**
* 网络服务ip
*/
public static final String NET_SERVER_HOST = "0.0.0.0";
/**
* 请求头key
*/
public static final String TOKEN_KEY = "X-Access-Token";
/**
* 时间格式(yyyy-MM-dd HH:mm:ss)
*/
public static final SimpleDateFormat SIMPLEDATAFORMAT_YMDHMS = new SimpleDateFormat(
"yyyy-MM-dd HH:mm:ss");
/**
* 构造方法字符串
*/
public static final String CONSTRUCTOR = "constructor...";
/**
* 轮询job最大线程数
*/
public static final int POLLING_JOB_THREAD_MAX_NUM = 20;
/**
* amos线程池数量
*/
public static final int AMOS_THREAD_NUM = 20;
/**
* 设备测试最大线程数
*/
public static final int TEST_EQUIPMENT_THREAD_MAX_NUM = 5;
/**
* 时间格式字符串:yyyy-MM-dd HH:mm:ss
*/
public static final String DATE_TIME_STR_YMDHMS = "yyyy-MM-dd HH:mm:ss";
/**
* bar
*/
public static final String BAR = "-";
/**
* Underline
*/
public static final String UNDERLINE = "_";
/**
* user
*/
public static final String USER = "user";
/**
* token
*/
public static final String TOKEN = "token";
/**
* loginType
*/
public static final String LOGIN_TYPE = "loginType";
/**
* subGraphId
*/
public static final String SUB_GRAPH_ID = "subGraphId";
public static final String ADMIN_ID = "1";
/**
* 帧报文异常
*/
public static final String FRAME_EXECPTION = "FRAME";
/**
* 性能指标
*/
public static final String METRIC = "METRIC";
/**
* 报文通道
*/
public static final String CHANNEL = "CHANNEL";
/**
* 设备状态(掉线)告警
*/
public static final String EQUIPMENT_STATUS = "EQUIPMENT_STATUS";
/**
* 设备连通性告警告警
*/
public static final String EQUIPMENT_CONNECTION = "EQUIPMENT_CONNECTION";
/**
* 通道注册
*/
public static final String REGISTER = "REGISTER";
/**
* 通道注销
*/
public static final String UNREGISTER = "UNREGISTER";
/**
* 报文正常
*/
public static final String NORMAL = "NORMAL";
/**
* 报文异常
*/
public static final String UNNORMAL = "UNNORMAL";
/**
* 告警socket类型
*/
public static final String ALARM_SOCKET = "ALARM_SOCKET";
/**
* 数据socket类型
*/
public static final String METRIC_SOCKET = "METRIC_SOCKET";
/**
* 数据socket类型
*/
public static final String MORPHIC_SOCKET = "MORPHIC_SOCKET";
/**
* false
*/
public static final Boolean FAIL_BOOLEAN_VALUE = Boolean.FALSE;
/**
* 0
*/
public static final Integer ZERO_INT_VALUE = Integer.parseInt("0");
/**
* -1
*/
public static final Integer FAIL_INT_VALUE = Integer.parseInt("-1");
/**
* -1
*/
public static final Long FAIL_LONG_VALUE = Long.parseLong("-1");
/**
* -1
*/
public static final Short FAIL_SHORT_VALUE = Short.parseShort("-1");
/**
*
*/
public static final Float FAIL_FLOAT_VALUE = Float.parseFloat("-1");
/**
* -1
*/
public static final Double FAIL_DOUBLE_VALUE = Double.parseDouble("-1");
/**
* 空格
*/
public static final Character FAIL_CHARACTER_VALUE = Character.valueOf(' ');
/**
* 失败
*/
public static final int FAILURE = 0;
/**
* 成功
*/
public static final int SUCCESS = 1;
/**
* 在线
*/
public static final String ONLINE = "在线";
/**
* 掉线
*/
public static final String OFFLINE = "掉线";
/**
* 通
*/
public static final String OPEN = "通";
/**
* 不通
*/
public static final String OFF = "不通";
/**
* ip
*/
public static final String IP = "ip";
/**
* #
*/
public static final String SHARP = "#";
/**
* TCP
*/
public static final String TCP = "TCP";
public static final String PIE_CHAR = "pieChar";
public static final String BAR_CHAR = "barChar";
public static final String HBAR_CHAR = "hbarChar";
public static final String LINE_CHAR = "lineChar";
public static final String DOUGHUNT_CHAR = "doughuntChar";
public static final String ROSE_CHAR = "roseChar";
public static final String AREA_CHAR = "areaChar";
public static final String DIMENSION = "dimension";
public static final String MEASURE = "measure";
/**
* xunjian
*/
public static final String TABLE_USERS = "Users";
public static final String EDIT_PWD = "editPassword";
public static final String EDIT_NOT_PWD = "editUsersInfo";
public static final String SAVE_USERS = "saveTableById";
public static final String SAVE_COM_USER = "saveComUserInfo";
public static final String EDIT_COM_USER = "editComUserInfo";
public static final String TABLE_CHECK = "Check";
public static final String TABLE_COM_USER = "companyUser";
public static final int FINISH_YES = 2;
public static final int FINISH_ING = 1;
public static final int FINISH_NO = 0;
public static final String SAVE_DEPART = "saveDepartMent";
public static final String EDIT_DEPART = "editsDepartMent";
public static final String TABLE_DEPART = "Group";
public static final String TABLE_ERROR = "Error";//隐患表
public static final String SAVE_ERROR = "saveErrorByID";//更新隐患表
public static final int XJ_ADMIN_ROLE = 9;//巡检管理员角色ID
public static final int XJ_USER_ROLE = 0;//巡检普通用户角色ID
public static final int TASK_STATUS_TIMEOUT = 3;//已超时
public static final int TASK_STATUS_FINISH = 2;//已结束
public static final int TASK_STATUS_DEAL = 1;//进行中
public static final int TASK_STATUS_NO_START = 0;//未开始
public static final String PLAN_TASK_DET_FINISH_NO = "0";//任务明细状态:未完成
public static final String PLAN_TASK_DET_FINISH_YES = "1";//任务明细状态:完成
public static final String PLAN_TASK_DET_FINISH_OUT = "2";//任务明细状态:超时漏检
public static final String USER_DATA_ADMIN = "全部可见"; //用户数据可见范围
public static final String USER_DATA_DEPART = "部门可见"; //用户数据可见范围
public static final String USER_DATA_PERSON = "个人可见"; //用户数据可见范围
public static final String USER_ROLE_SUPERADMIN = "1"; //权限id-超级管理员
public static final String USER_ROLE_ADMIN = "2"; //权限id-管理员
public static final String USER_ROLE_DEPART = "3"; //权限id-部门管理
public static final String USER_ROLE_PERSON = "4"; //权限id-普通用户
public static final String ROLE_NAME_SUPERADMIN = "SUPERADMIN"; //数据权限-超级管理员
public static final String ROLE_NAME_ADMIN = "ADMIN"; //数据权限-超级管理员
public static final String ROLE_NAME_DEPTADMIN = "DEPTADMIN"; //数据权限-部门
public static final String ROLE_NAME_PERSON = "PERSONAL"; //数据权限-个人
public static final String ADMIN_FLAG = "2"; //权限标记
public static final String DEPART_FLAG = "1"; //权限标记
public static final String PERSON_FLAG = "0";//权限标记
public static final String ADMIN_FLAG_NO = "0"; //标记 0-无关
public static final String ADMIN_FLAG_UP = "1"; //1-上级admin
public static final String ADMIN_FLAG_THIS = "2"; //2-本级admin
public static final String UNCLASSIFIED = "Unclassifed"; //巡检点未分类
public static final String ADMIN_ORG_CODE = "2";
public static final String CHECK_CHANGE_NO = "0";//是否记为合格:否
public static final String CHECK_CHANGE_YES = "1";//是否记为合格:是
public static final String SCHED_FLAG = "99";//自动任务标记
public static final String REGEN_FLAG = "98";//重做任务标记
public static final String FIX_DATE_NO = "0";//不固定日期(区间)
public static final String FIX_DATE_YES = "1";//固定日期
//计划类型
public static final String PLAN_TYPE_DAY = "1";//日计划
public static final String PLAN_TYPE_WEEK = "2";//周计划
public static final String PLAN_TYPE_MONTH = "3";//月计划
public static final String PLAN_TYPE_YEAR = "4";//年计划
//月类型
public static final String MONTH_TYPE_DAY = "1";//第几天
public static final String MONTH_TYPE_AT = "2";//在第几周的第几天
public static final String INTERVAL_UNIT_HOUR = "1";//执行间隔小时
public static final String INTERVAL_UNIT_MINUTE = "2";//执行间隔分钟
public static final String INTERVAL_UNIT_SECOND = "3";//执行间隔秒
public static final String ZERO_TIME = "00:00:00";//time
public static final String PLAN_STATUS_START = "0";//计划状态:正常
public static final String PLAN_STATUS_STOP = "1";//计划状态:已停用
public static final int PLAN_FIRST_STATUS_YES = 0;//计划:初始状态
public static final int PLAN_FIRST_STATUS_NO = 1;//计划:非初始状态
public static final String UPD_PLAN_GEN_DATE = "1";//更新plan表日期
public static final String UPD_PLAN_STATUS = "2";//更新plan表next_gen_status
public static final int DAY_RATE_ONE = 0;//0-1次
public static final int DAY_RATE_MANY = 1;//1-多次
public static final int IS_DETETE_NO = 0;//未删除
public static final int IS_DETETE_YES = 1;//删除
public static final String UPLOAD_ROOT_PATH = "upload";
public static final String INPUT_ITEM_TEXT = "文本";
public static final String INPUT_ITEM_NUMBER = "数字";
public static final String INPUT_ITEM_SELECT = "选择";
public static final String CHECK_TYPE_ALWAYS_OK = "始终合格";
public static final String CHECK_TYPE_ALWAYS_NO = "始终不合格";
public static final String CHECK_TYPE_NO_CONTEXT_OK = "无内容合格";
public static final String CHECK_TYPE_CONTEXT_OK = "有内容合格";
public static final String GEN_MORE_DATA_YES = "YES";
public static final String OK = "合格";
public static final String NO = "不合格";
public static final String YES = "是";
public static final String NOT = "否";
public static final String INPUT_ITEM_OK_SCORE = "OkScore";
public static final String INPUT_ITEM_NOT_SCORE = "NoScore";
/**
* 任务是否发送消息状态
*/
public static final String TASK_WARN = "是";
public static final String TASK_NOT_WARN = "否";
/**
* 系统定时任务类型
*/
public static final String STATUS_MONITOR_START = "statusMonitorStart"; //状态监控是否开始
public static final String STATUS_MONITOR_END = "statusMonitorEnd"; //状态监控是否结束
public static final String PLAN_TASK_WARN_MSG_PUSH = "planTaskWarnMsgPush"; //计划即将开始消息提醒推送开始前几分钟
public static final String PLAN_TASK_BEGIN_MSG_PUSH = "planTaskBeginMsgPush"; //计划已经开始消息提醒推送已经开始后几分钟
public static final String PLAN_TASK_END_MSG_PUSH = "planTaskEndMsgPush"; //计划已经开始消息提醒推送漏检
public static final String MESSAGE_PUSH = "messagePush"; //消息推送
public static final int IS_SENT = 1; //已发送
public static final int NOT_SENT = 0; //未发送
public static final String IS_FIXED_YES = "1"; //固定点
public static final String IMG = "img";
public static final String REVIEW_DEPT = "1";
public static final String COMBINE_DATA = "2";
}
package com.yeejoin.amos.jpush.service.core.enums;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.apache.commons.lang.enums.ValuedEnum;
/**
* 操作枚举
*
* @author as-youjun
*
*/
@SuppressWarnings("all")
public final class QueryOperatorEnum extends ValuedEnum {
private static final long serialVersionUID = -375127751242109017L;
public static final int LESS_VALUE = 1; // 小于
public static final int BIGGER_VALUE = 2; // 大于
public static final int EQUAL_VALUE = 3; // 等于
public static final int LESS_EQUAL_VALUE = 4; // 小于等于
public static final int BIGGER_EQUAL_VALUE = 5; // 大于等于
public static final int NOT_EQUAL_VALUE = 6; // 不等于
public static final int IN_VALUE = 7; // 包含
public static final int LIKE_VALUE = 8; // like
public static final int OR_VALUE = 9; // 或者
public static final int ORDER_VALUE = 10; // 排序
public static final int NOT_IN_VALUE = 11; // 不包含
public static final int IS_VALUE= 12; //是
public static final QueryOperatorEnum LESS = new QueryOperatorEnum("LESS", 1, "<");
public static final QueryOperatorEnum BIGGER = new QueryOperatorEnum("BIGGER", 2, ">");
public static final QueryOperatorEnum EQUAL = new QueryOperatorEnum("EQUAL", 3, "=");
public static final QueryOperatorEnum LESS_EQUAL = new QueryOperatorEnum("LESS_EQUAL", 4, "<=");
public static final QueryOperatorEnum BIGGER_EQUAL = new QueryOperatorEnum("BIGGER_EQUAL", 5, ">=");
public static final QueryOperatorEnum NOT_EQUAL = new QueryOperatorEnum("NOT_EQUAL", 6, "<>");
public static final QueryOperatorEnum IN = new QueryOperatorEnum("IN", 7, "IN");
public static final QueryOperatorEnum LIKE = new QueryOperatorEnum("LIKE", 8, "LIKE");
public static final QueryOperatorEnum OR = new QueryOperatorEnum("OR", 9, "OR");
public static final QueryOperatorEnum ORDER_BY = new QueryOperatorEnum("ORDER BY", 10, "ORDER BY");
public static final QueryOperatorEnum NOT_IN = new QueryOperatorEnum("NOT IN", 11, "NOT IN");
public static final QueryOperatorEnum IS = new QueryOperatorEnum("IS", 12, "IS");
public String condition;
public String getCondition() {
return condition;
}
public void setCondition(String condition) {
this.condition = condition;
}
protected QueryOperatorEnum(String arg0, int arg1, String condition) {
super(arg0, arg1);
this.condition = condition;
}
public static QueryOperatorEnum getEnum(String name) {
try {
return ((QueryOperatorEnum) getEnum(QueryOperatorEnum.class, name));
} catch (Exception ex) {
return null;
}
}
public static QueryOperatorEnum getEnum(int name) {
try {
return ((QueryOperatorEnum) getEnum(QueryOperatorEnum.class, name));
} catch (Exception ex) {
return null;
}
}
public static Map getMap() {
try {
return getEnumMap(QueryOperatorEnum.class);
} catch (Exception ex) {
return null;
}
}
public static List getList() {
try {
return getEnumList(QueryOperatorEnum.class);
} catch (Exception ex) {
return null;
}
}
public static Iterator iterator() {
try {
return iterator(QueryOperatorEnum.class);
} catch (Exception ex) {
return null;
}
}
}
package com.yeejoin.amos.jpush.service.core.util;
import java.sql.Time;
import java.text.ParseException;
import java.text.ParsePosition;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.Period;
import java.util.Calendar;
import java.util.Date;
import java.util.TimeZone;
import com.yeejoin.amos.jpush.service.exception.YeeException;
/**
* <pre>
* 日期
* </pre>
*
* @author as-chenjiajun
* @version $Id: DateUtil.java, v 0.1 2018年1月29日 下午5:08:40 as-chenjiajun Exp $
*/
public class DateUtil {
public static String LONG_PATTERN = "yyyy-MM-dd HH:mm:ss";
public static String MID_PATTERN = "yyyy-MM-dd HH:mm";
public static String SHORT_PATTERN = "yyyy-MM-dd";
public static long THREE_DAY_MILLSEC = 259200000L;
public static long ONE_DAY_MILLSEC = 86400000L;
public static long ONE_HOUR_MILLSEC = 3600000L;
public static long THREE_HOURS_MILLSEC = 10800000L;
public static long TWELVE_HOURS_MILLSEC = 43200000L;
public static Date EMPTY_DATE = null;
static {
Calendar calendar = Calendar.getInstance();
calendar.set(9999, 0, 0);
EMPTY_DATE = calendar.getTime();
}
/**
* <pre>
* 获取当前北京时间
* </pre>
*
* @return
*/
public static Date getCurrentDate() {
return getCurrentCalendar().getTime();
}
public static String getLongCurrentDate() {
return new SimpleDateFormat(LONG_PATTERN)
.format(getCurrentCalendar().getTime());
}
public static String getLongDate(Date date) {
if (null == date)
return getLongCurrentDate();
else
return new SimpleDateFormat(LONG_PATTERN).format(date);
}
public static String getLongDate(long value) {
return new SimpleDateFormat(LONG_PATTERN).format(new Date(value));
}
public static String getShortCurrentDate() {
return new SimpleDateFormat(SHORT_PATTERN).format(new Date());
}
public static String getShortDate(Date date) {
if (null == date)
return getShortCurrentDate();
else
return new SimpleDateFormat(SHORT_PATTERN).format(date);
}
public static String getShortDate(long value) {
return new SimpleDateFormat(SHORT_PATTERN).format(new Date(value));
}
public static Date getShortCurrentDate(String shortDateStr) throws ParseException {
return new SimpleDateFormat(SHORT_PATTERN).parse(shortDateStr);
}
public static Date getLongDate(String longDateStr) throws ParseException {
return new SimpleDateFormat(LONG_PATTERN).parse(longDateStr);
}
public static String getMidCurrentDate() {
return new SimpleDateFormat(MID_PATTERN).format(new Date());
}
public static String getMidDate(Date date) {
if (null == date)
return getMidCurrentDate();
else
return new SimpleDateFormat(MID_PATTERN).format(new Date());
}
public static String getMidDate(long value) {
return new SimpleDateFormat(MID_PATTERN).format(new Date(value));
}
public static Date str2Date(String strDate, String dateFormat) {
SimpleDateFormat formatter = new SimpleDateFormat(dateFormat);
ParsePosition pos = new ParsePosition(0);
Date strtodate = formatter.parse(strDate, pos);
return strtodate;
}
public static int getYear(Date date) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
int year = calendar.get(Calendar.YEAR);
return year;
}
public static int getMonth(Date date) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
int month = calendar.get(Calendar.MONTH) + 1;
return month;
}
public static int getDay(Date date) {
Calendar c = Calendar.getInstance();
c.setTime(date);
int day = c.get(Calendar.DATE);
return day;
}
public static int getHour(Date date) {
Calendar c = Calendar.getInstance();
c.setTime(date);
int hour = c.get(Calendar.HOUR_OF_DAY);
return hour;
}
public static int getMinite(Date date) {
Calendar c = Calendar.getInstance();
c.setTime(date);
int minite = c.get(Calendar.MINUTE);
return minite;
}
/**
* <pre>
* 获取当前北京时间
* </pre>
*
* @return
*/
public static Calendar getCurrentCalendar() {
TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai"));
return Calendar.getInstance();
}
/**
* <pre>
* 获取当前两个时间差
* </pre>
*
* @return
*/
public static String getTimeDifference(Date dateBefore, Date dateAfter) {
long l = dateAfter.getTime() - dateBefore.getTime();
long day = l / (24 * 60 * 60 * 1000);
long hour = (l / (60 * 60 * 1000) - day * 24);
long min = ((l / (60 * 1000)) - day * 24 * 60 - hour * 60);
long s = (l / 1000 - day * 24 * 60 * 60 - hour * 60 * 60 - min * 60);
return "" + day + "天" + hour + "小时" + min + "分" + s + "秒";
}
/**
* 获取某年某月的第一天日期
*
* @param date
* @param format
* @return
*/
public static String getStartMonthDate(String date, String format) {
if (date == null || date.length() < 6 || format == null) {
return null;
}
int year = Integer.parseInt(date.substring(0, 4));
int month = Integer.parseInt(date.substring(4, 6));
Calendar calendar = Calendar.getInstance();
calendar.set(year, month - 1, 1);
return new SimpleDateFormat(format).format(calendar.getTime());
}
/**
* 获取某年某月的最后一天日期
*
* @param date
* @param format
* @return
*/
public static String getEndMonthDate(String date, String format) {
if (date == null || date.length() < 6 || format == null) {
return null;
}
int year = Integer.parseInt(date.substring(0, 4));
int month = Integer.parseInt(date.substring(4, 6));
Calendar calendar = Calendar.getInstance();
calendar.set(year, month - 1, 1);
int day = calendar.getActualMaximum(5);
calendar.set(year, month - 1, day);
return new SimpleDateFormat(format).format(calendar.getTime());
}
/**
* 获取某天的间隔天数
*
* @param date
* @param interval 间隔天数。负数为前,正数为后
* @param format 输出格式化
* @return
*/
public static String getIntervalDateStr(Date date, int interval, String format) {
if (date == null || format == null) {
return null;
}
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.add(Calendar.DATE, interval);
return new SimpleDateFormat(format).format(calendar.getTime());
}
/**
* 获取某天的年初第一天
*
* @param date
* @param format 输出格式化
* @return
*/
public static String getFirstDayOfYear(String date, String format) {
int year = Integer.parseInt(date.substring(0, 4));
Calendar calendar = Calendar.getInstance();
calendar.set(year, Calendar.JANUARY, 1);
return new SimpleDateFormat(format).format(calendar.getTime());
}
/**
* 获取某天的年初第一天
*
* @param date
* @param format 输出格式化
* @return date
*/
public static Date getFirstDayOfYearDate(String date) {
int year = Integer.parseInt(date.substring(0, 4));
Calendar calendar = Calendar.getInstance();
calendar.set(year, Calendar.JANUARY, 1);
return calendar.getTime();
}
/**
* 获取某天的年末最后一天
*
* @param date
* @param format 输出格式化
* @return date
*/
public static Date getLastDayOfYearDate(Date date) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
final int last = calendar.getActualMaximum(Calendar.DAY_OF_YEAR);
calendar.set(Calendar.DAY_OF_YEAR, last);
return calendar.getTime();
}
/**
* 获取某天的间隔天数
*
* @param date
* @param interval 间隔天数。负数为前,正数为后
* @param format 输出格式化
* @return
*/
public static Date getIntervalDate(Date date, int interval) {
if (date == null) {
return null;
}
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.add(Calendar.DATE, interval);
return calendar.getTime();
}
/**
* 获得指定日期的间隔周末
*
* @param exeDate
* @param init
* @return
*/
public static Date getIntervalWeekDate(Date exeDate, int init) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(exeDate);
calendar.add(Calendar.DATE, init * 7);
calendar.set(Calendar.DAY_OF_WEEK, Calendar.SUNDAY);
return calendar.getTime();
}
/**
* 获得制定日期间隔的上个月最后一天
*
* @param exeDate
* @param inter
* @return
*/
public static Date getEndMonthDate(Date exeDate, int inter) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(exeDate);
calendar.add(Calendar.MONTH, inter - 1);
calendar.set(Calendar.DAY_OF_MONTH, calendar.getActualMaximum(Calendar.DAY_OF_MONTH));
return calendar.getTime();
}
/**
* 获取间隔周的
*
* @param mounthFirstDate
* @param whatWeek
* @param weekDay
* @return
*/
public static Date getIntMonthWeekDate(Date mounthFirstDate, int week, int day) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(mounthFirstDate);
if (day == 7) {
day = 1;
week = week + 1;
} else {
day = day + 1;
}
calendar.set(Calendar.WEEK_OF_MONTH, week);
calendar.set(Calendar.DAY_OF_WEEK, day);
return calendar.getTime();
}
/**
* 获取间隔的年日期
*
* @param planDegin
* @param init
* @return
*/
public static String getIntervalYearDate(Date planDegin, int init) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(planDegin);
calendar.add(Calendar.YEAR, init);
return new SimpleDateFormat("yyyy-MM-dd").format(calendar.getTime());
}
/**
* 格式化日期
*
* @param beginDate
* @param string
* @return
*/
public static String formatDatrToStr(Date beginDate, String formart) {
SimpleDateFormat df = new SimpleDateFormat(formart);
String strDate = df.format(beginDate);
return strDate;
}
public static Time formatStrToTime(String strDate) {
String str = strDate;
SimpleDateFormat format = new SimpleDateFormat("hh:mm:ss");
Date d = null;
try {
d = format.parse(str);
} catch (Exception e) {
e.printStackTrace();
}
Time date = new Time(d.getTime());
return date;
}
/**
* 获得间隔分钟的时间
*
* @param strBeginTime 被操作时间
* @param duration 间隔分钟数
* @param string 格式化的格式
* @return
*/
public static String getIntMinStrDate(String strBeginTime, int duration, String formart) {
SimpleDateFormat df = new SimpleDateFormat(formart);
Date date;
try {
date = df.parse(strBeginTime);
} catch (ParseException e) {
throw new YeeException("格式化日期失败");
}
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.add(Calendar.MINUTE, duration);
String strDate = df.format(calendar.getTime());
return strDate;
}
public static String cronTime(Date date) {
StringBuilder cron = new StringBuilder();
cron.append(date.getSeconds()).append(" ")
.append(date.getMinutes()).append(" ")
.append(date.getHours()).append(" ")
.append(date.getDay()).append(" ")
.append(date.getMonth()).append(" ")
.append("?").append(" ")
.append(date.getYear());
return cron.toString();
}
/**
* 获取指定日期的周一
*/
public static Date getThisWeekMonday(Date date) {
Calendar cal = getCurrentCalendar();
cal.setTime(date);
// 获得当前日期是一个星期的第几天
int dayWeek = cal.get(Calendar.DAY_OF_WEEK);
if (1 == dayWeek) {
cal.add(Calendar.DAY_OF_MONTH, -1);
}
// 设置一个星期的第一天,按中国的习惯一个星期的第一天是星期一
cal.setFirstDayOfWeek(Calendar.MONDAY);
// 获得当前日期是一个星期的第几天
int day = cal.get(Calendar.DAY_OF_WEEK);
// 根据日历的规则,给当前日期减去星期几与一个星期第一天的差值
cal.add(Calendar.DATE, cal.getFirstDayOfWeek() - day);
return cal.getTime();
}
/**
* 获取指定日期的月份第一天
*/
public static Date getThisMonthFirstDay(Date date) {
Calendar cal = getCurrentCalendar();
cal.setTime(date);
//获取某月最小天数
int firstDay = cal.getMinimum(Calendar.DATE);
//设置日历中月份的最小天数
cal.set(Calendar.DAY_OF_MONTH, firstDay);
return cal.getTime();
}
public static Date getCurrYearFirst() {
Calendar currCal = getCurrentCalendar();
int currentYear = currCal.get(Calendar.YEAR);
return getYearFirst(currentYear);
}
public static Date getCurrYearLast() {
Calendar currCal = getCurrentCalendar();
int currentYear = currCal.get(Calendar.YEAR);
return getYearLast(currentYear);
}
public static Date getYearFirst(int year) {
Calendar calendar = getCurrentCalendar();
calendar.clear();
calendar.set(Calendar.YEAR, year);
return calendar.getTime();
}
public static Date getYearLast(int year) {
Calendar calendar = getCurrentCalendar();
calendar.clear();
calendar.set(Calendar.YEAR, year);
calendar.roll(Calendar.DAY_OF_YEAR, -1);
return calendar.getTime();
}
/**
* 获得指定日期所在周第一天
* @param planBegin
* @return
*/
public static String getFirstDayOfWeekAtDay(String planBegin) {
Calendar calendar = Calendar.getInstance();
calendar.setFirstDayOfWeek(Calendar.MONDAY);
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
Date date;
try {
date = df.parse(planBegin);
} catch (ParseException e) {
throw new YeeException("日期格式化失败");
}
calendar.setTime(date);
calendar.set(Calendar.DAY_OF_WEEK,Calendar.MONDAY);
return df.format(calendar.getTime());
}
/**
* 获得指定日期所在周第一天
* @param planEnd
* @return
*/
public static String getEndDayOfWeekAtDay(String planEnd) {
Calendar calendar = Calendar.getInstance();
calendar.setFirstDayOfWeek(Calendar.MONDAY);
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
Date date;
try {
date = df.parse(planEnd);
} catch (ParseException e) {
throw new YeeException("日期格式化失败");
}
calendar.setTime(date);
calendar.set(Calendar.DAY_OF_WEEK,Calendar.SUNDAY);
return df.format(calendar.getTime());
}
/**
* 获得日期在周的天数
* @param planBegin
* @return
* @throws ParseException
*/
public static int getDayOfWeek(String planBegin) {
Calendar calendar = Calendar.getInstance();
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
Date date;
try {
date = df.parse(planBegin);
} catch (ParseException e) {
throw new YeeException("日期格式化失败");
}
calendar.setFirstDayOfWeek(Calendar.MONDAY);
calendar.setTime(date);
int dayOfWeek = calendar.get(Calendar.DAY_OF_WEEK) - 1;
if(dayOfWeek == 0) {
dayOfWeek = 7;
}
return dayOfWeek;
}
/**
* 计算两个日期间隔天数
* @param beginData
* @param endData
* @return
*/
public static int calInterverDay(String beginDate,String endDate){
LocalDate ld1 = LocalDate.parse(beginDate);
LocalDate ld2 = LocalDate.parse(endDate);
Period pe = Period.between(ld1, ld2);
return pe.getDays();
}
/**
* 获得日期所在周
* @param beginData
* @return
* @throws ParseException
*/
public static int calAtWeekOfDay(String srtdate){
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
Date date1;
try {
date1 = df.parse(srtdate);
} catch (ParseException e) {
throw new YeeException("日期格式化失败");
}
Calendar calendar = Calendar.getInstance();
calendar.setFirstDayOfWeek(Calendar.MONDAY);
calendar.setTime(date1);
return calendar.get(Calendar.WEEK_OF_YEAR);
}
public static Date getDateByNumber(Date date, Integer dayNumber) {
Calendar cal = Calendar.getInstance();
cal.setTime(date);
cal.add(Calendar.DATE, dayNumber);
return cal.getTime();
}
public static Date getHourBeginOfDay(int hour) {
Calendar cal = Calendar.getInstance();
cal.set(Calendar.HOUR_OF_DAY, hour);
cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.SECOND, 0);
return cal.getTime();
}
}
package com.yeejoin.amos.jpush.service.core.util;
public class MailUtil {
private static final String regex = "^[A-Za-z]{1,40}@[A-Za-z0-9]{1,40}\\.[A-Za-z]{2,3}$";
public static boolean isValidEmail(String email){
boolean flag = true;
if (email != null && !email.equals("")) {
if (email.toString().length() > 0) {
flag = email.matches(regex);
}
} else {
flag = false;
}
return flag;
}
}
package com.yeejoin.amos.jpush.service.core.util;
import java.math.BigDecimal;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.springframework.util.Assert;
/**
* 字符串工具类
*
* @author as-youjun
*
*/
public class StringUtil {
private static Pattern NOT_ZERO_AT_THE_END = Pattern.compile("[1-9](\\d*[1-9])?");
private static Pattern numericPattern = Pattern.compile("-?[0-9]+\\.?[0-9]*");
/**
* 判断对象是否为空
*
* @param str
* @return
*/
public static boolean isNotEmpty(Object str) {
boolean flag = true;
if (str != null && !str.equals("")) {
if (str.toString().length() > 0) {
flag = true;
}
} else {
flag = false;
}
return flag;
}
/***************************************************************************
* repeat - 通过源字符串重复生成N次组成新的字符串。
*
* @param src
* - 源字符串 例如: 空格(" "), 星号("*"), "浙江" 等等...
* @param num
* - 重复生成次数
* @return 返回已生成的重复字符串
* @version 1.0 (2006.10.10) Wilson Lin
**************************************************************************/
public static String repeat(String src, int num) {
StringBuffer s = new StringBuffer();
for (int i = 0; i < num; i++)
s.append(src);
return s.toString();
}
/**
* 判断是否数字表示
*
* @param src
* 源字符串
* @return 是否数字的标志
*/
public static boolean isNumeric(String str) {
// 该正则表达式可以匹配所有的数字 包括负数
String bigStr;
try {
bigStr = new BigDecimal(str).toString();
} catch (Exception e) {
return false;// 异常 说明包含非数字。
}
Matcher isNum = numericPattern.matcher(bigStr); // matcher是全匹配
if (!isNum.matches()) {
return false;
}
return true;
}
public static int toInt(String s) {
if (s != null && !"".equals(s.trim())) {
try {
return Integer.parseInt(s);
} catch (Exception e) {
return 0;
}
}
return 0;
}
/**
* 截取前后都不是0的数字字符串
*
* 12010102 => 12010102 12010100 => 120101 ab1201100b => 12011
*
* @param str
* @return
*/
public static String delEndZero(String str) {
Matcher mat = NOT_ZERO_AT_THE_END.matcher(str);
boolean rs = mat.find();
if (rs) {
return mat.group(0);
}
return null;
}
/**
*
* <pre>
* 移除字符串后面的0
* </pre>
*
* @param s
* @return
*/
public static String removeSufixZero(String s) {
if (s == null) {
return "";
}
while (s.endsWith("0")) {
if (s.equals("0")) {
s = "";
break;
}
s = s.substring(0, s.length() - 1);
}
return s;
}
public static String transforCode(String code) {
if (code.endsWith("0000000")) {
code = code.substring(0, 1);
} else if (code.endsWith("000000")) {
code = code.substring(0, 2);
} else if (code.endsWith("0000")) {
code = code.substring(0, 4);
} else if (code.endsWith("00")) {
code = code.substring(0, 6);
}
return code;
}
/**
* 获取支队orgCode
*
* @param orgCode
* @return
*/
public static String getDetachmentOrgCode(String orgCode) {
Assert.notNull(orgCode, "组织结构orgCode不能为空!");
String[] codes = orgCode.split("\\*");
if (codes.length < 2) {
throw new IllegalArgumentException("组织结构orgCode为总队,不能获取支队orgCode!");
} else {
return codes[0] + "*" + codes[1];
}
}
}
package com.yeejoin.amos.jpush.service.exception;
/**
*
* <pre>
* 自定义异常
* </pre>
*
* @author as-youjun
* @version $Id: YeeException.java, v 0.1 2017年7月18日 上午9:34:21 as-youjun Exp $
*/
public class YeeException extends RuntimeException {
/**
* <pre>
*
* </pre>
*/
private static final long serialVersionUID = -1963401137898098411L;
private int errorCode = 0;
public YeeException(int errorCode) {
this.errorCode = errorCode;
}
public YeeException(String message, int errorCode) {
super(message);
this.errorCode = errorCode;
}
public YeeException(String message) {
super(message);
}
public YeeException(String message, Throwable cause, int errorCode) {
super(message, cause);
this.errorCode = errorCode;
}
public YeeException(Throwable cause, int errorCode) {
super(cause);
this.errorCode = errorCode;
}
public YeeException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace,
int errorCode) {
super(message, cause, enableSuppression, writableStackTrace);
this.errorCode = errorCode;
}
/**
* Getter method for property <tt>errorCode</tt>.
*
* @return property value of errorCode
*/
public int getErrorCode() {
return errorCode;
}
/**
* Setter method for property <tt>errorCode</tt>.
*
* @param errorCode
* value to be assigned to property errorCode
*/
public void setErrorCode(int errorCode) {
this.errorCode = errorCode;
}
}
package com.yeejoin.amos.jpush.service.jpush;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.Base64;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpDelete;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
import com.alibaba.fastjson.JSON;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.collect.Lists;
import com.yeejoin.amos.jpush.common.enums.JPushTypeEnum;
import com.yeejoin.amos.jpush.service.business.param.PushMsgParam;
import cn.jiguang.common.resp.APIConnectionException;
import cn.jiguang.common.resp.APIRequestException;
import cn.jpush.api.JPushClient;
import cn.jpush.api.push.model.Options;
import cn.jpush.api.push.model.Platform;
import cn.jpush.api.push.model.PushPayload;
import cn.jpush.api.push.model.PushPayload.Builder;
import cn.jpush.api.push.model.audience.Audience;
import cn.jpush.api.push.model.notification.AndroidNotification;
import cn.jpush.api.push.model.notification.Notification;
@Service
@Component
public class AppMessagePushService {
protected static final Logger log = LoggerFactory
.getLogger(AppMessagePushService.class);
@Value("${params.isPush}")
private String isPush;
private static RestTemplate restTemplate;
private static ObjectMapper objectMapper = new ObjectMapper();
//端口443
protected static final String URL ="https://device.jpush.cn/";
protected static final String APP_KEY = "1b3f7b961200f4b236811dfe";
protected static final String MASTER_SECRET = "8b650e645fb3a43c96be02b2";
private static JPushClient jpushClient = new JPushClient(MASTER_SECRET,
APP_KEY);
public static String buildJpushUserKey(String userId) {
// return XJConstant.JPUSH_USER_KEY + "_" + userId;
return userId;
}
public void sendMessage(List<PushMsgParam> responses) {
try {
if (responses != null && "true".equals(isPush)) {
for (PushMsgParam response : responses) {
PushPayload payload = buildPushPayload(response);
jpushClient.sendPush(payload);
}
}
} catch (Exception e) {
log.error(e.getMessage(), e);
e.printStackTrace();
}
}
public static PushPayload buildPushPayload(PushMsgParam response) {
Builder builder= PushPayload.newBuilder();
builder.setPlatform(Platform.all());
//设置如果用户不在线、离线消息保存的时间
Options options=Options.sendno();
options.setTimeToLive(86400l);
options.setApnsProduction(true);
builder.setOptions(options);
//设置推送方式
List<String> recivers = response.getRecivers();
List<String> users = Lists.newArrayList();
recivers.forEach(e -> users.add(buildJpushUserKey(e)));
if (JPushTypeEnum.ALL.getCode().equals(response.getType())) {
builder.setAudience(Audience.all());//Audience设置为all,说明采用广播方式推送,所有用户都可以接收到
} else if (JPushTypeEnum.TAG.getCode().equals(response.getType())) {
builder.setAudience(Audience.tag(users));//根据标签推送
} else {
builder.setAudience(Audience.alias(users));//根据别名推送
}
builder.setNotification(Notification.newBuilder()
.addPlatformNotification(AndroidNotification.newBuilder().addExtras(response.getExtras()).setAlert(response.getContent()).setTitle(response.getSubject()).build())
.build());
PushPayload pushPayload=builder.build();
return pushPayload;
}
public void sendMessage(PushMsgParam response) {
try {
if (null != response && "true".equals(isPush)) {
Builder builder= PushPayload.newBuilder();
builder.setPlatform(Platform.all());
Options options=Options.sendno();
options.setTimeToLive(86400l);
options.setApnsProduction(true);
builder.setOptions(options);
//设置推送方式
List<String> recivers = response.getRecivers();
List<String> users = Lists.newArrayList();
recivers.forEach(e -> users.add(buildJpushUserKey(e)));
builder.setAudience(Audience.all());
builder.setNotification(Notification.newBuilder()
.addPlatformNotification(AndroidNotification.newBuilder().addExtras(response.getExtras()).setAlert(response.getContent()).setTitle(response.getSubject()).build())
.build());
PushPayload payload=builder.build();
jpushClient.sendPush(payload);
}
} catch (Exception e) {
log.error(e.getMessage(), e);
e.printStackTrace();
}
}
public static void pushNoticeMany( PushMsgParam response){
PushPayload payload = buildPushPayload(response);
try {
jpushClient.sendPush(payload);
} catch (APIConnectionException e) {
e.printStackTrace();
} catch (APIRequestException e) {
e.printStackTrace();
}
}
//删除一个别名,以及该别名与设备的绑定关系。
public static boolean PushDevice(String alias) {
CloseableHttpClient httpClient = null;
CloseableHttpResponse httpResponse = null;
try {
httpClient = HttpClients.createDefault();
HttpDelete httpDelete = new HttpDelete(URL +"v3/aliases/"+alias);
RequestConfig requestConfig = RequestConfig.custom().setConnectTimeout(35000)
.setConnectionRequestTimeout(35000)
.setSocketTimeout(60000)
.build();
httpDelete.setConfig(requestConfig);
httpDelete.addHeader("Accept", "application/json");
httpDelete.addHeader("Authorization", "Basic "+Base64(APP_KEY+":"+MASTER_SECRET));
httpResponse = httpClient.execute(httpDelete);
return true;
} catch (Exception e) {
e.printStackTrace();
return false;
} finally {
// 关闭资源
if (null != httpResponse) {
try {
httpResponse.close();
} catch (IOException e) {
e.printStackTrace();
}
}
if (null != httpClient) {
try {
httpClient.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
//设置设备的别名与标签
public static boolean PushDeviceRegistration(String registrationId,String alias) {
CloseableHttpClient httpClient = null;
CloseableHttpResponse httpResponse = null;
try {
httpClient = HttpClients.createDefault();
HttpPost httpPost = new HttpPost(URL +"v3/devices/"+registrationId);
RequestConfig requestConfig = RequestConfig.custom().setConnectTimeout(35000)
.setConnectionRequestTimeout(35000)
.setSocketTimeout(60000)
.build();
httpPost.setConfig(requestConfig);
httpPost.addHeader("Accept", "application/json");
httpPost.addHeader("Authorization", "Basic "+Base64(APP_KEY+":"+MASTER_SECRET));
if (null != alias ) {
Map<String, Object> nvps = new HashMap<>();
// 通过map集成entrySet方法获取entity
nvps.put("alias", alias);
nvps.put("tags", "");
nvps.put("mobile", "");
String json= JSON.toJSONString(nvps);
StringEntity stringEntity = new StringEntity(json,"UTF-8");//解决中文乱码问题
httpPost.setEntity(stringEntity);
httpResponse = httpClient.execute(httpPost);
return true;
}else{
return false;
}
} catch (Exception e) {
e.printStackTrace();
return false;
} finally {
// 关闭资源
if (null != httpResponse) {
try {
httpResponse.close();
} catch (IOException e) {
e.printStackTrace();
}
}
if (null != httpClient) {
try {
httpClient.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
//Base64转码
public static String Base64(String code) {
final Base64.Encoder encoder = Base64.getEncoder();
byte[] textByte;
try {
textByte = code.getBytes("UTF-8");
//编码
String encodedText = encoder.encodeToString(textByte);
return encodedText;
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
return "";
}
}
}
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <project xmlns="http://maven.apache.org/POM/4.0.0"
<modelVersion>4.0.0</modelVersion> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<parent> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<artifactId>amos-boot-module-biz</artifactId> <modelVersion>4.0.0</modelVersion>
<groupId>com.amosframework.boot</groupId> <parent>
<version>1.0.0</version> <artifactId>amos-boot-module-biz</artifactId>
</parent> <groupId>com.amosframework.boot</groupId>
<version>1.0.0</version>
</parent>
<artifactId>amos-boot-module-knowledgebase-biz</artifactId> <artifactId>amos-boot-module-knowledgebase-biz</artifactId>
<name>amos-boot-module-knowledgebase-biz</name> <name>amos-boot-module-knowledgebase-biz</name>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>com.amosframework.boot</groupId> <groupId>com.amosframework.boot</groupId>
<artifactId>amos-boot-biz-common</artifactId> <artifactId>amos-boot-module-knowledgebase-api</artifactId>
<version>${amos-biz-boot.version}</version> <version>${amos-biz-boot.version}</version>
</dependency> </dependency>
<dependency> </dependencies>
<groupId>org.typroject</groupId>
<artifactId>tyboot-component-emq</artifactId>
<version>${tyboot-version}</version>
<exclusions>
<exclusion>
<groupId>org.typroject</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- 规则模块 -->
<dependency>
<groupId>com.yeejoin</groupId>
<artifactId>amos-component-rule</artifactId>
<version>${amos.version}</version>
</dependency>
<!-- 解析word -->
<dependency>
<groupId>org.docx4j</groupId>
<artifactId>docx4j</artifactId>
<version>3.3.6</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.docx4j</groupId>
<artifactId>docx4j-ImportXHTML</artifactId>
<version>3.3.6</version>
</dependency>
<dependency>
<groupId>org.docx4j</groupId>
<artifactId>docx4j-export-fo</artifactId>
<version>3.3.6</version>
</dependency>
<!-- 解析html -->
<dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<version>1.11.2</version>
</dependency>
<!-- 解析pdf -->
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>kernel</artifactId>
<version>${itext.version}</version>
</dependency>
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>layout</artifactId>
<version>${itext.version}</version>
</dependency>
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>html2pdf</artifactId>
<version>2.0.1</version>
</dependency>
<!-- 解析excel -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>4.0.1</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>4.0.1</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-elasticsearch</artifactId>
</dependency>
</dependencies>
</project> </project>
package com.yeejoin.amos.knowledgebase.controller; package com.yeejoin.amos.knowledgebase.controller;
import com.alibaba.fastjson.JSON; import java.util.Map;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.knowledgebase.face.service.DocContentService; import javax.servlet.http.HttpServletRequest;
import com.yeejoin.amos.knowledgebase.face.service.DocLibraryService; import javax.servlet.http.HttpServletResponse;
import com.yeejoin.amos.knowledgebase.face.service.ESDocService;
import com.yeejoin.amos.knowledgebase.face.util.excel.ExcelImportConfig;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import org.typroject.tyboot.core.foundation.context.RequestContext; import org.typroject.tyboot.core.foundation.context.RequestContext;
import org.typroject.tyboot.core.foundation.enumeration.UserType; import org.typroject.tyboot.core.foundation.enumeration.UserType;
...@@ -20,9 +23,15 @@ import org.typroject.tyboot.core.restful.exception.instance.BadRequest; ...@@ -20,9 +23,15 @@ import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import org.typroject.tyboot.core.restful.utils.ResponseHelper; import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel; import org.typroject.tyboot.core.restful.utils.ResponseModel;
import javax.servlet.http.HttpServletRequest; import com.alibaba.fastjson.JSON;
import javax.servlet.http.HttpServletResponse; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import java.util.Map; import com.yeejoin.amos.knowledgebase.face.service.DocLibraryService;
import com.yeejoin.amos.knowledgebase.face.service.ESDocService;
import com.yeejoin.amos.knowledgebase.face.util.Constants;
import com.yeejoin.amos.knowledgebase.face.util.excel.ExcelImportConfig;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
/** /**
* <p> * <p>
...@@ -64,7 +73,7 @@ public class DocLibraryResource { ...@@ -64,7 +73,7 @@ public class DocLibraryResource {
@RequestParam(value = "createTimeLeft", required = false) String createTimeLeft, @RequestParam(value = "createTimeLeft", required = false) String createTimeLeft,
@RequestParam(value = "createTimeRight", required = false) String createTimeRight) { @RequestParam(value = "createTimeRight", required = false) String createTimeRight) {
Map requestMap = request.getParameterMap(); Map requestMap = request.getParameterMap();
Page page = docLibraryService.queryDocList(offset, end, directoryId, docTitle, null, DocContentService.DOC_STATUS_PUBLISHED, Page page = docLibraryService.queryDocList(offset, end, directoryId, docTitle, null, Constants.DOC_STATUS_PUBLISHED,
requestMap, createTimeLeft, createTimeRight, Boolean.parseBoolean(filterByCollection), false); requestMap, createTimeLeft, createTimeRight, Boolean.parseBoolean(filterByCollection), false);
return ResponseHelper.buildResponse(page); return ResponseHelper.buildResponse(page);
} }
......
package com.yeejoin.amos.knowledgebase.controller; package com.yeejoin.amos.knowledgebase.controller;
import com.yeejoin.amos.knowledgebase.face.model.KnowledgeTagModel;
import com.yeejoin.amos.knowledgebase.face.service.TagService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.RequestBody;
import org.typroject.tyboot.core.foundation.context.RequestContext; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.typroject.tyboot.core.foundation.enumeration.UserType; import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.foundation.utils.StringUtil; import org.typroject.tyboot.core.foundation.utils.StringUtil;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil; import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
...@@ -19,6 +18,13 @@ import org.typroject.tyboot.core.restful.exception.instance.BadRequest; ...@@ -19,6 +18,13 @@ import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import org.typroject.tyboot.core.restful.utils.ResponseHelper; import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel; import org.typroject.tyboot.core.restful.utils.ResponseModel;
import com.yeejoin.amos.knowledgebase.face.model.KnowledgeTagModel;
import com.yeejoin.amos.knowledgebase.face.service.TagService;
import com.yeejoin.amos.knowledgebase.face.util.Constants;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
/** /**
* <p> * <p>
* 标签库 前端控制器 * 标签库 前端控制器
...@@ -101,7 +107,7 @@ public class TagResource { ...@@ -101,7 +107,7 @@ public class TagResource {
@ApiOperation(value = "查询TOP15") @ApiOperation(value = "查询TOP15")
@RequestMapping(value = "/list/top", method = RequestMethod.GET) @RequestMapping(value = "/list/top", method = RequestMethod.GET)
public ResponseModel selectForList(@RequestParam(value = "quoteType", required = false) String quoteType) { public ResponseModel selectForList(@RequestParam(value = "quoteType", required = false) String quoteType) {
boolean isAll = ValidationUtil.equalsIgnoreCase(quoteType, TagService.APPKEY_ALL); boolean isAll = ValidationUtil.equalsIgnoreCase(quoteType, Constants.APPKEY_ALL);
return ResponseHelper.buildResponse(tagService.queryTopList(isAll)); return ResponseHelper.buildResponse(tagService.queryTopList(isAll));
} }
...@@ -117,14 +123,14 @@ public class TagResource { ...@@ -117,14 +123,14 @@ public class TagResource {
@ApiOperation(value = "启用标签") @ApiOperation(value = "启用标签")
@RequestMapping(value = "status/activate/{ids}", method = RequestMethod.PUT) @RequestMapping(value = "status/activate/{ids}", method = RequestMethod.PUT)
public ResponseModel batchActivate(@PathVariable(value = "ids") String ids) { public ResponseModel batchActivate(@PathVariable(value = "ids") String ids) {
return ResponseHelper.buildResponse(tagService.updateTagStatus(StringUtil.String2LongList(ids), TagService.TAG_STATUS_ACTIVATE)); return ResponseHelper.buildResponse(tagService.updateTagStatus(StringUtil.String2LongList(ids), Constants.TAG_STATUS_ACTIVATE));
} }
@TycloudOperation(ApiLevel = UserType.AGENCY) @TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "停用标签") @ApiOperation(value = "停用标签")
@RequestMapping(value = "status/deactivate/{ids}", method = RequestMethod.PUT) @RequestMapping(value = "status/deactivate/{ids}", method = RequestMethod.PUT)
public ResponseModel batchDeactivate(@PathVariable(value = "ids") String ids) { public ResponseModel batchDeactivate(@PathVariable(value = "ids") String ids) {
return ResponseHelper.buildResponse(tagService.updateTagStatus(StringUtil.String2LongList(ids), TagService.TAG_STATUS_DEACTIVATE)); return ResponseHelper.buildResponse(tagService.updateTagStatus(StringUtil.String2LongList(ids), Constants.TAG_STATUS_DEACTIVATE));
} }
@TycloudOperation(ApiLevel = UserType.AGENCY) @TycloudOperation(ApiLevel = UserType.AGENCY)
......
package com.yeejoin.amos.knowledgebase.face.util; package com.yeejoin.amos.knowledgebase.face.feign;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.typroject.tyboot.core.foundation.context.RequestContext;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import com.yeejoin.amos.component.feign.utils.FeignUtil; import com.yeejoin.amos.component.feign.utils.FeignUtil;
import com.yeejoin.amos.feign.privilege.Privilege; import com.yeejoin.amos.feign.privilege.Privilege;
import com.yeejoin.amos.feign.privilege.model.AgencyUserModel; import com.yeejoin.amos.feign.privilege.model.AgencyUserModel;
import com.yeejoin.amos.feign.privilege.model.RoleModel; import com.yeejoin.amos.feign.privilege.model.RoleModel;
import org.typroject.tyboot.core.foundation.context.RequestContext;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import sun.util.resources.cldr.vai.CalendarData_vai_Latn_LR;
import java.util.*;
/** /**
* @author 杨博超 * @author 杨博超
......
package com.yeejoin.amos.knowledgebase.face.util; package com.yeejoin.amos.knowledgebase.face.feign;
import com.google.common.base.Joiner; import com.google.common.base.Joiner;
import com.yeejoin.amos.component.feign.utils.FeignUtil; import com.yeejoin.amos.component.feign.utils.FeignUtil;
......
package com.yeejoin.amos.knowledgebase.face.service; package com.yeejoin.amos.knowledgebase.face.service;
import com.yeejoin.amos.knowledgebase.face.model.KnowledgeDocAnnotateModel; import java.util.Date;
import com.yeejoin.amos.knowledgebase.face.orm.dao.DocAnnotateMapper; import java.util.List;
import com.yeejoin.amos.knowledgebase.face.orm.entity.KnowledgeDocAnnotate; import java.util.Map;
import com.yeejoin.amos.knowledgebase.face.util.RemoteData; import java.util.Set;
import java.util.stream.Collectors;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
...@@ -14,11 +16,10 @@ import org.typroject.tyboot.core.foundation.utils.Bean; ...@@ -14,11 +16,10 @@ import org.typroject.tyboot.core.foundation.utils.Bean;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil; import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.rdbms.service.BaseService; import org.typroject.tyboot.core.rdbms.service.BaseService;
import java.util.Date; import com.yeejoin.amos.knowledgebase.face.feign.RemoteData;
import java.util.List; import com.yeejoin.amos.knowledgebase.face.model.KnowledgeDocAnnotateModel;
import java.util.Map; import com.yeejoin.amos.knowledgebase.face.orm.dao.DocAnnotateMapper;
import java.util.Set; import com.yeejoin.amos.knowledgebase.face.orm.entity.KnowledgeDocAnnotate;
import java.util.stream.Collectors;
/** /**
......
package com.yeejoin.amos.knowledgebase.face.service; package com.yeejoin.amos.knowledgebase.face.service;
import com.alibaba.fastjson.JSON; import java.util.ArrayList;
import com.alibaba.fastjson.JSONObject; import java.util.Collection;
import com.yeejoin.amos.component.rule.action.Topic; import java.util.Iterator;
import com.yeejoin.amos.component.rule.config.ClazzUtils; import java.util.List;
import com.yeejoin.amos.component.rule.config.RuleConfig; import java.util.concurrent.atomic.AtomicBoolean;
import com.yeejoin.amos.component.rule.model.ConstantCategoryModel; import java.util.concurrent.atomic.AtomicReference;
import com.yeejoin.amos.component.rule.model.ConstantModel;
import com.yeejoin.amos.component.rule.model.DefinitionModel;
import com.yeejoin.amos.knowledgebase.face.model.KnowledgeDocContentModel;
import com.yeejoin.amos.knowledgebase.face.model.KnowledgeTagInstanceModel;
import com.yeejoin.amos.knowledgebase.face.model.KnowledgeTagValueModel;
import com.yeejoin.amos.knowledgebase.face.util.BaseUtil;
import com.yeejoin.amos.knowledgebase.face.util.ConfigLoader;
import com.yeejoin.amos.knowledgebase.face.util.QuoteCountFlushTiming;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -31,12 +24,21 @@ import org.typroject.tyboot.core.foundation.utils.ValidationUtil; ...@@ -31,12 +24,21 @@ import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.restful.exception.instance.DataNotFound; import org.typroject.tyboot.core.restful.exception.instance.DataNotFound;
import org.typroject.tyboot.core.restful.exception.instance.RequestForbidden; import org.typroject.tyboot.core.restful.exception.instance.RequestForbidden;
import java.util.ArrayList; import com.alibaba.fastjson.JSON;
import java.util.Collection; import com.alibaba.fastjson.JSONObject;
import java.util.Iterator; import com.yeejoin.amos.component.rule.action.Topic;
import java.util.List; import com.yeejoin.amos.component.rule.config.ClazzUtils;
import java.util.concurrent.atomic.AtomicBoolean; import com.yeejoin.amos.component.rule.config.RuleConfig;
import java.util.concurrent.atomic.AtomicReference; import com.yeejoin.amos.component.rule.model.ConstantCategoryModel;
import com.yeejoin.amos.component.rule.model.ConstantModel;
import com.yeejoin.amos.component.rule.model.DefinitionModel;
import com.yeejoin.amos.knowledgebase.face.model.KnowledgeDocContentModel;
import com.yeejoin.amos.knowledgebase.face.model.KnowledgeTagInstanceModel;
import com.yeejoin.amos.knowledgebase.face.model.KnowledgeTagValueModel;
import com.yeejoin.amos.knowledgebase.face.util.BaseUtil;
import com.yeejoin.amos.knowledgebase.face.util.ConfigLoader;
import com.yeejoin.amos.knowledgebase.face.util.Constants;
import com.yeejoin.amos.knowledgebase.face.util.QuoteCountFlushTiming;
/** /**
...@@ -50,26 +52,6 @@ import java.util.concurrent.atomic.AtomicReference; ...@@ -50,26 +52,6 @@ import java.util.concurrent.atomic.AtomicReference;
@Component @Component
public class DocAuditService { public class DocAuditService {
/**
* 审核状态--待提交
*/
public static final String DOC_AUDIT_STATUS_SAVED = "SAVED";
/**
* 审核状态--待审核
*/
public static final String DOC_AUDIT_STATUS_SUBMITTED = "SUBMITTED";
/**
* 审核状态--通过
*/
public static final String DOC_AUDIT_STATUS_PASSED = "PASSED";
/**
* 审核状态--驳回
*/
public static final String DOC_AUDIT_STATUS_REJECTED = "REJECTED";
private static final String TAG_INSTANCE_LABEL = "label";
private static String DELETE_SYNC_PLAN_TOPIC = "DELETE_SYNC_PLAN_DOC";
@Autowired @Autowired
private DocContentService service; private DocContentService service;
...@@ -103,9 +85,9 @@ public class DocAuditService { ...@@ -103,9 +85,9 @@ public class DocAuditService {
} }
//更新状态 //更新状态
for (KnowledgeDocContentModel oldDoc : resList) { for (KnowledgeDocContentModel oldDoc : resList) {
if (ValidationUtil.equals(oldDoc.getDocStatus(), DocContentService.DOC_STATUS_UNPUBLISHED)) { if (ValidationUtil.equals(oldDoc.getDocStatus(), Constants.DOC_STATUS_UNPUBLISHED)) {
oldDoc.setDocStatus(DocContentService.DOC_STATUS_PUBLISHED); oldDoc.setDocStatus(Constants.DOC_STATUS_PUBLISHED);
oldDoc.setAuditStatus(DOC_AUDIT_STATUS_PASSED); oldDoc.setAuditStatus(Constants.DOC_AUDIT_STATUS_PASSED);
oldDoc.setAuditorUserId(RequestContext.getExeUserId()); oldDoc.setAuditorUserId(RequestContext.getExeUserId());
service.updateWithModel(oldDoc); service.updateWithModel(oldDoc);
} else { } else {
...@@ -136,13 +118,13 @@ public class DocAuditService { ...@@ -136,13 +118,13 @@ public class DocAuditService {
throw new DataNotFound("数据不存在"); throw new DataNotFound("数据不存在");
} }
for (KnowledgeDocContentModel oldDoc : resList) { for (KnowledgeDocContentModel oldDoc : resList) {
if (ValidationUtil.equals(oldDoc.getDocStatus(), DocContentService.DOC_STATUS_PUBLISHED)) { if (ValidationUtil.equals(oldDoc.getDocStatus(), Constants.DOC_STATUS_PUBLISHED)) {
//判断文档是否被引用 //判断文档是否被引用
if (service.getReference(oldDoc.getSequenceNbr()) > 0) { if (service.getReference(oldDoc.getSequenceNbr()) > 0) {
throw new RequestForbidden("含被引用文档,不能取消发布"); throw new RequestForbidden("含被引用文档,不能取消发布");
} }
oldDoc.setDocStatus(DocContentService.DOC_STATUS_UNPUBLISHED); oldDoc.setDocStatus(Constants.DOC_STATUS_UNPUBLISHED);
oldDoc.setAuditStatus(DOC_AUDIT_STATUS_SAVED); oldDoc.setAuditStatus(Constants.DOC_AUDIT_STATUS_SAVED);
oldDoc.setAuditorUserId(RequestContext.getExeUserId()); oldDoc.setAuditorUserId(RequestContext.getExeUserId());
service.updateWithModel(oldDoc); service.updateWithModel(oldDoc);
} else { } else {
...@@ -173,9 +155,9 @@ public class DocAuditService { ...@@ -173,9 +155,9 @@ public class DocAuditService {
throw new DataNotFound("数据不存在"); throw new DataNotFound("数据不存在");
} }
for (KnowledgeDocContentModel oldDoc : resList) { for (KnowledgeDocContentModel oldDoc : resList) {
if (ValidationUtil.equals(oldDoc.getAuditStatus(), DOC_AUDIT_STATUS_SAVED)) { if (ValidationUtil.equals(oldDoc.getAuditStatus(), Constants.DOC_AUDIT_STATUS_SAVED)) {
//更新审核状态 //更新审核状态
oldDoc.setAuditStatus(DOC_AUDIT_STATUS_SUBMITTED); oldDoc.setAuditStatus(Constants.DOC_AUDIT_STATUS_SUBMITTED);
service.updateWithModel(oldDoc); service.updateWithModel(oldDoc);
} else { } else {
throw new RequestForbidden("只允许对待提交状态的文档执行此操作"); throw new RequestForbidden("只允许对待提交状态的文档执行此操作");
...@@ -197,12 +179,12 @@ public class DocAuditService { ...@@ -197,12 +179,12 @@ public class DocAuditService {
throw new DataNotFound("数据不存在"); throw new DataNotFound("数据不存在");
} }
for (KnowledgeDocContentModel oldDoc : resList) { for (KnowledgeDocContentModel oldDoc : resList) {
if (ValidationUtil.equals(oldDoc.getAuditStatus(), DOC_AUDIT_STATUS_SUBMITTED)) { if (ValidationUtil.equals(oldDoc.getAuditStatus(), Constants.DOC_AUDIT_STATUS_SUBMITTED)) {
//更新审核状态 //更新审核状态
oldDoc.setAuditStatus(DOC_AUDIT_STATUS_PASSED); oldDoc.setAuditStatus(Constants.DOC_AUDIT_STATUS_PASSED);
oldDoc.setAuditorUserId(RequestContext.getExeUserId()); oldDoc.setAuditorUserId(RequestContext.getExeUserId());
//更新文档发布状态 //更新文档发布状态
oldDoc.setDocStatus(DocContentService.DOC_STATUS_PUBLISHED); oldDoc.setDocStatus(Constants.DOC_STATUS_PUBLISHED);
service.updateWithModel(oldDoc); service.updateWithModel(oldDoc);
} else { } else {
throw new RequestForbidden("只允许对待审核状态的文档执行此操作"); throw new RequestForbidden("只允许对待审核状态的文档执行此操作");
...@@ -231,12 +213,12 @@ public class DocAuditService { ...@@ -231,12 +213,12 @@ public class DocAuditService {
if (ValidationUtil.isEmpty(oldDoc)) { if (ValidationUtil.isEmpty(oldDoc)) {
throw new DataNotFound("数据不存在"); throw new DataNotFound("数据不存在");
} }
if (ValidationUtil.equals(oldDoc.getAuditStatus(), DOC_AUDIT_STATUS_SUBMITTED)) { if (ValidationUtil.equals(oldDoc.getAuditStatus(), Constants.DOC_AUDIT_STATUS_SUBMITTED)) {
//更新审核状态&文档状态 //更新审核状态&文档状态
oldDoc.setAuditStatus(DOC_AUDIT_STATUS_REJECTED); oldDoc.setAuditStatus(Constants.DOC_AUDIT_STATUS_REJECTED);
oldDoc.setRejectionComment(rejectionComment); oldDoc.setRejectionComment(rejectionComment);
oldDoc.setAuditorUserId(RequestContext.getExeUserId()); oldDoc.setAuditorUserId(RequestContext.getExeUserId());
oldDoc.setDocStatus(DocContentService.DOC_STATUS_UNPUBLISHED); oldDoc.setDocStatus(Constants.DOC_STATUS_UNPUBLISHED);
return service.updateWithModel(oldDoc); return service.updateWithModel(oldDoc);
} else { } else {
throw new RequestForbidden("只允许对待审核状态的文档执行此操作"); throw new RequestForbidden("只允许对待审核状态的文档执行此操作");
...@@ -251,7 +233,7 @@ public class DocAuditService { ...@@ -251,7 +233,7 @@ public class DocAuditService {
public void pushDeletedDocs2DigitalPlanByMQ(List<KnowledgeDocContentModel> resList) { public void pushDeletedDocs2DigitalPlanByMQ(List<KnowledgeDocContentModel> resList) {
List<Long> ids = BaseUtil.getModelIds(resList); List<Long> ids = BaseUtil.getModelIds(resList);
try { try {
emqKeeper.getMqttClient().publish(DELETE_SYNC_PLAN_TOPIC, ClazzUtils.serializableObject(ids), RuleConfig.DEFAULT_QOS, false); emqKeeper.getMqttClient().publish(Constants.DELETE_SYNC_PLAN_TOPIC, ClazzUtils.serializableObject(ids), RuleConfig.DEFAULT_QOS, false);
logger.info("文档" + ids.toString() + "取消发布,已推送消息至数字预案服务"); logger.info("文档" + ids.toString() + "取消发布,已推送消息至数字预案服务");
} catch (Exception e) { } catch (Exception e) {
logger.fatal("文档" + ids.toString() + "取消发布未能成功推送至数字预案服务", e); logger.fatal("文档" + ids.toString() + "取消发布未能成功推送至数字预案服务", e);
...@@ -364,13 +346,13 @@ public class DocAuditService { ...@@ -364,13 +346,13 @@ public class DocAuditService {
AtomicReference<String> unit = new AtomicReference<>(""); AtomicReference<String> unit = new AtomicReference<>("");
if (!ObjectUtils.isEmpty(values)) { if (!ObjectUtils.isEmpty(values)) {
values.forEach(value -> { values.forEach(value -> {
if (TagValueService.VALUE_TAG_FIELD_RANGE_MAX.equals(value.getFieldName())) { if (Constants.VALUE_TAG_FIELD_RANGE_MAX.equals(value.getFieldName())) {
resRight.set(value.getTagValue()); resRight.set(value.getTagValue());
} else { } else {
resLeft.set(value.getTagValue()); resLeft.set(value.getTagValue());
} }
if (TagValueService.VALUE_TAG_FIELD_RANGE_MAX.equals(value.getFieldName()) if (Constants.VALUE_TAG_FIELD_RANGE_MAX.equals(value.getFieldName())
|| TagValueService.VALUE_TAG_FIELD_RANGE_MIN.equals(value.getFieldName())) { || Constants.VALUE_TAG_FIELD_RANGE_MIN.equals(value.getFieldName())) {
isRange.set(true); isRange.set(true);
} }
unit.set(ValidationUtil.isEmpty(value.getUnit()) || "null".equals(value.getUnit()) ? "" : value.getUnit()); unit.set(ValidationUtil.isEmpty(value.getUnit()) || "null".equals(value.getUnit()) ? "" : value.getUnit());
...@@ -393,7 +375,7 @@ public class DocAuditService { ...@@ -393,7 +375,7 @@ public class DocAuditService {
if (!ValidationUtil.isEmpty(frontEndConfig)) { if (!ValidationUtil.isEmpty(frontEndConfig)) {
try { try {
JSONObject configObject = JSON.parseObject(frontEndConfig); JSONObject configObject = JSON.parseObject(frontEndConfig);
return (String) configObject.get(TAG_INSTANCE_LABEL); return (String) configObject.get(Constants.TAG_INSTANCE_LABEL);
} catch (Exception e) { } catch (Exception e) {
} }
} }
......
package com.yeejoin.amos.knowledgebase.face.service; package com.yeejoin.amos.knowledgebase.face.service;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import java.util.ArrayList;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import java.util.Arrays;
import com.yeejoin.amos.knowledgebase.face.model.KnowledgeDocCategoryModel; import java.util.Collection;
import com.yeejoin.amos.knowledgebase.face.model.MultipleNodeModel; import java.util.Collections;
import com.yeejoin.amos.knowledgebase.face.orm.dao.DocCategoryMapper; import java.util.List;
import com.yeejoin.amos.knowledgebase.face.orm.entity.KnowledgeDocCategory; import java.util.Map;
import com.yeejoin.amos.knowledgebase.face.orm.entity.KnowledgeTag; import java.util.SortedSet;
import com.yeejoin.amos.knowledgebase.face.util.BaseUtil; import java.util.TreeSet;
import com.yeejoin.amos.knowledgebase.face.util.TreeUtil;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
...@@ -24,7 +24,16 @@ import org.typroject.tyboot.core.rdbms.service.BaseService; ...@@ -24,7 +24,16 @@ import org.typroject.tyboot.core.rdbms.service.BaseService;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest; import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import org.typroject.tyboot.core.restful.exception.instance.RequestForbidden; import org.typroject.tyboot.core.restful.exception.instance.RequestForbidden;
import java.util.*; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.knowledgebase.face.model.KnowledgeDocCategoryModel;
import com.yeejoin.amos.knowledgebase.face.model.MultipleNodeModel;
import com.yeejoin.amos.knowledgebase.face.orm.dao.DocCategoryMapper;
import com.yeejoin.amos.knowledgebase.face.orm.entity.KnowledgeDocCategory;
import com.yeejoin.amos.knowledgebase.face.orm.entity.KnowledgeTag;
import com.yeejoin.amos.knowledgebase.face.util.BaseUtil;
import com.yeejoin.amos.knowledgebase.face.util.Constants;
import com.yeejoin.amos.knowledgebase.face.util.TreeUtil;
/** /**
* <p> * <p>
...@@ -203,7 +212,7 @@ public class DocCategoryService extends BaseService<KnowledgeDocCategoryModel, K ...@@ -203,7 +212,7 @@ public class DocCategoryService extends BaseService<KnowledgeDocCategoryModel, K
List<KnowledgeDocCategoryModel> allChildren = TreeUtil.getAllChildren(categoryTree); List<KnowledgeDocCategoryModel> allChildren = TreeUtil.getAllChildren(categoryTree);
if (!allChildren.isEmpty()) { if (!allChildren.isEmpty()) {
List<Long> directoryIds = BaseUtil.getModelIds(allChildren); List<Long> directoryIds = BaseUtil.getModelIds(allChildren);
List<MultipleNodeModel> multipleNodeModels = this.baseMapper.queryDocAndCategoryTree(directoryIds, onlyPublish ? DocContentService.DOC_STATUS_PUBLISHED : null); List<MultipleNodeModel> multipleNodeModels = this.baseMapper.queryDocAndCategoryTree(directoryIds, onlyPublish ? Constants.DOC_STATUS_PUBLISHED : null);
return TreeBuilder.buildByRecursive(multipleNodeModels, null == rootCategory ? root : rootCategory.getParentId()); return TreeBuilder.buildByRecursive(multipleNodeModels, null == rootCategory ? root : rootCategory.getParentId());
} }
} }
......
package com.yeejoin.amos.knowledgebase.face.service; package com.yeejoin.amos.knowledgebase.face.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import java.util.Date;
import com.yeejoin.amos.knowledgebase.face.enumeration.OperateType; import java.util.List;
import com.yeejoin.amos.knowledgebase.face.model.KnowledgeDocCommentsModel;
import com.yeejoin.amos.knowledgebase.face.model.KnowledgeInteractionRecordModel;
import com.yeejoin.amos.knowledgebase.face.orm.dao.DocCommentsMapper;
import com.yeejoin.amos.knowledgebase.face.orm.entity.KnowledgeDocComments;
import com.yeejoin.amos.knowledgebase.face.util.RemoteData;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.typroject.tyboot.core.foundation.context.RequestContext; import org.typroject.tyboot.core.foundation.context.RequestContext;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil; import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.rdbms.service.BaseService; import org.typroject.tyboot.core.rdbms.service.BaseService;
import java.util.Date; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import java.util.List; import com.yeejoin.amos.knowledgebase.face.enumeration.OperateType;
import com.yeejoin.amos.knowledgebase.face.feign.RemoteData;
import com.yeejoin.amos.knowledgebase.face.model.KnowledgeDocCommentsModel;
import com.yeejoin.amos.knowledgebase.face.model.KnowledgeInteractionRecordModel;
import com.yeejoin.amos.knowledgebase.face.orm.dao.DocCommentsMapper;
import com.yeejoin.amos.knowledgebase.face.orm.entity.KnowledgeDocComments;
/** /**
......
...@@ -11,13 +11,14 @@ import com.yeejoin.amos.feign.systemctl.model.FileInfoModel; ...@@ -11,13 +11,14 @@ import com.yeejoin.amos.feign.systemctl.model.FileInfoModel;
import com.yeejoin.amos.knowledgebase.face.enumeration.DynamicsFunctional; import com.yeejoin.amos.knowledgebase.face.enumeration.DynamicsFunctional;
import com.yeejoin.amos.knowledgebase.face.enumeration.KnowledgeRoleName; import com.yeejoin.amos.knowledgebase.face.enumeration.KnowledgeRoleName;
import com.yeejoin.amos.knowledgebase.face.enumeration.OperateType; import com.yeejoin.amos.knowledgebase.face.enumeration.OperateType;
import com.yeejoin.amos.knowledgebase.face.feign.DataFillter;
import com.yeejoin.amos.knowledgebase.face.feign.RemoteData;
import com.yeejoin.amos.knowledgebase.face.model.*; import com.yeejoin.amos.knowledgebase.face.model.*;
import com.yeejoin.amos.knowledgebase.face.orm.dao.DocContentMapper; import com.yeejoin.amos.knowledgebase.face.orm.dao.DocContentMapper;
import com.yeejoin.amos.knowledgebase.face.orm.entity.KnowledgeDocContent; import com.yeejoin.amos.knowledgebase.face.orm.entity.KnowledgeDocContent;
import com.yeejoin.amos.knowledgebase.face.util.DataFillter; import com.yeejoin.amos.knowledgebase.face.util.Constants;
import com.yeejoin.amos.knowledgebase.face.util.DocSortUtil; import com.yeejoin.amos.knowledgebase.face.util.DocSortUtil;
import com.yeejoin.amos.knowledgebase.face.util.QuoteCountFlushTiming; import com.yeejoin.amos.knowledgebase.face.util.QuoteCountFlushTiming;
import com.yeejoin.amos.knowledgebase.face.util.RemoteData;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
...@@ -46,12 +47,11 @@ import java.util.*; ...@@ -46,12 +47,11 @@ import java.util.*;
@Component @Component
public class DocContentService extends BaseService<KnowledgeDocContentModel, KnowledgeDocContent, DocContentMapper> implements DataFillter { public class DocContentService extends BaseService<KnowledgeDocContentModel, KnowledgeDocContent, DocContentMapper> implements DataFillter {
public static final String DOC_STATUS_UNPUBLISHED = "UNPUBLISHED";//文档发布状态--未发布
public static final String DOC_STATUS_PUBLISHED = "PUBLISHED"; //文档发布状态--已发布
private final String orderBy = new StringBuilder().append("ORDER BY FIELD(audit_status, '").append(DocAuditService.DOC_AUDIT_STATUS_SAVED).append("', '")
.append(DocAuditService.DOC_AUDIT_STATUS_SUBMITTED).append("', '").append(DocAuditService.DOC_AUDIT_STATUS_REJECTED).append("', '") private final String orderBy = new StringBuilder().append("ORDER BY FIELD(audit_status, '").append(Constants.DOC_AUDIT_STATUS_SAVED).append("', '")
.append(DocAuditService.DOC_AUDIT_STATUS_PASSED).append("') ASC, create_time DESC").toString(); .append(Constants.DOC_AUDIT_STATUS_SUBMITTED).append("', '").append(Constants.DOC_AUDIT_STATUS_REJECTED).append("', '")
.append(Constants.DOC_AUDIT_STATUS_PASSED).append("') ASC, create_time DESC").toString();
@Autowired @Autowired
private DynamicsValueService dynamicsValueService; private DynamicsValueService dynamicsValueService;
...@@ -127,8 +127,8 @@ public class DocContentService extends BaseService<KnowledgeDocContentModel, Kno ...@@ -127,8 +127,8 @@ public class DocContentService extends BaseService<KnowledgeDocContentModel, Kno
docContentModel.setAgencyCode(RequestContext.getAgencyCode()); docContentModel.setAgencyCode(RequestContext.getAgencyCode());
docContentModel.setUserId(RequestContext.getExeUserId()); docContentModel.setUserId(RequestContext.getExeUserId());
docContentModel.setCreateTime(new Date()); docContentModel.setCreateTime(new Date());
docContentModel.setDocStatus(DOC_STATUS_UNPUBLISHED); docContentModel.setDocStatus(Constants.DOC_STATUS_UNPUBLISHED);
docContentModel.setAuditStatus(DocAuditService.DOC_AUDIT_STATUS_SAVED); docContentModel.setAuditStatus(Constants.DOC_AUDIT_STATUS_SAVED);
docContentModel.setSequenceNbr(sequenceNbr); docContentModel.setSequenceNbr(sequenceNbr);
String inputerOrg = RemoteData.getOrgWithCurUserAndRole(KnowledgeRoleName.INPUTER.getRoleName()); String inputerOrg = RemoteData.getOrgWithCurUserAndRole(KnowledgeRoleName.INPUTER.getRoleName());
if (ValidationUtil.isEmpty(inputerOrg)) { if (ValidationUtil.isEmpty(inputerOrg)) {
...@@ -145,8 +145,8 @@ public class DocContentService extends BaseService<KnowledgeDocContentModel, Kno ...@@ -145,8 +145,8 @@ public class DocContentService extends BaseService<KnowledgeDocContentModel, Kno
dynamicsValueService.saveValueList(docContentModel.getDocBaseInfo(), sequenceNbr, DynamicsFunctional.DOC_BASEINFO, RequestContext.getAppKey()); dynamicsValueService.saveValueList(docContentModel.getDocBaseInfo(), sequenceNbr, DynamicsFunctional.DOC_BASEINFO, RequestContext.getAppKey());
// 保存标签实例 // 保存标签实例
List<KnowledgeTagInstanceModel> docTags = tagInstanceService.saveInstance(docContentModel.getDocTags(), sequenceNbr, TagInstanceService.MARKING_TYPE_DOC); List<KnowledgeTagInstanceModel> docTags = tagInstanceService.saveInstance(docContentModel.getDocTags(), sequenceNbr, Constants.MARKING_TYPE_DOC);
tagInstanceService.saveInstance(docContentModel.getDocContentTags(), sequenceNbr, TagInstanceService.MARKING_TYPE_CONTENT); tagInstanceService.saveInstance(docContentModel.getDocContentTags(), sequenceNbr, Constants.MARKING_TYPE_CONTENT);
QuoteCountFlushTiming.needFlushTag(); QuoteCountFlushTiming.needFlushTag();
//保存附件信息 //保存附件信息
saveAttachments(docContentModel.getAttachments(), sequenceNbr); saveAttachments(docContentModel.getAttachments(), sequenceNbr);
...@@ -234,14 +234,14 @@ public class DocContentService extends BaseService<KnowledgeDocContentModel, Kno ...@@ -234,14 +234,14 @@ public class DocContentService extends BaseService<KnowledgeDocContentModel, Kno
throw new DataNotFound("找不到指定的文档."); throw new DataNotFound("找不到指定的文档.");
} }
//判断文档的可编辑状态。 //判断文档的可编辑状态。
if (DOC_STATUS_PUBLISHED.equals(oldModel.getDocStatus()) if (Constants.DOC_STATUS_PUBLISHED.equals(oldModel.getDocStatus())
|| DocAuditService.DOC_AUDIT_STATUS_PASSED.equals(oldModel.getAuditStatus()) || Constants.DOC_AUDIT_STATUS_PASSED.equals(oldModel.getAuditStatus())
|| DocAuditService.DOC_AUDIT_STATUS_SUBMITTED.equals(oldModel.getAuditStatus())) { || Constants.DOC_AUDIT_STATUS_SUBMITTED.equals(oldModel.getAuditStatus())) {
throw new BadRequest("当前文档状态不可编辑."); throw new BadRequest("当前文档状态不可编辑.");
} }
//如果文档为驳回状态,更改为待提交 //如果文档为驳回状态,更改为待提交
if (ValidationUtil.equals(DocAuditService.DOC_AUDIT_STATUS_REJECTED, oldModel.getAuditStatus())) { if (ValidationUtil.equals(Constants.DOC_AUDIT_STATUS_REJECTED, oldModel.getAuditStatus())) {
oldModel.setAuditStatus(DocAuditService.DOC_AUDIT_STATUS_SAVED); oldModel.setAuditStatus(Constants.DOC_AUDIT_STATUS_SAVED);
} }
if (!ValidationUtil.isEmpty(docContentModel.getHaveAttachment())) { if (!ValidationUtil.isEmpty(docContentModel.getHaveAttachment())) {
oldModel.setHaveAttachment(docContentModel.getHaveAttachment()); oldModel.setHaveAttachment(docContentModel.getHaveAttachment());
...@@ -254,8 +254,8 @@ public class DocContentService extends BaseService<KnowledgeDocContentModel, Kno ...@@ -254,8 +254,8 @@ public class DocContentService extends BaseService<KnowledgeDocContentModel, Kno
// 保存标签实例 // 保存标签实例
tagInstanceService.deleteByTargetSeq(oldModel.getSequenceNbr());//删除已有的标签 tagInstanceService.deleteByTargetSeq(oldModel.getSequenceNbr());//删除已有的标签
List<KnowledgeTagInstanceModel> docTags = tagInstanceService.saveInstance(docContentModel.getDocTags(), oldModel.getSequenceNbr(), TagInstanceService.MARKING_TYPE_DOC); List<KnowledgeTagInstanceModel> docTags = tagInstanceService.saveInstance(docContentModel.getDocTags(), oldModel.getSequenceNbr(), Constants.MARKING_TYPE_DOC);
tagInstanceService.saveInstance(docContentModel.getDocContentTags(), oldModel.getSequenceNbr(), TagInstanceService.MARKING_TYPE_CONTENT); tagInstanceService.saveInstance(docContentModel.getDocContentTags(), oldModel.getSequenceNbr(), Constants.MARKING_TYPE_CONTENT);
// 重新保存附件信息 // 重新保存附件信息
deleteAttachments(oldModel.getSequenceNbr());//删除已有的文件信息 deleteAttachments(oldModel.getSequenceNbr());//删除已有的文件信息
...@@ -278,9 +278,9 @@ public class DocContentService extends BaseService<KnowledgeDocContentModel, Kno ...@@ -278,9 +278,9 @@ public class DocContentService extends BaseService<KnowledgeDocContentModel, Kno
if (ValidationUtil.isEmpty(docContentModel)) { if (ValidationUtil.isEmpty(docContentModel)) {
throw new BadRequest("指定的文档不存在."); throw new BadRequest("指定的文档不存在.");
} }
if (DOC_STATUS_PUBLISHED.equals(docContentModel.getDocStatus()) if (Constants.DOC_STATUS_PUBLISHED.equals(docContentModel.getDocStatus())
|| DocAuditService.DOC_AUDIT_STATUS_PASSED.equals(docContentModel.getAuditStatus()) || Constants.DOC_AUDIT_STATUS_PASSED.equals(docContentModel.getAuditStatus())
|| DocAuditService.DOC_AUDIT_STATUS_SUBMITTED.equals(docContentModel.getAuditStatus())) { || Constants.DOC_AUDIT_STATUS_SUBMITTED.equals(docContentModel.getAuditStatus())) {
throw new BadRequest("当前文档状态不可删除."); throw new BadRequest("当前文档状态不可删除.");
} }
this.dynamicsValueService.deleteByInstanceId(docContentModel.getSequenceNbr()); this.dynamicsValueService.deleteByInstanceId(docContentModel.getSequenceNbr());
...@@ -324,7 +324,7 @@ public class DocContentService extends BaseService<KnowledgeDocContentModel, Kno ...@@ -324,7 +324,7 @@ public class DocContentService extends BaseService<KnowledgeDocContentModel, Kno
}); });
tagInstanceModelList.forEach(instanceModel -> { tagInstanceModelList.forEach(instanceModel -> {
switch (instanceModel.getMarkingType()) { switch (instanceModel.getMarkingType()) {
case TagInstanceService.MARKING_TYPE_DOC: case Constants.MARKING_TYPE_DOC:
docTags.add(instanceModel); docTags.add(instanceModel);
break; break;
default: default:
...@@ -534,8 +534,8 @@ public class DocContentService extends BaseService<KnowledgeDocContentModel, Kno ...@@ -534,8 +534,8 @@ public class DocContentService extends BaseService<KnowledgeDocContentModel, Kno
case AUDITOR: case AUDITOR:
case INPUTER: case INPUTER:
case VIEWER: case VIEWER:
auditStatusSet.add(DocAuditService.DOC_AUDIT_STATUS_PASSED); auditStatusSet.add(Constants.DOC_AUDIT_STATUS_PASSED);
docStatusSet.add(DocContentService.DOC_STATUS_PUBLISHED); docStatusSet.add(Constants.DOC_STATUS_PUBLISHED);
dataPrivilegemap.put(docStatus, docStatusSet.toArray(new String[docStatusSet.size()])); dataPrivilegemap.put(docStatus, docStatusSet.toArray(new String[docStatusSet.size()]));
dataPrivilegemap.put(auditStatus, auditStatusSet.toArray(new String[auditStatusSet.size()])); dataPrivilegemap.put(auditStatus, auditStatusSet.toArray(new String[auditStatusSet.size()]));
break; break;
...@@ -615,7 +615,7 @@ public class DocContentService extends BaseService<KnowledgeDocContentModel, Kno ...@@ -615,7 +615,7 @@ public class DocContentService extends BaseService<KnowledgeDocContentModel, Kno
} }
} }
if (!ValidationUtil.isEmpty(auditorOrg)) { if (!ValidationUtil.isEmpty(auditorOrg)) {
String[] auditStatus = {DocAuditService.DOC_AUDIT_STATUS_PASSED, DocAuditService.DOC_AUDIT_STATUS_SUBMITTED}; String[] auditStatus = {Constants.DOC_AUDIT_STATUS_PASSED, Constants.DOC_AUDIT_STATUS_SUBMITTED};
w.likeRight("org_code", auditorOrg).in("audit_status", Arrays.asList(auditStatus)); w.likeRight("org_code", auditorOrg).in("audit_status", Arrays.asList(auditStatus));
} }
}); });
......
...@@ -10,6 +10,7 @@ import com.yeejoin.amos.knowledgebase.face.enumeration.DynamicsFunctional; ...@@ -10,6 +10,7 @@ import com.yeejoin.amos.knowledgebase.face.enumeration.DynamicsFunctional;
import com.yeejoin.amos.knowledgebase.face.enumeration.KnowledgeRoleName; import com.yeejoin.amos.knowledgebase.face.enumeration.KnowledgeRoleName;
import com.yeejoin.amos.knowledgebase.face.enumeration.OperateType; import com.yeejoin.amos.knowledgebase.face.enumeration.OperateType;
import com.yeejoin.amos.knowledgebase.face.enumeration.OptionDataType; import com.yeejoin.amos.knowledgebase.face.enumeration.OptionDataType;
import com.yeejoin.amos.knowledgebase.face.feign.RemoteData;
import com.yeejoin.amos.knowledgebase.face.model.*; import com.yeejoin.amos.knowledgebase.face.model.*;
import com.yeejoin.amos.knowledgebase.face.orm.entity.ESDocEntity; import com.yeejoin.amos.knowledgebase.face.orm.entity.ESDocEntity;
import com.yeejoin.amos.knowledgebase.face.orm.entity.ESTagEntity; import com.yeejoin.amos.knowledgebase.face.orm.entity.ESTagEntity;
...@@ -95,8 +96,8 @@ public class DocLibraryService { ...@@ -95,8 +96,8 @@ public class DocLibraryService {
static { static {
List<String> list = new ArrayList<>(); List<String> list = new ArrayList<>();
list.add(DocAuditService.DOC_AUDIT_STATUS_SUBMITTED); list.add(Constants.DOC_AUDIT_STATUS_SUBMITTED);
list.add(DocAuditService.DOC_AUDIT_STATUS_PASSED); list.add(Constants.DOC_AUDIT_STATUS_PASSED);
auditStatusList = Collections.unmodifiableList(list); auditStatusList = Collections.unmodifiableList(list);
} }
...@@ -288,7 +289,7 @@ public class DocLibraryService { ...@@ -288,7 +289,7 @@ public class DocLibraryService {
public Page searchAdvanced(Page page, Map<String, Object> queryParams) { public Page searchAdvanced(Page page, Map<String, Object> queryParams) {
QueryWrapper<KnowledgeDocContent> wrapper = new QueryWrapper<>(); QueryWrapper<KnowledgeDocContent> wrapper = new QueryWrapper<>();
wrapper.select("SEQUENCE_NBR") wrapper.select("SEQUENCE_NBR")
.eq("DOC_STATUS", DocContentService.DOC_STATUS_PUBLISHED) .eq("DOC_STATUS", Constants.DOC_STATUS_PUBLISHED)
.orderByAsc("SORT_STR"); .orderByAsc("SORT_STR");
BaseSqlCondition sqlCondition = BaseSqlCondition.getInstance(queryParams); BaseSqlCondition sqlCondition = BaseSqlCondition.getInstance(queryParams);
...@@ -451,7 +452,7 @@ public class DocLibraryService { ...@@ -451,7 +452,7 @@ public class DocLibraryService {
List<KnowledgeTag> tagList = tagService.getBaseMapper().queryTagByNameInPublishedDoc(queryStr); List<KnowledgeTag> tagList = tagService.getBaseMapper().queryTagByNameInPublishedDoc(queryStr);
resList.addAll(Bean.listToMap(tagList, "tagName", KnowledgeTag.class).keySet()); resList.addAll(Bean.listToMap(tagList, "tagName", KnowledgeTag.class).keySet());
QueryWrapper<KnowledgeDocContent> wrapper = new QueryWrapper<KnowledgeDocContent>() QueryWrapper<KnowledgeDocContent> wrapper = new QueryWrapper<KnowledgeDocContent>()
.select("DOC_TITLE").eq("DOC_STATUS", DocContentService.DOC_STATUS_PUBLISHED).like("DOC_TITLE", queryStr); .select("DOC_TITLE").eq("DOC_STATUS", Constants.DOC_STATUS_PUBLISHED).like("DOC_TITLE", queryStr);
List<KnowledgeDocContent> docContentList = docContentService.list(wrapper); List<KnowledgeDocContent> docContentList = docContentService.list(wrapper);
docContentList.forEach(doc -> { docContentList.forEach(doc -> {
if (!resList.contains(doc.getDocTitle())) { if (!resList.contains(doc.getDocTitle())) {
...@@ -469,7 +470,7 @@ public class DocLibraryService { ...@@ -469,7 +470,7 @@ public class DocLibraryService {
public Map<String, Integer> count(int days) { public Map<String, Integer> count(int days) {
Map<String, Integer> res = new HashMap<>(); Map<String, Integer> res = new HashMap<>();
QueryWrapper<KnowledgeDocContent> wrapper = new QueryWrapper<>(); QueryWrapper<KnowledgeDocContent> wrapper = new QueryWrapper<>();
wrapper.eq("doc_status", DocContentService.DOC_STATUS_PUBLISHED); wrapper.eq("doc_status", Constants.DOC_STATUS_PUBLISHED);
res.put("totalAll", docContentService.count(wrapper)); res.put("totalAll", docContentService.count(wrapper));
Date rightRange = new Date(); Date rightRange = new Date();
Date leftRange = getDateBeforeDays(rightRange, days - 1); Date leftRange = getDateBeforeDays(rightRange, days - 1);
...@@ -485,7 +486,7 @@ public class DocLibraryService { ...@@ -485,7 +486,7 @@ public class DocLibraryService {
* @return * @return
*/ */
public List queryNewDocs(int top) { public List queryNewDocs(int top) {
List<KnowledgeDocContentModel> list = docContentService.queryNewDocsWithStatus(top, DocContentService.DOC_STATUS_PUBLISHED); List<KnowledgeDocContentModel> list = docContentService.queryNewDocsWithStatus(top, Constants.DOC_STATUS_PUBLISHED);
fillDirectoryName(list); fillDirectoryName(list);
return fillDynamics(list, false); return fillDynamics(list, false);
} }
...@@ -686,7 +687,7 @@ public class DocLibraryService { ...@@ -686,7 +687,7 @@ public class DocLibraryService {
tagInstanceModelList.forEach(tagInstanceModel -> { tagInstanceModelList.forEach(tagInstanceModel -> {
KnowledgeDocContentModel docContentModel = docContentModelMap.get(tagInstanceModel.getTargetSeq()); KnowledgeDocContentModel docContentModel = docContentModelMap.get(tagInstanceModel.getTargetSeq());
if (null != docContentModel) { if (null != docContentModel) {
boolean isDoc = TagInstanceService.MARKING_TYPE_DOC.equals(tagInstanceModel.getMarkingType()); boolean isDoc = Constants.MARKING_TYPE_DOC.equals(tagInstanceModel.getMarkingType());
List<KnowledgeTagInstanceModel> tagList = isDoc ? docContentModel.getDocTags() : docContentModel.getDocContentTags(); List<KnowledgeTagInstanceModel> tagList = isDoc ? docContentModel.getDocTags() : docContentModel.getDocContentTags();
if (null == tagList) { if (null == tagList) {
tagList = new ArrayList<>(); tagList = new ArrayList<>();
...@@ -806,7 +807,7 @@ public class DocLibraryService { ...@@ -806,7 +807,7 @@ public class DocLibraryService {
records.forEach(doc -> { records.forEach(doc -> {
if (ValidationUtil.isEmpty(doc.getTextContent()) && ValidationUtil.isEmpty(doc.getSortStr())) { if (ValidationUtil.isEmpty(doc.getTextContent()) && ValidationUtil.isEmpty(doc.getSortStr())) {
doc.setTextContent(htmlContent2Text(doc.getHtmlContent())); doc.setTextContent(htmlContent2Text(doc.getHtmlContent()));
doc.setSortStr(DocSortUtil.getSortStr(tagInstanceService.queryByTargetAndType(null, doc.getSequenceNbr(), TagInstanceService.MARKING_TYPE_DOC))); doc.setSortStr(DocSortUtil.getSortStr(tagInstanceService.queryByTargetAndType(null, doc.getSequenceNbr(), Constants.MARKING_TYPE_DOC)));
} }
}); });
docContentService.updateBatchById(records); docContentService.updateBatchById(records);
...@@ -845,7 +846,7 @@ public class DocLibraryService { ...@@ -845,7 +846,7 @@ public class DocLibraryService {
public Page queryDocPage(Page page, String docTitle, String code) { public Page queryDocPage(Page page, String docTitle, String code) {
QueryWrapper<KnowledgeDocContent> wrapper = new QueryWrapper<>(); QueryWrapper<KnowledgeDocContent> wrapper = new QueryWrapper<>();
wrapper.eq("DOC_STATUS", DocContentService.DOC_STATUS_PUBLISHED); wrapper.eq("DOC_STATUS", Constants.DOC_STATUS_PUBLISHED);
if (!ValidationUtil.isEmpty(docTitle)) { if (!ValidationUtil.isEmpty(docTitle)) {
wrapper.like("DOC_TITLE", docTitle); wrapper.like("DOC_TITLE", docTitle);
} }
...@@ -873,7 +874,7 @@ public class DocLibraryService { ...@@ -873,7 +874,7 @@ public class DocLibraryService {
} }
); );
QueryWrapper<KnowledgeDocContent> wrapper = new QueryWrapper<>(); QueryWrapper<KnowledgeDocContent> wrapper = new QueryWrapper<>();
wrapper.eq("DOC_STATUS", DocContentService.DOC_STATUS_PUBLISHED) wrapper.eq("DOC_STATUS", Constants.DOC_STATUS_PUBLISHED)
.in("DIRECTORY_ID", directoryIdSet); .in("DIRECTORY_ID", directoryIdSet);
if (total != null) { if (total != null) {
wrapper.last("ORDER BY RAND() LIMIT "+ total); wrapper.last("ORDER BY RAND() LIMIT "+ total);
......
...@@ -5,11 +5,13 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; ...@@ -5,11 +5,13 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.yeejoin.amos.knowledgebase.face.enumeration.DynamicsFunctional; import com.yeejoin.amos.knowledgebase.face.enumeration.DynamicsFunctional;
import com.yeejoin.amos.knowledgebase.face.enumeration.KnowledgeRoleName; import com.yeejoin.amos.knowledgebase.face.enumeration.KnowledgeRoleName;
import com.yeejoin.amos.knowledgebase.face.enumeration.OptionDataType; import com.yeejoin.amos.knowledgebase.face.enumeration.OptionDataType;
import com.yeejoin.amos.knowledgebase.face.feign.DataFillter;
import com.yeejoin.amos.knowledgebase.face.model.KnowledgeDynamicsOptionModel; import com.yeejoin.amos.knowledgebase.face.model.KnowledgeDynamicsOptionModel;
import com.yeejoin.amos.knowledgebase.face.model.KnowledgeDynamicsValueModel; import com.yeejoin.amos.knowledgebase.face.model.KnowledgeDynamicsValueModel;
import com.yeejoin.amos.knowledgebase.face.orm.dao.DynamicsValueMapper; import com.yeejoin.amos.knowledgebase.face.orm.dao.DynamicsValueMapper;
import com.yeejoin.amos.knowledgebase.face.orm.entity.KnowledgeDynamicsValue; import com.yeejoin.amos.knowledgebase.face.orm.entity.KnowledgeDynamicsValue;
import com.yeejoin.amos.knowledgebase.face.util.DataFillter; import com.yeejoin.amos.knowledgebase.face.util.Constants;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
...@@ -146,8 +148,8 @@ public class DynamicsValueService extends BaseService<KnowledgeDynamicsValueMode ...@@ -146,8 +148,8 @@ public class DynamicsValueService extends BaseService<KnowledgeDynamicsValueMode
} }
switch (knowledgeRoleName) { switch (knowledgeRoleName) {
case AUDITOR: case AUDITOR:
auditStatusSet.add(DocAuditService.DOC_AUDIT_STATUS_PASSED); auditStatusSet.add(Constants.DOC_AUDIT_STATUS_PASSED);
auditStatusSet.add(DocAuditService.DOC_AUDIT_STATUS_SUBMITTED); auditStatusSet.add(Constants.DOC_AUDIT_STATUS_SUBMITTED);
dataPrivilegemap.put(DataFillter.orgCode, orgCode); dataPrivilegemap.put(DataFillter.orgCode, orgCode);
dataPrivilegemap.put(auditStatus, auditStatusSet.toArray(new String[auditStatusSet.size()])); dataPrivilegemap.put(auditStatus, auditStatusSet.toArray(new String[auditStatusSet.size()]));
break; break;
...@@ -158,8 +160,8 @@ public class DynamicsValueService extends BaseService<KnowledgeDynamicsValueMode ...@@ -158,8 +160,8 @@ public class DynamicsValueService extends BaseService<KnowledgeDynamicsValueMode
dataPrivilegemap.put(DataFillter.noData, true); dataPrivilegemap.put(DataFillter.noData, true);
break; break;
case VIEWER: case VIEWER:
auditStatusSet.add(DocAuditService.DOC_AUDIT_STATUS_PASSED); auditStatusSet.add(Constants.DOC_AUDIT_STATUS_PASSED);
docStatusSet.add(DocContentService.DOC_STATUS_PUBLISHED); docStatusSet.add(Constants.DOC_STATUS_PUBLISHED);
dataPrivilegemap.put(docStatus, docStatusSet.toArray(new String[docStatusSet.size()])); dataPrivilegemap.put(docStatus, docStatusSet.toArray(new String[docStatusSet.size()]));
dataPrivilegemap.put(auditStatus, auditStatusSet.toArray(new String[auditStatusSet.size()])); dataPrivilegemap.put(auditStatus, auditStatusSet.toArray(new String[auditStatusSet.size()]));
break; break;
......
...@@ -3,6 +3,7 @@ package com.yeejoin.amos.knowledgebase.face.service; ...@@ -3,6 +3,7 @@ package com.yeejoin.amos.knowledgebase.face.service;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.yeejoin.amos.knowledgebase.face.feign.RemoteData;
import com.yeejoin.amos.knowledgebase.face.model.KnowledgeDocContentModel; import com.yeejoin.amos.knowledgebase.face.model.KnowledgeDocContentModel;
import com.yeejoin.amos.knowledgebase.face.model.KnowledgeDynamicsValueModel; import com.yeejoin.amos.knowledgebase.face.model.KnowledgeDynamicsValueModel;
import com.yeejoin.amos.knowledgebase.face.model.KnowledgeTagInstanceModel; import com.yeejoin.amos.knowledgebase.face.model.KnowledgeTagInstanceModel;
...@@ -11,7 +12,8 @@ import com.yeejoin.amos.knowledgebase.face.orm.dao.ESDocRepository; ...@@ -11,7 +12,8 @@ import com.yeejoin.amos.knowledgebase.face.orm.dao.ESDocRepository;
import com.yeejoin.amos.knowledgebase.face.orm.entity.ESDocEntity; import com.yeejoin.amos.knowledgebase.face.orm.entity.ESDocEntity;
import com.yeejoin.amos.knowledgebase.face.orm.entity.ESTagEntity; import com.yeejoin.amos.knowledgebase.face.orm.entity.ESTagEntity;
import com.yeejoin.amos.knowledgebase.face.orm.entity.KnowledgeDocContent; import com.yeejoin.amos.knowledgebase.face.orm.entity.KnowledgeDocContent;
import com.yeejoin.amos.knowledgebase.face.util.RemoteData; import com.yeejoin.amos.knowledgebase.face.util.Constants;
import org.elasticsearch.index.query.BoolQueryBuilder; import org.elasticsearch.index.query.BoolQueryBuilder;
import org.elasticsearch.index.query.QueryBuilders; import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.search.fetch.subphase.highlight.HighlightBuilder; import org.elasticsearch.search.fetch.subphase.highlight.HighlightBuilder;
...@@ -304,7 +306,7 @@ public class ESDocService { ...@@ -304,7 +306,7 @@ public class ESDocService {
Map<String, Map<String, String>> enumCnEnMap = docLibraryService.getBaseEnumMap(); Map<String, Map<String, String>> enumCnEnMap = docLibraryService.getBaseEnumMap();
List<ESDocEntity> esDocs = new ArrayList<>(); List<ESDocEntity> esDocs = new ArrayList<>();
for (KnowledgeDocContentModel docDetail : docs) { for (KnowledgeDocContentModel docDetail : docs) {
if (ValidationUtil.equals(docDetail.getDocStatus(), DocContentService.DOC_STATUS_PUBLISHED)) { if (ValidationUtil.equals(docDetail.getDocStatus(), Constants.DOC_STATUS_PUBLISHED)) {
List<ESTagEntity> docTags = buildESTagsByInstanceList(docDetail.getDocTags()); List<ESTagEntity> docTags = buildESTagsByInstanceList(docDetail.getDocTags());
List<ESTagEntity> contentTags = buildESTagsByInstanceList(docDetail.getDocContentTags()); List<ESTagEntity> contentTags = buildESTagsByInstanceList(docDetail.getDocContentTags());
ESDocEntity esDocEntity = new ESDocEntity() ESDocEntity esDocEntity = new ESDocEntity()
...@@ -384,7 +386,7 @@ public class ESDocService { ...@@ -384,7 +386,7 @@ public class ESDocService {
private String getTagInfoStr(KnowledgeTagInstanceModel instanceModel) { private String getTagInfoStr(KnowledgeTagInstanceModel instanceModel) {
StringBuilder infoStr = new StringBuilder(); StringBuilder infoStr = new StringBuilder();
infoStr.append(instanceModel.getTagName()).append(" "); infoStr.append(instanceModel.getTagName()).append(" ");
if (TagService.TAG_TYPE_TEXT.equals(instanceModel.getTagType()) if (Constants.TAG_TYPE_TEXT.equals(instanceModel.getTagType())
|| ValidationUtil.isEmpty(instanceModel.getTagValues())) { || ValidationUtil.isEmpty(instanceModel.getTagValues())) {
return infoStr.toString().trim(); return infoStr.toString().trim();
} }
...@@ -392,7 +394,7 @@ public class ESDocService { ...@@ -392,7 +394,7 @@ public class ESDocService {
String fieldName = valueModel.getFieldName(); String fieldName = valueModel.getFieldName();
String tagValue = valueModel.getTagValue(); String tagValue = valueModel.getTagValue();
switch (fieldName) { switch (fieldName) {
case TagValueService.VALUE_TAG_FIELD_DATE_H: case Constants.VALUE_TAG_FIELD_DATE_H:
infoStr.append(tagValue).append(" "); infoStr.append(tagValue).append(" ");
try { try {
Date date = DateUtil.formatStringToDate(tagValue, null); Date date = DateUtil.formatStringToDate(tagValue, null);
...@@ -442,7 +444,7 @@ public class ESDocService { ...@@ -442,7 +444,7 @@ public class ESDocService {
esDocRepository.deleteAll(); esDocRepository.deleteAll();
//保存所有已发布文档 //保存所有已发布文档
QueryWrapper<KnowledgeDocContent> wrapper = new QueryWrapper<>(); QueryWrapper<KnowledgeDocContent> wrapper = new QueryWrapper<>();
wrapper.eq("doc_status", DocContentService.DOC_STATUS_PUBLISHED); wrapper.eq("doc_status", Constants.DOC_STATUS_PUBLISHED);
int count = docContentService.count(wrapper); int count = docContentService.count(wrapper);
int finishNmu = 0; int finishNmu = 0;
int current = 0; int current = 0;
......
...@@ -4,11 +4,12 @@ package com.yeejoin.amos.knowledgebase.face.service; ...@@ -4,11 +4,12 @@ package com.yeejoin.amos.knowledgebase.face.service;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Sequence; import com.baomidou.mybatisplus.core.toolkit.Sequence;
import com.yeejoin.amos.knowledgebase.face.feign.RemoteData;
import com.yeejoin.amos.knowledgebase.face.model.KnowledgeMessageModel; import com.yeejoin.amos.knowledgebase.face.model.KnowledgeMessageModel;
import com.yeejoin.amos.knowledgebase.face.orm.dao.MessageMapper; import com.yeejoin.amos.knowledgebase.face.orm.dao.MessageMapper;
import com.yeejoin.amos.knowledgebase.face.orm.entity.KnowledgeMessage; import com.yeejoin.amos.knowledgebase.face.orm.entity.KnowledgeMessage;
import com.yeejoin.amos.knowledgebase.face.orm.entity.KnowledgeMessagePersonal; import com.yeejoin.amos.knowledgebase.face.orm.entity.KnowledgeMessagePersonal;
import com.yeejoin.amos.knowledgebase.face.util.RemoteData; import com.yeejoin.amos.knowledgebase.face.util.Constants;
import org.eclipse.paho.client.mqttv3.MqttException; import org.eclipse.paho.client.mqttv3.MqttException;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
...@@ -35,20 +36,7 @@ import java.util.*; ...@@ -35,20 +36,7 @@ import java.util.*;
@Component @Component
public class MessageService extends BaseService<KnowledgeMessageModel, KnowledgeMessage, MessageMapper> { public class MessageService extends BaseService<KnowledgeMessageModel, KnowledgeMessage, MessageMapper> {
/**
* 消息类型-要点推送
*/
public static final String MESSAGE_TYPE_PUSH = "ESSENTIAL_PUSH";
/**
* 消息类型-战例分享
*/
public static final String MESSAGE_TYPE_SHARE = "DOC_SHARE";
/**
* 消息主题前缀
*/
public static final String TOPIC_PREFIX = "knowledge_message_";
public static final String SHARE_WAY_APP = "app";
private final String userTypeUser = "user"; private final String userTypeUser = "user";
private final String userTypeGroup = "group"; private final String userTypeGroup = "group";
...@@ -107,14 +95,14 @@ public class MessageService extends BaseService<KnowledgeMessageModel, Knowledge ...@@ -107,14 +95,14 @@ public class MessageService extends BaseService<KnowledgeMessageModel, Knowledge
*/ */
@Transactional(rollbackFor = {BaseException.class, Exception.class}) @Transactional(rollbackFor = {BaseException.class, Exception.class})
public boolean shareDoc(List<Map<String, Object>> users, List<Map<String, Object>> docs, String way) { public boolean shareDoc(List<Map<String, Object>> users, List<Map<String, Object>> docs, String way) {
if (ValidationUtil.equalsIgnoreCase(way, SHARE_WAY_APP)) { if (ValidationUtil.equalsIgnoreCase(way, Constants.SHARE_WAY_APP)) {
for (Map<String, Object> doc : docs) { for (Map<String, Object> doc : docs) {
//创建消息 //创建消息
if (ValidationUtil.isEmpty(doc) || ValidationUtil.isEmpty(doc.get("sequenceNbr"))) { if (ValidationUtil.isEmpty(doc) || ValidationUtil.isEmpty(doc.get("sequenceNbr"))) {
throw new BadRequest("分享内容缺失"); throw new BadRequest("分享内容缺失");
} }
String messageTitle = String.valueOf(doc.get("docTitle")); String messageTitle = String.valueOf(doc.get("docTitle"));
KnowledgeMessageModel message = createMessage(MESSAGE_TYPE_SHARE, Long.valueOf(doc.get("sequenceNbr").toString()), messageTitle, String.valueOf(doc.get("summary"))); KnowledgeMessageModel message = createMessage(Constants.MESSAGE_TYPE_SHARE, Long.valueOf(doc.get("sequenceNbr").toString()), messageTitle, String.valueOf(doc.get("summary")));
Set<String> userIdSet = new HashSet<>(); Set<String> userIdSet = new HashSet<>();
userIdSet = parseUserMapToIdList(users, userIdSet); userIdSet = parseUserMapToIdList(users, userIdSet);
//创建个人消息 //创建个人消息
...@@ -134,7 +122,7 @@ public class MessageService extends BaseService<KnowledgeMessageModel, Knowledge ...@@ -134,7 +122,7 @@ public class MessageService extends BaseService<KnowledgeMessageModel, Knowledge
@Transactional(rollbackFor = {BaseException.class, Exception.class}) @Transactional(rollbackFor = {BaseException.class, Exception.class})
public boolean pushEssential(List<Map<String, Object>> users, String messageTitle, String content, Long docSeq) { public boolean pushEssential(List<Map<String, Object>> users, String messageTitle, String content, Long docSeq) {
//创建消息 //创建消息
KnowledgeMessageModel message = createMessage(MESSAGE_TYPE_PUSH, docSeq, messageTitle, content); KnowledgeMessageModel message = createMessage(Constants.MESSAGE_TYPE_PUSH, docSeq, messageTitle, content);
Set<String> userIdSet = new HashSet<>(); Set<String> userIdSet = new HashSet<>();
userIdSet = parseUserMapToIdList(users, userIdSet); userIdSet = parseUserMapToIdList(users, userIdSet);
//创建个人消息 //创建个人消息
...@@ -251,7 +239,7 @@ public class MessageService extends BaseService<KnowledgeMessageModel, Knowledge ...@@ -251,7 +239,7 @@ public class MessageService extends BaseService<KnowledgeMessageModel, Knowledge
* 获取用户的主题 * 获取用户的主题
*/ */
private String getTopic(String userId) { private String getTopic(String userId) {
return TOPIC_PREFIX + String.valueOf(userId); return Constants.TOPIC_PREFIX + String.valueOf(userId);
} }
/** /**
......
...@@ -8,6 +8,8 @@ import com.yeejoin.amos.knowledgebase.face.model.KnowledgeTagModel; ...@@ -8,6 +8,8 @@ import com.yeejoin.amos.knowledgebase.face.model.KnowledgeTagModel;
import com.yeejoin.amos.knowledgebase.face.model.KnowledgeTagValueModel; import com.yeejoin.amos.knowledgebase.face.model.KnowledgeTagValueModel;
import com.yeejoin.amos.knowledgebase.face.orm.dao.TagInstanceMapper; import com.yeejoin.amos.knowledgebase.face.orm.dao.TagInstanceMapper;
import com.yeejoin.amos.knowledgebase.face.orm.entity.KnowledgeTagInstance; import com.yeejoin.amos.knowledgebase.face.orm.entity.KnowledgeTagInstance;
import com.yeejoin.amos.knowledgebase.face.util.Constants;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.typroject.tyboot.core.foundation.context.RequestContext; import org.typroject.tyboot.core.foundation.context.RequestContext;
...@@ -31,10 +33,6 @@ import java.util.*; ...@@ -31,10 +33,6 @@ import java.util.*;
@Component @Component
public class TagInstanceService extends BaseService<KnowledgeTagInstanceModel, KnowledgeTagInstance, TagInstanceMapper> { public class TagInstanceService extends BaseService<KnowledgeTagInstanceModel, KnowledgeTagInstance, TagInstanceMapper> {
public static final String MARKING_TYPE_DOC = "DOC"; // 标记类型--文档标签
public static final String MARKING_TYPE_CONTENT = "CONTENT";// 标记类型--内容标签
@Autowired @Autowired
private TagValueService tagValueService; private TagValueService tagValueService;
...@@ -71,7 +69,7 @@ public class TagInstanceService extends BaseService<KnowledgeTagInstanceModel, K ...@@ -71,7 +69,7 @@ public class TagInstanceService extends BaseService<KnowledgeTagInstanceModel, K
instanceModel.setTagType(tagModel.getTagType()); instanceModel.setTagType(tagModel.getTagType());
//值标签保存标签的具体值 //值标签保存标签的具体值
List<KnowledgeTagValueModel> valueModels = instanceModel.getTagValues(); List<KnowledgeTagValueModel> valueModels = instanceModel.getTagValues();
if (TagService.TAG_TYPE_VALUE.equals(tagModel.getTagType()) && !ValidationUtil.isEmpty(valueModels)) { if (Constants.TAG_TYPE_VALUE.equals(tagModel.getTagType()) && !ValidationUtil.isEmpty(valueModels)) {
List<KnowledgeDynamicsValueModel> valueTagConfigs = dynamicsValueService.queryByInstanceId(tagModel.getSequenceNbr()); List<KnowledgeDynamicsValueModel> valueTagConfigs = dynamicsValueService.queryByInstanceId(tagModel.getSequenceNbr());
Map<String,Object> valueTagConfigMap = Bean.listToMap(valueTagConfigs,"fieldName","fieldValue",KnowledgeDynamicsValueModel.class); Map<String,Object> valueTagConfigMap = Bean.listToMap(valueTagConfigs,"fieldName","fieldValue",KnowledgeDynamicsValueModel.class);
String unit = String.valueOf(valueTagConfigMap.get("unit")); String unit = String.valueOf(valueTagConfigMap.get("unit"));
...@@ -138,7 +136,7 @@ public class TagInstanceService extends BaseService<KnowledgeTagInstanceModel, K ...@@ -138,7 +136,7 @@ public class TagInstanceService extends BaseService<KnowledgeTagInstanceModel, K
List<KnowledgeTagInstanceModel> instanceModels = this.queryForList(null, false, agencyCode, targetSeq,markingType); List<KnowledgeTagInstanceModel> instanceModels = this.queryForList(null, false, agencyCode, targetSeq,markingType);
if (!ValidationUtil.isEmpty(instanceModels)) { if (!ValidationUtil.isEmpty(instanceModels)) {
for (KnowledgeTagInstanceModel instanceModel : instanceModels) { for (KnowledgeTagInstanceModel instanceModel : instanceModels) {
if (TagService.TAG_TYPE_VALUE.equals(instanceModel.getTagType())) { if (Constants.TAG_TYPE_VALUE.equals(instanceModel.getTagType())) {
List<KnowledgeTagValueModel> list = this.tagValueService.queryByInstance(instanceModel.getSequenceNbr()); List<KnowledgeTagValueModel> list = this.tagValueService.queryByInstance(instanceModel.getSequenceNbr());
instanceModel.setTagValues(list); instanceModel.setTagValues(list);
} }
......
...@@ -4,12 +4,14 @@ package com.yeejoin.amos.knowledgebase.face.service; ...@@ -4,12 +4,14 @@ package com.yeejoin.amos.knowledgebase.face.service;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Sequence; import com.baomidou.mybatisplus.core.toolkit.Sequence;
import com.yeejoin.amos.knowledgebase.face.enumeration.DynamicsFunctional; import com.yeejoin.amos.knowledgebase.face.enumeration.DynamicsFunctional;
import com.yeejoin.amos.knowledgebase.face.feign.RemoteData;
import com.yeejoin.amos.knowledgebase.face.model.*; import com.yeejoin.amos.knowledgebase.face.model.*;
import com.yeejoin.amos.knowledgebase.face.orm.dao.TagMapper; import com.yeejoin.amos.knowledgebase.face.orm.dao.TagMapper;
import com.yeejoin.amos.knowledgebase.face.orm.entity.KnowledgeDocContent; import com.yeejoin.amos.knowledgebase.face.orm.entity.KnowledgeDocContent;
import com.yeejoin.amos.knowledgebase.face.orm.entity.KnowledgeTag; import com.yeejoin.amos.knowledgebase.face.orm.entity.KnowledgeTag;
import com.yeejoin.amos.knowledgebase.face.util.ConfigLoader; import com.yeejoin.amos.knowledgebase.face.util.ConfigLoader;
import com.yeejoin.amos.knowledgebase.face.util.RemoteData; import com.yeejoin.amos.knowledgebase.face.util.Constants;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
...@@ -39,27 +41,6 @@ import java.util.*; ...@@ -39,27 +41,6 @@ import java.util.*;
@Component @Component
public class TagService extends BaseService<KnowledgeTagModel, KnowledgeTag, TagMapper> { public class TagService extends BaseService<KnowledgeTagModel, KnowledgeTag, TagMapper> {
/**
* 标签状态-激活
*/
public static final String TAG_STATUS_ACTIVATE = "ACTIVATED";
/**
* 标签状态-禁用
*/
public static final String TAG_STATUS_DEACTIVATE = "DEACTIVATED";
/**
* 标签类型-文本标签
*/
public static final String TAG_TYPE_TEXT = "TEXT_TAG";
/**
* 标签类型-值标签
*/
public static final String TAG_TYPE_VALUE = "VALUE_TAG";
public static final String APPKEY_ALL = "ALL";
@Autowired @Autowired
private TagGroupService tagGroupService; private TagGroupService tagGroupService;
@Autowired @Autowired
...@@ -92,7 +73,7 @@ public class TagService extends BaseService<KnowledgeTagModel, KnowledgeTag, Tag ...@@ -92,7 +73,7 @@ public class TagService extends BaseService<KnowledgeTagModel, KnowledgeTag, Tag
} }
Long sequenceNbr = sequence.nextId(); Long sequenceNbr = sequence.nextId();
model.setSequenceNbr(sequenceNbr); model.setSequenceNbr(sequenceNbr);
model.setTagStatus(TAG_STATUS_DEACTIVATE); model.setTagStatus(Constants.TAG_STATUS_DEACTIVATE);
model.setAgencyCode(RequestContext.getAgencyCode()); model.setAgencyCode(RequestContext.getAgencyCode());
model.setCreator(RequestContext.getExeUserId()); model.setCreator(RequestContext.getExeUserId());
//创建标签-分组关联关系 //创建标签-分组关联关系
...@@ -120,7 +101,7 @@ public class TagService extends BaseService<KnowledgeTagModel, KnowledgeTag, Tag ...@@ -120,7 +101,7 @@ public class TagService extends BaseService<KnowledgeTagModel, KnowledgeTag, Tag
throw new BadRequest("标签名称不可重复"); throw new BadRequest("标签名称不可重复");
} }
//判断标签状态 //判断标签状态
if (ValidationUtil.equals(oldTagModel.getTagStatus(), TAG_STATUS_ACTIVATE)) { if (ValidationUtil.equals(oldTagModel.getTagStatus(), Constants.TAG_STATUS_ACTIVATE)) {
throw new BadRequest("启用状态的标签不允许编辑"); throw new BadRequest("启用状态的标签不允许编辑");
} }
Long sequenceNbr = oldTagModel.getSequenceNbr(); Long sequenceNbr = oldTagModel.getSequenceNbr();
...@@ -134,12 +115,12 @@ public class TagService extends BaseService<KnowledgeTagModel, KnowledgeTag, Tag ...@@ -134,12 +115,12 @@ public class TagService extends BaseService<KnowledgeTagModel, KnowledgeTag, Tag
} }
private void restoreDynamicsValues(Long sequenceNbr, KnowledgeTagModel model) { private void restoreDynamicsValues(Long sequenceNbr, KnowledgeTagModel model) {
if (ValidationUtil.equals(TAG_TYPE_VALUE, model.getTagType())) { if (ValidationUtil.equals(Constants.TAG_TYPE_VALUE, model.getTagType())) {
Map<String, Object> tagValues = model.getTagValues(); Map<String, Object> tagValues = model.getTagValues();
if (!ValidationUtil.isEmpty(tagValues)) { if (!ValidationUtil.isEmpty(tagValues)) {
dynamicsValueService.saveValueList(tagValues, sequenceNbr, dynamicsValueService.saveValueList(tagValues, sequenceNbr,
DynamicsFunctional.VALUE_TAG_CONFIG, DynamicsFunctional.VALUE_TAG_CONFIG,
APPKEY_ALL); Constants.APPKEY_ALL);
} }
} }
} }
...@@ -259,7 +240,7 @@ public class TagService extends BaseService<KnowledgeTagModel, KnowledgeTag, Tag ...@@ -259,7 +240,7 @@ public class TagService extends BaseService<KnowledgeTagModel, KnowledgeTag, Tag
tagIdList = StringUtil.String2LongList(tags); tagIdList = StringUtil.String2LongList(tags);
} }
for (KnowledgeTagModel tagModel : tagModels) { for (KnowledgeTagModel tagModel : tagModels) {
if (ValidationUtil.equals(tagModel.getTagStatus(), TAG_STATUS_ACTIVATE)) { if (ValidationUtil.equals(tagModel.getTagStatus(), Constants.TAG_STATUS_ACTIVATE)) {
throw new RequestForbidden("包含启用状态的标签,不允许删除"); throw new RequestForbidden("包含启用状态的标签,不允许删除");
} }
if (tagIsQuoted(tagModel.getSequenceNbr())) { if (tagIsQuoted(tagModel.getSequenceNbr())) {
...@@ -398,7 +379,7 @@ public class TagService extends BaseService<KnowledgeTagModel, KnowledgeTag, Tag ...@@ -398,7 +379,7 @@ public class TagService extends BaseService<KnowledgeTagModel, KnowledgeTag, Tag
} }
public List<KnowledgeTagModel> queryTagDetailList(String tagName) { public List<KnowledgeTagModel> queryTagDetailList(String tagName) {
List<KnowledgeTag> tagList = queryTagListWithGroup(null, tagName, null, TAG_STATUS_ACTIVATE); List<KnowledgeTag> tagList = queryTagListWithGroup(null, tagName, null, Constants.TAG_STATUS_ACTIVATE);
List<KnowledgeTagModel> res = new ArrayList<>(); List<KnowledgeTagModel> res = new ArrayList<>();
for (KnowledgeTag tag : tagList) { for (KnowledgeTag tag : tagList) {
KnowledgeTagModel tagModel = new KnowledgeTagModel(); KnowledgeTagModel tagModel = new KnowledgeTagModel();
...@@ -412,7 +393,7 @@ public class TagService extends BaseService<KnowledgeTagModel, KnowledgeTag, Tag ...@@ -412,7 +393,7 @@ public class TagService extends BaseService<KnowledgeTagModel, KnowledgeTag, Tag
} }
private void tagAddDynamicsValues(KnowledgeTagModel tagModel) { private void tagAddDynamicsValues(KnowledgeTagModel tagModel) {
if (ValidationUtil.equals(TAG_TYPE_VALUE, tagModel.getTagType())) { if (ValidationUtil.equals(Constants.TAG_TYPE_VALUE, tagModel.getTagType())) {
List<KnowledgeDynamicsValueModel> valueModels = dynamicsValueService.queryByInstanceId(tagModel.getSequenceNbr()); List<KnowledgeDynamicsValueModel> valueModels = dynamicsValueService.queryByInstanceId(tagModel.getSequenceNbr());
if (!ValidationUtil.isEmpty(valueModels)) { if (!ValidationUtil.isEmpty(valueModels)) {
Map fieldsMap = Bean.listToMap(valueModels, "fieldName", KnowledgeDynamicsValueModel.class); Map fieldsMap = Bean.listToMap(valueModels, "fieldName", KnowledgeDynamicsValueModel.class);
...@@ -436,7 +417,7 @@ public class TagService extends BaseService<KnowledgeTagModel, KnowledgeTag, Tag ...@@ -436,7 +417,7 @@ public class TagService extends BaseService<KnowledgeTagModel, KnowledgeTag, Tag
throw new BadRequest("参数有误"); throw new BadRequest("参数有误");
} }
QueryWrapper<KnowledgeDocContent> wrapper = new QueryWrapper<KnowledgeDocContent>() QueryWrapper<KnowledgeDocContent> wrapper = new QueryWrapper<KnowledgeDocContent>()
.eq("DOC_STATUS", DocContentService.DOC_STATUS_PUBLISHED) .eq("DOC_STATUS", Constants.DOC_STATUS_PUBLISHED)
.inSql("SEQUENCE_NBR", "SELECT DISTINCT TARGET_SEQ FROM knowledge_tag_instance WHERE TAG_SEQ = " + sequenceNbr); .inSql("SEQUENCE_NBR", "SELECT DISTINCT TARGET_SEQ FROM knowledge_tag_instance WHERE TAG_SEQ = " + sequenceNbr);
return docContentService.list(wrapper); return docContentService.list(wrapper);
} }
......
package com.yeejoin.amos.knowledgebase.face.service; package com.yeejoin.amos.knowledgebase.face.service;
import com.yeejoin.amos.knowledgebase.face.model.KnowledgeTagValueModel; import java.util.Collection;
import com.yeejoin.amos.knowledgebase.face.orm.dao.TagValueMapper; import java.util.List;
import com.yeejoin.amos.knowledgebase.face.orm.entity.KnowledgeTagValue;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.typroject.tyboot.core.foundation.context.RequestContext; import org.typroject.tyboot.core.foundation.context.RequestContext;
import org.typroject.tyboot.core.foundation.exception.BaseException; import org.typroject.tyboot.core.foundation.exception.BaseException;
import org.typroject.tyboot.core.foundation.utils.Bean; import org.typroject.tyboot.core.foundation.utils.Bean;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil; import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.rdbms.annotation.Condition;
import org.typroject.tyboot.core.rdbms.annotation.Operator;
import org.typroject.tyboot.core.rdbms.service.BaseService; import org.typroject.tyboot.core.rdbms.service.BaseService;
import java.util.Collection; import com.yeejoin.amos.knowledgebase.face.model.KnowledgeTagValueModel;
import java.util.List; import com.yeejoin.amos.knowledgebase.face.orm.dao.TagValueMapper;
import com.yeejoin.amos.knowledgebase.face.orm.entity.KnowledgeTagValue;
/** /**
...@@ -29,15 +28,6 @@ import java.util.List; ...@@ -29,15 +28,6 @@ import java.util.List;
@Component @Component
public class TagValueService extends BaseService<KnowledgeTagValueModel, KnowledgeTagValue, TagValueMapper> { public class TagValueService extends BaseService<KnowledgeTagValueModel, KnowledgeTagValue, TagValueMapper> {
public static final String VALUE_TAG_FIELD_SINGLEVALUE = "singleValue";//单值字段名
public static final String VALUE_TAG_FIELD_RANGE_MAX = "rangeMax";//范围值 上界
public static final String VALUE_TAG_FIELD_RANGE_MIN = "rangeMin";//范围值 下界
public static final String VALUE_TAG_FIELD_TEXT = "text";//文本值
public static final String VALUE_TAG_FIELD_DATE_H = "dateH";//时间,年月日时分秒
public static final String VALUE_TAG_FIELD_ENUM_NAME = "enumName";// 枚举类型字段名
@Transactional(rollbackFor = {Exception.class, BaseException.class}) @Transactional(rollbackFor = {Exception.class, BaseException.class})
public List<KnowledgeTagValueModel> saveInstanceValue(Long instanceSeq, List<KnowledgeTagValueModel> valueModels, String unit) { public List<KnowledgeTagValueModel> saveInstanceValue(Long instanceSeq, List<KnowledgeTagValueModel> valueModels, String unit) {
......
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <project xmlns="http://maven.apache.org/POM/4.0.0"
<modelVersion>4.0.0</modelVersion> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<parent> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<artifactId>amos-boot-module-biz</artifactId> <modelVersion>4.0.0</modelVersion>
<groupId>com.amosframework.boot</groupId> <parent>
<version>1.0.0</version> <artifactId>amos-boot-module-biz</artifactId>
</parent> <groupId>com.amosframework.boot</groupId>
<artifactId>amos-boot-module-maintenance-biz</artifactId> <version>1.0.0</version>
</parent>
<artifactId>amos-boot-module-maintenance-biz</artifactId>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>com.amosframework.boot</groupId> <groupId>com.amosframework.boot</groupId>
<artifactId>amos-boot-module-maintenance-api</artifactId> <artifactId>amos-boot-module-maintenance-api</artifactId>
<version>${amos-biz-boot.version}</version> <version>${amos-biz-boot.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.yeejoin</groupId>
<artifactId>amos-component-rule</artifactId>
<exclusions>
<exclusion>
<groupId>org.typroject</groupId>
<artifactId>tyboot-core-auth</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId> <artifactId>spring-boot-starter-data-jpa</artifactId>
<exclusions> <exclusions>
...@@ -82,6 +94,6 @@ ...@@ -82,6 +94,6 @@
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-mail</artifactId> <artifactId>spring-boot-starter-mail</artifactId>
</dependency> </dependency>
</dependencies> </dependencies>
</project> </project>
...@@ -11,7 +11,6 @@ ...@@ -11,7 +11,6 @@
<artifactId>amos-boot-module-patrol-biz</artifactId> <artifactId>amos-boot-module-patrol-biz</artifactId>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>com.amosframework.boot</groupId> <groupId>com.amosframework.boot</groupId>
...@@ -19,6 +18,16 @@ ...@@ -19,6 +18,16 @@
<version>${amos-biz-boot.version}</version> <version>${amos-biz-boot.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.yeejoin</groupId>
<artifactId>amos-component-rule</artifactId>
<exclusions>
<exclusion>
<groupId>org.typroject</groupId>
<artifactId>tyboot-core-auth</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId> <artifactId>spring-boot-starter-data-jpa</artifactId>
<exclusions> <exclusions>
......
...@@ -24,6 +24,16 @@ ...@@ -24,6 +24,16 @@
</exclusion> </exclusion>
</exclusions> </exclusions>
</dependency> </dependency>
<dependency>
<groupId>com.yeejoin</groupId>
<artifactId>amos-component-rule</artifactId>
<exclusions>
<exclusion>
<groupId>org.typroject</groupId>
<artifactId>tyboot-core-auth</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- 添加fastjson 依赖包. --> <!-- 添加fastjson 依赖包. -->
<dependency> <dependency>
<groupId>com.alibaba</groupId> <groupId>com.alibaba</groupId>
......
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <project xmlns="http://maven.apache.org/POM/4.0.0"
<modelVersion>4.0.0</modelVersion> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<parent> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<artifactId>amos-boot-module</artifactId> <modelVersion>4.0.0</modelVersion>
<groupId>com.amosframework.boot</groupId> <parent>
<version>1.0.0</version> <artifactId>amos-boot-module</artifactId>
</parent> <groupId>com.amosframework.boot</groupId>
<version>1.0.0</version>
</parent>
<artifactId>amos-boot-module-biz</artifactId> <artifactId>amos-boot-module-biz</artifactId>
<packaging>pom</packaging> <packaging>pom</packaging>
<dependencies> <dependencies>
</dependencies>
<modules> </dependencies>
<module>amos-boot-module-tzs-biz</module>
<module>amos-boot-module-jcs-biz</module> <modules>
<module>amos-boot-module-common-biz</module> <module>amos-boot-module-tzs-biz</module>
<module>amos-boot-module-command-biz</module> <module>amos-boot-module-jcs-biz</module>
<module>amos-boot-module-knowledgebase-biz</module> <module>amos-boot-module-common-biz</module>
<module>amos-boot-module-patrol-biz</module> <module>amos-boot-module-command-biz</module>
<module>amos-boot-module-fas-biz</module> <module>amos-boot-module-knowledgebase-biz</module>
<module>amos-boot-module-maintenance-biz</module> <module>amos-boot-module-patrol-biz</module>
<module>amos-boot-module-supervision-biz</module> <module>amos-boot-module-fas-biz</module>
</modules> <module>amos-boot-module-maintenance-biz</module>
<module>amos-boot-module-supervision-biz</module>
<module>amos-boot-module-jpush-biz</module>
</modules>
</project> </project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <project xmlns="http://maven.apache.org/POM/4.0.0"
<modelVersion>4.0.0</modelVersion> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<parent> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<artifactId>amos-biz-boot</artifactId> <modelVersion>4.0.0</modelVersion>
<groupId>com.amosframework.boot</groupId> <parent>
<version>1.0.0</version> <artifactId>amos-biz-boot</artifactId>
</parent> <groupId>com.amosframework.boot</groupId>
<version>1.0.0</version>
</parent>
<artifactId>amos-boot-module</artifactId> <artifactId>amos-boot-module</artifactId>
<packaging>pom</packaging> <packaging>pom</packaging>
<dependencies> <dependencies>
<!-- amos rule--> <dependency>
<dependency> <groupId>com.amosframework.boot</groupId>
<groupId>com.yeejoin</groupId> <artifactId>amos-boot-biz-common</artifactId>
<artifactId>amos-component-rule</artifactId> <version>${amos-biz-boot.version}</version>
<version>1.4.7</version> </dependency>
<exclusions> </dependencies>
<exclusion>
<groupId>org.typroject</groupId>
<artifactId>tyboot-core-auth</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<modules> <modules>
<module>amos-boot-module-api</module> <module>amos-boot-module-api</module>
<module>amos-boot-module-biz</module> <module>amos-boot-module-biz</module>
<module>amos-boot-cloud-gateway</module> <module>amos-boot-cloud-gateway</module>
</modules> </modules>
</project> </project>
...@@ -13,7 +13,6 @@ ...@@ -13,7 +13,6 @@
<version>3.0.1.3</version> <version>3.0.1.3</version>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>com.amosframework.boot</groupId> <groupId>com.amosframework.boot</groupId>
<artifactId>amos-boot-module-fas-biz</artifactId> <artifactId>amos-boot-module-fas-biz</artifactId>
......
...@@ -32,7 +32,7 @@ rule.definition.default-agency=jcs ...@@ -32,7 +32,7 @@ rule.definition.default-agency=jcs
rule.definition.localIp=172.16.3.39 rule.definition.localIp=172.16.3.39
## mongodb properties: ## mongodb properties:
spring.data.mongodb.uri=mongodb://172.16.3.41:27017/command_db spring.data.mongodb.uri=mongodb://172.16.10.66:27017/command_db
## file properties: ## file properties:
file.url=http://39.98.45.134:9000/ file.url=http://39.98.45.134:9000/
......
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>amos-biz-boot</artifactId>
<groupId>com.amosframework.boot</groupId>
<version>1.0.0</version>
</parent>
<artifactId>amos-boot-system-jpush</artifactId>
<version>8.0.0</version>
<dependencies>
<dependency>
<groupId>com.amosframework.boot</groupId>
<artifactId>amos-boot-module-jpush-biz</artifactId>
<version>${amos-biz-boot.version}</version>
<exclusions>
<exclusion>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-generator</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
package com.yeejoin.amos;
import java.net.InetAddress;
import java.net.UnknownHostException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.core.env.Environment;
import org.springframework.scheduling.annotation.EnableAsync;
import org.typroject.tyboot.core.restful.exception.GlobalExceptionHandler;
/**
* <pre>
* 服务启动类
* </pre>
*
* @author amos
* @version $Id: YeeAMOSPatrolStart.java, v 0.1 2018年11月26日 下午4:56:29 amos Exp $
*/
@SpringBootApplication
@EnableConfigurationProperties
@ServletComponentScan
@EnableDiscoveryClient
@EnableFeignClients
@EnableAsync
@EnableEurekaClient
@ComponentScan({"org.typroject","com.yeejoin.amos"})
public class JpushApplication {
private static final Logger logger = LoggerFactory.getLogger(JpushApplication.class);
public static void main(String[] args) throws UnknownHostException {
ConfigurableApplicationContext context = SpringApplication.run(JpushApplication.class, args);
GlobalExceptionHandler.setAlwaysOk(true);
Environment env = context.getEnvironment();
String ip = InetAddress.getLocalHost().getHostAddress();
String port = env.getProperty("server.port");
String path = env.getProperty("server.servlet.context-path");
logger.info("\n----------------------------------------------------------\n\t" +
"Application Amos-Biz-Boot is running! Access URLs:\n\t" +
"Swagger文档: \thttp://" + ip + ":" + port + path + "/doc.html\n" +
"----------------------------------------------------------");
}
}
\ No newline at end of file
#注册中心地址
eureka.client.service-url.defaultZone =http://172.16.10.72:10001/eureka/
eureka.instance.prefer-ip-address=true
management.endpoint.health.show-details=always
management.endpoints.web.exposure.include=*
eureka.instance.health-check-url-path=/actuator/health
eureka.instance.metadata-map.management.context-path=${server.servlet.context-path}/actuator
eureka.instance.status-page-url-path=/actuator/info
eureka.instance.metadata-map.management.api-docs=http://localhost:${server.port}${server.servlet.context-path}/swagger-ui.html
params.isPush=true
\ No newline at end of file
eureka.client.serviceUrl.defaultZone=http://amos-eurka:10001/eureka/
eureka.client.register-with-eureka=true
eureka.client.fetch-registry=true
eureka.client.healthcheck.enabled=true
eureka.client.fetchRegistry=true
params.isPush=true
\ No newline at end of file
server.port=7800
spring.application.name=AMOS-PUSH
spring.profiles.active=dev
spring.jackson.time-zone=GMT+8
spring.jackson.date-format=yyyy-MM-dd HH:mm:ss
ribbon.eureka.enabled=true
ribbon.ConnectTimeout=60000
ribbon.ReadTimeout=60000
ribbon.OkToRetryOnAllOperations=true
ribbon.MaxAutoRetriesNextServer=2
ribbon.MaxAutoRetries=1
spring.jackson.serialization.write-dates-as-timestamps=true
<?xml version="1.0" encoding="UTF-8"?>
<configuration debug="false">
<!--定义日志文件的存储地址 勿在 LogBack 的配置中使用相对路径-->
<property name="LOG_HOME" value="log" />
<!-- 按照每天生成日志文件 -->
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<!--日志文件输出的文件名-->
<FileNamePattern>${LOG_HOME}/knowledgebase.log.%d{yyyy-MM-dd}.%i.log</FileNamePattern>
<!--日志文件保留天数-->
<MaxHistory>30</MaxHistory>
<!--日志文件大小-->
<MaxFileSize>30mb</MaxFileSize>
</rollingPolicy>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符-->
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern>
</encoder>
</appender>
<!-- 控制台输出 -->
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符-->
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern>
</encoder>
</appender>
<!-- show parameters for hibernate sql 专为 Hibernate 定制
<logger name="org.hibernate.type.descriptor.sql.BasicBinder" level="TRACE" />
<logger name="org.hibernate.type.descriptor.sql.BasicExtractor" level="DEBUG" />
<logger name="org.hibernate.SQL" level="DEBUG" />
<logger name="org.hibernate.engine.QueryParameters" level="DEBUG" />
<logger name="org.hibernate.engine.query.HQLQueryPlan" level="DEBUG" />
-->
<!--myibatis log configure-->
<logger name="com.apache.ibatis" level="DEBUG"/>
<logger name="org.mybatis" level="DEBUG" />
<logger name="java.sql.Connection" level="DEBUG"/>
<logger name="java.sql.Statement" level="DEBUG"/>
<logger name="java.sql.PreparedStatement" level="DEBUG"/>
<logger name="org.springframework" level="DEBUG"/>
<!-- 日志输出级别 -->
<root level="DEBUG">
<appender-ref ref="FILE" />
<appender-ref ref="STDOUT" />
</root>
</configuration>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<configuration debug="false">
<!--定义日志文件的存储地址 勿在 LogBack 的配置中使用相对路径-->
<property name="LOG_HOME" value="log"/>
<!-- 按照每天生成日志文件 -->
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!--日志文件输出的文件名-->
<FileNamePattern>${LOG_HOME}/knowledgebase.%d{yyyy-MM-dd}.%i.log</FileNamePattern>
<!--日志文件保留天数-->
<MaxHistory>30</MaxHistory>
<!--按大小分割同一天的-->
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>100MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
</rollingPolicy>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符-->
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern>
</encoder>
</appender>
<!-- show parameters for hibernate sql 专为 Hibernate 定制
<logger name="org.hibernate.type.descriptor.sql.BasicBinder" level="TRACE" />
<logger name="org.hibernate.type.descriptor.sql.BasicExtractor" level="DEBUG" />
<logger name="org.hibernate.SQL" level="DEBUG" />
<logger name="org.hibernate.engine.QueryParameters" level="DEBUG" />
<logger name="org.hibernate.engine.query.HQLQueryPlan" level="DEBUG" />
-->
<!--myibatis log configure-->
<logger name="com.apache.ibatis" level="INFO"/>
<logger name="org.mybatis" level="INFO"/>
<logger name="java.sql.Connection" level="INFO"/>
<logger name="java.sql.Statement" level="INFO"/>
<logger name="java.sql.PreparedStatement" level="INFO"/>
<logger name="com.baomidou.mybatisplus" level="INFO"/>
<logger name="org.typroject" level="INFO"/>
<logger name="com.yeejoin.amos" level="INFO"/>
<logger name="org.springframework" level="INFO"/>
<!-- 日志输出级别 -->
<root level="INFO">
<appender-ref ref="FILE"/>
</root>
</configuration>
\ No newline at end of file
...@@ -62,21 +62,6 @@ ...@@ -62,21 +62,6 @@
<version>1.2.67</version> <version>1.2.67</version>
</dependency> </dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.2.0</version>
</dependency>
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>2.1.0</version>
</dependency>
<!--
<dependency> <groupId>com.baomidou</groupId> <artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.1.2</version> </dependency> -->
<!--����MongoDB -->
<dependency> <dependency>
<groupId>com.alibaba</groupId> <groupId>com.alibaba</groupId>
...@@ -89,7 +74,6 @@ ...@@ -89,7 +74,6 @@
</exclusion> </exclusion>
</exclusions> </exclusions>
</dependency> </dependency>
<!-- ���commons-lang������ -->
<dependency> <dependency>
<groupId>commons-lang</groupId> <groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId> <artifactId>commons-lang</artifactId>
...@@ -100,80 +84,69 @@ ...@@ -100,80 +84,69 @@
<artifactId>commons-compress</artifactId> <artifactId>commons-compress</artifactId>
<version>1.18</version> <version>1.18</version>
</dependency> </dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<!--集成apache poi word 转html --> <artifactId>poi-scratchpad</artifactId>
<version>3.17</version>
<dependency> <exclusions>
<groupId>org.apache.poi</groupId> <exclusion>
<artifactId>poi-scratchpad</artifactId> <artifactId>poi</artifactId>
<version>3.17</version> <groupId>org.apache.poi</groupId>
<exclusions> </exclusion>
<exclusion> </exclusions>
<artifactId>poi</artifactId> </dependency>
<groupId>org.apache.poi</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.17</version>
<exclusions>
<exclusion>
<artifactId>poi</artifactId>
<groupId>org.apache.poi</groupId>
</exclusion>
<exclusion>
<artifactId>poi-ooxml-schemas</artifactId>
<groupId>org.apache.poi</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>fr.opensagres.xdocreport</groupId>
<artifactId>xdocreport</artifactId>
<version>1.0.6</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml-schemas</artifactId>
<version>3.17</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>ooxml-schemas</artifactId>
<version>1.3</version>
<exclusions>
<exclusion>
<artifactId>xmlbeans</artifactId>
<groupId>org.apache.xmlbeans</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<version>1.11.3</version>
</dependency>
<dependency> <dependency>
<groupId>org.apache.commons</groupId> <groupId>org.apache.poi</groupId>
<artifactId>commons-lang3</artifactId> <artifactId>poi-ooxml</artifactId>
<version>3.17</version>
<exclusions>
<exclusion>
<artifactId>poi</artifactId>
<groupId>org.apache.poi</groupId>
</exclusion>
<exclusion>
<artifactId>poi-ooxml-schemas</artifactId>
<groupId>org.apache.poi</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>fr.opensagres.xdocreport</groupId>
<artifactId>xdocreport</artifactId>
<version>1.0.6</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml-schemas</artifactId>
<version>3.17</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.baomidou</groupId> <groupId>org.apache.poi</groupId>
<artifactId>mybatis-plus-generator</artifactId> <artifactId>ooxml-schemas</artifactId>
<version>3.2.0</version> <version>1.3</version>
<exclusions>
<exclusion>
<artifactId>xmlbeans</artifactId>
<groupId>org.apache.xmlbeans</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<version>1.11.3</version>
</dependency>
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.10.4</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.apache.velocity</groupId> <groupId>org.apache.velocity</groupId>
...@@ -231,53 +204,47 @@ ...@@ -231,53 +204,47 @@
</exclusion> </exclusion>
<exclusion> <exclusion>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-undertow</artifactId> <artifactId>spring-boot-starter-undertow</artifactId>
</exclusion> </exclusion>
</exclusions> </exclusions>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.yeejoin</groupId>
<artifactId>amos-feign-privilege</artifactId>
<version>${amos.version}</version>
</dependency>
<dependency>
<groupId>com.yeejoin</groupId>
<artifactId>amos-feign-systemctl</artifactId>
<version>${amos.version}</version>
</dependency>
<dependency>
<groupId>org.typroject</groupId> <groupId>org.typroject</groupId>
<artifactId>tyboot-core-auth</artifactId> <artifactId>tyboot-core-rdbms</artifactId>
<version>${tyboot-version}</version> <version>${tyboot-version}</version>
<exclusions> <exclusions>
<exclusion> <exclusion>
<groupId>org.typroject</groupId> <groupId>org.typroject</groupId>
<artifactId>*</artifactId> <artifactId>*</artifactId>
</exclusion> </exclusion>
<exclusion>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
</exclusion>
</exclusions> </exclusions>
</dependency> </dependency>
<dependency> <dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.10.4</version>
</dependency>
<dependency>
<groupId>org.typroject</groupId> <groupId>org.typroject</groupId>
<artifactId>tyboot-core-rdbms</artifactId> <artifactId>tyboot-core-auth</artifactId>
<version>${tyboot-version}</version> <version>${tyboot-version}</version>
<exclusions> <exclusions>
<exclusion> <exclusion>
<groupId>org.typroject</groupId> <groupId>org.typroject</groupId>
<artifactId>*</artifactId> <artifactId>*</artifactId>
</exclusion> </exclusion>
<exclusion>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
</exclusion>
</exclusions> </exclusions>
</dependency> </dependency>
<dependency>
<groupId>com.yeejoin</groupId>
<artifactId>amos-feign-privilege</artifactId>
<version>${amos.version}</version>
</dependency>
<dependency>
<groupId>com.yeejoin</groupId>
<artifactId>amos-feign-systemctl</artifactId>
<version>${amos.version}</version>
</dependency>
</dependencies> </dependencies>
<dependencyManagement> <dependencyManagement>
<dependencies> <dependencies>
<dependency> <dependency>
...@@ -295,6 +262,26 @@ ...@@ -295,6 +262,26 @@
<type>pom</type> <type>pom</type>
<scope>import</scope> <scope>import</scope>
</dependency> </dependency>
<dependency>
<groupId>com.yeejoin</groupId>
<artifactId>amos-component-rule</artifactId>
<version>1.4.7</version>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-generator</artifactId>
<version>3.2.0</version>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.2.0</version>
</dependency>
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>2.1.0</version>
</dependency>
</dependencies> </dependencies>
</dependencyManagement> </dependencyManagement>
<repositories> <repositories>
...@@ -334,5 +321,6 @@ ...@@ -334,5 +321,6 @@
<module>amos-boot-system-patrol</module> <module>amos-boot-system-patrol</module>
<module>amos-boot-system-maintenance</module> <module>amos-boot-system-maintenance</module>
<module>amos-boot-system-supervision</module> <module>amos-boot-system-supervision</module>
<module>amos-boot-system-jpush</module>
</modules> </modules>
</project> </project>
\ No newline at end of file
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