zhangkan преди 3 седмици
ревизия
458c176590

+ 45 - 0
.gitignore

@@ -0,0 +1,45 @@
+# 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/
+
+.DS_Store
+target/
+build/
+.env
+.env.*
+!.env.example
+application-local.properties

+ 367 - 0
pom.xml

@@ -0,0 +1,367 @@
+<?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.yinzhou</groupId>
+    <artifactId>yinzhou</artifactId>
+<!--    <packaging>jar</packaging>-->
+    <version>1.0-SNAPSHOT</version>
+    <name>yinzhou</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>
+
+        <!--Map缓存方法:可设置Map中的Entry在一段时间后自动过期-->
+        <dependency>
+            <groupId>net.jodah</groupId>
+            <artifactId>expiringmap</artifactId>
+            <version>0.5.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/yinzhou/YinZhouApplication.java

@@ -0,0 +1,21 @@
+package com.muzhi.yinzhou;
+
+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.yinzhou.mapper")
+@EnableAsync//开启异步注解
+@SpringBootApplication(exclude= DataSourceAutoConfiguration.class)//启动时不加载数据库(exclude= DataSourceAutoConfiguration.class)
+@EnableScheduling//开启定时任务
+//@ComponentScan(basePackages = {"com.muzhi"})
+public class YinZhouApplication {
+
+    public static void main(String[] args){
+        SpringApplication.run(YinZhouApplication.class, args);
+    }
+
+}

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

@@ -0,0 +1,77 @@
+package com.muzhi.yinzhou.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/yinzhou/common/ResultCode.java

@@ -0,0 +1,12 @@
+package com.muzhi.yinzhou.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/yinzhou/controller/AccessTokenController.java

@@ -0,0 +1,34 @@
+package com.muzhi.yinzhou.controller;
+
+import com.muzhi.yinzhou.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;
+    }
+}

+ 147 - 0
src/main/java/com/muzhi/yinzhou/controller/DingOaController.java

