Commit 38b9285d by 陶湘宇

增加自定义设置考勤机时间接口

parent be8bc544
...@@ -147,6 +147,24 @@ public class FkController { ...@@ -147,6 +147,24 @@ public class FkController {
return ResultUtil.data("设置失败,请联系管理员"); return ResultUtil.data("设置失败,请联系管理员");
} }
// 同步考勤机时间
@PostMapping("/setTimer")
public Result<String> setTime(@RequestParam String devId,@RequestParam String time) {
FkDev fkDev = FkDev.builder().build().selectOne(new LambdaQueryWrapper<FkDev>().eq(FkDev::getDevId, devId));
if (fkDev != null && (fkDev.getOrgCode() == 1 || fkDev.getOrgCode() == 2)) { // 1-浩顺 2-浩顺3代
boolean result = false;
try {
result = hsTools.setTime(devId,time);
} catch (Exception e) {
return ResultUtil.error("添加失败,请确认考勤机绑定状态");
}
if (result == false)
return ResultUtil.data("添加失败");
return ResultUtil.data("同步成功");
} else
return ResultUtil.data("设置失败,请联系管理员");
}
// 删除考勤机用户 // 删除考勤机用户
@PostMapping("/deleteUser") @PostMapping("/deleteUser")
public Result<String> deleteUser(@RequestParam String devId, @RequestParam String userId) { public Result<String> deleteUser(@RequestParam String devId, @RequestParam String userId) {
......
...@@ -1364,6 +1364,22 @@ public class HSTools { ...@@ -1364,6 +1364,22 @@ public class HSTools {
return result; return result;
} }
public boolean setTime(String devId,String time) {
String cmd = Command.SET_TIME;
Date now = new Date();
Device dev = Device.getDevice(devId);
String jsonStr = "{\"time\":\"" + time + "\"}";
FkHsRequest fkHsRequest = new FkHsRequest();
fkHsRequest.setJsonStr(jsonStr);
fkHsRequest.setDevId(devId);
fkHsRequest.setCommand(cmd);
fkHsRequest.setTime(now);
fkHsRequest.insert();
String transId = fkHsRequest.getId().toString();
boolean result = dev.addCmd(cmd, jsonStr, transId);
return result;
}
public boolean setDeleteUser(String devId, String userId) { public boolean setDeleteUser(String devId, String userId) {
String cmd = Command.DELETE_USER; String cmd = Command.DELETE_USER;
JSONObject vResultJson = new JSONObject(); JSONObject vResultJson = new JSONObject();
......
...@@ -3,8 +3,8 @@ server: ...@@ -3,8 +3,8 @@ server:
spring: spring:
datasource: datasource:
username: youling8timer username: youling8timer
password: (!0YouLing8Timer0!) password: (!0YouLingRoot0!)
url: jdbc:mysql://192.168.3.3:33000/record?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&allowMultiQueries=true&zeroDateTimeBehavior=CONVERT_TO_NULL url: jdbc:mysql://rm-wz950gd8jf8209376.mysql.rds.aliyuncs.com/record?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&allowMultiQueries=true&zeroDateTimeBehavior=CONVERT_TO_NULL
driver-class-name: com.mysql.cj.jdbc.Driver driver-class-name: com.mysql.cj.jdbc.Driver
jackson: jackson:
time-zone: Asia/Shanghai time-zone: Asia/Shanghai
......
spring: spring:
profiles: profiles:
active: test active: pro
#active: '@environment@' #active: '@environment@'
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment