|
@@ -1,6 +1,9 @@
|
|
|
package com.huimv.receive.service.impl;
|
|
|
|
|
|
+import cn.hutool.core.io.FileUtil;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
+import cn.hutool.http.Header;
|
|
|
+import cn.hutool.http.HttpRequest;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
|
@@ -22,7 +25,11 @@ import org.springframework.web.multipart.MultipartFile;
|
|
|
import javax.annotation.Resource;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
+import java.io.FileOutputStream;
|
|
|
import java.io.IOException;
|
|
|
+import java.io.InputStream;
|
|
|
+import java.net.HttpURLConnection;
|
|
|
+import java.net.URL;
|
|
|
import java.text.DecimalFormat;
|
|
|
import java.text.ParseException;
|
|
|
import java.text.SimpleDateFormat;
|
|
@@ -227,13 +234,13 @@ public class BillPcrServiceImpl extends ServiceImpl<BillPcrMapper, BillPcr> impl
|
|
|
QueryWrapper<BillPcr> queryWrapper = new QueryWrapper<>();
|
|
|
queryWrapper.eq("farm_id", farmId);
|
|
|
Integer integer = pcrMapper.selectCount(queryWrapper);//检测总数
|
|
|
- queryWrapper.in("bill_status", 1,3);
|
|
|
+ queryWrapper.in("bill_status", 1, 3);
|
|
|
Integer integer1 = pcrMapper.selectCount(queryWrapper);//合格总数
|
|
|
queryWrapper.orderByDesc("sub_date").last(" limit 10");
|
|
|
DecimalFormat def = new DecimalFormat("0.00");
|
|
|
String rank;
|
|
|
if (integer == 0 || integer == null) {
|
|
|
- Double ranks = Double.valueOf("0.00");
|
|
|
+ Double ranks = Double.valueOf("0.00");
|
|
|
rank = ranks.toString();
|
|
|
} else {
|
|
|
Double ranks = (Double.valueOf(integer1.toString()) / Double.valueOf(integer.toString())) * 100;
|
|
@@ -264,6 +271,12 @@ public class BillPcrServiceImpl extends ServiceImpl<BillPcrMapper, BillPcr> impl
|
|
|
private UploadImage uploadImage;
|
|
|
@Autowired
|
|
|
private ExistMapper existMapper;
|
|
|
+ @Autowired
|
|
|
+ private DeviceListMapper deviceListMapper;
|
|
|
+ @Autowired
|
|
|
+ private PeopleListMapper peopleListMapper;
|
|
|
+ @Autowired
|
|
|
+ private BillPersonnelAdmissionMapper personnelAdmissionMapper;
|
|
|
|
|
|
@Override
|
|
|
public Result list(HttpServletRequest httpServletRequest, Map<String, String> paramsMap) {
|
|
@@ -313,9 +326,9 @@ public class BillPcrServiceImpl extends ServiceImpl<BillPcrMapper, BillPcr> impl
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public Result edit(HttpServletRequest httpServletRequest,String farmId, String id, String date, String result,
|
|
|
+ public Result edit(HttpServletRequest httpServletRequest, String farmId, String id, String date, String result,
|
|
|
MultipartFile img1, MultipartFile img2, MultipartFile img3) throws ParseException, IOException {
|
|
|
- //1为合格2为异常
|
|
|
+ //1为合格2为异常
|
|
|
String s1 = "";
|
|
|
String s2 = "";
|
|
|
String s3 = "";
|
|
@@ -340,7 +353,7 @@ public class BillPcrServiceImpl extends ServiceImpl<BillPcrMapper, BillPcr> impl
|
|
|
}
|
|
|
s3 = "," + uploadImage.uploadImg(img3);
|
|
|
}
|
|
|
- String s = s1 + s2 + s3 ;
|
|
|
+ String s = s1 + s2 + s3;
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
|
|
|
|
|
|
if (StringUtils.isBlank(date)) {
|
|
@@ -406,6 +419,72 @@ public class BillPcrServiceImpl extends ServiceImpl<BillPcrMapper, BillPcr> impl
|
|
|
billClean.setImgStatus(0);
|
|
|
billClean.setCarNum(billPcr.getCarNum());
|
|
|
cleanMapper.insert(billClean);
|
|
|
+ //通过生成门禁白名单
|
|
|
+ QueryWrapper<DeviceList> deviceListQueryWrapper = new QueryWrapper<>();
|
|
|
+ deviceListQueryWrapper.eq("farm_id", billPcr.getFarmId()).eq("location_id", baseLocation.getId());
|
|
|
+ List<DeviceList> deviceLists = deviceListMapper.selectList(deviceListQueryWrapper);
|
|
|
+ //找到对应的入场申请表
|
|
|
+ QueryWrapper<BillPersonnelAdmission> queryWrapper1 = new QueryWrapper<>();
|
|
|
+ queryWrapper1.eq("farm_id", billPcr.getFarmId()).eq("process_id", baseProcess.getId());
|
|
|
+ BillPersonnelAdmission billPersonnelAdmission = personnelAdmissionMapper.selectOne(queryWrapper1);
|
|
|
+ if (deviceLists.size() > 0) {
|
|
|
+ for (DeviceList deviceList : deviceLists) {
|
|
|
+ //通过生成门禁白名单
|
|
|
+ PeopleList peopleList = new PeopleList();
|
|
|
+ peopleList.setFarmId(billPcr.getFarmId().toString());
|
|
|
+ peopleList.setDeviceCode(deviceList.getDeviceCode());
|
|
|
+ peopleList.setUserId(billPcr.getAdmissionUserId());
|
|
|
+ peopleList.setUserName(billPcr.getAdmissionUserName());
|
|
|
+ peopleList.setPassword("123456");
|
|
|
+ peopleList.setType(0);
|
|
|
+ peopleList.setCreateTime(new Date());
|
|
|
+ Date date2 = new Date();
|
|
|
+ Calendar calendar = Calendar.getInstance();
|
|
|
+ calendar.setTime(date2);
|
|
|
+ calendar.add(Calendar.HOUR_OF_DAY, 2);
|
|
|
+ Date date1 = calendar.getTime();
|
|
|
+ peopleList.setOutTime(date1);
|
|
|
+ peopleListMapper.insert(peopleList);
|
|
|
+
|
|
|
+ HashMap<String, Object> jsonObject = new HashMap<>();
|
|
|
+ jsonObject.put("seq", deviceList.getDeviceCode());
|
|
|
+// String savePath = "D:\\works\\pig_projects\\甜妹.jpg";
|
|
|
+ String savePath = "/opt/huatong/test.jpg";
|
|
|
+ URL url = new URL(billPersonnelAdmission.getUserImgUrl());
|
|
|
+ HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
|
|
+ connection.setRequestMethod("GET");
|
|
|
+ int resCode = connection.getResponseCode();
|
|
|
+ if (resCode == HttpURLConnection.HTTP_OK) {
|
|
|
+ InputStream inputStream = connection.getInputStream();
|
|
|
+ byte[] buffer = new byte[4096];
|
|
|
+ int length;
|
|
|
+ //读取数据并写入到文件中
|
|
|
+ try (FileOutputStream outStream = new FileOutputStream(savePath)) {
|
|
|
+ while ((length = inputStream.read(buffer)) != -1) {
|
|
|
+ outStream.write(buffer, 0, length);
|
|
|
+ }
|
|
|
+ outStream.flush();
|
|
|
+ } finally {
|
|
|
+ inputStream.close();
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ System.out.println("文件下载错误码为" + resCode);
|
|
|
+ }
|
|
|
+
|
|
|
+// jsonObject.put("face", FileUtil.file("D:\\works\\pig_projects\\甜妹.jpg"));
|
|
|
+ jsonObject.put("face", FileUtil.file(savePath));
|
|
|
+ jsonObject.put("name", billPersonnelAdmission.getAdmissionUserName());
|
|
|
+ jsonObject.put("password", "123456");
|
|
|
+ jsonObject.put("timestamp", date1.getTime());
|
|
|
+ jsonObject.put("uid", billPersonnelAdmission.getAdmissionUserId());
|
|
|
+ String post = HttpRequest.post("http://39.173.90.137:8040/addDeviceUser")
|
|
|
+ .header(Header.CONTENT_TYPE, "multipart/form-data")
|
|
|
+ .form(jsonObject)
|
|
|
+ .timeout(30 * 1000).execute().body();
|
|
|
+ System.out.println(post);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
baseProcess.setUpdateDate(baseProcess.getUpdateDate() + "," + sdf.format(new Date()));
|
|
|
baseProcess.setCurrentLocation(baseProcess.getCurrentLocation() + "," + baseLocation.getLocationName());
|
|
@@ -481,7 +560,7 @@ public class BillPcrServiceImpl extends ServiceImpl<BillPcrMapper, BillPcr> impl
|
|
|
split[3] = "3";
|
|
|
baseProcess.setAllLocationStatus(split[0] + "," + split[1] + "," + split[2] + "," + split[3] + status1.substring(7));
|
|
|
}
|
|
|
- if (baseLocation.getId() == 4&&exist.getExist()==0) {
|
|
|
+ if (baseLocation.getId() == 4 && exist.getExist() == 0) {
|
|
|
//第三次不合格
|
|
|
baseProcess.setProcessType(2);
|
|
|
baseProcess.setCurrentLocation(baseProcess.getCurrentLocation());
|
|
@@ -495,7 +574,7 @@ public class BillPcrServiceImpl extends ServiceImpl<BillPcrMapper, BillPcr> impl
|
|
|
split[4] = "3";
|
|
|
baseProcess.setAllLocationStatus(split[0] + "," + split[1] + "," + split[2] + "," + split[3] + "," + split[4] + status1.substring(9));
|
|
|
}
|
|
|
- if (baseLocation.getId() == 4&&exist.getExist()==1) {
|
|
|
+ if (baseLocation.getId() == 4 && exist.getExist() == 1) {
|
|
|
//第三次不合格
|
|
|
baseProcess.setProcessType(2);
|
|
|
baseProcess.setCurrentLocation(baseProcess.getCurrentLocation());
|
|
@@ -514,21 +593,21 @@ public class BillPcrServiceImpl extends ServiceImpl<BillPcrMapper, BillPcr> impl
|
|
|
String[] split = status1.split(",");
|
|
|
split[0] = "2";
|
|
|
split[1] = "3";
|
|
|
- baseProcess.setAllLocationStatus(split[0] + "," + split[1] + status1.substring(3));
|
|
|
+ baseProcess.setAllLocationStatus(split[0] + "," + split[1] + status1.substring(3));
|
|
|
}
|
|
|
if (baseLocation.getId() == 15) {
|
|
|
String status1 = baseProcess.getAllLocationStatus();
|
|
|
String[] split = status1.split(",");
|
|
|
split[0] = "2";
|
|
|
split[1] = "3";
|
|
|
- baseProcess.setAllLocationStatus(split[0] + "," + split[1] + status1.substring(3));
|
|
|
+ baseProcess.setAllLocationStatus(split[0] + "," + split[1] + status1.substring(3));
|
|
|
}
|
|
|
if (baseLocation.getId() == 9) {
|
|
|
String status1 = baseProcess.getAllLocationStatus();
|
|
|
String[] split = status1.split(",");
|
|
|
split[0] = "2";
|
|
|
split[1] = "3";
|
|
|
- baseProcess.setAllLocationStatus(split[0] + "," + split[1] + status1.substring(3));
|
|
|
+ baseProcess.setAllLocationStatus(split[0] + "," + split[1] + status1.substring(3));
|
|
|
}
|
|
|
if (baseLocation.getId() == 10) {
|
|
|
String status1 = baseProcess.getAllLocationStatus();
|
|
@@ -610,7 +689,7 @@ public class BillPcrServiceImpl extends ServiceImpl<BillPcrMapper, BillPcr> impl
|
|
|
String[] split = status1.split(",");
|
|
|
split[0] = "2";
|
|
|
split[1] = "3";
|
|
|
- baseProcess.setAllLocationStatus(split[0] + "," + split[1] + status1.substring(3));
|
|
|
+ baseProcess.setAllLocationStatus(split[0] + "," + split[1] + status1.substring(3));
|
|
|
}
|
|
|
baseProcess.setUpdateDate(baseProcess.getUpdateDate() + "," + sdf.format(new Date()));
|
|
|
baseProcess.setCurrentLocation(baseProcess.getCurrentLocation());
|
|
@@ -624,7 +703,7 @@ public class BillPcrServiceImpl extends ServiceImpl<BillPcrMapper, BillPcr> impl
|
|
|
String[] split = status1.split(",");
|
|
|
split[0] = "2";
|
|
|
split[1] = "3";
|
|
|
- baseProcess.setAllLocationStatus(split[0] + "," + split[1] + status1.substring(3));
|
|
|
+ baseProcess.setAllLocationStatus(split[0] + "," + split[1] + status1.substring(3));
|
|
|
}
|
|
|
if (baseLocation.getId() == 10) {
|
|
|
String status1 = baseProcess.getAllLocationStatus();
|
|
@@ -645,7 +724,7 @@ public class BillPcrServiceImpl extends ServiceImpl<BillPcrMapper, BillPcr> impl
|
|
|
String[] split = status1.split(",");
|
|
|
split[0] = "2";
|
|
|
split[1] = "3";
|
|
|
- baseProcess.setAllLocationStatus(split[0] + "," + split[1] + status1.substring(3));
|
|
|
+ baseProcess.setAllLocationStatus(split[0] + "," + split[1] + status1.substring(3));
|
|
|
}
|
|
|
|
|
|
billPcr.setBillStatus(2);
|
|
@@ -662,10 +741,11 @@ public class BillPcrServiceImpl extends ServiceImpl<BillPcrMapper, BillPcr> impl
|
|
|
|
|
|
}
|
|
|
|
|
|
- }
|
|
|
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
+
|
|
|
private void xiugaiPro(BaseProcess baseProcess, BillPcr billPcr) {
|
|
|
baseProcess.setUpdateDate(baseProcess.getUpdateDate() + "," + new Date());
|
|
|
baseProcess.setCurrentLocation(baseProcess.getCurrentLocation() + "," + billPcr.getTestLocation());
|
|
@@ -693,3 +773,5 @@ public class BillPcrServiceImpl extends ServiceImpl<BillPcrMapper, BillPcr> impl
|
|
|
return "成功";
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+
|