Ver código fonte

出入库日志接口

fanxw 1 ano atrás
pai
commit
a1e17b5b9c

+ 2 - 0
src/main/java/com/chinaitop/agile/SwaggerAgileConfig.java

@@ -1,6 +1,7 @@
1 1
 package com.chinaitop.agile;
2 2
 
3 3
 import org.springframework.beans.factory.annotation.Value;
4
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
4 5
 import org.springframework.context.annotation.Bean;
5 6
 import org.springframework.context.annotation.Configuration;
6 7
 
@@ -14,6 +15,7 @@ import springfox.documentation.swagger2.annotations.EnableSwagger2;
14 15
 
15 16
 @Configuration
16 17
 @EnableSwagger2
18
+@ConditionalOnProperty(name = "swagger.enable", havingValue = "true")
17 19
 public class SwaggerAgileConfig {
18 20
 
19 21
 	@Value("${eureka.instance.hostname}")

+ 0 - 1
src/main/java/com/chinaitop/agile/controller/BusinessSceduleController.java

@@ -37,7 +37,6 @@ import io.swagger.annotations.ApiOperation;
37 37
 @RestController
38 38
 @RequestMapping(value="/agile/scedule")
39 39
 @Api(value= "BusinessSceduleController", description = "执行进度")
40
-
41 40
 public class BusinessSceduleController {
42 41
     
43 42
     @Resource

+ 55 - 0
src/main/java/com/chinaitop/agile/controller/LoginfoController.java

@@ -0,0 +1,55 @@
1
+package com.chinaitop.agile.controller;
2
+
3
+import java.util.List;
4
+
5
+import javax.annotation.Resource;
6
+
7
+import org.springframework.http.MediaType;
8
+import org.springframework.web.bind.annotation.RequestMapping;
9
+import org.springframework.web.bind.annotation.RequestMethod;
10
+import org.springframework.web.bind.annotation.RestController;
11
+
12
+import com.chinaitop.agile.model.Loginfo;
13
+import com.chinaitop.agile.service.LoginfoService;
14
+import com.github.pagehelper.PageHelper;
15
+import com.github.pagehelper.PageInfo;
16
+
17
+import io.swagger.annotations.Api;
18
+import io.swagger.annotations.ApiImplicitParam;
19
+import io.swagger.annotations.ApiImplicitParams;
20
+import io.swagger.annotations.ApiOperation;
21
+
22
+@RestController
23
+@RequestMapping(value="/agile/crkrz")
24
+@Api(value= "LoginfoController", description = "出入库日志")
25
+public class LoginfoController {
26
+
27
+	@Resource
28
+	private LoginfoService loginfoService;
29
+
30
+	@RequestMapping(value="/getList", produces = MediaType.APPLICATION_JSON_VALUE, method = RequestMethod.GET)
31
+	@ApiOperation(value="出入库日志列表", notes = "支持分页")
32
+	@ApiImplicitParams({
33
+			@ApiImplicitParam(name = "pageNum", value = "页码", paramType = "query"),
34
+			@ApiImplicitParam(name = "pageSize", value = "每页条数", paramType = "query"),
35
+			@ApiImplicitParam(name = "rzlx", value = "日志类型", paramType = "query"),
36
+			@ApiImplicitParam(name="gnmc", value="模块名称", paramType="query"),
37
+			@ApiImplicitParam(name="fwstartTime", value="访问起始时间", paramType="query"),
38
+			@ApiImplicitParam(name="fwendDate", value="访问终止时间", paramType="query"),
39
+			@ApiImplicitParam(name="yhmc", value="用户名称", paramType="query")
40
+	})
41
+	public PageInfo<Loginfo> getList(Integer pageNum, Integer pageSize, String rzlx, String gnmc,
42
+			String fwstartTime, String fwendDate, String yhmc) {
43
+		List<Loginfo> list = null;
44
+		try {
45
+			if (pageNum != null && pageSize != null) {
46
+				PageHelper.startPage(pageNum, pageSize);
47
+			}
48
+			list = loginfoService.quaryList(rzlx, gnmc, fwstartTime, fwendDate, yhmc);
49
+		} catch (Exception e) {
50
+			e.printStackTrace();
51
+		}
52
+		PageInfo<Loginfo> pageInfo = new PageInfo<>(list);
53
+		return pageInfo;
54
+	}
55
+}

+ 11 - 0
src/main/java/com/chinaitop/agile/mapper/LoginfoMapper.java

@@ -0,0 +1,11 @@
1
+package com.chinaitop.agile.mapper;
2
+
3
+import java.util.List;
4
+import java.util.Map;
5
+
6
+import com.chinaitop.agile.model.Loginfo;
7
+
8
+public interface LoginfoMapper {
9
+
10
+	List<Loginfo> quaryList(Map<String, Object> map);
11
+}

+ 35 - 0
src/main/java/com/chinaitop/agile/mapper/LoginfoMapper.xml

@@ -0,0 +1,35 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
3
+<mapper namespace="com.chinaitop.agile.mapper.LoginfoMapper">
4
+  <select id="quaryList" parameterType="java.util.Map" resultType="com.chinaitop.agile.model.Loginfo">
5
+    select 
6
+      b.username yhzh, 
7
+      b.real_name yhmc, 
8
+      a.ip yhip, 
9
+      to_char(a.createtime, 'yyyy-MM-dd HH24:mi:ss') fwsj,
10
+      to_char(createtime + 3 / 24, 'yyyy-mm-dd HH24:MI:SS') zxsj,
11
+      a.method gnmc
12
+	 from lsreport_ts:loginfo a 
13
+	 left join depot:user_info b on b.user_id=a.userid
14
+	 where 1=1
15
+	 <if test="rzlx=='0'">
16
+	 and a.module='登录' 
17
+	 </if>
18
+	 <if test="rzlx=='1'">
19
+	 and a.module!='登录' 
20
+	 </if>
21
+	 <if test="gnmc != null">
22
+	 and a.method like #{gnmc, jdbcType=VARCHAR}
23
+	 </if>
24
+	 <if test="fwstartTime != null">
25
+	 and a.createtime >= #{fwstartTime, jdbcType=TIMESTAMP}
26
+	 </if>
27
+	 <if test="fwendDate != null">
28
+	 and a.createtime &lt;= #{fwendDate, jdbcType=TIMESTAMP}
29
+	 </if>
30
+	 <if test="yhmc != null">
31
+	 and b.real_name like #{yhmc, jdbcType=VARCHAR}
32
+	 </if>
33
+	 order by a.createtime desc
34
+  </select>
35
+</mapper>

+ 78 - 0
src/main/java/com/chinaitop/agile/model/Loginfo.java

@@ -0,0 +1,78 @@
1
+package com.chinaitop.agile.model;
2
+
3
+import io.swagger.annotations.ApiModelProperty;
4
+
5
+/**
6
+ * 出入库日志
7
+ * @author fanxw
8
+ *
9
+ */
10
+public class Loginfo {
11
+
12
+	@ApiModelProperty(value = "用户账号")
13
+	private String yhzh;
14
+
15
+	@ApiModelProperty(value = "用户名称")
16
+	private String yhmc;
17
+
18
+	@ApiModelProperty(value = "用户IP")
19
+	private String yhip;
20
+
21
+	@ApiModelProperty(value = "访问时间")
22
+	private String fwsj;
23
+
24
+	@ApiModelProperty(value = "注销时间")
25
+	private String zxsj;
26
+
27
+	@ApiModelProperty(value = "功能名称")
28
+	private String gnmc;
29
+
30
+	public String getYhzh() {
31
+		return yhzh;
32
+	}
33
+
34
+	public void setYhzh(String yhzh) {
35
+		this.yhzh = yhzh;
36
+	}
37
+
38
+	public String getYhmc() {
39
+		return yhmc;
40
+	}
41
+
42
+	public void setYhmc(String yhmc) {
43
+		this.yhmc = yhmc;
44
+	}
45
+
46
+	public String getYhip() {
47
+		return yhip;
48
+	}
49
+
50
+	public void setYhip(String yhip) {
51
+		this.yhip = yhip;
52
+	}
53
+
54
+	public String getDlsj() {
55
+		return fwsj;
56
+	}
57
+
58
+	public void setFwsj(String fwsj) {
59
+		this.fwsj = fwsj;
60
+	}
61
+
62
+	public String getZxsj() {
63
+		return zxsj;
64
+	}
65
+
66
+	public void setZxsj(String zxsj) {
67
+		this.zxsj = zxsj;
68
+	}
69
+
70
+	public String getGnmc() {
71
+		return gnmc;
72
+	}
73
+
74
+	public void setGnmc(String gnmc) {
75
+		this.gnmc = gnmc;
76
+	}
77
+
78
+}

+ 10 - 0
src/main/java/com/chinaitop/agile/service/LoginfoService.java

@@ -0,0 +1,10 @@
1
+package com.chinaitop.agile.service;
2
+
3
+import java.util.List;
4
+
5
+import com.chinaitop.agile.model.Loginfo;
6
+
7
+public interface LoginfoService {
8
+
9
+	List<Loginfo> quaryList(String rzlx, String gnmc, String fwstartTime, String fwendDate, String yhmc) throws Exception;
10
+}

+ 45 - 0
src/main/java/com/chinaitop/agile/service/impl/LoginfoServiceImpl.java

@@ -0,0 +1,45 @@
1
+package com.chinaitop.agile.service.impl;
2
+
3
+import java.util.HashMap;
4
+import java.util.List;
5
+import java.util.Map;
6
+
7
+import javax.annotation.Resource;
8
+
9
+import org.apache.commons.lang3.StringUtils;
10
+import org.springframework.stereotype.Service;
11
+
12
+import com.chinaitop.agile.mapper.LoginfoMapper;
13
+import com.chinaitop.agile.model.Loginfo;
14
+import com.chinaitop.agile.service.LoginfoService;
15
+import com.chinaitop.agile.utils.ParameterUtil;
16
+
17
+@Service
18
+public class LoginfoServiceImpl implements LoginfoService {
19
+
20
+	@Resource
21
+	private LoginfoMapper loginfoMapper;
22
+
23
+	@Override
24
+	public List<Loginfo> quaryList(String rzlx, String gnmc, String fwstartTime, String fwendDate, String yhmc) throws Exception {
25
+		Map<String, Object> map = new HashMap<>();
26
+		if (StringUtils.isNotBlank(rzlx)) {
27
+			map.put("rzlx", rzlx);
28
+		}
29
+		if (StringUtils.isNotBlank(gnmc)) {
30
+			map.put("gnmc", "%"+gnmc+"%");
31
+		}
32
+		if (StringUtils.isNotBlank(fwstartTime)) {
33
+			map.put("fwstartTime", ParameterUtil.string2datetime(fwstartTime));
34
+		}
35
+		if (StringUtils.isNotBlank(fwendDate)) {
36
+			map.put("fwendDate", ParameterUtil.string2datetime(fwendDate));
37
+		}
38
+		if (StringUtils.isNotBlank(yhmc)) {
39
+			map.put("yhmc", "%"+yhmc+"%");
40
+		}
41
+		return loginfoMapper.quaryList(map);
42
+	}
43
+	
44
+	
45
+}

+ 6 - 2
src/main/resources/bootstrap.yml

@@ -3,6 +3,10 @@ server:
3 3
   tomcat:
4 4
     uri-encoding: utf-8
5 5
 
6
+#是否开启swaggeer? true开启,false关闭,生产环境要求关闭
7
+swagger:
8
+  enable: true
9
+
6 10
 # 注册中心配置
7 11
 eureka:
8 12
   client:
@@ -10,6 +14,7 @@ eureka:
10 14
       defaultZone: http://tj_admin:Admin_1234@${eureka.instance.hostname}:9001/eureka/
11 15
   instance:
12 16
     hostname: 172.16.0.16
17
+    #hostname: localhost
13 18
     #prefer-ip-address: true
14 19
     # 每隔10s发送一次心跳(默认30s)
15 20
     lease-renewal-interval-in-seconds: 10
@@ -25,7 +30,6 @@ management:
25 30
     port: -1
26 31
 
27 32
 spring:
28
-  #profiles: local
29 33
   application:
30 34
     name: depot-agile
31 35
   # 数据库配置
@@ -37,7 +41,7 @@ spring:
37 41
     username: gbasedbt
38 42
     password: cDbK2S0go8
39 43
     #政务云数据库
40
-    #url: jdbc:gbasedbt-sqli://10.223.3.63:9088/lsreport_ts:INFORMIXSERVER=gbaseserver;NEWCODESET=GBK,8859-1,819;GL_USEGLU=1;IFX_USE_STRENC=true;characterEncoding=utf8;
44
+    #url: jdbc:gbasedbt-sqli://200.2.68.230:9088/lsreport_ts:INFORMIXSERVER=gbaseserver;NEWCODESET=GBK,8859-1,819;GL_USEGLU=1;IFX_USE_STRENC=true;characterEncoding=utf8;
41 45
     #username: gbasedbt
42 46
     #password: 4E7#8x8Yut
43 47