诊疗下没有项目功能完善
This commit is contained in:
@@ -5,8 +5,6 @@ import com.core.common.core.domain.model.LoginUser;
|
||||
import com.core.common.utils.SecurityUtils;
|
||||
import com.core.framework.config.TenantContext;
|
||||
import org.apache.ibatis.reflection.MetaObject;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.context.request.RequestContextHolder;
|
||||
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||
@@ -14,97 +12,39 @@ import org.springframework.web.context.request.ServletRequestAttributes;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* MyBatis-Plus 自动填充处理器
|
||||
* 用于自动填充创建时间和更新时间,以及创建人和更新人
|
||||
*/
|
||||
@Component
|
||||
public class MybastisColumnsHandler implements MetaObjectHandler {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(MybastisColumnsHandler.class);
|
||||
|
||||
// 设置数据新增时的字段自动赋值规则
|
||||
// 设置数据新增时候的,字段自动赋值规则
|
||||
@Override
|
||||
public void insertFill(MetaObject metaObject) {
|
||||
logger.info("开始执行 insertFill 自动填充");
|
||||
|
||||
// 填充创建时间
|
||||
Date currentTime = new Date();
|
||||
this.strictInsertFill(metaObject, "createTime", Date.class, currentTime);
|
||||
this.strictInsertFill(metaObject, "create_time", Date.class, currentTime);
|
||||
logger.debug("已填充创建时间: {}", currentTime);
|
||||
|
||||
// 获取当前登录用户名
|
||||
String username = getCurrentUsername();
|
||||
logger.debug("获取到当前用户名: {}", username);
|
||||
|
||||
// 填充创建人
|
||||
this.strictInsertFill(metaObject, "createBy", String.class, username);
|
||||
this.strictInsertFill(metaObject, "create_by", String.class, username);
|
||||
logger.debug("已填充创建人: {}", username);
|
||||
|
||||
// 确保tenantId被设置
|
||||
Integer tenantId = getCurrentTenantId();
|
||||
if (tenantId == null) {
|
||||
throw new RuntimeException("无法获取当前租户ID,请确保用户已登录或正确设置租户上下文");
|
||||
}
|
||||
this.strictInsertFill(metaObject, "tenantId", Integer.class, tenantId);
|
||||
this.strictInsertFill(metaObject, "tenant_id", Integer.class, tenantId);
|
||||
logger.debug("已填充租户ID: {}", tenantId);
|
||||
|
||||
logger.info("insertFill 自动填充完成");
|
||||
}
|
||||
|
||||
// 设置数据修改时的字段自动赋值规则
|
||||
@Override
|
||||
public void updateFill(MetaObject metaObject) {
|
||||
logger.info("开始执行 updateFill 自动填充");
|
||||
|
||||
// 填充更新时间
|
||||
Date currentTime = new Date();
|
||||
this.strictUpdateFill(metaObject, "updateTime", Date.class, currentTime);
|
||||
this.strictUpdateFill(metaObject, "update_time", Date.class, currentTime);
|
||||
logger.debug("已填充更新时间: {}", currentTime);
|
||||
|
||||
// 填充更新人
|
||||
String username = getCurrentUsername();
|
||||
logger.debug("获取到当前用户名: {}", username);
|
||||
|
||||
this.strictUpdateFill(metaObject, "updateBy", String.class, username);
|
||||
this.strictUpdateFill(metaObject, "update_by", String.class, username);
|
||||
logger.debug("已填充更新人: {}", username);
|
||||
|
||||
logger.info("updateFill 自动填充完成");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前登录用户名
|
||||
* @return 当前登录用户名,如果无法获取则返回 "system"
|
||||
*/
|
||||
private String getCurrentUsername() {
|
||||
String username = "system"; // 默认值
|
||||
|
||||
this.strictInsertFill(metaObject, "createTime", Date.class, new Date());
|
||||
String username = "system";
|
||||
try {
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
if (loginUser != null) {
|
||||
username = loginUser.getUsername();
|
||||
logger.debug("从SecurityContext获取到用户名: {}", username);
|
||||
} else {
|
||||
logger.warn("SecurityContext中没有找到登录用户信息");
|
||||
// 尝试从请求中获取用户信息
|
||||
ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
|
||||
if (attributes != null) {
|
||||
HttpServletRequest request = attributes.getRequest();
|
||||
// 可以在这里添加额外的逻辑来从请求中获取用户信息
|
||||
// 例如从请求头、session等获取用户信息
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// 记录异常但不中断处理流程
|
||||
logger.error("获取当前登录用户时发生异常: ", e);
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
// 使用 fillStrategy 而不是 strictInsertFill,确保即使字段已设置也能填充(如果为null)
|
||||
this.fillStrategy(metaObject, "createBy", username != null ? username : "system");
|
||||
this.fillStrategy(metaObject, "tenantId", getCurrentTenantId());
|
||||
}
|
||||
|
||||
return username;
|
||||
// 设置数据修改update时候的,字段自动赋值规则
|
||||
@Override
|
||||
public void updateFill(MetaObject metaObject) {
|
||||
this.strictUpdateFill(metaObject, "updateTime", Date.class, new Date());
|
||||
String username = "system";
|
||||
try {
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
if (loginUser != null) {
|
||||
username = loginUser.getUsername();
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
this.strictUpdateFill(metaObject, "updateBy", String.class, username);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -121,14 +61,10 @@ public class MybastisColumnsHandler implements MetaObjectHandler {
|
||||
// 获取当前登录用户的租户ID(优先使用SecurityUtils中储存的LoginUser的租户ID)
|
||||
try {
|
||||
if (SecurityUtils.getAuthentication() != null) {
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
if (loginUser != null) {
|
||||
result = loginUser.getTenantId();
|
||||
}
|
||||
result = SecurityUtils.getLoginUser().getTenantId();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// 记录异常但不中断处理
|
||||
logger.error("获取当前登录用户租户ID时发生异常: ", e);
|
||||
result = 1; // 默认租户ID
|
||||
}
|
||||
|
||||
if (result == null) {
|
||||
@@ -136,31 +72,19 @@ public class MybastisColumnsHandler implements MetaObjectHandler {
|
||||
ServletRequestAttributes attributes = (ServletRequestAttributes)RequestContextHolder.getRequestAttributes();
|
||||
if (attributes != null) {
|
||||
HttpServletRequest request = attributes.getRequest();
|
||||
if (request != null) {
|
||||
// 从请求头获取租户ID,假设header名称为"X-Tenant-ID" ; 登录接口前端把租户id放到请求头里
|
||||
String tenantIdHeader = request.getHeader("X-Tenant-ID");
|
||||
String requestMethodName = request.getHeader("Request-Method-Name");
|
||||
// 登录
|
||||
if ("login".equals(requestMethodName)) {
|
||||
if (tenantIdHeader != null && !tenantIdHeader.isEmpty()) {
|
||||
try {
|
||||
result = Integer.parseInt(tenantIdHeader);
|
||||
} catch (NumberFormatException e) {
|
||||
logger.error("解析请求头中的租户ID时发生异常: ", e);
|
||||
}
|
||||
}
|
||||
// 从请求头获取租户ID,假设header名称为"X-Tenant-ID" ; 登录接口前端把租户id放到请求头里
|
||||
String tenantIdHeader = request.getHeader("X-Tenant-ID");
|
||||
String requestMethodName = request.getHeader("Request-Method-Name");
|
||||
// 登录
|
||||
if ("login".equals(requestMethodName)) {
|
||||
if (tenantIdHeader != null && !tenantIdHeader.isEmpty()) {
|
||||
result = Integer.parseInt(tenantIdHeader);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 如果仍然没有获取到租户ID,返回默认值
|
||||
if (result == null) {
|
||||
logger.warn("未能获取当前租户ID,将使用默认租户ID 1");
|
||||
result = 1; // 默认租户ID
|
||||
}
|
||||
|
||||
return result;
|
||||
return result != null ? result : 1; // 默认租户ID
|
||||
}
|
||||
}
|
||||
|
||||
@@ -242,6 +242,8 @@ public class DiagTreatMAppServiceImpl implements IDiagTreatMAppService {
|
||||
// 显式设置新增的字段
|
||||
activityDefinition.setSortOrder(diagnosisTreatmentUpDto.getSortOrder());
|
||||
activityDefinition.setServiceRange(diagnosisTreatmentUpDto.getServiceRange());
|
||||
// 显式设置划价标记(避免前端字段/类型差异导致 copyProperties 后仍为默认值)
|
||||
activityDefinition.setPricingFlag(diagnosisTreatmentUpDto.getPricingFlag());
|
||||
|
||||
// 拼音码
|
||||
activityDefinition.setPyStr(ChineseConvertUtils.toPinyinFirstLetter(activityDefinition.getName()));
|
||||
@@ -402,6 +404,7 @@ public class DiagTreatMAppServiceImpl implements IDiagTreatMAppService {
|
||||
activityDefinition.setStatusEnum(PublicationStatus.ACTIVE.getValue());
|
||||
|
||||
// 显式设置创建者和租户ID,确保插入时不为null
|
||||
|
||||
String createBy = "system";
|
||||
Integer tenantId = null;
|
||||
try {
|
||||
@@ -415,6 +418,10 @@ public class DiagTreatMAppServiceImpl implements IDiagTreatMAppService {
|
||||
}
|
||||
activityDefinition.setCreateBy(createBy);
|
||||
activityDefinition.setTenantId(tenantId != null ? tenantId : 1); // 默认租户ID为1
|
||||
// 确保创建时间不为null
|
||||
if (activityDefinition.getCreateTime() == null) {
|
||||
activityDefinition.setCreateTime(new java.util.Date());
|
||||
}
|
||||
|
||||
// 检查编码是否已存在
|
||||
List<ActivityDefinition> existingDefinitions = activityDefinitionMapper.selectList(
|
||||
@@ -484,7 +491,8 @@ public class DiagTreatMAppServiceImpl implements IDiagTreatMAppService {
|
||||
for (DiagnosisTreatmentImportDto importDto : importDtoList) {
|
||||
// 创建诊疗定义
|
||||
ActivityDefinition activityDefinition = createActivityDefinitionEntity(importDto, orgId);
|
||||
activityDefinitionService.save(activityDefinition);
|
||||
// 使用 addDiagnosisTreatment 方法,确保字段完整性
|
||||
activityDefinitionService.addDiagnosisTreatment(activityDefinition);
|
||||
// 创建费用定价和详情
|
||||
chargeItemDefinitionService.addChargeItemDefinitionAndDetail(importDto.getName(), importDto.getTypeCode(),
|
||||
importDto.getYbType(), importDto.getPermittedUnitCode(), null, importDto.getRetailPrice(),
|
||||
@@ -654,6 +662,10 @@ public class DiagTreatMAppServiceImpl implements IDiagTreatMAppService {
|
||||
}
|
||||
activityDefinition.setCreateBy(createBy);
|
||||
activityDefinition.setTenantId(tenantId != null ? tenantId : 1); // 默认租户ID为1
|
||||
// 确保创建时间不为null
|
||||
if (activityDefinition.getCreateTime() == null) {
|
||||
activityDefinition.setCreateTime(new java.util.Date());
|
||||
}
|
||||
return activityDefinition;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,8 @@ package com.openhis.web.datadictionary.appservice.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.core.common.core.domain.model.LoginUser;
|
||||
import com.core.common.utils.SecurityUtils;
|
||||
import com.core.common.utils.bean.BeanUtils;
|
||||
import com.openhis.administration.domain.ChargeItemDefDetail;
|
||||
import com.openhis.administration.domain.ChargeItemDefinition;
|
||||
@@ -17,6 +19,7 @@ import org.springframework.stereotype.Service;
|
||||
import javax.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -47,6 +50,9 @@ public class ItemDefinitionServiceImpl implements IItemDefinitionService {
|
||||
|
||||
ChargeItemDefinition chargeItemDefinition = new ChargeItemDefinition();
|
||||
BeanUtils.copyProperties(itemUpFromDirectoryDto, chargeItemDefinition);
|
||||
|
||||
// 显式设置创建者、创建时间和租户ID,确保插入时不为null
|
||||
setRequiredFields(chargeItemDefinition);
|
||||
|
||||
boolean insertCIDSuccess = chargeItemDefinitionService.save(chargeItemDefinition);
|
||||
|
||||
@@ -86,6 +92,9 @@ public class ItemDefinitionServiceImpl implements IItemDefinitionService {
|
||||
|
||||
shargeItemDefDetails.add(chargeItemDefDetail3);
|
||||
|
||||
// 批量设置必需字段(tenant_id、create_by、create_time)
|
||||
setRequiredFieldsForDetailList(shargeItemDefDetails);
|
||||
|
||||
return chargeItemDefDetailService.saveBatch(shargeItemDefDetails);
|
||||
}
|
||||
|
||||
@@ -139,4 +148,55 @@ public class ItemDefinitionServiceImpl implements IItemDefinitionService {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置必需的字段(tenant_id、create_by、create_time),确保插入时不为null
|
||||
*
|
||||
* @param chargeItemDefinition 费用定价对象
|
||||
*/
|
||||
private void setRequiredFields(ChargeItemDefinition chargeItemDefinition) {
|
||||
String createBy = "system";
|
||||
Integer tenantId = null;
|
||||
try {
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
if (loginUser != null) {
|
||||
createBy = loginUser.getUsername();
|
||||
tenantId = loginUser.getTenantId();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// 如果获取失败,使用默认值
|
||||
}
|
||||
chargeItemDefinition.setCreateBy(createBy != null ? createBy : "system");
|
||||
chargeItemDefinition.setTenantId(tenantId != null ? tenantId : 1);
|
||||
if (chargeItemDefinition.getCreateTime() == null) {
|
||||
chargeItemDefinition.setCreateTime(new Date());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量设置费用定价详情列表的必需字段(tenant_id、create_by、create_time)
|
||||
*
|
||||
* @param chargeItemDefDetailList 费用定价详情对象列表
|
||||
*/
|
||||
private void setRequiredFieldsForDetailList(List<ChargeItemDefDetail> chargeItemDefDetailList) {
|
||||
String createBy = "system";
|
||||
Integer tenantId = null;
|
||||
try {
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
if (loginUser != null) {
|
||||
createBy = loginUser.getUsername();
|
||||
tenantId = loginUser.getTenantId();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// 如果获取失败,使用默认值
|
||||
}
|
||||
Date now = new Date();
|
||||
for (ChargeItemDefDetail detail : chargeItemDefDetailList) {
|
||||
detail.setCreateBy(createBy != null ? createBy : "system");
|
||||
detail.setTenantId(tenantId != null ? tenantId : 1);
|
||||
if (detail.getCreateTime() == null) {
|
||||
detail.setCreateTime(now);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.openhis.web.datadictionary.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonAlias;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import com.openhis.common.annotation.Dict;
|
||||
@@ -105,8 +106,18 @@ public class DiagnosisTreatmentUpDto {
|
||||
private String childrenJson;
|
||||
|
||||
/** 划价标记 */
|
||||
@JsonAlias({"pricing_flag"})
|
||||
private Integer pricingFlag;
|
||||
|
||||
/**
|
||||
* 兼容前端把勾选框按 boolean 传参(true/false)的场景
|
||||
* - true -> 1
|
||||
* - false -> 0
|
||||
*/
|
||||
public void setPricingFlag(Boolean pricingFlag) {
|
||||
this.pricingFlag = pricingFlag == null ? null : (pricingFlag ? 1 : 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* 物价编码
|
||||
*/
|
||||
|
||||
@@ -369,9 +369,7 @@ public class DoctorStationAdviceAppServiceImpl implements IDoctorStationAdviceAp
|
||||
.collect(Collectors.toList());
|
||||
// 价格信息
|
||||
baseDto.setPriceList(priceList);
|
||||
// 活动类型
|
||||
baseDto.setActivityType_enumText(
|
||||
EnumUtils.getInfoByValue(ActivityType.class, baseDto.getActivityType()));
|
||||
// 活动类型:字典转换框架会自动填充 activityType_dictText,无需手动设置
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -29,7 +29,9 @@ public class AdviceBaseDto {
|
||||
/**
|
||||
* 医嘱详细分类
|
||||
*/
|
||||
@Dict(dictCode = "activity_category_code")
|
||||
private String categoryCode;
|
||||
private String categoryCode_dictText;
|
||||
|
||||
/**
|
||||
* 药品性质
|
||||
@@ -104,10 +106,11 @@ public class AdviceBaseDto {
|
||||
private String productName;
|
||||
|
||||
/**
|
||||
* 活动类型
|
||||
* 活动类型(诊疗项目使用目录类别)
|
||||
*/
|
||||
@Dict(dictCode = "activity_category_code")
|
||||
private Integer activityType;
|
||||
private String activityType_enumText;
|
||||
private String activityType_dictText;
|
||||
|
||||
/**
|
||||
* 是否皮试
|
||||
|
||||
@@ -200,7 +200,29 @@ public class IInventoryAdjustPriceServiceImpl implements IInventoryAdjustPriceSe
|
||||
itemDefDetailPurchaseList.add(chargeItemDefDetail);
|
||||
}
|
||||
}
|
||||
// 批量插入价格子表
|
||||
// 批量插入价格子表(在保存前设置必需字段)
|
||||
// 只对新插入的记录(id为null)设置字段
|
||||
List<ChargeItemDefDetail> newRetailList = itemDefDetailRetailList.stream()
|
||||
.filter(detail -> detail.getId() == null)
|
||||
.collect(Collectors.toList());
|
||||
if (!newRetailList.isEmpty()) {
|
||||
this.chargeItemDefDetailService.setRequiredFieldsBatch(newRetailList);
|
||||
}
|
||||
|
||||
List<ChargeItemDefDetail> newBuyingList = itemDefDetailBuyingList.stream()
|
||||
.filter(detail -> detail.getId() == null)
|
||||
.collect(Collectors.toList());
|
||||
if (!newBuyingList.isEmpty()) {
|
||||
this.chargeItemDefDetailService.setRequiredFieldsBatch(newBuyingList);
|
||||
}
|
||||
|
||||
List<ChargeItemDefDetail> newPurchaseList = itemDefDetailPurchaseList.stream()
|
||||
.filter(detail -> detail.getId() == null)
|
||||
.collect(Collectors.toList());
|
||||
if (!newPurchaseList.isEmpty()) {
|
||||
this.chargeItemDefDetailService.setRequiredFieldsBatch(newPurchaseList);
|
||||
}
|
||||
|
||||
this.chargeItemDefDetailService.saveOrUpdateBatch(itemDefDetailRetailList);
|
||||
this.chargeItemDefDetailService.saveOrUpdateBatch(itemDefDetailBuyingList);
|
||||
this.chargeItemDefDetailService.saveOrUpdateBatch(itemDefDetailPurchaseList);
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
abi.yb_no,
|
||||
abi.product_name,
|
||||
abi.activity_type,
|
||||
abi.activity_type_dictText,
|
||||
abi.unit_code,
|
||||
abi.min_unit_code,
|
||||
abi.volume,
|
||||
@@ -69,6 +70,7 @@
|
||||
T1.yb_no AS yb_no,
|
||||
T1.merchandise_name AS product_name,
|
||||
0 AS activity_type,
|
||||
'' AS activity_type_dictText,
|
||||
T1.unit_code AS unit_code,
|
||||
T1.min_unit_code AS min_unit_code,
|
||||
T2.total_volume AS volume,
|
||||
@@ -138,6 +140,7 @@
|
||||
T1.yb_no AS yb_no,
|
||||
'' AS product_name,
|
||||
0 AS activity_type,
|
||||
'' AS activity_type_dictText,
|
||||
T1.unit_code AS unit_code,
|
||||
T1.min_unit_code AS min_unit_code,
|
||||
T1.SIZE AS volume,
|
||||
@@ -200,8 +203,12 @@
|
||||
T1.wb_str AS wb_str,
|
||||
T1.yb_no AS yb_no,
|
||||
'' AS product_name,
|
||||
T1.type_enum AS activity_type,
|
||||
'' AS unit_code,
|
||||
-- 前端"类型"列:显示目录类别(category_code)
|
||||
-- 将category_code转换为整数,用于字典转换(字典转换框架会自动填充activityType_dictText)
|
||||
CAST(T1.category_code AS INTEGER) AS activity_type,
|
||||
NULL AS activity_type_dictText,
|
||||
-- 前端"包装单位"列:显示使用单位(permitted_unit_code)
|
||||
T1.permitted_unit_code AS unit_code,
|
||||
'' AS min_unit_code,
|
||||
'' AS volume,
|
||||
'' AS method_code,
|
||||
@@ -263,6 +270,7 @@
|
||||
CAST('' AS VARCHAR) AS yb_no,
|
||||
CAST('' AS VARCHAR) AS product_name,
|
||||
CAST(0 AS INTEGER) AS activity_type,
|
||||
CAST('' AS VARCHAR) AS activity_type_dictText,
|
||||
CAST('' AS VARCHAR) AS unit_code,
|
||||
CAST('' AS VARCHAR) AS min_unit_code,
|
||||
CAST(0 AS NUMERIC) AS volume,
|
||||
|
||||
@@ -65,4 +65,11 @@ public interface IChargeItemDefDetailService extends IService<ChargeItemDefDetai
|
||||
* @return 批号售价信息
|
||||
*/
|
||||
List<ChargeItemDefDetail> getLotNumberPriceByDefIds(List<Long> chargeItemDefIdList);
|
||||
|
||||
/**
|
||||
* 批量设置必需的字段(tenant_id、create_by、create_time),确保插入时不为null
|
||||
*
|
||||
* @param chargeItemDefDetailList 费用定价详情对象列表
|
||||
*/
|
||||
void setRequiredFieldsBatch(List<ChargeItemDefDetail> chargeItemDefDetailList);
|
||||
}
|
||||
@@ -2,6 +2,8 @@ package com.openhis.administration.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.core.common.core.domain.model.LoginUser;
|
||||
import com.core.common.utils.SecurityUtils;
|
||||
import com.core.common.enums.DelFlag;
|
||||
import com.openhis.administration.domain.ChargeItemDefDetail;
|
||||
import com.openhis.administration.mapper.ChargeItemDefDetailAppMapper;
|
||||
@@ -9,6 +11,7 @@ import com.openhis.administration.service.IChargeItemDefDetailService;
|
||||
import com.openhis.common.enums.ConditionCode;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -55,6 +58,8 @@ public class ChargeItemDefDetailServiceImpl extends ServiceImpl<ChargeItemDefDet
|
||||
if (chargeItemDefDetail.getId() != null) {
|
||||
return false;
|
||||
} else {
|
||||
// 显式设置创建者、创建时间和租户ID,确保插入时不为null
|
||||
setRequiredFields(chargeItemDefDetail);
|
||||
return baseMapper.insert(chargeItemDefDetail) > 0;
|
||||
}
|
||||
}
|
||||
@@ -102,4 +107,35 @@ public class ChargeItemDefDetailServiceImpl extends ServiceImpl<ChargeItemDefDet
|
||||
.eq(ChargeItemDefDetail::getConditionCode, ConditionCode.LOT_NUMBER_PRICE.getCode())
|
||||
.eq(ChargeItemDefDetail::getDeleteFlag, DelFlag.NO.getCode()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRequiredFieldsBatch(List<ChargeItemDefDetail> chargeItemDefDetailList) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置必需的字段(tenant_id、create_by、create_time),确保插入时不为null
|
||||
*
|
||||
* @param chargeItemDefDetail 费用定价详情对象
|
||||
*/
|
||||
private void setRequiredFields(ChargeItemDefDetail chargeItemDefDetail) {
|
||||
String createBy = "system";
|
||||
Integer tenantId = null;
|
||||
try {
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
if (loginUser != null) {
|
||||
createBy = loginUser.getUsername();
|
||||
tenantId = loginUser.getTenantId();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// 如果获取失败,使用默认值
|
||||
}
|
||||
chargeItemDefDetail.setCreateBy(createBy != null ? createBy : "system");
|
||||
chargeItemDefDetail.setTenantId(tenantId != null ? tenantId : 1);
|
||||
if (chargeItemDefDetail.getCreateTime() == null) {
|
||||
chargeItemDefDetail.setCreateTime(new Date());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -3,6 +3,8 @@ package com.openhis.administration.service.impl;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.core.common.core.domain.model.LoginUser;
|
||||
import com.core.common.utils.SecurityUtils;
|
||||
import com.core.common.enums.DelFlag;
|
||||
import com.core.common.utils.DateUtils;
|
||||
import com.openhis.administration.domain.ChargeItemDefDetail;
|
||||
@@ -21,6 +23,7 @@ import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -71,6 +74,8 @@ public class ChargeItemDefinitionServiceImpl extends ServiceImpl<ChargeItemDefin
|
||||
if (chargeItemDefinition.getId() != null) {
|
||||
return false;
|
||||
} else {
|
||||
// 显式设置创建者、创建时间和租户ID,确保插入时不为null
|
||||
setRequiredFields(chargeItemDefinition);
|
||||
return baseMapper.insert(chargeItemDefinition) > 0;
|
||||
}
|
||||
}
|
||||
@@ -104,6 +109,8 @@ public class ChargeItemDefinitionServiceImpl extends ServiceImpl<ChargeItemDefin
|
||||
if (healthcareService.getId() != null) {
|
||||
chargeItemDefinition.setInstanceTable(CommonConstants.TableName.ADM_HEALTHCARE_SERVICE);
|
||||
chargeItemDefinition.setInstanceId(healthcareService.getId());
|
||||
// 显式设置创建者、创建时间和租户ID,确保插入时不为null
|
||||
setRequiredFields(chargeItemDefinition);
|
||||
return baseMapper.insert(chargeItemDefinition) > 0;
|
||||
} else {
|
||||
return false;
|
||||
@@ -133,6 +140,8 @@ public class ChargeItemDefinitionServiceImpl extends ServiceImpl<ChargeItemDefin
|
||||
.setStatusEnum(PublicationStatus.ACTIVE.getValue()).setOrgId(orgId).setInstanceTable(instanceTable)
|
||||
.setInstanceId(instanceId).setEffectiveStart(DateUtils.getNowDate()).setTypeCode(typeCode).setYbType(ybCode)
|
||||
.setConditionFlag(Whether.YES.getValue()).setPrice(retailPrice);
|
||||
// 显式设置创建者、创建时间和租户ID,确保插入时不为null
|
||||
setRequiredFields(chargeItemDefinition);
|
||||
this.save(chargeItemDefinition);
|
||||
List<ChargeItemDefDetail> chargeItemDefDetailList = new ArrayList<>();
|
||||
// 购入价子表(购入价不一定存在)
|
||||
@@ -151,6 +160,10 @@ public class ChargeItemDefinitionServiceImpl extends ServiceImpl<ChargeItemDefin
|
||||
= new ChargeItemDefDetail().setDefinitionId(chargeItemDefinition.getId())
|
||||
.setConditionCode(ConditionCode.LIMIT.getCode()).setAmount(maximumRetailPrice);
|
||||
chargeItemDefDetailList.add(defDetailMaximumRetail);
|
||||
|
||||
// 批量设置必需字段(tenant_id、create_by、create_time)
|
||||
setRequiredFieldsForDetailList(chargeItemDefDetailList);
|
||||
|
||||
chargeItemDefDetailService.saveBatch(chargeItemDefDetailList);
|
||||
}
|
||||
|
||||
@@ -184,4 +197,85 @@ public class ChargeItemDefinitionServiceImpl extends ServiceImpl<ChargeItemDefin
|
||||
return this.baseMapper.getProductPrice(statusEnum, instanceId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置必需的字段(tenant_id、create_by、create_time),确保插入时不为null
|
||||
*
|
||||
* @param chargeItemDefinition 费用定价对象
|
||||
*/
|
||||
private void setRequiredFields(ChargeItemDefinition chargeItemDefinition) {
|
||||
String createBy = "system";
|
||||
Integer tenantId = null;
|
||||
try {
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
if (loginUser != null) {
|
||||
createBy = loginUser.getUsername();
|
||||
tenantId = loginUser.getTenantId();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// 如果获取失败,使用默认值
|
||||
}
|
||||
chargeItemDefinition.setCreateBy(createBy != null ? createBy : "system");
|
||||
chargeItemDefinition.setTenantId(tenantId != null ? tenantId : 1);
|
||||
if (chargeItemDefinition.getCreateTime() == null) {
|
||||
chargeItemDefinition.setCreateTime(new Date());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量设置费用定价详情列表的必需字段(tenant_id、create_by、create_time)
|
||||
*
|
||||
* @param chargeItemDefDetailList 费用定价详情对象列表
|
||||
*/
|
||||
private void setRequiredFieldsForDetailList(List<ChargeItemDefDetail> chargeItemDefDetailList) {
|
||||
String createBy = "system";
|
||||
Integer tenantId = null;
|
||||
try {
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
if (loginUser != null) {
|
||||
createBy = loginUser.getUsername();
|
||||
tenantId = loginUser.getTenantId();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// 如果获取失败,使用默认值
|
||||
}
|
||||
Date now = new Date();
|
||||
for (ChargeItemDefDetail detail : chargeItemDefDetailList) {
|
||||
detail.setCreateBy(createBy != null ? createBy : "system");
|
||||
detail.setTenantId(tenantId != null ? tenantId : 1);
|
||||
if (detail.getCreateTime() == null) {
|
||||
detail.setCreateTime(now);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量设置费用定价列表的必需字段(tenant_id、create_by、create_time),确保插入时不为null
|
||||
*
|
||||
* @param chargeItemDefinitionList 费用定价对象列表
|
||||
*/
|
||||
public void setRequiredFieldsBatch(List<ChargeItemDefinition> chargeItemDefinitionList) {
|
||||
if (chargeItemDefinitionList == null || chargeItemDefinitionList.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
String createBy = "system";
|
||||
Integer tenantId = null;
|
||||
try {
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
if (loginUser != null) {
|
||||
createBy = loginUser.getUsername();
|
||||
tenantId = loginUser.getTenantId();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// 如果获取失败,使用默认值
|
||||
}
|
||||
Date now = new Date();
|
||||
for (ChargeItemDefinition definition : chargeItemDefinitionList) {
|
||||
definition.setCreateBy(createBy != null ? createBy : "system");
|
||||
definition.setTenantId(tenantId != null ? tenantId : 1);
|
||||
if (definition.getCreateTime() == null) {
|
||||
definition.setCreateTime(now);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package com.openhis.sys.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.core.common.core.domain.model.LoginUser;
|
||||
import com.core.common.utils.SecurityUtils;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.openhis.sys.domain.OperationRecord;
|
||||
@@ -10,6 +12,7 @@ import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -44,6 +47,10 @@ public class OperationRecordServiceImpl extends ServiceImpl<OperationRecordMappe
|
||||
operationRecord.setDbOpType(dbOpType);
|
||||
operationRecord.setTableName(tableName);
|
||||
operationRecord.setParamJson(paramJson);
|
||||
|
||||
// 统一补全必填字段(create_by、tenant_id、create_time)
|
||||
setRequiredFields(operationRecord);
|
||||
|
||||
baseMapper.insert(operationRecord);
|
||||
} catch (JsonProcessingException e) {
|
||||
e.printStackTrace();
|
||||
@@ -65,6 +72,10 @@ public class OperationRecordServiceImpl extends ServiceImpl<OperationRecordMappe
|
||||
operationRecord.setDbOpType(dbOpType);
|
||||
operationRecord.setTableName(tableName);
|
||||
operationRecord.setParamJson(paramJson);
|
||||
|
||||
// 统一补全必填字段(create_by、tenant_id、create_time)
|
||||
setRequiredFields(operationRecord);
|
||||
|
||||
baseMapper.insert(operationRecord);
|
||||
}
|
||||
|
||||
@@ -80,4 +91,28 @@ public class OperationRecordServiceImpl extends ServiceImpl<OperationRecordMappe
|
||||
return objectMapper.writeValueAsString(map);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置操作记录的必需字段(tenant_id、create_by、create_time),确保插入时不为null
|
||||
*
|
||||
* @param operationRecord 操作记录对象
|
||||
*/
|
||||
private void setRequiredFields(OperationRecord operationRecord) {
|
||||
String createBy = "system";
|
||||
Integer tenantId = null;
|
||||
try {
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
if (loginUser != null) {
|
||||
createBy = loginUser.getUsername();
|
||||
tenantId = loginUser.getTenantId();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// 如果获取失败,使用默认值
|
||||
}
|
||||
operationRecord.setCreateBy(createBy != null ? createBy : "system");
|
||||
operationRecord.setTenantId(tenantId != null ? tenantId : 1);
|
||||
if (operationRecord.getCreateTime() == null) {
|
||||
operationRecord.setCreateTime(new Date());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,7 +2,9 @@ package com.openhis.workflow.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.core.common.core.domain.model.LoginUser;
|
||||
import com.core.common.enums.DelFlag;
|
||||
import com.core.common.utils.SecurityUtils;
|
||||
import com.openhis.common.enums.PublicationStatus;
|
||||
import com.openhis.medication.dto.AdjustPriceMedListDto;
|
||||
import com.openhis.workflow.domain.ActivityDefinition;
|
||||
@@ -14,6 +16,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -46,6 +49,10 @@ public class ActivityDefinitionServiceImpl extends ServiceImpl<ActivityDefinitio
|
||||
if (activityDefinitions.size() > 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 统一补全必填字段(create_by、tenant_id、create_time)
|
||||
setRequiredFields(activityDefinition);
|
||||
|
||||
// 新增诊疗项目
|
||||
int insert = activityDefinitionMapper.insert(activityDefinition);
|
||||
if (insert != 1) {
|
||||
@@ -101,4 +108,30 @@ public class ActivityDefinitionServiceImpl extends ServiceImpl<ActivityDefinitio
|
||||
DelFlag.NO.getCode());
|
||||
return baseMapper.selectList(queryWrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置诊疗定义对象的必需字段(tenant_id、create_by、create_time),确保插入时不为null
|
||||
*
|
||||
* @param activityDefinition 诊疗定义对象
|
||||
*/
|
||||
private void setRequiredFields(ActivityDefinition activityDefinition) {
|
||||
String createBy = "system";
|
||||
Integer tenantId = null;
|
||||
try {
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
if (loginUser != null) {
|
||||
createBy = loginUser.getUsername();
|
||||
tenantId = loginUser.getTenantId();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// 如果获取失败,使用默认值
|
||||
}
|
||||
// 强制设置,确保不为null
|
||||
activityDefinition.setCreateBy(createBy != null ? createBy : "system");
|
||||
activityDefinition.setTenantId(tenantId != null ? tenantId : 1); // 默认租户ID为1
|
||||
// 确保创建时间不为null
|
||||
if (activityDefinition.getCreateTime() == null) {
|
||||
activityDefinition.setCreateTime(new Date());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,3 +92,8 @@ WHERE aci.context_enum = 'ACTIVITY'
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -84,3 +84,8 @@ WHERE (aci.context_enum::text = '3' OR aci.context_enum = 3)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -163,3 +163,8 @@ ChargeItemContext.ACTIVITY.getValue()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user