37 changed files with 2128 additions and 0 deletions
@ -0,0 +1,35 @@ |
|||||
|
<?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> |
||||
|
<groupId>com.epmet</groupId> |
||||
|
<artifactId>epmet-common-service</artifactId> |
||||
|
<version>2.0.0</version> |
||||
|
</parent> |
||||
|
|
||||
|
<artifactId>common-service-client</artifactId> |
||||
|
<packaging>jar</packaging> |
||||
|
|
||||
|
<dependencies> |
||||
|
<dependency> |
||||
|
<groupId>com.epmet</groupId> |
||||
|
<artifactId>epmet-commons-tools</artifactId> |
||||
|
<version>2.0.0</version> |
||||
|
</dependency> |
||||
|
<dependency> |
||||
|
<groupId>io.springfox</groupId> |
||||
|
<artifactId>springfox-swagger2</artifactId> |
||||
|
</dependency> |
||||
|
<dependency> |
||||
|
<groupId>io.springfox</groupId> |
||||
|
<artifactId>springfox-swagger-ui</artifactId> |
||||
|
</dependency> |
||||
|
</dependencies> |
||||
|
|
||||
|
<build> |
||||
|
<finalName>${project.artifactId}</finalName> |
||||
|
</build> |
||||
|
|
||||
|
</project> |
@ -0,0 +1,131 @@ |
|||||
|
/** |
||||
|
* Copyright 2018 人人开源 https://www.renren.io
|
||||
|
* <p> |
||||
|
* This program is free software: you can redistribute it and/or modify |
||||
|
* it under the terms of the GNU General Public License as published by |
||||
|
* the Free Software Foundation, either version 3 of the License, or |
||||
|
* (at your option) any later version. |
||||
|
* <p> |
||||
|
* This program is distributed in the hope that it will be useful, |
||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
|
* GNU General Public License for more details. |
||||
|
* <p> |
||||
|
* You should have received a copy of the GNU General Public License |
||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
*/ |
||||
|
|
||||
|
package com.epmet.dto; |
||||
|
|
||||
|
import java.io.Serializable; |
||||
|
import java.util.Date; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* |
||||
|
* |
||||
|
* @author generator generator@elink-cn.com |
||||
|
* @since v1.0.0 2020-05-11 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class CalenderDTO implements Serializable { |
||||
|
|
||||
|
private static final long serialVersionUID = 1L; |
||||
|
|
||||
|
/** |
||||
|
* 主键 |
||||
|
*/ |
||||
|
private String id; |
||||
|
|
||||
|
/** |
||||
|
* 0表示成功,其他为失败 |
||||
|
*/ |
||||
|
private Integer retCode; |
||||
|
|
||||
|
/** |
||||
|
* 查询的日期:20200510 |
||||
|
*/ |
||||
|
private String day; |
||||
|
|
||||
|
/** |
||||
|
* 查询的日期:20200510 |
||||
|
*/ |
||||
|
private Date queryDate; |
||||
|
|
||||
|
/** |
||||
|
* 星期几的数字 |
||||
|
*/ |
||||
|
private Integer weekday; |
||||
|
|
||||
|
/** |
||||
|
* 节日或周末开始时间,如果是工作日,此字段为空串 |
||||
|
*/ |
||||
|
private String begin; |
||||
|
|
||||
|
/** |
||||
|
* 节日或周末结束时间,如果是工作日,此字段为空串 |
||||
|
*/ |
||||
|
private String end; |
||||
|
|
||||
|
/** |
||||
|
* 节日备注 |
||||
|
*/ |
||||
|
private String holidayRemark; |
||||
|
|
||||
|
/** |
||||
|
* 1为工作日,2为周末,3为节假日 |
||||
|
*/ |
||||
|
private String type; |
||||
|
|
||||
|
/** |
||||
|
* 工作日,周末,节假日 |
||||
|
*/ |
||||
|
private String typeName; |
||||
|
|
||||
|
/** |
||||
|
* 节日名称,工作日时显示“无”,周末时显示“周末”,节日时显示节日名称 |
||||
|
*/ |
||||
|
private String holiday; |
||||
|
|
||||
|
/** |
||||
|
* 星期几的英文名 |
||||
|
*/ |
||||
|
private String en; |
||||
|
|
||||
|
/** |
||||
|
* 星期几的中文名 |
||||
|
*/ |
||||
|
private String cn; |
||||
|
|
||||
|
/** |
||||
|
* 是否删除,0:未删除,1:已删除 |
||||
|
*/ |
||||
|
private Integer delFlag; |
||||
|
|
||||
|
/** |
||||
|
* 乐观锁 |
||||
|
*/ |
||||
|
private Integer revision; |
||||
|
|
||||
|
/** |
||||
|
* 创建者id |
||||
|
*/ |
||||
|
private String createdBy; |
||||
|
|
||||
|
/** |
||||
|
* 创建时间 |
||||
|
*/ |
||||
|
private Date createdTime; |
||||
|
|
||||
|
/** |
||||
|
* 更新者id |
||||
|
*/ |
||||
|
private String updatedBy; |
||||
|
|
||||
|
/** |
||||
|
* 更新时间 |
||||
|
*/ |
||||
|
private Date updatedTime; |
||||
|
|
||||
|
} |
@ -0,0 +1,31 @@ |
|||||
|
package com.epmet.dto.form; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
|
||||
|
import java.io.Serializable; |
||||
|
|
||||
|
/** |
||||
|
* @Description 工作日计算入参 |
||||
|
* @Author yinzuomei |
||||
|
* @Date 2020/5/11 21:53 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class WorkDayFormDTO implements Serializable { |
||||
|
private static final long serialVersionUID = 5018009446003442250L; |
||||
|
|
||||
|
/** |
||||
|
* key |
||||
|
*/ |
||||
|
private String id; |
||||
|
|
||||
|
/** |
||||
|
* 起始日期 |
||||
|
*/ |
||||
|
private String startDate; |
||||
|
|
||||
|
/** |
||||
|
* 终止日期 |
||||
|
*/ |
||||
|
private String endDate; |
||||
|
} |
||||
|
|
@ -0,0 +1,37 @@ |
|||||
|
package com.epmet.dto.result; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
|
||||
|
import javax.validation.constraints.NotBlank; |
||||
|
import java.io.Serializable; |
||||
|
|
||||
|
/** |
||||
|
* @Description 工作日计算返参 |
||||
|
* @Author yinzuomei |
||||
|
* @Date 2020/5/11 21:48 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class WorkDayResultDTO implements Serializable { |
||||
|
private static final long serialVersionUID = 4578531109651717997L; |
||||
|
|
||||
|
/** |
||||
|
* key |
||||
|
*/ |
||||
|
private String id; |
||||
|
|
||||
|
/** |
||||
|
* 起始日期 |
||||
|
*/ |
||||
|
private String startDate; |
||||
|
|
||||
|
/** |
||||
|
* 终止日期 |
||||
|
*/ |
||||
|
private String endDate; |
||||
|
|
||||
|
/** |
||||
|
* 已滞留工作日 |
||||
|
*/ |
||||
|
private String detentionDays; |
||||
|
} |
||||
|
|
@ -0,0 +1,11 @@ |
|||||
|
FROM java:8 |
||||
|
|
||||
|
RUN export LANG="zh_CN.UTF-8" |
||||
|
RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime |
||||
|
RUN echo 'Asia/Shanghai' > /etc/timezone |
||||
|
|
||||
|
COPY ./target/*.jar ./app.jar |
||||
|
|
||||
|
EXPOSE 8103 |
||||
|
|
||||
|
ENTRYPOINT ["java","-Xms32m","-Xmx200m","-jar","./app.jar"] |
@ -0,0 +1,15 @@ |
|||||
|
version: "3.7" |
||||
|
services: |
||||
|
common-service-server: |
||||
|
container_name: common-service-server-dev |
||||
|
image: registry-vpc.cn-qingdao.aliyuncs.com/epmet-cloud-dev/common-service-server:0.3.0 |
||||
|
ports: |
||||
|
- "8103:8103" |
||||
|
network_mode: host # 使用现有网络 |
||||
|
volumes: |
||||
|
- "/opt/epmet-cloud-logs/dev:/logs" |
||||
|
deploy: |
||||
|
resources: |
||||
|
limits: |
||||
|
cpus: '0.1' |
||||
|
memory: 250M |
@ -0,0 +1,148 @@ |
|||||
|
<?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> |
||||
|
<version>0.3.0</version> |
||||
|
<parent> |
||||
|
<groupId>com.epmet</groupId> |
||||
|
<artifactId>epmet-common-service</artifactId> |
||||
|
<version>2.0.0</version> |
||||
|
</parent> |
||||
|
<artifactId>common-service-server</artifactId> |
||||
|
<packaging>jar</packaging> |
||||
|
|
||||
|
<dependencies> |
||||
|
<dependency> |
||||
|
<groupId>com.epmet</groupId> |
||||
|
<artifactId>common-service-client</artifactId> |
||||
|
<version>2.0.0</version> |
||||
|
</dependency> |
||||
|
<dependency> |
||||
|
<groupId>com.epmet</groupId> |
||||
|
<artifactId>epmet-commons-tools</artifactId> |
||||
|
<version>2.0.0</version> |
||||
|
</dependency> |
||||
|
<dependency> |
||||
|
<groupId>com.epmet</groupId> |
||||
|
<artifactId>epmet-commons-mybatis</artifactId> |
||||
|
<version>2.0.0</version> |
||||
|
</dependency> |
||||
|
<dependency> |
||||
|
<groupId>org.springframework.boot</groupId> |
||||
|
<artifactId>spring-boot-starter-web</artifactId> |
||||
|
</dependency> |
||||
|
<dependency> |
||||
|
<groupId>org.springframework</groupId> |
||||
|
<artifactId>spring-context-support</artifactId> |
||||
|
</dependency> |
||||
|
<dependency> |
||||
|
<groupId>org.springframework.boot</groupId> |
||||
|
<artifactId>spring-boot-starter-actuator</artifactId> |
||||
|
</dependency> |
||||
|
<dependency> |
||||
|
<groupId>de.codecentric</groupId> |
||||
|
<artifactId>spring-boot-admin-starter-client</artifactId> |
||||
|
<version>${spring.boot.admin.version}</version> |
||||
|
</dependency> |
||||
|
<dependency> |
||||
|
<groupId>com.alibaba.cloud</groupId> |
||||
|
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId> |
||||
|
</dependency> |
||||
|
<dependency> |
||||
|
<groupId>com.alibaba.cloud</groupId> |
||||
|
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId> |
||||
|
</dependency> |
||||
|
<!-- 替换Feign原生httpclient --> |
||||
|
<dependency> |
||||
|
<groupId>io.github.openfeign</groupId> |
||||
|
<artifactId>feign-httpclient</artifactId> |
||||
|
<version>10.3.0</version> |
||||
|
</dependency> |
||||
|
</dependencies> |
||||
|
|
||||
|
<build> |
||||
|
<finalName>${project.artifactId}</finalName> |
||||
|
<plugins> |
||||
|
<plugin> |
||||
|
<groupId>org.springframework.boot</groupId> |
||||
|
<artifactId>spring-boot-maven-plugin</artifactId> |
||||
|
</plugin> |
||||
|
<plugin> |
||||
|
<groupId>org.apache.maven.plugins</groupId> |
||||
|
<artifactId>maven-surefire-plugin</artifactId> |
||||
|
<configuration> |
||||
|
<skipTests>true</skipTests> |
||||
|
</configuration> |
||||
|
</plugin> |
||||
|
</plugins> |
||||
|
<sourceDirectory>${project.basedir}/src/main/java</sourceDirectory> |
||||
|
<resources> |
||||
|
<resource> |
||||
|
<filtering>true</filtering> |
||||
|
<directory>${basedir}/src/main/resources</directory> |
||||
|
</resource> |
||||
|
</resources> |
||||
|
</build> |
||||
|
<profiles> |
||||
|
<profile> |
||||
|
<id>dev-local</id> |
||||
|
<activation> |
||||
|
<activeByDefault>true</activeByDefault> |
||||
|
</activation> |
||||
|
<properties> |
||||
|
<server.port>8103</server.port> |
||||
|
<spring.profiles.active>dev</spring.profiles.active> |
||||
|
|
||||
|
<!-- 数据库配置--> |
||||
|
<spring.datasource.druid.url> |
||||
|
<![CDATA[jdbc:mysql://localhost:3306/epmet_common_service?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai]]> |
||||
|
</spring.datasource.druid.url> |
||||
|
<spring.datasource.druid.username>root</spring.datasource.druid.username> |
||||
|
<spring.datasource.druid.password>root</spring.datasource.druid.password> |
||||
|
<!-- redis配置 --> |
||||
|
<spring.redis.index>0</spring.redis.index> |
||||
|
<spring.redis.host>192.168.1.130</spring.redis.host> |
||||
|
<spring.redis.port>6379</spring.redis.port> |
||||
|
<spring.redis.password>123456</spring.redis.password> |
||||
|
<!-- nacos --> |
||||
|
<nacos.register-enabled>false</nacos.register-enabled> |
||||
|
<nacos.server-addr>122.152.200.70:8848</nacos.server-addr> |
||||
|
<nacos.discovery.namespace>fcd6fc8f-ca3a-4b01-8026-2b05cdc5976b</nacos.discovery.namespace> |
||||
|
<nacos.config.namespace></nacos.config.namespace> |
||||
|
<nacos.config.group></nacos.config.group> |
||||
|
<nacos.config-enabled>false</nacos.config-enabled> |
||||
|
<nacos.ip/> |
||||
|
</properties> |
||||
|
</profile> |
||||
|
<profile> |
||||
|
<id>dev</id> |
||||
|
<!--<activation> |
||||
|
<activeByDefault>true</activeByDefault> |
||||
|
</activation>--> |
||||
|
<properties> |
||||
|
<server.port>8103</server.port> |
||||
|
<spring.profiles.active>dev</spring.profiles.active> |
||||
|
|
||||
|
<!-- 数据库配置--> |
||||
|
<spring.datasource.druid.url> |
||||
|
<![CDATA[jdbc:mysql://rm-m5ef9t617j6o5eup7.mysql.rds.aliyuncs.com:3306/epmet_resi_group_dev?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai]]> |
||||
|
</spring.datasource.druid.url> |
||||
|
<spring.datasource.druid.username>epmet</spring.datasource.druid.username> |
||||
|
<spring.datasource.druid.password>elink@833066</spring.datasource.druid.password> |
||||
|
<!-- redis配置 --> |
||||
|
<spring.redis.index>0</spring.redis.index> |
||||
|
<spring.redis.host>r-m5eoz5b6tkx09y6bpz.redis.rds.aliyuncs.com</spring.redis.host> |
||||
|
<spring.redis.port>6379</spring.redis.port> |
||||
|
<spring.redis.password>EpmEtrEdIs!q@w</spring.redis.password> |
||||
|
<!-- nacos --> |
||||
|
<nacos.register-enabled>true</nacos.register-enabled> |
||||
|
<nacos.server-addr>192.168.10.150:8848</nacos.server-addr> |
||||
|
<nacos.discovery.namespace>67e3c350-533e-4d7c-9f8f-faf1b4aa82ae</nacos.discovery.namespace> |
||||
|
<nacos.config.namespace></nacos.config.namespace> |
||||
|
<nacos.config.group></nacos.config.group> |
||||
|
<nacos.config-enabled>false</nacos.config-enabled> |
||||
|
<nacos.ip/> |
||||
|
</properties> |
||||
|
</profile> |
||||
|
</profiles> |
||||
|
</project> |
@ -0,0 +1,31 @@ |
|||||
|
/** |
||||
|
* Copyright (c) 2018 人人开源 All rights reserved. |
||||
|
* |
||||
|
* https://www.renren.io
|
||||
|
* |
||||
|
* 版权所有,侵权必究! |
||||
|
*/ |
||||
|
|
||||
|
package com.epmet; |
||||
|
|
||||
|
import org.springframework.boot.SpringApplication; |
||||
|
import org.springframework.boot.autoconfigure.SpringBootApplication; |
||||
|
import org.springframework.cloud.client.discovery.EnableDiscoveryClient; |
||||
|
import org.springframework.cloud.openfeign.EnableFeignClients; |
||||
|
|
||||
|
/** |
||||
|
* 模块 |
||||
|
* |
||||
|
* @author Mark sunlightcs@gmail.com |
||||
|
* @since 1.0.0 |
||||
|
*/ |
||||
|
@SpringBootApplication |
||||
|
@EnableDiscoveryClient |
||||
|
@EnableFeignClients |
||||
|
public class EpmetCommonServiceApplication { |
||||
|
|
||||
|
public static void main(String[] args) { |
||||
|
SpringApplication.run(EpmetCommonServiceApplication.class, args); |
||||
|
} |
||||
|
|
||||
|
} |
@ -0,0 +1,26 @@ |
|||||
|
/** |
||||
|
* Copyright (c) 2018 人人开源 All rights reserved. |
||||
|
* |
||||
|
* https://www.renren.io
|
||||
|
* |
||||
|
* 版权所有,侵权必究! |
||||
|
*/ |
||||
|
|
||||
|
package com.epmet.config; |
||||
|
|
||||
|
import com.epmet.commons.tools.config.ModuleConfig; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
|
||||
|
/** |
||||
|
* 模块配置信息 |
||||
|
* |
||||
|
* @author Mark sunlightcs@gmail.com |
||||
|
* @since 1.0.0 |
||||
|
*/ |
||||
|
@Service |
||||
|
public class ModuleConfigImpl implements ModuleConfig { |
||||
|
@Override |
||||
|
public String getName() { |
||||
|
return "commonservice"; |
||||
|
} |
||||
|
} |
@ -0,0 +1,36 @@ |
|||||
|
package com.epmet.constant; |
||||
|
|
||||
|
/** |
||||
|
* @Description 万维易源API |
||||
|
* @Author yinzuomei |
||||
|
* @Date 2020/5/11 16:56 |
||||
|
*/ |
||||
|
public interface ShowApiConstant { |
||||
|
/** |
||||
|
* showapi_appid |
||||
|
*/ |
||||
|
String SHOWAPI_APPID = "222733"; |
||||
|
|
||||
|
/** |
||||
|
* secret |
||||
|
*/ |
||||
|
String SHOWAPI_SIGN = "ada451c248454d4eaf2db178482f14a7"; |
||||
|
|
||||
|
/** |
||||
|
* 2020年我国节假日查询,持续更新中...... |
||||
|
* api:https://route.showapi.com/894-5
|
||||
|
* 第一个参数:showapi_appidshowapi_appid |
||||
|
* 第二个参数:showapi_sign=secret |
||||
|
* 第三个参数:输入格式yyyyMMdd。如果不输入,则默认是当天。 |
||||
|
*/ |
||||
|
String QUERY_HOLIDAY_V2020 = "http://route.showapi.com/894-5?showapi_appid=%s&showapi_sign=%s&day=%s"; |
||||
|
|
||||
|
/** |
||||
|
* 根据年份查询当年的节假日列表 |
||||
|
* api:https://route.showapi.com/894-5
|
||||
|
* 第一个参数:showapi_appidshowapi_appid |
||||
|
* 第二个参数:showapi_sign=secret |
||||
|
* 第三个参数:year需要查询的年份,默认查询2019年的节假日列表 |
||||
|
*/ |
||||
|
String HOLIDAY_LIST = "http://route.showapi.com/894-4?showapi_appid=%s&showapi_sign=%s&year=%s"; |
||||
|
} |
@ -0,0 +1,85 @@ |
|||||
|
/** |
||||
|
* Copyright 2018 人人开源 https://www.renren.io
|
||||
|
* <p> |
||||
|
* This program is free software: you can redistribute it and/or modify |
||||
|
* it under the terms of the GNU General Public License as published by |
||||
|
* the Free Software Foundation, either version 3 of the License, or |
||||
|
* (at your option) any later version. |
||||
|
* <p> |
||||
|
* This program is distributed in the hope that it will be useful, |
||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
|
* GNU General Public License for more details. |
||||
|
* <p> |
||||
|
* You should have received a copy of the GNU General Public License |
||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
*/ |
||||
|
|
||||
|
package com.epmet.controller; |
||||
|
|
||||
|
import com.epmet.commons.tools.page.PageData; |
||||
|
import com.epmet.commons.tools.utils.Result; |
||||
|
import com.epmet.commons.tools.validator.AssertUtils; |
||||
|
import com.epmet.commons.tools.validator.ValidatorUtils; |
||||
|
import com.epmet.commons.tools.validator.group.AddGroup; |
||||
|
import com.epmet.commons.tools.validator.group.UpdateGroup; |
||||
|
import com.epmet.commons.tools.validator.group.DefaultGroup; |
||||
|
import com.epmet.dto.CalenderDTO; |
||||
|
import com.epmet.service.CalenderService; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.web.bind.annotation.*; |
||||
|
|
||||
|
import java.util.Map; |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* |
||||
|
* |
||||
|
* @author generator generator@elink-cn.com |
||||
|
* @since v1.0.0 2020-05-11 |
||||
|
*/ |
||||
|
@RestController |
||||
|
@RequestMapping("calender") |
||||
|
public class CalenderController { |
||||
|
|
||||
|
@Autowired |
||||
|
private CalenderService calenderService; |
||||
|
|
||||
|
@GetMapping("page") |
||||
|
public Result<PageData<CalenderDTO>> page(@RequestParam Map<String, Object> params){ |
||||
|
PageData<CalenderDTO> page = calenderService.page(params); |
||||
|
return new Result<PageData<CalenderDTO>>().ok(page); |
||||
|
} |
||||
|
|
||||
|
@GetMapping("{id}") |
||||
|
public Result<CalenderDTO> get(@PathVariable("id") String id){ |
||||
|
CalenderDTO data = calenderService.get(id); |
||||
|
return new Result<CalenderDTO>().ok(data); |
||||
|
} |
||||
|
|
||||
|
@PostMapping |
||||
|
public Result save(@RequestBody CalenderDTO dto){ |
||||
|
//效验数据
|
||||
|
ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); |
||||
|
calenderService.save(dto); |
||||
|
return new Result(); |
||||
|
} |
||||
|
|
||||
|
@PutMapping |
||||
|
public Result update(@RequestBody CalenderDTO dto){ |
||||
|
//效验数据
|
||||
|
ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); |
||||
|
calenderService.update(dto); |
||||
|
return new Result(); |
||||
|
} |
||||
|
|
||||
|
@DeleteMapping |
||||
|
public Result delete(@RequestBody String[] ids){ |
||||
|
//效验数据
|
||||
|
AssertUtils.isArrayEmpty(ids, "id"); |
||||
|
calenderService.delete(ids); |
||||
|
return new Result(); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
} |
@ -0,0 +1,62 @@ |
|||||
|
package com.epmet.controller; |
||||
|
|
||||
|
import com.epmet.commons.tools.utils.Result; |
||||
|
import com.epmet.service.ShowApiService; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.web.bind.annotation.PathVariable; |
||||
|
import org.springframework.web.bind.annotation.PostMapping; |
||||
|
import org.springframework.web.bind.annotation.RequestMapping; |
||||
|
import org.springframework.web.bind.annotation.RestController; |
||||
|
|
||||
|
/** |
||||
|
* @Description 工作日信息维护 |
||||
|
* @Author yinzuomei |
||||
|
* @Date 2020/5/11 21:39 |
||||
|
*/ |
||||
|
@RestController |
||||
|
@RequestMapping("holiday") |
||||
|
public class ShowApiController { |
||||
|
|
||||
|
@Autowired |
||||
|
private ShowApiService showApiService; |
||||
|
|
||||
|
/** |
||||
|
* @return com.epmet.commons.tools.utils.Result |
||||
|
* @param year |
||||
|
* @Author yinzuomei |
||||
|
* @Description 初始化日历插入数据库 |
||||
|
* @Date 2020/5/11 23:23 |
||||
|
**/ |
||||
|
@PostMapping("init/{year}") |
||||
|
public Result initYearCalender(@PathVariable("year") String year) { |
||||
|
showApiService.initYearCalender(year); |
||||
|
return new Result(); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* @return com.epmet.commons.tools.utils.Result |
||||
|
* @Author yinzuomei |
||||
|
* @Description 2020年我国节假日查询 |
||||
|
* @Date 2020/5/11 23:24 |
||||
|
**/ |
||||
|
@PostMapping("initWorkDayList/{year}") |
||||
|
public Result initWorkDayList(@PathVariable("year") String year) { |
||||
|
showApiService.initWorkDayList(year); |
||||
|
return new Result(); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* @return com.epmet.commons.tools.utils.Result |
||||
|
* @param year |
||||
|
* @Author yinzuomei |
||||
|
* @Description 根据年份查询当年的节假日列表(调用api同步到本地) |
||||
|
* @Date 2020/5/11 23:24 |
||||
|
**/ |
||||
|
@PostMapping("holidayList/{year}") |
||||
|
public Result holidayList(@PathVariable("year") String year) { |
||||
|
showApiService.holidayList(year); |
||||
|
return new Result(); |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
|
@ -0,0 +1,41 @@ |
|||||
|
package com.epmet.controller; |
||||
|
|
||||
|
import com.epmet.commons.tools.utils.Result; |
||||
|
import com.epmet.dto.form.WorkDayFormDTO; |
||||
|
import com.epmet.dto.result.WorkDayResultDTO; |
||||
|
import com.epmet.service.WorkDayService; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.web.bind.annotation.PostMapping; |
||||
|
import org.springframework.web.bind.annotation.RequestBody; |
||||
|
import org.springframework.web.bind.annotation.RequestMapping; |
||||
|
import org.springframework.web.bind.annotation.RestController; |
||||
|
|
||||
|
import java.util.List; |
||||
|
import java.util.Set; |
||||
|
|
||||
|
/** |
||||
|
* @Description 工作日计算 |
||||
|
* @Author yinzuomei |
||||
|
* @Date 2020/5/12 0:27 |
||||
|
*/ |
||||
|
@RestController |
||||
|
@RequestMapping("workday") |
||||
|
public class WorkDayController { |
||||
|
|
||||
|
@Autowired |
||||
|
private WorkDayService workDayService; |
||||
|
|
||||
|
/** |
||||
|
* @return com.epmet.commons.tools.utils.Result<java.util.List<com.epmet.dto.result.WorkDayResultDTO>> |
||||
|
* @param formDTO |
||||
|
* @Author yinzuomei |
||||
|
* @Description 根据每一组起止时间,计算工作日 |
||||
|
* @Date 2020/5/12 2:08 |
||||
|
**/ |
||||
|
@PostMapping("detentiondays") |
||||
|
public Result<List<WorkDayResultDTO>> detentionDays(@RequestBody List<WorkDayFormDTO> formDTO) { |
||||
|
List<WorkDayResultDTO> list = workDayService.detentionDays(formDTO); |
||||
|
return new Result<List<WorkDayResultDTO>>().ok(list); |
||||
|
} |
||||
|
} |
||||
|
|
@ -0,0 +1,44 @@ |
|||||
|
/** |
||||
|
* Copyright 2018 人人开源 https://www.renren.io
|
||||
|
* <p> |
||||
|
* This program is free software: you can redistribute it and/or modify |
||||
|
* it under the terms of the GNU General Public License as published by |
||||
|
* the Free Software Foundation, either version 3 of the License, or |
||||
|
* (at your option) any later version. |
||||
|
* <p> |
||||
|
* This program is distributed in the hope that it will be useful, |
||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
|
* GNU General Public License for more details. |
||||
|
* <p> |
||||
|
* You should have received a copy of the GNU General Public License |
||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
*/ |
||||
|
|
||||
|
package com.epmet.dao; |
||||
|
|
||||
|
import com.epmet.commons.mybatis.dao.BaseDao; |
||||
|
import com.epmet.entity.CalenderEntity; |
||||
|
import com.epmet.result.HolidayDetailDTO; |
||||
|
import org.apache.ibatis.annotations.Mapper; |
||||
|
import org.apache.ibatis.annotations.Param; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* |
||||
|
* |
||||
|
* @author generator generator@elink-cn.com |
||||
|
* @since v1.0.0 2020-05-11 |
||||
|
*/ |
||||
|
@Mapper |
||||
|
public interface CalenderDao extends BaseDao<CalenderEntity> { |
||||
|
|
||||
|
int updateHoliday(HolidayDetailDTO holidayDetail); |
||||
|
|
||||
|
CalenderEntity selectByDay(String day); |
||||
|
|
||||
|
List<CalenderEntity> selectList(String year); |
||||
|
|
||||
|
List<CalenderEntity> selectByStartAndEnd(@Param("begin")String startDateStr, @Param("end")String endDateStr); |
||||
|
} |
@ -0,0 +1,101 @@ |
|||||
|
/** |
||||
|
* Copyright 2018 人人开源 https://www.renren.io
|
||||
|
* <p> |
||||
|
* This program is free software: you can redistribute it and/or modify |
||||
|
* it under the terms of the GNU General Public License as published by |
||||
|
* the Free Software Foundation, either version 3 of the License, or |
||||
|
* (at your option) any later version. |
||||
|
* <p> |
||||
|
* This program is distributed in the hope that it will be useful, |
||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
|
* GNU General Public License for more details. |
||||
|
* <p> |
||||
|
* You should have received a copy of the GNU General Public License |
||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
*/ |
||||
|
|
||||
|
package com.epmet.entity; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.annotation.TableName; |
||||
|
|
||||
|
import com.epmet.commons.mybatis.entity.BaseEpmetEntity; |
||||
|
import lombok.Data; |
||||
|
import lombok.EqualsAndHashCode; |
||||
|
|
||||
|
import java.util.Date; |
||||
|
|
||||
|
/** |
||||
|
* |
||||
|
* |
||||
|
* @author generator generator@elink-cn.com |
||||
|
* @since v1.0.0 2020-05-11 |
||||
|
*/ |
||||
|
@Data |
||||
|
@EqualsAndHashCode(callSuper=false) |
||||
|
@TableName("calender") |
||||
|
public class CalenderEntity extends BaseEpmetEntity { |
||||
|
|
||||
|
private static final long serialVersionUID = 1L; |
||||
|
|
||||
|
/** |
||||
|
* 0表示成功,其他为失败 |
||||
|
*/ |
||||
|
private Integer retCode; |
||||
|
|
||||
|
/** |
||||
|
* 查询的日期:20200510 |
||||
|
*/ |
||||
|
private String day; |
||||
|
|
||||
|
/** |
||||
|
* 查询的日期:20200510 |
||||
|
*/ |
||||
|
private Date queryDate; |
||||
|
|
||||
|
/** |
||||
|
* 星期几的数字 |
||||
|
*/ |
||||
|
private Integer weekday; |
||||
|
|
||||
|
/** |
||||
|
* 节日或周末开始时间,如果是工作日,此字段为空串 |
||||
|
*/ |
||||
|
private String begin; |
||||
|
|
||||
|
/** |
||||
|
* 节日或周末结束时间,如果是工作日,此字段为空串 |
||||
|
*/ |
||||
|
private String end; |
||||
|
|
||||
|
/** |
||||
|
* 节日备注 |
||||
|
*/ |
||||
|
private String holidayRemark; |
||||
|
|
||||
|
/** |
||||
|
* 1为工作日,2为周末,3为节假日 |
||||
|
*/ |
||||
|
private String type; |
||||
|
|
||||
|
/** |
||||
|
* 工作日,周末,节假日 |
||||
|
*/ |
||||
|
private String typeName; |
||||
|
|
||||
|
/** |
||||
|
* 节日名称,工作日时显示“无”,周末时显示“周末”,节日时显示节日名称 |
||||
|
*/ |
||||
|
private String holiday; |
||||
|
|
||||
|
/** |
||||
|
* 星期几的英文名 |
||||
|
*/ |
||||
|
private String en; |
||||
|
|
||||
|
/** |
||||
|
* 星期几的中文名 |
||||
|
*/ |
||||
|
private String cn; |
||||
|
|
||||
|
} |
@ -0,0 +1,25 @@ |
|||||
|
/** |
||||
|
* Copyright (c) 2018 人人开源 All rights reserved. |
||||
|
* |
||||
|
* https://www.renren.io
|
||||
|
* |
||||
|
* 版权所有,侵权必究! |
||||
|
*/ |
||||
|
|
||||
|
package com.epmet.exception; |
||||
|
|
||||
|
|
||||
|
import com.epmet.commons.tools.exception.ErrorCode; |
||||
|
|
||||
|
/** |
||||
|
* 模块错误编码,由9位数字组成,前6位为模块编码,后3位为业务编码 |
||||
|
* <p> |
||||
|
* 如:100001001(100001代表模块,001代表业务代码) |
||||
|
* </p> |
||||
|
* |
||||
|
* @author Mark sunlightcs@gmail.com |
||||
|
* @since 1.0.0 |
||||
|
*/ |
||||
|
public interface ModuleErrorCode extends ErrorCode { |
||||
|
|
||||
|
} |
@ -0,0 +1,77 @@ |
|||||
|
package com.epmet.result; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
|
||||
|
import java.io.Serializable; |
||||
|
|
||||
|
/** |
||||
|
* @Description 2020年我国节假日查询返参 |
||||
|
* @Author yinzuomei |
||||
|
* @Date 2020/5/11 21:27 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class DayDetailResultDTO implements Serializable { |
||||
|
/*{ |
||||
|
"ret_code": 0, |
||||
|
"day": "20200511", |
||||
|
"weekDay": 1, |
||||
|
"begin": "", |
||||
|
"end": "", |
||||
|
"holiday_remark": "", |
||||
|
"type": "1", |
||||
|
"holiday": "无", |
||||
|
"en": "Monday", |
||||
|
"cn": "周一" |
||||
|
}*/ |
||||
|
|
||||
|
/** |
||||
|
* 0表示成功,其他为失败 |
||||
|
*/ |
||||
|
private Integer ret_code; |
||||
|
|
||||
|
/** |
||||
|
* 查询的日期20200510 |
||||
|
*/ |
||||
|
private String day; |
||||
|
|
||||
|
/** |
||||
|
* 星期几的数字 |
||||
|
*/ |
||||
|
private Integer weekDay; |
||||
|
|
||||
|
/** |
||||
|
* 节日或周末开始时间,如果是工作日,此字段为空串 |
||||
|
*/ |
||||
|
private String begin; |
||||
|
|
||||
|
/** |
||||
|
* 节日或周末结束时间,如果是工作日,此字段为空串 |
||||
|
*/ |
||||
|
private String end; |
||||
|
|
||||
|
/** |
||||
|
* 节日备注 |
||||
|
*/ |
||||
|
private String holiday_remark; |
||||
|
|
||||
|
/** |
||||
|
* 1为工作日,2为周末,3为节假日 |
||||
|
*/ |
||||
|
private String type; |
||||
|
|
||||
|
/** |
||||
|
* 节日名称,工作日时显示“无”,周末时显示“周末”,节日时显示节日名称 |
||||
|
*/ |
||||
|
private String holiday; |
||||
|
|
||||
|
/** |
||||
|
* 星期几(英文文) |
||||
|
*/ |
||||
|
private String en; |
||||
|
|
||||
|
/** |
||||
|
* 星期几(中文) |
||||
|
*/ |
||||
|
private String cn; |
||||
|
} |
||||
|
|
@ -0,0 +1,44 @@ |
|||||
|
package com.epmet.result; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
|
||||
|
import java.io.Serializable; |
||||
|
|
||||
|
/** |
||||
|
* @Description TODO |
||||
|
* @Author yinzuomei |
||||
|
* @Date 2020/5/11 22:55 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class HolidayDetailDTO implements Serializable { |
||||
|
private static final long serialVersionUID = -3840795046551145292L; |
||||
|
|
||||
|
/*{ |
||||
|
"holiday": "元旦", |
||||
|
"holiday_remark": "2020年1月1日放假,共1天。", |
||||
|
"end": "20200101", |
||||
|
"begin": "20200101" |
||||
|
}*/ |
||||
|
|
||||
|
/** |
||||
|
* 节假日名称:中秋节 |
||||
|
*/ |
||||
|
private String holiday; |
||||
|
|
||||
|
/** |
||||
|
* 节假日描述:共放假3天,周末连休,不需要调休。 |
||||
|
*/ |
||||
|
private String holiday_remark; |
||||
|
|
||||
|
/** |
||||
|
* 节假日的结束时间:20190915 |
||||
|
*/ |
||||
|
private String end; |
||||
|
|
||||
|
/** |
||||
|
* 节假日的开始时间:20190913 |
||||
|
*/ |
||||
|
private String begin; |
||||
|
|
||||
|
} |
||||
|
|
@ -0,0 +1,27 @@ |
|||||
|
package com.epmet.result; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
|
||||
|
import java.io.Serializable; |
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* @Description 根据年份查询当年的节假日列表返参 |
||||
|
* @Author yinzuomei |
||||
|
* @Date 2020/5/11 21:27 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class HolidayResultDTO implements Serializable { |
||||
|
|
||||
|
/** |
||||
|
* 接口调用是否成功,0表示成功,其他值默认失败 |
||||
|
*/ |
||||
|
private Integer ret_code; |
||||
|
|
||||
|
/** |
||||
|
* 整年的节假日列表 |
||||
|
*/ |
||||
|
private List<HolidayDetailDTO> data; |
||||
|
|
||||
|
} |
||||
|
|
@ -0,0 +1,74 @@ |
|||||
|
package com.epmet.result; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
|
||||
|
import java.io.Serializable; |
||||
|
|
||||
|
/** |
||||
|
* @Description 万维易源-api返参 |
||||
|
* @Author yinzuomei |
||||
|
* @Date 2020/5/11 16:36 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class ShowApiResult implements Serializable { |
||||
|
|
||||
|
// {
|
||||
|
// "showapi_res_error": "",
|
||||
|
// "showapi_res_id": "5eb90db28d57baae12d8d42d",
|
||||
|
// "showapi_res_code": 0,
|
||||
|
// "showapi_res_body": {"ret_code":0,"day":"20200511","weekDay":1,"begin":"","end":"","holiday_remark":"","type":"1","holiday":"无","en":"Monday","cn":"周一"}
|
||||
|
// }
|
||||
|
|
||||
|
/** |
||||
|
*易源返回标志,0为成功,其他为失败。 |
||||
|
* 0成功 |
||||
|
* -1,系统调用错误 |
||||
|
* -2,可调用次数或金额为0 |
||||
|
* -3,读取超时 |
||||
|
* -4,服务端返回数据解析错误 |
||||
|
* -5,后端服务器DNS解析错误 |
||||
|
* -6,服务不存在或未上线 |
||||
|
* -7, API创建者的网关资源不足 |
||||
|
* -1000,系统维护 |
||||
|
* -1002,showapi_appid字段必传 |
||||
|
* -1003,showapi_sign字段必传 |
||||
|
* -1004,签名sign验证有误 |
||||
|
* -1005,showapi_timestamp无效 |
||||
|
* -1006,app无权限调用接口 |
||||
|
* -1007,没有订购套餐 |
||||
|
* -1008,服务商关闭对您的调用权限 |
||||
|
* -1009,调用频率受限 |
||||
|
* -1010,找不到您的应用 |
||||
|
* -1011,子授权app_child_id无效 |
||||
|
* -1012,子授权已过期或失效 |
||||
|
* -1013,子授权ip受限 |
||||
|
* -1014,token权限无效 |
||||
|
*/ |
||||
|
private int showapi_res_code=0; |
||||
|
|
||||
|
/** |
||||
|
* 错误信息的展示 demo:用户输入有误! |
||||
|
*/ |
||||
|
private String showapi_res_error; |
||||
|
|
||||
|
/** |
||||
|
* 本次请求id demo:ce135f6739294c63be0c021b76b6fbff |
||||
|
*/ |
||||
|
private String showapi_res_id; |
||||
|
|
||||
|
/** |
||||
|
* 消息体的JSON封装,所有应用级的返回参数将嵌入此对象 。 demo:{"city":"昆明","prov":"云南"} |
||||
|
*/ |
||||
|
private String showapi_res_body; |
||||
|
|
||||
|
@Override |
||||
|
public String toString() { |
||||
|
return "ShowApiResult{" + |
||||
|
"showapi_res_code=" + showapi_res_code + |
||||
|
", showapi_res_error='" + showapi_res_error + '\'' + |
||||
|
", showapi_res_id='" + showapi_res_id + '\'' + |
||||
|
", showapi_res_body='" + showapi_res_body + '\'' + |
||||
|
'}'; |
||||
|
} |
||||
|
} |
||||
|
|
@ -0,0 +1,95 @@ |
|||||
|
/** |
||||
|
* Copyright 2018 人人开源 https://www.renren.io
|
||||
|
* <p> |
||||
|
* This program is free software: you can redistribute it and/or modify |
||||
|
* it under the terms of the GNU General Public License as published by |
||||
|
* the Free Software Foundation, either version 3 of the License, or |
||||
|
* (at your option) any later version. |
||||
|
* <p> |
||||
|
* This program is distributed in the hope that it will be useful, |
||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
|
* GNU General Public License for more details. |
||||
|
* <p> |
||||
|
* You should have received a copy of the GNU General Public License |
||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
*/ |
||||
|
|
||||
|
package com.epmet.service; |
||||
|
|
||||
|
import com.epmet.commons.mybatis.service.BaseService; |
||||
|
import com.epmet.commons.tools.page.PageData; |
||||
|
import com.epmet.dto.CalenderDTO; |
||||
|
import com.epmet.entity.CalenderEntity; |
||||
|
|
||||
|
import java.util.List; |
||||
|
import java.util.Map; |
||||
|
|
||||
|
/** |
||||
|
* |
||||
|
* |
||||
|
* @author generator generator@elink-cn.com |
||||
|
* @since v1.0.0 2020-05-11 |
||||
|
*/ |
||||
|
public interface CalenderService extends BaseService<CalenderEntity> { |
||||
|
|
||||
|
/** |
||||
|
* 默认分页 |
||||
|
* |
||||
|
* @param params |
||||
|
* @return PageData<CalenderDTO> |
||||
|
* @author generator |
||||
|
* @date 2020-05-11 |
||||
|
*/ |
||||
|
PageData<CalenderDTO> page(Map<String, Object> params); |
||||
|
|
||||
|
/** |
||||
|
* 默认查询 |
||||
|
* |
||||
|
* @param params |
||||
|
* @return java.util.List<CalenderDTO> |
||||
|
* @author generator |
||||
|
* @date 2020-05-11 |
||||
|
*/ |
||||
|
List<CalenderDTO> list(Map<String, Object> params); |
||||
|
|
||||
|
/** |
||||
|
* 单条查询 |
||||
|
* |
||||
|
* @param id |
||||
|
* @return CalenderDTO |
||||
|
* @author generator |
||||
|
* @date 2020-05-11 |
||||
|
*/ |
||||
|
CalenderDTO get(String id); |
||||
|
|
||||
|
/** |
||||
|
* 默认保存 |
||||
|
* |
||||
|
* @param dto |
||||
|
* @return void |
||||
|
* @author generator |
||||
|
* @date 2020-05-11 |
||||
|
*/ |
||||
|
void save(CalenderDTO dto); |
||||
|
|
||||
|
/** |
||||
|
* 默认更新 |
||||
|
* |
||||
|
* @param dto |
||||
|
* @return void |
||||
|
* @author generator |
||||
|
* @date 2020-05-11 |
||||
|
*/ |
||||
|
void update(CalenderDTO dto); |
||||
|
|
||||
|
/** |
||||
|
* 批量删除 |
||||
|
* |
||||
|
* @param ids |
||||
|
* @return void |
||||
|
* @author generator |
||||
|
* @date 2020-05-11 |
||||
|
*/ |
||||
|
void delete(String[] ids); |
||||
|
} |
@ -0,0 +1,16 @@ |
|||||
|
package com.epmet.service; |
||||
|
|
||||
|
/** |
||||
|
* @Description 工作日信息维护 |
||||
|
* @Author yinzuomei |
||||
|
* @Date 2020/5/11 21:55 |
||||
|
*/ |
||||
|
public interface ShowApiService { |
||||
|
|
||||
|
void initYearCalender(String year); |
||||
|
|
||||
|
void initWorkDayList(String year); |
||||
|
|
||||
|
void holidayList(String year); |
||||
|
|
||||
|
} |
@ -0,0 +1,16 @@ |
|||||
|
package com.epmet.service; |
||||
|
|
||||
|
import com.epmet.dto.form.WorkDayFormDTO; |
||||
|
import com.epmet.dto.result.WorkDayResultDTO; |
||||
|
|
||||
|
import java.util.List; |
||||
|
import java.util.Set; |
||||
|
|
||||
|
/** |
||||
|
* @Description 工作日计算 |
||||
|
* @Author yinzuomei |
||||
|
* @Date 2020/5/12 0:27 |
||||
|
*/ |
||||
|
public interface WorkDayService { |
||||
|
List<WorkDayResultDTO> detentionDays(List<WorkDayFormDTO> formDTO); |
||||
|
} |
@ -0,0 +1,97 @@ |
|||||
|
/** |
||||
|
* Copyright 2018 人人开源 https://www.renren.io
|
||||
|
* <p> |
||||
|
* This program is free software: you can redistribute it and/or modify |
||||
|
* it under the terms of the GNU General Public License as published by |
||||
|
* the Free Software Foundation, either version 3 of the License, or |
||||
|
* (at your option) any later version. |
||||
|
* <p> |
||||
|
* This program is distributed in the hope that it will be useful, |
||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
|
* GNU General Public License for more details. |
||||
|
* <p> |
||||
|
* You should have received a copy of the GNU General Public License |
||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
*/ |
||||
|
|
||||
|
package com.epmet.service.impl; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
||||
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
|
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; |
||||
|
import com.epmet.commons.tools.page.PageData; |
||||
|
import com.epmet.commons.tools.utils.ConvertUtils; |
||||
|
import com.epmet.commons.tools.constant.FieldConstant; |
||||
|
import com.epmet.dao.CalenderDao; |
||||
|
import com.epmet.dto.CalenderDTO; |
||||
|
import com.epmet.entity.CalenderEntity; |
||||
|
import com.epmet.service.CalenderService; |
||||
|
import org.apache.commons.lang3.StringUtils; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
import org.springframework.transaction.annotation.Transactional; |
||||
|
|
||||
|
import java.util.Arrays; |
||||
|
import java.util.List; |
||||
|
import java.util.Map; |
||||
|
|
||||
|
/** |
||||
|
* @author generator generator@elink-cn.com |
||||
|
* @since v1.0.0 2020-05-11 |
||||
|
*/ |
||||
|
@Service |
||||
|
public class CalenderServiceImpl extends BaseServiceImpl<CalenderDao, CalenderEntity> implements CalenderService { |
||||
|
|
||||
|
@Override |
||||
|
public PageData<CalenderDTO> page(Map<String, Object> params) { |
||||
|
IPage<CalenderEntity> page = baseDao.selectPage( |
||||
|
getPage(params, FieldConstant.CREATED_TIME, false), |
||||
|
getWrapper(params) |
||||
|
); |
||||
|
return getPageData(page, CalenderDTO.class); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public List<CalenderDTO> list(Map<String, Object> params) { |
||||
|
List<CalenderEntity> entityList = baseDao.selectList(getWrapper(params)); |
||||
|
|
||||
|
return ConvertUtils.sourceToTarget(entityList, CalenderDTO.class); |
||||
|
} |
||||
|
|
||||
|
private QueryWrapper<CalenderEntity> getWrapper(Map<String, Object> params) { |
||||
|
String id = (String) params.get(FieldConstant.ID_HUMP); |
||||
|
|
||||
|
QueryWrapper<CalenderEntity> wrapper = new QueryWrapper<>(); |
||||
|
wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); |
||||
|
|
||||
|
return wrapper; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public CalenderDTO get(String id) { |
||||
|
CalenderEntity entity = baseDao.selectById(id); |
||||
|
return ConvertUtils.sourceToTarget(entity, CalenderDTO.class); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
@Transactional(rollbackFor = Exception.class) |
||||
|
public void save(CalenderDTO dto) { |
||||
|
CalenderEntity entity = ConvertUtils.sourceToTarget(dto, CalenderEntity.class); |
||||
|
insert(entity); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
@Transactional(rollbackFor = Exception.class) |
||||
|
public void update(CalenderDTO dto) { |
||||
|
CalenderEntity entity = ConvertUtils.sourceToTarget(dto, CalenderEntity.class); |
||||
|
updateById(entity); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
@Transactional(rollbackFor = Exception.class) |
||||
|
public void delete(String[] ids) { |
||||
|
// 逻辑删除(@TableLogic 注解)
|
||||
|
baseDao.deleteBatchIds(Arrays.asList(ids)); |
||||
|
} |
||||
|
|
||||
|
} |
@ -0,0 +1,201 @@ |
|||||
|
package com.epmet.service.impl; |
||||
|
|
||||
|
import com.epmet.commons.tools.exception.RenException; |
||||
|
import com.epmet.dao.CalenderDao; |
||||
|
import com.epmet.entity.CalenderEntity; |
||||
|
import com.epmet.result.DayDetailResultDTO; |
||||
|
import com.epmet.result.HolidayDetailDTO; |
||||
|
import com.epmet.result.HolidayResultDTO; |
||||
|
import com.epmet.service.ShowApiService; |
||||
|
import com.epmet.utils.ShowApiUtil; |
||||
|
import org.slf4j.Logger; |
||||
|
import org.slf4j.LoggerFactory; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
|
||||
|
import java.text.ParseException; |
||||
|
import java.text.SimpleDateFormat; |
||||
|
import java.util.Calendar; |
||||
|
import java.util.Date; |
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* @Description 工作日信息维护 |
||||
|
* @Author yinzuomei |
||||
|
* @Date 2020/5/11 21:55 |
||||
|
*/ |
||||
|
@Service |
||||
|
public class ShowApiServiceImpl implements ShowApiService { |
||||
|
|
||||
|
private static Logger logger = LoggerFactory.getLogger(ShowApiServiceImpl.class); |
||||
|
private static SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); |
||||
|
private static SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMdd"); |
||||
|
@Autowired |
||||
|
private CalenderDao calenderDao; |
||||
|
|
||||
|
@Override |
||||
|
public void initYearCalender(String year) { |
||||
|
String dateStart = String.format("%s-01-01", year); |
||||
|
String dateEnd = String.format("%s-12-31", year); |
||||
|
long startTime = 0;//start
|
||||
|
try { |
||||
|
startTime = dateFormat.parse(dateStart).getTime(); |
||||
|
long endTime = dateFormat.parse(dateEnd).getTime();//end
|
||||
|
long day = 1000 * 60 * 60 * 24; |
||||
|
for (long i = startTime; i <= endTime; i += day) { |
||||
|
CalenderEntity calender = calenderDao.selectByDay(simpleDateFormat.format(new Date(i))); |
||||
|
if (null == calender) { |
||||
|
logger.info("日期:" + dateFormat.format(new Date(i))); |
||||
|
CalenderEntity calenderEntity = new CalenderEntity(); |
||||
|
calenderEntity.setQueryDate(new Date(i)); |
||||
|
calenderEntity.setDay(simpleDateFormat.format(new Date(i))); |
||||
|
calenderEntity.setEn(dateToWeekEn(dateFormat.format(new Date(i)))); |
||||
|
calenderEntity.setCn(dateToWeekCn(dateFormat.format(new Date(i)))); |
||||
|
calenderEntity.setWeekday(dateToWeek(dateFormat.format(new Date(i)))); |
||||
|
if (calenderEntity.getWeekday() >= 1 && calenderEntity.getWeekday() <= 5) { |
||||
|
calenderEntity.setTypeName("工作日"); |
||||
|
calenderEntity.setType("1"); |
||||
|
} else { |
||||
|
calenderEntity.setTypeName("周末"); |
||||
|
calenderEntity.setType("2"); |
||||
|
} |
||||
|
calenderDao.insert(calenderEntity); |
||||
|
} else { |
||||
|
logger.info(String.format("数据库存在日期:%s的记录", dateFormat.format(new Date(i)))); |
||||
|
} |
||||
|
} |
||||
|
} catch (ParseException e) { |
||||
|
e.printStackTrace(); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public void initWorkDayList(String year) { |
||||
|
try { |
||||
|
List<CalenderEntity> entityList = calenderDao.selectList(year); |
||||
|
if (null != entityList && entityList.size() > 0) { |
||||
|
CalenderEntity calenderEntity = entityList.get(0); |
||||
|
logger.info("要查询的日期:" + calenderEntity.getDay()); |
||||
|
DayDetailResultDTO dayDetailResultDTO = ShowApiUtil.queryHolidayV2020(calenderEntity.getDay()); |
||||
|
if (0 == dayDetailResultDTO.getRet_code()) { |
||||
|
calenderEntity.setRetCode(dayDetailResultDTO.getRet_code()); |
||||
|
calenderEntity.setWeekday(dayDetailResultDTO.getWeekDay()); |
||||
|
calenderEntity.setBegin(dayDetailResultDTO.getBegin()); |
||||
|
calenderEntity.setEnd(dayDetailResultDTO.getEnd()); |
||||
|
calenderEntity.setHoliday(dayDetailResultDTO.getHoliday()); |
||||
|
calenderEntity.setHolidayRemark(dayDetailResultDTO.getHoliday_remark()); |
||||
|
calenderEntity.setEn(dayDetailResultDTO.getEn()); |
||||
|
calenderEntity.setCn(dayDetailResultDTO.getCn()); |
||||
|
calenderEntity.setType(dayDetailResultDTO.getType()); |
||||
|
//1为工作日,2为周末,3为节假日
|
||||
|
if ("1".equals(dayDetailResultDTO.getType())) { |
||||
|
calenderEntity.setTypeName("工作日"); |
||||
|
} else if ("2".equals(dayDetailResultDTO.getType())) { |
||||
|
calenderEntity.setTypeName("周末"); |
||||
|
} else if ("3".equals(dayDetailResultDTO.getType())) { |
||||
|
calenderEntity.setTypeName("节假日"); |
||||
|
} |
||||
|
calenderDao.updateById(calenderEntity); |
||||
|
} |
||||
|
|
||||
|
} else { |
||||
|
logger.info("无需更新"); |
||||
|
} |
||||
|
} catch (Exception e) { |
||||
|
e.printStackTrace(); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public void holidayList(String year) { |
||||
|
HolidayResultDTO holidayResultDTO = null; |
||||
|
try { |
||||
|
holidayResultDTO = ShowApiUtil.holidayList(year); |
||||
|
if (0 != holidayResultDTO.getRet_code()) { |
||||
|
throw new RenException("根据年份查询当年的节假日列表API【https://route.showapi.com/894-4】查询失败"); |
||||
|
} |
||||
|
for (HolidayDetailDTO holidayDetail : holidayResultDTO.getData()) { |
||||
|
calenderDao.updateHoliday(holidayDetail); |
||||
|
} |
||||
|
} catch (Exception e) { |
||||
|
e.printStackTrace(); |
||||
|
throw new RenException("根据年份查询当年的节假日列表API【https://route.showapi.com/894-4】查询异常"); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/* public static void main(String[] args) throws ParseException { |
||||
|
String dateStart = "2020-01-01"; |
||||
|
String dateEnd = "2020-12-31"; |
||||
|
SimpleDateFormat date = new SimpleDateFormat("yyyy-MM-dd"); |
||||
|
long startTime = date.parse(dateStart).getTime();//start
|
||||
|
long endTime = date.parse(dateEnd).getTime();//end
|
||||
|
long day = 1000 * 60 * 60 * 24; |
||||
|
for (long i = startTime; i <= endTime; i += day) { |
||||
|
System.out.println(date.format(new Date(i))); |
||||
|
} |
||||
|
}*/ |
||||
|
|
||||
|
/** |
||||
|
* 根据日期获取当天是周几 |
||||
|
* |
||||
|
* @param datetime 日期 |
||||
|
* @return 周几 |
||||
|
*/ |
||||
|
public static String dateToWeekCn(String datetime) { |
||||
|
// SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||
|
String[] weekDays = {"周日", "周一", "周二", "周三", "周四", "周五", "周六"}; |
||||
|
Calendar cal = Calendar.getInstance(); |
||||
|
Date date; |
||||
|
try { |
||||
|
date = dateFormat.parse(datetime); |
||||
|
cal.setTime(date); |
||||
|
} catch (ParseException e) { |
||||
|
e.printStackTrace(); |
||||
|
} |
||||
|
int w = cal.get(Calendar.DAY_OF_WEEK) - 1; |
||||
|
return weekDays[w]; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 根据日期获取当天是周几 |
||||
|
* |
||||
|
* @param datetime 日期 |
||||
|
* @return 周几英文 |
||||
|
*/ |
||||
|
public static String dateToWeekEn(String datetime) { |
||||
|
// SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||
|
String[] weekDays = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}; |
||||
|
Calendar cal = Calendar.getInstance(); |
||||
|
Date date; |
||||
|
try { |
||||
|
date = dateFormat.parse(datetime); |
||||
|
cal.setTime(date); |
||||
|
} catch (ParseException e) { |
||||
|
e.printStackTrace(); |
||||
|
} |
||||
|
int w = cal.get(Calendar.DAY_OF_WEEK) - 1; |
||||
|
return weekDays[w]; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 根据日期获取当天是周几 |
||||
|
* |
||||
|
* @param datetime 日期 |
||||
|
* @return 周几数字 |
||||
|
*/ |
||||
|
public static Integer dateToWeek(String datetime) { |
||||
|
// SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||
|
int[] weekDays = {7, 1, 2, 3, 4, 5, 6}; |
||||
|
Calendar cal = Calendar.getInstance(); |
||||
|
Date date; |
||||
|
try { |
||||
|
date = dateFormat.parse(datetime); |
||||
|
cal.setTime(date); |
||||
|
} catch (ParseException e) { |
||||
|
e.printStackTrace(); |
||||
|
} |
||||
|
int w = cal.get(Calendar.DAY_OF_WEEK) - 1; |
||||
|
return weekDays[w]; |
||||
|
} |
||||
|
} |
||||
|
|
@ -0,0 +1,82 @@ |
|||||
|
package com.epmet.service.impl; |
||||
|
|
||||
|
import com.epmet.commons.tools.exception.RenException; |
||||
|
import com.epmet.dao.CalenderDao; |
||||
|
import com.epmet.dto.form.WorkDayFormDTO; |
||||
|
import com.epmet.dto.result.WorkDayResultDTO; |
||||
|
import com.epmet.entity.CalenderEntity; |
||||
|
import com.epmet.service.WorkDayService; |
||||
|
import org.slf4j.Logger; |
||||
|
import org.slf4j.LoggerFactory; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
|
||||
|
import java.text.SimpleDateFormat; |
||||
|
import java.util.*; |
||||
|
|
||||
|
/** |
||||
|
* @Description 工作日计算 |
||||
|
* @Author yinzuomei |
||||
|
* @Date 2020/5/12 0:27 |
||||
|
*/ |
||||
|
@Service |
||||
|
public class WorkDayServiceImpl implements WorkDayService { |
||||
|
private static Logger logger = LoggerFactory.getLogger(WorkDayServiceImpl.class); |
||||
|
@Autowired |
||||
|
private CalenderDao calenderDao; |
||||
|
|
||||
|
@Override |
||||
|
public List<WorkDayResultDTO> detentionDays(List<WorkDayFormDTO> workDayFormDTO) { |
||||
|
List<WorkDayResultDTO> list = new ArrayList<>(); |
||||
|
if (workDayFormDTO.isEmpty()) { |
||||
|
throw new RenException("起始时间、终止时间不能为空"); |
||||
|
} |
||||
|
Iterator it = workDayFormDTO.iterator(); |
||||
|
while (it.hasNext()) { |
||||
|
WorkDayResultDTO workDayResult = new WorkDayResultDTO(); |
||||
|
WorkDayFormDTO workDayDTO = (WorkDayFormDTO) it.next(); |
||||
|
workDayResult.setId(workDayDTO.getId()); |
||||
|
workDayResult.setStartDate(workDayDTO.getStartDate()); |
||||
|
workDayResult.setEndDate(workDayDTO.getEndDate()); |
||||
|
workDayResult.setDetentionDays(this.caculateDetentionDays(workDayDTO.getStartDate(), workDayResult.getEndDate())); |
||||
|
list.add(workDayResult); |
||||
|
} |
||||
|
return list; |
||||
|
} |
||||
|
|
||||
|
//公式: 当前日期 - 被吹日期 - 期间的节假日
|
||||
|
private String caculateDetentionDays(String startDateStr, String endDateStr) { |
||||
|
if (startDateStr.equals(endDateStr)) { |
||||
|
logger.info(String.format("%s-%s起止时间一致,返回<1,",startDateStr,endDateStr)); |
||||
|
return "<1"; |
||||
|
} |
||||
|
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMdd"); |
||||
|
try { |
||||
|
Date startDate = simpleDateFormat.parse(startDateStr); |
||||
|
Date endDate = simpleDateFormat.parse(endDateStr); |
||||
|
long day = (endDate.getTime() - startDate.getTime()) / (24 * 60 * 60 * 1000); |
||||
|
logger.info(String.format("当前日期[%s]-被吹日期[%s]=%s", endDateStr, startDateStr, day)); |
||||
|
List<CalenderEntity> list = calenderDao.selectByStartAndEnd(startDateStr, endDateStr); |
||||
|
|
||||
|
long totalHoliday = 0; |
||||
|
for (CalenderEntity calenderEntity : list) { |
||||
|
if (!"1".equals(calenderEntity.getType())) { |
||||
|
totalHoliday += 1; |
||||
|
} |
||||
|
} |
||||
|
logger.info(String.format("期间的节假日[%s-%s]=%s", endDateStr, startDateStr, totalHoliday)); |
||||
|
long detentionDay = day - totalHoliday; |
||||
|
logger.info(String.format("当前日期[%s]-被吹日期[%s]-期间的节假日[%s]=%s", endDateStr, startDateStr, totalHoliday, detentionDay)); |
||||
|
if (detentionDay < 1) { |
||||
|
return "<1"; |
||||
|
} |
||||
|
return String.valueOf(detentionDay); |
||||
|
} catch (Exception e) { |
||||
|
e.printStackTrace(); |
||||
|
} |
||||
|
return "-1"; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
} |
||||
|
|
@ -0,0 +1,38 @@ |
|||||
|
package com.epmet.task; |
||||
|
|
||||
|
import org.springframework.scheduling.annotation.Async; |
||||
|
import org.springframework.scheduling.annotation.EnableAsync; |
||||
|
import org.springframework.scheduling.annotation.EnableScheduling; |
||||
|
import org.springframework.scheduling.annotation.Scheduled; |
||||
|
import org.springframework.stereotype.Component; |
||||
|
|
||||
|
import java.time.LocalDateTime; |
||||
|
|
||||
|
/** |
||||
|
* @Description TODO |
||||
|
* @Author yinzuomei |
||||
|
* @Date 2020/5/12 0:04 |
||||
|
*/ |
||||
|
//@Component注解用于对那些比较中立的类进行注释;
|
||||
|
//相对与在持久层、业务层和控制层分别采用 @Repository、@Service 和 @Controller 对分层中的类进行注释
|
||||
|
//@Component
|
||||
|
//@EnableScheduling // 1.开启定时任务
|
||||
|
//@EnableAsync // 2.开启多线程
|
||||
|
public class MultithreadScheduleTask { |
||||
|
|
||||
|
@Async |
||||
|
@Scheduled(fixedDelay = 1000) //间隔1秒
|
||||
|
public void first() throws InterruptedException { |
||||
|
System.out.println("第一个定时任务开始 : " + LocalDateTime.now().toLocalTime() + "\r\n线程 : " + Thread.currentThread().getName()); |
||||
|
System.out.println(); |
||||
|
Thread.sleep(1000 * 10); |
||||
|
} |
||||
|
|
||||
|
@Async |
||||
|
@Scheduled(fixedDelay = 2000) |
||||
|
public void second() { |
||||
|
System.out.println("第二个定时任务开始 : " + LocalDateTime.now().toLocalTime() + "\r\n线程 : " + Thread.currentThread().getName()); |
||||
|
System.out.println(); |
||||
|
} |
||||
|
} |
||||
|
|
@ -0,0 +1,31 @@ |
|||||
|
package com.epmet.task; |
||||
|
|
||||
|
import com.epmet.service.ShowApiService; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.context.annotation.Configuration; |
||||
|
import org.springframework.scheduling.annotation.EnableScheduling; |
||||
|
import org.springframework.scheduling.annotation.Scheduled; |
||||
|
|
||||
|
import java.time.LocalDateTime; |
||||
|
|
||||
|
/** |
||||
|
* @Description TODO |
||||
|
* @Author yinzuomei |
||||
|
* @Date 2020/5/12 0:01 |
||||
|
*/ |
||||
|
//@Configuration //1.主要用于标记配置类,兼备Component的效果。
|
||||
|
//@EnableScheduling // 2.开启定时任务
|
||||
|
public class SaticScheduleTask { |
||||
|
@Autowired |
||||
|
private ShowApiService showApiService; |
||||
|
|
||||
|
//3.添加定时任务
|
||||
|
@Scheduled(cron = "0/1 * * * * ?") |
||||
|
//或直接指定时间间隔,例如:5秒
|
||||
|
//@Scheduled(fixedRate=5000)
|
||||
|
private void configureTasks() { |
||||
|
showApiService.initWorkDayList("2020"); |
||||
|
System.err.println("执行静态定时任务时间: " + LocalDateTime.now()); |
||||
|
} |
||||
|
} |
||||
|
|
@ -0,0 +1,106 @@ |
|||||
|
package com.epmet.utils; |
||||
|
|
||||
|
import com.alibaba.fastjson.JSONObject; |
||||
|
import com.epmet.constant.ShowApiConstant; |
||||
|
import com.epmet.result.DayDetailResultDTO; |
||||
|
import com.epmet.result.HolidayResultDTO; |
||||
|
import com.epmet.result.ShowApiResult; |
||||
|
import org.slf4j.Logger; |
||||
|
import org.slf4j.LoggerFactory; |
||||
|
|
||||
|
import java.io.ByteArrayOutputStream; |
||||
|
import java.io.InputStream; |
||||
|
import java.net.URL; |
||||
|
|
||||
|
/** |
||||
|
* @Description 万维易源-api工具类 |
||||
|
* @Author yinzuomei |
||||
|
* @Date 2020/5/11 15:55 |
||||
|
*/ |
||||
|
public class ShowApiUtil { |
||||
|
private static Logger logger = LoggerFactory.getLogger(ShowApiUtil.class); |
||||
|
|
||||
|
/** |
||||
|
* @return com.epmet.result.showapi.ShowApiResult |
||||
|
* @param day 输入格式yyyyMMdd。如果不输入,则默认是当天 |
||||
|
* @Author yinzuomei |
||||
|
* @Description 2020年我国节假日查询 |
||||
|
* @Date 2020/5/11 21:20 |
||||
|
**/ |
||||
|
public static DayDetailResultDTO queryHolidayV2020(String day) throws Exception { |
||||
|
String url=String.format(ShowApiConstant.QUERY_HOLIDAY_V2020,ShowApiConstant.SHOWAPI_APPID,ShowApiConstant.SHOWAPI_SIGN,day); |
||||
|
logger.info(String.format("(1)QUERY_HOLIDAY_V2020入参:%s",url)); |
||||
|
URL u = new URL(url); |
||||
|
InputStream in = u.openStream(); |
||||
|
ByteArrayOutputStream out = new ByteArrayOutputStream(); |
||||
|
try { |
||||
|
byte buf[] = new byte[1024]; |
||||
|
int read = 0; |
||||
|
while ((read = in .read(buf)) > 0) { |
||||
|
out.write(buf, 0, read); |
||||
|
} |
||||
|
} finally { |
||||
|
if ( in != null) { |
||||
|
in .close(); |
||||
|
} |
||||
|
} |
||||
|
byte b[] = out.toByteArray(); |
||||
|
String resultStr=new String(b, "utf-8"); |
||||
|
logger.info(String.format("(2)QUERY_HOLIDAY_V2020返参:%s",resultStr)); |
||||
|
JSONObject jsonobject = JSONObject.parseObject(resultStr); |
||||
|
ShowApiResult showApiResult= (ShowApiResult)JSONObject.toJavaObject(jsonobject, ShowApiResult.class); |
||||
|
logger.info(showApiResult.toString()); |
||||
|
|
||||
|
JSONObject holidayJsonObject = JSONObject.parseObject(showApiResult.getShowapi_res_body()); |
||||
|
DayDetailResultDTO dayDetailResultDTO= (DayDetailResultDTO)JSONObject.toJavaObject(holidayJsonObject, DayDetailResultDTO.class); |
||||
|
logger.info(String.format("(3)QUERY_HOLIDAY_V2020返参:%s",dayDetailResultDTO.toString())); |
||||
|
return dayDetailResultDTO; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* @return com.epmet.result.HolidayResultDTO |
||||
|
* @param year |
||||
|
* @Author yinzuomei |
||||
|
* @Description 根据年份查询当年的节假日列表 |
||||
|
* @Date 2020/5/11 22:58 |
||||
|
**/ |
||||
|
public static HolidayResultDTO holidayList(String year) throws Exception { |
||||
|
String url=String.format(ShowApiConstant.HOLIDAY_LIST,ShowApiConstant.SHOWAPI_APPID,ShowApiConstant.SHOWAPI_SIGN,year); |
||||
|
logger.info(String.format("(1)HOLIDAY_LIST入参:%s",url)); |
||||
|
URL u = new URL(url); |
||||
|
InputStream in = u.openStream(); |
||||
|
ByteArrayOutputStream out = new ByteArrayOutputStream(); |
||||
|
try { |
||||
|
byte buf[] = new byte[1024]; |
||||
|
int read = 0; |
||||
|
while ((read = in .read(buf)) > 0) { |
||||
|
out.write(buf, 0, read); |
||||
|
} |
||||
|
} finally { |
||||
|
if ( in != null) { |
||||
|
in .close(); |
||||
|
} |
||||
|
} |
||||
|
byte b[] = out.toByteArray(); |
||||
|
String resultStr=new String(b, "utf-8"); |
||||
|
logger.info(String.format("(2)HOLIDAY_LIST返参:%s",resultStr)); |
||||
|
JSONObject jsonobject = JSONObject.parseObject(resultStr); |
||||
|
ShowApiResult showApiResult= (ShowApiResult)JSONObject.toJavaObject(jsonobject, ShowApiResult.class); |
||||
|
logger.info(showApiResult.toString()); |
||||
|
|
||||
|
JSONObject holidayJsonObject = JSONObject.parseObject(showApiResult.getShowapi_res_body()); |
||||
|
HolidayResultDTO holidayResultDTO= (HolidayResultDTO)JSONObject.toJavaObject(holidayJsonObject, HolidayResultDTO.class); |
||||
|
logger.info(String.format("(3)HOLIDAY_LIST返参:%s",holidayResultDTO.toString())); |
||||
|
return holidayResultDTO; |
||||
|
} |
||||
|
public static void main(String[] args) { |
||||
|
try { |
||||
|
// queryHolidayV2020("20200503");
|
||||
|
holidayList("2020"); |
||||
|
} catch (Exception e) { |
||||
|
e.printStackTrace(); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
@ -0,0 +1,106 @@ |
|||||
|
server: |
||||
|
port: @server.port@ |
||||
|
servlet: |
||||
|
context-path: /commonservice |
||||
|
|
||||
|
spring: |
||||
|
main: |
||||
|
allow-bean-definition-overriding: true |
||||
|
application: |
||||
|
name: common-service-server |
||||
|
#环境 dev|test|prod |
||||
|
profiles: |
||||
|
active: dev |
||||
|
messages: |
||||
|
encoding: UTF-8 |
||||
|
basename: i18n/messages,i18n/messages_common |
||||
|
jackson: |
||||
|
time-zone: GMT+8 |
||||
|
date-format: yyyy-MM-dd HH:mm:ss |
||||
|
redis: |
||||
|
database: @spring.redis.index@ |
||||
|
host: @spring.redis.host@ |
||||
|
port: @spring.redis.port@ |
||||
|
password: @spring.redis.password@ |
||||
|
timeout: 30s |
||||
|
datasource: |
||||
|
druid: |
||||
|
#MySQL |
||||
|
driver-class-name: com.mysql.cj.jdbc.Driver |
||||
|
url: @spring.datasource.druid.url@ |
||||
|
username: @spring.datasource.druid.username@ |
||||
|
password: @spring.datasource.druid.password@ |
||||
|
cloud: |
||||
|
nacos: |
||||
|
discovery: |
||||
|
server-addr: @nacos.server-addr@ |
||||
|
#nacos的命名空间ID,默认是public |
||||
|
namespace: @nacos.discovery.namespace@ |
||||
|
#不把自己注册到注册中心的地址 |
||||
|
register-enabled: @nacos.register-enabled@ |
||||
|
ip: @nacos.ip@ |
||||
|
config: |
||||
|
enabled: @nacos.config-enabled@ |
||||
|
server-addr: @nacos.server-addr@ |
||||
|
namespace: @nacos.config.namespace@ |
||||
|
group: @nacos.config.group@ |
||||
|
file-extension: yaml |
||||
|
#指定共享配置,且支持动态刷新 |
||||
|
# ext-config: |
||||
|
# - data-id: datasource.yaml |
||||
|
# group: ${spring.cloud.nacos.config.group} |
||||
|
# refresh: true |
||||
|
# - data-id: common.yaml |
||||
|
# group: ${spring.cloud.nacos.config.group} |
||||
|
# refresh: true |
||||
|
management: |
||||
|
endpoints: |
||||
|
web: |
||||
|
exposure: |
||||
|
include: "*" |
||||
|
endpoint: |
||||
|
health: |
||||
|
show-details: ALWAYS |
||||
|
|
||||
|
mybatis-plus: |
||||
|
mapper-locations: classpath:/mapper/**/*.xml |
||||
|
#实体扫描,多个package用逗号或者分号分隔 |
||||
|
typeAliasesPackage: com.epmet.modules.*.entity |
||||
|
global-config: |
||||
|
#数据库相关配置 |
||||
|
db-config: |
||||
|
#主键类型 AUTO:"数据库ID自增", INPUT:"用户输入ID", ID_WORKER:"全局唯一ID (数字类型唯一ID)", UUID:"全局唯一ID UUID"; |
||||
|
id-type: ID_WORKER |
||||
|
#字段策略 IGNORED:"忽略判断",NOT_NULL:"非 NULL 判断"),NOT_EMPTY:"非空判断" |
||||
|
field-strategy: NOT_NULL |
||||
|
#驼峰下划线转换 |
||||
|
column-underline: true |
||||
|
banner: false |
||||
|
#原生配置 |
||||
|
configuration: |
||||
|
map-underscore-to-camel-case: true |
||||
|
cache-enabled: false |
||||
|
call-setters-on-nulls: true |
||||
|
jdbc-type-for-null: 'null' |
||||
|
|
||||
|
feign: |
||||
|
hystrix: |
||||
|
enabled: true |
||||
|
client: |
||||
|
config: |
||||
|
default: |
||||
|
loggerLevel: BASIC |
||||
|
httpclient: |
||||
|
enabled: true |
||||
|
|
||||
|
hystrix: |
||||
|
command: |
||||
|
default: |
||||
|
execution: |
||||
|
isolation: |
||||
|
thread: |
||||
|
timeoutInMilliseconds: 60000 #缺省为1000 |
||||
|
|
||||
|
ribbon: |
||||
|
ReadTimeout: 300000 |
||||
|
ConnectTimeout: 300000 |
@ -0,0 +1,158 @@ |
|||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||
|
<configuration> |
||||
|
<include resource="org/springframework/boot/logging/logback/base.xml"/> |
||||
|
|
||||
|
<property name="log.path" value="logs/common-service"/> |
||||
|
|
||||
|
<!-- 彩色日志格式 --> |
||||
|
<property name="CONSOLE_LOG_PATTERN" |
||||
|
value="${CONSOLE_LOG_PATTERN:-%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(${LOG_LEVEL_PATTERN:-%5p}) %clr(${PID:- }){magenta} %clr(---){faint} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}}"/> |
||||
|
|
||||
|
<!--1. 输出到控制台--> |
||||
|
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender"> |
||||
|
<!--此日志appender是为开发使用,只配置最底级别,控制台输出的日志级别是大于或等于此级别的日志信息--> |
||||
|
<filter class="ch.qos.logback.classic.filter.ThresholdFilter"> |
||||
|
<level>debug</level> |
||||
|
</filter> |
||||
|
<encoder> |
||||
|
<Pattern>${CONSOLE_LOG_PATTERN}</Pattern> |
||||
|
<!-- 设置字符集 --> |
||||
|
<charset>UTF-8</charset> |
||||
|
</encoder> |
||||
|
</appender> |
||||
|
|
||||
|
<!--2. 输出到文档--> |
||||
|
<!-- 2.1 level为 DEBUG 日志,时间滚动输出 --> |
||||
|
<appender name="DEBUG_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> |
||||
|
<!-- 正在记录的日志文档的路径及文档名 --> |
||||
|
<file>${log.path}/debug.log</file> |
||||
|
<!--日志文档输出格式--> |
||||
|
<encoder> |
||||
|
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern> |
||||
|
<charset>UTF-8</charset> <!-- 设置字符集 --> |
||||
|
</encoder> |
||||
|
<!-- 日志记录器的滚动策略,按日期,按大小记录 --> |
||||
|
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> |
||||
|
<!-- 日志归档 --> |
||||
|
<fileNamePattern>${log.path}/debug-%d{yyyy-MM-dd}.%i.log</fileNamePattern> |
||||
|
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"> |
||||
|
<maxFileSize>100MB</maxFileSize> |
||||
|
</timeBasedFileNamingAndTriggeringPolicy> |
||||
|
<!--日志文档保留天数--> |
||||
|
<maxHistory>15</maxHistory> |
||||
|
</rollingPolicy> |
||||
|
<!-- 此日志文档只记录debug级别的 --> |
||||
|
<filter class="ch.qos.logback.classic.filter.LevelFilter"> |
||||
|
<level>debug</level> |
||||
|
<onMatch>ACCEPT</onMatch> |
||||
|
<onMismatch>DENY</onMismatch> |
||||
|
</filter> |
||||
|
</appender> |
||||
|
|
||||
|
<!-- 2.2 level为 INFO 日志,时间滚动输出 --> |
||||
|
<appender name="INFO_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> |
||||
|
<!-- 正在记录的日志文档的路径及文档名 --> |
||||
|
<file>${log.path}/info.log</file> |
||||
|
<!--日志文档输出格式--> |
||||
|
<encoder> |
||||
|
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern> |
||||
|
<charset>UTF-8</charset> |
||||
|
</encoder> |
||||
|
<!-- 日志记录器的滚动策略,按日期,按大小记录 --> |
||||
|
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> |
||||
|
<!-- 每天日志归档路径以及格式 --> |
||||
|
<fileNamePattern>${log.path}/info-%d{yyyy-MM-dd}.%i.log</fileNamePattern> |
||||
|
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"> |
||||
|
<maxFileSize>100MB</maxFileSize> |
||||
|
</timeBasedFileNamingAndTriggeringPolicy> |
||||
|
<!--日志文档保留天数--> |
||||
|
<maxHistory>15</maxHistory> |
||||
|
</rollingPolicy> |
||||
|
<!-- 此日志文档只记录info级别的 --> |
||||
|
<filter class="ch.qos.logback.classic.filter.LevelFilter"> |
||||
|
<level>info</level> |
||||
|
<onMatch>ACCEPT</onMatch> |
||||
|
<onMismatch>DENY</onMismatch> |
||||
|
</filter> |
||||
|
</appender> |
||||
|
|
||||
|
<!-- 2.3 level为 WARN 日志,时间滚动输出 --> |
||||
|
<appender name="WARN_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> |
||||
|
<!-- 正在记录的日志文档的路径及文档名 --> |
||||
|
<file>${log.path}/warn.log</file> |
||||
|
<!--日志文档输出格式--> |
||||
|
<encoder> |
||||
|
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern> |
||||
|
<charset>UTF-8</charset> <!-- 此处设置字符集 --> |
||||
|
</encoder> |
||||
|
<!-- 日志记录器的滚动策略,按日期,按大小记录 --> |
||||
|
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> |
||||
|
<fileNamePattern>${log.path}/warn-%d{yyyy-MM-dd}.%i.log</fileNamePattern> |
||||
|
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"> |
||||
|
<maxFileSize>100MB</maxFileSize> |
||||
|
</timeBasedFileNamingAndTriggeringPolicy> |
||||
|
<!--日志文档保留天数--> |
||||
|
<maxHistory>15</maxHistory> |
||||
|
</rollingPolicy> |
||||
|
<!-- 此日志文档只记录warn级别的 --> |
||||
|
<filter class="ch.qos.logback.classic.filter.LevelFilter"> |
||||
|
<level>warn</level> |
||||
|
<onMatch>ACCEPT</onMatch> |
||||
|
<onMismatch>DENY</onMismatch> |
||||
|
</filter> |
||||
|
</appender> |
||||
|
|
||||
|
<!-- 2.4 level为 ERROR 日志,时间滚动输出 --> |
||||
|
<appender name="ERROR_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> |
||||
|
<!-- 正在记录的日志文档的路径及文档名 --> |
||||
|
<file>${log.path}/error.log</file> |
||||
|
<!--日志文档输出格式--> |
||||
|
<encoder> |
||||
|
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern> |
||||
|
<charset>UTF-8</charset> <!-- 此处设置字符集 --> |
||||
|
</encoder> |
||||
|
<!-- 日志记录器的滚动策略,按日期,按大小记录 --> |
||||
|
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> |
||||
|
<fileNamePattern>${log.path}/error-%d{yyyy-MM-dd}.%i.log</fileNamePattern> |
||||
|
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"> |
||||
|
<maxFileSize>100MB</maxFileSize> |
||||
|
</timeBasedFileNamingAndTriggeringPolicy> |
||||
|
<!--日志文档保留天数--> |
||||
|
<maxHistory>15</maxHistory> |
||||
|
</rollingPolicy> |
||||
|
<!-- 此日志文档只记录ERROR级别的 --> |
||||
|
<filter class="ch.qos.logback.classic.filter.LevelFilter"> |
||||
|
<level>ERROR</level> |
||||
|
<onMatch>ACCEPT</onMatch> |
||||
|
<onMismatch>DENY</onMismatch> |
||||
|
</filter> |
||||
|
</appender> |
||||
|
|
||||
|
<!-- 开发、测试环境 --> |
||||
|
<springProfile name="dev,test"> |
||||
|
<logger name="org.springframework.web" level="INFO"/> |
||||
|
<logger name="org.springboot.sample" level="INFO"/> |
||||
|
<logger name="com.epmet.dao" level="DEBUG"/> |
||||
|
<root level="INFO"> |
||||
|
<appender-ref ref="DEBUG_FILE"/> |
||||
|
<appender-ref ref="INFO_FILE"/> |
||||
|
<appender-ref ref="WARN_FILE"/> |
||||
|
<appender-ref ref="ERROR_FILE"/> |
||||
|
</root> |
||||
|
</springProfile> |
||||
|
|
||||
|
<!-- 生产环境 --> |
||||
|
<springProfile name="prod"> |
||||
|
<logger name="org.springframework.web" level="INFO"/> |
||||
|
<logger name="org.springboot.sample" level="INFO"/> |
||||
|
<logger name="com.epmet.dao" level="INFO"/> |
||||
|
<root level="INFO"> |
||||
|
<appender-ref ref="CONSOLE"/> |
||||
|
<appender-ref ref="DEBUG_FILE"/> |
||||
|
<appender-ref ref="INFO_FILE"/> |
||||
|
<appender-ref ref="WARN_FILE"/> |
||||
|
<appender-ref ref="ERROR_FILE"/> |
||||
|
</root> |
||||
|
</springProfile> |
||||
|
|
||||
|
</configuration> |
@ -0,0 +1,64 @@ |
|||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
||||
|
|
||||
|
<mapper namespace="com.epmet.dao.CalenderDao"> |
||||
|
|
||||
|
<resultMap type="com.epmet.entity.CalenderEntity" id="calenderMap"> |
||||
|
<result property="id" column="ID"/> |
||||
|
<result property="retCode" column="RET_CODE"/> |
||||
|
<result property="day" column="DAY"/> |
||||
|
<result property="queryDate" column="QUERY_DATE"/> |
||||
|
<result property="weekday" column="WEEKDAY"/> |
||||
|
<result property="begin" column="BEGIN"/> |
||||
|
<result property="end" column="END"/> |
||||
|
<result property="holidayRemark" column="HOLIDAY_REMARK"/> |
||||
|
<result property="type" column="TYPE"/> |
||||
|
<result property="typeName" column="TYPE_NAME"/> |
||||
|
<result property="holiday" column="HOLIDAY"/> |
||||
|
<result property="en" column="EN"/> |
||||
|
<result property="cn" column="CN"/> |
||||
|
<result property="delFlag" column="DEL_FLAG"/> |
||||
|
<result property="revision" column="REVISION"/> |
||||
|
<result property="createdBy" column="CREATED_BY"/> |
||||
|
<result property="createdTime" column="CREATED_TIME"/> |
||||
|
<result property="updatedBy" column="UPDATED_BY"/> |
||||
|
<result property="updatedTime" column="UPDATED_TIME"/> |
||||
|
</resultMap> |
||||
|
|
||||
|
<select id="selectByDay" parameterType="java.lang.String" resultType="com.epmet.entity.CalenderEntity"> |
||||
|
select * from calender c |
||||
|
where c.del_flag='0' |
||||
|
and c.DAY=#{day} |
||||
|
</select> |
||||
|
|
||||
|
<update id="updateHoliday" parameterType="com.epmet.result.HolidayDetailDTO"> |
||||
|
UPDATE calender |
||||
|
SET type = '3', |
||||
|
TYPE_NAME = '节假日', |
||||
|
HOLIDAY_REMARK = #{holiday_remark}, |
||||
|
HOLIDAY = #{holiday} |
||||
|
WHERE |
||||
|
DEL_FLAG = '0' |
||||
|
AND QUERY_DATE BETWEEN #{begin} |
||||
|
AND #{end} |
||||
|
</update> |
||||
|
|
||||
|
<select id="selectList" parameterType="java.lang.String" resultType="com.epmet.entity.CalenderEntity"> |
||||
|
select * from calender c |
||||
|
where c.del_flag='0' |
||||
|
AND (c.RET_CODE is null or c.ret_code!='') |
||||
|
and c.DAY like concat(#{year}, '%') |
||||
|
order by c.query_date asc |
||||
|
</select> |
||||
|
|
||||
|
<select id="selectByStartAndEnd" parameterType="map" resultType="com.epmet.entity.CalenderEntity"> |
||||
|
SELECT |
||||
|
* |
||||
|
FROM |
||||
|
calender |
||||
|
WHERE |
||||
|
DEL_FLAG = '0' |
||||
|
AND QUERY_DATE BETWEEN #{begin} |
||||
|
AND #{end} |
||||
|
</select> |
||||
|
</mapper> |
@ -0,0 +1,21 @@ |
|||||
|
<?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> |
||||
|
<groupId>com.epmet</groupId> |
||||
|
<artifactId>epmet-module</artifactId> |
||||
|
<version>2.0.0</version> |
||||
|
</parent> |
||||
|
|
||||
|
<groupId>com.epmet</groupId> |
||||
|
<artifactId>epmet-common-service</artifactId> |
||||
|
<packaging>pom</packaging> |
||||
|
|
||||
|
<modules> |
||||
|
<module>common-service-client</module> |
||||
|
<module>common-service-server</module> |
||||
|
</modules> |
||||
|
|
||||
|
</project> |
Loading…
Reference in new issue