|
|
@@ -2,6 +2,7 @@ package biz.xy;
|
|
|
|
|
|
import biz.kq.HkConnU;
|
|
|
import biz.kq.HkPersonMappingU;
|
|
|
+import biz.ry.RyC;
|
|
|
import com.google.gson.Gson;
|
|
|
import core.co.haikang.HkApiClient;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
@@ -16,8 +17,13 @@ import ss.obj.ObjC;
|
|
|
import ss.serv.Serv;
|
|
|
import ss.serv.ServC;
|
|
|
import ss.user.UserU;
|
|
|
+import ss.cmn.str.StrUuid;
|
|
|
|
|
|
+import java.awt.Graphics2D;
|
|
|
+import java.awt.RenderingHints;
|
|
|
+import java.awt.image.BufferedImage;
|
|
|
import java.io.File;
|
|
|
+import java.io.FileOutputStream;
|
|
|
import java.nio.file.Files;
|
|
|
import java.sql.Timestamp;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
@@ -26,6 +32,7 @@ import java.util.Base64;
|
|
|
import java.util.LinkedHashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
+import javax.imageio.ImageIO;
|
|
|
|
|
|
/**
|
|
|
* Back-office bridge for:
|
|
|
@@ -773,14 +780,16 @@ public class FaceCollectAuditServ extends Serv {
|
|
|
File imgFile = resolveImgFile(imgPath);
|
|
|
if (imgFile == null)
|
|
|
return writeBackFail(fcDb, collect, "采集图片文件不存在或不可读:" + imgPath);
|
|
|
+ String thumbPath = makeFaceCollectThumb(imgPath);
|
|
|
|
|
|
String beforeZjzwj = rdStr(person, "zjzwj");
|
|
|
String beforeRltzwj = rdStr(person, "rltzwj");
|
|
|
Timestamp now = now();
|
|
|
- SqlCmd updRy = new SqlCmd("update RY set ZJZWJ=:zjzwj,RLTZWJ=:rltzwj,CJQZJZWJ=:cjqzjzwj,PZJZSJ=:pzjzsj where RYID=:ryid");
|
|
|
- updRy.wrStrParm("zjzwj", imgPath);
|
|
|
+ SqlCmd updRy = new SqlCmd("update RY set ZJZWJ=:zjzwj,RLTZWJ=:rltzwj,CJQZJZWJ=:cjqzjzwj,YZJZWJ=:yzjzwj,PZJZSJ=:pzjzsj where RYID=:ryid");
|
|
|
+ updRy.wrStrParm("zjzwj", thumbPath);
|
|
|
updRy.wrStrParm("rltzwj", imgPath);
|
|
|
updRy.wrStrParm("cjqzjzwj", rawImgPath);
|
|
|
+ updRy.wrStrParm("yzjzwj", rawImgPath);
|
|
|
updRy.wrTimeParm("pzjzsj", now);
|
|
|
updRy.wrLongParm("ryid", ryid);
|
|
|
int updRyCount = pmsDb.doModByC(updRy);
|
|
|
@@ -801,13 +810,13 @@ public class FaceCollectAuditServ extends Serv {
|
|
|
" SYNC_HK_STATUS=1,SYNC_HK_MSG=:syncMsg,XGSJ=:xgsj" +
|
|
|
" where FACE_COLLECT_ID=:faceCollectId");
|
|
|
String msg = isStudent(person)
|
|
|
- ? "RY 照片回写成功,BJCY.SFYPZJZ 更新行数=" + updBjcyCount + "。"
|
|
|
- : "教职工 RY 照片回写成功。";
|
|
|
+ ? "RY 照片回写成功,已生成列表缩略图,BJCY.SFYPZJZ 更新行数=" + updBjcyCount + "。"
|
|
|
+ : "教职工 RY 照片回写成功,已生成列表缩略图。";
|
|
|
updCollect.wrTimeParm("writeTime", now);
|
|
|
updCollect.wrStrParm("writeMsg", msg);
|
|
|
updCollect.wrStrParm("zjBefore", beforeZjzwj);
|
|
|
updCollect.wrStrParm("rltBefore", beforeRltzwj);
|
|
|
- updCollect.wrStrParm("zjAfter", imgPath);
|
|
|
+ updCollect.wrStrParm("zjAfter", thumbPath);
|
|
|
updCollect.wrStrParm("rltAfter", imgPath);
|
|
|
updCollect.wrStrParm("syncMsg", "RY 回写成功,等待海康同步。");
|
|
|
updCollect.wrTimeParm("xgsj", now);
|
|
|
@@ -819,7 +828,7 @@ public class FaceCollectAuditServ extends Serv {
|
|
|
result.ok = true;
|
|
|
result.faceCollectId = faceCollectId;
|
|
|
result.ryid = ryid;
|
|
|
- result.zjzwj = imgPath;
|
|
|
+ result.zjzwj = thumbPath;
|
|
|
result.rltzwj = imgPath;
|
|
|
result.msg = msg;
|
|
|
return result;
|
|
|
@@ -1335,6 +1344,46 @@ public class FaceCollectAuditServ extends Serv {
|
|
|
return faceFile;
|
|
|
}
|
|
|
|
|
|
+ private String makeFaceCollectThumb(String imgPath) throws Exception {
|
|
|
+ File srcFile = resolveImgFile(imgPath);
|
|
|
+ if (srcFile == null)
|
|
|
+ throw new IllegalArgumentException("采集图片文件不存在或不可读:" + imgPath);
|
|
|
+ BufferedImage source = ImageIO.read(srcFile);
|
|
|
+ if (source == null)
|
|
|
+ throw new IllegalArgumentException("无法读取采集图片:" + imgPath);
|
|
|
+
|
|
|
+ File thumbDir = new File(AppB.imgBaseDir, RyC.IDPHOTO_thnDir);
|
|
|
+ if (!thumbDir.exists() && !thumbDir.mkdirs() && !thumbDir.isDirectory())
|
|
|
+ throw new IllegalStateException("无法创建证件照缩略图目录:" + thumbDir.getAbsolutePath());
|
|
|
+
|
|
|
+ File thumbFile;
|
|
|
+ String thumbPath;
|
|
|
+ do {
|
|
|
+ thumbPath = RyC.IDPHOTO_thnDir + StrUuid.makeUuid() + AppC.EXT_jpg;
|
|
|
+ thumbFile = new File(AppB.imgBaseDir, thumbPath.replace("/", File.separator));
|
|
|
+ } while (thumbFile.exists());
|
|
|
+
|
|
|
+ BufferedImage thumb = resizeImage(source, RyC.IDPHOTO_thnWidth, RyC.IDPHOTO_thnHeight);
|
|
|
+ try (FileOutputStream fos = new FileOutputStream(thumbFile)) {
|
|
|
+ boolean written = ImageIO.write(thumb, AppC.EXT_pureJpg, fos);
|
|
|
+ if (!written)
|
|
|
+ throw new IllegalStateException("无法写入证件照缩略图:" + thumbPath);
|
|
|
+ }
|
|
|
+ return thumbPath;
|
|
|
+ }
|
|
|
+
|
|
|
+ private BufferedImage resizeImage(BufferedImage source, int width, int height) {
|
|
|
+ BufferedImage target = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
|
|
|
+ Graphics2D g2d = target.createGraphics();
|
|
|
+ g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
|
|
|
+ g2d.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
|
|
|
+ g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
|
|
+ g2d.setRenderingHint(RenderingHints.KEY_ALPHA_INTERPOLATION, RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY);
|
|
|
+ g2d.drawImage(source, 0, 0, width, height, null);
|
|
|
+ g2d.dispose();
|
|
|
+ return target;
|
|
|
+ }
|
|
|
+
|
|
|
private File resolveImgFile(String relPath) {
|
|
|
if (StringUtils.isBlank(relPath) || StringUtils.isBlank(AppB.imgBaseDir))
|
|
|
return null;
|