|
@@ -21,6 +21,8 @@ import com.huimv.receive.timer.test.TestWeight;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.data.redis.core.RedisTemplate;
|
|
|
import org.springframework.http.ResponseEntity;
|
|
|
+
|
|
|
+import org.springframework.mock.web.MockMultipartFile;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
import org.springframework.web.client.RestTemplate;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
@@ -28,9 +30,12 @@ import org.springframework.web.multipart.MultipartFile;
|
|
|
import javax.imageio.ImageIO;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
+import java.awt.*;
|
|
|
import java.awt.image.BufferedImage;
|
|
|
-import java.io.File;
|
|
|
-import java.io.IOException;
|
|
|
+import java.io.*;
|
|
|
+import java.net.HttpURLConnection;
|
|
|
+import java.net.MalformedURLException;
|
|
|
+import java.net.URL;
|
|
|
import java.util.Date;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
@@ -56,15 +61,15 @@ public class LoginController {
|
|
|
private BillGateMapper billGateMapper;
|
|
|
|
|
|
@PostMapping("/saveDiBang")
|
|
|
- public String logout(@RequestBody Map<String, List<TestWeight>> map ) {
|
|
|
+ public String logout(@RequestBody Map<String, List<TestWeight>> map) {
|
|
|
List<TestWeight> dibang = map.get("dibang");
|
|
|
for (TestWeight testWeight : dibang) {
|
|
|
System.out.println(testWeight);
|
|
|
|
|
|
- BillGate billGate = billGateMapper.selectOne(new QueryWrapper<BillGate>().eq("stdno",testWeight.getFStdNo()));
|
|
|
+ BillGate billGate = billGateMapper.selectOne(new QueryWrapper<BillGate>().eq("stdno", testWeight.getFStdNo()));
|
|
|
if (ObjectUtil.isEmpty(billGate)) {
|
|
|
List<BillGate> billGate1 = billGateMapper.selectList(new QueryWrapper<BillGate>().eq("car_num", testWeight.getFCarNo())
|
|
|
- .between("check_date", testWeight.getBeginTime(), testWeight.getEndTime()).eq("check_location",testWeight.getDeviceCode()));
|
|
|
+ .between("check_date", testWeight.getBeginTime(), testWeight.getEndTime()).eq("check_location", testWeight.getDeviceCode()));
|
|
|
if (ObjectUtil.isNotEmpty(billGate1)) {
|
|
|
billGate = billGate1.get(0);
|
|
|
billGate.setGross(testWeight.getGross() + "");
|
|
@@ -85,13 +90,12 @@ public class LoginController {
|
|
|
}
|
|
|
|
|
|
@PostMapping("/test")
|
|
|
- public Result test(@RequestParam(name = "picture1")MultipartFile picture1 ) throws IOException {
|
|
|
+ public Result test(@RequestParam(name = "picture1") MultipartFile picture1) throws IOException {
|
|
|
uploadImage.getVideoCom(picture1);
|
|
|
return iLoginService.logout();
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
@Autowired
|
|
|
private RedisTemplate<String, String> redisTemplate;
|
|
|
|
|
@@ -171,33 +175,33 @@ public class LoginController {
|
|
|
String type = map.get("type");
|
|
|
String remoteHost = req.getRemoteHost();
|
|
|
// 未对密码加密
|
|
|
- SysAccountMultilevel accountEntity = accountMultilevelService.getById(userId);
|
|
|
+ SysAccountMultilevel accountEntity = accountMultilevelService.getById(userId);
|
|
|
|
|
|
- accountEntity.setType(Integer.parseInt(type));
|
|
|
- accountMultilevelService.updateById(accountEntity);
|
|
|
- accountEntity.setJobName(baseJobService.getById(type).getJobName());
|
|
|
+ accountEntity.setType(Integer.parseInt(type));
|
|
|
+ accountMultilevelService.updateById(accountEntity);
|
|
|
+ accountEntity.setJobName(baseJobService.getById(type).getJobName());
|
|
|
|
|
|
- Integer id = accountEntity.getId();
|
|
|
- IpTools.getRemoteHost(req);
|
|
|
- AccessToken accessToken = new AccessToken();
|
|
|
- accessToken.setCreated(new Date());
|
|
|
- accessToken.setAccountName(accountEntity.getAccount());
|
|
|
- accessToken.setFarmId(accountEntity.getFarmIds());
|
|
|
- String token = TokenSign.sign(accountEntity.getUserName(), id, accountEntity.getFarmIds(), accountEntity.getWorkLocationType()+"", accountEntity.getType());
|
|
|
- accessToken.setToken(token);
|
|
|
+ Integer id = accountEntity.getId();
|
|
|
+ IpTools.getRemoteHost(req);
|
|
|
+ AccessToken accessToken = new AccessToken();
|
|
|
+ accessToken.setCreated(new Date());
|
|
|
+ accessToken.setAccountName(accountEntity.getAccount());
|
|
|
+ accessToken.setFarmId(accountEntity.getFarmIds());
|
|
|
+ String token = TokenSign.sign(accountEntity.getUserName(), id, accountEntity.getFarmIds(), accountEntity.getWorkLocationType() + "", accountEntity.getType());
|
|
|
+ accessToken.setToken(token);
|
|
|
|
|
|
- accessToken.setId(id);
|
|
|
- accessToken.setLoginIp(remoteHost);
|
|
|
- accessToken.setType(accountEntity.getType());
|
|
|
- Integer lastFarmId = accountEntity.getLastFarmId();
|
|
|
- if (ObjectUtil.isEmpty(lastFarmId)) {
|
|
|
- lastFarmId = Integer.parseInt(accountEntity.getFarmIds().split(",")[0]);
|
|
|
- }
|
|
|
- accessToken.setLastFarmId(lastFarmId);
|
|
|
- accessToken.setUserName(accountEntity.getUserName());
|
|
|
- accessToken.setSysAccountMultilevel(accountEntity);
|
|
|
+ accessToken.setId(id);
|
|
|
+ accessToken.setLoginIp(remoteHost);
|
|
|
+ accessToken.setType(accountEntity.getType());
|
|
|
+ Integer lastFarmId = accountEntity.getLastFarmId();
|
|
|
+ if (ObjectUtil.isEmpty(lastFarmId)) {
|
|
|
+ lastFarmId = Integer.parseInt(accountEntity.getFarmIds().split(",")[0]);
|
|
|
+ }
|
|
|
+ accessToken.setLastFarmId(lastFarmId);
|
|
|
+ accessToken.setUserName(accountEntity.getUserName());
|
|
|
+ accessToken.setSysAccountMultilevel(accountEntity);
|
|
|
|
|
|
- return new Result(ResultCode.SUCCESS, accessToken);
|
|
|
+ return new Result(ResultCode.SUCCESS, accessToken);
|
|
|
}
|
|
|
|
|
|
//测试-token
|
|
@@ -236,11 +240,11 @@ public class LoginController {
|
|
|
accessToken.setAccountName(accountName);
|
|
|
accessToken.setFarmId(accountEntity.getFarmIds());
|
|
|
Integer lastFarmId1 = accountEntity.getLastFarmId();
|
|
|
- if (ObjectUtil.isEmpty(lastFarmId1)){
|
|
|
+ if (ObjectUtil.isEmpty(lastFarmId1)) {
|
|
|
lastFarmId1 = accountEntity.getFarmId();
|
|
|
}
|
|
|
|
|
|
- String token = TokenSign.sign(accountName, id,lastFarmId1.toString() , accountEntity.getWorkLocationType(),accountEntity.getType());
|
|
|
+ String token = TokenSign.sign(accountName, id, lastFarmId1.toString(), accountEntity.getWorkLocationType(), accountEntity.getType());
|
|
|
accessToken.setToken(token);
|
|
|
|
|
|
accessToken.setId(id);
|
|
@@ -273,7 +277,7 @@ public class LoginController {
|
|
|
accessToken.setFarmId(data.getFarmIds());
|
|
|
accessToken.setType(data.getType());
|
|
|
accessToken.setId(data.getId());
|
|
|
- String token = TokenSign.sign(data.getUserName(), data.getId(), data.getLastFarmId().toString(), data.getWorkLocationType()+"", data.getType());
|
|
|
+ String token = TokenSign.sign(data.getUserName(), data.getId(), data.getLastFarmId().toString(), data.getWorkLocationType() + "", data.getType());
|
|
|
accessToken.setToken(token);
|
|
|
Integer lastFarmId = data.getLastFarmId();
|
|
|
if (ObjectUtil.isEmpty(lastFarmId)) {
|
|
@@ -352,7 +356,7 @@ public class LoginController {
|
|
|
}*/
|
|
|
|
|
|
@GetMapping("/logoutWeChat")
|
|
|
- public Result logoutWeChat(HttpServletRequest req, @RequestParam String jsCode,@RequestParam String phone) {
|
|
|
+ public Result logoutWeChat(HttpServletRequest req, @RequestParam String jsCode, @RequestParam String phone) {
|
|
|
String remoteHost = req.getRemoteHost();
|
|
|
Map<String, Object> paramsMap = new HashMap<>();
|
|
|
paramsMap.put("appid", "wx221c66f51278c05f");
|
|
@@ -398,7 +402,7 @@ public class LoginController {
|
|
|
accessToken.setFarmId(data1.getFarmIds());
|
|
|
accessToken.setType(7);
|
|
|
accessToken.setId(data1.getId());
|
|
|
- String token = TokenSign.sign(data1.getUserName(), data1.getId(), data1.getLastFarmId().toString(), data1.getWorkLocationType()+"", 7);
|
|
|
+ String token = TokenSign.sign(data1.getUserName(), data1.getId(), data1.getLastFarmId().toString(), data1.getWorkLocationType() + "", 7);
|
|
|
accessToken.setToken(token);
|
|
|
Integer lastFarmId = data1.getLastFarmId();
|
|
|
if (ObjectUtil.isEmpty(lastFarmId)) {
|
|
@@ -427,7 +431,7 @@ public class LoginController {
|
|
|
accessToken.setFarmId(data.getFarmIds());
|
|
|
accessToken.setType(7);
|
|
|
accessToken.setId(data.getId());
|
|
|
- String token = TokenSign.sign(data.getUserName(), data.getId(), data.getLastFarmId().toString(), data.getWorkLocationType()+"", 7);
|
|
|
+ String token = TokenSign.sign(data.getUserName(), data.getId(), data.getLastFarmId().toString(), data.getWorkLocationType() + "", 7);
|
|
|
accessToken.setToken(token);
|
|
|
Integer lastFarmId = data.getLastFarmId();
|
|
|
if (ObjectUtil.isEmpty(lastFarmId)) {
|
|
@@ -436,7 +440,7 @@ public class LoginController {
|
|
|
accessToken.setLastFarmId(lastFarmId);
|
|
|
accessToken.setLoginIp(remoteHost);
|
|
|
return new Result(ResultCode.SUCCESS, accessToken);
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
return new Result(ResultCode.UNAUTHENTICATED, "输入的手机号已被他人进行过微信登录!");
|
|
|
}
|
|
|
}
|
|
@@ -444,15 +448,15 @@ public class LoginController {
|
|
|
|
|
|
@GetMapping("/logWeChatGetPhone")
|
|
|
public Result logWeChatGetPhone(HttpServletRequest req, @RequestParam String jsCode) {
|
|
|
- String access_token ="";
|
|
|
- if ( !redisTemplate.hasKey("weChatGetPhone") || redisTemplate.getExpire("weChatGetPhone") ==null || redisTemplate.getExpire("weChatGetPhone") <=0){
|
|
|
+ String access_token = "";
|
|
|
+ if (!redisTemplate.hasKey("weChatGetPhone") || redisTemplate.getExpire("weChatGetPhone") == null || redisTemplate.getExpire("weChatGetPhone") <= 0) {
|
|
|
String result = HttpUtil.get("https://api.weixin.qq.com/cgi-bin/token?appid=wx221c66f51278c05f&secret=b553cf2e2de240ac93db6b6c8d135f55&grant_type=client_credential");
|
|
|
System.out.println(result);
|
|
|
JSONObject jsonObject = JSON.parseObject(result);
|
|
|
- access_token = (String) jsonObject.get("access_token");
|
|
|
- redisTemplate.opsForValue().set("weChatGetPhone",access_token);
|
|
|
- redisTemplate.expire("weChatGetPhone",7200,TimeUnit.SECONDS);
|
|
|
- }else {
|
|
|
+ access_token = (String) jsonObject.get("access_token");
|
|
|
+ redisTemplate.opsForValue().set("weChatGetPhone", access_token);
|
|
|
+ redisTemplate.expire("weChatGetPhone", 7200, TimeUnit.SECONDS);
|
|
|
+ } else {
|
|
|
access_token = redisTemplate.opsForValue().get("weChatGetPhone");
|
|
|
}
|
|
|
RestTemplate restTemplate = new RestTemplate();
|
|
@@ -461,11 +465,12 @@ public class LoginController {
|
|
|
ResponseEntity<String> stringResponseEntity = restTemplate.postForEntity("https://api.weixin.qq.com/wxa/business/getuserphonenumber?access_token=" + access_token, paramsMap, String.class);
|
|
|
|
|
|
System.out.println(stringResponseEntity.getBody());
|
|
|
- return new Result(ResultCode.SUCCESS,JSON.parseObject(stringResponseEntity.getBody()));
|
|
|
+ return new Result(ResultCode.SUCCESS, JSON.parseObject(stringResponseEntity.getBody()));
|
|
|
}
|
|
|
+
|
|
|
@PostMapping("/register2")
|
|
|
- public String register2( @RequestParam(value = "video", required = false) MultipartFile video) throws IOException {
|
|
|
- return uploadImage.getVideoCom(video);
|
|
|
+ public String register2(@RequestParam(value = "video", required = false) MultipartFile video) throws IOException {
|
|
|
+ return uploadImage.getVideoCom(video);
|
|
|
}
|
|
|
|
|
|
@PostMapping("/register")
|
|
@@ -479,12 +484,12 @@ public class LoginController {
|
|
|
String remoteHost = req.getRemoteHost();
|
|
|
|
|
|
MultipartFile multipartFile = ImageSizeUtil.byte2Base64StringFun(imgUrl);
|
|
|
- boolean result = uploadImage.checkFileSize(multipartFile.getSize(), 200, "K");
|
|
|
+ boolean result = uploadImage.checkFileSize(multipartFile.getSize(), 100, "K");
|
|
|
if (!result) {
|
|
|
return new Result(10001, "上传个人照片太大,请重新上传", false);
|
|
|
}
|
|
|
QueryWrapper<SysAccountMultilevel> queryWrapper = new QueryWrapper<>();
|
|
|
- queryWrapper.eq("type",7).and(i->i.eq("phone", phone).or().eq("papers_code", papersCode));
|
|
|
+ queryWrapper.eq("type", 7).and(i -> i.eq("phone", phone).or().eq("papers_code", papersCode));
|
|
|
if (ObjectUtil.isNotEmpty(accountMultilevelService.getOne(queryWrapper))) {
|
|
|
return new Result(10001, "该手机号或身份证号已被使用!", false);
|
|
|
}
|
|
@@ -524,7 +529,7 @@ public class LoginController {
|
|
|
accessToken.setFarmId(sysAccountMultilevel.getFarmIds());
|
|
|
accessToken.setType(sysAccountMultilevel.getType());
|
|
|
accessToken.setId(sysAccountMultilevel.getId());
|
|
|
- String token = TokenSign.sign(sysAccountMultilevel.getUserName(), sysAccountMultilevel.getId(), sysAccountMultilevel.getLastFarmId().toString(), sysAccountMultilevel.getWorkLocationType()+"", sysAccountMultilevel.getType());
|
|
|
+ String token = TokenSign.sign(sysAccountMultilevel.getUserName(), sysAccountMultilevel.getId(), sysAccountMultilevel.getLastFarmId().toString(), sysAccountMultilevel.getWorkLocationType() + "", sysAccountMultilevel.getType());
|
|
|
accessToken.setToken(token);
|
|
|
Integer lastFarmId = sysAccountMultilevel.getLastFarmId();
|
|
|
if (ObjectUtil.isEmpty(lastFarmId)) {
|
|
@@ -534,4 +539,46 @@ public class LoginController {
|
|
|
accessToken.setLoginIp(remoteHost);
|
|
|
return new Result(ResultCode.SUCCESS, accessToken);
|
|
|
}
|
|
|
+
|
|
|
+ @PostMapping("/test1")
|
|
|
+ public Result test1() throws IOException {
|
|
|
+ List<SysAccountMultilevel> list = accountMultilevelService.list();
|
|
|
+ for (SysAccountMultilevel sysAccountMultilevel : list) {
|
|
|
+ String imgUrl = sysAccountMultilevel.getImgUrl();
|
|
|
+ if (null == imgUrl || "".equals(imgUrl)) {}else{
|
|
|
+ URL url = new URL(imgUrl);
|
|
|
+ // 将在线图片地址转换为URL对象
|
|
|
+// 打开URL连接
|
|
|
+ HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
|
|
+// 获取输入流
|
|
|
+ InputStream inputStream = connection.getInputStream();
|
|
|
+// 读取输入流中的数据,并保存到字节数组中
|
|
|
+ ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
|
|
+ byte[] buffer = new byte[1024];
|
|
|
+ int bytesRead;
|
|
|
+ while ((bytesRead = inputStream.read(buffer)) != -1) {
|
|
|
+ byteArrayOutputStream.write(buffer, 0, bytesRead);
|
|
|
+ }
|
|
|
+// 将字节数组转换为字节数组输入流
|
|
|
+ ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(byteArrayOutputStream.toByteArray());
|
|
|
+// 创建MultipartFile对象
|
|
|
+ MultipartFile file = new MockMultipartFile("file", "filename.jpg", "image/jpg", byteArrayInputStream);
|
|
|
+ MultipartFile multipartFile = ImageSizeUtil.byte2Base64StringFun(file);
|
|
|
+ boolean result = uploadImage.checkFileSize(multipartFile.getSize(), 100, "K");
|
|
|
+ if (!result) {
|
|
|
+ return new Result(10001, "上传个人照片太大,请重新上传", false);
|
|
|
+ }
|
|
|
+ String imageCom = uploadImage.getImageCom(multipartFile);
|
|
|
+ if (imageCom.equals("上传失败")) {
|
|
|
+ return new Result(10001, "图片上传失败!", false);
|
|
|
+ }
|
|
|
+ sysAccountMultilevel.setImgUrl(imageCom);
|
|
|
+ accountMultilevelService.updateById(sysAccountMultilevel);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ return new Result(ResultCode.SUCCESS);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|