张延森 3 yıl önce
ebeveyn
işleme
0bfeab7659

+ 6
- 0
README.md Dosyayı Görüntüle

@@ -0,0 +1,6 @@
1
+### 说明
2
+
3
+本项目把所有依赖放到了 libs 目录
4
+配置文件放到了 config 目录
5
+
6
+启动命令 java -Dloader.path=./libs -jar gnyy.xxx.jar

+ 58
- 0
deploy/bootstrap.sh Dosyayı Görüntüle

@@ -0,0 +1,58 @@
1
+#!/bin/sh
2
+#
3
+#
4
+source /etc/profile
5
+
6
+PROC_STR="gnyy-v"
7
+SERVICE_HOME="/home/xlk/marketing-cloud/service"
8
+LOG="$SERVICE_HOME/logs/service.log"
9
+JAR=$(ls -lt ${SERVICE_HOME}/*.jar|head -n1|rev|cut -d" " -f1|rev)
10
+LIBS="$SERVICE_HOME/libs"
11
+
12
+start() {
13
+    PID=`ps -ef|grep $PROC_STR|grep -v grep|awk '{print $2}'`
14
+    if [[ "$PID" != "" ]]; then
15
+        echo ""
16
+        echo "Service is running. pid=$PID"
17
+        echo ""
18
+        exit 0
19
+    else
20
+        echo ""
21
+        echo "Start service ..."
22
+        echo "FILE: $JAR"
23
+
24
+        nohup java -Dloader.path=$LIBS -jar $JAR > $LOG 2>&1 &
25
+
26
+        echo "Start finished"
27
+        echo "Pls goto $LOG see process status"
28
+        echo ""
29
+    fi
30
+}
31
+
32
+stop() {
33
+    echo ""
34
+    echo "Stoping service ..."
35
+
36
+    PID=`ps -ef|grep $PROC_STR|grep -v grep|awk '{print $2}'`
37
+    if [[ "$PID" != "" ]]; then
38
+        kill -9 $PID
39
+    fi
40
+
41
+    # 这个延迟不能去掉
42
+    sleep 2s
43
+    echo "Service is stoped"
44
+    echo ""
45
+}
46
+
47
+case $1 in
48
+    "start")
49
+        start ;;
50
+    "stop")
51
+        stop ;;
52
+    "reload"|"restart")
53
+        stop
54
+        start ;;
55
+    *)
56
+        echo "Usage: `basename $0` {start|stop|restart}"
57
+        exit 1
58
+esac

+ 13
- 0
deploy/gnyy.service Dosyayı Görüntüle

@@ -0,0 +1,13 @@
1
+[Unit]
2
+Description=marketing
3
+After=mysqld.target
4
+
5
+[Service]
6
+Type=forking
7
+ExecStart=/home/xlk/marketing-cloud/service/service.sh start
8
+ExecReload=/home/xlk/marketing-cloud/service/service.sh restart
9
+ExecStop=/home/xlk/marketing-cloud/service/service.sh stop
10
+PrivateTmp=true
11
+
12
+[Install]
13
+WantedBy=multi-user.target

+ 37
- 0
pom.xml Dosyayı Görüntüle

@@ -177,9 +177,46 @@
177 177
 						<artifactId>spring-boot-maven-plugin</artifactId>
178 178
 						<configuration>
179 179
 							<includeSystemScope>true</includeSystemScope>
180
+
181
+							<!-- 以下为减少依赖 -->
182
+							<layout>ZIP</layout>
183
+							<includes>
184
+<!--								<include>-->
185
+<!--									<groupId>nothing</groupId>-->
186
+<!--									<artifactId>nothing</artifactId>-->
187
+<!--								</include>-->
188
+								<include>
189
+									<groupId>com.yunzhi</groupId>
190
+									<artifactId>gnyy</artifactId>
191
+								</include>
192
+							</includes>
180 193
 						</configuration>
181 194
 					</plugin>
182 195
 
196
+					<!-- 拷贝依赖 -->
197
+					<plugin>
198
+						<groupId>org.apache.maven.plugins</groupId>
199
+						<artifactId>maven-dependency-plugin</artifactId>
200
+						<executions>
201
+							<execution>
202
+								<id>copy</id>
203
+								<phase>package</phase>
204
+								<goals>
205
+									<goal>copy-dependencies</goal>
206
+								</goals>
207
+								<configuration>
208
+									<excludeGroupIds>
209
+										com.yunzhi
210
+									</excludeGroupIds>
211
+									<excludeArtifactIds>
212
+										gnyy
213
+									</excludeArtifactIds>
214
+									<outputDirectory>${project.build.directory}/libs</outputDirectory>
215
+								</configuration>
216
+							</execution>
217
+						</executions>
218
+					</plugin>
219
+
183 220
 					<!-- 跳过测试 -->
184 221
 					<plugin>
185 222
 						<groupId>org.apache.maven.plugins</groupId>

+ 2
- 2
src/main/java/com/yunzhi/gnyy/common/BaseController.java Dosyayı Görüntüle

@@ -12,10 +12,10 @@ import org.springframework.stereotype.Component;
12 12
 public class BaseController {
13 13
 
14 14
     @Autowired
15
-    IWxUserService iWxUserService;
15
+    protected IWxUserService iWxUserService;
16 16
 
17 17
     @Autowired
18
-    ITaPersonService iTaPersonService;
18
+    protected ITaPersonService iTaPersonService;
19 19
 
20 20
     public String getLoginId() {
21 21
         return StpUtil.getLoginIdAsString();

+ 6
- 1
src/main/java/com/yunzhi/gnyy/common/HttpUtils.java Dosyayı Görüntüle

@@ -1,5 +1,6 @@
1 1
 package com.yunzhi.gnyy.common;
2 2
 
3
+import lombok.extern.slf4j.Slf4j;
3 4
 import org.springframework.http.*;
4 5
 import org.springframework.stereotype.Component;
5 6
 import org.springframework.web.client.RestTemplate;
@@ -8,9 +9,11 @@ import java.io.UnsupportedEncodingException;
8 9
 import java.net.URLDecoder;
9 10
 import java.util.*;
10 11
 
12
+@Slf4j
11 13
 @Component
12 14
 public class HttpUtils {
13 15
     public String get(String url) throws Exception {
16
+        log.info("请求地址: ", url);
14 17
         RestTemplate restTemplate = new RestTemplate();
15 18
         HttpHeaders headers = new HttpHeaders();
16 19
         headers.setAccept(Arrays.asList(MediaType.APPLICATION_JSON));
@@ -21,7 +24,9 @@ public class HttpUtils {
21 24
         Map<String, String> params = (Map<String, String>) urlAndParams.get("params");
22 25
 
23 26
         ResponseEntity<String> resp = restTemplate.exchange(formatURL, HttpMethod.GET, entity, String.class, params);
24
-        return resp.getBody();
27
+        String res = resp.getBody();
28
+        log.info("请求结果: ", res);
29
+        return res;
25 30
     }
26 31
 
27 32
     public String post(String url, Map<String, String> header, String body) throws Exception {

+ 4
- 6
src/main/java/com/yunzhi/gnyy/config/SaTokenConfigure.java Dosyayı Görüntüle

@@ -18,13 +18,11 @@ public class SaTokenConfigure implements WebMvcConfigurer {
18 18
     public void addInterceptors(InterceptorRegistry registry) {
19 19
 
20 20
         List<String> anonList = new ArrayList<>();
21
-        anonList.add("/wxpay/notify/**");
22
-        anonList.add("/**/sms-captcha");
23
-        anonList.add("/**/**/sms-captcha");
24
-        anonList.add("/**/preload");
21
+        anonList.add("/swagger-ui/**");
22
+        anonList.add("/swagger-resources/**");
23
+        anonList.add("/v2/**");
24
+        anonList.add("/wx/preload");
25 25
         anonList.add("/**/login");
26
-        anonList.add("/**/**/login");
27
-        anonList.add("/**/**/login");
28 26
 
29 27
         // 注册Sa-Token的路由拦截器
30 28
         registry.addInterceptor(new SaRouteInterceptor())

+ 38
- 28
src/main/java/com/yunzhi/gnyy/controller/TaPersonController.java Dosyayı Görüntüle

@@ -1,11 +1,9 @@
1 1
 package com.yunzhi.gnyy.controller;
2 2
 
3
-import com.yunzhi.gnyy.common.BaseController;
4
-import com.yunzhi.gnyy.common.Constants;
5
-import com.yunzhi.gnyy.common.ResponseBean;
6
-import com.yunzhi.gnyy.common.StringUtils;
3
+import com.yunzhi.gnyy.common.*;
7 4
 import com.yunzhi.gnyy.entity.SysSetting;
8 5
 import com.yunzhi.gnyy.entity.TaPerson;
6
+import com.yunzhi.gnyy.entity.WxUser;
9 7
 import com.yunzhi.gnyy.service.ISysSettingService;
10 8
 import io.swagger.annotations.Api;
11 9
 import io.swagger.annotations.ApiOperation;
@@ -13,11 +11,10 @@ import io.swagger.annotations.ApiParam;
13 11
 import org.slf4j.Logger;
14 12
 import org.slf4j.LoggerFactory;
15 13
 import org.springframework.beans.factory.annotation.Autowired;
16
-import org.springframework.web.bind.annotation.PathVariable;
17
-import org.springframework.web.bind.annotation.RequestMapping;
18
-import org.springframework.web.bind.annotation.RequestMethod;
14
+import org.springframework.web.bind.annotation.*;
19 15
 import com.yunzhi.gnyy.service.ITaPersonService;
20
-import org.springframework.web.bind.annotation.RestController;
16
+
17
+import java.time.LocalDateTime;
21 18
 
22 19
 /**
23 20
  * <p>
@@ -36,7 +33,7 @@ public class TaPersonController extends BaseController {
36 33
     private final Logger logger = LoggerFactory.getLogger(TaPersonController.class);
37 34
 
38 35
     @Autowired
39
-    public ITaPersonService iTaPersonService;
36
+    public HttpUtils httpUtils;
40 37
 
41 38
     @Autowired
42 39
     public ISysSettingService iSysSettingService;
@@ -91,23 +88,31 @@ public class TaPersonController extends BaseController {
91 88
 //        }
92 89
 //    }
93 90
 //
94
-//    /**
95
-//     * 修改对象
96
-//     * @param id  实体ID
97
-//     * @param taPerson 实体对象
98
-//     * @return
99
-//     */
100
-//    @RequestMapping(value="/taPerson/{id}",method= RequestMethod.PUT)
101
-//    @ApiOperation(value="更新", notes = "更新", httpMethod = "PUT", response = ResponseBean.class)
102
-//    public ResponseBean taPersonUpdate(@ApiParam("对象ID") @PathVariable Integer id,
103
-//                                        @ApiParam("更新内容") @RequestBody TaPerson taPerson) throws Exception{
104
-//
105
-//        if (iTaPersonService.updateById(taPerson)){
106
-//            return ResponseBean.success(iTaPersonService.getById(id));
107
-//        }else {
108
-//            return ResponseBean.error("修改失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
109
-//        }
110
-//    }
91
+    /**
92
+     * 修改对象
93
+     * @param id  实体ID
94
+     * @param taPerson 实体对象
95
+     * @return
96
+     */
97
+    @RequestMapping(value="/wx/{clientId}/person",method= RequestMethod.PUT)
98
+    @ApiOperation(value="更新", notes = "更新", httpMethod = "PUT", response = ResponseBean.class)
99
+    public ResponseBean taPersonUpdate(@ApiParam("更新内容") @RequestBody TaPerson taPerson) throws Exception{
100
+
101
+        // TODO 暂未校验 taPerson 各个必填字段
102
+
103
+        WxUser wxUser = currentWxUser();
104
+        if (StringUtils.isEmpty(wxUser.getPersonId())) {
105
+            taPerson.setPersonId(null);
106
+            iTaPersonService.save(taPerson);
107
+            wxUser.setPersonId(taPerson.getPersonId());
108
+            iWxUserService.updateById(wxUser);
109
+        } else {
110
+            taPerson.setPersonId(wxUser.getPersonId());
111
+            iTaPersonService.updateById(taPerson);
112
+        }
113
+
114
+        return ResponseBean.success(taPerson);
115
+    }
111 116
 //
112 117
 //    /**
113 118
 //     * 根据id查询对象
@@ -131,9 +136,14 @@ public class TaPersonController extends BaseController {
131 136
             return ResponseBean.error("人员不存在");
132 137
         }
133 138
 
139
+        String today = DateUtils.toString(LocalDateTime.now(), "yyyy-MM-dd");
140
+
134 141
         SysSetting sysSetting = iSysSettingService.getById(Constants.SETTING_BARCODE_URL);
135
-        String url = sysSetting.getContent() + "?id_no=" + StringUtils.urlEncode(taPerson.getIdNo());
142
+        String url = String.format("%s?createDate=%s&idNo=%s",
143
+                sysSetting.getContent(),
144
+                StringUtils.urlEncode(today),
145
+                StringUtils.urlEncode(taPerson.getIdNo()));
136 146
 
137
-        return ResponseBean.success(iTaPersonService.getById(id));
147
+        return ResponseBean.success(httpUtils.get(url));
138 148
     }
