|
|
|
@ -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<LanguageTypeRespDTO> languageTypeList = languageTypeApi.getAllLanguageType().getData();
|
|
|
|
|
|
|
|
|
|
Map<String, GoodsInfoRespDTO> goodsInfoMap = new HashMap<>();
|
|
|
|
|
List<HarvestBatchConfigDO> 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();
|
|
|
|
|
}
|
|
|
|
|