15810770710@163.com 4 gadi atpakaļ
vecāks
revīzija
1221b0e94a
32 mainītis faili ar 2554 papildinājumiem un 0 dzēšanām
  1. 82 0
      deploy/cloud-yysj-product-info.yaml
  2. 30 0
      deploy/config-map.yaml
  3. 164 0
      pom.xml
  4. 21 0
      src/main/java/info/aspirecn/cloud/yysj/Application.java
  5. 48 0
      src/main/java/info/aspirecn/cloud/yysj/config/SwaggerConfig.java
  6. 137 0
      src/main/java/info/aspirecn/cloud/yysj/controller/ProductController.java
  7. 60 0
      src/main/java/info/aspirecn/cloud/yysj/entity/EditRoutePriceInfoReq.java
  8. 26 0
      src/main/java/info/aspirecn/cloud/yysj/entity/Produce.java
  9. 17 0
      src/main/java/info/aspirecn/cloud/yysj/entity/ProduceList.java
  10. 23 0
      src/main/java/info/aspirecn/cloud/yysj/entity/ProduceRelevance.java
  11. 20 0
      src/main/java/info/aspirecn/cloud/yysj/entity/ProductDetailRes.java
  12. 30 0
      src/main/java/info/aspirecn/cloud/yysj/entity/ProductManagerListReq.java
  13. 58 0
      src/main/java/info/aspirecn/cloud/yysj/entity/ProductManagerListRes.java
  14. 18 0
      src/main/java/info/aspirecn/cloud/yysj/entity/ResponseInfo.java
  15. 21 0
      src/main/java/info/aspirecn/cloud/yysj/entity/SjjhProduce.java
  16. 19 0
      src/main/java/info/aspirecn/cloud/yysj/entity/SwitchCondition.java
  17. 24 0
      src/main/java/info/aspirecn/cloud/yysj/entity/User.java
  18. 12 0
      src/main/java/info/aspirecn/cloud/yysj/entity/UserChannel.java
  19. 22 0
      src/main/java/info/aspirecn/cloud/yysj/entity/UserProduce.java
  20. 21 0
      src/main/java/info/aspirecn/cloud/yysj/entity/UserProduct.java
  21. 12 0
      src/main/java/info/aspirecn/cloud/yysj/entity/UserProductPo.java
  22. 32 0
      src/main/java/info/aspirecn/cloud/yysj/entity/response/ProductResponse.java
  23. 41 0
      src/main/java/info/aspirecn/cloud/yysj/mapper/ProductMapper.java
  24. 15 0
      src/main/java/info/aspirecn/cloud/yysj/mapper/UserMapper.java
  25. 26 0
      src/main/java/info/aspirecn/cloud/yysj/service/ProductService.java
  26. 40 0
      src/main/java/info/aspirecn/cloud/yysj/service/SjjhProductService.java
  27. 318 0
      src/main/java/info/aspirecn/cloud/yysj/service/impl/ProductServiceImpl.java
  28. 38 0
      src/main/java/info/aspirecn/cloud/yysj/util/RedisConfig.java
  29. 889 0
      src/main/java/info/aspirecn/cloud/yysj/util/RedisUtil.java
  30. 43 0
      src/main/resources/bootstrap.yml
  31. 227 0
      src/main/resources/mapping/ProductMapper.xml
  32. 20 0
      src/main/resources/mapping/UserMapper.xml

+ 82 - 0
deploy/cloud-yysj-product-info.yaml

@@ -0,0 +1,82 @@
+apiVersion: v1
+kind: Service
+metadata:
+  name: cloud-yysj-product-info
+  labels:
+    app: cloud-yysj-product-info
+    svcEndpoints: actuator
+spec:
+  type: NodePort
+  ports:
+    - name: server
+      port: 8080
+      targetPort: 8080
+    - name: management
+      port: 8081
+      targetPort: 8081
+  selector:
+    app: cloud-yysj-product-info
+---
+apiVersion: apps/v1
+kind: Deployment
+metadata:
+  name: cloud-yysj-product-info
+  labels:
+    app: cloud-yysj-product-info
+spec:
+  replicas: 1
+  selector:
+    matchLabels:
+      app: cloud-yysj-product-info
+  template:
+    metadata:
+      name: cloud-yysj-product-info
+      labels:
+        app: cloud-yysj-product-info
+    spec:
+      restartPolicy: Always
+      containers:
+      - name: service-provider
+        image: hub.i139.cn/cloud-yysj/cloud-yysj-product-info:1.0.0
+        imagePullPolicy: IfNotPresent
+        ports:
+        - name: server
+          containerPort: 8080
+        - name: management
+          containerPort: 8081
+        env:
+        - name: KUBERNETES_NAMESPACE
+          valueFrom:
+            fieldRef:
+              fieldPath: metadata.namespace
+        - name: POD_NAME
+          valueFrom:
+            fieldRef:
+              fieldPath: metadata.name
+        - name: JAVA_OPTS
+          value: ""
+        - name: APP_OPTS
+          value: ""
+        resources:
+          limits:
+            memory: 1000Mi
+            cpu: 2000m
+          requests:
+            memory: 256Mi
+            cpu: 1000m
+        readinessProbe:
+          initialDelaySeconds: 20
+          periodSeconds: 5
+          timeoutSeconds: 10
+          failureThreshold: 5
+          httpGet:
+            path: /actuator/health
+            port: 8081
+        livenessProbe:
+          initialDelaySeconds: 60
+          periodSeconds: 5
+          timeoutSeconds: 5
+          failureThreshold: 3
+          httpGet:
+            path: /actuator/health
+            port: 8081

+ 30 - 0
deploy/config-map.yaml

@@ -0,0 +1,30 @@
+kind: ConfigMap
+apiVersion: v1
+metadata:
+  name: cloud-yysj-product-info
+data:
+  application.yaml: |-
+    spring:
+      datasource:
+        username: root
+        password: 123456
+        url: jdbc:mysql://10.8.17.119:32196/cloud-yysj?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai
+        driver-class-name: com.mysql.cj.jdbc.Driver
+      redis:
+        host: 10.8.17.119
+        port: 32042
+        database: 0
+        timeout: 1000
+        password:
+        lettuce:
+          pool:
+            max-active: 100
+            max-wait: -1
+            min-idle: 0
+            max-idle: 20
+    product:
+      permitProductId1: 30000218
+      permitProductId2: 30000222
+    mybatis:
+      mapper-locations: classpath:mapping/*Mapper.xml
+              

+ 164 - 0
pom.xml

@@ -0,0 +1,164 @@
+<?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 https://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.2.2.RELEASE</version>
+        <relativePath/> <!-- lookup parent from repository -->
+    </parent>
+    <groupId>cloud.yysj.product.info</groupId>
+    <artifactId>cloud-yysj-product-info</artifactId>
+    <version>1.0.6</version>
+    <name>cloud-yysj-product-info</name>
+    <description>cloud yysj platform driver product information</description>
+
+    <properties>
+        <java.version>1.8</java.version>
+         <spring-cloud.version>Hoxton.RELEASE</spring-cloud.version>
+    </properties>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-web</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.cloud</groupId>
+            <artifactId>spring-cloud-starter-openfeign</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>org.projectlombok</groupId>
+            <artifactId>lombok</artifactId>
+            <optional>true</optional>
+        </dependency>
+        <!-- 配置jdbc依赖 -->
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-data-jdbc</artifactId>
+        </dependency>
+        <dependency>
+		    <groupId>org.springframework.data</groupId>
+		    <artifactId>spring-data-commons</artifactId>
+		     <version>2.2.2.RELEASE</version>
+		</dependency>
+        <!-- mysql依赖 -->
+        <dependency>
+            <groupId>mysql</groupId>
+            <artifactId>mysql-connector-java</artifactId>
+        </dependency>
+        <!-- mybatis依赖 -->
+          <dependency>
+            <groupId>org.mybatis.spring.boot</groupId>
+            <artifactId>mybatis-spring-boot-starter</artifactId>
+            <version>1.3.2</version>
+        </dependency>
+        <!--		swagger2-->
+       <dependency>
+		    <groupId>org.projectlombok</groupId>
+		    <artifactId>lombok</artifactId>
+		    <optional>true</optional>
+		</dependency>
+		<!--swagger-->
+		<dependency>
+		    <groupId>io.springfox</groupId>
+		    <artifactId>springfox-swagger2</artifactId>
+		    <version>2.9.2</version>
+		</dependency>
+		<dependency>
+		    <groupId>io.springfox</groupId>
+		    <artifactId>springfox-swagger-ui</artifactId>
+		    <version>2.9.2</version>
+		</dependency>
+		<dependency>
+		    <groupId>com.github.xiaoymin</groupId>
+		    <artifactId>knife4j-spring-boot-starter</artifactId>
+		    <version>2.0.1</version>
+		</dependency>
+      <dependency>
+            <groupId>org.apache.commons</groupId>
+            <artifactId>commons-lang3</artifactId>
+        </dependency>
+         <!-- redis -->
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-data-redis</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.commons</groupId>
+            <artifactId>commons-pool2</artifactId>
+        </dependency>
+        <dependency>
+		  <groupId>org.springframework.cloud</groupId>
+		  <artifactId>spring-cloud-starter-kubernetes-config</artifactId>
+		</dependency>
+		<!--actuator-->
+		<dependency>
+		    <groupId>org.springframework.boot</groupId>
+		    <artifactId>spring-boot-starter-actuator</artifactId>
+		</dependency>
+    </dependencies>
+    <dependencyManagement>
+        <dependencies>
+            <dependency>
+                <groupId>org.springframework.cloud</groupId>
+                <artifactId>spring-cloud-dependencies</artifactId>
+                <version>${spring-cloud.version}</version>
+                <type>pom</type>
+                <scope>import</scope>
+            </dependency>
+        </dependencies>
+    </dependencyManagement>
+
+    <build>
+	    <plugins>
+	        <!--设置应用 Main 参数启动依赖查找的地址指向外部 lib 文件夹-->
+	        <plugin>
+	            <groupId>org.apache.maven.plugins</groupId>
+	            <artifactId>maven-jar-plugin</artifactId>
+	            <configuration>
+	                <archive>
+	                    <manifest>
+	                        <addClasspath>true</addClasspath>
+	                        <classpathPrefix>lib/</classpathPrefix>
+	                    </manifest>
+	                </archive>
+	            </configuration>
+	        </plugin>
+	        <!--设置 SpringBoot 打包插件不包含任何 Jar 依赖包-->
+	        <plugin>
+	            <groupId>org.springframework.boot</groupId>
+	            <artifactId>spring-boot-maven-plugin</artifactId>
+	            <configuration>
+	                <includes>
+	                    <include>
+	                        <groupId>nothing</groupId>
+	                        <artifactId>nothing</artifactId>
+	                    </include>
+	                </includes>
+	            </configuration>
+	        </plugin>
+	        <!--设置将 lib 拷贝到应用 Jar 外面-->
+	        <plugin>
+	            <groupId>org.apache.maven.plugins</groupId>
+	            <artifactId>maven-dependency-plugin</artifactId>
+	            <executions>
+	                <execution>
+	                    <id>copy-dependencies</id>
+	                    <phase>prepare-package</phase>
+	                    <goals>
+	                        <goal>copy-dependencies</goal>
+	                    </goals>
+	                    <configuration>
+	                        <outputDirectory>${project.build.directory}/lib</outputDirectory>
+	                    </configuration>
+	                </execution>
+	            </executions>
+	        </plugin>
+	    </plugins>
+	</build>
+
+</project>

+ 21 - 0
src/main/java/info/aspirecn/cloud/yysj/Application.java

@@ -0,0 +1,21 @@
+package info.aspirecn.cloud.yysj;
+
+import org.mybatis.spring.annotation.MapperScan;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.cloud.openfeign.EnableFeignClients;
+
+import springfox.documentation.swagger2.annotations.EnableSwagger2;
+
+@EnableSwagger2
+@SpringBootApplication
+@EnableFeignClients
+@MapperScan("info.aspirecn.cloud.yysj.mapper")
+public class Application {
+
+    public static void main(String[] args) {
+    	
+        SpringApplication.run(Application.class, args);
+    }
+
+}

+ 48 - 0
src/main/java/info/aspirecn/cloud/yysj/config/SwaggerConfig.java

@@ -0,0 +1,48 @@
+package info.aspirecn.cloud.yysj.config;
+
+import com.google.common.base.Predicates;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import springfox.documentation.builders.ApiInfoBuilder;
+import springfox.documentation.builders.PathSelectors;
+import springfox.documentation.builders.RequestHandlerSelectors;
+import springfox.documentation.service.ApiInfo;
+import springfox.documentation.spi.DocumentationType;
+import springfox.documentation.spring.web.plugins.Docket;
+
+/**
+ * Swagger 配置
+ *
+ * @author dingliqiang
+ */
+@Configuration
+public class SwaggerConfig {
+    @Bean
+    public Docket createRestApi() {
+        return new Docket(DocumentationType.SWAGGER_2)
+                // 项目组名
+                .apiInfo(apiInfo())
+                // 选择那些路径和api会生成document
+                .select()
+                // 对所有api进行监控
+                .apis(RequestHandlerSelectors.any())
+                // 对所有路径进行监控
+                .paths(PathSelectors.any())
+                //错误路径不监控
+                .paths(Predicates.not(PathSelectors.regex("/error.*")))
+                //actuator路径跳过
+                .paths(Predicates.not(PathSelectors.regex("/actuator.*")))
+                .build();
+    }
+
+    private ApiInfo apiInfo() {
+        return new ApiInfoBuilder()
+                // 文档标题
+                .title("swagger-example-service")
+                // 文档描述
+                .description("This is a swagger project.")
+                // 文档版本
+                .version("1.0.0")
+                .build();
+    }
+}