139 149
 }

+ 8
- 5
src/main/java/com/yunzhi/gnyy/controller/WxMaController.java Dosyayı Görüntüle

@@ -6,8 +6,10 @@ import cn.binarywang.wx.miniapp.bean.WxMaPhoneNumberInfo;
6 6
 import cn.binarywang.wx.miniapp.bean.WxMaUserInfo;
7 7
 import cn.dev33.satoken.stp.StpUtil;
8 8
 import com.yunzhi.gnyy.common.*;
9
+import com.yunzhi.gnyy.entity.BdsOrganization;
9 10
 import com.yunzhi.gnyy.entity.TaPerson;
10 11
 import com.yunzhi.gnyy.entity.WxUser;
12
+import com.yunzhi.gnyy.service.IBdsOrganizationService;
11 13
 import com.yunzhi.gnyy.service.ITaPersonService;
12 14
 import com.yunzhi.gnyy.service.IWxUserService;
13 15
 import com.yunzhi.gnyy.vo.LoginParam;
@@ -28,13 +30,10 @@ import java.util.Map;
28 30
 public class WxMaController extends BaseController {
29 31
 
30 32
     @Autowired
31
-    ITaPersonService iTaPersonService;
32
-
33
-    @Autowired
34
-    IWxUserService iWxUserService;
33
+    WxUtils wxUtils;
35 34
 
36 35
     @Autowired
37
-    WxUtils wxUtils;
36
+    IBdsOrganizationService iBdsOrganizationService;
38 37
 
39 38
     private boolean checkLoginParam(LoginParam loginParam) {
40 39
         return !StringUtils.isEmpty(loginParam.getCode())
@@ -83,6 +82,10 @@ public class WxMaController extends BaseController {
83 82
         TaPerson taPerson = null;
84 83
         if (!StringUtils.isEmpty(wxUser.getPersonId())) {
85 84
             taPerson = iTaPersonService.getExistBy("person_id", wxUser.getPersonId(), false, true);
85
+            if (null != taPerson && !StringUtils.isEmpty(taPerson.getDeptCode())) {
86
+                BdsOrganization org = iBdsOrganizationService.getById(taPerson.getDeptCode());
87
+                taPerson.setDeptName(org.getName());
88
+            }
86 89
         }
87 90
 
88 91
         StpUtil.login(wxUser.getUserId(), "wx");

+ 7
- 2
src/main/java/com/yunzhi/gnyy/entity/TaPerson.java Dosyayı Görüntüle

@@ -2,6 +2,8 @@ package com.yunzhi.gnyy.entity;
2 2
 
3 3
 import com.baomidou.mybatisplus.annotation.IdType;
4 4
 import java.time.LocalDateTime;
5
+
6
+import com.baomidou.mybatisplus.annotation.TableField;
5 7
 import com.baomidou.mybatisplus.annotation.TableId;
6 8
 import java.io.Serializable;
7 9
 import io.swagger.annotations.ApiModel;
@@ -39,8 +41,8 @@ public class TaPerson implements Serializable {
39 41
     @ApiModelProperty(value = "身份证号码")
40 42
     private String idNo;
41 43
 
42
-    @ApiModelProperty(value = "科室名称")
43
-    private String deptName;
44
+    @ApiModelProperty(value = "科室编码")
45
+    private String deptCode;
44 46
 
45 47
     @ApiModelProperty(value = "状态")
46 48
     private Integer status;
@@ -48,5 +50,8 @@ public class TaPerson implements Serializable {
48 50
     @ApiModelProperty(value = "创建时间")
49 51
     private LocalDateTime createDate;
50 52
 
53
+    @TableField(exist = false)
54
+    @ApiModelProperty(value = "科室名称")
55
+    private String deptName;
51 56
 
52 57
 }

+ 4
- 1
src/main/resources/application-prod.yml Dosyayı Görüntüle

@@ -1,3 +1,6 @@
1
+server:
2
+  port: 8081
3
+
1 4
 ###
2 5
 spring:
3 6
   servlet:
@@ -5,7 +8,7 @@ spring:
5 8
       max-file-size: 10MB
6 9
       max-request-size: 50MB
7 10
   datasource:
8
-    url: jdbc:mysql://110.40.183.156:3306/lyg_gnyy?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8&useSSL=false&allowPublicKeyRetrieval=true
11
+    url: jdbc:mysql://127.0.0.1:3306/lyg_gnyy?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8&useSSL=false&allowPublicKeyRetrieval=true
9 12
     username: lyg_gnyy
10 13
     password: gnyy@ABCD1234
11 14
 

+ 2
- 2
src/main/resources/application.yml Dosyayı Görüntüle

@@ -33,8 +33,8 @@ mybatis-plus:
33 33
 ###
34 34
 weixin:
35 35
   miniapp:
36
-    appid: wxd6f47a9bb3052175
37
-    secret: 28f33b6bbc0f778c11a0bb234a7d6d4e
36
+    appid: wx835627a9b9b3932a
37
+    secret: 51cc2b26c1628ae098f05a3ba8e6f6f4
38 38
     token:
39 39
     aesKey:
40 40
     msgDataFormat: JSON