|
|
@@ -4,9 +4,11 @@ import cn.hutool.core.bean.BeanUtil;
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
import cn.hutool.core.date.TimeInterval;
|
|
|
+import cn.hutool.core.img.ImgUtil;
|
|
|
import cn.hutool.core.io.FileUtil;
|
|
|
import cn.hutool.core.net.multipart.UploadFile;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
+import cn.hutool.crypto.digest.MD5;
|
|
|
import cn.hutool.http.HttpUtil;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
@@ -15,8 +17,11 @@ import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.fdkankan.common.constant.CommonStatus;
|
|
|
import com.fdkankan.common.constant.ErrorCode;
|
|
|
+import com.fdkankan.common.constant.ImageUtil;
|
|
|
import com.fdkankan.common.constant.ServerCode;
|
|
|
import com.fdkankan.common.exception.BusinessException;
|
|
|
+import com.fdkankan.common.util.DateExtUtil;
|
|
|
+import com.fdkankan.common.util.FileMd5Util;
|
|
|
import com.fdkankan.common.util.FileUtils;
|
|
|
import com.fdkankan.db.response.PageInfo;
|
|
|
import com.fdkankan.fyun.face.FYunFileServiceInterface;
|
|
|
@@ -26,7 +31,10 @@ import com.fdkankan.redis.constant.RedisKey;
|
|
|
import com.fdkankan.scene.bean.EvidenceBean;
|
|
|
import com.fdkankan.scene.bean.IconBean;
|
|
|
import com.fdkankan.scene.bean.JMErrorCode;
|
|
|
+import com.fdkankan.scene.config.HaixinProperties;
|
|
|
+import com.fdkankan.scene.config.OssProperties;
|
|
|
import com.fdkankan.scene.entity.*;
|
|
|
+import com.fdkankan.scene.httpclient.HaixinClient;
|
|
|
import com.fdkankan.scene.httpclient.ManageHttpClient;
|
|
|
import com.fdkankan.scene.mapper.ISceneEvidenceMapper;
|
|
|
import com.fdkankan.scene.service.*;
|
|
|
@@ -44,6 +52,7 @@ import org.springframework.stereotype.Service;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import java.awt.image.BufferedImage;
|
|
|
import java.io.File;
|
|
|
import java.io.IOException;
|
|
|
import java.util.*;
|
|
|
@@ -61,6 +70,8 @@ import java.util.stream.Collectors;
|
|
|
@Service
|
|
|
public class SceneEvidenceServiceImpl extends ServiceImpl<ISceneEvidenceMapper, SceneEvidence> implements ISceneEvidenceService {
|
|
|
|
|
|
+ @Resource
|
|
|
+ private HaixinProperties haixinProperties;
|
|
|
@Autowired
|
|
|
private IScenePlusService scenePlusService;
|
|
|
@Autowired
|
|
|
@@ -77,6 +88,12 @@ public class SceneEvidenceServiceImpl extends ServiceImpl<ISceneEvidenceMapper,
|
|
|
private JmgaSSOLoginHelper jmgaSSOLoginHelper;
|
|
|
@Autowired
|
|
|
private ISceneMidService sceneMidService;
|
|
|
+ @Resource
|
|
|
+ private HaixinClient haixinClient;
|
|
|
+ @Resource
|
|
|
+ private OssProperties ossProperties;
|
|
|
+ @Autowired
|
|
|
+ private IJyUserService jyUserService;
|
|
|
|
|
|
@Override
|
|
|
public void saveEvidence(SaveEvidenceParamVO param, String token) throws Exception {
|
|
|
@@ -85,7 +102,7 @@ public class SceneEvidenceServiceImpl extends ServiceImpl<ISceneEvidenceMapper,
|
|
|
if (scenePlus == null)
|
|
|
throw new BusinessException(ErrorCode.FAILURE_CODE_5005);
|
|
|
|
|
|
- this.addOrUpdateData(param.getNum(), scenePlus.getKNo(), token, param.getDataList());
|
|
|
+ List<EvidenceParamVO> addVOList = this.addOrUpdateData(param.getNum(), scenePlus.getKNo(), token, param.getDataList());
|
|
|
|
|
|
//设置应用到全部数据
|
|
|
this.generalConfig(param.getNum(), param.getGeneralConfig());
|
|
|
@@ -99,8 +116,145 @@ public class SceneEvidenceServiceImpl extends ServiceImpl<ISceneEvidenceMapper,
|
|
|
|
|
|
this.reviseSceneMid(param.getNum());
|
|
|
|
|
|
- //推送媒体库
|
|
|
-// this.batchPushMedia(param, token, scenePlus);
|
|
|
+ //推送痕迹物证
|
|
|
+ if(haixinProperties.isPushEvidence()){
|
|
|
+ this.pushEvidenceToHaixin(param.getNum(), addVOList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void pushEvidenceToHaixin(String num, List<EvidenceParamVO> addVOList){
|
|
|
+ if(addVOList.isEmpty()){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ ScenePlus scenePlus = scenePlusService.getScenePlusByNum(num);
|
|
|
+ Long userId = scenePlus.getUserId();
|
|
|
+ JyUser jyUser = jyUserService.getByUserId(userId.intValue());
|
|
|
+
|
|
|
+ //组装参数
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
+ jsonObject.put("cid", jyUser.getIdCard());
|
|
|
+ jsonObject.put("account", jyUser.getRyNo());
|
|
|
+ jsonObject.put("investigationNo", scenePlus.getKNo());
|
|
|
+ List<Map<String, JSONObject>> sceneMaterialEvidenceList = new ArrayList<>();
|
|
|
+ jsonObject.put("sceneMaterialEvidenceList", sceneMaterialEvidenceList);
|
|
|
+ for (EvidenceParamVO evidenceParamVO : addVOList) {
|
|
|
+ Map<String, JSONObject> map = this.genSceneMaterialEvidence(num, evidenceParamVO);
|
|
|
+ sceneMaterialEvidenceList.add(map);
|
|
|
+ }
|
|
|
+ haixinClient.saveSceneInfo(haixinProperties.getHost().concat(haixinProperties.getApi().getSaveSceneInfo()), haixinProperties.getAppKey(), jsonObject);
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private Map<String, JSONObject> genSceneMaterialEvidence(String num, EvidenceParamVO evidenceParamVO){
|
|
|
+
|
|
|
+ Map<String, JSONObject> result = new HashMap<>();
|
|
|
+
|
|
|
+ JSONObject data = evidenceParamVO.getData();
|
|
|
+
|
|
|
+ JSONObject sceneMaterialEvidence = new JSONObject();
|
|
|
+ result.put("sceneMaterialEvidence", sceneMaterialEvidence);
|
|
|
+ //痕迹物证名称
|
|
|
+ sceneMaterialEvidence.put("materialEvidenceName", data.getString("title"));
|
|
|
+ //遗留部位
|
|
|
+ sceneMaterialEvidence.put("leftPosition", data.getString("leftPosition"));
|
|
|
+ //是否列入现场提取登记表,默认0
|
|
|
+ sceneMaterialEvidence.put("collectedFlag", "0");
|
|
|
+ //提取时间
|
|
|
+ sceneMaterialEvidence.put("collectedTime", DateExtUtil.format(new Date(data.getLong("collectedTime")), DateExtUtil.dateStyle));
|
|
|
+ //基本特征
|
|
|
+ sceneMaterialEvidence.put("feature", data.getString("feature"));
|
|
|
+ //数据来源,固定084533305
|
|
|
+ sceneMaterialEvidence.put("source", "084533305");
|
|
|
+ //类别 分类 类型
|
|
|
+ JSONObject category = data.getJSONObject("category");
|
|
|
+ String categoryEvidenceType = null;
|
|
|
+ if(category != null){
|
|
|
+ categoryEvidenceType = category.getString("evidenceType");
|
|
|
+ sceneMaterialEvidence.put("category", category.getString("evidenceKey"));
|
|
|
+ sceneMaterialEvidence.put("materialEvidenceTypeDict", category.getString("evidenceName"));
|
|
|
+ sceneMaterialEvidence.put("materialEvidenceType", categoryEvidenceType);
|
|
|
+ }
|
|
|
+ //推断 设备
|
|
|
+ JSONObject species = data.getJSONObject("species");
|
|
|
+ String speciesEvidenceType = null;
|
|
|
+ if(species != null){
|
|
|
+ speciesEvidenceType = species.getString("evidenceType");
|
|
|
+ //工具推断
|
|
|
+ if("GJTDZLDM".equals(speciesEvidenceType)){
|
|
|
+ sceneMaterialEvidence.put("materialEvidenceJudgement", species.getString("evidenceKey"));
|
|
|
+ }
|
|
|
+ //枪弹制式
|
|
|
+ if("QDZSDM".equals(speciesEvidenceType)){
|
|
|
+ sceneMaterialEvidence.put("bulletModel", species.getString("evidenceKey"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //电脑品牌 枪支弹药种类
|
|
|
+ JSONObject standard = data.getJSONObject("standard");
|
|
|
+ if(standard != null){
|
|
|
+ String standardEvidenceType = standard.getString("evidenceType");
|
|
|
+ if("QZDYZLDM".equals(standardEvidenceType)){//枪支带药种类
|
|
|
+ sceneMaterialEvidence.put("bulletModel", standard.getString("evidenceKey"));
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ //提取方法
|
|
|
+ JSONObject method = data.getJSONObject("method");
|
|
|
+ if(method != null){//下拉选
|
|
|
+ sceneMaterialEvidence.put("collectionModeDict", method.getString("evidenceType"));
|
|
|
+ sceneMaterialEvidence.put("collectionMode", method.getString("evidenceKey"));
|
|
|
+ }else{//手动录入
|
|
|
+ sceneMaterialEvidence.put("collectionMode", data.getString("collectionModeName"));
|
|
|
+ }
|
|
|
+
|
|
|
+ //电子物证特殊信息,如果类型代码是电子物证就是电子物证信息
|
|
|
+ if("SB-DZWZLBDM".equals(categoryEvidenceType)){
|
|
|
+ JSONObject sceneElectroEvidence = new JSONObject();
|
|
|
+ result.put("sceneElectroEvidence", sceneElectroEvidence);
|
|
|
+ sceneElectroEvidence.put("evidenceType1", categoryEvidenceType);
|
|
|
+ sceneElectroEvidence.put("evidenceType2", speciesEvidenceType);
|
|
|
+ //电脑品牌
|
|
|
+ if(StrUtil.isNotEmpty(standard.getString("type")) || standard.getString("type").equals("input")){
|
|
|
+ sceneElectroEvidence.put("brand", standard.getString("name"));
|
|
|
+ }else{
|
|
|
+ sceneElectroEvidence.put("brand", standard.getString("evidenceName"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //上传图片
|
|
|
+ //获取到第一张图片
|
|
|
+ JSONArray medias = data.getJSONArray("media");
|
|
|
+ JSONObject firstImageObj = medias.stream().findFirst().filter(v -> {
|
|
|
+ String type = ((JSONObject) v).getString("type");
|
|
|
+ if ("image".equals(type)) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }).map(v -> (JSONObject) v).get();
|
|
|
+ String fileName = firstImageObj.getString("src");
|
|
|
+ String imagePath = ossProperties.getAbsolutePath(String.format(UploadFilePath.USER_EDIT_PATH, num)) + fileName;
|
|
|
+ JSONObject jsonObject = haixinClient.uploadToFdfs(haixinProperties.getHost().concat(haixinProperties.getApi().getFdfsUpload()), imagePath);
|
|
|
+ JSONObject uploadToFdfsResp = jsonObject.getJSONObject("data");
|
|
|
+ //海信文件服务器存储路径
|
|
|
+ String fileServerPath = uploadToFdfsResp.getString("fileNameRemote");
|
|
|
+ //宽
|
|
|
+ BufferedImage read = ImgUtil.read(imagePath);
|
|
|
+ String width = String.valueOf(read.getWidth());
|
|
|
+ String height = String.valueOf(read.getHeight());
|
|
|
+ String fileSuffix = FileUtil.getSuffix(fileName);
|
|
|
+ String fileMd5 = MD5.create().digestHex16(imagePath);
|
|
|
+ JSONObject commonPicture = new JSONObject();
|
|
|
+ result.put("commonPicture", commonPicture);
|
|
|
+ commonPicture.put("width", width);//
|
|
|
+ commonPicture.put("height", height);
|
|
|
+ commonPicture.put("fileName", fileName);
|
|
|
+ commonPicture.put("fileSuffix", fileSuffix);
|
|
|
+ commonPicture.put("fileMd5", fileMd5);
|
|
|
+ commonPicture.put("fileServerPath", fileServerPath);
|
|
|
+ commonPicture.put("source", "084533305");
|
|
|
+
|
|
|
+ return result;
|
|
|
+
|
|
|
}
|
|
|
|
|
|
private void reviseSceneMid(String num){
|
|
|
@@ -230,7 +384,7 @@ public class SceneEvidenceServiceImpl extends ServiceImpl<ISceneEvidenceMapper,
|
|
|
// return resultData.getData().stream().map(v -> v.getLong("id")).collect(Collectors.toSet());
|
|
|
}
|
|
|
|
|
|
- private void addOrUpdateData(String num, String kno, String token, List<EvidenceParamVO> dataList) throws Exception{
|
|
|
+ private List<EvidenceParamVO> addOrUpdateData(String num, String kno, String token, List<EvidenceParamVO> dataList) throws Exception{
|
|
|
Set<String> sidList = dataList.stream().map(v->v.getSid()).collect(Collectors.toSet());
|
|
|
List<SceneEvidence> sceneEvidences = this.listByNumAndSids(num, sidList);
|
|
|
Map<String, SceneEvidence> dbMap = new HashMap<>();
|
|
|
@@ -238,9 +392,11 @@ public class SceneEvidenceServiceImpl extends ServiceImpl<ISceneEvidenceMapper,
|
|
|
dbMap = sceneEvidences.stream().collect(Collectors.toMap(v -> v.getSid(), v -> v));
|
|
|
}
|
|
|
Map<String, SceneEvidence> finalDbMap = dbMap;
|
|
|
+ List<EvidenceParamVO> addVoList = new ArrayList<>();
|
|
|
List<SceneEvidence> collect = dataList.stream().map(v -> {
|
|
|
SceneEvidence sceneEvidence = finalDbMap.get(v.getSid());
|
|
|
if (Objects.isNull(sceneEvidence)) {
|
|
|
+ addVoList.add(v);
|
|
|
sceneEvidence = new SceneEvidence();
|
|
|
sceneEvidence.setNum(num);
|
|
|
sceneEvidence.setSid(v.getSid());
|
|
|
@@ -271,6 +427,8 @@ public class SceneEvidenceServiceImpl extends ServiceImpl<ISceneEvidenceMapper,
|
|
|
return sceneEvidence;
|
|
|
}).collect(Collectors.toList());
|
|
|
this.saveOrUpdateBatch(collect);
|
|
|
+
|
|
|
+ return addVoList;
|
|
|
}
|
|
|
|
|
|
private void pushMedia(String num, String kNo, JSONObject data, JSONObject media, String token){
|
|
|
@@ -332,9 +490,7 @@ public class SceneEvidenceServiceImpl extends ServiceImpl<ISceneEvidenceMapper,
|
|
|
@Override
|
|
|
public List<SceneEvidence> listByNumAndSids(String num, Set<String> sids) {
|
|
|
LambdaQueryWrapper<SceneEvidence> queryWrapper = new LambdaQueryWrapper<SceneEvidence>().eq(SceneEvidence::getNum, num);
|
|
|
- if(CollUtil.isNotEmpty(sids)){
|
|
|
- queryWrapper.in(SceneEvidence::getSid, sids);
|
|
|
- }
|
|
|
+ queryWrapper.in(SceneEvidence::getSid, sids);
|
|
|
return this.list(queryWrapper);
|
|
|
}
|
|
|
|
|
|
@@ -507,7 +663,7 @@ public class SceneEvidenceServiceImpl extends ServiceImpl<ISceneEvidenceMapper,
|
|
|
String newFileName = sid + "." + FileUtil.extName(fileName);
|
|
|
String meshKey = String.format(UploadFilePath.USER_EDIT_PATH, param.getNum()) + newFileName;
|
|
|
if(path.startsWith("http")){
|
|
|
- HttpUtil.downloadFile(path, new File("/oss/4dkankan/"+meshKey), 600000);
|
|
|
+ HttpUtil.downloadFile(path, new File(ossProperties.getAbsolutePath(meshKey)), 600000);
|
|
|
}else{
|
|
|
if(path.startsWith("/oss/")){
|
|
|
path = path.replace("/oss/", "");
|