+ 137 - 0
src/main/java/info/aspirecn/cloud/yysj/controller/ProductController.java

@@ -0,0 +1,137 @@
+package info.aspirecn.cloud.yysj.controller;
+
+import java.util.List;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletResponse;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestHeader;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
+import info.aspirecn.cloud.yysj.entity.Produce;
+import info.aspirecn.cloud.yysj.entity.ProduceList;
+import info.aspirecn.cloud.yysj.entity.ResponseInfo;
+import info.aspirecn.cloud.yysj.entity.UserProduce;
+import info.aspirecn.cloud.yysj.service.ProductService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiResponse;
+import io.swagger.annotations.ApiResponses;
+
+/**
+ * 产品列表、产品订购、订购产品数量等信息接口
+ *
+ * @author baizehui
+ */
+@Api(tags = "产品配置相关服务接口")
+@ApiResponses({
+        @ApiResponse(code = 200, message = "成功处理请求"),
+        @ApiResponse(code = 400, message = "参数错误"),
+        @ApiResponse(code = 401, message = "没有权限访问该服务"),
+        @ApiResponse(code = 403, message = "权限不足无法访问该服务"),
+        @ApiResponse(code = 404, message = "未发现该微服务"),
+        @ApiResponse(code = 500, message = "服务器内部错误")
+})
+@RestController
+public class ProductController {
+	
+	@Autowired
+    private ProductService productService;
+
+
+//    @ApiOperation(value = "新建产品接口", notes = "新建产品接口。")
+//    @PostMapping(value = "/saveProduce")
+//    private ResponseInfo saveProduce(@RequestBody Produce produce){
+//    	if (produce.getProduceName()== null&&"".equals(produce.getProduceName())) {
+//    		return new ResponseInfo().setMessage("产品名称不能为空");
+//		}
+//    	if (produce.getSjjhId()== null&&produce.getSjjhId()== 0) {
+//    		return new ResponseInfo().setMessage("数据交互产品id不能为空");
+//		}
+//    	if (produce.getType()== null&&produce.getType()== 0) {
+//    		return new ResponseInfo().setMessage("产品类型不能为空");
+//		}
+//    	productService.saveProduce(produce);
+//		return new ResponseInfo().setData("新建产品成功");
+//    }
+	
+    @ApiOperation(value = "查询产品列表接口", notes = "获取产品列表接口。")
+    @PostMapping("/productList")
+    private ResponseInfo productList(HttpServletResponse response,@RequestHeader(required = false) String userId,@RequestBody ProduceList produceList){
+    	  Map<String, Object>	map= productService.getProductList(userId,produceList.getProductName(),produceList.getPageNum(),produceList.getPageSize());
+    	  Integer total = (Integer)map.get("total");
+    	  response.addHeader("pageNum", Integer.toString(produceList.getPageNum()));
+          response.addHeader("pageSize", Integer.toString(produceList.getPageSize()));
+          response.addHeader("pageTotal",   Integer.toString(total%produceList.getPageSize() > 0 ? total/produceList.getPageSize()+1 : total/produceList.getPageSize()));
+          response.addHeader("total",Integer.toString(total));
+    	return new ResponseInfo().setData(map.get("dataList"));
+    }
+    
+    @ApiOperation(value = "订购产品接口", notes = "订购产品接口。")
+    @PostMapping(value = "/saveUserProduce")
+    private ResponseInfo saveUserProduce(@RequestHeader(required = false) String userId,@RequestBody UserProduce userProduce){
+    	if (userProduce.getProduceId()== null&&userProduce.getProduceId()== 0) {
+    		 return new ResponseInfo().setMessage("产品id不能为空");
+		}
+    	if (userProduce.getProduceName()== null&&"".equals(userProduce.getProduceName())) {
+    		 return new ResponseInfo().setMessage("产品名称不能为空");
+		}
+    	List<UserProduce> userProduceList=productService.queryUserProduce(userId,userProduce.getProduceId());
+    	if (userProduceList.size()>=1) {
+    		 return new ResponseInfo().setMessage("产品已订购");
+		}
+    	Integer saveUserProduce=productService.saveUserProduce(userId,userProduce);
+    	if (saveUserProduce==1) {
+    		return new ResponseInfo().setData("订购成功");
+		}
+		return new ResponseInfo().setData("订购失败");
+    }
+    
+    @ApiOperation(value = "取消订购产品接口", notes = "取消订购产品接口。")
+    @DeleteMapping(value = "/deleteUserProduce")
+    private ResponseInfo deleteUserProduce(@RequestHeader(required = false) String userId,
+    		@RequestParam(required = true) Integer produceId,
+    		@RequestParam(required = true) String produceName){
+    	if (userId== null&&"".equals(userId)) {
+    		 return new ResponseInfo().setMessage("userId不能为空");
+		}
+    	if (produceId== null) {
+    		 return new ResponseInfo().setMessage("产品id不能为空");
+		}
+    	if (produceName== null&&"".equals(produceName)) {
+    		return new ResponseInfo().setMessage("产品名称不能为空");
+		}
+    	Integer deleteUserProduce=productService.deleteUserProduce(userId,produceId,produceName);
+    	if (deleteUserProduce==1) {
+    		return new ResponseInfo().setData("取消订购成功");
+		}
+		return new ResponseInfo().setData("取消订购失败");
+    }
+    
+    
+    @ApiOperation(value = "获取订购产品数量接口", notes = "获取订购产品数量接口。")
+    @GetMapping("/getOrderProductCount")
+    private ResponseInfo getOrderProductCount(@RequestHeader(required = false) String userId){
+	    	if (userId== null&&"".equals(userId)) {
+	   		 	return new ResponseInfo().setMessage("参数不能为空");
+			}
+	    	Map<String, Integer> orderProductCount=productService.getOrderProductCount(userId);
+    	  return new ResponseInfo().setData(orderProductCount);
+    }
+    
+     
+    @ApiOperation(value = "获取产品名称列表接口", notes = "获取产品列表接口。")
+    @GetMapping("/getProductNameList")
+    private ResponseInfo getProductNameList(){
+	    	List<Produce> list=productService.getProductNameList();
+    	  return new ResponseInfo().setData(list);
+    }
+    
+    
+}

