|
@@ -1,30 +1,34 @@
|
|
package com.hboxs.control.api.equipment;
|
|
package com.hboxs.control.api.equipment;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
+import com.google.zxing.client.j2se.MatrixToImageWriter;
|
|
import com.hboxs.ViewObject.AlarmRecordVo;
|
|
import com.hboxs.ViewObject.AlarmRecordVo;
|
|
import com.hboxs.common.JsonMessage;
|
|
import com.hboxs.common.JsonMessage;
|
|
import com.hboxs.common.utils.MailUtil;
|
|
import com.hboxs.common.utils.MailUtil;
|
|
import com.hboxs.common.utils.YunPianSms;
|
|
import com.hboxs.common.utils.YunPianSms;
|
|
import com.hboxs.control.api.BaseController;
|
|
import com.hboxs.control.api.BaseController;
|
|
-import com.hboxs.entity.Admin;
|
|
|
|
-import com.hboxs.entity.AlarmRecord;
|
|
|
|
-import com.hboxs.entity.CleanHistory;
|
|
|
|
-import com.hboxs.entity.Equipment;
|
|
|
|
-import com.hboxs.service.AdminService;
|
|
|
|
-import com.hboxs.service.AlarmRecordService;
|
|
|
|
-import com.hboxs.service.CleanHistoryService;
|
|
|
|
-import com.hboxs.service.EquipmentService;
|
|
|
|
|
|
+import com.hboxs.entity.*;
|
|
|
|
+import com.hboxs.service.*;
|
|
import org.apache.commons.lang.StringUtils;
|
|
import org.apache.commons.lang.StringUtils;
|
|
import org.springframework.stereotype.Controller;
|
|
import org.springframework.stereotype.Controller;
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RequestMethod;
|
|
import org.springframework.web.bind.annotation.RequestMethod;
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
-
|
|
|
|
|
|
+import com.google.zxing.BarcodeFormat;
|
|
|
|
+import com.google.zxing.EncodeHintType;
|
|
|
|
+import com.google.zxing.WriterException;
|
|
|
|
+import com.google.zxing.common.BitMatrix;
|
|
|
|
+import com.google.zxing.qrcode.QRCodeWriter;
|
|
|
|
+import java.io.ByteArrayOutputStream;
|
|
|
|
+import java.io.IOException;
|
|
|
|
+import java.util.Base64;
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
import java.text.ParseException;
|
|
import java.text.ParseException;
|
|
import java.text.SimpleDateFormat;
|
|
import java.text.SimpleDateFormat;
|
|
import java.util.Date;
|
|
import java.util.Date;
|
|
|
|
+import java.util.HashMap;
|
|
|
|
+import java.util.Random;
|
|
|
|
|
|
@Controller("appCleanController")
|
|
@Controller("appCleanController")
|
|
@RequestMapping("/api/app_alarmRecord/clean")
|
|
@RequestMapping("/api/app_alarmRecord/clean")
|
|
@@ -39,6 +43,8 @@ public class CleanController extends BaseController {
|
|
@Resource(name = "cleanHistoryServiceImpl")
|
|
@Resource(name = "cleanHistoryServiceImpl")
|
|
private CleanHistoryService cleanHistoryService;
|
|
private CleanHistoryService cleanHistoryService;
|
|
|
|
|
|
|
|
+ @Resource(name = "signServiceImpl")
|
|
|
|
+ private SignService signService;
|
|
@Resource(name = "adminServiceImpl")
|
|
@Resource(name = "adminServiceImpl")
|
|
private AdminService adminService;
|
|
private AdminService adminService;
|
|
private static final String appid = "07784f5fedb508046c841b391005b7de";
|
|
private static final String appid = "07784f5fedb508046c841b391005b7de";
|
|
@@ -376,4 +382,49 @@ public class CleanController extends BaseController {
|
|
return JsonMessage.success(sformat.format(date));
|
|
return JsonMessage.success(sformat.format(date));
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 获取签到二维码
|
|
|
|
+ */
|
|
|
|
+ @RequestMapping(value = "/getCode", method = RequestMethod.GET, produces = "application/json;charset=UTF-8")
|
|
|
|
+ @ResponseBody
|
|
|
|
+ public Object getCode(String clientId) throws IOException, WriterException{
|
|
|
|
+ if(StringUtils.isEmpty(clientId)){
|
|
|
|
+ return JsonMessage.error("设备号为空!");
|
|
|
|
+ }
|
|
|
|
+ StringBuilder number = new StringBuilder();
|
|
|
|
+ Random random = new Random();
|
|
|
|
+ /**
|
|
|
|
+ * 6位随机
|
|
|
|
+ */
|
|
|
|
+ for (int i = 0; i < 6; i++) {
|
|
|
|
+ number.append(String.valueOf(random.nextInt(10)));
|
|
|
|
+ }
|
|
|
|
+ String code = number.toString();
|
|
|
|
+ QRCodeWriter qrCodeWriter = new QRCodeWriter();
|
|
|
|
+
|
|
|
|
+ HashMap<EncodeHintType, Object> hints = new HashMap<>();
|
|
|
|
+ hints.put(EncodeHintType.CHARACTER_SET, "utf-8");
|
|
|
|
+
|
|
|
|
+ BitMatrix bitMatrix = qrCodeWriter.encode(code, BarcodeFormat.QR_CODE, 600, 600, hints);
|
|
|
|
+ ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
|
|
|
+ MatrixToImageWriter.writeToStream(bitMatrix, "PNG", outputStream);
|
|
|
|
+ Base64.Encoder encoder = Base64.getEncoder();
|
|
|
|
+ String text = encoder.encodeToString(outputStream.toByteArray());
|
|
|
|
+ if(!StringUtils.isEmpty(text)){
|
|
|
|
+ Equipment equipment = equipmentService.findByClientId(clientId);
|
|
|
|
+ Long adminId = equipment.getAdminId();
|
|
|
|
+ if(adminId==null){
|
|
|
|
+ return JsonMessage.error("设备号错误!");
|
|
|
|
+ }
|
|
|
|
+ Sign sign = new Sign();
|
|
|
|
+ sign.setClientId(clientId);
|
|
|
|
+ sign.setStatus("0");
|
|
|
|
+ sign.setCode(code);
|
|
|
|
+ sign.setAdminId(adminId);
|
|
|
|
+ signService.save(sign);
|
|
|
|
+ }
|
|
|
|
+ JSONObject kindData = new JSONObject();
|
|
|
|
+ kindData.put("rd_Pic","data:image/png;base64,"+text);
|
|
|
|
+ return JsonMessage.success(kindData.toString());
|
|
|
|
+ }
|
|
}
|
|
}
|