瀏覽代碼

项目迁移

zhang-kan-kan 2 年之前
當前提交
8975e84e31

+ 37 - 0
.gitignore

@@ -0,0 +1,37 @@
+# IntelliJ project files
+.idea
+*.iml
+out
+gen
+### Java template
+# Compiled class file
+*.class
+
+# Log file
+*.log
+/log/
+
+# BlueJ files
+*.ctxt
+
+# Mobile Tools for Java (J2ME)
+.mtj.tmp/
+
+# Package Files #
+*.jar
+*.war
+*.nar
+*.ear
+*.zip
+*.tar.gz
+*.rar
+
+# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
+hs_err_pid*
+
+mvnw
+mvnw.cmd
+
+# tmp file
+.tmp
+/tmp/

+ 360 - 0
pom.xml

@@ -0,0 +1,360 @@
+<?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>org.springframework.boot</groupId>
+        <artifactId>spring-boot-starter-parent</artifactId>
+        <version>2.3.3.RELEASE</version>
+        <relativePath/> <!-- lookup parent from repository -->
+    </parent>
+    <groupId>com.muzhi.shennongshi</groupId>
+    <artifactId>shennongshi</artifactId>
+<!--    <packaging>jar</packaging>-->
+    <version>1.0-SNAPSHOT</version>
+    <name>shennongshi</name>
+    <description>Demo project for Spring Boot</description>
+
+    <properties>
+        <java.version>1.8</java.version>
+        <fastjson.version>1.2.33</fastjson.version>
+        <gson.version>2.8.2</gson.version>
+        <json.version>20170516</json.version>
+        <poi.version>3.17</poi.version>
+        <jodatime.version>2.10.1</jodatime.version>
+        <swagger.version>2.7.0</swagger.version>
+        <commons-fileupload.version>1.3.1</commons-fileupload.version>
+        <!--        <thymeleaf.version>3.0.2.RELEASE</thymeleaf.version>-->
+        <!-- 布局功能的支持程序 thymeleaf3主程序 layout2以上版本-->
+        <!--        <thymeleaf-layout-dialect.version>2.1.1</thymeleaf-layout-dialect.version>-->
+    </properties>
+
+    <repositories>
+        <repository>
+            <id>sonatype-nexus-staging</id>
+            <name>Sonatype Nexus Staging</name>
+            <url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
+            <releases>
+                <enabled>true</enabled>
+            </releases>
+            <snapshots>
+                <enabled>true</enabled>
+            </snapshots>
+        </repository>
+    </repositories>
+
+    <dependencies>
+        <dependency>
+            <groupId>com.auth0</groupId>
+            <artifactId>java-jwt</artifactId>
+            <version>3.4.0</version>
+        </dependency>
+
+        <!-- httpClient -->
+        <dependency>
+            <groupId>org.apache.httpcomponents</groupId>
+            <artifactId>httpclient</artifactId>
+            <version>4.5.2</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.httpcomponents</groupId>
+            <artifactId>httpcore</artifactId>
+            <version>4.4.13</version>
+        </dependency>
+
+        <dependency>
+            <groupId>commons-httpclient</groupId>
+            <artifactId>commons-httpclient</artifactId>
+            <version>3.1</version>
+        </dependency>
+
+        <dependency>
+            <groupId>com.squareup.okhttp3</groupId>
+            <artifactId>okhttp</artifactId>
+            <version>4.4.1</version>
+        </dependency>
+
+        <dependency>
+            <groupId>com.konghq</groupId>
+            <artifactId>unirest-java</artifactId>
+            <version>2.3.17</version>
+        </dependency>
+
+<!--        <dependency>-->
+<!--            <groupId>org.slf4j</groupId>-->
+<!--            <artifactId>slf4j-api</artifactId>-->
+<!--        </dependency>-->
+
+<!--        <dependency>-->
+<!--            <groupId>commons-io</groupId>-->
+<!--            <artifactId>commons-io</artifactId>-->
+<!--        </dependency>-->
+
+        <!--json 组件 -->
+<!--        <dependency>-->
+<!--            <groupId>com.alibaba</groupId>-->
+<!--            <artifactId>fastjson</artifactId>-->
+<!--            <scope>provided</scope>-->
+<!--        </dependency>-->
+
+        <!--        <dependency>-->
+        <!--            <groupId>org.apache.cxf</groupId>-->
+        <!--            <artifactId>cxf-spring-boot-starter-jaxws</artifactId>-->
+        <!--            <version>3.3.1</version>-->
+        <!--        </dependency>-->
+
+        <!--        <dependency>-->
+        <!--            <groupId>org.springframework.boot</groupId>-->
+        <!--            <artifactId>spring-boot-starter-thymeleaf</artifactId>-->
+        <!--&lt;!&ndash;            <version>2.3.3.RELEASE</version>&ndash;&gt;-->
+        <!--        </dependency>-->
+
+        <!--钉钉相关-->
+        <dependency>
+            <groupId>com.aliyun</groupId>
+            <artifactId>alibaba-dingtalk-service-sdk</artifactId>
+            <version>2.0.0</version>
+        </dependency>
+
+        <dependency>
+            <groupId>com.aliyun</groupId>
+            <artifactId>dingtalk</artifactId>
+            <version>1.4.35</version>
+        </dependency>
+
+        <!--json相关-->
+        <dependency>
+            <groupId>com.alibaba</groupId>
+            <artifactId>fastjson</artifactId>
+            <version>${fastjson.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.json</groupId>
+            <artifactId>json</artifactId>
+            <version>${json.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>com.google.code.gson</groupId>
+            <artifactId>gson</artifactId>
+            <version>${gson.version}</version>
+        </dependency>
+
+        <!--        <dependency>-->
+        <!--            <groupId>net.sf.json-lib</groupId>-->
+        <!--            <artifactId>json-lib</artifactId>-->
+        <!--            <version>2.4</version>-->
+        <!--        </dependency>-->
+
+
+        <!-- JSONObject对象依赖的jar包 -->
+        <dependency>
+            <groupId>commons-beanutils</groupId>
+            <artifactId>commons-beanutils</artifactId>
+            <version>1.9.3</version>
+        </dependency>
+        <dependency>
+            <groupId>commons-collections</groupId>
+            <artifactId>commons-collections</artifactId>
+            <version>3.2.1</version>
+        </dependency>
+        <dependency>
+            <groupId>commons-lang</groupId>
+            <artifactId>commons-lang</artifactId>
+            <version>2.6</version>
+        </dependency>
+        <dependency>
+            <groupId>commons-logging</groupId>
+            <artifactId>commons-logging</artifactId>
+            <version>1.1.1</version>
+        </dependency>
+        <dependency>
+            <groupId>net.sf.ezmorph</groupId>
+            <artifactId>ezmorph</artifactId>
+            <version>1.0.6</version>
+        </dependency>
+        <dependency>
+            <groupId>net.sf.json-lib</groupId>
+            <artifactId>json-lib</artifactId>
+            <version>2.2.3</version>
+            <classifier>jdk15</classifier><!-- 指定jdk版本 -->
+        </dependency>
+
+
+        <!--xls-->
+        <dependency>
+            <groupId>org.apache.poi</groupId>
+            <artifactId>poi</artifactId>
+            <version>${poi.version}</version>
+        </dependency>
+        <!--xlsx-->
+        <dependency>
+            <groupId>org.apache.poi</groupId>
+            <artifactId>poi-ooxml</artifactId>
+            <version>${poi.version}</version>
+        </dependency>
+        <!--文件上传-->
+        <dependency>
+            <groupId>commons-fileupload</groupId>
+            <artifactId>commons-fileupload</artifactId>
+            <version>${commons-fileupload.version}</version>
+        </dependency>
+
+        <!--        <dependency>-->
+        <!--            <groupId>org.springframework.boot</groupId>-->
+        <!--            <artifactId>spring-boot-starter-thymeleaf</artifactId>-->
+        <!--        </dependency>-->
+
+        <!--引入web模块-->
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-web</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-devtools</artifactId>
+            <version>2.3.3.RELEASE</version>
+        </dependency>
+        <dependency>
+            <groupId>org.projectlombok</groupId>
+            <artifactId>lombok</artifactId>
+            <optional>true</optional>
+            <version>1.18.10</version>
+        </dependency>
+
+        <!--MD5加密-->
+        <dependency>
+            <groupId>org.apache.directory.studio</groupId>
+            <artifactId>org.apache.commons.codec</artifactId>
+            <version>1.8</version>
+        </dependency>
+
+<!--        &lt;!&ndash;mybatis-plus数据库连接&ndash;&gt;-->
+<!--        <dependency>-->
+<!--            <groupId>com.baomidou</groupId>-->
+<!--            <artifactId>mybatis-plus-boot-starter</artifactId>-->
+<!--            <version>3.2.0</version>-->
+<!--        </dependency>-->
+<!--        &lt;!&ndash;引入mysql:数据库驱动&ndash;&gt;-->
+<!--        <dependency>-->
+<!--            <groupId>mysql</groupId>-->
+<!--            <artifactId>mysql-connector-java</artifactId>-->
+<!--            <scope>runtime</scope>-->
+<!--        </dependency>-->
+<!--        &lt;!&ndash;引入druid数据源&ndash;&gt;-->
+<!--        &lt;!&ndash; https://mvnrepository.com/artifact/com.alibaba/druid &ndash;&gt;-->
+<!--        <dependency>-->
+<!--            <groupId>com.alibaba</groupId>-->
+<!--            <artifactId>druid</artifactId>-->
+<!--            <version>1.1.9</version>-->
+<!--        </dependency>-->
+<!--        <dependency>-->
+<!--            <groupId>com.alibaba</groupId>-->
+<!--            <artifactId>druid-spring-boot-starter</artifactId>-->
+<!--            <version>1.1.9</version>-->
+<!--        </dependency>-->
+
+        <!--引入jpa模块-->
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-data-jpa</artifactId>
+        </dependency>
+
+        <!--日期时间工具-->
+        <dependency>
+            <groupId>joda-time</groupId>
+            <artifactId>joda-time</artifactId>
+            <version>${jodatime.version}</version>
+        </dependency>
+
+        <!--日期工具-->
+        <dependency>
+            <groupId>cn.hutool</groupId>
+            <artifactId>hutool-all</artifactId>
+            <version>4.6.8</version>
+        </dependency>
+
+        <!--log4j-->
+        <dependency>
+            <groupId>log4j</groupId>
+            <artifactId>log4j</artifactId>
+            <version>1.2.17</version>
+        </dependency>
+
+        <!--swagger-->
+        <dependency>
+            <groupId>io.springfox</groupId>
+            <artifactId>springfox-swagger2</artifactId>
+            <version>${swagger.version}</version>
+        </dependency>
+        <!--swagger ui-->
+        <dependency>
+            <groupId>io.springfox</groupId>
+            <artifactId>springfox-swagger-ui</artifactId>
+            <version>${swagger.version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-test</artifactId>
+            <scope>test</scope>
+            <exclusions>
+                <exclusion>
+                    <groupId>org.junit.vintage</groupId>
+                    <artifactId>junit-vintage-engine</artifactId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.springframework.boot</groupId>
+                <artifactId>spring-boot-maven-plugin</artifactId>
+                <configuration>
+                    <fork>true</fork>
+                </configuration>
+            </plugin>
+
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-compiler-plugin</artifactId>
+                <version>2.3.1</version>
+                <configuration>
+                    <source>1.8</source>
+                    <target>1.8</target>
+                    <encoding>utf8</encoding>
+                </configuration>
+            </plugin>
+
+            <!--打包跳过测试-->
+<!--            <plugin>-->
+<!--                <groupId>org.apache.maven.plugins</groupId>-->
+<!--                <artifactId>maven-surefire-plugin</artifactId>-->
+<!--                <version>2.4.2</version>-->
+<!--                <configuration>-->
+<!--                    <skipTests>true</skipTests>-->
+<!--                </configuration>-->
+<!--            </plugin>-->
+        </plugins>
+
+        <!--映射mapper中对应的xml配置文件,如果没有mapper.xml文件则将下列注释-->
+<!--        <resources>-->
+<!--            <resource>-->
+<!--                <directory>src/main/java</directory>-->
+<!--                <includes>-->
+<!--                    <include>**/*.xml</include>-->
+
+<!--                    <include>**/*.properties</include>-->
+<!--                    <include>**/*.tld</include>-->
+<!--                    <include>**/*.xls</include>-->
+<!--                    <include>**/*.xlsx</include>-->
+<!--                </includes>-->
+<!--                <filtering>false</filtering>-->
+<!--            </resource>-->
+<!--        </resources>-->
+    </build>
+
+</project>

+ 21 - 0
src/main/java/com/muzhi/shennongshi/ShenNongShiApplication.java

@@ -0,0 +1,21 @@
+package com.muzhi.shennongshi;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
+import org.springframework.scheduling.annotation.EnableAsync;
+import org.springframework.scheduling.annotation.EnableScheduling;
+
+
+//@MapperScan("com.muzhi.shennongshi.mapper")
+@EnableAsync//开启异步注解
+@SpringBootApplication(exclude= DataSourceAutoConfiguration.class)//启动时不加载数据库(exclude= DataSourceAutoConfiguration.class)
+@EnableScheduling//开启定时任务
+//@ComponentScan(basePackages = {"com.muzhi"})
+public class ShenNongShiApplication {
+
+    public static void main(String[] args){
+        SpringApplication.run(ShenNongShiApplication.class, args);
+    }
+
+}

+ 77 - 0
src/main/java/com/muzhi/shennongshi/common/R.java

@@ -0,0 +1,77 @@
+package com.muzhi.shennongshi.common;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @Author ZhangKan
+ * @Data 11:20
+ */
+
+//统一返回结果类
+@Data
+public class R {
+
+    @ApiModelProperty(value = "是否成功")
+    private Boolean success;
+
+    @ApiModelProperty(value = "返回码")
+    private Integer code;
+
+    @ApiModelProperty(value = "返回消息")
+    private String message;
+
+    @ApiModelProperty(value = "返回数据")
+    private Map<String, Object> data = new HashMap<String, Object>();
+
+    //把构造方法私有
+    private R(){}
+
+    //成功静态方法
+    public static R ok(){
+
+        R r = new R();
+        r.setSuccess(true);
+        r.setCode(ResultCode.SUCCESS);
+        r.setMessage("成功");
+        return r;
+    }
+
+    //失败静态方法
+    public static R error(){
+
+        R r = new R();
+        r.setSuccess(false);
+        r.setCode(ResultCode.ERROR);
+        r.setMessage("失败");
+        return r;
+    }
+
+    public R message(String message){
+        this.setMessage(message);
+        return this;
+    }
+
+    public R code(Integer code){
+        this.setCode(code);
+        return this;
+    }
+
+    public R data(String key, Object value){
+        this.data.put(key, value);
+        return this;
+    }
+
+    public R data(String key, String value){
+        this.data.put(key, value);
+        return this;
+    }
+
+    public R data(Map<String, Object> map){
+        this.setData(map);
+        return this;
+    }
+}

+ 12 - 0
src/main/java/com/muzhi/shennongshi/common/ResultCode.java

@@ -0,0 +1,12 @@
+package com.muzhi.shennongshi.common;
+
+/**
+ * @Author ZhangKan
+ * @Data 11:15
+ */
+public interface ResultCode {
+
+    public static Integer SUCCESS = 200;//成功
+
+    public static Integer ERROR = 201;//失败
+}

+ 34 - 0
src/main/java/com/muzhi/shennongshi/controller/AccessTokenController.java

@@ -0,0 +1,34 @@
+package com.muzhi.shennongshi.controller;
+
+import com.muzhi.shennongshi.service.AccessTokenService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.CrossOrigin;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * @Author ZhangKan
+ * @Data 15:03
+ */
+
+@Api(description = "钉钉授权AccessToken")
+@RestController
+@RequestMapping("/dingservice")
+@CrossOrigin//解决跨域问题
+public class AccessTokenController {
+
+    @Autowired
+    private AccessTokenService AccessTokenService;
+
+    //获取钉钉中的access_token(美犀架构)
+    @ApiOperation(value = "获取钉钉中的access_token")
+    @GetMapping("getAccessToken")
+    public String getAccessToken(){
+
+        String accessToken = AccessTokenService.getAccessToken();
+        return accessToken;
+    }
+}

+ 101 - 0
src/main/java/com/muzhi/shennongshi/controller/DingOaController.java

@@ -0,0 +1,101 @@
+package com.muzhi.shennongshi.controller;
+
+import com.muzhi.shennongshi.common.R;
+import com.muzhi.shennongshi.service.DingOaService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.Map;
+
+
+@Api(description = "钉钉")
+@RestController
+@RequestMapping("/dingservice")
+@CrossOrigin//解决跨域问题
+public class DingOaController {
+
+    @Autowired
+    private DingOaService dingOaService;
+
+    /**
+     * 表单打开时加载(所属主体)
+     */
+    @ApiOperation(value = "表单打开时加载(所属主体)")
+    @GetMapping("getSuoshuzhuti")
+//    @Scheduled(cron = "0 10 0 * * ?")//每天00:10触发(也就是凌晨0点10分触发)
+//    @Scheduled(cron = "0 0/10 * * * ?")//每10分钟执行一次
+//    @Scheduled(cron = "0 */10 * * * ?")//每隔10分钟执行一次
+    public Map getSuoshuzhuti(String userid){
+
+        Map suoshuzhuti = dingOaService.getSuoshuzhuti(userid);
+        return suoshuzhuti;
+    }
+
+    /**
+     * 表单提交审批通过后反写智能人事花名册更新(所属主体)
+     */
+    @ApiOperation(value = "表单提交审批通过后反写智能人事花名册更新(所属主体)")
+    @PostMapping("updateSuoshuzhuti")
+//    @Scheduled(cron = "0 10 0 * * ?")//每天00:10触发(也就是凌晨0点10分触发)
+//    @Scheduled(cron = "0 0/10 * * * ?")//每10分钟执行一次
+//    @Scheduled(cron = "0 */10 * * * ?")//每隔10分钟执行一次
+    public R updateSuoshuzhuti(String userid,String sszt){
+
+        R updateSuoshuzhuti = dingOaService.updateSuoshuzhuti(userid,sszt);
+        return updateSuoshuzhuti;
+    }
+
+    /**
+     * 表单打开时加载(人员类型)
+     */
+    @ApiOperation(value = "表单打开时加载(人员类型)")
+    @GetMapping("getRenyuanleixing")
+//    @Scheduled(cron = "0 10 0 * * ?")//每天00:10触发(也就是凌晨0点10分触发)
+//    @Scheduled(cron = "0 0/10 * * * ?")//每10分钟执行一次
+//    @Scheduled(cron = "0 */10 * * * ?")//每隔10分钟执行一次
+    public String getRenyuanleixing(String userid){
+
+        String renyuanleixing = dingOaService.getRenyuanleixing(userid);
+        return renyuanleixing;
+    }
+
+    //表单提交时校验
+    @ApiOperation(value = "表单提交时校验")
+    @GetMapping("getJBJY")
+    public Map getJBJY(String rylx,String jbbcfs){
+
+        Map jbjy = dingOaService.getJBJY(rylx,jbbcfs);
+
+        return jbjy;
+    }
+
+    /**
+     * 表单打开时加载(员工假期类型)
+     */
+    @ApiOperation(value = "表单打开时加载(员工假期类型)")
+    @GetMapping("getJiaqileixing")
+//    @Scheduled(cron = "0 10 0 * * ?")//每天00:10触发(也就是凌晨0点10分触发)
+//    @Scheduled(cron = "0 0/10 * * * ?")//每10分钟执行一次
+//    @Scheduled(cron = "0 */10 * * * ?")//每隔10分钟执行一次
+    public String getJiaqileixing(String userid){
+
+        String jiaqileixing = dingOaService.getJiaqileixing(userid);
+        return jiaqileixing;
+    }
+
+    /**
+     * 请假审批表单提交后反校验是否提交单据内容是否符合规则,不符合执行撤销审批实例
+     */
+    @ApiOperation(value = "表单提交审批通过后反写智能人事花名册更新(所属主体)")
+    @PostMapping("revocationProcessInstances")
+//    @Scheduled(cron = "0 10 0 * * ?")//每天00:10触发(也就是凌晨0点10分触发)
+//    @Scheduled(cron = "0 0/10 * * * ?")//每10分钟执行一次
+//    @Scheduled(cron = "0 */10 * * * ?")//每隔10分钟执行一次
+    public R revocationProcessInstances(String processInstances,String ygjqlx,String userid){
+
+        R revocationProcessInstances = dingOaService.revocationProcessInstances(processInstances,ygjqlx,userid);
+        return revocationProcessInstances;
+    }
+}

+ 11 - 0
src/main/java/com/muzhi/shennongshi/service/AccessTokenService.java

@@ -0,0 +1,11 @@
+package com.muzhi.shennongshi.service;
+
+/**
+ * @Author ZhangKan
+ * @Data 15:34
+ */
+public interface AccessTokenService {
+
+    //获取access_token的方法(美邸艾架构)
+    String getAccessToken();
+}

+ 40 - 0
src/main/java/com/muzhi/shennongshi/service/DingOaService.java

@@ -0,0 +1,40 @@
+package com.muzhi.shennongshi.service;
+
+import com.muzhi.shennongshi.common.R;
+
+import java.util.Map;
+
+/**
+ * @Author ZhangKan
+ * @Data 15:34
+ */
+public interface DingOaService {
+
+    /**
+     * 表单打开时加载(所属主体)
+     */
+    Map getSuoshuzhuti(String userid);
+
+    /**
+     * 表单提交审批通过后反写智能人事花名册更新(所属主体)
+     */
+    R updateSuoshuzhuti(String userid,String sszt);
+
+    /**
+     * 表单打开时加载(人员类型)
+     */
+    String getRenyuanleixing(String userid);
+
+    //表单提交时校验
+    Map getJBJY(String rylx,String jbbcfs);
+
+    /**
+     * 表单打开时加载(员工假期类型)
+     */
+    String getJiaqileixing(String userid);
+
+    /**
+     * 请假审批表单提交后反校验是否提交单据内容是否符合规则,不符合执行撤销审批实例
+     */
+    R revocationProcessInstances(String processInstances,String ygjqlx,String userid);
+}

+ 46 - 0
src/main/java/com/muzhi/shennongshi/service/impl/AccessTokenServiceImpl.java

@@ -0,0 +1,46 @@
+package com.muzhi.shennongshi.service.impl;
+
+import com.dingtalk.api.DefaultDingTalkClient;
+import com.dingtalk.api.request.OapiGettokenRequest;
+import com.dingtalk.api.response.OapiGettokenResponse;
+import com.muzhi.shennongshi.service.AccessTokenService;
+import com.taobao.api.ApiException;
+import org.springframework.stereotype.Service;
+
+
+/**
+ * @Author ZhangKan
+ * @Data 15:39
+ */
+
+@Service
+public class AccessTokenServiceImpl implements AccessTokenService {
+
+    //神农氏
+    //APPKEY
+    private static String APPKEY = "dingafishtqycyanna3n";
+    //APPSECRET
+    private static String APPSECRET = "IXHzCtm2X-nmt6f3gdHEgRwKeCqHM9OZpF0xvW0DElZOByTJG4zwQ-Qx-3cZH-NM";
+    //AgenthId:2358039528
+
+    public static String accessToken = null;
+
+
+    //获取access_token的方法(神农氏架构)
+    @Override
+    public String getAccessToken() {
+        DefaultDingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/gettoken");
+        OapiGettokenRequest request = new OapiGettokenRequest();
+        request.setAppkey(APPKEY);
+        request.setAppsecret(APPSECRET);
+        request.setHttpMethod("GET");
+        try {
+            OapiGettokenResponse response = client.execute(request);
+            accessToken = response.getAccessToken();
+            System.out.println("AccessToken:" + accessToken);
+        } catch (ApiException e) {
+            e.printStackTrace();
+        }
+        return accessToken;
+    }
+}

+ 452 - 0
src/main/java/com/muzhi/shennongshi/service/impl/DingOaServiceImpl.java

@@ -0,0 +1,452 @@
+package com.muzhi.shennongshi.service.impl;
+
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.aliyun.dingtalkworkflow_1_0.models.GetProcessInstanceResponse;
+import com.aliyun.tea.TeaException;
+import com.aliyun.teautil.models.RuntimeOptions;
+import com.dingtalk.api.DefaultDingTalkClient;
+import com.dingtalk.api.DingTalkClient;
+import com.dingtalk.api.request.OapiSmartworkHrmEmployeeV2ListRequest;
+import com.dingtalk.api.request.OapiSmartworkHrmEmployeeV2UpdateRequest;
+import com.dingtalk.api.response.OapiSmartworkHrmEmployeeV2ListResponse;
+import com.dingtalk.api.response.OapiSmartworkHrmEmployeeV2UpdateResponse;
+import com.google.gson.JsonObject;
+import com.muzhi.shennongshi.common.R;
+import com.muzhi.shennongshi.service.AccessTokenService;
+import com.muzhi.shennongshi.service.DingOaService;
+import com.taobao.api.ApiException;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.scheduling.annotation.Async;
+import org.springframework.stereotype.Service;
+
+import java.text.SimpleDateFormat;
+import java.util.*;
+
+
+@Service
+@Slf4j
+public class DingOaServiceImpl implements DingOaService {
+
+    @Autowired
+    private AccessTokenService accessTokenService;
+
+    /**
+     * 表单打开时加载(原所属主体)
+     */
+    @Override
+    public Map getSuoshuzhuti(String userid){
+        log.info("获取当前表单传参人员userid:" + userid);
+
+        //智能人事获取员工花名册信息,抓取【人员主体】字段信息
+        String body = null;
+        String label = null;
+        String value = null;
+        try {
+            DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/smartwork/hrm/employee/v2/list");
+            OapiSmartworkHrmEmployeeV2ListRequest req = new OapiSmartworkHrmEmployeeV2ListRequest();
+            //待查询人员userid
+            req.setUseridList(userid);
+            req.setAgentid(2358039528L);
+            OapiSmartworkHrmEmployeeV2ListResponse rsp = client.execute(req, accessTokenService.getAccessToken());
+            body = rsp.getBody();
+            System.out.println(body);
+
+            JSONObject jsonObject = JSON.parseObject(body);
+            JSONArray result = jsonObject.getJSONArray("result");
+            JSONArray field_data_list = result.getJSONObject(0).getJSONArray("field_data_list");
+
+            for (int i = 0; i < field_data_list.size(); i++) {
+                //字段code
+                String field_code = field_data_list.getJSONObject(i).getString("field_code");
+//                log.info("当前花名册字段field_code:" + field_code);
+                switch (field_code) {
+                    //人员主体
+                    case "3ee15b1a-3fda-46d5-ac4b-c11ea01e0c5c":
+                        JSONArray field_value_list = field_data_list.getJSONObject(i).getJSONArray("field_value_list");
+                        //人员主体内容
+                        label = field_value_list.getJSONObject(0).getString("label");
+                        //人员主体编号
+                        value = field_value_list.getJSONObject(0).getString("value");
+                        //当前字段下标
+                        int old_index = i;
+                        log.info("当前字段下标:" + old_index);
+                        break;
+                }
+            }
+        } catch (ApiException e) {
+            e.printStackTrace();
+        }
+        log.info("当前人员所属主体:" + label + "<-->" + "所属主体编号:" + value);
+
+        //封装连接器出参
+        List list = new ArrayList();
+
+        Map map = new HashMap();
+        map.put("vlaue",value);
+        map.put("label",label);
+
+        return map;
+    }
+
+    /**
+     * 表单提交审批通过后反写智能人事花名册更新(所属主体)
+     */
+    @Override
+    public R updateSuoshuzhuti(String userid,String sszt){
+        log.info("获取当前表单传参待更新人员userid:" + userid);
+        log.info("获取当前表单传参待更新人员所属主体:" + sszt);
+
+        String ssztid = null;
+        if (sszt.equals("餐饮")){
+            ssztid = "10001";
+        }else if (sszt.equals("管理")){
+            ssztid = "10002";
+        }else if (sszt.equals("神唐")){
+            ssztid = "10003";
+        }else if (sszt.equals("五斗米")){
+            ssztid = "10004";
+        }
+
+        //更新智能人事员工花名册【人员主体】字段信息
+        String body = null;
+        String success = null;
+        String errmsg = null;
+        try {
+            DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/smartwork/hrm/employee/v2/update");
+            OapiSmartworkHrmEmployeeV2UpdateRequest req = new OapiSmartworkHrmEmployeeV2UpdateRequest();
+            req.setAgentid(2358039528L);
+            OapiSmartworkHrmEmployeeV2UpdateRequest.EmpUpdateByCustomParam obj1 = new OapiSmartworkHrmEmployeeV2UpdateRequest.EmpUpdateByCustomParam();
+            List<OapiSmartworkHrmEmployeeV2UpdateRequest.EmpGroupFieldVo> list3 = new ArrayList<OapiSmartworkHrmEmployeeV2UpdateRequest.EmpGroupFieldVo>();
+            OapiSmartworkHrmEmployeeV2UpdateRequest.EmpGroupFieldVo obj4 = new OapiSmartworkHrmEmployeeV2UpdateRequest.EmpGroupFieldVo();
+            list3.add(obj4);
+            List<OapiSmartworkHrmEmployeeV2UpdateRequest.EmpListFieldVo> list7 = new ArrayList<OapiSmartworkHrmEmployeeV2UpdateRequest.EmpListFieldVo>();
+            OapiSmartworkHrmEmployeeV2UpdateRequest.EmpListFieldVo obj8 = new OapiSmartworkHrmEmployeeV2UpdateRequest.EmpListFieldVo();
+            list7.add(obj8);
+            List<OapiSmartworkHrmEmployeeV2UpdateRequest.EmpFieldVo> list11 = new ArrayList<OapiSmartworkHrmEmployeeV2UpdateRequest.EmpFieldVo>();
+            OapiSmartworkHrmEmployeeV2UpdateRequest.EmpFieldVo obj12 = new OapiSmartworkHrmEmployeeV2UpdateRequest.EmpFieldVo();
+            list11.add(obj12);
+            //智能人事花名册中【人员主体】字段编号
+            obj12.setFieldCode("3ee15b1a-3fda-46d5-ac4b-c11ea01e0c5c");
+            //更新内容编号
+            obj12.setValue(ssztid);
+            obj8.setSection(list11);
+            //TODO 智能人事花名册中【人员主体】数组下标
+            obj8.setOldIndex(30L);
+            obj4.setSections(list7);
+            //字段分组编号
+            obj4.setGroupId("sys01");
+            obj1.setGroups(list3);
+            //更新人员的userid
+            obj1.setUserid(userid);
+            req.setParam(obj1);
+            OapiSmartworkHrmEmployeeV2UpdateResponse rsp = client.execute(req, accessTokenService.getAccessToken());
+            body = rsp.getBody();
+            System.out.println(body);
+            JSONObject jsonObject = JSON.parseObject(body);
+            success = jsonObject.getString("success");
+            log.info("钉钉智能人事更新员工花名册字段返回结果标识:" + success);
+            errmsg = jsonObject.getString("errmsg");
+            log.info("钉钉智能人事更新员工花名册字段返回结果信息:" + errmsg);
+        } catch (ApiException e) {
+            e.printStackTrace();
+        }
+
+        //封装返回信息
+        if (success.equals("true")){
+            return R.ok().message(errmsg);
+        }else {
+            return R.error().message(errmsg);
+        }
+    }
+
+    /**
+     * 表单打开时加载(人员类型)
+     */
+    @Override
+    public String getRenyuanleixing(String userid){
+        log.info("获取当前表单传参人员userid:" + userid);
+
+        //智能人事获取员工花名册信息,抓取【人员类型】字段信息
+        String body = null;
+        String label = null;
+        try {
+            DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/smartwork/hrm/employee/v2/list");
+            OapiSmartworkHrmEmployeeV2ListRequest req = new OapiSmartworkHrmEmployeeV2ListRequest();
+            //待查询人员userid
+            req.setUseridList(userid);
+            req.setAgentid(2358039528L);
+            OapiSmartworkHrmEmployeeV2ListResponse rsp = client.execute(req, accessTokenService.getAccessToken());
+            body = rsp.getBody();
+            System.out.println(body);
+
+            JSONObject jsonObject = JSON.parseObject(body);
+            JSONArray result = jsonObject.getJSONArray("result");
+            JSONArray field_data_list = result.getJSONObject(0).getJSONArray("field_data_list");
+
+            for (int i = 0; i < field_data_list.size(); i++) {
+                //字段code
+                String field_code = field_data_list.getJSONObject(i).getString("field_code");
+//                log.info("当前花名册字段field_code:" + field_code);
+                switch (field_code) {
+                    //人员类型
+                    case "691436b8-b2ed-4f7d-b4dd-d8cd7a6fc98b":
+                        JSONArray field_value_list = field_data_list.getJSONObject(i).getJSONArray("field_value_list");
+                        //人员类型
+                        label = field_value_list.getJSONObject(0).getString("label");
+                        //当前字段下标
+                        int old_index = i;
+                        log.info("当前字段下标:" + old_index);
+                        break;
+                }
+            }
+        } catch (ApiException e) {
+            e.printStackTrace();
+        }
+        log.info("人员类型:" + label);
+
+        return label;
+    }
+
+    /**
+     * 表单提交时校验
+     * @param rylx(连接器传参人员类型)
+     * @param jbbcfs(连接器传参加班补偿方式)
+     * @return
+     */
+
+    @Override
+    public Map getJBJY(String rylx,String jbbcfs){
+        System.out.println("连接器传参人员类型:" + rylx);
+        System.out.println("连接器传参加班补偿方式:" + jbbcfs);
+
+        Boolean zhi = null;
+
+        if (rylx.equals("领导")){
+            if (jbbcfs.equals("转调休")){
+                zhi = true;
+            }else {
+                zhi = false;
+            }
+        }else {
+            zhi = true;
+        }
+
+        System.out.println("校验结果:" + zhi);
+
+        Map map = new HashMap();
+        map.put("jiaoyanjieguo", zhi);
+        map.put("jiaoyanxinxi","【领导】人员,不允许选择加班费,请重新选择!");
+
+        return map;
+    }
+
+    /**
+     * 表单打开时加载(员工假期类型)
+     */
+    @Override
+    public String getJiaqileixing(String userid){
+        log.info("获取当前表单传参人员userid:" + userid);
+
+        //智能人事获取员工花名册信息,抓取【人员类型】字段信息
+        String body = null;
+        String label = null;
+        try {
+            DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/smartwork/hrm/employee/v2/list");
+            OapiSmartworkHrmEmployeeV2ListRequest req = new OapiSmartworkHrmEmployeeV2ListRequest();
+            //待查询人员userid
+            req.setUseridList(userid);
+            req.setAgentid(2358039528L);
+            OapiSmartworkHrmEmployeeV2ListResponse rsp = client.execute(req, accessTokenService.getAccessToken());
+            body = rsp.getBody();
+            System.out.println(body);
+
+            JSONObject jsonObject = JSON.parseObject(body);
+            JSONArray result = jsonObject.getJSONArray("result");
+            JSONArray field_data_list = result.getJSONObject(0).getJSONArray("field_data_list");
+
+            for (int i = 0; i < field_data_list.size(); i++) {
+                //字段code
+                String field_code = field_data_list.getJSONObject(i).getString("field_code");
+//                log.info("当前花名册字段field_code:" + field_code);
+                switch (field_code) {
+                    //员工假期类型
+                    case "02b2e018-0ba3-4d2c-ba8a-2d248ce23087":
+                        JSONArray field_value_list = field_data_list.getJSONObject(i).getJSONArray("field_value_list");
+                        //员工假期类型
+                        label = field_value_list.getJSONObject(0).getString("label");
+                        //当前字段下标
+                        int old_index = i;
+                        log.info("当前字段下标:" + old_index);
+                        break;
+                }
+            }
+        } catch (ApiException e) {
+            e.printStackTrace();
+        }
+        log.info("员工假期类型:" + label);
+
+        return label;
+    }
+
+
+    //宜搭接口服务【审批单实例详情】
+    public static com.aliyun.dingtalkworkflow_1_0.Client createClient() throws Exception {
+        com.aliyun.teaopenapi.models.Config config = new com.aliyun.teaopenapi.models.Config();
+        config.protocol = "https";
+        config.regionId = "central";
+        return new com.aliyun.dingtalkworkflow_1_0.Client(config);
+    }
+
+    //TB接口服务【创建自由任务】
+    public static com.aliyun.dingtalkproject_1_0.Client createClient1() throws Exception {
+        com.aliyun.teaopenapi.models.Config config = new com.aliyun.teaopenapi.models.Config();
+        config.protocol = "https";
+        config.regionId = "central";
+        return new com.aliyun.dingtalkproject_1_0.Client(config);
+    }
+
+    /**
+     * 请假审批表单提交后反校验是否提交单据内容是否符合规则,不符合执行撤销审批实例
+     */
+    @Async
+    @Override
+    public R revocationProcessInstances(String processInstances,String ygjqlx,String userid){
+        log.info("获取当前表单传参审批实例id:" + processInstances);
+        log.info("获取当前员工假期类型:" + ygjqlx);
+        log.info("获取当前员工userid:" + userid);
+
+        //查询请假审批单实例详情,获取请假类型
+        JSONObject jsonObject = null;
+        String qjlx = null;
+        try {
+            com.aliyun.dingtalkworkflow_1_0.Client client = createClient();
+            com.aliyun.dingtalkworkflow_1_0.models.GetProcessInstanceHeaders getProcessInstanceHeaders = new com.aliyun.dingtalkworkflow_1_0.models.GetProcessInstanceHeaders();
+            getProcessInstanceHeaders.xAcsDingtalkAccessToken = accessTokenService.getAccessToken();
+            com.aliyun.dingtalkworkflow_1_0.models.GetProcessInstanceRequest getProcessInstanceRequest = new com.aliyun.dingtalkworkflow_1_0.models.GetProcessInstanceRequest()
+                    //审批实例id
+                    .setProcessInstanceId(processInstances);
+
+            GetProcessInstanceResponse processInstanceWithOptions = client.getProcessInstanceWithOptions(getProcessInstanceRequest, getProcessInstanceHeaders, new RuntimeOptions());
+            System.out.println(JSON.toJSONString(processInstanceWithOptions.getBody()));
+            String s = JSON.toJSONString(processInstanceWithOptions.getBody());
+            jsonObject = JSON.parseObject(s);
+            System.out.println("审批详情接口object对象:" + jsonObject);
+        } catch (TeaException err) {
+            if (!com.aliyun.teautil.Common.empty(err.code) && !com.aliyun.teautil.Common.empty(err.message)) {
+                // err 中含有 code 和 message 属性,可帮助开发定位问题
+            }
+        } catch (Exception _err) {
+            TeaException err = new TeaException(_err.getMessage(), _err);
+            if (!com.aliyun.teautil.Common.empty(err.code) && !com.aliyun.teautil.Common.empty(err.message)) {
+                // err 中含有 code 和 message 属性,可帮助开发定位问题
+            }
+        }
+        JSONObject result = jsonObject.getJSONObject("result");
+        JSONArray formComponentValues = result.getJSONArray("formComponentValues");
+        for (int i = 0; i < formComponentValues.size(); i++) {
+            //请假套件类型
+            String componentType = formComponentValues.getJSONObject(i).getString("componentType");
+            switch (componentType) {
+                //请假套件类型
+                case "DDHolidayField":
+                    JSONArray value = formComponentValues.getJSONObject(i).getJSONArray("value");
+                    //请假类型
+                    qjlx = value.get(4).toString();
+                    break;
+            }
+        }
+        log.info("当前请假套件选择的请假类型:" + qjlx);
+
+        //世界标准时间
+        Date Date = new Date();
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTime(Date);
+        calendar.add(Calendar.HOUR_OF_DAY,-8);
+        String format = sdf.format(calendar.getTime());
+        System.out.println("世界标准时间:" + format);
+
+        //判断当前员工类型属于【退休返聘】,则不能提交【年假】的请假类型
+        if (ygjqlx.equals("退休返聘") && qjlx.equals("年假")){
+            //一、发起自由任务的通知
+            try {
+                com.aliyun.dingtalkproject_1_0.Client client = createClient1();
+                com.aliyun.dingtalkproject_1_0.models.CreateOrganizationTaskHeaders createOrganizationTaskHeaders = new com.aliyun.dingtalkproject_1_0.models.CreateOrganizationTaskHeaders();
+                createOrganizationTaskHeaders.xAcsDingtalkAccessToken = accessTokenService.getAccessToken();
+                com.aliyun.dingtalkproject_1_0.models.CreateOrganizationTaskRequest createOrganizationTaskRequest = new com.aliyun.dingtalkproject_1_0.models.CreateOrganizationTaskRequest()
+                        //任务可见性。
+                        //involves:仅参与者可见
+                        //members:所有人可见
+                        .setVisible("involves")
+                        //自由任务优先级
+                        //较低,默认值:10
+                        //普通:0
+                        //紧急:1
+                        //非常紧急:2
+                        .setPriority(0)
+                        //执行者userid
+                        .setExecutorId(userid)
+                        //是否禁止通知。
+                        //true:禁止,不显示通知。
+                        //false:不禁止,显示通知。
+                        .setDisableNotification(false)
+                        .setContent("请假审批撤销通知")
+                        //任务截止时间:【格式:YYYY-MM-DDTHH:mm:ssZ(ISO 8601/RFC 3339)】【世界标准时间】
+                        .setDueDate(format);
+
+                client.createOrganizationTaskWithOptions(userid, createOrganizationTaskRequest, createOrganizationTaskHeaders, new com.aliyun.teautil.models.RuntimeOptions());
+            } catch (TeaException err) {
+                if (!com.aliyun.teautil.Common.empty(err.code) && !com.aliyun.teautil.Common.empty(err.message)) {
+                    // err 中含有 code 和 message 属性,可帮助开发定位问题
+                }
+            } catch (Exception _err) {
+                TeaException err = new TeaException(_err.getMessage(), _err);
+                if (!com.aliyun.teautil.Common.empty(err.code) && !com.aliyun.teautil.Common.empty(err.message)) {
+                    // err 中含有 code 和 message 属性,可帮助开发定位问题
+                }
+            }
+
+            //二、休眠16秒后,进行审批实例撤销
+            try {
+                log.info("休眠中,时长为:16秒...");
+                Thread.sleep(16000);
+            }catch (Exception e){
+                e.printStackTrace();
+            }
+            log.info("开始执行撤销审批实例操作===>");
+            try {
+                com.aliyun.dingtalkworkflow_1_0.Client client = createClient();
+                com.aliyun.dingtalkworkflow_1_0.models.TerminateProcessInstanceHeaders terminateProcessInstanceHeaders = new com.aliyun.dingtalkworkflow_1_0.models.TerminateProcessInstanceHeaders();
+                terminateProcessInstanceHeaders.xAcsDingtalkAccessToken = accessTokenService.getAccessToken();
+                com.aliyun.dingtalkworkflow_1_0.models.TerminateProcessInstanceRequest terminateProcessInstanceRequest = new com.aliyun.dingtalkworkflow_1_0.models.TerminateProcessInstanceRequest()
+                        //是否通过系统操作。
+                        //true:由系统直接终止
+                        //false:由指定的操作者终止(需要传发起人才能撤销)
+                        .setIsSystem(true)
+                        //审批实例id
+                        .setProcessInstanceId(processInstances)
+                        //终止说明
+                        .setRemark("当前人员属于【退休返聘】,不能提交年假,系统自动发起撤销!");
+
+                client.terminateProcessInstanceWithOptions(terminateProcessInstanceRequest, terminateProcessInstanceHeaders, new com.aliyun.teautil.models.RuntimeOptions());
+            } catch (TeaException err) {
+                if (!com.aliyun.teautil.Common.empty(err.code) && !com.aliyun.teautil.Common.empty(err.message)) {
+                    // err 中含有 code 和 message 属性,可帮助开发定位问题
+                }
+            } catch (Exception _err) {
+                TeaException err = new TeaException(_err.getMessage(), _err);
+                if (!com.aliyun.teautil.Common.empty(err.code) && !com.aliyun.teautil.Common.empty(err.message)) {
+                    // err 中含有 code 和 message 属性,可帮助开发定位问题
+                }
+            }
+            return R.error().message("当前人员属于【退休返聘】,不能提交年假,将发起审批撤回!");
+        }else {
+            return R.ok().message("正常通过提交...");
+        }
+
+    }
+}

+ 57 - 0
src/main/resources/application.properties

@@ -0,0 +1,57 @@
+server.port=8082
+server.servlet.context-path=/shennongshi
+
+server.tomcat.uri-encoding=UTF-8
+
+## 服务名
+#spring.application.name=shennongshi-yd
+## 环境设置:dev、test、prod(开发环境、测试环境、生产环境)
+#spring.profiles.active=dev
+
+# mysql数据库连接
+# 本地测试数据库
+#spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
+#spring.datasource.url=jdbc:mysql://localhost:3306/dingtalk?serverTimezone=GMT%2B8
+#spring.datasource.username=root
+#spring.datasource.password=123456
+
+# 云璞【47.98.130.40服务器】测试数据库
+#spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
+#spring.datasource.url=jdbc:mysql://47.97.181.40:3306/dingtalk?serverTimezone=GMT%2B8
+#spring.datasource.username=root
+#spring.datasource.password=cp-root@2022++
+
+#定时同步
+
+#配置日志,当前为默认的控制台输出,也可以用log4j
+#mybatis-plus.configuration.log-impl=org.apache.ibatis.logging.stdout.StdOutImpl
+
+#控制台显示sql
+#spring.jpa.show-sql=true
+#更新或者创建数据表结构
+#spring.jpa.hibernate.ddl-auto=update
+
+#返回json的全局时间格式
+spring.jackson.date-format=yyyy-MM-dd HH:mm:ss
+spring.jackson.time-zone=GMT+8
+#配置mapper xml文件的路径
+#mybatis-plus.mapper-locations=classpath:com/muzhi/lz/mapper/xml/*.xml
+
+#mybatis-plus.config-location=classpath:mybatis/mybatis-config.xml
+
+#禁用缓存
+spring.thymeleaf.cache=false
+#spring.thymeleaf.mode= LEGACYHTML5
+#spring.resources.chain.strategy.content.enabled=true
+#spring.resources.chain.strategy.content.paths=/**
+#spring.thymeleaf.check-template = true
+#spring.thymeleaf.servlet.content-type=text/html
+#spring.thymeleaf.enabled = true
+#spring.thymeleaf.encoding = UTF-8
+#spring.thymeleaf.prefix = classpath:/static/
+#spring.thymeleaf.suffix = .html
+
+#定义日期提交的格式(日期的格式化):SpingMVC将页面提交的值需要转换为指定类型;默认的是yyyy/MM/dd
+#spring.mvc.date-format=yyyy-MM-dd
+
+spring.resources.static-locations=classpath:/META-INF/resources/,classpath:/resources/,classpath:/static/,classpath:/public/,classpath:/templates/

+ 208 - 0
src/test/java/com/muzhi/shennongshi/APITest/Test1.java

@@ -0,0 +1,208 @@
+package com.muzhi.shennongshi.APITest;
+
+import cn.hutool.core.date.DateTime;
+import cn.hutool.core.date.DateUtil;
+import com.muzhi.shennongshi.service.AccessTokenService;
+import lombok.extern.slf4j.Slf4j;
+import org.junit.jupiter.api.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+import java.util.Date;
+
+@SpringBootTest
+@Slf4j
+public class Test1 {
+
+    @Autowired
+    private AccessTokenService accessTokenService;
+
+    @Test
+    public void panduan(){
+        //判断日期是否为周六周日
+        String date = "2022-10-08 00:00:00";
+        DateFormat format = new SimpleDateFormat("yyyy-MM-dd");
+        Date date1 = null;
+        try {
+            date1 = format.parse(date);
+            System.out.println("date1:" + date1);
+        }catch (Exception e){
+            e.printStackTrace();
+        }
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTime(date1);
+
+        if (calendar.get(Calendar.DAY_OF_WEEK)==Calendar.SATURDAY||calendar.get(Calendar.DAY_OF_WEEK)==Calendar.SUNDAY){
+            System.out.println("当前日期为周六周日!");
+        }else {
+            System.out.println("当前日期为工作日");
+        }
+    }
+
+    @Test
+    public void date(){
+        int dkcs = 5;
+        int ccts = 0;
+
+        dkcs = dkcs/2;
+        int dkcsLast = (int)dkcs;
+
+
+        if (dkcs > 0){
+            //实际出差天数
+            ccts = ccts + dkcsLast;
+            System.out.println("实际出差天数:" + ccts);
+        }
+
+        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        long startLong = new Long("1670342400000");
+        //将时间戳转换为时间
+        Date startDate = new Date(startLong);
+        System.out.println("出差开始时间(时间型):" + startDate);
+        //将时间调整为yyyy-MM-dd HH:mm:ss时间样式
+        String startString = simpleDateFormat.format(startDate);
+        System.out.println("出差开始时间(时间样式):" + startString);
+
+        long endLong = new Long("1670428800000");
+        //将时间戳转换为时间
+        Date endDate = new Date(endLong);
+        System.out.println("出差结束时间(时间型):" + endDate);
+        //将时间调整为yyyy-MM-dd HH:mm:ss时间样式
+        String endString = simpleDateFormat.format(endDate);
+        System.out.println("出差结束时间(时间样式):" + endString);
+
+        Calendar calendar1 = Calendar.getInstance();
+        calendar1.setTime(endDate);
+        //后面一天
+        calendar1.add(Calendar.DAY_OF_MONTH,1);
+        calendar1.set(Calendar.HOUR_OF_DAY,0);
+        calendar1.set(Calendar.MINUTE,0);
+        calendar1.set(Calendar.SECOND,0);
+        calendar1.set(Calendar.MILLISECOND,0);
+        String time1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(calendar1.getTime());
+        System.out.println("出差结束时间后面一天零点:" + time1);
+
+        DateTime lastDateTime = DateUtil.parse(time1);
+        System.out.println("出差结束时间后面一天(时间型):" + lastDateTime);
+
+        //获取当天前一天的零点零分零秒
+        Date Date = new Date(System.currentTimeMillis());
+        System.out.println("当前时间:" + Date);
+        String dateNowString = simpleDateFormat.format(Date);
+        System.out.println("当前时间(时间样式):" + dateNowString);
+
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTime(Date);
+        //前一天
+        calendar.add(Calendar.DAY_OF_MONTH,-1);
+        calendar.set(Calendar.HOUR_OF_DAY,0);
+        calendar.set(Calendar.MINUTE,0);
+        calendar.set(Calendar.SECOND,0);
+        calendar.set(Calendar.MILLISECOND,0);
+        String time = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(calendar.getTime());
+        System.out.println("前一天零点:" + time);
+
+        Calendar calendar111 = Calendar.getInstance();
+        calendar111.setTime(Date);
+        //前一个月第一天
+        calendar111.add(Calendar.MONTH,-1);
+        calendar111.set(Calendar.DAY_OF_MONTH,1);
+        calendar111.set(Calendar.HOUR_OF_DAY,0);
+        calendar111.set(Calendar.MINUTE,0);
+        calendar111.set(Calendar.SECOND,0);
+        calendar111.set(Calendar.MILLISECOND,0);
+        String FORMtime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(calendar111.getTime());
+        System.out.println("前一个月第一天零点:" + FORMtime);
+
+        Calendar calendar222 = Calendar.getInstance();
+        int month222 = calendar222.get(Calendar.MONTH);
+        //前一个月最后一天
+        calendar222.set(Calendar.MONTH,month222-1);
+        calendar222.set(Calendar.DAY_OF_MONTH,calendar222.getActualMaximum(Calendar.DAY_OF_MONTH));
+        calendar222.set(Calendar.HOUR_OF_DAY,0);
+        calendar222.set(Calendar.MINUTE,0);
+        calendar222.set(Calendar.SECOND,0);
+        calendar222.set(Calendar.MILLISECOND,0);
+        String TOtime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(calendar222.getTime());
+        System.out.println("前一个月最后一天零点:" + TOtime);
+
+        //世界标准时间
+        Date Date333 = new Date();
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
+        Calendar calendar333 = Calendar.getInstance();
+        calendar333.setTime(Date333);
+        calendar333.add(Calendar.HOUR_OF_DAY,-8);
+        String format = sdf.format(calendar333.getTime());
+        System.out.println("世界标准时间:" + format);
+    }
+
+    //MD5加密
+//    @Test
+//    public void MD5(){
+//
+//        /*明文
+//        * timestamp毫秒级时间戳
+//        * */
+//        //当前时间的时间戳
+//        long timeMillis = System.currentTimeMillis();
+//        String timestamp = String.valueOf(timeMillis);
+//        log.info("当前时间的时间戳(毫秒级):" + timestamp);
+//
+//        /*秘钥
+//         * AppSecret应用秘钥
+//         * */
+//        String AppSecret = "34ea7fa251a2971a7a37ae387398cd67627501f7024c685e";
+//
+//        //加密后的字符串
+//        String encodeStr= DigestUtils.md5Hex(AppSecret + "_" + timestamp);
+//        log.info("MD5加密后的字符串encodeStr:" + encodeStr);
+//
+//        Map map = new HashMap();
+//        map.put("appKey","shbbf1cqrbml3r0od4");
+//        map.put("timestamp",timestamp);
+//        map.put("verifyCode",encodeStr);
+//        String parmsStr = JSON.toJSONString(map);
+//        log.info("封装秘钥参数parmsStr:" + parmsStr);
+//
+//        //售后宝【接口授权】
+//        //授权码
+//        String access_token = null;
+//        //失效时间
+//        String expire_time = null;
+//        try {
+//            OkHttpClient client = new OkHttpClient().newBuilder()
+//                    .build();
+//            MediaType mediaType = MediaType.parse("application/json");
+//            RequestBody body = RequestBody.create(mediaType, parmsStr);
+//            Request request = new Request.Builder()
+//                    .url("https://oapi.linker.ltd/service/auth/get_access_token")
+//                    .method("POST", body)
+//                    .addHeader("Content-Type", "application/json")
+//                    .addHeader("Cookie", "acw_tc=0a45662a16728986832314856e80f39124201b89184960430078b3ebfda740")
+//                    .build();
+//
+//            Response response = client.newCall(request).execute();
+//            String responseBody = response.body().string();
+//            log.info("售后宝【接口授权】返回信息:" + responseBody);
+//            String substring1 = responseBody.substring(1, responseBody.length() - 1);
+//            log.info("去除首尾双引号后的返回信息:" + substring1);
+//            String substring2 = substring1.replaceAll("\\\\", "");
+//            log.info("去除转义字符后的返回信息:" + substring2);
+//
+//            JSONObject jsonObject = JSON.parseObject(substring2);
+//            JSONObject data = jsonObject.getJSONObject("data");
+//            //授权码
+//            access_token = data.getString("access_token");
+//            //失效时间
+//            expire_time = data.getString("expire_time");
+//        }catch (Exception e){
+//            e.printStackTrace();
+//        }
+//        log.info("【授权码】:" + access_token + "【失效时间】:" + expire_time);
+//        //4364bbbc-3480-4cf2-a6c6-2e5a42635892
+//        //1672913268514
+//    }
+}

+ 13 - 0
src/test/java/com/muzhi/shennongshi/TestApplicationTests.java

@@ -0,0 +1,13 @@
+package com.muzhi.shennongshi;
+
+import org.junit.jupiter.api.Test;
+import org.springframework.boot.test.context.SpringBootTest;
+
+@SpringBootTest
+class TestApplicationTests {
+
+    @Test
+    void contextLoads() {
+    }
+
+}