+ 60 - 0
src/main/java/info/aspirecn/cloud/yysj/entity/EditRoutePriceInfoReq.java

@@ -0,0 +1,60 @@
+package info.aspirecn.cloud.yysj.entity;
+
+
+import java.util.List;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+/**
+ * @Author: bzh
+ * @Description: 编辑某用户的某产品的路由信息,此处编辑同步产品的信息和异步产品的价格信息,异步产品的回调地址需在用户库修改
+ */
+@ApiModel(description = "编辑路由价格信息请求类")
+@Data
+public class EditRoutePriceInfoReq {
+    @ApiModelProperty("用户nid")
+    private Integer userNid;
+    @ApiModelProperty("产品的sid")
+    private String productSid;
+    @ApiModelProperty("路由价格")
+    private Integer price;
+
+    @ApiModelProperty("第二路由价格")
+    private Integer secondPrice;
+
+    @ApiModelProperty("启用")
+    private Integer secondPriceEable;
+    @ApiModelProperty("缓存标志")
+    private Integer cacheSign;
+    @ApiModelProperty("回调地址")
+    private String callbackUrl;
+    @ApiModelProperty("路由通道集合")
+    private List<ChannelInfo> channelInfos;
+    @ApiModelProperty("是否固定价格")
+    private String ifFixedPrice;
+    @ApiModelProperty("预测单数")
+    private String forecastNum;
+
+    @ApiModelProperty(value = "次/日")
+    private String dayMaxNum;
+    @ApiModelProperty(value = "次/月")
+    private String mouthMaxNum;
+
+    @Data
+    @ApiModel(description = "产品下的通道路由信息")
+    public static class ChannelInfo{
+        @ApiModelProperty("通道sid")
+        private String channelSid;
+        @ApiModelProperty("通道优先级")
+        private Integer order;
+        @ApiModelProperty("切换条件 可选值: error timeout")
+        private List<SwitchCondition> switchCondition;
+        @ApiModelProperty("超时时间")
+        private Integer timeout;
+        @ApiModelProperty("返回结果集")
+        private String result;
+        
+    }
+}

+ 26 - 0
src/main/java/info/aspirecn/cloud/yysj/entity/Produce.java

@@ -0,0 +1,26 @@
+package info.aspirecn.cloud.yysj.entity;
+
+import java.util.Date;
+
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+/**
+ * @author bzh
+ */
+@Data
+@Accessors(chain = true)
+public class Produce {
+	
+    private Integer id;
+    private String produceName;
+    private String remark;
+    private String price;
+    private Integer type;
+    /**是否订购*/
+    private Integer isOrder;
+    private Date createTime;
+    private Date updateTime;
+    private Integer sjjhId;
+
+}

+ 17 - 0
src/main/java/info/aspirecn/cloud/yysj/entity/ProduceList.java

@@ -0,0 +1,17 @@
+package info.aspirecn.cloud.yysj.entity;
+
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+/**
+ * @author bzh
+ */
+@Data
+@Accessors(chain = true)
+public class ProduceList {
+	
+    private String productName;
+    private int pageNum;
+    private int pageSize;
+
+}

+ 23 - 0
src/main/java/info/aspirecn/cloud/yysj/entity/ProduceRelevance.java

@@ -0,0 +1,23 @@
+package info.aspirecn.cloud.yysj.entity;
+
+import java.util.Date;
+
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+/**
+ * @author bzh
+ */
+@Data
+@Accessors(chain = true)
+public class ProduceRelevance {
+	
+	private Integer id;
+	private Integer yysjId;
+	private Integer type;
+	private Integer sjjhId;
+	private Date createTime;
+	private Date updateTime;
+	
+
+}

+ 20 - 0
src/main/java/info/aspirecn/cloud/yysj/entity/ProductDetailRes.java

@@ -0,0 +1,20 @@
+package info.aspirecn.cloud.yysj.entity;
+
+import java.util.Date;
+
+import io.swagger.annotations.ApiModel;
+import lombok.Data;
+@Data
+@ApiModel(description = "产品")
+public class ProductDetailRes {
+
+    private Integer id;
+    private String sid;
+    private String name;
+    private Integer price;
+    private Integer status;
+    private String productType;
+    private int channelTypeId;
+    private Date createtime;
+    private Date updatetime;
+}

+ 30 - 0
src/main/java/info/aspirecn/cloud/yysj/entity/ProductManagerListReq.java

@@ -0,0 +1,30 @@
+package info.aspirecn.cloud.yysj.entity;
+
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+/**
+ * @Author: bzh
+ * @Description:
+ */
+@ApiModel(description = "查询产品管理列表请求类")
+@Data
+public class ProductManagerListReq {
+    @ApiModelProperty("产品sid")
+    private String sid;
+    @ApiModelProperty("开始时间 格式:yyyy-MM-dd")
+    private String startTime;
+    @ApiModelProperty("结束时间 格式:yyyy-MM-dd")
+    private String endTime;
+    @ApiModelProperty("产品状态 1:上线 3:下线")
+    private Integer status;
+    @ApiModelProperty("产品类型 32:实时 31:异步")
+    private Integer productType;
+    @ApiModelProperty("页码")
+    private int pageNum;
+    @ApiModelProperty("每页展示数量")
+    private int pageSize;
+
+}

+ 58 - 0
src/main/java/info/aspirecn/cloud/yysj/entity/ProductManagerListRes.java

@@ -0,0 +1,58 @@
+package info.aspirecn.cloud.yysj.entity;
+
+
+import java.util.List;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+/**
+ * @Author: bzh
+ * @Description:
+ */
+@Data
+@ApiModel(description = "产品管理列表")
+public class ProductManagerListRes {
+    @ApiModelProperty("集合总条数")
+    private int total;
+    @ApiModelProperty("集合信息")
+    private List<ProductManagerInfo> list;
+
+    @Data
+    @ApiModel(description = "产品管理信息")
+    public static class ProductManagerInfo{
+        @ApiModelProperty("产品名称")
+        private String name;
+        @ApiModelProperty("产品Id")
+        private Integer id;
+        @ApiModelProperty("产品SId")
+        private String sid;
+        @ApiModelProperty("建议零售价")
+        private Integer price;
+        @ApiModelProperty("通道分类名称")
+        private String channelClassifyName;
+        @ApiModelProperty("通道分类Id")
+        private String channelClassifySId;
+        @ApiModelProperty("下属通道集合数量")
+        private String channelCount;
+        @ApiModelProperty("下属通道集合")
+        private List<ChannelInfo> list;
+        @ApiModelProperty("产品状态 1:上线 3:下线")
+        private Integer status;
+        @ApiModelProperty("产品类型 31:实时 31:异步")
+        private Integer productType;
+        @ApiModelProperty("创建时间 格式:yyyy-MM-dd")
+        private String createtime;
+    }
+
+    @Data
+    @ApiModel(description = "产品下属通道信息")
+    public static class ChannelInfo{
+        @ApiModelProperty("通道Id")
+        private String channelId;
+        @ApiModelProperty("通道名称")
+        private String channelName;
+    }
+
+}

+ 18 - 0
src/main/java/info/aspirecn/cloud/yysj/entity/ResponseInfo.java

@@ -0,0 +1,18 @@
+package info.aspirecn.cloud.yysj.entity;
+
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+/**
+ * @author dingliqiang
+ */
+@Data
+@Accessors(chain = true)
+public class ResponseInfo {
+
+    /** 错误信息*/
+    private String message = "";
+    /** 返回结果*/
+    private Object data = "";
+
+}

+ 21 - 0
src/main/java/info/aspirecn/cloud/yysj/entity/SjjhProduce.java

@@ -0,0 +1,21 @@
+package info.aspirecn.cloud.yysj.entity;
+
+import java.util.Date;
+
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+/**
+ * @author bzh
+ */
+@Data
+@Accessors(chain = true)
+public class SjjhProduce {
+	
+    private Integer id;
+    private Integer yysjId;
+    private Integer sjjhId;
+    private Date createTime;
+    private Date updateTime;
+
+}

+ 19 - 0
src/main/java/info/aspirecn/cloud/yysj/entity/SwitchCondition.java

@@ -0,0 +1,19 @@
+package info.aspirecn.cloud.yysj.entity;
+
+import java.io.Serializable;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+@ApiModel(description = "路由切换条件类")
+@Data
+public class SwitchCondition implements Serializable{
+	 @ApiModelProperty("switchCondition")
+	 private String switchCondition;
+	 @ApiModelProperty("seconds")
+	 private int seconds;
+	 @ApiModelProperty("result")
+	 private String result;
+	 
+}

+ 24 - 0
src/main/java/info/aspirecn/cloud/yysj/entity/User.java

@@ -0,0 +1,24 @@
+package info.aspirecn.cloud.yysj.entity;
+
+import java.util.Date;
+
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+/**
+ * @author bzh
+ */
+@Data
+@Accessors(chain = true)
+public class User {
+
+    private Integer id;
+    private String userId;
+    private Integer sjjhUserId;
+    private String appId;
+    private String secret;
+    private String username;
+    private Date createTime;
+    private Date updateTime;
+    
+}

+ 12 - 0
src/main/java/info/aspirecn/cloud/yysj/entity/UserChannel.java