@@ -0,0 +1,147 @@
+package com.muzhi.yinzhou.controller;
+
+import com.alibaba.fastjson.JSONObject;
+import com.muzhi.yinzhou.common.R;
+import com.muzhi.yinzhou.service.DingOaService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.web.bind.annotation.*;
+
+
+@Api(description = "钉钉")
+@RestController
+@RequestMapping("/dingservice")
+@CrossOrigin//解决跨域问题
+public class DingOaController {
+
+    @Autowired
+    private DingOaService dingOaService;
+
+    //获取容器列表(托盘)
+    @ApiOperation(value = "获取容器列表")
+    @GetMapping("getRongqiList")
+//    @Scheduled(cron = "0 10 0 * * ?")//每天00:10触发(也就是凌晨0点10分触发)
+//    @Scheduled(cron = "0 0/10 * * * ?")//每10分钟执行一次
+//    @Scheduled(cron = "0 */10 * * * ?")//每隔10分钟执行一次
+    public JSONObject getRongqiList(){
+
+        JSONObject rongqiList = dingOaService.getRongqiList();
+        return rongqiList;
+    }
+
+    //获取产品列表
+    @ApiOperation(value = "获取产品列表")
+    @GetMapping("getChanpinList")
+    @Scheduled(cron = "0 10 1 * * ?")//每天01:10触发(也就是凌晨1点10分触发)
+//    @Scheduled(cron = "0 0/10 * * * ?")//每10分钟执行一次
+
+//    @Scheduled(cron = "0 */5 * * * ?")//每隔5分钟执行一次
+    public String getChanpinList(){
+
+        String chanpinList = dingOaService.getChanpinList();
+        return chanpinList;
+    }
+
+    //获取库区列表
+    @ApiOperation(value = "获取库区列表")
+    @GetMapping("getKuquList")
+//    @Scheduled(cron = "0 10 0 * * ?")//每天00:10触发(也就是凌晨0点10分触发)
+//    @Scheduled(cron = "0 0/10 * * * ?")//每10分钟执行一次
+//    @Scheduled(cron = "0 */10 * * * ?")//每隔10分钟执行一次
+    public JSONObject getKuquList(){
+
+        JSONObject kuquList = dingOaService.getKuquList();
+
+        return kuquList;
+    }
+
+    //获取仓位列表
+    @ApiOperation(value = "获取仓位列表")
+    @GetMapping("getCangweiList")
+//    @Scheduled(cron = "0 10 0 * * ?")//每天00:10触发(也就是凌晨0点10分触发)
+//    @Scheduled(cron = "0 0/10 * * * ?")//每10分钟执行一次
+//    @Scheduled(cron = "0 */10 * * * ?")//每隔10分钟执行一次
+    public JSONObject getCangweiList(String kuquid){
+
+        JSONObject cangweiList = dingOaService.getCangweiList(kuquid);
+        return cangweiList;
+    }
+
+    //库存查询
+    @ApiOperation(value = "库存查询")
+    @PostMapping("postKucun")
+//    @Scheduled(cron = "0 10 0 * * ?")//每天00:10触发(也就是凌晨0点10分触发)
+//    @Scheduled(cron = "0 0/10 * * * ?")//每10分钟执行一次
+
+//    @Scheduled(cron = "0 */5 * * * ?")//每隔5分钟执行一次
+    public JSONObject postKucun(String kuquid,String name){
+
+        JSONObject kucun = dingOaService.postKucun(kuquid,name);
+        return kucun;
+    }
+
+    //出库订单
+    @ApiOperation(value = "出库订单")
+    @PostMapping("postChuku")
+//    @Scheduled(cron = "0 10 0 * * ?")//每天00:10触发(也就是凌晨0点10分触发)
+//    @Scheduled(cron = "0 0/10 * * * ?")//每10分钟执行一次
+//    @Scheduled(cron = "0 */10 * * * ?")//每隔10分钟执行一次
+    public R postChuku(String shiliID){
+
+        R chuku = dingOaService.postChuku(shiliID);
+        return chuku;
+    }
+
+    //入库订单
+    @ApiOperation(value = "入库订单")
+    @PostMapping("postRuku")
+//    @Scheduled(cron = "0 10 0 * * ?")//每天00:10触发(也就是凌晨0点10分触发)
+//    @Scheduled(cron = "0 0/10 * * * ?")//每10分钟执行一次
+//    @Scheduled(cron = "0 */10 * * * ?")//每隔10分钟执行一次
+    public R postRuku(String shiliID){
+
+        R ruku = dingOaService.postRuku(shiliID);
+        return ruku;
+    }
+
+
+    //新增、补货入库
+    @ApiOperation(value = "入库订单")
+    @PostMapping("addRuku")
+//    @Scheduled(cron = "0 10 0 * * ?")//每天00:10触发(也就是凌晨0点10分触发)
+//    @Scheduled(cron = "0 0/10 * * * ?")//每10分钟执行一次
+//    @Scheduled(cron = "0 */10 * * * ?")//每隔10分钟执行一次
+    public R addRuku(String shiliID){
+
+        R ruku = dingOaService.addRuku(shiliID);
+        return ruku;
+    }
+
+
+
+    //定时同步库存至宜搭
+    @ApiOperation(value = "定时同步库存至宜搭")
+    @PostMapping("tongbuKucun")
+    @Scheduled(cron = "0 10 0 * * ?")//每天00:10触发(也就是凌晨0点10分触发)
+//    @Scheduled(cron = "0 0/10 * * * ?")//每10分钟执行一次
+//    @Scheduled(cron = "0 */10 * * * ?")//每隔10分钟执行一次
+    public String tongbuKucun(){
+
+        String s = dingOaService.tongbuKucun();
+        return s;
+    }
+
+    //定时同步库区(仓库)至宜搭
+    @ApiOperation(value = "定时同步库区(仓库)至宜搭")
+    @PostMapping("tongbuKuqu")
+    @Scheduled(cron = "0 10 2 * * ?")//每天02:10触发(也就是凌晨2点10分触发)
+//    @Scheduled(cron = "0 0/10 * * * ?")//每10分钟执行一次
+//    @Scheduled(cron = "0 */10 * * * ?")//每隔10分钟执行一次
+    public String tongbuKuqu(){
+
+        String s = dingOaService.tongbuKuqu();
+        return s;
+    }
+}

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

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

+ 42 - 0
src/main/java/com/muzhi/yinzhou/service/DingOaService.java

