diff --git a/epmet-gateway/pom.xml b/epmet-gateway/pom.xml
index e3c45756f4..4029f58948 100644
--- a/epmet-gateway/pom.xml
+++ b/epmet-gateway/pom.xml
@@ -174,6 +174,9 @@
lb://gov-project-server
+
+ http://127.0.0.1:8103
+
@@ -244,6 +247,8 @@
lb://gov-issue-server
lb://gov-project-server
+
+ lb://common-service-server
@@ -312,6 +317,8 @@
lb://gov-issue-server
lb://gov-project-server
+
+ lb://common-service-server
diff --git a/epmet-gateway/src/main/resources/bootstrap.yml b/epmet-gateway/src/main/resources/bootstrap.yml
index 112369073e..a009c0c628 100644
--- a/epmet-gateway/src/main/resources/bootstrap.yml
+++ b/epmet-gateway/src/main/resources/bootstrap.yml
@@ -224,6 +224,14 @@ spring:
filters:
- StripPrefix=1
- CpAuth=true
+ #政府工作端项目管理
+ - id: common-service-server
+ uri: @gateway.routes.common-service-server.uri@
+ order: 23
+ predicates:
+ - Path=${server.servlet.context-path}/commonservice/**
+ filters:
+ - StripPrefix=1
nacos:
discovery:
server-addr: @nacos.server-addr@
diff --git a/epmet-module/epmet-common-service/common-service-client/pom.xml b/epmet-module/epmet-common-service/common-service-client/pom.xml
new file mode 100644
index 0000000000..d8b8c6d070
--- /dev/null
+++ b/epmet-module/epmet-common-service/common-service-client/pom.xml
@@ -0,0 +1,35 @@
+
+
+ 4.0.0
+
+
+ com.epmet
+ epmet-common-service
+ 2.0.0
+
+
+ common-service-client
+ jar
+
+
+
+ com.epmet
+ epmet-commons-tools
+ 2.0.0
+
+
+ io.springfox
+ springfox-swagger2
+
+
+ io.springfox
+ springfox-swagger-ui
+
+
+
+
+ ${project.artifactId}
+
+
+
diff --git a/epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/dto/CalenderDTO.java b/epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/dto/CalenderDTO.java
new file mode 100644
index 0000000000..77c75ed9e3
--- /dev/null
+++ b/epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/dto/CalenderDTO.java
@@ -0,0 +1,131 @@
+/**
+ * Copyright 2018 人人开源 https://www.renren.io
+ *
+ * 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.
+ *
+ * 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.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+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;
+
+}
\ No newline at end of file
diff --git a/epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/dto/form/WorkDayFormDTO.java b/epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/dto/form/WorkDayFormDTO.java
new file mode 100644
index 0000000000..3442f81481
--- /dev/null
+++ b/epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/dto/form/WorkDayFormDTO.java
@@ -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;
+}
+
diff --git a/epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/dto/result/WorkDayResultDTO.java b/epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/dto/result/WorkDayResultDTO.java
new file mode 100644
index 0000000000..8c594b1298
--- /dev/null
+++ b/epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/dto/result/WorkDayResultDTO.java
@@ -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;
+}
+
diff --git a/epmet-module/epmet-common-service/common-service-server/Dockerfile b/epmet-module/epmet-common-service/common-service-server/Dockerfile
new file mode 100644
index 0000000000..456b190e80
--- /dev/null
+++ b/epmet-module/epmet-common-service/common-service-server/Dockerfile
@@ -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"]
\ No newline at end of file
diff --git a/epmet-module/epmet-common-service/common-service-server/docker-compose.yml b/epmet-module/epmet-common-service/common-service-server/docker-compose.yml
new file mode 100644
index 0000000000..9af8426d0d
--- /dev/null
+++ b/epmet-module/epmet-common-service/common-service-server/docker-compose.yml
@@ -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
\ No newline at end of file
diff --git a/epmet-module/epmet-common-service/common-service-server/pom.xml b/epmet-module/epmet-common-service/common-service-server/pom.xml
new file mode 100644
index 0000000000..9bfa6132e5
--- /dev/null
+++ b/epmet-module/epmet-common-service/common-service-server/pom.xml
@@ -0,0 +1,148 @@
+
+
+ 4.0.0
+ 0.3.0
+
+ com.epmet
+ epmet-common-service
+ 2.0.0
+
+ common-service-server
+ jar
+
+
+
+ com.epmet
+ common-service-client
+ 2.0.0
+
+
+ com.epmet
+ epmet-commons-tools
+ 2.0.0
+
+
+ com.epmet
+ epmet-commons-mybatis
+ 2.0.0
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
+ org.springframework
+ spring-context-support
+
+
+ org.springframework.boot
+ spring-boot-starter-actuator
+
+
+ de.codecentric
+ spring-boot-admin-starter-client
+ ${spring.boot.admin.version}
+
+
+ com.alibaba.cloud
+ spring-cloud-starter-alibaba-nacos-discovery
+
+
+ com.alibaba.cloud
+ spring-cloud-starter-alibaba-nacos-config
+
+
+
+ io.github.openfeign
+ feign-httpclient
+ 10.3.0
+
+
+
+
+ ${project.artifactId}
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+
+ true
+
+
+
+ ${project.basedir}/src/main/java
+
+
+ true
+ ${basedir}/src/main/resources
+
+
+
+
+
+ dev-local
+
+ true
+
+
+ 8103
+ dev
+
+
+
+
+
+ root
+ root
+
+ 0
+ 192.168.1.130
+ 6379
+ 123456
+
+ false
+ 122.152.200.70:8848
+ fcd6fc8f-ca3a-4b01-8026-2b05cdc5976b
+
+
+ false
+
+
+
+
+ dev
+
+
+ 8103
+ dev
+
+
+
+
+
+ epmet
+ elink@833066
+
+ 0
+ r-m5eoz5b6tkx09y6bpz.redis.rds.aliyuncs.com
+ 6379
+ EpmEtrEdIs!q@w
+
+ true
+ 192.168.10.150:8848
+ 67e3c350-533e-4d7c-9f8f-faf1b4aa82ae
+
+
+ false
+
+
+
+
+
diff --git a/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/EpmetCommonServiceApplication.java b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/EpmetCommonServiceApplication.java
new file mode 100644
index 0000000000..238b8546d4
--- /dev/null
+++ b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/EpmetCommonServiceApplication.java
@@ -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);
+ }
+
+}
diff --git a/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/config/ModuleConfigImpl.java b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/config/ModuleConfigImpl.java
new file mode 100644
index 0000000000..6fbaa47ba2
--- /dev/null
+++ b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/config/ModuleConfigImpl.java
@@ -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";
+ }
+}
diff --git a/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/constant/ShowApiConstant.java b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/constant/ShowApiConstant.java
new file mode 100644
index 0000000000..69799d4fde
--- /dev/null
+++ b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/constant/ShowApiConstant.java
@@ -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";
+}
diff --git a/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/controller/CalenderController.java b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/controller/CalenderController.java
new file mode 100644
index 0000000000..a3acf8c5ff
--- /dev/null
+++ b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/controller/CalenderController.java
@@ -0,0 +1,85 @@
+/**
+ * Copyright 2018 人人开源 https://www.renren.io
+ *
+ * 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.
+ *
+ * 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.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+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> page(@RequestParam Map params){
+ PageData page = calenderService.page(params);
+ return new Result>().ok(page);
+ }
+
+ @GetMapping("{id}")
+ public Result get(@PathVariable("id") String id){
+ CalenderDTO data = calenderService.get(id);
+ return new Result().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();
+ }
+
+
+}
\ No newline at end of file
diff --git a/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/controller/ShowApiController.java b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/controller/ShowApiController.java
new file mode 100644
index 0000000000..209c3f4cc4
--- /dev/null
+++ b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/controller/ShowApiController.java
@@ -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();
+ }
+
+}
+
diff --git a/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/controller/WorkDayController.java b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/controller/WorkDayController.java
new file mode 100644
index 0000000000..679613a48d
--- /dev/null
+++ b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/controller/WorkDayController.java
@@ -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>
+ * @param formDTO
+ * @Author yinzuomei
+ * @Description 根据每一组起止时间,计算工作日
+ * @Date 2020/5/12 2:08
+ **/
+ @PostMapping("detentiondays")
+ public Result> detentionDays(@RequestBody List formDTO) {
+ List list = workDayService.detentionDays(formDTO);
+ return new Result>().ok(list);
+ }
+}
+
diff --git a/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/dao/CalenderDao.java b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/dao/CalenderDao.java
new file mode 100644
index 0000000000..1240add1e1
--- /dev/null
+++ b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/dao/CalenderDao.java
@@ -0,0 +1,44 @@
+/**
+ * Copyright 2018 人人开源 https://www.renren.io
+ *
+ * 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.
+ *
+ * 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.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+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 {
+
+ int updateHoliday(HolidayDetailDTO holidayDetail);
+
+ CalenderEntity selectByDay(String day);
+
+ List selectList(String year);
+
+ List selectByStartAndEnd(@Param("begin")String startDateStr, @Param("end")String endDateStr);
+}
\ No newline at end of file
diff --git a/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/entity/CalenderEntity.java b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/entity/CalenderEntity.java
new file mode 100644
index 0000000000..831b102b38
--- /dev/null
+++ b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/entity/CalenderEntity.java
@@ -0,0 +1,101 @@
+/**
+ * Copyright 2018 人人开源 https://www.renren.io
+ *
+ * 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.
+ *
+ * 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.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+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;
+
+}
diff --git a/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/exception/ModuleErrorCode.java b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/exception/ModuleErrorCode.java
new file mode 100644
index 0000000000..1206c71b9a
--- /dev/null
+++ b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/exception/ModuleErrorCode.java
@@ -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位为业务编码
+ *
+ * 如:100001001(100001代表模块,001代表业务代码)
+ *
+ *
+ * @author Mark sunlightcs@gmail.com
+ * @since 1.0.0
+ */
+public interface ModuleErrorCode extends ErrorCode {
+
+}
diff --git a/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/result/DayDetailResultDTO.java b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/result/DayDetailResultDTO.java
new file mode 100644
index 0000000000..827a27fcf9
--- /dev/null
+++ b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/result/DayDetailResultDTO.java
@@ -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;
+}
+
diff --git a/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/result/HolidayDetailDTO.java b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/result/HolidayDetailDTO.java
new file mode 100644
index 0000000000..d47713fc3a
--- /dev/null
+++ b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/result/HolidayDetailDTO.java
@@ -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;
+
+}
+
diff --git a/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/result/HolidayResultDTO.java b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/result/HolidayResultDTO.java
new file mode 100644
index 0000000000..c75adf0cbd
--- /dev/null
+++ b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/result/HolidayResultDTO.java
@@ -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 data;
+
+}
+
diff --git a/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/result/ShowApiResult.java b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/result/ShowApiResult.java
new file mode 100644
index 0000000000..fbba994ece
--- /dev/null
+++ b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/result/ShowApiResult.java
@@ -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 + '\'' +
+ '}';
+ }
+}
+
diff --git a/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/CalenderService.java b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/CalenderService.java
new file mode 100644
index 0000000000..5dbc9c2634
--- /dev/null
+++ b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/CalenderService.java
@@ -0,0 +1,95 @@
+/**
+ * Copyright 2018 人人开源 https://www.renren.io
+ *
+ * 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.
+ *
+ * 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.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+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 {
+
+ /**
+ * 默认分页
+ *
+ * @param params
+ * @return PageData
+ * @author generator
+ * @date 2020-05-11
+ */
+ PageData page(Map params);
+
+ /**
+ * 默认查询
+ *
+ * @param params
+ * @return java.util.List
+ * @author generator
+ * @date 2020-05-11
+ */
+ List list(Map 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);
+}
\ No newline at end of file
diff --git a/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/ShowApiService.java b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/ShowApiService.java
new file mode 100644
index 0000000000..372c247ca7
--- /dev/null
+++ b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/ShowApiService.java
@@ -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);
+
+}
diff --git a/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/WorkDayService.java b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/WorkDayService.java
new file mode 100644
index 0000000000..7433b154c1
--- /dev/null
+++ b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/WorkDayService.java
@@ -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 detentionDays(List formDTO);
+}
diff --git a/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/impl/CalenderServiceImpl.java b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/impl/CalenderServiceImpl.java
new file mode 100644
index 0000000000..6c0dca44c8
--- /dev/null
+++ b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/impl/CalenderServiceImpl.java
@@ -0,0 +1,97 @@
+/**
+ * Copyright 2018 人人开源 https://www.renren.io
+ *
+ * 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.
+ *
+ * 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.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+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 implements CalenderService {
+
+ @Override
+ public PageData page(Map params) {
+ IPage page = baseDao.selectPage(
+ getPage(params, FieldConstant.CREATED_TIME, false),
+ getWrapper(params)
+ );
+ return getPageData(page, CalenderDTO.class);
+ }
+
+ @Override
+ public List list(Map params) {
+ List entityList = baseDao.selectList(getWrapper(params));
+
+ return ConvertUtils.sourceToTarget(entityList, CalenderDTO.class);
+ }
+
+ private QueryWrapper getWrapper(Map params) {
+ String id = (String) params.get(FieldConstant.ID_HUMP);
+
+ QueryWrapper 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));
+ }
+
+}
\ No newline at end of file
diff --git a/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/impl/ShowApiServiceImpl.java b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/impl/ShowApiServiceImpl.java
new file mode 100644
index 0000000000..25a98d7bce
--- /dev/null
+++ b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/impl/ShowApiServiceImpl.java
@@ -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 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];
+ }
+}
+
diff --git a/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/impl/WorkDayServiceImpl.java b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/impl/WorkDayServiceImpl.java
new file mode 100644
index 0000000000..25ede12e88
--- /dev/null
+++ b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/impl/WorkDayServiceImpl.java
@@ -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 detentionDays(List workDayFormDTO) {
+ List 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 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";
+ }
+
+
+}
+
diff --git a/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/task/MultithreadScheduleTask.java b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/task/MultithreadScheduleTask.java
new file mode 100644
index 0000000000..8485f229cb
--- /dev/null
+++ b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/task/MultithreadScheduleTask.java
@@ -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();
+ }
+}
+
diff --git a/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/task/SaticScheduleTask.java b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/task/SaticScheduleTask.java
new file mode 100644
index 0000000000..bdca1553d2
--- /dev/null
+++ b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/task/SaticScheduleTask.java
@@ -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());
+ }
+}
+
diff --git a/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/utils/ShowApiUtil.java b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/utils/ShowApiUtil.java
new file mode 100644
index 0000000000..8e4c8f4de3
--- /dev/null
+++ b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/utils/ShowApiUtil.java
@@ -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();
+ }
+ }
+}
+
diff --git a/epmet-module/epmet-common-service/common-service-server/src/main/resources/bootstrap.yml b/epmet-module/epmet-common-service/common-service-server/src/main/resources/bootstrap.yml
new file mode 100644
index 0000000000..15b337db7c
--- /dev/null
+++ b/epmet-module/epmet-common-service/common-service-server/src/main/resources/bootstrap.yml
@@ -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
diff --git a/epmet-module/epmet-common-service/common-service-server/src/main/resources/db/migration/db.sql b/epmet-module/epmet-common-service/common-service-server/src/main/resources/db/migration/db.sql
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/epmet-module/epmet-common-service/common-service-server/src/main/resources/logback-spring.xml b/epmet-module/epmet-common-service/common-service-server/src/main/resources/logback-spring.xml
new file mode 100644
index 0000000000..e3cfdd0927
--- /dev/null
+++ b/epmet-module/epmet-common-service/common-service-server/src/main/resources/logback-spring.xml
@@ -0,0 +1,158 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+ debug
+
+
+ ${CONSOLE_LOG_PATTERN}
+
+ UTF-8
+
+
+
+
+
+
+
+ ${log.path}/debug.log
+
+
+ %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n
+ UTF-8
+
+
+
+
+ ${log.path}/debug-%d{yyyy-MM-dd}.%i.log
+
+ 100MB
+
+
+ 15
+
+
+
+ debug
+ ACCEPT
+ DENY
+
+
+
+
+
+
+ ${log.path}/info.log
+
+
+ %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n
+ UTF-8
+
+
+
+
+ ${log.path}/info-%d{yyyy-MM-dd}.%i.log
+
+ 100MB
+
+
+ 15
+
+
+
+ info
+ ACCEPT
+ DENY
+
+
+
+
+
+
+ ${log.path}/warn.log
+
+
+ %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n
+ UTF-8
+
+
+
+ ${log.path}/warn-%d{yyyy-MM-dd}.%i.log
+
+ 100MB
+
+
+ 15
+
+
+
+ warn
+ ACCEPT
+ DENY
+
+
+
+
+
+
+ ${log.path}/error.log
+
+
+ %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n
+ UTF-8
+
+
+
+ ${log.path}/error-%d{yyyy-MM-dd}.%i.log
+
+ 100MB
+
+
+ 15
+
+
+
+ ERROR
+ ACCEPT
+ DENY
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/epmet-module/epmet-common-service/common-service-server/src/main/resources/mapper/CalenderDao.xml b/epmet-module/epmet-common-service/common-service-server/src/main/resources/mapper/CalenderDao.xml
new file mode 100644
index 0000000000..b1a3ab8e8d
--- /dev/null
+++ b/epmet-module/epmet-common-service/common-service-server/src/main/resources/mapper/CalenderDao.xml
@@ -0,0 +1,64 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ select * from calender c
+ where c.del_flag='0'
+ and c.DAY=#{day}
+
+
+
+ UPDATE calender
+ SET type = '3',
+ TYPE_NAME = '节假日',
+ HOLIDAY_REMARK = #{holiday_remark},
+ HOLIDAY = #{holiday}
+ WHERE
+ DEL_FLAG = '0'
+ AND QUERY_DATE BETWEEN #{begin}
+ AND #{end}
+
+
+
+ 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
+ *
+ FROM
+ calender
+ WHERE
+ DEL_FLAG = '0'
+ AND QUERY_DATE BETWEEN #{begin}
+ AND #{end}
+
+
\ No newline at end of file
diff --git a/epmet-module/epmet-common-service/pom.xml b/epmet-module/epmet-common-service/pom.xml
new file mode 100644
index 0000000000..7882f594f0
--- /dev/null
+++ b/epmet-module/epmet-common-service/pom.xml
@@ -0,0 +1,21 @@
+
+
+ 4.0.0
+
+
+ com.epmet
+ epmet-module
+ 2.0.0
+
+
+ com.epmet
+ epmet-common-service
+ pom
+
+
+ common-service-client
+ common-service-server
+
+
+
diff --git a/epmet-module/pom.xml b/epmet-module/pom.xml
index 50fdc831c0..5637182706 100644
--- a/epmet-module/pom.xml
+++ b/epmet-module/pom.xml
@@ -33,6 +33,7 @@
resi-hall
gov-issue
gov-project
+ epmet-common-service