@@ -0,0 +1,12 @@
+package info.aspirecn.cloud.yysj.entity;
+
+import java.io.Serializable;
+
+import lombok.Data;
+
+@Data
+public class UserChannel implements Serializable{
+		private int channelId;
+		private String channelSid;
+		private String channelName;
+}

+ 22 - 0
src/main/java/info/aspirecn/cloud/yysj/entity/UserProduce.java

@@ -0,0 +1,22 @@
+package info.aspirecn.cloud.yysj.entity;
+
+import java.util.Date;
+
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+/**
+ * @author bzh
+ */
+@Data
+@Accessors(chain = true)
+public class UserProduce {
+
+    private Integer id;
+    private String userId;
+    private Integer produceId;
+    private Integer event;
+    private String produceName;
+    private Date createTime;
+
+}

+ 21 - 0
src/main/java/info/aspirecn/cloud/yysj/entity/UserProduct.java

@@ -0,0 +1,21 @@
+package info.aspirecn.cloud.yysj.entity;
+
+
+import java.io.Serializable;
+import java.util.List;
+
+import lombok.Data;
+
+
+@Data
+public class UserProduct implements Serializable{
+	private int productId;//产品Id
+	private String productSid;//产品Sid
+	private String productName;//产品名称
+	private int price;//路由价格
+	private int buySign;//是否购买标志位
+	List<UserChannel> channels;
+	private int userId;
+
+	
+}

+ 12 - 0
src/main/java/info/aspirecn/cloud/yysj/entity/UserProductPo.java

@@ -0,0 +1,12 @@
+package info.aspirecn.cloud.yysj.entity;
+
+
+import java.io.Serializable;
+import java.util.List;
+
+import lombok.Data;
+@Data
+public class UserProductPo implements Serializable{
+	private int count;
+	private List<UserProduct> userProducts; 
+}

+ 32 - 0
src/main/java/info/aspirecn/cloud/yysj/entity/response/ProductResponse.java

@@ -0,0 +1,32 @@
+package info.aspirecn.cloud.yysj.entity.response;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import lombok.experimental.Accessors;
+
+/**
+ * 产品信息
+ *
+ * @author baizehui
+ */
+@Data
+@Accessors(chain = true)
+@NoArgsConstructor
+@AllArgsConstructor
+public class ProductResponse {
+
+    @ApiModelProperty(value = "产品id")
+    private String productId;
+
+    @ApiModelProperty(value = "产品名称")
+    private String productName;
+    
+    @ApiModelProperty(value = "产品价格")
+    private String productPrice;
+    
+    @ApiModelProperty(value = "订购状态 0、未订购  1、已订购")
+    private int status;
+
+}

+ 41 - 0
src/main/java/info/aspirecn/cloud/yysj/mapper/ProductMapper.java

@@ -0,0 +1,41 @@
+package info.aspirecn.cloud.yysj.mapper;
+
+import java.util.Date;
+import java.util.List;
+
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import info.aspirecn.cloud.yysj.entity.Produce;
+import info.aspirecn.cloud.yysj.entity.ProduceRelevance;
+import info.aspirecn.cloud.yysj.entity.SjjhProduce;
+import info.aspirecn.cloud.yysj.entity.UserProduce;
+
+@Mapper
+public interface ProductMapper  {
+
+	Integer saveUserProduce(@Param("userId")String userId,@Param("produceId")Integer produceId,@Param("createTime") Date createTime);
+
+	List<UserProduce> queryUserProduce(@Param("userId")String userId,@Param("produceId")Integer produceId);
+
+	Integer deleteUserProduce(@Param("userId")String userId,@Param("produceId")Integer produceId);
+
+	List<Integer> getOrderProductCount(@Param("userId")String userId);
+
+	List<Produce> getProductList(@Param("userId")String userId,@Param("productName")String productName,@Param("pageNum") int pageNum,@Param("pageSize") int pageSize);
+
+	Integer saveProduce(Produce produce);
+
+	void saveSjjhProduce(SjjhProduce sjjhProduce);
+
+	List<Integer> getUserProduces(@Param("userId")String userId);
+
+	void saveUserProduceEvent(UserProduce userProduce);
+
+	List<ProduceRelevance> getProductByProduceId(@Param("produceId")Integer produceId);
+
+	List<Produce> getAllProductList(@Param("productName")String productName);
+
+	Integer getProductCount();
+
+}

+ 15 - 0
src/main/java/info/aspirecn/cloud/yysj/mapper/UserMapper.java

@@ -0,0 +1,15 @@
+package info.aspirecn.cloud.yysj.mapper;
+
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import info.aspirecn.cloud.yysj.entity.User;
+
+@Mapper
+public interface UserMapper  {
+
+	User getUserByUserId(@Param("userId")String userId);
+
+
+
+}

+ 26 - 0
src/main/java/info/aspirecn/cloud/yysj/service/ProductService.java

@@ -0,0 +1,26 @@
+package info.aspirecn.cloud.yysj.service;
+
+import java.util.List;
+import java.util.Map;
+
+import info.aspirecn.cloud.yysj.entity.Produce;
+import info.aspirecn.cloud.yysj.entity.UserProduce;
+
+
+public interface ProductService {
+
+	Integer saveUserProduce(String userId, UserProduce userProduce);
+
+	List<UserProduce> queryUserProduce(String userId, Integer produceId);
+
+	Integer deleteUserProduce(String userId, Integer produceId, String produceName);
+
+	Map<String, Integer> getOrderProductCount(String userId);
+
+	void saveProduce(Produce produce);
+
+	Map<String, Object> getProductList(String userId, String productName, int pageNum, int pageSize);
+	
+	List<Produce> getProductNameList();
+
+}

+ 40 - 0
src/main/java/info/aspirecn/cloud/yysj/service/SjjhProductService.java

@@ -0,0 +1,40 @@
+package info.aspirecn.cloud.yysj.service;
+
+import java.util.List;
+
+import org.springframework.cloud.openfeign.FeignClient;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+
+import info.aspirecn.cloud.yysj.entity.EditRoutePriceInfoReq;
+import info.aspirecn.cloud.yysj.entity.ProductDetailRes;
+import info.aspirecn.cloud.yysj.entity.ProductManagerListReq;
+import info.aspirecn.cloud.yysj.entity.ProductManagerListRes;
+import info.aspirecn.cloud.yysj.entity.UserProductPo;
+
+//@FeignClient(value = "http://10.8.18.171:20180",url = "http://10.8.18.171:20180")
+@FeignClient(value = "http://iov-sjjh-servicenode-channel.iov-sjjh:8080",url = "http://iov-sjjh-servicenode-channel.iov-sjjh:8080")
+public interface SjjhProductService {
+	
+	 /**根据多个产品id获取产品详情,包括删除与未删除*/
+	 @RequestMapping(value = "/getDetailListByIds.do",method = RequestMethod.POST)
+	 public List<ProductDetailRes> getDetailListByIds(@RequestBody List<Integer> ids);
+	 
+	  /** 查询产品管理列表 */
+	 @RequestMapping(value = "/productMgtList.do",method = RequestMethod.POST)
+	 public ProductManagerListRes productMgtList(@RequestBody ProductManagerListReq productManagerListReq);
+	 
+	  /** 产品配置添加产品和路由信息或者配置路由信息 */
+	 @RequestMapping(value = "/addOrEditRouteInfo.do",method = RequestMethod.POST)
+	 public Integer addOrEditRouteInfo(@RequestBody EditRoutePriceInfoReq editRoutePriceInfoReq);
+	 
+	  /** 客户删除产品 */
+	 @RequestMapping(value = "/delProductForCustomer.do",method = RequestMethod.POST)
+	 public Integer delProductForCustomer(@RequestParam("userId")Integer userId, @RequestParam("productSid")String productSid);
+	 
+	 @RequestMapping(value = "/getUserPriceList.do",method = RequestMethod.POST)
+	 public UserProductPo userPriceList(@RequestParam(value="userId")Integer userId,@RequestParam("start")Integer start,@RequestParam("size")Integer size,@RequestParam(value="productSid",required = false)String productSid);
+	   
+}

+ 318 - 0
src/main/java/info/aspirecn/cloud/yysj/service/impl/ProductServiceImpl.java

