20250407 更新
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
package digital.laboratory.platform.entrustment.controller;
|
||||
|
||||
import cn.hutool.json.JSONObject;
|
||||
import digital.laboratory.platform.common.core.util.R;
|
||||
import digital.laboratory.platform.entrustment.service.PushDataToLabsCareService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* @author ChenJiangBao
|
||||
* @version 1.0
|
||||
* @description: 推送数据到LabsCare平台接口管理
|
||||
* @date 2025/4/3 10:48
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/pushDataToLabsCare")
|
||||
@Api(tags = "19-推送数据到LabsCare平台接口管理", description = "推送数据到LabsCare平台接口管理")
|
||||
public class PushDataToLabsCareController {
|
||||
|
||||
|
||||
|
||||
@Resource
|
||||
private PushDataToLabsCareService pushDataToLabsCareService;
|
||||
|
||||
@ApiOperation("获取推送鉴定委托书的数据")
|
||||
@PostMapping("/entrustLetter")
|
||||
public R<JSONObject> entrustLetter(@RequestParam("entrustId") String entrustId) {
|
||||
try {
|
||||
return R.ok(pushDataToLabsCareService.fetchEntrustLetterData(entrustId));
|
||||
} catch (Exception e) {
|
||||
return R.failed(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@ApiOperation("获取推送鉴定事项确认书的数据")
|
||||
@PostMapping("/itemConfirmLetter")
|
||||
public R<JSONObject> itemConfirmLetter(@RequestParam("entrustId") String entrustId) {
|
||||
try {
|
||||
return R.ok(pushDataToLabsCareService.fetchItemConfirmLetterData(entrustId));
|
||||
} catch (Exception e) {
|
||||
return R.failed(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -93,7 +93,6 @@ public interface EntrustmentIdentificationMaterialService extends IService<Entru
|
||||
EntrustmentIdentificationMaterial settingAcceptSampleInfoDivide(EntrustmentIdentificationMaterial material);
|
||||
|
||||
//设置送检单位初始分样信息
|
||||
|
||||
EntrustmentIdentificationMaterial settingProviderSampleInfo(EntrustmentIdentificationMaterial material);
|
||||
|
||||
EntrustmentIdentificationMaterial settingAcceptSampleInfoNoDivide(EntrustmentIdentificationMaterial material);
|
||||
@@ -106,7 +105,7 @@ public interface EntrustmentIdentificationMaterialService extends IService<Entru
|
||||
|
||||
List<EntrustmentIdentificationMaterial> createNewIm(List<EntrustmentIdentificationMaterial> identificationMaterial, DLPUser dlpUser);
|
||||
|
||||
public List<String> printLabel(List<PrintDTO> printDTOList);
|
||||
List<String> printLabel(List<PrintDTO> printDTOList);
|
||||
|
||||
List<String> printManyLabel(List<PrintDTO> printDTOList);
|
||||
|
||||
@@ -114,7 +113,13 @@ public interface EntrustmentIdentificationMaterialService extends IService<Entru
|
||||
|
||||
void conformityDrugs(List<EntrustmentIdentificationMaterial> list);
|
||||
|
||||
List<EntrustmentIdentificationMaterial> sortByAcceptNo(List<EntrustmentIdentificationMaterial> materials);
|
||||
/**
|
||||
* 处理检材重量四舍五入
|
||||
* 设置检材列表, 对检材的重量进行处理 小于100的保留两位小数,100以上保留一位小数
|
||||
* @param entrustId 委托ID
|
||||
* @return 处理后的检材列表
|
||||
*/
|
||||
List<EntrustmentIdentificationMaterial> handleMaterialWeightRounding(String entrustId);
|
||||
|
||||
List<EntrustmentIdentificationMaterialVO> sortVoByAcceptNo(List<EntrustmentIdentificationMaterialVO> materials);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package digital.laboratory.platform.entrustment.service;
|
||||
|
||||
import cn.hutool.json.JSONObject;
|
||||
import digital.laboratory.platform.entrustment.vo.EntrustmentVO;
|
||||
|
||||
|
||||
@@ -24,4 +25,18 @@ public interface PushDataToLabsCareService {
|
||||
* @param entrustVO
|
||||
*/
|
||||
void pushEntrustLetterData(EntrustmentVO entrustVO) throws IllegalAccessException;
|
||||
|
||||
/**
|
||||
* 获取推送鉴定委托书的数据
|
||||
* @param entrustId 委托id
|
||||
* @return
|
||||
*/
|
||||
JSONObject fetchEntrustLetterData(String entrustId);
|
||||
|
||||
/**
|
||||
* 获取推送鉴定事项确认书的数据
|
||||
* @param entrustId 委托id
|
||||
* @return
|
||||
*/
|
||||
JSONObject fetchItemConfirmLetterData(String entrustId);
|
||||
}
|
||||
|
||||
@@ -52,6 +52,7 @@ import javax.annotation.Resource;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
@@ -1532,7 +1533,11 @@ public class EntrustmentIdentificationMaterialServiceImpl extends ServiceImpl<En
|
||||
return entrustmentIdentificationMaterial;
|
||||
}
|
||||
|
||||
//用作于处理一些打印委托书或鉴定事项确认书时的字段类型转换
|
||||
/**
|
||||
* 处理一些打印委托书或鉴定事项确认书时的字段类型转换
|
||||
*
|
||||
* @param list 包含委托书或鉴定事项确认书材料的列表
|
||||
*/
|
||||
@Override
|
||||
public void conformityDrugs(List<EntrustmentIdentificationMaterial> list) {
|
||||
if (list != null && list.size() > 0) {
|
||||
@@ -1628,15 +1633,31 @@ public class EntrustmentIdentificationMaterialServiceImpl extends ServiceImpl<En
|
||||
return cj;
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理检材重量四舍五入
|
||||
* 设置检材列表, 对检材的重量进行处理 小于100的保留两位小数,100以上保留一位小数
|
||||
* @param entrustId 委托ID
|
||||
* @return 处理后的检材列表
|
||||
*/
|
||||
@Override
|
||||
public List<EntrustmentIdentificationMaterial> sortByAcceptNo(List<EntrustmentIdentificationMaterial> materials){
|
||||
materials.sort(Comparator.comparing((EntrustmentIdentificationMaterial m) -> {
|
||||
String[] parts = m.getAcceptNo().split("-");
|
||||
return new int[]{Integer.parseInt(parts[0]), Integer.parseInt(parts[1]), Integer.parseInt(parts[2])};
|
||||
}, Comparator.comparingInt((int[] arr) -> arr[0]) // 按年份排序
|
||||
.thenComparingInt(arr -> arr[1]) // 按流水号排序
|
||||
.thenComparingInt(arr -> arr[2]))); // 按子流水号排序
|
||||
return materials;
|
||||
public List<EntrustmentIdentificationMaterial> handleMaterialWeightRounding(String entrustId) {
|
||||
List<EntrustmentIdentificationMaterial> materialList = super.list(
|
||||
Wrappers.<EntrustmentIdentificationMaterial>lambdaQuery()
|
||||
.eq(EntrustmentIdentificationMaterial::getEntrustmentId, entrustId)
|
||||
.orderByAsc(EntrustmentIdentificationMaterial::getOrderNo)
|
||||
);
|
||||
conformityDrugs(materialList);
|
||||
//设置检材列表, 对检材的重量进行处理 小于100的保留两位小数,100以上保留一位小数
|
||||
BigDecimal compareNumber = new BigDecimal(100);
|
||||
for (EntrustmentIdentificationMaterial entrustmentIdentificationMaterial : materialList) {
|
||||
BigDecimal quantity = entrustmentIdentificationMaterial.getQuantity();
|
||||
if (quantity.compareTo(compareNumber) >= 0) {
|
||||
entrustmentIdentificationMaterial.setQuantity(quantity.setScale(1, RoundingMode.HALF_UP));
|
||||
} else {
|
||||
entrustmentIdentificationMaterial.setQuantity(quantity.setScale(2, RoundingMode.HALF_UP));
|
||||
}
|
||||
}
|
||||
return materialList;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -2176,27 +2176,13 @@ public class EntrustmentServiceImpl extends ServiceImpl<EntrustmentMapper, Entru
|
||||
SysOrg org = commonFeignService.remoteGetSysOrg(ev.getClientOrgId());
|
||||
dm.put("clientOrg", ClassUtils.objectToMap(org));
|
||||
|
||||
List<EntrustmentIdentificationMaterial> materialList = entrustmentIdentificationMaterialService.list(
|
||||
Wrappers.<EntrustmentIdentificationMaterial>query()
|
||||
.eq("entrustment_id", ev.getId())
|
||||
.orderByAsc("order_no")
|
||||
);
|
||||
entrustmentIdentificationMaterialService.conformityDrugs(materialList);
|
||||
List<EntrustmentIdentificationMaterial> materialList = entrustmentIdentificationMaterialService.handleMaterialWeightRounding(ev.getId());
|
||||
//设置检材描述
|
||||
dm.put("materialDes", this.buildMaterialDes(materialList));
|
||||
//设置鉴定要求
|
||||
//dm.put("identifyReq",entrustmentService.buildIdentfyReq(materialList));
|
||||
dm.put("identifyReq", ev.getEntrustRequirement());
|
||||
//设置检材列表, 对检材的重量进行处理 小于100的保留两位小数,100以上保留一位小数
|
||||
BigDecimal compareNumber = new BigDecimal(100);
|
||||
for (EntrustmentIdentificationMaterial entrustmentIdentificationMaterial : materialList) {
|
||||
BigDecimal quantity = entrustmentIdentificationMaterial.getQuantity();
|
||||
if (quantity.compareTo(compareNumber) >= 0) {
|
||||
entrustmentIdentificationMaterial.setQuantity(quantity.setScale(1, RoundingMode.HALF_UP));
|
||||
} else {
|
||||
entrustmentIdentificationMaterial.setQuantity(quantity.setScale(2, RoundingMode.HALF_UP));
|
||||
}
|
||||
}
|
||||
|
||||
dm.put("materialList", materialList);
|
||||
// QR Code
|
||||
// BufferedImage bufferedImage = QRCodeUtils.genQRCode(ev.getEntrustmentNo(), 100, 100);
|
||||
|
||||
@@ -3,6 +3,7 @@ package digital.laboratory.platform.entrustment.service.impl;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import digital.laboratory.platform.common.core.exception.CheckedException;
|
||||
import digital.laboratory.platform.entrustment.config.properties.ApiPathProperties;
|
||||
import digital.laboratory.platform.entrustment.entity.Entrustment;
|
||||
import digital.laboratory.platform.entrustment.entity.EntrustmentIdentificationMaterial;
|
||||
@@ -140,8 +141,7 @@ public class PushDataToLabsCareServiceImpl implements PushDataToLabsCareService
|
||||
*/
|
||||
@Override
|
||||
public void pushEntrustLetterData(EntrustmentVO entrustVO) throws IllegalAccessException {
|
||||
Map<String, Object> dataMap = entrustmentService.buildEntrustLetterDataMap(entrustVO);
|
||||
JSONObject jsonObject = buildEntrustLetterJsonPayload(entrustVO, dataMap);
|
||||
JSONObject jsonObject = buildEntrustLetterJsonPayload(entrustVO);
|
||||
|
||||
String successFlag = ENTRUST_LETTER + ":true";
|
||||
String failureFlag = ENTRUST_LETTER + ":false";
|
||||
@@ -161,15 +161,38 @@ public class PushDataToLabsCareServiceImpl implements PushDataToLabsCareService
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取推送鉴定委托书的数据
|
||||
* @param entrustId 委托id
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public JSONObject fetchEntrustLetterData(String entrustId) {
|
||||
// 获取委托信息
|
||||
EntrustmentVO entrustVO = validFetchParam(entrustId);
|
||||
return buildEntrustLetterJsonPayload(entrustVO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取推送鉴定事项确认书的数据
|
||||
* @param entrustId 委托id
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public JSONObject fetchItemConfirmLetterData(String entrustId) {
|
||||
// 获取委托信息
|
||||
EntrustmentVO entrustVO = validFetchParam(entrustId);
|
||||
return buildItemConfirmLetterJsonPayload(entrustVO);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 构建委托函的JSON负载
|
||||
*
|
||||
* @param entrustVO 委托VO对象
|
||||
* @param dataMap 数据映射
|
||||
* @return 构建好的JSON对象
|
||||
*/
|
||||
private JSONObject buildEntrustLetterJsonPayload(EntrustmentVO entrustVO, Map<String, Object> dataMap) {
|
||||
private JSONObject buildEntrustLetterJsonPayload(EntrustmentVO entrustVO) {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.set("afsj", entrustVO.getHappenTime()); // 案发时间
|
||||
jsonObject.set("ajmc", entrustVO.getCaseName()); // 案事件名称
|
||||
@@ -186,7 +209,7 @@ public class PushDataToLabsCareServiceImpl implements PushDataToLabsCareService
|
||||
jsonObject.set("yjdqk", entrustVO.getOldIdentificationResult());
|
||||
|
||||
// 组装材料信息
|
||||
List<EntrustmentIdentificationMaterial> materialList = (List<EntrustmentIdentificationMaterial>) dataMap.get("materialList");
|
||||
List<EntrustmentIdentificationMaterial> materialList = entrustmentIdentificationMaterialService.handleMaterialWeightRounding(entrustVO.getId());
|
||||
AtomicInteger index = new AtomicInteger(1);
|
||||
List<JSONObject> table = materialList.stream().map(material -> {
|
||||
JSONObject materialJson = new JSONObject();
|
||||
@@ -305,5 +328,19 @@ public class PushDataToLabsCareServiceImpl implements PushDataToLabsCareService
|
||||
.set(Entrustment::getPushFlag, String.join(",", flagList)));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据委托ID验证并获取委托信息
|
||||
*
|
||||
* @param entrustId 委托ID
|
||||
* @return 委托信息对象 EntrustmentVO
|
||||
* @throws CheckedException 当未找到对应的委托信息时抛出此异常
|
||||
*/
|
||||
private EntrustmentVO validFetchParam(String entrustId) {
|
||||
EntrustmentVO entrustVO = entrustmentService.getEntrustmentVOById(entrustId);
|
||||
if (entrustVO == null) {
|
||||
log.error("未找到委托信息, entrustId={}", entrustId);
|
||||
throw new CheckedException(String.format("未找到委托信息, entrustId=%s", entrustId));
|
||||
}
|
||||
return entrustVO;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user