Merge remote-tracking branch 'origin/dev_drug' into dev_drug

# Conflicts:
#	src/main/resources/mybatis/mapper/basic/UdiProductDao.xml
dev_unify
qiuyt 8 months ago
commit 07d2029e96

@ -128,7 +128,6 @@ public class UdiRelevanceController extends BaseController {
}
//基础信息-耗材字典-查询页面、业务单据-选入耗材字典-查询页面
@AuthRuleAnnotation("")
@GetMapping("/udi/udirel/filterUdi")
@ -245,6 +244,18 @@ public class UdiRelevanceController extends BaseController {
tempRequest.setNameCode(filterUdiRelRequest.getNameCode());
}
List<UdiProductEntity> udiInfoEntities = udiProductService.filterAllUdiInfo(tempRequest);
//移除层级为空的数据
if (CollUtil.isNotEmpty(udiInfoEntities) && udiInfoEntities.size() > 1) {
for (int i = 0; i < udiInfoEntities.size(); i++) {
if (StrUtil.isEmpty(udiInfoEntities.get(i).getNameCode())) {
udiProductService.deleteById(udiInfoEntities.get(i).getId() + "");
udiInfoEntities.remove(i);
break;
}
}
}
List<UdiRelevanceResponse> udiRelevanceResponses = new ArrayList<>();
if (CollUtil.isNotEmpty(udiInfoEntities)) {
for (UdiProductEntity udiProductEntity : udiInfoEntities) {

@ -54,6 +54,13 @@ public class ThirdAliDrugController extends BaseController {
if (bindingResult.hasErrors()) {
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage());
}
if (StrUtil.isEmpty(thirdAliDrug.getApprovalNum()) && StrUtil.isEmpty(thirdAliDrug.getNameCode()) &&
StrUtil.isEmpty(thirdAliDrug.getCpmctymc())
) {
return ResultVOUtils.success("查询参数不能为空");
}
List<ThirdAliDrug> list = thirdAliDrugService.filterList(thirdAliDrug);
PageInfo<ThirdAliDrug> pageInfo = new PageInfo<>(list);
PageSimpleResponse<ThirdAliDrug> pageSimpleResponse = new PageSimpleResponse<>();
@ -74,8 +81,10 @@ public class ThirdAliDrugController extends BaseController {
}
List<ThirdAliDrug> list = thirdAliDrugService.list(new LambdaQueryWrapper<ThirdAliDrug>()
.eq(ThirdAliDrug::getApprovalNum, one.getApprovalNum())
.eq(ThirdAliDrug::getCpmctymc, one.getCpmctymc())
.eq(ThirdAliDrug::getForm, one.getForm())
.eq(ThirdAliDrug::getFormSpec, one.getFormSpec())
.eq(ThirdAliDrug::getBzgg, one.getBzgg())
.eq(ThirdAliDrug::getPackRatio, one.getPackRatio()));
return ResultVOUtils.success(list);

@ -7,10 +7,7 @@ import com.glxp.api.constant.ConstantStatus;
import com.glxp.api.dao.basic.UdiRelevanceDao;
import com.glxp.api.entity.basic.UdiProductEntity;
import com.glxp.api.entity.basic.UdiRelevanceEntity;
import com.glxp.api.entity.thrsys.BasicInsMaterialEntity;
import com.glxp.api.entity.thrsys.ThrProductsAddDiEntity;
import com.glxp.api.entity.thrsys.ThrProductsEntity;
import com.glxp.api.entity.thrsys.YbDrug;
import com.glxp.api.entity.thrsys.*;
import com.glxp.api.exception.JsonException;
import com.glxp.api.http.NmpaUdiClient;
import com.glxp.api.req.basic.UdiCombineRequest;
@ -21,12 +18,10 @@ import com.glxp.api.req.thrsys.ThrInsDrugFeeRequest;
import com.glxp.api.req.thrsys.ThrInsMaterialFeeRequest;
import com.glxp.api.res.basic.UdiRelevanceResponse;
import com.glxp.api.service.thrsys.BasicInsMaterialService;
import com.glxp.api.service.thrsys.ThirdAliDrugService;
import com.glxp.api.service.thrsys.ThrProductsService;
import com.glxp.api.service.thrsys.YbDrugService;
import com.glxp.api.util.CustomUtil;
import com.glxp.api.util.DateUtil;
import com.glxp.api.util.GennerOrderUtils;
import com.glxp.api.util.IntUtil;
import com.glxp.api.util.*;
import com.glxp.api.util.udi.UdiInfoUtil;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
@ -205,6 +200,8 @@ public class UdiContrastService {
.orElse(null);
}
@Resource
ThirdAliDrugService thirdAliDrugService;
public void createOnlyMainId(String mainId) {
FilterThrProductsRequest filterThrProductsRequest = new FilterThrProductsRequest();
@ -233,11 +230,13 @@ public class UdiContrastService {
ybHcflDetailFilterRequest.setPage(1);
ybHcflDetailFilterRequest.setGoodsCode(thrProductsEntity.getYbbm());
List<YbDrug> list = ybDrugService.getList(ybHcflDetailFilterRequest);
UdiProductEntity udiProductEntity = new UdiProductEntity();
BeanUtils.copyProperties(thrProductsEntity, udiProductEntity);
udiProductEntity.setId(IdUtil.getSnowflakeNextId());
if (list != null && list.size() > 0) {
YbDrug ybDrug = list.get(0);
udiProductEntity.setId(IdUtil.getSnowflakeNextId());
// udiProductEntity.setNameCode(thrProductsEntity.getCode());
udiProductEntity.setPrepnSpec(ybDrug.getRealityOutlook());
udiProductEntity.setZczbhhzbapzbh(ybDrug.getApprovalCode());
@ -259,8 +258,6 @@ public class UdiContrastService {
//商品条码 essentialDrugMarkName sptm
// udiProductEntity.setSptm(ybDrug.getBusinessLicense());
udiProductEntity.setPrepnUnit(ybDrug.getRealityMedicinemodel());
}
udiProductEntity.setUuid(udiRelevanceEntity.getUuid());
udiProductEntity.setDiType(1);
udiProductEntity.setScbssfbhph("是");
@ -276,11 +273,31 @@ public class UdiContrastService {
}
udiProductEntity.setUpdateTime(new Date());
udiProductEntity = UdiInfoUtil.initUdiInfoEntity(udiProductEntity);
List<ThirdAliDrug> thirdAliDrugList = thirdAliDrugService.findByByApproved(ybDrug.getApprovalCode());
if (CollUtil.isNotEmpty(thirdAliDrugList)) {
for (int i = 0; i < thirdAliDrugList.size(); i++) {
ThirdAliDrug thirdAliDrug = thirdAliDrugList.get(i);
List<Integer> integers = DimaUtil.calculateLevels(thirdAliDrug.getPackRatio());
udiProductEntity.setPackLevel(thirdAliDrug.getPackLevel());
udiProductEntity.setBhxjsl(integers.get(IntUtil.value(thirdAliDrug.getPackLevel()) - 1));
udiProductEntity.setNameCode(thirdAliDrug.getNameCode());
if (IntUtil.value(thirdAliDrug.getPackLevel()) == 1) {
udiProductEntity.setXjdw(ybDrug.getMinUnit());
udiProductEntity.setBhxjsl(ybDrug.getFactor());
}
udiProductEntity.setDiType(IntUtil.value(thirdAliDrug.getPackLevel()) == 1 ? 1 : 4);
udiProductEntity.setId(IdUtil.getSnowflakeNextId());
udiProductService.insertUdiInfo(udiProductEntity);
}
} else {
udiProductService.insertUdiInfo(udiProductEntity);
}
}
// setLevel(udiRelevanceEntity.getUuid());
UdiProductEntity byUuid = udiProductService.findByUuid(udiRelevanceEntity.getUuid());
udiRelevanceEntity = udiRelevanceService.insertDefaultLevel(udiRelevanceEntity, byUuid);
udiRelevanceService.insertUdiRelevance(udiRelevanceEntity);
udiProductService.updateLevelCount(udiRelevanceEntity);
} else {
//器械
ThrInsMaterialFeeRequest request = new ThrInsMaterialFeeRequest();

@ -172,7 +172,7 @@ public class UdiProductServiceImpl implements UdiProductService {
@Override
public boolean insertUdiInfos(List<UdiProductEntity> udiInfoEntities) {
return udiProductDao.insertUdiInfos(udiInfoEntities);
return udiProductDao.replaceBatchs(udiInfoEntities);
}
@Override

@ -501,51 +501,73 @@ public class RelCodeBatchService extends ServiceImpl<RelCodeBatchMapper, RelCode
//开始处理codeMap
if (!codeMap.isEmpty()){
Map<String, List<RelCodeDetail>> sortedCodeMap = codeMap.entrySet()
.stream()
.sorted(Comparator.comparing(
e -> Optional.ofNullable(e.getValue().isEmpty() ? null : e.getValue().get(0))
.map(RelCodeDetail::getPackLayer)
.orElse(Integer.MIN_VALUE), // Default to Integer.MIN_VALUE if the list is empty (shouldn't happen normally)
Comparator.reverseOrder()
))
.collect(Collectors.toMap(
Map.Entry::getKey,
Map.Entry::getValue,
(e1, e2) -> e1, // Merge function in case of duplicate keys (shouldn't happen with a well-formed Map)
LinkedHashMap::new // Preserve insertion order, though not strictly necessary for sorting
));
Map<String, Integer> batchIdFkMap = new HashMap<>();
List<RelCodeDetail> addRelCodeDetail = new ArrayList<>();
RelCodeBatch updateDrugLevelRelCodeBatch = null;
List<RelCodeBatch> updateDrugLevelRelCodeBatch = new ArrayList<>();
// 遍历 Map
for (Map.Entry<String, List<RelCodeDetail>> entry : codeMap.entrySet()) {
for (Map.Entry<String, List<RelCodeDetail>> entry : sortedCodeMap.entrySet()) {
String key = entry.getKey();
List<RelCodeDetail> list = entry.getValue();
if ("0".equals(key)){
for (RelCodeDetail relCodeDetail : list) {
RelCodeBatch addRelCodeBatch = new RelCodeBatch();
BeanUtils.copyProperties(relCodeBatch,addRelCodeBatch);
addRelCodeBatch.setParentCode(key);
if ("0".equals(key)){
RelCodeDetail relCodeDetail = list.get(0);
String curCode = relCodeDetail.getCurCode();
String diStr = FilterUdiUtils.getUdi(curCode).getUdi();
addRelCodeBatch.setProductCode(diStr);
addRelCodeBatch.setCurCode(curCode);
addRelCodeBatch.setThreeLevelCount(1);
addRelCodeBatch.setId(null);
this.save(addRelCodeBatch);
batchIdFkMap.put(curCode,addRelCodeBatch.getId());
updateDrugLevelRelCodeBatch = addRelCodeBatch;
updateDrugLevelRelCodeBatch.add(addRelCodeBatch);
}
}else {
for (RelCodeDetail detail : list) {
Integer packLayer = detail.getPackLayer();
if (packLayer == 2){
RelCodeBatch addRelCodeBatch2 = new RelCodeBatch();
BeanUtils.copyProperties(relCodeBatch,addRelCodeBatch2);
addRelCodeBatch2.setParentCode(key);
String curCode = detail.getCurCode();
String parentCode = detail.getParentCode();
addRelCodeBatch2.setParentCode(parentCode);
String diStr = FilterUdiUtils.getUdi(curCode).getUdi();
addRelCodeBatch2.setProductCode(diStr);
addRelCodeBatch2.setCurCode(curCode);
addRelCodeBatch2.setThreeLevelCount(0);
addRelCodeBatch2.setTwoLevelCount(1);
addRelCodeBatch2.setId(null);
this.save(addRelCodeBatch2);
batchIdFkMap.put(curCode,addRelCodeBatch2.getId());
//同时也是上面的明细
detail.setBatchIdFk(batchIdFkMap.get(key));
detail.setBatchIdFk(batchIdFkMap.get(parentCode));
addRelCodeDetail.add(detail);
}else if (packLayer == 1){
//直接明细
detail.setBatchIdFk(batchIdFkMap.get(key));
String parentCode = detail.getParentCode();
detail.setBatchIdFk(batchIdFkMap.get(parentCode));
addRelCodeDetail.add(detail);
}
}
@ -554,7 +576,9 @@ public class RelCodeBatchService extends ServiceImpl<RelCodeBatchMapper, RelCode
if (CollUtil.isNotEmpty(addRelCodeDetail)){
relCodeDetailService.saveBatch(addRelCodeDetail);
//更新层级关系的数量
this.updateDrugLevelCount(updateDrugLevelRelCodeBatch);
updateDrugLevelRelCodeBatch.forEach( item -> {
this.updateDrugLevelCount(item);
});
}
}
}

@ -3,6 +3,7 @@ package com.glxp.api.service.thrsys;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.github.pagehelper.PageHelper;
import com.glxp.api.exception.JsonException;
import com.glxp.api.req.thrsys.ThirdAliDrugRequest;
@ -238,4 +239,9 @@ public class ThirdAliDrugService extends ServiceImpl<ThirdAliDrugMapper, ThirdAl
}
return this.baseMapper.filterList(thirdAliDrug);
}
public List<ThirdAliDrug> findByByApproved(String approvalNum) {
return this.baseMapper.selectList(new LambdaQueryWrapper<ThirdAliDrug>().eq(ThirdAliDrug::getApprovalNum, approvalNum));
}
}

@ -0,0 +1,37 @@
package com.glxp.api.util;
import java.util.ArrayList;
import java.util.List;
/**
* @author AnthonyYwj
* @date 2024/11/12
*/
public class DimaUtil {
public static List<Integer> calculateLevels(String ratio) {
// 分割比例字符串并转成整数数组
String[] parts = ratio.split(":");
int[] levels = new int[parts.length];
for (int i = 0; i < parts.length; i++) {
levels[i] = Integer.parseInt(parts[i]);
}
// 存储每层级的倍数关系
List<Integer> calculatedLevels = new ArrayList<>();
for (int i = levels.length - 1; i > 0; i--) {
calculatedLevels.add(levels[i] / levels[i - 1]);
}
// 最后加上最小单位(第一层级为 1
calculatedLevels.add(1);
// 结果倒序
List<Integer> reversed = new ArrayList<>();
for (int i = calculatedLevels.size() - 1; i >= 0; i--) {
reversed.add(calculatedLevels.get(i));
}
return reversed;
}
}

@ -201,8 +201,9 @@
catalogname3,
matrial,
destinyType,
productsType,prepnUnit,prepnSpec,storageCondition,transportCondition,indate,packMatrial,majorType,majorStatus,physicType,medicareType,bzgg,
requireScanCode,detailSort)
productsType, prepnUnit, prepnSpec, storageCondition, transportCondition, indate, packMatrial, majorType,
majorStatus, physicType, medicareType, bzgg, xjdw,
requireScanCode)
values (#{id}, #{uuid},
#{originUuid},
#{nameCode},
@ -275,12 +276,8 @@
#{majorStatus},
#{physicType},
#{medicareType},
#{bzgg},
#{requireScanCode},
#{detailSort}
)
#{bzgg}, #{xjdw},
#{requireScanCode})
</insert>
<insert id="insertUdiInfos" parameterType="java.util.List">
@ -293,7 +290,7 @@
allowNoProduct, allowNoSerial, spmc, cplx, hchzsb, cpdls, price, basicPrductRemak1, basicPrductRemak2,
basicPrductRemak3, basicPrductRemak4, basicPrductRemak5, basicPrductRemak6, basicPrductRemak7,
basicPrductRemak8, updateTime, sfwblztlcp, cgzmraqxgxx, sfbjwycxsy, zdcfsycs, sfwwjbz, syqsfxyjxmj,
mjfs, categoryName, pinyinInitial)
mjfs, categoryName, pinyinInitial, xjdw)
values
<foreach collection="udiInfoEntities" item="item" index="index"
@ -352,7 +349,7 @@
#{item.basicPrductRemak8}, #{item.updateTime}, #{item.sfwblztlcp}, #{item.cgzmraqxgxx}, #{item.sfbjwycxsy},
#{item.zdcfsycs},
#{item.sfwwjbz}, #{item.syqsfxyjxmj}, #{item.mjfs},
#{item.categoryName}, #{item.pinyinInitial})
#{item.categoryName}, #{item.pinyinInitial}, #{item.xjdw})
</foreach>
</insert>
@ -1010,7 +1007,6 @@
<if test="matrial != null">
matrial=#{matrial},
</if>
</trim>
where id = #{id}
</update>
@ -1231,9 +1227,6 @@
<if test="price != null">
price=#{price},
</if>
<if test="price != null">
detailSort=#{detailSort},
</if>
</trim>
WHERE uuid = #{uuid}
</update>

@ -38,7 +38,9 @@
</sql>
<select id="selectDrugsByNameCodes" resultType="int">
SELECT count(1) FROM third_ali_drug WHERE nameCode = #{nameCode}
SELECT count(1)
FROM third_ali_drug
WHERE nameCode = #{nameCode}
</select>
<!-- 自定义saveOrUpdateBatch方法 -->
@ -55,10 +57,9 @@
</insert>
<select id="filterList" parameterType="com.glxp.api.req.thrsys.ThirdAliDrugRequest" resultType="com.glxp.api.entity.thrsys.ThirdAliDrug">
select
id,
<select id="filterList" parameterType="com.glxp.api.req.thrsys.ThirdAliDrugRequest"
resultType="com.glxp.api.entity.thrsys.ThirdAliDrug">
select id,
`type`,
manufacturer,
cpmctymc,
@ -86,5 +87,4 @@
</if>
</where>
</select>
</mapper>

Loading…
Cancel
Save