@@ -0,0 +1,318 @@
+package info.aspirecn.cloud.yysj.service.impl;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import info.aspirecn.cloud.yysj.entity.EditRoutePriceInfoReq;
+import info.aspirecn.cloud.yysj.entity.EditRoutePriceInfoReq.ChannelInfo;
+import info.aspirecn.cloud.yysj.entity.Produce;
+import info.aspirecn.cloud.yysj.entity.ProduceRelevance;
+import info.aspirecn.cloud.yysj.entity.ProductDetailRes;
+import info.aspirecn.cloud.yysj.entity.ProductManagerListReq;
+import info.aspirecn.cloud.yysj.entity.ProductManagerListRes;
+import info.aspirecn.cloud.yysj.entity.SjjhProduce;
+import info.aspirecn.cloud.yysj.entity.SwitchCondition;
+import info.aspirecn.cloud.yysj.entity.User;
+import info.aspirecn.cloud.yysj.entity.UserProduce;
+import info.aspirecn.cloud.yysj.entity.UserProductPo;
+import info.aspirecn.cloud.yysj.mapper.ProductMapper;
+import info.aspirecn.cloud.yysj.mapper.UserMapper;
+import info.aspirecn.cloud.yysj.service.ProductService;
+import info.aspirecn.cloud.yysj.service.SjjhProductService;
+import info.aspirecn.cloud.yysj.util.RedisUtil;
+
+@Service
+@Transactional
+public class  ProductServiceImpl implements ProductService {
+
+	 /** 数据交互经营许可证产品编号 */
+     @Value("${product.permitProductId1}")
+     private  Integer permitProductId1;
+     
+     @Value("${product.permitProductId2}")
+     private  Integer permitProductId2;
+	
+	 @Autowired
+	 private UserMapper userMapper;
+	 
+	 @Autowired
+	 private ProductMapper productMapper;
+	 
+	 @Autowired
+	 private SjjhProductService sjjhProductService;
+
+     @Autowired
+     private RedisUtil redisUtil;
+	 
+	
+	@Override
+	public Integer saveUserProduce(String userId,UserProduce userProduce) {
+		User user=userMapper.getUserByUserId(userId);
+		List<ProduceRelevance> list= productMapper.getProductByProduceId(userProduce.getProduceId());
+		Integer state=0;
+		if (list.size()>0&&user!=null) {
+			for (int i = 0; i < list.size(); i++) {
+				List<Integer> ids=new ArrayList<Integer>();
+				ids.add(list.get(i).getSjjhId());
+				List<ProductDetailRes> detailRes=sjjhProductService.getDetailListByIds(ids);
+				if (detailRes.size()>0) {
+					ProductManagerListReq productManagerListReq=new ProductManagerListReq();
+					productManagerListReq.setSid(detailRes.get(0).getSid());
+					productManagerListReq.setProductType(32);
+					productManagerListReq.setStatus(1);
+					productManagerListReq.setPageNum(1);
+					productManagerListReq.setPageSize(1);
+					ProductManagerListRes productManagerListRes=sjjhProductService.productMgtList(productManagerListReq);
+					if (productManagerListRes.getList().size()>0) {
+						for (int j = 0; j < productManagerListRes.getList().size(); j++) {
+							EditRoutePriceInfoReq editRoutePriceInfoReq=new EditRoutePriceInfoReq();
+							editRoutePriceInfoReq.setUserNid(user.getSjjhUserId());
+							editRoutePriceInfoReq.setProductSid(productManagerListRes.getList().get(j).getSid());
+							editRoutePriceInfoReq.setPrice(productManagerListRes.getList().get(j).getPrice());
+							editRoutePriceInfoReq.setIfFixedPrice("1");
+							editRoutePriceInfoReq.setCacheSign(0);
+							editRoutePriceInfoReq.setSecondPriceEable(0);
+							List<ChannelInfo> listChannelInfo=new ArrayList<ChannelInfo>();
+							for (int k = 0; k < productManagerListRes.getList().get(j).getList().size(); k++) {
+								ChannelInfo channelInfos=new ChannelInfo();
+								channelInfos.setChannelSid(productManagerListRes.getList().get(j).getList().get(k).getChannelId());
+								channelInfos.setOrder(1);
+								List<SwitchCondition> listSwitchCondition=new ArrayList<SwitchCondition>();
+								SwitchCondition switchCondition=new SwitchCondition();
+								switchCondition.setSwitchCondition("timeout");
+								switchCondition.setSeconds(3000);
+								listSwitchCondition.add(switchCondition);
+								SwitchCondition switchCondition1=new SwitchCondition();
+								switchCondition1.setSwitchCondition("returnResult");
+								switchCondition1.setSeconds(0);
+								switchCondition.setResult("3");
+								listSwitchCondition.add(switchCondition1);
+								channelInfos.setSwitchCondition(listSwitchCondition);
+								listChannelInfo.add(channelInfos);
+							}
+							editRoutePriceInfoReq.setChannelInfos(listChannelInfo);
+							Integer addOrEditRouteInfo = sjjhProductService.addOrEditRouteInfo(editRoutePriceInfoReq);
+							if (addOrEditRouteInfo==1) {
+								redisUtil.del("yyshcore::getUserProduct_"+userId+"_"+list.get(i).getType());
+								 if (!permitProductId1.equals(list.get(i).getSjjhId())) {
+									 state= productMapper.saveUserProduce(userId,userProduce.getProduceId(),new Date());	
+									 userProduce.setUserId(userId);
+							    	 userProduce.setEvent(1);
+							         userProduce.setCreateTime(new Date());
+							         productMapper.saveUserProduceEvent(userProduce);
+								 }
+							}
+						}
+					}
+			
+				}
+			}
+				
+		 }
+		return state;
+	}
+	
+	@Override
+	public List<UserProduce> queryUserProduce(String userId, Integer produceId) {
+		return productMapper.queryUserProduce(userId,produceId);
+	}
+
+	@Override
+	public Integer deleteUserProduce(String userId, Integer produceId,String produceName) {
+		User user=userMapper.getUserByUserId(userId);
+		List<ProduceRelevance> list= productMapper.getProductByProduceId(produceId);
+		Integer state=0;
+		for (int i = 0; i < list.size(); i++) {
+			List<Integer> ids=new ArrayList<Integer>();
+			ids.add(list.get(i).getSjjhId());
+			List<ProductDetailRes> detailRes=sjjhProductService.getDetailListByIds(ids);
+			if (detailRes.size()>0) {
+				for (int j = 0; j < detailRes.size(); j++) {
+					Integer delProductForCustomer = sjjhProductService.delProductForCustomer(user.getSjjhUserId(), detailRes.get(j).getSid());
+					if (delProductForCustomer==1) {
+						redisUtil.del("yyshcore::getUserProduct_"+userId+"_"+list.get(i).getType());
+						redisUtil.del("sjjhcore::getRouteDetailByProductIdAndUserId_"+detailRes.get(j).getId()+"_"+user.getSjjhUserId());
+						state= productMapper.deleteUserProduce(userId,produceId);	
+						if (state==1) {
+							UserProduce userProduce=new UserProduce();
+					    	userProduce.setUserId(userId);
+					    	userProduce.setProduceId(produceId);
+					    	userProduce.setEvent(0);
+					    	userProduce.setProduceName(produceName);
+					    	userProduce.setCreateTime(new Date());
+					    	productMapper.saveUserProduceEvent(userProduce);
+						}
+					}
+				}
+			}
+		}
+		return state;
+	}
+
+@Override
+	public Map<String, Integer> getOrderProductCount(String userId) {
+		//获取云雁所有产品
+		List<Produce> producesAllList=productMapper.getAllProductList(null);
+		User userByUserId = userMapper.getUserByUserId(userId);
+		//调用数据交互服务,获取产品价格
+		UserProductPo userPriceList = sjjhProductService.userPriceList(userByUserId.getSjjhUserId(), 0, 9999, null);
+		Iterator<Produce> producesIter = producesAllList.iterator();
+		int orderProductCount=0;
+		int chargeOrderProductCount=0;
+		 while(producesIter.hasNext()){
+			 Produce produce = producesIter.next();
+			 for (int j = 0; j < userPriceList.getUserProducts().size(); j++) {
+					if (produce.getSjjhId().equals(userPriceList.getUserProducts().get(j).getProductId())) {
+						if (produce.getSjjhId().equals(permitProductId1)) {
+							producesIter.remove();
+						}else {
+							if (userPriceList.getUserProducts().get(j).getBuySign()==1) {
+								orderProductCount++;
+								if (userPriceList.getUserProducts().get(j).getPrice()>0) {
+									chargeOrderProductCount++;
+								}
+							}
+						}
+					}
+				}
+			 
+		 }		
+		Map<String, Integer>  map=new HashMap<String, Integer>();
+		map.put("orderProductCount", orderProductCount);
+		map.put("chargeOrderProductCount", chargeOrderProductCount);
+		return map;
+	}
+
+	@Override
+	public Map<String, Object> getProductList(String userId,String productName, int pageNum, int pageSize) {
+		//获取云雁所有产品
+		List<Produce> producesAllList=productMapper.getAllProductList(productName);
+		User userByUserId = userMapper.getUserByUserId(userId);
+		//调用数据交互服务,获取产品价格
+		UserProductPo userPriceList = sjjhProductService.userPriceList(userByUserId.getSjjhUserId(), 0, 9999, null);
+		List<Produce> list=new ArrayList<Produce>();
+		if (userPriceList!=null) {
+			Integer price=0;
+			Iterator<Produce> producesIter = producesAllList.iterator();
+			 while(producesIter.hasNext()){
+				 Produce produce = producesIter.next();
+				 for (int j = 0; j < userPriceList.getUserProducts().size(); j++) {
+						if (produce.getSjjhId().equals(userPriceList.getUserProducts().get(j).getProductId())) {
+							if (produce.getSjjhId().equals(permitProductId1)) {
+								price+=Integer.valueOf(userPriceList.getUserProducts().get(j).getPrice());
+							}else {
+								if (produce.getSjjhId().equals(permitProductId2)) {
+									produce.setPrice(priceprocess(String.valueOf(userPriceList.getUserProducts().get(j).getPrice()+price)));
+									produce.setIsOrder(userPriceList.getUserProducts().get(j).getBuySign());
+									list.add(produce);
+								}else {
+									produce.setPrice(priceprocess(String.valueOf(userPriceList.getUserProducts().get(j).getPrice())));
+									produce.setIsOrder(userPriceList.getUserProducts().get(j).getBuySign());
+									list.add(produce);
+								}
+								
+							}
+							 //用查询用户是否订购产品
+			            	 List<UserProduce> queryUserProduce = productMapper.queryUserProduce(userId,produce.getId());
+							if (queryUserProduce.isEmpty()&&userPriceList.getUserProducts().get(j).getBuySign()==1) {
+								//用户订购产品
+								productMapper.saveUserProduce(userId,produce.getId(),new Date());	
+						    	UserProduce userProduce=new UserProduce();
+								userProduce.setUserId(userId);
+								userProduce.setProduceId(produce.getId());
+						    	userProduce.setEvent(userPriceList.getUserProducts().get(j).getBuySign());
+						    	userProduce.setProduceName(produce.getProduceName());
+						    	userProduce.setCreateTime(new Date());
+						    	productMapper.saveUserProduceEvent(userProduce);
+							}
+							//用户取消订购
+							if (queryUserProduce.size()>0&&userPriceList.getUserProducts().get(j).getBuySign()==0) {
+								productMapper.deleteUserProduce(userId,produce.getId());	
+								UserProduce userProduce=new UserProduce();
+						    	userProduce.setUserId(userId);
+						    	userProduce.setProduceId(produce.getId());
+						    	userProduce.setEvent(0);
+						    	userProduce.setProduceName(produce.getProduceName());
+						    	userProduce.setCreateTime(new Date());
+						    	productMapper.saveUserProduceEvent(userProduce);
+							}
+						}
+					}
+				 
+			 }
+			 if (!list.isEmpty()) {
+				 list.sort((x, y) -> Integer.compare(y.getIsOrder(), x.getIsOrder()));
+			}
+		}
+	    Integer count = list.size(); //记录总数
+        Integer pageCount = 0; //页数
+        if (count % pageSize == 0) {
+            pageCount = count / pageSize;
+        } else {
+            pageCount = count / pageSize + 1;
+        }
+        int fromIndex = 0; //开始索引
+        int toIndex = 0; //结束索引
+        if(pageNum > pageCount){
+            pageNum = pageCount;
+        }
+        if (pageNum!=pageCount) {
+            fromIndex = (pageNum - 1) * pageSize;
+            toIndex = fromIndex + pageSize;
+        } else {
+            fromIndex = (pageNum - 1) * pageSize;
+            toIndex = count;
+        }
+		Map<String, Object> map=new HashMap<String, Object>();
+		map.put("dataList", list.subList(fromIndex, toIndex));
+		map.put("total", count);
+		return map;
+	}
+	
+	@Override
+	public List<Produce> getProductNameList() {
+		return productMapper.getAllProductList(null);
+	}
+
+	@Override
+	public void saveProduce(Produce produce) {
+		produce.setCreateTime(new Date());
+		produce.setUpdateTime(new Date());
+		productMapper.saveProduce(produce);	
+		SjjhProduce sjjhProduce=new SjjhProduce();
+		sjjhProduce.setYysjId(produce.getId());
+		sjjhProduce.setSjjhId(produce.getSjjhId());
+		sjjhProduce.setCreateTime(new Date());
+		sjjhProduce.setUpdateTime(new Date());
+		productMapper.saveSjjhProduce(sjjhProduce);
+	}
+	/**
+	 * 处理价格单位
+	 */
+	private static String priceprocess(String price){
+	    // 获取签名部分
+	    if (price.length() == 1){
+	        return "0.00" + price;
+	    } else if (price.length() == 2){
+	        return "0.0" + price;
+	    } else if (price.length() == 3){
+	        return "0." + price;
+	    }
+	    // 获取签名部分
+	    String pricePre = StringUtils.substring(price,0,price.length()-3);
+	    // 获取后面部分
+	    String pricePost = StringUtils.substring(price,price.length()-3,price.length());
+	    // 拼接
+	    return pricePre + "." + pricePost;
+	}
+}

