|
|
@@ -0,0 +1,116 @@
|
|
|
+package com.tuoren.web.layer.service.impl;
|
|
|
+
|
|
|
+import cn.hutool.core.bean.BeanUtil;
|
|
|
+import cn.hutool.core.util.ObjectUtil;
|
|
|
+import cn.hutool.crypto.digest.DigestUtil;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.tuoren.web.layer.entity.BusPumpEntity;
|
|
|
+import com.tuoren.web.layer.entity.BusReceiveRecordUpdateEntity;
|
|
|
+import com.tuoren.web.layer.mapper.BusReceiveRecordUpdateMapper;
|
|
|
+import com.tuoren.web.layer.service.IBusReceiveRecordUpdateService;
|
|
|
+import com.tuoren.web.layer.vo.ReceiveRecordUpdateQueryParam;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.util.Arrays;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @author wangzl
|
|
|
+ * @description: TODO
|
|
|
+ * @date 2025/8/5 8:38
|
|
|
+ */
|
|
|
+@Slf4j
|
|
|
+@Service
|
|
|
+public class BusReceiveRecordUpdateImpl extends ServiceImpl<BusReceiveRecordUpdateMapper, BusReceiveRecordUpdateEntity> implements IBusReceiveRecordUpdateService {
|
|
|
+ private static final String[] MD5_FIELDS = {"pumpCode", "hospitalCode", "patientCode", "continueQuantity", "maxQuantity", "firstQuantity", "singleQuantity", "totalQuantity"};
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param pumpEntity 泵实体
|
|
|
+ * @description: 比对泵表输注信息是否有修改
|
|
|
+ * @author wangzl
|
|
|
+ * @date 2025/8/5
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public void comparePumpData(BusPumpEntity pumpEntity) {
|
|
|
+ try {
|
|
|
+ if (ObjectUtil.isNull(pumpEntity)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ BusReceiveRecordUpdateEntity busReceiveRecordUpdateEntity = this.getBaseMapper().selectOne(new LambdaQueryWrapper<BusReceiveRecordUpdateEntity>()
|
|
|
+ .eq(BusReceiveRecordUpdateEntity::getPumpCode, pumpEntity.getPumpCode())
|
|
|
+ .eq(BusReceiveRecordUpdateEntity::getHospitalCode, pumpEntity.getHospitalCode())
|
|
|
+ .eq(BusReceiveRecordUpdateEntity::getPatientCode, pumpEntity.getPatientCode())
|
|
|
+ .orderByDesc(BusReceiveRecordUpdateEntity::getGmtModified).last("limit 1"));
|
|
|
+
|
|
|
+ // 2. 转换为Map并应用配置
|
|
|
+ Map<String, Object> pumpEntityMap = beanToMapWithInclude(pumpEntity, MD5_FIELDS);
|
|
|
+ //将pumpEntity转为Map 为了加密校验做准备
|
|
|
+ //将map转为实体 做插入
|
|
|
+ BusReceiveRecordUpdateEntity insertUpdateEntity = BeanUtil.mapToBean(pumpEntityMap, BusReceiveRecordUpdateEntity.class, true);
|
|
|
+ if (ObjectUtil.isNull(busReceiveRecordUpdateEntity)) {
|
|
|
+ this.save(insertUpdateEntity);
|
|
|
+ } else {
|
|
|
+ Map<String, Object> updateEntityMap = beanToMapWithInclude(busReceiveRecordUpdateEntity, MD5_FIELDS);
|
|
|
+ String pumpMd5 = DigestUtil.md5Hex(pumpEntityMap.toString());
|
|
|
+ String updateMd5 = DigestUtil.md5Hex(updateEntityMap.toString());
|
|
|
+ if (!pumpMd5.equals(updateMd5)) {
|
|
|
+ this.save(insertUpdateEntity);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.info("增加修改记录信息异常了:{} ", e.getMessage());
|
|
|
+ e.printStackTrace();
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public IPage<BusReceiveRecordUpdateEntity> queryUpdateList(Integer pageNo, Integer pageSize, ReceiveRecordUpdateQueryParam param) {
|
|
|
+ IPage<BusReceiveRecordUpdateEntity> iPage = new Page<>(pageNo, pageSize);
|
|
|
+ List<BusReceiveRecordUpdateEntity> list = this.list(new LambdaQueryWrapper<BusReceiveRecordUpdateEntity>()
|
|
|
+ .eq(BusReceiveRecordUpdateEntity::getHospitalCode, param.getHospitalCode())
|
|
|
+ .eq(BusReceiveRecordUpdateEntity::getPatientCode, param.getPatientCode())
|
|
|
+ .eq(BusReceiveRecordUpdateEntity::getPumpCode, param.getPumpCode())
|
|
|
+ .orderByDesc(BusReceiveRecordUpdateEntity::getGmtModified));
|
|
|
+ iPage.setRecords(list);
|
|
|
+ return iPage;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 转换对象为Map,只保留指定的特定属性
|
|
|
+ */
|
|
|
+ public static Map<String, Object> beanToMapWithInclude(Object bean, String... includeFields) {
|
|
|
+ Map<String, Object> fullMap = BeanUtil.beanToMap(bean);
|
|
|
+ Map<String, Object> resultMap = new HashMap<>();
|
|
|
+ for (Map.Entry<String, Object> entry : fullMap.entrySet()) {
|
|
|
+ boolean exists = Arrays.asList(includeFields).contains(entry.getKey());
|
|
|
+ if (exists) {
|
|
|
+ resultMap.put(entry.getKey(), entry.getValue());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return resultMap;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public static void main(String[] args) {
|
|
|
+ BusPumpEntity pumpEntity = new BusPumpEntity();
|
|
|
+ pumpEntity.setPumpCode("PUMP_CODE");
|
|
|
+ pumpEntity.setHospitalCode("HOSPITAL_CODE");
|
|
|
+ pumpEntity.setPatientCode("PATIENT_CODE");
|
|
|
+ pumpEntity.setContinueQuantity(BigDecimal.valueOf(1));
|
|
|
+ pumpEntity.setMaxQuantity(BigDecimal.valueOf(1));
|
|
|
+ pumpEntity.setFirstQuantity(1);
|
|
|
+ pumpEntity.setSingleQuantity(BigDecimal.valueOf(1));
|
|
|
+ pumpEntity.setTotalQuantity(1);
|
|
|
+ BusReceiveRecordUpdateEntity updateEntityNew = new BusReceiveRecordUpdateEntity();
|
|
|
+
|
|
|
+ }
|
|
|
+}
|