From a4fe7b80468d1e49820aa6b363195005029e0a22 Mon Sep 17 00:00:00 2001 From: yedejiamingshi <540057894@qq.com> Date: Thu, 16 Jan 2025 13:46:31 +0800 Subject: [PATCH] =?UTF-8?q?=E9=87=87=E6=94=B6=E5=85=A5=E5=9D=91=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E6=97=B6=20=20=E5=A2=9E=E5=8A=A0=E9=87=87=E6=94=B6?= =?UTF-8?q?=E6=89=B9=E6=AC=A1=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../harvestbatch/HarvestBatchServiceImpl.java | 1 - .../harvestinfo/HarvestInfoServiceImpl.java | 37 +++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/yudao-module-product/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/harvestbatch/HarvestBatchServiceImpl.java b/yudao-module-product/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/harvestbatch/HarvestBatchServiceImpl.java index 4821e7c..dd31a15 100644 --- a/yudao-module-product/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/harvestbatch/HarvestBatchServiceImpl.java +++ b/yudao-module-product/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/harvestbatch/HarvestBatchServiceImpl.java @@ -33,7 +33,6 @@ import cn.iocoder.yudao.module.product.dal.mysql.harvestbatch.HarvestBatchMapper import cn.iocoder.yudao.module.product.dal.mysql.harvestbatchconfig.HarvestBatchConfigMapper; import cn.iocoder.yudao.module.product.enums.ErrorCodeConstants; import cn.iocoder.yudao.module.product.service.envtype.EnvTypeService; -import cn.iocoder.yudao.module.product.service.landplan.LandPlanService; import cn.iocoder.yudao.module.system.api.languagetype.LanguageTypeApi; import cn.iocoder.yudao.module.system.api.languagetype.dto.LanguageTypeRespDTO; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; diff --git a/yudao-module-product/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/harvestinfo/HarvestInfoServiceImpl.java b/yudao-module-product/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/harvestinfo/HarvestInfoServiceImpl.java index 1212f19..7aa49c1 100644 --- a/yudao-module-product/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/harvestinfo/HarvestInfoServiceImpl.java +++ b/yudao-module-product/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/service/harvestinfo/HarvestInfoServiceImpl.java @@ -18,6 +18,8 @@ import cn.iocoder.yudao.module.chain.api.blockcertificate.dto.UpdateStatusReqDTO import cn.iocoder.yudao.module.chain.enums.BatchTypeEnum; import cn.iocoder.yudao.module.chain.enums.ChainStatusEnum; import cn.iocoder.yudao.module.chain.enums.OperateTypeEnum; +import cn.iocoder.yudao.module.configure.api.uniTemplate.UniTemplateApi; +import cn.iocoder.yudao.module.configure.api.uniTemplate.dto.UniTemplateDTO; import cn.iocoder.yudao.module.product.controller.admin.harvestbatch.vo.HarvestBatchBaseVO; import cn.iocoder.yudao.module.product.controller.admin.harvestbatch.vo.HarvestBatchRespVO; import cn.iocoder.yudao.module.product.controller.admin.harvestbatch.vo.HarvestBatchSaveReqVO; @@ -25,10 +27,14 @@ import cn.iocoder.yudao.module.product.controller.admin.harvestinfo.vo.*; import cn.iocoder.yudao.module.product.convert.harvestbatch.HarvestBatchConvert; import cn.iocoder.yudao.module.product.convert.harvestinfo.HarvestInfoConvert; import cn.iocoder.yudao.module.product.dal.dataobject.harvestbatch.HarvestBatchDO; +import cn.iocoder.yudao.module.product.dal.dataobject.harvestbatchconfig.HarvestBatchConfigDO; import cn.iocoder.yudao.module.product.dal.dataobject.harvestinfo.HarvestInfoDO; import cn.iocoder.yudao.module.product.dal.mysql.harvestbatch.HarvestBatchMapper; +import cn.iocoder.yudao.module.product.dal.mysql.harvestbatchconfig.HarvestBatchConfigMapper; import cn.iocoder.yudao.module.product.dal.mysql.harvestinfo.HarvestInfoMapper; import cn.iocoder.yudao.module.product.enums.ErrorCodeConstants; +import cn.iocoder.yudao.module.system.api.languagetype.LanguageTypeApi; +import cn.iocoder.yudao.module.system.api.languagetype.dto.LanguageTypeRespDTO; import io.seata.spring.annotation.GlobalTransactional; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -53,6 +59,9 @@ public class HarvestInfoServiceImpl implements HarvestInfoService { @Resource private HarvestBatchMapper harvestBatchMapper; + @Resource + private HarvestBatchConfigMapper harvestBatchConfigMapper; + @Resource private GoodsInfoApi goodsInfoApi; @@ -62,6 +71,12 @@ public class HarvestInfoServiceImpl implements HarvestInfoService { @Resource private BlockCertificateApi blockCertificateApi; + @Resource + private UniTemplateApi uniTemplateApi; + + @Resource + private LanguageTypeApi languageTypeApi; + @Override @Transactional public Long createHarvestInfo(HarvestInfoCreateReqVO createReqVO) { @@ -70,8 +85,18 @@ public class HarvestInfoServiceImpl implements HarvestInfoService { if(businessInfo == null) { throw ServiceExceptionUtil.exception(cn.iocoder.yudao.module.basic.enums.ErrorCodeConstants.BUSINESS_INFO_NOT_EXISTS); } + // 获取默认模板 + UniTemplateDTO templateDTO = uniTemplateApi.getDefaultTemplate().getData(); + if (templateDTO == null) { + throw ServiceExceptionUtil.exception(ErrorCodeConstants.CAN_NOT_FIND_DEFAULT_UNI_TEMPLATE); + } + + // 查询所有的语言类型 + List languageTypeList = languageTypeApi.getAllLanguageType().getData(); Map goodsInfoMap = new HashMap<>(); + List createBatchConfigList = new ArrayList<>(); + // 校验商品信息 this.verifiGoodsInfos(createReqVO.getHarvestBatchs(), goodsInfoMap, null, createReqVO.getBelongBusinessId()); @@ -86,6 +111,14 @@ public class HarvestInfoServiceImpl implements HarvestInfoService { harvestBatch.setBelongBusinessName(goodsInfoMap.get(harvestBatch.getGoodsId()).getBelongBusinessName()); // 商品名以数据库的为准 harvestBatch.setGoodsName(goodsInfoMap.get(harvestBatch.getGoodsId()).getGoodsName()); + + languageTypeList.forEach(languageType -> { + HarvestBatchConfigDO config = new HarvestBatchConfigDO(); + config.setLanguageTypeId(languageType.getId()); + config.setHarvestBatchId(harvestBatch.getHarvestBatchId()); + config.setTemplateId(templateDTO.getId()); + createBatchConfigList.add(config); + }); }); HarvestInfoDO harvestInfo = HarvestInfoConvert.INSTANCE.convert(createReqVO); @@ -97,6 +130,10 @@ public class HarvestInfoServiceImpl implements HarvestInfoService { harvestInfoMapper.insert(harvestInfo); harvestBatchMapper.insertBatch(HarvestBatchDOs); + + if (!createBatchConfigList.isEmpty()) { + harvestBatchConfigMapper.insertBatch(createBatchConfigList); + } // 返回 return harvestInfo.getId(); }