+ 38 - 0
src/main/java/info/aspirecn/cloud/yysj/util/RedisConfig.java

@@ -0,0 +1,38 @@
+package info.aspirecn.cloud.yysj.util;
+
+import com.fasterxml.jackson.annotation.JsonAutoDetect;
+import com.fasterxml.jackson.annotation.PropertyAccessor;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.data.redis.connection.RedisConnectionFactory;
+import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
+import org.springframework.data.redis.serializer.StringRedisSerializer;
+
+@Configuration
+public class RedisConfig {
+
+    @Bean
+    @SuppressWarnings("all")
+    public RedisTemplate<String, Object> redisTemplate(RedisConnectionFactory factory) {
+        RedisTemplate<String, Object> template = new RedisTemplate<String, Object>();
+        template.setConnectionFactory(factory);
+        Jackson2JsonRedisSerializer jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer(Object.class);
+        ObjectMapper om = new ObjectMapper();
+        om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
+        om.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL);
+        jackson2JsonRedisSerializer.setObjectMapper(om);
+        StringRedisSerializer stringRedisSerializer = new StringRedisSerializer();
+        // key采用String的序列化方式
+        template.setKeySerializer(stringRedisSerializer);
+        // hash的key也采用String的序列化方式
+        template.setHashKeySerializer(stringRedisSerializer);
+        // value序列化方式采用jackson
+        template.setValueSerializer(jackson2JsonRedisSerializer);
+        // hash的value序列化方式采用jackson
+        template.setHashValueSerializer(jackson2JsonRedisSerializer);
+        template.afterPropertiesSet();
+        return template;
+    }
+}

+ 889 - 0
src/main/java/info/aspirecn/cloud/yysj/util/RedisUtil.java

