Commit b537495df3c9a98a45847d5573a41cb86c3354ab
1 parent
3bc07178
Exists in
master
微耕
Showing
20 changed files
with
1845 additions
and
77 deletions
Show diff stats
cloud/weigeng/pom.xml
... | ... | @@ -22,7 +22,7 @@ |
22 | 22 | <dependency> |
23 | 23 | <groupId>com.sincere</groupId> |
24 | 24 | <artifactId>common</artifactId> |
25 | - <version>1.0.0</version> | |
25 | + <version>0.0.1-SNAPSHOT</version> | |
26 | 26 | </dependency> |
27 | 27 | <dependency> |
28 | 28 | <groupId>org.apache.mina</groupId> |
... | ... | @@ -81,87 +81,15 @@ |
81 | 81 | </dependencyManagement> |
82 | 82 | |
83 | 83 | <build> |
84 | - <!--打包文件名--> | |
85 | - <finalName>weigeng</finalName> | |
86 | - <!--打包方式--> | |
87 | 84 | <plugins> |
88 | - <!-- 设置编译版本 --> | |
89 | 85 | <plugin> |
90 | - <groupId>org.apache.maven.plugins</groupId> | |
91 | - <artifactId>maven-compiler-plugin</artifactId> | |
92 | - <version>3.1</version> | |
86 | + <groupId>org.springframework.boot</groupId> | |
87 | + <artifactId>spring-boot-maven-plugin</artifactId> | |
93 | 88 | <configuration> |
94 | - <source>1.8</source> | |
95 | - <target>1.8</target> | |
96 | - <encoding>UTF-8</encoding> | |
89 | + <includeSystemScope>true</includeSystemScope> | |
97 | 90 | </configuration> |
98 | 91 | </plugin> |
99 | - <!-- 打包jar文件时,配置manifest文件,加入lib包的jar依赖 --> | |
100 | - <!-- 本地启动需要注释--> | |
101 | - <plugin> | |
102 | - <groupId>org.apache.maven.plugins</groupId> | |
103 | - <artifactId>maven-jar-plugin</artifactId> | |
104 | - <configuration> | |
105 | - <archive> | |
106 | - <manifest> | |
107 | - <mainClass>com.com.sincere.weigeng.WeigengApplication</mainClass> | |
108 | - <addClasspath>true</addClasspath> | |
109 | - <classpathPrefix>lib/</classpathPrefix> | |
110 | - </manifest> | |
111 | - <manifestEntries> | |
112 | - <Class-Path>./config/</Class-Path> | |
113 | - </manifestEntries> | |
114 | - </archive> | |
115 | - <excludes> | |
116 | - <exclude>config/**</exclude> | |
117 | - </excludes> | |
118 | - <classesDirectory></classesDirectory> | |
119 | - </configuration> | |
120 | - </plugin> | |
121 | - <!-- 拷贝依赖的jar包到lib目录 --> | |
122 | - <plugin> | |
123 | - <groupId>org.apache.maven.plugins</groupId> | |
124 | - <artifactId>maven-dependency-plugin</artifactId> | |
125 | - <executions> | |
126 | - <execution> | |
127 | - <id>copy</id> | |
128 | - <phase>package</phase> | |
129 | - <goals> | |
130 | - <goal>copy-dependencies</goal> | |
131 | - </goals> | |
132 | - <configuration> | |
133 | - <outputDirectory> | |
134 | - ${project.build.directory}/lib | |
135 | - </outputDirectory> | |
136 | - </configuration> | |
137 | - </execution> | |
138 | - </executions> | |
139 | - </plugin> | |
140 | - <!-- 解决资源文件的编码问题 --> | |
141 | - <plugin> | |
142 | - <groupId>org.apache.maven.plugins</groupId> | |
143 | - <artifactId>maven-resources-plugin</artifactId> | |
144 | - <version>2.5</version> | |
145 | - <configuration> | |
146 | - <encoding>UTF-8</encoding> | |
147 | - </configuration> | |
148 | - </plugin> | |
149 | - <!-- 打包source文件为jar文件 --> | |
150 | - <plugin> | |
151 | - <artifactId>maven-source-plugin</artifactId> | |
152 | - <version>2.2</version> | |
153 | - <configuration> | |
154 | - <attach>true</attach> | |
155 | - </configuration> | |
156 | - <executions> | |
157 | - <execution> | |
158 | - <phase>compile</phase> | |
159 | - <goals> | |
160 | - <goal>jar</goal> | |
161 | - </goals> | |
162 | - </execution> | |
163 | - </executions> | |
164 | - </plugin> | |
92 | + | |
165 | 93 | </plugins> |
166 | 94 | </build> |
167 | 95 | ... | ... |
cloud/weigeng/src/main/java/com/sincere/weigeng/Swagger2.java
0 → 100644
... | ... | @@ -0,0 +1,38 @@ |
1 | +package com.sincere.weigeng; | |
2 | + | |
3 | +import io.swagger.annotations.ApiOperation; | |
4 | +import org.springframework.context.annotation.Bean; | |
5 | +import org.springframework.context.annotation.Configuration; | |
6 | +import springfox.documentation.builders.ApiInfoBuilder; | |
7 | +import springfox.documentation.builders.PathSelectors; | |
8 | +import springfox.documentation.builders.RequestHandlerSelectors; | |
9 | +import springfox.documentation.service.ApiInfo; | |
10 | +import springfox.documentation.spi.DocumentationType; | |
11 | +import springfox.documentation.spring.web.plugins.Docket; | |
12 | +import springfox.documentation.swagger2.annotations.EnableSwagger2; | |
13 | + | |
14 | +@EnableSwagger2 | |
15 | +@Configuration //让Spring来加载该类配置 | |
16 | +public class Swagger2 { | |
17 | + | |
18 | + @Bean | |
19 | + public Docket createRestApi() { | |
20 | + return new Docket(DocumentationType.SWAGGER_2) | |
21 | + .apiInfo(apiInfo()) | |
22 | + .enableUrlTemplating(true) | |
23 | + .select() | |
24 | + // 扫描所有有注解的api,用这种方式更灵活 | |
25 | + .apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class)) | |
26 | + .paths(PathSelectors.any()) | |
27 | + .build(); | |
28 | + | |
29 | + } | |
30 | + private ApiInfo apiInfo() { | |
31 | + return new ApiInfoBuilder() | |
32 | + .title("Spring Boot中使用Swagger2构建RESTful APIs") | |
33 | + .description("接口文档") | |
34 | + .termsOfServiceUrl("") | |
35 | + .version("1.0") | |
36 | + .build(); | |
37 | + } | |
38 | +} | ... | ... |
cloud/weigeng/src/main/java/com/sincere/weigeng/WeigengApplication.java
1 | 1 | package com.sincere.weigeng; |
2 | 2 | |
3 | +import com.sincere.weigeng.utils.WatchServer; | |
3 | 4 | import org.springframework.boot.SpringApplication; |
4 | 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; |
5 | 6 | import org.springframework.cloud.netflix.eureka.EnableEurekaClient; |
... | ... | @@ -10,8 +11,12 @@ import org.springframework.cloud.openfeign.EnableFeignClients; |
10 | 11 | @SpringBootApplication |
11 | 12 | public class WeigengApplication { |
12 | 13 | |
14 | + private static String ip = "172.16.3.175"; | |
15 | + private static int port = 1200; | |
16 | + | |
13 | 17 | public static void main(String[] args) { |
14 | 18 | SpringApplication.run(WeigengApplication.class, args); |
19 | + //WatchServer.WatchingServerRunning(ip,port); | |
15 | 20 | } |
16 | 21 | |
17 | 22 | } | ... | ... |
cloud/weigeng/src/main/java/com/sincere/weigeng/controller/WgController.java
0 → 100644
... | ... | @@ -0,0 +1,220 @@ |
1 | +package com.sincere.weigeng.controller; | |
2 | + | |
3 | +import com.sincere.common.dto.smartCampus.SchoolDto; | |
4 | +import com.sincere.common.dto.smartCampus.StudentCardDto; | |
5 | +import com.sincere.common.dto.smartCampus.UpdateCardDto; | |
6 | +import com.sincere.common.dto.smartCampus.UserDto; | |
7 | +import com.sincere.common.dto.xiaoan.SendFailDto; | |
8 | +import com.sincere.common.dto.xiaoan.SendMessageDto; | |
9 | +import com.sincere.common.dto.xiaoan.SendSuccessDto; | |
10 | +import com.sincere.weigeng.feign.SmFeign; | |
11 | +import com.sincere.weigeng.feign.XaFeign; | |
12 | +import com.sincere.weigeng.logs.LogName; | |
13 | +import com.sincere.weigeng.logs.LoggerUtils; | |
14 | +import com.sincere.weigeng.utils.WatchServer; | |
15 | +import com.sincere.weigeng.vo.*; | |
16 | +import io.swagger.annotations.Api; | |
17 | +import io.swagger.annotations.ApiOperation; | |
18 | +import org.slf4j.Logger; | |
19 | +import org.springframework.beans.factory.annotation.Autowired; | |
20 | +import org.springframework.web.bind.annotation.RequestBody; | |
21 | +import org.springframework.web.bind.annotation.RequestMapping; | |
22 | +import org.springframework.web.bind.annotation.RequestMethod; | |
23 | +import org.springframework.web.bind.annotation.RestController; | |
24 | + | |
25 | +import java.util.List; | |
26 | + | |
27 | +/** | |
28 | + * @author chen | |
29 | + * @version 1.0 | |
30 | + * @date 2019/10/14 0014 9:12 | |
31 | + */ | |
32 | +@RestController | |
33 | +@Api(value = "微耕") | |
34 | +public class WgController { | |
35 | + | |
36 | + private static final Logger Log_orderSuccess = LoggerUtils.Logger(LogName.orderSuccess); | |
37 | + private static final Logger Log_orderFail = LoggerUtils.Logger(LogName.orderFail); | |
38 | + | |
39 | + @Autowired | |
40 | + SmFeign smFeign; | |
41 | + | |
42 | + @Autowired | |
43 | + XaFeign xaFeign; | |
44 | + | |
45 | + private static String ip = "172.16.3.175"; | |
46 | + private static int port = 1200; | |
47 | + | |
48 | + @RequestMapping(value = "watching" , method = RequestMethod.GET) | |
49 | + public void watching(){ | |
50 | + WatchServer.WatchingServerRunning(ip,port,smFeign,xaFeign); | |
51 | + } | |
52 | + | |
53 | + @RequestMapping(value = "setTime" , method = RequestMethod.GET) | |
54 | + public void setTime(long sn){ | |
55 | + WatchServer.setTime(xaFeign,sn,"48"); | |
56 | + } | |
57 | + | |
58 | + @ApiOperation("远程开门") | |
59 | + @RequestMapping(value = "openDoor" , method = RequestMethod.POST) | |
60 | + public boolean openDoor(@RequestBody OpenDoorVo openDoorVo) { | |
61 | + String functionId = smFeign.selectOutOrderId(openDoorVo.getType(),openDoorVo.getId()); | |
62 | + long messageId = WatchServer.openDoor(xaFeign,openDoorVo.getSn(),functionId,openDoorVo.getDoorNo(),null); | |
63 | + SendMessageDto message = getResult(messageId); | |
64 | + if(message.getCorrect() == 1){ | |
65 | + Log_orderSuccess.info("web端远程开门成功!"); | |
66 | + }else { | |
67 | + Log_orderFail.info("远程开门失败"); | |
68 | + } | |
69 | + return message.getCorrect() == 1 ; | |
70 | + } | |
71 | + | |
72 | + | |
73 | + @ApiOperation("设置考勤时段") | |
74 | + @RequestMapping(value = "setAttendanceTime" , method = RequestMethod.POST) | |
75 | + public boolean setAttendanceTime(@RequestBody AttendanceTimeVo attendanceTimeVo){ | |
76 | + String functionId = smFeign.selectOutOrderId(attendanceTimeVo.getType(),attendanceTimeVo.getId()); | |
77 | + List<Long> result = WatchServer.SetAttendanceTime(xaFeign,attendanceTimeVo.getSn(),functionId,attendanceTimeVo.getShiduan(), | |
78 | + attendanceTimeVo.getStart(),attendanceTimeVo.getEnd(),attendanceTimeVo.getIsMonday(),attendanceTimeVo.getIsTuesday(), | |
79 | + attendanceTimeVo.getIsWednesday(),attendanceTimeVo.getIsThursday(),attendanceTimeVo.getIsFriday(), | |
80 | + attendanceTimeVo.getIsSaturday(),attendanceTimeVo.getIsWeekend(),attendanceTimeVo.getShiqu()); | |
81 | + boolean isSuccess = true ; | |
82 | + for(Long messageId : result){ | |
83 | + SendMessageDto message = getResult(messageId); | |
84 | + if(message.getCorrect() == 1){ | |
85 | + Log_orderSuccess.info("设备"+attendanceTimeVo.getSn()+"时段"+attendanceTimeVo.getShiduan()+"!!设置成功"); | |
86 | + }else { | |
87 | + Log_orderFail.info("设备"+attendanceTimeVo.getSn()+"时段"+attendanceTimeVo.getShiduan()+"!!设置失败"); | |
88 | + isSuccess = false ; | |
89 | + } | |
90 | + } | |
91 | + return isSuccess; | |
92 | + } | |
93 | + | |
94 | + | |
95 | + @ApiOperation("单个卡号的权限添加或修改") | |
96 | + @RequestMapping(value = "setSignalCardInfo" , method = RequestMethod.POST) | |
97 | + public boolean setSignalCardInfo(@RequestBody SignalCardInfoVo signalCardInfoVo){ | |
98 | + String functionId = smFeign.selectOutOrderId(signalCardInfoVo.getType(),signalCardInfoVo.getId()); | |
99 | + String cardNo = initCardNo(signalCardInfoVo.getCardNo()); | |
100 | + long messageId = WatchServer.SetSignalCardInfo(xaFeign,signalCardInfoVo.getSn(),functionId,cardNo, | |
101 | + signalCardInfoVo.getShiduan(),signalCardInfoVo.getStartTime(),signalCardInfoVo.getEndTime()); | |
102 | + SendMessageDto message = getResult(messageId); | |
103 | + UserDto user = smFeign.selectUserByCardNum(cardNo); | |
104 | + StudentCardDto studentCard = smFeign.selectStudentCard(cardNo); | |
105 | + SchoolDto school = smFeign.selectSchoolBySchoolId(user.getSchoolId()); | |
106 | + UpdateCardDto updateCard = smFeign.selectUpdateCardByUpdateId(signalCardInfoVo.getUpdateId()); | |
107 | + if(message.getCorrect() == 1){ | |
108 | + Log_orderSuccess.info("设备"+signalCardInfoVo.getSn()+"时段"+signalCardInfoVo.getShiduan()+"卡号"+cardNo+"!!设置成功"); | |
109 | + SendSuccessDto sendSuccess = new SendSuccessDto(user,school,studentCard,updateCard); | |
110 | + sendSuccess.setDeviceId(signalCardInfoVo.getSn()+""); | |
111 | + sendSuccess.setShiduan(signalCardInfoVo.getShiduan()); | |
112 | + sendSuccess.setCardNum(cardNo); | |
113 | + sendSuccess.setUpdateId(signalCardInfoVo.getUpdateId()); | |
114 | + sendSuccess.setOpenFlag(1); | |
115 | + sendSuccess.setStatus(1); | |
116 | + xaFeign.insertSendSuccess(sendSuccess); | |
117 | + }else { | |
118 | + Log_orderFail.info("设备"+signalCardInfoVo.getSn()+"时段"+signalCardInfoVo.getShiduan()+"卡号"+cardNo+"!!设置失败"); | |
119 | + SendFailDto sendFail = new SendFailDto(user,school,studentCard,updateCard); | |
120 | + sendFail.setDeviceId(signalCardInfoVo.getSn()+""); | |
121 | + sendFail.setShiduan(signalCardInfoVo.getShiduan()); | |
122 | + sendFail.setCardNum(cardNo); | |
123 | + sendFail.setUpdateId(signalCardInfoVo.getUpdateId()); | |
124 | + sendFail.setOpenFlag(1); | |
125 | + sendFail.setStatus(1); | |
126 | + sendFail.setFailType(2); | |
127 | + sendFail.setFailContent("其他"); | |
128 | + xaFeign.insertSendFail(sendFail); | |
129 | + } | |
130 | + return message.getCorrect() == 1; | |
131 | + } | |
132 | + | |
133 | + | |
134 | + @ApiOperation("清除单个卡号权限") | |
135 | + @RequestMapping(value = "clearSinglePower" , method = RequestMethod.POST) | |
136 | + public boolean clearSinglePower(@RequestBody CardInfo cardInfo){ | |
137 | + String functionId = smFeign.selectOutOrderId(cardInfo.getType(),cardInfo.getId()); | |
138 | + String cardNo = initCardNo(cardInfo.getCardNo()); | |
139 | + long messageId = WatchServer.clearSinglePower(xaFeign,cardInfo.getSn(),functionId,cardNo); | |
140 | + SendMessageDto message = getResult(messageId); | |
141 | + if(message.getCorrect() == 1){ | |
142 | + Log_orderSuccess.info("卡号"+cardNo+"清除权限成功"); | |
143 | + SendSuccessDto sendSuccess = new SendSuccessDto(); | |
144 | + sendSuccess.setCardNum(cardNo); | |
145 | + sendSuccess.setDeviceId(cardInfo.getSn()+""); | |
146 | + xaFeign.updateSendSuccess(sendSuccess); | |
147 | + }else { | |
148 | + Log_orderFail.info("卡号"+cardNo+"清除权限失败"); | |
149 | + } | |
150 | + return message.getCorrect() == 1 ; | |
151 | + } | |
152 | + | |
153 | + @ApiOperation("清除全部权限") | |
154 | + @RequestMapping(value = "clearAllPower" , method = RequestMethod.POST) | |
155 | + public boolean clearAllPower(@RequestBody CleanShiDuanVo cleanShiDuanVo){ | |
156 | + String functionId = smFeign.selectOutOrderId(cleanShiDuanVo.getType(),cleanShiDuanVo.getId()); | |
157 | + long messageId = WatchServer.clearAllPower(xaFeign,cleanShiDuanVo.getSn(),functionId); | |
158 | + SendMessageDto message = getResult(messageId); | |
159 | + if(message.getCorrect() == 1){ | |
160 | + Log_orderSuccess.info("设备"+cleanShiDuanVo.getSn()+"清除权限成功"); | |
161 | + SendSuccessDto sendSuccess = new SendSuccessDto(); | |
162 | + sendSuccess.setDeviceId(cleanShiDuanVo.getSn()+""); | |
163 | + xaFeign.updateSendSuccess(sendSuccess); | |
164 | + }else { | |
165 | + Log_orderFail.info("设备"+cleanShiDuanVo.getSn()+"清除权限失败"); | |
166 | + } | |
167 | + return message.getCorrect() == 1 ; | |
168 | + } | |
169 | + | |
170 | + | |
171 | + @ApiOperation("清除时段") | |
172 | + @RequestMapping(value = "clearShiDuan" , method = RequestMethod.POST) | |
173 | + public boolean clearShiDuan(@RequestBody CleanShiDuanVo cleanShiDuanVo){ | |
174 | + String functionId = smFeign.selectOutOrderId(cleanShiDuanVo.getType(),cleanShiDuanVo.getId()); | |
175 | + long messageId = WatchServer.clearShiDuan(xaFeign,cleanShiDuanVo.getSn(),functionId); | |
176 | + SendMessageDto sendMessage = getResult(messageId); | |
177 | + if(sendMessage.getCorrect() == 1){ | |
178 | + Log_orderSuccess.info("设备"+cleanShiDuanVo.getSn()+"时段清除成功"); | |
179 | + }else { | |
180 | + Log_orderFail.info("设备"+cleanShiDuanVo.getSn()+"时段清除失败"); | |
181 | + } | |
182 | + return sendMessage.getCorrect() == 1; | |
183 | + } | |
184 | + | |
185 | + @ApiOperation("查询单个卡号 权限") | |
186 | + @RequestMapping(value = "searchPower" , method = RequestMethod.POST) | |
187 | + public boolean searchPower(@RequestBody CardInfo cardInfo){ | |
188 | + String functionId = smFeign.selectOutOrderId(cardInfo.getType(),cardInfo.getId()); | |
189 | + String cardNo = initCardNo(cardInfo.getCardNo()); | |
190 | + long messageId = WatchServer.searchPower(xaFeign,cardInfo.getSn(),functionId,cardNo); | |
191 | + SendMessageDto sendMessage = getResult(messageId); | |
192 | + if(sendMessage.getCorrect() == 1){ | |
193 | + Log_orderSuccess.info("设备"+cardInfo.getSn()+"卡号"+cardNo+"查询权限成功"); | |
194 | + }else { | |
195 | + Log_orderFail.info("设备"+cardInfo.getSn()+"卡号"+cardNo+"查询权限失败"); | |
196 | + } | |
197 | + return sendMessage.getCorrect() == 1; | |
198 | + } | |
199 | + | |
200 | + @RequestMapping(value = "watch" , method = RequestMethod.GET) | |
201 | + public int watch(){ | |
202 | + return 1 ; | |
203 | + } | |
204 | + | |
205 | + private SendMessageDto getResult(long messageId){ | |
206 | + try{ | |
207 | + Thread.sleep(300); | |
208 | + }catch (Exception e){ | |
209 | + | |
210 | + } | |
211 | + return xaFeign.selectById(messageId); | |
212 | + } | |
213 | + | |
214 | + private String initCardNo(String cardNo){ | |
215 | + while (cardNo.length() < 8){ | |
216 | + cardNo = "0" + cardNo ; | |
217 | + } | |
218 | + return cardNo ; | |
219 | + } | |
220 | +} | ... | ... |
cloud/weigeng/src/main/java/com/sincere/weigeng/feign/SmFeign.java
0 → 100644
... | ... | @@ -0,0 +1,40 @@ |
1 | +package com.sincere.weigeng.feign; | |
2 | + | |
3 | +import com.sincere.common.dto.smartCampus.SchoolDto; | |
4 | +import com.sincere.common.dto.smartCampus.StudentCardDto; | |
5 | +import com.sincere.common.dto.smartCampus.UpdateCardDto; | |
6 | +import com.sincere.common.dto.smartCampus.UserDto; | |
7 | +import org.springframework.cloud.openfeign.FeignClient; | |
8 | +import org.springframework.web.bind.annotation.RequestMapping; | |
9 | +import org.springframework.web.bind.annotation.RequestMethod; | |
10 | +import org.springframework.web.bind.annotation.RequestParam; | |
11 | + | |
12 | +/** | |
13 | + * @author chen | |
14 | + * @version 1.0 | |
15 | + * @date 2019/11/12 0012 11:08 | |
16 | + */ | |
17 | +@FeignClient("smartCampusSearch") | |
18 | +public interface SmFeign { | |
19 | + | |
20 | + @RequestMapping(value = "/sm/wg/updateLinkTime",method = RequestMethod.GET) | |
21 | + int updateLinkTime(@RequestParam("sno") String sno); | |
22 | + | |
23 | + @RequestMapping(value = "/sm/wg/selectOutOrderId",method = RequestMethod.GET) | |
24 | + String selectOutOrderId(@RequestParam("type") int type, @RequestParam("insideOrderId") int insideOrderId); | |
25 | + | |
26 | + @RequestMapping(value = "/sm/wg/checkLeave",method = RequestMethod.GET) | |
27 | + String checkLeave(@RequestParam("cardNo") String cardNo); | |
28 | + | |
29 | + @RequestMapping(value = "/sm/wg/selectSchoolBySchoolId",method = RequestMethod.GET) | |
30 | + SchoolDto selectSchoolBySchoolId(@RequestParam("schoolId") int schoolId); | |
31 | + | |
32 | + @RequestMapping(value = "/sm/wg/selectUserByCardNum",method = RequestMethod.GET) | |
33 | + UserDto selectUserByCardNum(@RequestParam("cardNum") String cardNum); | |
34 | + | |
35 | + @RequestMapping(value = "/sm/wg/selectUpdateCardByUpdateId",method = RequestMethod.GET) | |
36 | + UpdateCardDto selectUpdateCardByUpdateId(@RequestParam("updateId") int updateId); | |
37 | + | |
38 | + @RequestMapping(value = "/sm/wg/selectStudentCard",method = RequestMethod.GET) | |
39 | + StudentCardDto selectStudentCard(@RequestParam("cardNum") String cardNum); | |
40 | +} | ... | ... |
cloud/weigeng/src/main/java/com/sincere/weigeng/feign/XaFeign.java
0 → 100644
... | ... | @@ -0,0 +1,47 @@ |
1 | +package com.sincere.weigeng.feign; | |
2 | + | |
3 | +import com.sincere.common.dto.xiaoan.*; | |
4 | +import org.springframework.cloud.openfeign.FeignClient; | |
5 | +import org.springframework.web.bind.annotation.RequestBody; | |
6 | +import org.springframework.web.bind.annotation.RequestMapping; | |
7 | +import org.springframework.web.bind.annotation.RequestMethod; | |
8 | +import org.springframework.web.bind.annotation.RequestParam; | |
9 | + | |
10 | +/** | |
11 | + * @author chen | |
12 | + * @version 1.0 | |
13 | + * @date 2019/11/12 0012 11:12 | |
14 | + */ | |
15 | +@FeignClient("xiaoanSearch") | |
16 | +public interface XaFeign { | |
17 | + | |
18 | + @RequestMapping(value = "/xa/wg/checkIn",method = RequestMethod.POST) | |
19 | + CheckOutDto checkIn(@RequestBody CheckInDto checkInDto); | |
20 | + | |
21 | + @RequestMapping(value = "/xa/wg/insertMessage",method = RequestMethod.POST) | |
22 | + long insertMessage(@RequestBody SendMessageDto sendMessageDto); | |
23 | + | |
24 | + @RequestMapping(value = "/xa/wg/selectById",method = RequestMethod.GET) | |
25 | + SendMessageDto selectById(@RequestParam("id") long id); | |
26 | + | |
27 | + @RequestMapping(value = "/xa/wg/selectMessage",method = RequestMethod.GET) | |
28 | + SendMessageDto selectMessage(@RequestParam("deviceId") String deviceId, @RequestParam("index") long index,@RequestParam("functionId") String functionId); | |
29 | + | |
30 | + @RequestMapping(value = "/xa/wg/updateMessage",method = RequestMethod.GET) | |
31 | + int updateMessage(@RequestParam("id") long id, @RequestParam("result") String result, @RequestParam("correct") int correct); | |
32 | + | |
33 | + @RequestMapping(value = "/xa/wg/insertPassFail",method = RequestMethod.POST) | |
34 | + int insertPassFail(@RequestBody PassFailDto passFailDto); | |
35 | + | |
36 | + @RequestMapping(value = "/xa/wg/insertSendSuccess",method = RequestMethod.POST) | |
37 | + int insertSendSuccess(@RequestBody SendSuccessDto sendSuccessDto); | |
38 | + | |
39 | + @RequestMapping(value = "/xa/wg/insertSendFail",method = RequestMethod.POST) | |
40 | + int insertSendFail(@RequestBody SendFailDto sendFailDto); | |
41 | + | |
42 | + @RequestMapping(value = "/xa/wg/deleteSendFail",method = RequestMethod.POST) | |
43 | + int deleteSendFail(@RequestBody SendFailDto sendFailDto); | |
44 | + | |
45 | + @RequestMapping(value = "/xa/wg/deleteSendFail",method = RequestMethod.POST) | |
46 | + int updateSendSuccess(@RequestBody SendSuccessDto sendSuccessDto); | |
47 | +} | ... | ... |
cloud/weigeng/src/main/java/com/sincere/weigeng/logs/LogName.java
0 → 100644
... | ... | @@ -0,0 +1,39 @@ |
1 | +package com.sincere.weigeng.logs; | |
2 | + | |
3 | +/** | |
4 | + * @author chen | |
5 | + * @version 1.0 | |
6 | + * @date 2019/10/12 0012 16:18 | |
7 | + */ | |
8 | +public enum LogName { | |
9 | + orderSuccess("orderSuccess"), | |
10 | + orderFail("orderFail"), | |
11 | + kaoInfo("kaoInfo"), | |
12 | + heartBeat("heartBeat"), | |
13 | + error("error"); | |
14 | + | |
15 | + private String logFileName; | |
16 | + | |
17 | + LogName(String fileName) { | |
18 | + this.logFileName = fileName; | |
19 | + } | |
20 | + | |
21 | + public String getLogFileName() { | |
22 | + return logFileName; | |
23 | + } | |
24 | + | |
25 | + public void setLogFileName(String logFileName) { | |
26 | + this.logFileName = logFileName; | |
27 | + } | |
28 | + | |
29 | + public static LogName getAwardTypeEnum(String value) { | |
30 | + LogName[] arr = values(); | |
31 | + for (LogName item : arr) { | |
32 | + if (null != item && !item.logFileName.equals("")) { | |
33 | + return item; | |
34 | + } | |
35 | + } | |
36 | + return null; | |
37 | + } | |
38 | +} | |
39 | + | ... | ... |
cloud/weigeng/src/main/java/com/sincere/weigeng/logs/LoggerUtils.java
0 → 100644
... | ... | @@ -0,0 +1,27 @@ |
1 | +package com.sincere.weigeng.logs; | |
2 | + | |
3 | +import org.slf4j.Logger; | |
4 | +import org.slf4j.LoggerFactory; | |
5 | + | |
6 | +/** | |
7 | + * @author chen | |
8 | + * @version 1.0 | |
9 | + * @date 2019/10/12 0012 16:19 | |
10 | + */ | |
11 | +public class LoggerUtils { | |
12 | + | |
13 | + public static <T> Logger Logger(Class<T> clazz) { | |
14 | + return LoggerFactory.getLogger(clazz); | |
15 | + } | |
16 | + | |
17 | + /** | |
18 | + * 打印到指定的文件下 | |
19 | + * | |
20 | + * @param desc 日志文件名称 | |
21 | + * @return | |
22 | + */ | |
23 | + public static Logger Logger(LogName desc) { | |
24 | + return LoggerFactory.getLogger(desc.getLogFileName()); | |
25 | + } | |
26 | + | |
27 | +} | ... | ... |
cloud/weigeng/src/main/java/com/sincere/weigeng/logs/MyTimeBasedFileNamingAndTriggeringPolicy.java
0 → 100644
... | ... | @@ -0,0 +1,32 @@ |
1 | +package com.sincere.weigeng.logs; | |
2 | + | |
3 | +import ch.qos.logback.core.joran.spi.NoAutoStart; | |
4 | +import ch.qos.logback.core.rolling.DefaultTimeBasedFileNamingAndTriggeringPolicy; | |
5 | + | |
6 | +/** | |
7 | + * @author chen | |
8 | + * @version 1.0 | |
9 | + * @date 2019/10/31 0031 13:42 | |
10 | + */ | |
11 | +@NoAutoStart | |
12 | +public class MyTimeBasedFileNamingAndTriggeringPolicy<E> extends DefaultTimeBasedFileNamingAndTriggeringPolicy<E> { | |
13 | + | |
14 | + //这个用来指定时间间隔 | |
15 | + private Integer multiple = 1; | |
16 | + | |
17 | + @Override | |
18 | + protected void computeNextCheck() { | |
19 | + nextCheck = rc.getEndOfNextNthPeriod(dateInCurrentPeriod, multiple).getTime(); | |
20 | + } | |
21 | + | |
22 | + public Integer getMultiple() { | |
23 | + return multiple; | |
24 | + } | |
25 | + | |
26 | + public void setMultiple(Integer multiple) { | |
27 | + if (multiple > 1) { | |
28 | + this.multiple = multiple; | |
29 | + } | |
30 | + } | |
31 | + | |
32 | +} | ... | ... |
cloud/weigeng/src/main/java/com/sincere/weigeng/utils/WGUtils.java
0 → 100644
... | ... | @@ -0,0 +1,133 @@ |
1 | +package com.sincere.weigeng.utils; | |
2 | + | |
3 | +/** | |
4 | + * @author chen | |
5 | + * @version 1.0 | |
6 | + * @date 2019/10/14 0014 11:03 | |
7 | + */ | |
8 | +public class WGUtils { | |
9 | + | |
10 | + //指令转换 message 10进制 要先转16 在转byte | |
11 | + public static Byte toFunctionHex(String message){ | |
12 | + Integer i = Integer.valueOf(message) ; | |
13 | + if(i > 127){ | |
14 | + i = i-256 ; | |
15 | + } | |
16 | + return Byte.valueOf(i+""); | |
17 | + } | |
18 | + | |
19 | + //短报文 转化 message 16进制 要先转16 在转byte | |
20 | + public static Byte toHex(String message){ | |
21 | + Integer i = Integer.valueOf(message,16) ; | |
22 | + if(i > 127){ | |
23 | + i = i-256 ; | |
24 | + } | |
25 | + return Byte.valueOf(i+""); | |
26 | + } | |
27 | + | |
28 | + public static String getCardNo(byte[] buff, int start, int len){ | |
29 | + String cardNo = "" ; | |
30 | + for(int i = start ; i < start+len ; i++){ | |
31 | + cardNo += byte2Hex(buff[i]); | |
32 | + } | |
33 | + return cardNo; | |
34 | + } | |
35 | + | |
36 | + public static String byte2Hex(byte b){ | |
37 | + int i = b ; | |
38 | + if( b < 0){ | |
39 | + i = b + 256 ; | |
40 | + } | |
41 | + String result = Integer.toHexString(i).toUpperCase() ; | |
42 | + if(result.length() == 1){ | |
43 | + result = "0"+result; | |
44 | + } | |
45 | + return result; | |
46 | + } | |
47 | + | |
48 | + //4字节转成整型数(低位前, 高位后) | |
49 | + public static int byteToInt(byte[] buff, int start, int len) { | |
50 | + int val = 0; | |
51 | + for (int i = 0; i < len && i < 4; i++) | |
52 | + { | |
53 | + long lng = buff[i + start]; | |
54 | + val += (lng << (8 * i)); | |
55 | + } | |
56 | + return val; | |
57 | + } | |
58 | + | |
59 | + //4字节转成整型数(低位前, 高位后) | |
60 | + public static long byteToLong(byte[] buff, int start, int len) { | |
61 | + long val = 0; | |
62 | + for (int i = 0; i < len && i < 4; i++) | |
63 | + { | |
64 | + long lng = buff[i + start]; | |
65 | + val += (lng << (8 * i)); | |
66 | + } | |
67 | + return val; | |
68 | + } | |
69 | + | |
70 | + //获取Hex值, 主要用于日期时间格式 | |
71 | + public static byte getHex(int val) { | |
72 | + return (byte)((val % 10) + (((val -(val % 10)) / 10)%10) *16); | |
73 | + } | |
74 | + | |
75 | + | |
76 | + public static String getReasonDetailChinese(int Reason){ | |
77 | + if (Reason > 45) { | |
78 | + return ""; | |
79 | + } | |
80 | + if (Reason <= 0) { | |
81 | + return ""; | |
82 | + } | |
83 | + return RecordDetails[(Reason - 1) * 4 + 3]; //中文信息 | |
84 | + } | |
85 | + | |
86 | + public static String RecordDetails[] = { | |
87 | + "1","SwipePass","Swipe","刷卡开门", | |
88 | + "2","SwipePass","Swipe Close","刷卡关", | |
89 | + "3","SwipePass","Swipe Open","刷卡开", | |
90 | + "4","SwipePass","Swipe Limited Times","刷卡开门(带限次)", | |
91 | + "5","SwipeNOPass","Denied Access: PC Control","刷卡禁止通过: 电脑控制", | |
92 | + "6","SwipeNOPass","Denied Access: No PRIVILEGE","刷卡禁止通过: 没有权限", | |
93 | + "7","SwipeNOPass","Denied Access: Wrong PASSWORD","刷卡禁止通过: 密码不对", | |
94 | + "8","SwipeNOPass","Denied Access: AntiBack","刷卡禁止通过: 反潜回", | |
95 | + "9","SwipeNOPass","Denied Access: More Cards","刷卡禁止通过: 多卡", | |
96 | + "10","SwipeNOPass","Denied Access: First Card Open","刷卡禁止通过: 首卡", | |
97 | + "11","SwipeNOPass","Denied Access: Door Set NC","刷卡禁止通过: 门为常闭", | |
98 | + "12","SwipeNOPass","Denied Access: InterLock","刷卡禁止通过: 互锁", | |
99 | + "13","SwipeNOPass","Denied Access: Limited Times","刷卡禁止通过: 受刷卡次数限制", | |
100 | + "14","SwipeNOPass","Denied Access: Limited Person Indoor","刷卡禁止通过: 门内人数限制", | |
101 | + "15","SwipeNOPass","Denied Access: Invalid Timezone","刷卡禁止通过: 卡过期或不在有效时段", | |
102 | + "16","SwipeNOPass","Denied Access: In Order","刷卡禁止通过: 按顺序进出限制", | |
103 | + "17","SwipeNOPass","Denied Access: SWIPE GAP LIMIT","刷卡禁止通过: 刷卡间隔约束", | |
104 | + "18","SwipeNOPass","Denied Access","刷卡禁止通过: 原因不明", | |
105 | + "19","SwipeNOPass","Denied Access: Limited Times","刷卡禁止通过: 刷卡次数限制", | |
106 | + "20","ValidEvent","Push Button","按钮开门", | |
107 | + "21","ValidEvent","Push Button Open","按钮开", | |
108 | + "22","ValidEvent","Push Button Close","按钮关", | |
109 | + "23","ValidEvent","Door Open","门打开[门磁信号]", | |
110 | + "24","ValidEvent","Door Closed","门关闭[门磁信号]", | |
111 | + "25","ValidEvent","Super Password Open Door","超级密码开门", | |
112 | + "26","ValidEvent","Super Password Open","超级密码开", | |
113 | + "27","ValidEvent","Super Password Close","超级密码关", | |
114 | + "28","Warn","Controller Power On","控制器上电", | |
115 | + "29","Warn","Controller Reset","控制器复位", | |
116 | + "30","Warn","Push Button Invalid: Disable","按钮不开门: 按钮禁用", | |
117 | + "31","Warn","Push Button Invalid: Forced Lock","按钮不开门: 强制关门", | |
118 | + "32","Warn","Push Button Invalid: Not On Line","按钮不开门: 门不在线", | |
119 | + "33","Warn","Push Button Invalid: InterLock","按钮不开门: 互锁", | |
120 | + "34","Warn","Threat","胁迫报警", | |
121 | + "35","Warn","Threat Open","胁迫报警开", | |
122 | + "36","Warn","Threat Close","胁迫报警关", | |
123 | + "37","Warn","Open too long","门长时间未关报警[合法开门后]", | |
124 | + "38","Warn","Forced Open","强行闯入报警", | |
125 | + "39","Warn","Fire","火警", | |
126 | + "40","Warn","Forced Close","强制关门", | |
127 | + "41","Warn","Guard Against Theft","防盗报警", | |
128 | + "42","Warn","7*24Hour Zone","烟雾煤气温度报警", | |
129 | + "43","Warn","Emergency Call","紧急呼救报警", | |
130 | + "44","RemoteOpen","Remote Open Door","操作员远程开门", | |
131 | + "45","RemoteOpen","Remote Open Door By USB Reader","发卡器确定发出的远程开门" | |
132 | + }; | |
133 | +} | ... | ... |
cloud/weigeng/src/main/java/com/sincere/weigeng/utils/WatchServer.java
0 → 100644
... | ... | @@ -0,0 +1,509 @@ |
1 | +package com.sincere.weigeng.utils; | |
2 | + | |
3 | + | |
4 | +import com.sincere.common.dto.smartCampus.UserDto; | |
5 | +import com.sincere.common.dto.xiaoan.CheckInDto; | |
6 | +import com.sincere.common.dto.xiaoan.CheckOutDto; | |
7 | +import com.sincere.common.dto.xiaoan.PassFailDto; | |
8 | +import com.sincere.common.dto.xiaoan.SendMessageDto; | |
9 | +import com.sincere.common.util.DateUtils; | |
10 | +import com.sincere.weigeng.feign.SmFeign; | |
11 | +import com.sincere.weigeng.feign.XaFeign; | |
12 | +import com.sincere.weigeng.logs.LogName; | |
13 | +import com.sincere.weigeng.logs.LoggerUtils; | |
14 | +import org.apache.commons.lang3.StringUtils; | |
15 | +import org.apache.mina.core.session.IoSession; | |
16 | +import org.apache.mina.transport.socket.DatagramSessionConfig; | |
17 | +import org.apache.mina.transport.socket.nio.NioDatagramAcceptor; | |
18 | +import org.slf4j.Logger; | |
19 | + | |
20 | +import java.io.IOException; | |
21 | +import java.net.InetSocketAddress; | |
22 | +import java.util.*; | |
23 | +import java.util.concurrent.ConcurrentHashMap; | |
24 | + | |
25 | +/** | |
26 | + * @author chen | |
27 | + * @version 1.0 | |
28 | + * @date 2019/10/12 0012 16:57 | |
29 | + */ | |
30 | +public class WatchServer { | |
31 | + | |
32 | + private static final Logger Log_orderSuccess = LoggerUtils.Logger(LogName.orderSuccess); | |
33 | + private static final Logger Log_orderFail = LoggerUtils.Logger(LogName.orderFail); | |
34 | + private static final Logger Log_kaoInfo = LoggerUtils.Logger(LogName.kaoInfo); | |
35 | + private static final Logger Log_heartBeat = LoggerUtils.Logger(LogName.heartBeat); | |
36 | + private static final Logger Log_error = LoggerUtils.Logger(LogName.error); | |
37 | + | |
38 | + private static List<Long> snoList = new ArrayList<>(); | |
39 | + private static List<Long> indexList = new ArrayList<>(); | |
40 | + private static WatchingShortHandler watchingShortHandler ; | |
41 | + private static Queue<byte[]> queue = new LinkedList<>(); | |
42 | + private static Map<Long , IoSession> sessionMap = new ConcurrentHashMap<>(); | |
43 | + | |
44 | + // 进入服务器监控状态 | |
45 | + public static int WatchingServerRunning(String watchServerIP,int watchServerPort, | |
46 | + SmFeign smFeign ,XaFeign xaFeign) { | |
47 | + watchingShortHandler = new WatchingShortHandler(queue,sessionMap); | |
48 | + // 创建UDP数据包NIO | |
49 | + NioDatagramAcceptor acceptor = new NioDatagramAcceptor(); | |
50 | + // NIO设置底层IOHandler | |
51 | + acceptor.setHandler(watchingShortHandler); | |
52 | + | |
53 | + // 设置是否重用地址? 也就是每个发过来的udp信息都是一个地址? | |
54 | + DatagramSessionConfig dcfg = acceptor.getSessionConfig(); | |
55 | + dcfg.setReuseAddress(false); | |
56 | + // 绑定端口地址 | |
57 | + try { | |
58 | + acceptor.bind(new InetSocketAddress(watchServerIP, watchServerPort)); | |
59 | + } catch (IOException e) { | |
60 | + Log_orderSuccess.info("绑定接收服务器失败...."); | |
61 | + e.printStackTrace(); | |
62 | + return 0; | |
63 | + } | |
64 | + Log_orderSuccess.info("绑定接收服务器成功...."); | |
65 | + long recordIndex = 0; | |
66 | + while(true) { | |
67 | + if (!queue.isEmpty()) { | |
68 | + byte[] recvBuff; | |
69 | + synchronized (queue) { | |
70 | + recvBuff= queue.poll(); | |
71 | + } | |
72 | + if (recvBuff[1]== 0x20) { | |
73 | + long sn = WgUdpCommShort.getLongByByte(recvBuff, 4, 4); | |
74 | + smFeign.updateLinkTime(sn+""); | |
75 | + Log_heartBeat.info("设备"+sn); | |
76 | + boolean isExist = true ; | |
77 | + long recordIndexGet = WgUdpCommShort.getLongByByte(recvBuff, 8, 4); | |
78 | + if(snoList.indexOf(sn) >= 0){ | |
79 | + int number = snoList.indexOf(sn); | |
80 | + recordIndex = indexList.get(number); | |
81 | + indexList.set(number,recordIndexGet); | |
82 | + }else { | |
83 | + snoList.add(sn); | |
84 | + recordIndex = 0 ; | |
85 | + indexList.add(recordIndexGet); | |
86 | + System.out.println("设备"+sn+"上线"); | |
87 | + isExist = false ; | |
88 | + } | |
89 | + if(isExist){ | |
90 | + if (recordIndex < recordIndexGet || (recordIndexGet - recordIndex) < -5) { | |
91 | + watching(recvBuff,smFeign,xaFeign); | |
92 | + } | |
93 | + } | |
94 | + }else { | |
95 | + push(recvBuff,xaFeign); | |
96 | + } | |
97 | + } else { | |
98 | + long times = 100; | |
99 | + try { | |
100 | + Thread.sleep(times); | |
101 | + } catch (InterruptedException e) { | |
102 | + e.printStackTrace(); | |
103 | + } | |
104 | + } | |
105 | + } | |
106 | + } | |
107 | + | |
108 | + private static void watching(byte[] recv,SmFeign smFeign ,XaFeign xaFeign){ | |
109 | + long res = 0; | |
110 | + //8-11 记录的索引号 | |
111 | + //(=0表示没有记录) 4 0x00000000 | |
112 | + int recordIndex = 0; | |
113 | + recordIndex = WGUtils.byteToInt(recv, 8, 4); | |
114 | + //12 记录类型********************************************** | |
115 | + //0=无记录 | |
116 | + //1=刷卡记录 | |
117 | + //2=门磁,按钮, 设备启动, 远程开门记录 | |
118 | + //3=报警记录 1 | |
119 | + //0xFF=表示指定索引位的记录已被覆盖掉了. 请使用索引0, 取回最早一条记录的索引值 | |
120 | + int recordType = recv[12]; | |
121 | + | |
122 | + //13 有效性(0 表示不通过, 1表示通过) 1 | |
123 | + int recordValid = recv[13]; | |
124 | + | |
125 | + //14 门号(1,2,3,4) 1 业务需要-->1出2进 | |
126 | + int recordDoorNO = recv[14]; | |
127 | + | |
128 | + //15 进门/出门(1表示进门, 2表示出门) 1 0x01 | |
129 | + //int recordInOrOut = recv[15]; | |
130 | + | |
131 | + //16-19 卡号(类型是刷卡记录时) | |
132 | + //或编号(其他类型记录) 4 | |
133 | + String cardNo = WGUtils.getCardNo(recv, 16, 4); | |
134 | + | |
135 | + //20-26 刷卡时间: | |
136 | + //年月日时分秒 (采用BCD码)见设置时间部分的说明 | |
137 | + String recordTime = "2000-01-01 00:00:00"; | |
138 | + recordTime = String.format("%02X%02X-%02X-%02X %02X:%02X:%02X", | |
139 | + recv[20], recv[21], recv[22], recv[23], recv[24], recv[25], recv[26]); | |
140 | + //2012.12.11 10:49:59 7 | |
141 | + //27 记录原因代码(可以查 “刷卡记录说明.xls”文件的ReasonNO) | |
142 | + //处理复杂信息才用 1 | |
143 | + int reason = recv[27]; | |
144 | + if (recordType == 0) { | |
145 | + Log_orderSuccess.info(String.format("索引位={0} 无记录", recordIndex)); | |
146 | + }else if (recordType == 0xff) { | |
147 | + Log_orderSuccess.info("指定索引位的记录已被覆盖掉了,请使用索引0, 取回最早一条记录的索引值"); | |
148 | + } else if (recordType == 1) { | |
149 | + long sno = 0; | |
150 | + sno = WgUdpCommShort.getLongByByte(recv, 4, 4);//解析设备号 | |
151 | + String msg = "索引位=" + recordIndex | |
152 | + + ",卡号=" + cardNo | |
153 | + +"进出=" + (recordDoorNO == 1 ? "出门" : "进门") | |
154 | + + ",有效=" + (recordValid == 1 ? "通过" : "禁止") | |
155 | + + ",时间=" + recordTime | |
156 | + + ",描述=" + WGUtils.getReasonDetailChinese(reason) + ""; | |
157 | + Log_orderSuccess.info("控制器:" + sno + msg); | |
158 | + if(recordValid == 1) { | |
159 | + //有效刷卡调考勤存储过程 | |
160 | + CheckInDto checkIn = new CheckInDto(); | |
161 | + checkIn.setDeviceId(sno+""); | |
162 | + checkIn.setCardNo(cardNo); | |
163 | + checkIn.setFunNo(8); | |
164 | + checkIn.setFlag(recordDoorNO == 1 ? 1 : 0); | |
165 | + checkIn.setCheckTime(recordTime); | |
166 | + CheckOutDto checkOutDto = xaFeign.checkIn(checkIn); | |
167 | + if(checkOutDto.getIsSuccess() == 1){ | |
168 | + //考勤成功 | |
169 | + Log_kaoInfo.info("考勤成功!,设备:"+sno+"卡号:"+cardNo+"方向:"+(recordDoorNO == 1 ? "出门" : "进门")+"______"+ recordTime); | |
170 | + }else { | |
171 | + //考勤失败 | |
172 | + Log_orderFail.error("考勤失败!,设备:"+sno+"卡号:"+cardNo + "---"+ checkOutDto.getOut()); | |
173 | + } | |
174 | + }else { | |
175 | + //判断是否请假 | |
176 | + String studentNum = smFeign.checkLeave(cardNo); | |
177 | + if (StringUtils.isNotBlank(studentNum)) { | |
178 | + int outOf = recordDoorNO == 1 ? 1 : 0; | |
179 | + //远程开门 | |
180 | + openDoor(xaFeign,sno,"64",recordDoorNO,cardNo); | |
181 | + Log_orderSuccess.info("请假开门成功"+cardNo); | |
182 | + } else { | |
183 | + //没有请假不做任何处理,则是刷卡异常,入库 | |
184 | + UserDto user = smFeign.selectUserByCardNum(cardNo); | |
185 | + PassFailDto passFail = new PassFailDto(); | |
186 | + passFail.setCardNum(cardNo); | |
187 | + passFail.setDeviceId(sno+""); | |
188 | + passFail.setDirection((recordDoorNO == 1 ? "出门" : "进门")); | |
189 | + passFail.setResultIntro(WGUtils.getReasonDetailChinese(reason)); | |
190 | + passFail.setInTime(DateUtils.string2Date(recordTime, DateUtils.format2)); | |
191 | + passFail.setCreateTime(new Date()); | |
192 | + passFail.setSchoolId(user.getSchoolId()); | |
193 | + xaFeign.insertPassFail(passFail); | |
194 | + } | |
195 | + } | |
196 | + } | |
197 | + } | |
198 | + | |
199 | + private static void push(byte[] recv,XaFeign xaFeign){ | |
200 | + long index = WgUdpCommShort.getXidOfCommand(recv); | |
201 | + long sno = WgUdpCommShort.getLongByByte(recv, 4, 4); | |
202 | + String functionId = WGUtils.byte2Hex(recv[1]); | |
203 | + SendMessageDto sendMessage = xaFeign.selectMessage(sno+"",index,functionId); | |
204 | + if(sendMessage != null){ | |
205 | + if(recv[8] == 1){ | |
206 | + sendMessage.setCorrect(1); | |
207 | + }else { | |
208 | + sendMessage.setCorrect(0); | |
209 | + } | |
210 | + StringBuffer result = new StringBuffer(); | |
211 | + for(byte b : recv){ | |
212 | + result.append(WGUtils.byte2Hex(b)).append("-"); | |
213 | + } | |
214 | + sendMessage.setResult(result.toString().substring(0,result.toString().length()-1)); | |
215 | + xaFeign.updateMessage(sendMessage.getId(),sendMessage.getResult(),sendMessage.getCorrect()); | |
216 | + } | |
217 | + } | |
218 | + | |
219 | + //远程开门 | |
220 | + public static long openDoor(XaFeign xaFeign,long sno , String outsideOrderId,int doorNo , String cardNo){ | |
221 | + WgUdpCommShort pkt = new WgUdpCommShort(); | |
222 | + pkt.iDevSn = sno; | |
223 | + try{ | |
224 | + int doorNO =doorNo; | |
225 | + pkt.Reset(); | |
226 | + pkt.functionID = WGUtils.toFunctionHex(outsideOrderId); | |
227 | + pkt.data[0] =(byte) (doorNO & 0xff); | |
228 | + if(StringUtils.isNotBlank(cardNo)){ | |
229 | + pkt.data[20] = WGUtils.toHex(cardNo.substring(0,2)); | |
230 | + pkt.data[21] = WGUtils.toHex(cardNo.substring(2,4)); | |
231 | + pkt.data[22] = WGUtils.toHex(cardNo.substring(4,6)); | |
232 | + pkt.data[23] = WGUtils.toHex(cardNo.substring(6,8)); | |
233 | + } | |
234 | + byte[] bytes = pkt.toByte(); | |
235 | + long index = WgUdpCommShort.getXidOfCommand(bytes); | |
236 | + long result = insert(xaFeign,sno+"",outsideOrderId,cardNo,index,bytes); | |
237 | + pkt.run(watchingShortHandler.getSessionMap().get(sno),bytes); | |
238 | + return result ; | |
239 | + }catch (Exception e){ | |
240 | + Log_error.error(e.toString()); | |
241 | + } | |
242 | + return 0L; | |
243 | + } | |
244 | + | |
245 | + //重置控制板时间 | |
246 | + public static long setTime(XaFeign xaFeign,long sno , String outsideOrderId){ | |
247 | + WgUdpCommShort pkt = new WgUdpCommShort(); | |
248 | + pkt.iDevSn = sno; | |
249 | + try{ | |
250 | + pkt.Reset(); | |
251 | + pkt.functionID = WGUtils.toFunctionHex(outsideOrderId); | |
252 | + Calendar cal = (Calendar.getInstance()); | |
253 | + pkt.data[0] = WGUtils.toHex(String.valueOf(cal.get(Calendar.YEAR)).substring(0,2)); | |
254 | + pkt.data[1] = WGUtils.toHex(String.valueOf(cal.get(Calendar.YEAR)).substring(2,4)); | |
255 | + pkt.data[2] = WGUtils.toHex(String.valueOf(cal.get(Calendar.MONTH)+1)); | |
256 | + pkt.data[3] = WGUtils.toHex(String.valueOf(cal.get(Calendar.DATE))); | |
257 | + pkt.data[4] =WGUtils.toHex(String.valueOf(cal.get(Calendar.HOUR_OF_DAY))); | |
258 | + pkt.data[5] =WGUtils.toHex(String.valueOf(cal.get(Calendar.MINUTE))); | |
259 | + pkt.data[6] = WGUtils.toHex(String.valueOf(cal.get(Calendar.SECOND))); | |
260 | + byte[] bytes = pkt.toByte(); | |
261 | + long index = WgUdpCommShort.getXidOfCommand(bytes); | |
262 | + long result = insert(xaFeign,sno+"",outsideOrderId,null,index,bytes); | |
263 | + pkt.run(watchingShortHandler.getSessionMap().get(sno),bytes); | |
264 | + return result ; | |
265 | + }catch (Exception e){ | |
266 | + Log_error.error(e.toString()); | |
267 | + } | |
268 | + return 0L; | |
269 | + } | |
270 | + | |
271 | + | |
272 | + | |
273 | + //设置考勤时段 | |
274 | + public static List<Long> SetAttendanceTime(XaFeign xaFeign,long sno ,String outsideOrderId, int shiduan , Date begin ,Date end , | |
275 | + int isMonDay ,int isTuesDay , int isWednesDay ,int isThursDay , int isFriday , | |
276 | + int isSaturDay , int isWeekend , String shiqu){ | |
277 | + List<Long> resultList = new ArrayList<>(); | |
278 | + WgUdpCommShort pkt = new WgUdpCommShort(); | |
279 | + pkt.iDevSn = sno; | |
280 | + try{ | |
281 | + pkt.Reset(); | |
282 | + pkt.functionID = WGUtils.toFunctionHex(outsideOrderId); | |
283 | + String[] shiQuArray = shiqu.split(","); | |
284 | + int shiDuanCount = shiQuArray.length / 6 ; | |
285 | + for (int i = 0; i < shiDuanCount; i++){ | |
286 | + if (i == 0) { | |
287 | + pkt.data[0] = WGUtils.toHex(shiduan+""); | |
288 | + } else { | |
289 | + pkt.data[0] = WGUtils.toHex((shiduan+20*i)+""); | |
290 | + } | |
291 | + Calendar c = Calendar.getInstance(); | |
292 | + c.setTime(begin); | |
293 | + //开始时间 20 19 01 01 | |
294 | + pkt.data[1] = WGUtils.toHex(String.valueOf(c.get(Calendar.YEAR)).substring(0,2)); | |
295 | + pkt.data[2] = WGUtils.toHex(String.valueOf(c.get(Calendar.YEAR)).substring(2,4)); | |
296 | + pkt.data[3] = WGUtils.toHex(String.valueOf(c.get(Calendar.MONTH)+1)); | |
297 | + pkt.data[4] = WGUtils.toHex(String.valueOf(c.get(Calendar.DATE))); | |
298 | + //结束时间 | |
299 | + c.setTime(end); | |
300 | + pkt.data[5] = WGUtils.toHex(String.valueOf(c.get(Calendar.YEAR)).substring(0,2)); | |
301 | + pkt.data[6] = WGUtils.toHex(String.valueOf(c.get(Calendar.YEAR)).substring(2,4)); | |
302 | + pkt.data[7] = WGUtils.toHex(String.valueOf(c.get(Calendar.MONTH)+1)); | |
303 | + pkt.data[8] = WGUtils.toHex(String.valueOf(c.get(Calendar.DATE))); | |
304 | + //星期几 有效 | |
305 | + pkt.data[9] = WGUtils.toHex(String.valueOf(isMonDay)); | |
306 | + pkt.data[10] = WGUtils.toHex(String.valueOf(isTuesDay)); | |
307 | + pkt.data[11] = WGUtils.toHex(String.valueOf(isWednesDay)); | |
308 | + pkt.data[12] = WGUtils.toHex(String.valueOf(isThursDay)); | |
309 | + pkt.data[13] = WGUtils.toHex(String.valueOf(isFriday)); | |
310 | + pkt.data[14] = WGUtils.toHex(String.valueOf(isSaturDay)); | |
311 | + pkt.data[15] = WGUtils.toHex(String.valueOf(isWeekend)); | |
312 | + //有效时区 | |
313 | + pkt.data[16] = WGUtils.toHex(shiQuArray[i * 6 + 0].substring(0, 2)); | |
314 | + pkt.data[17] = WGUtils.toHex(shiQuArray[i * 6 + 0].substring(3, 5)); | |
315 | + | |
316 | + pkt.data[18] = WGUtils.toHex(shiQuArray[i * 6 + 1].substring(0, 2)); | |
317 | + pkt.data[19] = WGUtils.toHex(shiQuArray[i * 6 + 1].substring(3, 5)); | |
318 | + | |
319 | + pkt.data[20] = WGUtils.toHex(shiQuArray[i * 6 + 2].substring(0, 2)); | |
320 | + pkt.data[21] = WGUtils.toHex(shiQuArray[i * 6 + 2].substring(3, 5)); | |
321 | + | |
322 | + pkt.data[22] = WGUtils.toHex(shiQuArray[i * 6 + 3].substring(0, 2)); | |
323 | + pkt.data[23] = WGUtils.toHex(shiQuArray[i * 6 + 3].substring(3, 5)); | |
324 | + | |
325 | + pkt.data[24] = WGUtils.toHex(shiQuArray[i * 6 + 4].substring(0, 2)); | |
326 | + pkt.data[25] = WGUtils.toHex(shiQuArray[i * 6 + 4].substring(3, 5)); | |
327 | + | |
328 | + pkt.data[26] = WGUtils.toHex(shiQuArray[i * 6 + 5].substring(0, 2)); | |
329 | + pkt.data[27] = WGUtils.toHex(shiQuArray[i * 6 + 5].substring(3, 5)); | |
330 | + if (shiDuanCount != 1) { | |
331 | + //需要链接时段 | |
332 | + if (i != shiDuanCount - 1) { | |
333 | + //只要不是最后一个时段 | |
334 | + pkt.data[28] = WGUtils.toHex((shiduan+20*(i+1)+"")); | |
335 | + } else { | |
336 | + pkt.data[28] = 0; | |
337 | + } | |
338 | + } else { | |
339 | + pkt.data[28] = 0; | |
340 | + } | |
341 | + byte[] bytes = pkt.toByte(); | |
342 | + long index = WgUdpCommShort.getXidOfCommand(bytes); | |
343 | + long result = insert(xaFeign,sno+"",outsideOrderId,null,index,bytes); | |
344 | + pkt.run(watchingShortHandler.getSessionMap().get(sno),bytes); | |
345 | + resultList.add(result); | |
346 | + } | |
347 | + return resultList ; | |
348 | + }catch (Exception e){ | |
349 | + Log_error.error(e.toString()); | |
350 | + } | |
351 | + return resultList; | |
352 | + } | |
353 | + | |
354 | + | |
355 | + //设置权限 | |
356 | + public static long SetSignalCardInfo(XaFeign xaFeign,long sno , String outsideOrderId, String cardNo , int shiduan , Date begin , Date end){ | |
357 | + WgUdpCommShort pkt = new WgUdpCommShort(); | |
358 | + pkt.iDevSn = sno; | |
359 | + try{ | |
360 | + pkt.Reset(); | |
361 | + pkt.functionID = WGUtils.toFunctionHex(outsideOrderId); | |
362 | + pkt.iDevSn = sno; | |
363 | + //0D D7 37 00 | |
364 | + pkt.data[0] = WGUtils.toHex(cardNo.substring(0,2)); | |
365 | + pkt.data[1] = WGUtils.toHex(cardNo.substring(2,4)); | |
366 | + pkt.data[2] = WGUtils.toHex(cardNo.substring(4,6)); | |
367 | + pkt.data[3] = WGUtils.toHex(cardNo.substring(6,8)); | |
368 | + | |
369 | + //20 10 01 01 起始日期: 2010年01月01日 (必须大于2001年) | |
370 | + Calendar c = Calendar.getInstance(); | |
371 | + c.setTime(begin); | |
372 | + pkt.data[4] = WGUtils.toHex(String.valueOf(c.get(Calendar.YEAR)).substring(0,2)); | |
373 | + pkt.data[5] = WGUtils.toHex(String.valueOf(c.get(Calendar.YEAR)).substring(2,4)); | |
374 | + pkt.data[6] = WGUtils.toHex(String.valueOf(c.get(Calendar.MONTH)+1)); | |
375 | + pkt.data[7] = WGUtils.toHex(String.valueOf(c.get(Calendar.DATE))); | |
376 | + //20 29 12 31 截止日期: 2029年12月31日 | |
377 | + c.setTime(end); | |
378 | + pkt.data[8] = WGUtils.toHex(String.valueOf(c.get(Calendar.YEAR)).substring(0,2)); | |
379 | + pkt.data[9] = WGUtils.toHex(String.valueOf(c.get(Calendar.YEAR)).substring(2,4)); | |
380 | + pkt.data[10] = WGUtils.toHex(String.valueOf(c.get(Calendar.MONTH)+1)); | |
381 | + pkt.data[11] = WGUtils.toHex(String.valueOf(c.get(Calendar.DATE))); | |
382 | + //01 允许通过 一号门 [对单门, 双门, 四门控制器有效] | |
383 | + pkt.data[12] = WGUtils.toHex(shiduan+""); | |
384 | + //01 允许通过 二号门 [对双门, 四门控制器有效] | |
385 | + pkt.data[13] = WGUtils.toHex(shiduan+""); | |
386 | + //01 允许通过 三号门 [对四门控制器有效] | |
387 | + pkt.data[14] = WGUtils.toHex(shiduan+""); | |
388 | + //01 允许通过 四号门 [对四门控制器有效] | |
389 | + pkt.data[15] = WGUtils.toHex(shiduan+""); | |
390 | + byte[] bytes = pkt.toByte(); | |
391 | + long index = WgUdpCommShort.getXidOfCommand(bytes); | |
392 | + long result = insert(xaFeign,sno+"",outsideOrderId,cardNo,index,bytes); | |
393 | + pkt.run(watchingShortHandler.getSessionMap().get(sno),bytes); | |
394 | + return result ; | |
395 | + }catch (Exception e){ | |
396 | + Log_error.error(e.toString()); | |
397 | + } | |
398 | + return 0l; | |
399 | + } | |
400 | + | |
401 | + //删除单张卡权限 | |
402 | + public static long clearSinglePower(XaFeign xaFeign,long sno ,String outsideOrderId, String cardNo){ | |
403 | + WgUdpCommShort pkt = new WgUdpCommShort(); | |
404 | + pkt.iDevSn = sno; | |
405 | + try{ | |
406 | + pkt.Reset(); | |
407 | + pkt.functionID = WGUtils.toFunctionHex(outsideOrderId); | |
408 | + pkt.iDevSn = sno; | |
409 | + pkt.data[0] = WGUtils.toHex(cardNo.substring(0,2)); | |
410 | + pkt.data[1] = WGUtils.toHex(cardNo.substring(2,4)); | |
411 | + pkt.data[2] = WGUtils.toHex(cardNo.substring(4,6)); | |
412 | + pkt.data[3] = WGUtils.toHex(cardNo.substring(6,8)); | |
413 | + byte[] bytes = pkt.toByte(); | |
414 | + long index = WgUdpCommShort.getXidOfCommand(bytes); | |
415 | + long result = insert(xaFeign,sno+"",outsideOrderId,cardNo,index,bytes); | |
416 | + pkt.run(watchingShortHandler.getSessionMap().get(sno),bytes); | |
417 | + return result ; | |
418 | + }catch (Exception e){ | |
419 | + Log_error.error(e.toString()); | |
420 | + } | |
421 | + return 0l; | |
422 | + } | |
423 | + | |
424 | + //删除全部权限 | |
425 | + public static long clearAllPower(XaFeign xaFeign,long sno ,String outsideOrderId){ | |
426 | + WgUdpCommShort pkt = new WgUdpCommShort(); | |
427 | + pkt.iDevSn = sno; | |
428 | + try{ | |
429 | + pkt.Reset(); | |
430 | + pkt.functionID = WGUtils.toFunctionHex(outsideOrderId); | |
431 | + pkt.iDevSn = sno; | |
432 | + pkt.data[0] = (byte) 0x55 ; | |
433 | + pkt.data[1] = (byte) 0xAA ; | |
434 | + pkt.data[2] = (byte) 0xAA ; | |
435 | + pkt.data[3] = (byte) 0x55 ; | |
436 | + byte[] bytes = pkt.toByte(); | |
437 | + long index = WgUdpCommShort.getXidOfCommand(bytes); | |
438 | + long result = insert(xaFeign,sno+"",outsideOrderId,null,index,bytes); | |
439 | + pkt.run(watchingShortHandler.getSessionMap().get(sno),bytes); | |
440 | + return result ; | |
441 | + }catch (Exception e){ | |
442 | + Log_error.error(e.toString()); | |
443 | + } | |
444 | + return 0l; | |
445 | + } | |
446 | + | |
447 | + //查询卡权限 | |
448 | + public static long searchPower(XaFeign xaFeign,long sno ,String outsideOrderId, String cardNo){ | |
449 | + WgUdpCommShort pkt = new WgUdpCommShort(); | |
450 | + pkt.iDevSn = sno; | |
451 | + try{ | |
452 | + pkt.Reset(); | |
453 | + pkt.functionID = WGUtils.toFunctionHex(outsideOrderId); | |
454 | + pkt.iDevSn = sno; | |
455 | + pkt.data[0] = WGUtils.toHex(cardNo.substring(0,2)); | |
456 | + pkt.data[1] = WGUtils.toHex(cardNo.substring(2,4)); | |
457 | + pkt.data[2] = WGUtils.toHex(cardNo.substring(4,6)); | |
458 | + pkt.data[3] = WGUtils.toHex(cardNo.substring(6,8)); | |
459 | + byte[] bytes = pkt.toByte(); | |
460 | + long index = WgUdpCommShort.getXidOfCommand(bytes); | |
461 | + long result = insert(xaFeign,sno+"",outsideOrderId,cardNo,index,bytes); | |
462 | + pkt.run(watchingShortHandler.getSessionMap().get(sno),bytes); | |
463 | + return result ; | |
464 | + }catch (Exception e){ | |
465 | + Log_error.error(e.toString()); | |
466 | + } | |
467 | + return 0l; | |
468 | + } | |
469 | + | |
470 | + //删除时段 | |
471 | + public static long clearShiDuan(XaFeign xaFeign,long sno , String outsideOrderId){ | |
472 | + WgUdpCommShort pkt = new WgUdpCommShort(); | |
473 | + pkt.iDevSn = sno; | |
474 | + try{ | |
475 | + pkt.Reset(); | |
476 | + pkt.functionID = WGUtils.toFunctionHex(outsideOrderId); | |
477 | + pkt.iDevSn = sno; | |
478 | + pkt.data[0] = (byte) 0x55 ; | |
479 | + pkt.data[1] = (byte) 0xAA ; | |
480 | + pkt.data[2] = (byte) 0xAA ; | |
481 | + pkt.data[3] = (byte) 0x55 ; | |
482 | + byte[] bytes = pkt.toByte(); | |
483 | + long index = WgUdpCommShort.getXidOfCommand(bytes); | |
484 | + long result = insert(xaFeign,sno+"",outsideOrderId,null,index,bytes); | |
485 | + pkt.run(watchingShortHandler.getSessionMap().get(sno),bytes); | |
486 | + return result ; | |
487 | + }catch (Exception e){ | |
488 | + Log_error.error(e.toString()); | |
489 | + } | |
490 | + return 0l; | |
491 | + } | |
492 | + | |
493 | + private static long insert(XaFeign xaFeign ,String sn ,String functionId , String cardNo , long index , byte[] recv){ | |
494 | + | |
495 | + StringBuffer send = new StringBuffer(); | |
496 | + for(byte b : recv){ | |
497 | + send.append(WGUtils.byte2Hex(b)).append("-"); | |
498 | + } | |
499 | + SendMessageDto sendMessage = new SendMessageDto(); | |
500 | + sendMessage.setDeviceId(sn); | |
501 | + sendMessage.setFunctionId(Integer.toHexString(Integer.valueOf(functionId))); | |
502 | + sendMessage.setIndex(index); | |
503 | + sendMessage.setCardNo(cardNo); | |
504 | + sendMessage.setCreateTime(new Date()); | |
505 | + sendMessage.setSend(send.toString().substring(0,send.toString().length()-1)); | |
506 | + xaFeign.insertMessage(sendMessage); | |
507 | + return sendMessage.getId(); | |
508 | + } | |
509 | +} | ... | ... |
cloud/weigeng/src/main/java/com/sincere/weigeng/utils/WatchingShortHandler.java
0 → 100644
... | ... | @@ -0,0 +1,90 @@ |
1 | +package com.sincere.weigeng.utils; | |
2 | + | |
3 | +import org.apache.mina.core.buffer.IoBuffer; | |
4 | +import org.apache.mina.core.service.IoHandlerAdapter; | |
5 | +import org.apache.mina.core.session.IdleStatus; | |
6 | +import org.apache.mina.core.session.IoSession; | |
7 | + | |
8 | +import java.util.Map; | |
9 | +import java.util.Queue; | |
10 | + | |
11 | + | |
12 | +/** | |
13 | + * Class the extends IoHandlerAdapter in order to properly handle | |
14 | + * connections and the data the connections send | |
15 | + * | |
16 | + * @author <a href="http://mina.apache.org" mce_href="http://mina.apache.org">Apache MINA Project</a> | |
17 | + */ | |
18 | +public class WatchingShortHandler extends IoHandlerAdapter { | |
19 | + | |
20 | + private Queue<byte[]> queue; | |
21 | + private Map<Long , IoSession> sessionMap ; | |
22 | + public WatchingShortHandler(Queue<byte[]> queue , Map<Long , IoSession> sessionMap) { | |
23 | + super(); | |
24 | + this.queue = queue; | |
25 | + this.sessionMap = sessionMap; | |
26 | + } | |
27 | + | |
28 | + /** | |
29 | + * 异常来关闭session | |
30 | + */ | |
31 | + @Override | |
32 | + public void exceptionCaught(IoSession session, Throwable cause) | |
33 | + throws Exception { | |
34 | + cause.printStackTrace(); | |
35 | + session.close(true); | |
36 | + } | |
37 | + | |
38 | + /** | |
39 | + * 服务器端收到一个消息 | |
40 | + */ | |
41 | + @Override | |
42 | + public void messageReceived(IoSession session, Object message) throws Exception { | |
43 | + IoBuffer io = (IoBuffer) message; | |
44 | + if (io.hasRemaining()) { | |
45 | + byte[] validBytes = new byte[io.remaining()]; | |
46 | + io.get(validBytes,0,io.remaining()); | |
47 | + if (validBytes.length == WgUdpCommShort.WGPacketSize) { | |
48 | + synchronized (queue) { | |
49 | + long sn = WgUdpCommShort.getLongByByte(validBytes, 4, 4); | |
50 | + sessionMap.put(sn,session); | |
51 | + queue.offer(validBytes); | |
52 | + } | |
53 | + } else { | |
54 | + } | |
55 | + } | |
56 | + } | |
57 | + | |
58 | + @Override | |
59 | + public void sessionClosed(IoSession session) throws Exception { | |
60 | + } | |
61 | + | |
62 | + @Override | |
63 | + public void sessionCreated(IoSession session) throws Exception { | |
64 | + } | |
65 | + | |
66 | + @Override | |
67 | + public void sessionIdle(IoSession session, IdleStatus status) | |
68 | + throws Exception { | |
69 | + } | |
70 | + | |
71 | + @Override | |
72 | + public void sessionOpened(IoSession session) throws Exception { | |
73 | + } | |
74 | + | |
75 | + public Queue<byte[]> getQueue() { | |
76 | + return queue; | |
77 | + } | |
78 | + | |
79 | + public void setQueue(Queue<byte[]> queue) { | |
80 | + this.queue = queue; | |
81 | + } | |
82 | + | |
83 | + public Map<Long, IoSession> getSessionMap() { | |
84 | + return sessionMap; | |
85 | + } | |
86 | + | |
87 | + public void setSessionMap(Map<Long, IoSession> sessionMap) { | |
88 | + this.sessionMap = sessionMap; | |
89 | + } | |
90 | +} | ... | ... |
cloud/weigeng/src/main/java/com/sincere/weigeng/utils/WgUdpCommShort.java
0 → 100644
... | ... | @@ -0,0 +1,120 @@ |
1 | +package com.sincere.weigeng.utils; | |
2 | + | |
3 | +import org.apache.mina.core.buffer.IoBuffer; | |
4 | +import org.apache.mina.core.session.IoSession; | |
5 | + | |
6 | +public class WgUdpCommShort { //短报文协议 | |
7 | + | |
8 | + public static final int WGPacketSize = 64; //报文长度 | |
9 | + public static final byte Type = 0x17; //2015-04-30 08:50:29 0x19; //类型 | |
10 | + public static final int ControllerPort = 60000; //控制器端口 | |
11 | + public static final long SpecialFlag = 0x55AAAA55; //特殊标识 防止误操作 | |
12 | + | |
13 | + public static byte[] longToByte(long number) { | |
14 | + byte[] b = new byte[8]; | |
15 | + for (int i = 0; i < 8; i++) { | |
16 | + b[i] = (byte) (number % 256); | |
17 | + number >>= 8; | |
18 | + } | |
19 | + return b; | |
20 | + } | |
21 | + | |
22 | + //从字节转换为 long型数据, 最大长度为8字节 低位在前, 高位在后... | |
23 | + //bytlen (1--8), 不在此范围则返回 -1 | |
24 | + public static long getLongByByte(byte[] data,int startIndex,int bytlen) | |
25 | + { | |
26 | + long ret =-1; | |
27 | + if ((bytlen >=1) && (bytlen <=8)) | |
28 | + { | |
29 | + ret = getIntByByte(data[startIndex + bytlen-1]); | |
30 | + for (int i=1; i<bytlen; i++) | |
31 | + { | |
32 | + ret <<=8; | |
33 | + ret += getIntByByte(data[startIndex + bytlen-1-i]); | |
34 | + } | |
35 | + } | |
36 | + return ret; | |
37 | + } | |
38 | + | |
39 | + //将带符号的bt转换为不带符号的int类型数据 | |
40 | + public static int getIntByByte(byte bt) //bt 转换为无符号的int | |
41 | + { | |
42 | + if (bt <0) | |
43 | + { | |
44 | + return (bt+256); | |
45 | + } | |
46 | + else | |
47 | + { | |
48 | + return bt; | |
49 | + } | |
50 | + } | |
51 | + | |
52 | + | |
53 | + public byte functionID; //功能号 | |
54 | + public long iDevSn; //设备序列号 4字节 | |
55 | + public byte[] data= new byte[56]; //56字节的数据 [含流水号] | |
56 | + | |
57 | + private static long _Global_xid = 0; | |
58 | + protected long _xid = 0; //2011-5-12 15:28:37 | |
59 | + void GetNewXid() //2011-1-10 14:22:16 获取新的Xid | |
60 | + { | |
61 | + _Global_xid++; | |
62 | + _xid = _Global_xid; //新的值 | |
63 | + } | |
64 | + static long getXidOfCommand(byte[] cmd) //获取指令中的xid | |
65 | + { | |
66 | + long ret = -1; | |
67 | + if (cmd.length >= WGPacketSize) | |
68 | + { | |
69 | + ret = getLongByByte(cmd, 40, 4); | |
70 | + } | |
71 | + return ret; | |
72 | + } | |
73 | + | |
74 | + public WgUdpCommShort() | |
75 | + { | |
76 | + Reset(); | |
77 | + } | |
78 | + public void Reset() //数据复位 | |
79 | + { | |
80 | + for(int i=0; i<data.length; i++) | |
81 | + { | |
82 | + data[i] =0; | |
83 | + } | |
84 | + } | |
85 | + public byte[] toByte() //生成64字节指令包 | |
86 | + { | |
87 | + byte[] buff =new byte[WGPacketSize]; | |
88 | + for(int i=0; i<data.length; i++) | |
89 | + { | |
90 | + buff[i] =0; | |
91 | + } | |
92 | + buff[0] = Type; | |
93 | + buff[1] = functionID; | |
94 | + System.arraycopy(longToByte(iDevSn), 0, buff, 4, 4); | |
95 | + System.arraycopy(data, 0, buff, 8, data.length); | |
96 | + | |
97 | + GetNewXid(); | |
98 | + System.arraycopy(longToByte(_xid), 0, buff, 40, 4); | |
99 | + return buff; | |
100 | + } | |
101 | + | |
102 | + public void run(IoSession ioSession , byte[] command){ | |
103 | + byte[] bytCommand = command; | |
104 | + IoBuffer b; | |
105 | + Boolean bSent =false; | |
106 | + //ioSession = connFuture.getSession(); | |
107 | + if (ioSession !=null) | |
108 | + { | |
109 | + if (ioSession.isConnected()) | |
110 | + { | |
111 | + b = IoBuffer.allocate(bytCommand.length); | |
112 | + b.put(bytCommand); | |
113 | + b.flip(); | |
114 | + ioSession.write(b); | |
115 | + bSent = true; | |
116 | + } | |
117 | + } | |
118 | + } | |
119 | + | |
120 | +} | ... | ... |
cloud/weigeng/src/main/java/com/sincere/weigeng/vo/AttendanceTimeVo.java
0 → 100644
... | ... | @@ -0,0 +1,156 @@ |
1 | +package com.sincere.weigeng.vo; | |
2 | + | |
3 | +import java.util.Date; | |
4 | + | |
5 | +/** | |
6 | + * @author chen | |
7 | + * @version 1.0 | |
8 | + * @date 2019/11/1 0001 8:00 | |
9 | + */ | |
10 | +public class AttendanceTimeVo { | |
11 | + /** | |
12 | + * 设置考勤时段 | |
13 | + * @param id 指令id | |
14 | + * @param sn 设备号 | |
15 | + * @param shiduan 时段 | |
16 | + * @param start 开始时间 | |
17 | + * @param end 截止时间 | |
18 | + * @param IsMonday 周一是否有效 0 无效 1有效 | |
19 | + * @param IsTuesday 周二是否有效 0 无效 1有效 | |
20 | + * @param IsWednesday 周三是否有效 0 无效 1有效 | |
21 | + * @param IsThursday 周四是否有效 0 无效 1有效 | |
22 | + * @param IsFriday 周五是否有效 0 无效 1有效 | |
23 | + * @param IsSaturday 周六是否有效 0 无效 1有效 | |
24 | + * @param IsWeekend 周日是否有效 0 无效 1有效 | |
25 | + * @param shiqu 具体的时间点,格式 “09:09,11:11,00:00,00:00,00:00,00:00” | |
26 | + * 注意:时间点之间拿英文的都好隔开。时与分不足两位要补0。一个完整的时段需要6个时间点。不足6个的要补“00:00” | |
27 | + * @param type 设备类型 | |
28 | + * @return | |
29 | + */ | |
30 | + private int id ; | |
31 | + private int type ; | |
32 | + private long sn ; | |
33 | + private int shiduan ; | |
34 | + private Date start ; | |
35 | + private Date end ; | |
36 | + private int IsMonday ; | |
37 | + private int IsTuesday ; | |
38 | + private int IsWednesday ; | |
39 | + private int IsThursday ; | |
40 | + private int IsFriday ; | |
41 | + private int IsSaturday ; | |
42 | + private int IsWeekend ; | |
43 | + private String shiqu ; | |
44 | + | |
45 | + public int getId() { | |
46 | + return id; | |
47 | + } | |
48 | + | |
49 | + public void setId(int id) { | |
50 | + this.id = id; | |
51 | + } | |
52 | + | |
53 | + public int getType() { | |
54 | + return type; | |
55 | + } | |
56 | + | |
57 | + public void setType(int type) { | |
58 | + this.type = type; | |
59 | + } | |
60 | + | |
61 | + public Date getStart() { | |
62 | + return start; | |
63 | + } | |
64 | + | |
65 | + public void setStart(Date start) { | |
66 | + this.start = start; | |
67 | + } | |
68 | + | |
69 | + public Date getEnd() { | |
70 | + return end; | |
71 | + } | |
72 | + | |
73 | + public void setEnd(Date end) { | |
74 | + this.end = end; | |
75 | + } | |
76 | + | |
77 | + public int getIsMonday() { | |
78 | + return IsMonday; | |
79 | + } | |
80 | + | |
81 | + public void setIsMonday(int isMonday) { | |
82 | + IsMonday = isMonday; | |
83 | + } | |
84 | + | |
85 | + public int getIsTuesday() { | |
86 | + return IsTuesday; | |
87 | + } | |
88 | + | |
89 | + public void setIsTuesday(int isTuesday) { | |
90 | + IsTuesday = isTuesday; | |
91 | + } | |
92 | + | |
93 | + public int getIsWednesday() { | |
94 | + return IsWednesday; | |
95 | + } | |
96 | + | |
97 | + public void setIsWednesday(int isWednesday) { | |
98 | + IsWednesday = isWednesday; | |
99 | + } | |
100 | + | |
101 | + public int getIsThursday() { | |
102 | + return IsThursday; | |
103 | + } | |
104 | + | |
105 | + public void setIsThursday(int isThursday) { | |
106 | + IsThursday = isThursday; | |
107 | + } | |
108 | + | |
109 | + public int getIsFriday() { | |
110 | + return IsFriday; | |
111 | + } | |
112 | + | |
113 | + public void setIsFriday(int isFriday) { | |
114 | + IsFriday = isFriday; | |
115 | + } | |
116 | + | |
117 | + public int getIsSaturday() { | |
118 | + return IsSaturday; | |
119 | + } | |
120 | + | |
121 | + public void setIsSaturday(int isSaturday) { | |
122 | + IsSaturday = isSaturday; | |
123 | + } | |
124 | + | |
125 | + public int getIsWeekend() { | |
126 | + return IsWeekend; | |
127 | + } | |
128 | + | |
129 | + public void setIsWeekend(int isWeekend) { | |
130 | + IsWeekend = isWeekend; | |
131 | + } | |
132 | + | |
133 | + public String getShiqu() { | |
134 | + return shiqu; | |
135 | + } | |
136 | + | |
137 | + public void setShiqu(String shiqu) { | |
138 | + this.shiqu = shiqu; | |
139 | + } | |
140 | + | |
141 | + public long getSn() { | |
142 | + return sn; | |
143 | + } | |
144 | + | |
145 | + public void setSn(long sn) { | |
146 | + this.sn = sn; | |
147 | + } | |
148 | + | |
149 | + public int getShiduan() { | |
150 | + return shiduan; | |
151 | + } | |
152 | + | |
153 | + public void setShiduan(int shiduan) { | |
154 | + this.shiduan = shiduan; | |
155 | + } | |
156 | +} | ... | ... |
cloud/weigeng/src/main/java/com/sincere/weigeng/vo/CardInfo.java
0 → 100644
... | ... | @@ -0,0 +1,54 @@ |
1 | +package com.sincere.weigeng.vo; | |
2 | + | |
3 | +/** | |
4 | + * @author chen | |
5 | + * @version 1.0 | |
6 | + * @date 2019/11/1 0001 8:09 | |
7 | + */ | |
8 | +public class CardInfo { | |
9 | + | |
10 | + /** | |
11 | + * | |
12 | + * @param id 指令 | |
13 | + * @param sn 设备号 | |
14 | + * @param cardNo 卡号 | |
15 | + * @param type 设备类型 | |
16 | + * @return | |
17 | + */ | |
18 | + private int id ; | |
19 | + private int type ; | |
20 | + private long sn ; | |
21 | + private String cardNo ; | |
22 | + | |
23 | + public int getId() { | |
24 | + return id; | |
25 | + } | |
26 | + | |
27 | + public void setId(int id) { | |
28 | + this.id = id; | |
29 | + } | |
30 | + | |
31 | + public int getType() { | |
32 | + return type; | |
33 | + } | |
34 | + | |
35 | + public void setType(int type) { | |
36 | + this.type = type; | |
37 | + } | |
38 | + | |
39 | + public long getSn() { | |
40 | + return sn; | |
41 | + } | |
42 | + | |
43 | + public void setSn(long sn) { | |
44 | + this.sn = sn; | |
45 | + } | |
46 | + | |
47 | + public String getCardNo() { | |
48 | + return cardNo; | |
49 | + } | |
50 | + | |
51 | + public void setCardNo(String cardNo) { | |
52 | + this.cardNo = cardNo; | |
53 | + } | |
54 | +} | ... | ... |
cloud/weigeng/src/main/java/com/sincere/weigeng/vo/CleanShiDuanVo.java
0 → 100644
... | ... | @@ -0,0 +1,44 @@ |
1 | +package com.sincere.weigeng.vo; | |
2 | + | |
3 | +/** | |
4 | + * @author chen | |
5 | + * @version 1.0 | |
6 | + * @date 2019/11/1 0001 8:12 | |
7 | + */ | |
8 | +public class CleanShiDuanVo { | |
9 | + | |
10 | + /** | |
11 | + * | |
12 | + * @param id 指令 | |
13 | + * @param sn 设备号 | |
14 | + * @param type 设备类型 | |
15 | + * @return | |
16 | + */ | |
17 | + private int id ; | |
18 | + private int type ; | |
19 | + private long sn ; | |
20 | + | |
21 | + public int getId() { | |
22 | + return id; | |
23 | + } | |
24 | + | |
25 | + public void setId(int id) { | |
26 | + this.id = id; | |
27 | + } | |
28 | + | |
29 | + public int getType() { | |
30 | + return type; | |
31 | + } | |
32 | + | |
33 | + public void setType(int type) { | |
34 | + this.type = type; | |
35 | + } | |
36 | + | |
37 | + public long getSn() { | |
38 | + return sn; | |
39 | + } | |
40 | + | |
41 | + public void setSn(long sn) { | |
42 | + this.sn = sn; | |
43 | + } | |
44 | +} | ... | ... |
cloud/weigeng/src/main/java/com/sincere/weigeng/vo/OpenDoorVo.java
0 → 100644
... | ... | @@ -0,0 +1,53 @@ |
1 | +package com.sincere.weigeng.vo; | |
2 | + | |
3 | +/** | |
4 | + * @author chen | |
5 | + * @version 1.0 | |
6 | + * @date 2019/11/1 0001 7:58 | |
7 | + */ | |
8 | +public class OpenDoorVo { | |
9 | + /** | |
10 | + * 开门 | |
11 | + * @param sn 设备号 | |
12 | + * @param id 指令id | |
13 | + * @param doorNo 门号 | |
14 | + * @param type 设备类型 微耕 =1 | |
15 | + * @return | |
16 | + */ | |
17 | + private int id ; | |
18 | + private int type ; | |
19 | + private long sn ; | |
20 | + private int doorNo ; | |
21 | + | |
22 | + public int getId() { | |
23 | + return id; | |
24 | + } | |
25 | + | |
26 | + public void setId(int id) { | |
27 | + this.id = id; | |
28 | + } | |
29 | + | |
30 | + public int getType() { | |
31 | + return type; | |
32 | + } | |
33 | + | |
34 | + public void setType(int type) { | |
35 | + this.type = type; | |
36 | + } | |
37 | + | |
38 | + public long getSn() { | |
39 | + return sn; | |
40 | + } | |
41 | + | |
42 | + public void setSn(long sn) { | |
43 | + this.sn = sn; | |
44 | + } | |
45 | + | |
46 | + public int getDoorNo() { | |
47 | + return doorNo; | |
48 | + } | |
49 | + | |
50 | + public void setDoorNo(int doorNo) { | |
51 | + this.doorNo = doorNo; | |
52 | + } | |
53 | +} | ... | ... |
cloud/weigeng/src/main/java/com/sincere/weigeng/vo/SignalCardInfoVo.java
0 → 100644
... | ... | @@ -0,0 +1,95 @@ |
1 | +package com.sincere.weigeng.vo; | |
2 | + | |
3 | +import java.util.Date; | |
4 | + | |
5 | +/** | |
6 | + * @author chen | |
7 | + * @version 1.0 | |
8 | + * @date 2019/11/1 0001 8:05 | |
9 | + */ | |
10 | +public class SignalCardInfoVo { | |
11 | + /** | |
12 | + * 单个卡号的权限添加或修改 | |
13 | + * @param updateId updateCard 主键 | |
14 | + * @param cardNo 卡号 十进制 | |
15 | + * @param id 指令 | |
16 | + * @param sn 设备号 | |
17 | + * @param shiduan 时段 | |
18 | + * @param startTime 卡权限有效开始时间 | |
19 | + * @param endTime 卡权限有效结束时间 | |
20 | + * @param type 设备类型 | |
21 | + * @return | |
22 | + */ | |
23 | + private int id ; | |
24 | + private int type ; | |
25 | + private int updateId ; | |
26 | + private String cardNo ; | |
27 | + private long sn ; | |
28 | + private Date startTime ; | |
29 | + private Date endTime ; | |
30 | + private int shiduan ; | |
31 | + | |
32 | + public int getId() { | |
33 | + return id; | |
34 | + } | |
35 | + | |
36 | + public void setId(int id) { | |
37 | + this.id = id; | |
38 | + } | |
39 | + | |
40 | + public int getType() { | |
41 | + return type; | |
42 | + } | |
43 | + | |
44 | + public void setType(int type) { | |
45 | + this.type = type; | |
46 | + } | |
47 | + | |
48 | + public int getUpdateId() { | |
49 | + return updateId; | |
50 | + } | |
51 | + | |
52 | + public void setUpdateId(int updateId) { | |
53 | + this.updateId = updateId; | |
54 | + } | |
55 | + | |
56 | + public String getCardNo() { | |
57 | + return cardNo; | |
58 | + } | |
59 | + | |
60 | + public void setCardNo(String cardNo) { | |
61 | + this.cardNo = cardNo; | |
62 | + } | |
63 | + | |
64 | + public long getSn() { | |
65 | + return sn; | |
66 | + } | |
67 | + | |
68 | + public void setSn(long sn) { | |
69 | + this.sn = sn; | |
70 | + } | |
71 | + | |
72 | + public Date getStartTime() { | |
73 | + return startTime; | |
74 | + } | |
75 | + | |
76 | + public void setStartTime(Date startTime) { | |
77 | + this.startTime = startTime; | |
78 | + } | |
79 | + | |
80 | + public Date getEndTime() { | |
81 | + return endTime; | |
82 | + } | |
83 | + | |
84 | + public void setEndTime(Date endTime) { | |
85 | + this.endTime = endTime; | |
86 | + } | |
87 | + | |
88 | + public int getShiduan() { | |
89 | + return shiduan; | |
90 | + } | |
91 | + | |
92 | + public void setShiduan(int shiduan) { | |
93 | + this.shiduan = shiduan; | |
94 | + } | |
95 | +} | ... | ... |
... | ... | @@ -0,0 +1,20 @@ |
1 | +server: | |
2 | + port: 9000 | |
3 | + | |
4 | +spring: | |
5 | + application: | |
6 | + name: weigeng-server | |
7 | + profiles: | |
8 | + active: dev | |
9 | + | |
10 | + | |
11 | +eureka: | |
12 | + instance: | |
13 | + hostname: localhost | |
14 | + lease-expiration-duration-in-seconds: 60 | |
15 | + lease-renewal-interval-in-seconds: 10 | |
16 | + client: | |
17 | + service-url: | |
18 | + # defaultZone: http://localhost:8761/eureka/ | |
19 | + defaultZone: http://localhost:8761/eureka/,http://localhost:8762/eureka/ | |
20 | + | ... | ... |
... | ... | @@ -0,0 +1,118 @@ |
1 | +<?xml version="1.0" encoding="utf-8" ?> | |
2 | +<configuration scan="true" scanPeriod="60 seconds" debug="false"> | |
3 | + <!-- 定义日志文件 输入位置 --> | |
4 | + <property name="logPath" value="d:/wg_log" /> | |
5 | + <!-- 日志最大的历史 30天 --> | |
6 | + <property name="maxHistory" value="600"/> | |
7 | + | |
8 | + <!-- 配置项, 通过此节点配置日志输出位置(控制台、文件、数据库)、输出格式等--> | |
9 | + <!-- ConsoleAppender代表输出到控制台 --> | |
10 | + <appender name="consoleLog" class="ch.qos.logback.core.ConsoleAppender"> | |
11 | + <!-- layout代表输出格式 --> | |
12 | + <layout class="ch.qos.logback.classic.PatternLayout"> | |
13 | + <pattern>%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger -%msg%n</pattern> | |
14 | + </layout> | |
15 | + </appender> | |
16 | + <!-- 日志输出文件 --> | |
17 | + <appender name="orderSuccessInfoLog" class="ch.qos.logback.core.rolling.RollingFileAppender"> | |
18 | + <encoder> | |
19 | + <pattern>%d{yyyy-MM-dd HH:mm:ss} -%msg%n</pattern> | |
20 | + </encoder> | |
21 | + <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> | |
22 | + <timeBasedFileNamingAndTriggeringPolicy class="com.sincere.weigeng.logs.MyTimeBasedFileNamingAndTriggeringPolicy"> | |
23 | + <multiple>1</multiple> | |
24 | + </timeBasedFileNamingAndTriggeringPolicy> | |
25 | + <!-- 输出路径 --> | |
26 | + <fileNamePattern>${logPath}/info/orderSuccess/%d{yyyy-MM-dd HH}.log</fileNamePattern> | |
27 | + <maxHistory>${maxHistory}</maxHistory> | |
28 | + </rollingPolicy> | |
29 | + </appender> | |
30 | + <appender name="orderFailInfoLog" class="ch.qos.logback.core.rolling.RollingFileAppender"> | |
31 | + <encoder> | |
32 | + <pattern>%d{yyyy-MM-dd HH:mm:ss} -%msg%n</pattern> | |
33 | + </encoder> | |
34 | + <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> | |
35 | + <timeBasedFileNamingAndTriggeringPolicy class="com.sincere.weigeng.logs.MyTimeBasedFileNamingAndTriggeringPolicy"> | |
36 | + <multiple>1</multiple> | |
37 | + </timeBasedFileNamingAndTriggeringPolicy> | |
38 | + <!-- 输出路径 --> | |
39 | + <fileNamePattern>${logPath}/info/orderFail/%d{yyyy-MM-dd HH}.log</fileNamePattern> | |
40 | + <maxHistory>${maxHistory}</maxHistory> | |
41 | + </rollingPolicy> | |
42 | + </appender> | |
43 | + <appender name="heartBeatLog" class="ch.qos.logback.core.rolling.RollingFileAppender"> | |
44 | + <encoder> | |
45 | + <pattern>%d{yyyy-MM-dd HH:mm:ss} -%msg%n</pattern> | |
46 | + </encoder> | |
47 | + <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> | |
48 | + <timeBasedFileNamingAndTriggeringPolicy class="com.sincere.weigeng.logs.MyTimeBasedFileNamingAndTriggeringPolicy"> | |
49 | + <multiple>1</multiple> | |
50 | + </timeBasedFileNamingAndTriggeringPolicy> | |
51 | + <!-- 输出路径 --> | |
52 | + <fileNamePattern>${logPath}/info/heartBeat/%d{yyyy-MM-dd HH}.log</fileNamePattern> | |
53 | + <maxHistory>${maxHistory}</maxHistory> | |
54 | + </rollingPolicy> | |
55 | + </appender> | |
56 | + <appender name="kaoInfoInfoLog" class="ch.qos.logback.core.rolling.RollingFileAppender"> | |
57 | + <encoder> | |
58 | + <pattern>%d{yyyy-MM-dd HH:mm:ss} -%msg%n</pattern> | |
59 | + </encoder> | |
60 | + <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> | |
61 | + <timeBasedFileNamingAndTriggeringPolicy class="com.sincere.weigeng.logs.MyTimeBasedFileNamingAndTriggeringPolicy"> | |
62 | + <multiple>1</multiple> | |
63 | + </timeBasedFileNamingAndTriggeringPolicy> | |
64 | + <!-- 输出路径 --> | |
65 | + <fileNamePattern>${logPath}/info/kaoInfo/%d{yyyy-MM-dd HH}.log</fileNamePattern> | |
66 | + <maxHistory>${maxHistory}</maxHistory> | |
67 | + </rollingPolicy> | |
68 | + </appender> | |
69 | + | |
70 | + | |
71 | + <!-- 特殊记录Error日志 --> | |
72 | + <appender name="fileErrorLog" class="ch.qos.logback.core.rolling.RollingFileAppender"> | |
73 | + <!-- 只记录ERROR级别日志,添加范围过滤,可以将该类型的日志特殊记录到某个位置 --> | |
74 | + <filter class="ch.qos.logback.classic.filter.ThresholdFilter"> | |
75 | + <level>ERROR</level> | |
76 | + </filter> | |
77 | + <encoder> | |
78 | + <pattern>%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger -%msg%n</pattern> | |
79 | + </encoder> | |
80 | + <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> | |
81 | + <timeBasedFileNamingAndTriggeringPolicy class="com.sincere.weigeng.logs.MyTimeBasedFileNamingAndTriggeringPolicy"> | |
82 | + <multiple>1</multiple> | |
83 | + </timeBasedFileNamingAndTriggeringPolicy> | |
84 | + <fileNamePattern>${logPath}/infoError/${PROJECT_NAME}.%d{yyyy-MM-dd}.log</fileNamePattern> | |
85 | + <!-- 日志最大的历史 60天 --> | |
86 | + <maxHistory>${maxHistory}</maxHistory> | |
87 | + </rollingPolicy> | |
88 | + </appender> | |
89 | + | |
90 | + <!-- 不同的业务逻辑日志打印到指定文件夹--> | |
91 | + <logger name="orderSuccess" additivity="false" level="INFO"> | |
92 | + <appender-ref ref="orderSuccessInfoLog"/> | |
93 | + </logger> | |
94 | + <logger name="orderFail" additivity="false" level="INFO"> | |
95 | + <appender-ref ref="orderFailInfoLog"/> | |
96 | + </logger> | |
97 | + <logger name="kaoInfo" additivity="false" level="INFO"> | |
98 | + <appender-ref ref="kaoInfoInfoLog"/> | |
99 | + </logger> | |
100 | + <logger name="heartBeat" additivity="false" level="INFO"> | |
101 | + <appender-ref ref="heartBeatLog"/> | |
102 | + </logger> | |
103 | + <logger name="error" additivity="false" level="ERROR"> | |
104 | + <appender-ref ref="fileErrorLog"/> | |
105 | + </logger> | |
106 | + | |
107 | + <root level="info"> | |
108 | + <appender-ref ref="consoleLog" /> | |
109 | + <appender-ref ref="orderSuccessInfoLog" /> | |
110 | + <appender-ref ref="orderFailInfoLog" /> | |
111 | + <appender-ref ref="kaoInfoInfoLog" /> | |
112 | + <appender-ref ref="heartBeatLog" /> | |
113 | + </root> | |
114 | + | |
115 | + <root level="error"> | |
116 | + <appender-ref ref="fileErrorLog" /> | |
117 | + </root> | |
118 | +</configuration> | |
0 | 119 | \ No newline at end of file | ... | ... |