@@ -0,0 +1,42 @@
+package com.muzhi.yinzhou.service;
+
+import com.alibaba.fastjson.JSONObject;
+import com.muzhi.yinzhou.common.R;
+
+/**
+ * @Author ZhangKan
+ * @Data 15:34
+ */
+public interface DingOaService {
+
+    //获取容器列表(托盘)
+    JSONObject getRongqiList();
+
+    //定时同步获取产品列表
+    String getChanpinList();
+
+    //获取库区列表
+    JSONObject getKuquList();
+
+    //获取仓位列表
+    JSONObject getCangweiList(String kuquid);
+
+    //库存查询
+    JSONObject postKucun(String kuquid,String name);
+
+    //出库订单
+    R postChuku(String shiliID);
+
+
+    //入库订单
+    R postRuku(String shiliID);
+
+    //定时同步库存信息至宜搭
+    String tongbuKucun();
+
+    //定时同步库区(仓库)至宜搭
+    String tongbuKuqu();
+
+    //新增、补货入库
+    R addRuku(String shiliID);
+}

+ 45 - 0
src/main/java/com/muzhi/yinzhou/service/impl/AccessTokenServiceImpl.java

@@ -0,0 +1,45 @@
+package com.muzhi.yinzhou.service.impl;
+
+import com.dingtalk.api.DefaultDingTalkClient;
+import com.dingtalk.api.request.OapiGettokenRequest;
+import com.dingtalk.api.response.OapiGettokenResponse;
+import com.muzhi.yinzhou.service.AccessTokenService;
+import com.taobao.api.ApiException;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Service;
+
+
+/**
+ * @Author ZhangKan
+ * @Data 15:39
+ */
+
+@Service
+public class AccessTokenServiceImpl implements AccessTokenService {
+
+    @Value("${dingtalk.app-key}")
+    private String appKey;
+
+    @Value("${dingtalk.app-secret}")
+    private String appSecret;
+
+    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();
+        } catch (ApiException e) {
+            e.printStackTrace();
+        }
+        return accessToken;
+    }
+}

Файловите разлики са ограничени, защото са твърде много
+ 1406 - 0
src/main/java/com/muzhi/yinzhou/service/impl/DingOaServiceImpl.java


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

@@ -0,0 +1,61 @@
+server.port=8100
+server.servlet.context-path=/yinzhou
+
+server.tomcat.uri-encoding=UTF-8
+
+dingtalk.app-key=${DINGTALK_APP_KEY:}
+dingtalk.app-secret=${DINGTALK_APP_SECRET:}
+dingtalk.system-token=${DINGTALK_SYSTEM_TOKEN:}
+
+## 服务名
+#spring.application.name=yinzhou-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=${DB_PASSWORD}
+
+# 云璞【47.98.130.40服务器】测试数据库
+#spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
+#spring.datasource.url=${DB_URL}
+#spring.datasource.username=root
+#spring.datasource.password=${DB_PASSWORD}
+
+#定时同步
+
+#配置日志,当前为默认的控制台输出,也可以用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/

+ 411 - 0
src/test/java/com/muzhi/yinzhou/APITest/Test1.java