@@ -0,0 +1,889 @@
+package info.aspirecn.cloud.yysj.util;
+
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.data.redis.core.script.DefaultRedisScript;
+import org.springframework.data.redis.core.script.RedisScript;
+import org.springframework.stereotype.Component;
+import org.springframework.util.CollectionUtils;
+
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.TimeUnit;
+
+@Slf4j
+@Component
+public class RedisUtil {
+    private static final Long SUCCESS = 1L;
+
+    @Autowired
+    private RedisTemplate<String,Object> redisTemplate;
+
+    // =============================common============================
+
+
+    /**
+     * 获取锁
+     *
+     * @param lockKey
+     * @param value
+     * @param expireTime:单位-秒
+     * @return
+     */
+    public boolean getLock(String lockKey, Object value, int expireTime) {
+        try {
+            log.info("添加分布式锁key={},expireTime={}", lockKey, expireTime);
+            String script = "if redis.call('setNx',KEYS[1],ARGV[1]) then if redis.call('get',KEYS[1])==ARGV[1] then return redis.call('expire',KEYS[1],ARGV[2]) else return 0 end end";
+            RedisScript<String> redisScript = new DefaultRedisScript<>(script, String.class);
+            Object result = redisTemplate.execute(redisScript, Collections.singletonList(lockKey), value, expireTime);
+            if (SUCCESS.equals(result)) {
+                return true;
+            }
+        } catch (Exception e) {
+           log.info("content:{}",e);
+        }
+        return false;
+    }
+
+    /**
+     * 释放锁
+     *
+     * @param lockKey
+     * @param value
+     * @return
+     */
+    public boolean releaseLock(String lockKey, String value) {
+        String script = "if redis.call('get', KEYS[1]) == ARGV[1] then return redis.call('del', KEYS[1]) else return 0 end";
+        RedisScript<String> redisScript = new DefaultRedisScript<>(script, String.class);
+        Object result = redisTemplate.execute(redisScript, Collections.singletonList(lockKey), value);
+        if (SUCCESS.equals(result)) {
+            return true;
+        }
+        return false;
+    }
+
+    // =============================common============================
+
+    /**
+     * 指定缓存失效时间
+     *
+     * @param key  键
+     * @param time 时间(秒)
+     * @return
+     */
+
+    public boolean expire(String key, long time) {
+
+        try {
+
+            if (time > 0) {
+
+                redisTemplate.expire(key, time, TimeUnit.SECONDS);
+
+            }
+
+            return true;
+
+        } catch (Exception e) {
+
+           log.info("content:{}",e);
+
+            return false;
+
+        }
+
+    }
+
+
+    /**
+     * 根据key 获取过期时间
+     *
+     * @param key 键 不能为null
+     * @return 时间(秒) 返回代表为永久有效
+     */
+
+    public long getExpire(String key) {
+
+        return redisTemplate.getExpire(key, TimeUnit.SECONDS);
+
+    }
+
+
+    /**
+     * 判断key是否存在
+     *
+     * @param key 键
+     * @return true 存在 false不存在
+     */
+
+    public boolean hasKey(String key) {
+
+        try {
+
+            return redisTemplate.hasKey(key);
+
+        } catch (Exception e) {
+
+           log.info("content:{}",e);
+
+            return false;
+
+        }
+
+    }
+
+
+    /**
+     * 删除缓存
+     *
+     * @param key 可以传一个值 或多个
+     */
+
+    @SuppressWarnings("unchecked")
+
+    public void del(String... key) {
+
+        if (key != null && key.length > 0) {
+
+            if (key.length == 1) {
+
+                redisTemplate.delete(key[0]);
+
+            } else {
+
+                redisTemplate.delete(CollectionUtils.arrayToList(key));
+
+            }
+
+        }
+
+    }
+
+
+// ============================String=============================
+
+    /**
+     * 普通缓存获取
+     *
+     * @param key 键
+     * @return 值
+     */
+
+    public Object get(String key) {
+
+        return key == null ? null : redisTemplate.opsForValue().get(key);
+
+    }
+
+
+    /**
+     * 普通缓存放入
+     *
+     * @param key   键
+     * @param value 值
+     * @return true成功 false失败
+     */
+
+    public boolean set(String key, Object value) {
+
+        try {
+
+            redisTemplate.opsForValue().set(key, value);
+
+            return true;
+
+        } catch (Exception e) {
+
+           log.info("content:{}",e);
+
+            return false;
+
+        }
+
+
+    }
+
+
+    /**
+     * 普通缓存放入并设置时间
+     *
+     * @param key   键
+     * @param value 值
+     * @param time  时间(秒) time要大于0 如果time小于等于0 将设置无限期
+     * @return true成功 false 失败
+     */
+
+    public boolean set(String key, Object value, long time) {
+
+        try {
+
+            if (time > 0) {
+
+                redisTemplate.opsForValue().set(key, value, time, TimeUnit.SECONDS);
+
+            } else {
+
+                set(key, value);
+
+            }
+
+            return true;
+
+        } catch (Exception e) {
+
+           log.info("content:{}",e);
+
+            return false;
+
+        }
+
+    }
+
+
+    /**
+     * 递增
+     *
+     * @param key   键
+     * @param delta 要增加几(大于)
+     * @return
+     */
+
+    public long incr(String key, long delta) {
+
+        if (delta < 0) {
+
+            throw new RuntimeException("递增因子必须大于0");
+
+        }
+
+        return redisTemplate.opsForValue().increment(key, delta);
+
+    }
+
+
+    /**
+     * 递减
+     *
+     * @param key   键
+     * @param delta 要减少几(小于)
+     * @return
+     */
+
+    public long decr(String key, long delta) {
+
+        if (delta < 0) {
+
+            throw new RuntimeException("递减因子必须大于0");
+
+        }
+
+        return redisTemplate.opsForValue().increment(key, -delta);
+
+    }
+
+
+// ================================Map=================================
+
+    /**
+     * HashGet
+     *
+     * @param key  键 不能为null
+     * @param item 项 不能为null
+     * @return 值
+     */
+
+    public Object hget(String key, String item) {
+
+        return redisTemplate.opsForHash().get(key, item);
+
+    }
+
+
+    /**
+     * 获取hashKey对应的所有键值
+     *
+     * @param key 键
+     * @return 对应的多个键值
+     */
+
+    public Map<Object, Object> hmget(String key) {
+
+        return redisTemplate.opsForHash().entries(key);
+
+    }
+
+
+    /**
+     * HashSet
+     *
+     * @param key 键
+     * @param map 对应多个键值
+     * @return true 成功 false 失败
+     */
+
+    public boolean hmset(String key, Map<String, Object> map) {
+
+        try {
+
+            redisTemplate.opsForHash().putAll(key, map);
+
+            return true;
+
+        } catch (Exception e) {
+
+           log.info("content:{}",e);
+
+            return false;
+
+        }
+
+    }
+
+
+    /**
+     * HashSet 并设置时间
+     *
+     * @param key  键
+     * @param map  对应多个键值
+     * @param time 时间(秒)
+     * @return true成功 false失败
+     */
+
+    public boolean hmset(String key, Map<String, Object> map, long time) {
+
+        try {
+
+            redisTemplate.opsForHash().putAll(key, map);
+
+            if (time > 0) {
+
+                expire(key, time);
+
+            }
+
+            return true;
+
+        } catch (Exception e) {
+
+           log.info("content:{}",e);
+
+            return false;
+
+        }
+
+    }
+
+
+    /**
+     * 向一张hash表中放入数据,如果不存在将创建
+     *
+     * @param key   键
+     * @param item  项
+     * @param value 值
+     * @return true 成功 false失败
+     */
+
+    public boolean hset(String key, String item, Object value) {
+
+        try {
+
+            redisTemplate.opsForHash().put(key, item, value);
+
+            return true;
+
+        } catch (Exception e) {
+
+           log.info("content:{}",e);
+
+            return false;
+
+        }
+
+    }
+
+
+    /**
+     * 向一张hash表中放入数据,如果不存在将创建
+     *
+     * @param key   键
+     * @param item  项
+     * @param value 值
+     * @param time  时间(秒) 注意:如果已存在的hash表有时间,这里将会替换原有的时间
+     * @return true 成功 false失败
+     */
+
+    public boolean hset(String key, String item, Object value, long time) {
+
+        try {
+
+            redisTemplate.opsForHash().put(key, item, value);
+
+            if (time > 0) {
+
+                expire(key, time);
+
+            }
+
+            return true;
+
+        } catch (Exception e) {
+
+           log.info("content:{}",e);
+
+            return false;
+
+        }
+
+    }
+
+
+    /**
+     * 删除hash表中的值
+     *
+     * @param key  键 不能为null
+     * @param item 项 可以使多个 不能为null
+     */
+
+    public void hdel(String key, Object... item) {
+
+        redisTemplate.opsForHash().delete(key, item);
+
+    }
+
+
+    /**
+     * 判断hash表中是否有该项的值
+     *
+     * @param key  键 不能为null
+     * @param item 项 不能为null
+     * @return true 存在 false不存在
+     */
+
+    public boolean hHasKey(String key, String item) {
+
+        return redisTemplate.opsForHash().hasKey(key, item);
+
+    }
+
+
+    /**
+     * hash递增 如果不存在,就会创建一个 并把新增后的值返回
+     *
+     * @param key  键
+     * @param item 项
+     * @param by   要增加几(大于)
+     * @return
+     */
+
+    public double hincr(String key, String item, double by) {
+
+        return redisTemplate.opsForHash().increment(key, item, by);
+
+    }
+
+
+    /**
+     * hash递减
+     *
+     * @param key  键
+     * @param item 项
+     * @param by   要减少记(小于)
+     * @return
+     */
+
+    public double hdecr(String key, String item, double by) {
+
+        return redisTemplate.opsForHash().increment(key, item, -by);
+
+    }
+
+
+// ============================set=============================
+
+    /**
+     * 根据key获取Set中的所有值
+     *
+     * @param key 键
+     * @return
+     */
+
+    public Set<Object> sGet(String key) {
+
+        try {
+
+            return redisTemplate.opsForSet().members(key);
+
+        } catch (Exception e) {
+
+           log.info("content:{}",e);
+
+            return null;
+
+        }
+
+    }
+
+
+    /**
+     * 根据value从一个set中查询,是否存在
+     *
+     * @param key   键
+     * @param value 值
+     * @return true 存在 false不存在
+     */
+
+    public boolean sHasKey(String key, Object value) {
+
+        try {
+
+            return redisTemplate.opsForSet().isMember(key, value);
+
+        } catch (Exception e) {
+
+           log.info("content:{}",e);
+
+            return false;
+
+        }
+
+    }
+
+
+    /**
+     * 将数据放入set缓存
+     *
+     * @param key    键
+     * @param values 值 可以是多个
+     * @return 成功个数
+     */
+
+    public long sSet(String key, Object... values) {
+
+        try {
+
+            return redisTemplate.opsForSet().add(key, values);
+
+        } catch (Exception e) {
+
+           log.info("content:{}",e);
+
+            return 0;
+
+        }
+
+    }
+
+
+    /**
+     * 将set数据放入缓存
+     *
+     * @param key    键
+     * @param time   时间(秒)
+     * @param values 值 可以是多个
+     * @return 成功个数
+     */
+
+    public long sSetAndTime(String key, long time, Object... values) {
+
+        try {
+
+            Long count = redisTemplate.opsForSet().add(key, values);
+
+            if (time > 0)
+
+                expire(key, time);
+
+            return count;
+
+        } catch (Exception e) {
+
+           log.info("content:{}",e);
+
+            return 0;
+
+        }
+
+    }
+
+
+    /**
+     * 获取set缓存的长度
+     *
+     * @param key 键
+     * @return
+     */
+
+    public long sGetSetSize(String key) {
+
+        try {
+
+            return redisTemplate.opsForSet().size(key);
+
+        } catch (Exception e) {
+
+           log.info("content:{}",e);
+
+            return 0;
+
+        }
+
+    }
+
+
+    /**
+     * 移除值为value的
+     *
+     * @param key    键
+     * @param values 值 可以是多个
+     * @return 移除的个数
+     */
+
+    public long setRemove(String key, Object... values) {
+
+        try {
+
+            Long count = redisTemplate.opsForSet().remove(key, values);
+
+            return count;
+
+        } catch (Exception e) {
+
+           log.info("content:{}",e);
+
+            return 0;
+
+        }
+
+    }
+
+// ===============================list=================================
+
+
+    /**
+     * 获取list缓存的内容
+     *
+     * @param key   键
+     * @param start 开始
+     * @param end   结束  到 -代表所有值
+     * @return
+     */
+
+    public List<Object> lGet(String key, long start, long end) {
+
+        try {
+
+            return redisTemplate.opsForList().range(key, start, end);
+
+        } catch (Exception e) {
+
+           log.info("content:{}",e);
+
+            return null;
+
+        }
+
+    }
+
+    /**
+     * 获取list缓存的长度
+     *
+     * @param key 键
+     * @return
+     */
+
+    public long lGetListSize(String key) {
+
+        try {
+
+            return redisTemplate.opsForList().size(key);
+
+        } catch (Exception e) {
+
+           log.info("content:{}",e);
+
+            return 0;
+
+        }
+
+    }
+
+    /**
+     * 通过索引 获取list中的值
+     *
+     * @param key   键
+     * @param index 索引 index>=时,  表头, 第二个元素,依次类推;index<时,-,表尾,-倒数第二个元素,依次类推
+     * @return
+     */
+
+    public Object lGetIndex(String key, long index) {
+
+        try {
+
+            return redisTemplate.opsForList().index(key, index);
+
+        } catch (Exception e) {
+
+           log.info("content:{}",e);
+
+            return null;
+
+        }
+
+    }
+
+
+    /**
+     * 将list放入缓存
+     *
+     * @param key   键
+     * @param value 值
+     * @return
+     */
+
+    public boolean lSet(String key, Object value) {
+
+        try {
+
+            redisTemplate.opsForList().rightPush(key, value);
+
+            return true;
+
+        } catch (Exception e) {
+           log.info("content:{}",e);
+            return false;
+
+        }
+
+    }
+
+
+    /**
+     * 将list放入缓存
+     *
+     * @param key   键
+     * @param value 值
+     * @param time  时间(秒)
+     * @return
+     */
+
+    public boolean lSet(String key, Object value, long time) {
+
+        try {
+
+            redisTemplate.opsForList().rightPush(key, value);
+
+            if (time > 0)
+
+                expire(key, time);
+
+            return true;
+
+        } catch (Exception e) {
+
+           log.info("content:{}",e);
+
+            return false;
+
+        }
+
+    }
+
+
+    /**
+     * 将list放入缓存
+     *
+     * @param key   键
+     * @param value 值
+     * @return
+     */
+
+    public boolean lSet(String key, List<Object> value) {
+
+        try {
+
+            redisTemplate.opsForList().rightPushAll(key, value);
+
+            return true;
+
+        } catch (Exception e) {
+
+           log.info("content:{}",e);
+
+            return false;
+
+        }
+
+    }
+
+
+    /**
+     * 将list放入缓存
+     *
+     * @param key   键
+     * @param value 值
+     * @param time  时间(秒)
+     * @return
+     */
+
+    public boolean lSet(String key, List<Object> value, long time) {
+
+        try {
+
+            redisTemplate.opsForList().rightPushAll(key, value);
+
+            if (time > 0)
+
+                expire(key, time);
+
+            return true;
+
+        } catch (Exception e) {
+
+           log.info("content:{}",e);
+
+            return false;
+
+        }
+
+    }
+
+
+    /**
+     * 根据索引修改list中的某条数据
+     *
+     * @param key   键
+     * @param index 索引
+     * @param value 值
+     * @return
+     */
+    public boolean lUpdateIndex(String key, long index, Object value) {
+        try {
+            redisTemplate.opsForList().set(key, index, value);
+            return true;
+        } catch (Exception e) {
+           log.info("content:{}",e);
+            return false;
+        }
+    }
+
+    /**
+     * 移除N个值为value
+     *
+     * @param key   键
+     * @param count 移除多少个
+     * @return 移除的个数
+     */
+    public long lRemove(String key, long count, Object value) {
+        try {
+            Long remove = redisTemplate.opsForList().remove(key, count, value);
+            return remove;
+        } catch (Exception e) {
+           log.info("content:{}",e);
+            return 0;
+        }
+    }
+
+}

