feat: 药品关联关系

v3
chenhc 5 months ago
parent 1bbc8fb045
commit 66b2a6bc81

@ -139,4 +139,26 @@ public class RelCodeBatch implements Serializable {
private String erpId;
/**
* curCode
*/
@TableField(value = "curCode")
@ApiModelProperty(value = "")
private String curCode;
@TableField(value = "oneLevelCount")
@ApiModelProperty(value = "")
private Integer oneLevelCount;
@TableField(value = "twoLevelCount")
@ApiModelProperty(value = "")
private Integer twoLevelCount;
@TableField(value = "threeLevelCount")
@ApiModelProperty(value = "")
private Integer threeLevelCount;
}

@ -168,6 +168,7 @@ public class RelCodeBatchService extends ServiceImpl<RelCodeBatchMapper, RelCode
relCodeBatch.setCreateTime(new Date());
relCodeBatch.setUpdateTime(new Date());
relCodeBatch.setId(null);
relCodeBatch.setCurCode(detailList.get(0).getParentCode());
this.save(relCodeBatch);
List<RelCodeDetail> relCodeDetails = new ArrayList<>();
for(RelCodeDetailRequest request : detailList){
@ -180,6 +181,7 @@ public class RelCodeBatchService extends ServiceImpl<RelCodeBatchMapper, RelCode
relCodeDetails.add(relCodeDetail);
}
relCodeDetailService.saveBatch(relCodeDetails);
this.updateDrugLevelCount(relCodeBatch);
}
public List<RelCodeBatchResponse> filterList(RelCodeBatchRequest relCodeBatchRequest) {
@ -259,4 +261,41 @@ public class RelCodeBatchService extends ServiceImpl<RelCodeBatchMapper, RelCode
}
return respList;
}
/**
* curCode
*
* @param item
*/
private void updateDrugLevelCount(RelCodeBatch item) {
String curCode = item.getCurCode();
List<RelCodeDetail> list = relCodeDetailService.list(new LambdaQueryWrapper<RelCodeDetail>().eq(RelCodeDetail::getParentCode, curCode));
if (CollUtil.isNotEmpty(list)){
RelCodeDetail relCodeDetail = list.get(0);
Integer packLayer = relCodeDetail.getPackLayer();
if (packLayer == 2){
item.setThreeLevelCount(1);
item.setTwoLevelCount(list.size());
//需要计算出一级数量
List<String> twoCurCodes = list.stream().map(RelCodeDetail::getCurCode).collect(Collectors.toList());
List<RelCodeDetail> list2 = relCodeDetailService.list(new LambdaQueryWrapper<RelCodeDetail>().in(RelCodeDetail::getParentCode, twoCurCodes));
item.setOneLevelCount(list2.size());
//更新下 二级单
List<RelCodeBatch> twoRelCodeBatchs = this.list(new LambdaQueryWrapper<RelCodeBatch>().in(RelCodeBatch::getCurCode, twoCurCodes));
if (CollUtil.isNotEmpty(twoRelCodeBatchs)){
twoRelCodeBatchs.forEach( t -> {
this.updateDrugLevelCount(t);
});
}
}else if (packLayer == 1){
item.setThreeLevelCount(0);
item.setTwoLevelCount(1);
item.setOneLevelCount(list.size());
}
this.updateById(item);
}
return;
}
}

@ -205,4 +205,45 @@ CREATE TABLE IF NOT EXISTS `io_collect_code` (
`relId` bigint DEFAULT NULL COMMENT '耗材字典ID外键',
`webTitle` varchar(60) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '来源',
PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
CREATE TABLE IF NOT EXISTS `rel_code_batch` (
`id` int NOT NULL AUTO_INCREMENT,
`productCode` varchar(40) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '产品编码',
`subTypeNo` varchar(40) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '类型编码',
`cascadeRatio` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '包装比例',
`packageSpec` varchar(40) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '包装规格',
`comment` varchar(60) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '备注',
`batchNo` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '批次号',
`madeDate` datetime DEFAULT NULL COMMENT '生产日期',
`validateDate` datetime DEFAULT NULL COMMENT '失效日期',
`workShop` varchar(40) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '生产车间',
`lineName` varchar(40) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '生产线',
`lineManager` varchar(40) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '负责人',
`createTime` datetime DEFAULT NULL COMMENT '创建时间',
`createUser` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '创建人',
`updateTime` datetime DEFAULT NULL COMMENT '更新时间',
`updateUser` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '更新人',
`parentCode` varchar(60) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '父级码',
`uploadFlagUp` tinyint(1) DEFAULT '0' COMMENT '0 未上传 1已上传 2上传失败',
`uploadFlagDown` tinyint(1) DEFAULT '0' COMMENT '0 未上传 1已上传 2上传失败',
`erpId` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '供应商ID',
`curCode` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '当前码',
`oneLevelCount` int DEFAULT NULL COMMENT '一级数量',
`twoLevelCount` int DEFAULT NULL COMMENT '二级数量',
`threeLevelCount` int DEFAULT NULL COMMENT '三级数量',
PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=131 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
CREATE TABLE IF NOT EXISTS `rel_code_detail` (
`id` int NOT NULL AUTO_INCREMENT,
`curCode` varchar(60) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '当前条码',
`packLayer` tinyint DEFAULT NULL COMMENT '包装级别',
`parentCode` varchar(60) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '父级码',
`flag` tinyint DEFAULT NULL COMMENT '状态',
`batchIdFk` int DEFAULT NULL COMMENT '产品批次ID外键',
PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=708 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
Loading…
Cancel
Save