|
|
|
@ -1,5 +1,6 @@ |
|
|
|
|
package com.cjy.traceability.module.traceability.service.product; |
|
|
|
|
|
|
|
|
|
import cn.hutool.core.date.LocalDateTimeUtil; |
|
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|
|
|
|
import com.cjy.traceability.framework.common.pojo.PageResult; |
|
|
|
@ -31,10 +32,7 @@ import org.springframework.validation.annotation.Validated; |
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
|
|
import java.math.BigDecimal; |
|
|
|
|
import java.util.ArrayList; |
|
|
|
|
import java.util.HashMap; |
|
|
|
|
import java.util.List; |
|
|
|
|
import java.util.Map; |
|
|
|
|
import java.util.*; |
|
|
|
|
|
|
|
|
|
import static com.cjy.traceability.framework.common.exception.util.ServiceExceptionUtil.exception; |
|
|
|
|
import static com.cjy.traceability.module.traceability.enums.ErrorCodeConstants.PRODUCT_NOT_EXISTS; |
|
|
|
@ -222,11 +220,12 @@ public class ProductServiceImpl implements ProductService { |
|
|
|
|
cropperAgriculture.put("cropperName", productMap.get("processingName").toString()); |
|
|
|
|
cropperAgriculture.put("agriculture", agriculture); |
|
|
|
|
map.put("agricultureRecord", cropperAgriculture); |
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
List<Map<String, Object>> agricultureRecord = new ArrayList<>(); |
|
|
|
|
for (Map<String, Object> rawMaterial : rawMaterials) { |
|
|
|
|
List<Map<String, Object>> agriculture = husbandryRecordService.getHusbandryRecordListByBatch(Integer.parseInt(rawMaterial.get("cropperId").toString()), Integer.parseInt(rawMaterial.get("batch").toString())); |
|
|
|
|
//TODO: 奇怪的数据逻辑 二级加工产品生成原料表cropper_id(农作物id)存的是溯源产品id
|
|
|
|
|
ProductDO productDO = productMapper.selectProductById(Integer.parseInt(rawMaterial.get("cropperId").toString())); |
|
|
|
|
List<Map<String, Object>> agriculture = husbandryRecordService.getHusbandryRecordListByBatch(productDO.getCropperId(), Integer.parseInt(rawMaterial.get("batch").toString())); |
|
|
|
|
Map<String, Object> cropperAgriculture = new HashMap<>(2); |
|
|
|
|
cropperAgriculture.put("cropperName", rawMaterial.get("productName").toString()); |
|
|
|
|
cropperAgriculture.put("agriculture", agriculture); |
|
|
|
@ -244,19 +243,22 @@ public class ProductServiceImpl implements ProductService { |
|
|
|
|
materialList.add(baseBlockMap); |
|
|
|
|
} else { |
|
|
|
|
for (Map<String, Object> materials : rawMaterials) { |
|
|
|
|
List<Map<String, Object>> baseBlockList = blockMapper.selectBaseBlock(productMap.get("cropperId").toString()); |
|
|
|
|
ProductDO productDO = productMapper.selectProductById(Integer.parseInt(materials.get("cropperId").toString())); |
|
|
|
|
List<Map<String, Object>> baseBlockList = blockMapper.selectBaseBlock(productDO.getCropperId().toString()); |
|
|
|
|
Map<String, Object> baseBlockMap = new HashMap<>(2); |
|
|
|
|
baseBlockMap.put("cropperName", productMap.get("processingName").toString()); |
|
|
|
|
baseBlockMap.put("cropperName", productDO.getProcessingName()); |
|
|
|
|
baseBlockMap.put("baseBlockList", baseBlockList); |
|
|
|
|
materialList.add(baseBlockMap); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
map.put("baseBlock", materialList); |
|
|
|
|
ScanRecordDO scanRecordDO = new ScanRecordDO() |
|
|
|
|
.setProvince(province) |
|
|
|
|
.setCity(city) |
|
|
|
|
.setCountry(country) |
|
|
|
|
.setProductId(Integer.parseInt(productMap.get("id").toString())); |
|
|
|
|
ScanRecordDO scanRecordDO = new ScanRecordDO(); |
|
|
|
|
scanRecordDO.setProvince(province); |
|
|
|
|
scanRecordDO.setCity(city); |
|
|
|
|
scanRecordDO.setCountry(country); |
|
|
|
|
scanRecordDO.setCreator("访客"); |
|
|
|
|
scanRecordDO.setUpdater("访客"); |
|
|
|
|
scanRecordDO.setProductId(Integer.parseInt(productMap.get("id").toString())); |
|
|
|
|
scanRecordMapper.insert(scanRecordDO); |
|
|
|
|
return map; |
|
|
|
|
} |
|
|
|
|