+ 43 - 0
src/main/resources/bootstrap.yml

@@ -0,0 +1,43 @@
+#ConfigMap 配置参数
+server:
+  port: 8080
+spring:
+  application:
+    name: cloud-yysj-product-info
+  cloud:
+    kubernetes:
+      reload:
+        enabled: true
+        mode: polling
+        period: 10000
+        strategy: refresh
+        monitoring-secrets: true
+      config:
+        enabled: true
+        enableApi: true
+        sources:
+          - namespace: cloud-yysj
+            name: ${spring.application.name}
+# 打印sql
+logging:
+  level:
+     info.aspirecn.cloud.yysj.mapper : debug
+#监控配置参数
+management:
+  server:
+    port: 8081
+  endpoint:
+    restart:
+      enabled: true
+    health:
+      show-details: always
+  endpoints:
+    enabled-by-default: true
+    web:
+      exposure:
+        include: "*"
+        
+info:
+  name: 产品配置
+  version: '1.0.0'
+  

+ 227 - 0
src/main/resources/mapping/ProductMapper.xml

@@ -0,0 +1,227 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
+<mapper namespace="info.aspirecn.cloud.yysj.mapper.ProductMapper">
+
+	<sql id="base_user_produce_columns">
+        id,userId,produceId,createTime
+    </sql>
+
+	<insert id="saveUserProduce">
+	  insert into yysj_user_produce(userId,produceId,createTime)
+	  values(#{userId},#{produceId},#{createTime})
+	</insert>
+	
+	<insert id="saveUserProduceEvent">
+        insert into yysj_user_produce_event
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="id != null">
+                id,
+            </if>
+            <if test="userId != null">
+                userId,
+            </if>
+            <if test="produceId != null">
+                produceId,
+            </if>
+            <if test="event != null">
+                event,
+            </if>
+            <if test="produceName != null">
+                produceName,
+            </if>
+            <if test="createTime != null">
+                createTime,
+            </if>
+        </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="id != null">
+                #{id,jdbcType=INTEGER},
+            </if>
+            <if test="userId != null">
+                #{userId,jdbcType=VARCHAR},
+            </if>
+             <if test="produceId != null">
+                #{produceId,jdbcType=INTEGER},
+            </if>
+            <if test="event != null">
+                #{event,jdbcType=INTEGER},
+            </if>
+            <if test="produceName != null">
+                #{produceName,jdbcType=VARCHAR},
+            </if>
+            <if test="createTime != null">
+                #{createTime,jdbcType=TIMESTAMP},
+            </if>
+        </trim>
+    </insert>
+	
+	<select id="queryUserProduce" resultType="info.aspirecn.cloud.yysj.entity.UserProduce">
+		 SELECT
+          <include refid="base_user_produce_columns"/>
+         FROM
+          yysj_user_produce WHERE userId=#{userId} AND produceId=#{produceId}
+	</select>
+	
+	<select id="getUserProduces" resultType="java.lang.Integer">
+		 SELECT
+			produceId 
+		FROM
+			yysj_user_produce 
+		WHERE
+			userId = #{userId}
+	</select>
+	
+	<delete id="deleteUserProduce">
+	    delete from yysj_user_produce
+	    where userId = #{userId} and produceId=#{produceId}
+  	</delete>
+  	
+  	<select id="getOrderProductCount" resultType="java.lang.Integer">
+	  	SELECT
+			sjjh_produce.sjjhId
+		FROM
+			yysj_produce produce
+			LEFT JOIN yysj_sjjh_produce_relevance sjjh_produce ON sjjh_produce.yysjId=produce.id
+			LEFT JOIN yysj_user_produce user_produce ON produce.id = user_produce.produceId 
+		WHERE
+			user_produce.userId =#{userId}
+  	</select>
+  	
+  	<select id="getProductList" resultType="info.aspirecn.cloud.yysj.entity.Produce">
+  		SELECT
+			p.id,
+			p.produceName,
+			p.remark 
+		FROM
+			yysj_produce p
+			LEFT JOIN yysj_user_produce up ON p.id = up.produceId 
+			AND up.userId = #{userId} 
+		WHERE
+			1 = 1 
+		<if test="productName != null and productName != ''">
+      		AND p.produceName=#{productName}
+      	</if>
+      	ORDER BY up.userId DESC 
+		LIMIT #{pageNum},#{pageSize}
+  	</select>
+  	
+  	<select id="getAllProductList" resultType="info.aspirecn.cloud.yysj.entity.Produce">
+  		SELECT
+			p.id,
+			p.produceName,
+			p.remark,
+			sp.sjjhId 
+		FROM
+			yysj_produce p
+			LEFT JOIN yysj_sjjh_produce_relevance sp ON p.id = sp.yysjId
+			WHERE
+			1=1 
+			<if test="productName != null and productName != ''">
+	      		AND p.produceName=#{productName}
+	      	</if>
+  	</select>
+  	
+  	<select id="getProductCount" resultType="java.lang.Integer">
+  		SELECT
+			count( 1 ) 
+		FROM
+			yysj_produce
+  	</select>
+  	
+  	<select id="getProductByProduceId" resultType="info.aspirecn.cloud.yysj.entity.ProduceRelevance">
+	    SELECT
+			yspr.id,
+			yspr.yysjId,
+			yp.type,
+			yspr.sjjhId,
+			yspr.createTime,
+			yspr.updateTime 
+		FROM
+			yysj_sjjh_produce_relevance  yspr
+			LEFT JOIN yysj_produce yp  ON yp.id=yspr.yysjId
+		WHERE
+			yspr.yysjId =#{produceId}
+  	</select>
+  	
+	 <insert id="saveProduce" parameterType="java.lang.Integer" useGeneratedKeys="true" keyProperty="id">
+        insert into yysj_produce
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="id != null">
+                id,
+            </if>
+            <if test="produceName != null">
+                produceName,
+            </if>
+            <if test="type != null">
+                type,
+            </if>
+            <if test="remark != null">
+                remark,
+            </if>
+            <if test="createTime != null">
+                createTime,
+            </if>
+            <if test="updateTime != null">
+                updateTime,
+            </if>
+        </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="id != null">
+                #{id,jdbcType=INTEGER},
+            </if>
+            <if test="produceName != null">
+                #{produceName,jdbcType=VARCHAR},
+            </if>
+             <if test="type != null">
+                #{type,jdbcType=INTEGER},
+            </if>
+            <if test="remark != null">
+                #{remark,jdbcType=VARCHAR},
+            </if>
+            <if test="createTime != null">
+                #{createTime,jdbcType=TIMESTAMP},
+            </if>
+            <if test="updateTime != null">
+                #{updateTime,jdbcType=TIMESTAMP},
+            </if>
+        </trim>
+    </insert>
+  	
+	 <insert id="saveSjjhProduce" >
+        insert into yysj_sjjh_produce_relevance
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="id != null">
+                id,
+            </if>
+            <if test="yysjId != null">
+                yysjId,
+            </if>
+            <if test="sjjhId != null">
+                sjjhId,
+            </if>
+            <if test="createTime != null">
+                createTime,
+            </if>
+            <if test="updateTime != null">
+                updateTime,
+            </if>
+        </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="id != null">
+                #{id,jdbcType=INTEGER},
+            </if>
+            <if test="yysjId != null">
+                #{yysjId,jdbcType=INTEGER},
+            </if>
+            <if test="sjjhId != null">
+                #{sjjhId,jdbcType=INTEGER},
+            </if>
+            <if test="createTime != null">
+                #{createTime,jdbcType=TIMESTAMP},
+            </if>
+            <if test="updateTime != null">
+                #{updateTime,jdbcType=TIMESTAMP},
+            </if>
+        </trim>
+    </insert>
+</mapper>

+ 20 - 0
src/main/resources/mapping/UserMapper.xml

@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
+<mapper namespace="info.aspirecn.cloud.yysj.mapper.UserMapper">
+
+	<select id="getUserByUserId" resultType="info.aspirecn.cloud.yysj.entity.User">
+		SELECT
+			id,
+			userId,
+			sjjhUserId,
+			appId,
+			secret,
+			username,
+			createTime,
+			updateTime 
+		FROM
+			yysj_user WHERE userId=#{userId}
+		
+	</select>
+	
+</mapper>