@@ -0,0 +1,411 @@
+package com.muzhi.yinzhou.APITest;
+
+import cn.hutool.core.date.DateTime;
+import cn.hutool.core.date.DateUtil;
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.muzhi.yinzhou.service.AccessTokenService;
+import lombok.extern.slf4j.Slf4j;
+import okhttp3.*;
+import org.apache.commons.codec.digest.DigestUtils;
+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;
+import java.util.HashMap;
+import java.util.Map;
+
+@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);
+    }
+
+    //MD5加密
+    @Test
+    public void MD5(){
+
+        /*明文
+        * timestamp毫秒级时间戳
+        * */
+        //当前时间的时间戳
+        long timeMillis = System.currentTimeMillis();
+        String timestamp = String.valueOf(timeMillis);
+        log.info("当前时间的时间戳(毫秒级):" + timestamp);
+
+        /*秘钥
+         * AppSecret应用秘钥
+         * */
+        String AppSecret = System.getenv("SHB_APP_SECRET");
+
+        //加密后的字符串
+        String encodeStr= DigestUtils.md5Hex(AppSecret + "_" + timestamp);
+
+        Map map = new HashMap();
+        map.put("appKey", System.getenv("SHB_APP_KEY"));
+        map.put("timestamp",timestamp);
+        map.put("verifyCode",encodeStr);
+        String parmsStr = JSON.toJSONString(map);
+
+        //售后宝【接口授权】
+        //授权码
+        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.shb.ltd/service/auth/get_access_token")
+                    .method("POST", body)
+                    .addHeader("Content-Type", "application/json")
+                    .build();
+
+            Response response = client.newCall(request).execute();
+            String responseBody = response.body().string();
+            String substring1 = responseBody.substring(1, responseBody.length() - 1);
+            String substring2 = substring1.replaceAll("\\\\", "");
+
+            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();
+        }
+
+        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        long endLong = new Long(expire_time);
+        //将时间戳转换为时间
+        Date endDate = new Date(endLong);
+        System.out.println("授权码失效时间(时间型):" + endDate);
+        //将时间调整为yyyy-MM-dd HH:mm:ss时间样式
+        String endString = simpleDateFormat.format(endDate);
+        System.out.println("授权码失效时间(时间样式):" + endString);
+        log.info("授权码失效时间:" + endString);
+    }
+
+    //【客户列表】
+    @Test
+    public void getKehuList(){
+        OkHttpClient client = new OkHttpClient().newBuilder()
+                .build();
+        MediaType mediaType = MediaType.parse("application/json");
+        RequestBody body = RequestBody.create(mediaType, "{\r\n    \"pageSize\":50,\r\n    \"pageNum\":1\r\n}");
+        Request request = new Request.Builder()
+                .url("https://oapi.shb.ltd/service/customer/get_customers?accessToken=" + System.getenv("SHB_ACCESS_TOKEN"))
+                .method("POST", body)
+                .addHeader("Content-Type", "application/json")
+                .build();
+
+        try {
+            Response response = client.newCall(request).execute();
+        }catch (Exception e){
+            e.printStackTrace();
+        }
+    }
+
+    //【工单类型】
+    @Test
+    public void getGongdanType(){
+        OkHttpClient client = new OkHttpClient().newBuilder()
+                .build();
+        Request request = new Request.Builder()
+                .url("https://oapi.shb.ltd/service/task/get_task_types?accessToken=" + System.getenv("SHB_ACCESS_TOKEN"))
+                .method("GET", null)
+                .build();
+
+        try {
+            Response response = client.newCall(request).execute();
+        }catch (Exception e){
+            e.printStackTrace();
+        }
+    }
+
+    //【创建工单】
+    @Test
+    public void addGongdan(){
+
+        /*
+        【创建工单json参数】
+        {
+            "cusNo":"CUSEH00762",
+            "cusName":"上海市松江区城市管理行政执法局执法大队岳阳街道中队",
+            "address":"西林北路367号",
+            "lmName":"陆老师",
+            "lmPhone":"13371958895",
+            "templateId":"279bb347-913e-4627-bffc-605317774885",
+            "templateName":"安装工单",
+            "planTime":"2023-03-19"
+        }
+         */
+
+        OkHttpClient client = new OkHttpClient().newBuilder()
+                .build();
+        MediaType mediaType = MediaType.parse("application/json");
+        RequestBody body = RequestBody.create(mediaType, "{\r\n    \"cusNo\":\"CUSEH00762\",\r\n    \"cusName\":\"上海市松江区城市管理行政执法局执法大队岳阳街道中队\",\r\n    \"address\":\"西林北路367号\",\r\n    \"lmName\":\"陆老师\",\r\n    \"lmPhone\":\"13371958895\",\r\n    \"templateId\":\"279bb347-913e-4627-bffc-605317774885\",\r\n    \"templateName\":\"安装工单\",\r\n    \"planTime\":\"2023-03-19\"\r\n}");
+        Request request = new Request.Builder()
+                .url("https://oapi.shb.ltd/service/task/create_task_v2?accessToken=" + System.getenv("SHB_ACCESS_TOKEN"))
+                .method("POST", body)
+                .addHeader("Content-Type", "application/json")
+                .build();
+
+        try {
+            Response response = client.newCall(request).execute();
+        }catch (Exception e){
+            e.printStackTrace();
+        }
+    }
+
+//    public static String IP = "http://124.221.15.189:8002";
+    //调整第四版
+    public static String IP = "http://101.43.89.2:8002";
+
+    @Test
+    public void test(){
+        OkHttpClient client = new OkHttpClient().newBuilder()
+                .build();
+        Request request = new Request.Builder()
+                .url(IP + "/GetKuquList")
+                .method("GET", null)
+                .build();
+
+        String s = null;
+        String s1 = null;
+        String s2 = null;
+        try {
+            Response response = client.newCall(request).execute();
+            String result = response.body().string();
+            //获取接口返回的原始内容
+            s = JSON.toJSONString(result);
+            //去除返回字符串中的\转义字符
+            s1 = s.trim().replace("\\", "");
+            //去除返回字符串的首尾""双引号,去除两次
+            s2 = s1.replaceAll("^\"|\"$", "")
+                    .replaceAll("^\"|\"$", "");
+        }catch (Exception e){
+            e.printStackTrace();
+        }
+        System.out.println("接口返回【库区列表】:" + s2);
+    }
+
+    //查询商品库存
+    @Test
+    public void getChanpinList(){
+
+        //商品编码
+        String shangpinbianma = "202300026";
+        //商品名称
+        String shangpinmingcheng = "锉刀";
+        //仓库id
+        String cangkuid = "1115";
+
+        /*先查询当前商品的库存实际数量*/
+        log.info("开始执行库存查询接口,获取当前实际库存...");
+        OkHttpClient client = new OkHttpClient().newBuilder()
+                .build();
+        MediaType mediaType = MediaType.parse("text/plain");
+        RequestBody body = RequestBody.create(mediaType, "");
+        Request request = new Request.Builder()
+                .url(IP + "/PostInventoryInquiry?commodity=" + shangpinbianma + "&commodityname=" + shangpinmingcheng
+                        + "&kuqu_id=" + cangkuid)
+                .method("POST", body)
+                .build();
+
+        String s = null;
+        String s1 = null;
+        String s2 = null;
+        try {
+            Response response = client.newCall(request).execute();
+            String result = response.body().string();
+            //获取接口返回的原始内容
+            s = JSON.toJSONString(result);
+            //去除返回字符串中的\转义字符
+            s1 = s.trim().replace("\\", "");
+            //去除返回字符串的首尾""双引号,去除两次
+            s2 = s1.replaceAll("^\"|\"$", "")
+                    .replaceAll("^\"|\"$", "");
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        JSONObject jsonObjectKUCUN = JSON.parseObject(s2);
+        JSONObject list = jsonObjectKUCUN.getJSONArray("list").getJSONObject(0);
+        System.out.println("库存查询接口返回list:" + list);
+        //商品编码
+        String commodity = list.getString("commodity");
+        System.out.println("【库存】商品编码:" + commodity);
+        //商品名称
+        String name = list.getString("name");
+        System.out.println("【库存】商品名称:" + name);
+        //仓位
+        String position = list.getString("position");
+        System.out.println("【库存】仓位:" + position);
+        //容器(托盘)
+        String tuopan_code = list.getString("tuopan_code");
+        System.out.println("【库存】容器(托盘):" + tuopan_code);
+        //库存数量
+        int kucun_num = list.getInteger("kucun_num");
+        System.out.println("【库存】库存数量:" + kucun_num);
+        /*先查询当前商品的库存实际数量*/
+    }
+
+    @Test
+    public void getAll(){
+        String kuquid = "1115";
+
+        OkHttpClient client = new OkHttpClient().newBuilder()
+                .build();
+        MediaType mediaType = MediaType.parse("text/plain");
+        RequestBody body = RequestBody.create(mediaType, "");
+        Request request = new Request.Builder()
+                .url(IP + "/PostInventoryInquiry?commodity=&commodityname=&kuqu_id=" + kuquid)
+                .method("POST", body)
+                .build();
+
+        String s = null;
+        String s1 = null;
+        String s2 = null;
+
+        JSONArray list = null;
+        try {
+            Response response = client.newCall(request).execute();
+            String result = response.body().string();
+            //获取接口返回的原始内容
+            s = JSON.toJSONString(result);
+            //去除返回字符串中的\转义字符
+            s1 = s.trim().replace("\\", "");
+            //去除返回字符串的首尾""双引号,去除两次
+            s2 = s1.replaceAll("^\"|\"$", "")
+                    .replaceAll("^\"|\"$", "");
+
+            //System.out.println("接口返回【库存列表】:" + s2);
+            JSONObject jsonObject = JSON.parseObject(s2);
+            //System.out.println("接口返回【库存列表】jsonObject:" + jsonObject);
+
+            list = jsonObject.getJSONArray("list");
+            System.out.println("当前库区的库存信息:" + list);
+        }catch (Exception e){
+            e.printStackTrace();
+        }
+    }
+}

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

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