|
@@ -24,6 +24,7 @@ import com.fjhx.sale.entity.documents.po.DocumentsPdf;
|
|
|
import com.fjhx.sale.entity.documents.po.DocumentsProduct;
|
|
|
import com.fjhx.sale.entity.documents.po.DocumentsTransport;
|
|
|
import com.fjhx.sale.entity.documents.vo.DocumentsVo;
|
|
|
+import com.fjhx.sale.entity.pack.po.Pack;
|
|
|
import com.fjhx.sale.entity.pack.po.PackDetail;
|
|
|
import com.fjhx.sale.entity.pack.po.PackDetailGoods;
|
|
|
import com.fjhx.sale.entity.pack.po.PackShipment;
|
|
@@ -34,14 +35,11 @@ import com.fjhx.sale.service.documents.DocumentsPdfService;
|
|
|
import com.fjhx.sale.service.documents.DocumentsProductService;
|
|
|
import com.fjhx.sale.service.documents.DocumentsService;
|
|
|
import com.fjhx.sale.service.documents.DocumentsTransportService;
|
|
|
-import com.fjhx.sale.service.pack.PackDetailGoodsService;
|
|
|
-import com.fjhx.sale.service.pack.PackDetailService;
|
|
|
-import com.fjhx.sale.service.pack.PackShipmentService;
|
|
|
+import com.fjhx.sale.service.pack.*;
|
|
|
import com.ruoyi.common.exception.ServiceException;
|
|
|
import com.ruoyi.common.utils.SecurityUtils;
|
|
|
import com.ruoyi.common.utils.StringUtils;
|
|
|
import com.ruoyi.common.utils.wrapper.IWrapper;
|
|
|
-import com.ruoyi.system.service.ISysUserService;
|
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
@@ -49,6 +47,7 @@ import org.springframework.stereotype.Service;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
|
+import java.util.concurrent.ConcurrentHashMap;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
@@ -75,6 +74,9 @@ public class DocumentsServiceImpl extends ServiceImpl<DocumentsMapper, Documents
|
|
|
private PackDetailGoodsService packDetailGoodsService;
|
|
|
|
|
|
@Autowired
|
|
|
+ private PackDetailProductService packDetailProductService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
private DocumentsTransportService documentsTransportService;
|
|
|
|
|
|
@Autowired
|
|
@@ -99,7 +101,7 @@ public class DocumentsServiceImpl extends ServiceImpl<DocumentsMapper, Documents
|
|
|
private FlowExampleService flowExampleService;
|
|
|
|
|
|
@Autowired
|
|
|
- private ISysUserService iSysUserService;
|
|
|
+ private PackService packService;
|
|
|
|
|
|
private static final SimpleDateFormat sdf = new SimpleDateFormat("dd/MMM/yyyy", Locale.ENGLISH);
|
|
|
|
|
@@ -129,8 +131,8 @@ public class DocumentsServiceImpl extends ServiceImpl<DocumentsMapper, Documents
|
|
|
return pageCommon(dto, wrapper);
|
|
|
}
|
|
|
|
|
|
- public Page<DocumentsVo> pageCommon(DocumentsSelectDto dto,IWrapper<Documents> wrapper){
|
|
|
- wrapper.orderByDesc("d",Documents::getCreateTime);
|
|
|
+ public Page<DocumentsVo> pageCommon(DocumentsSelectDto dto, IWrapper<Documents> wrapper) {
|
|
|
+ wrapper.orderByDesc("d", Documents::getCreateTime);
|
|
|
if (StringUtils.isNotEmpty(dto.getKeyword())) {
|
|
|
//归属公司
|
|
|
List<Long> corporationIds = corporationService.listObject(Corporation::getId, q -> q.like(Corporation::getName, dto.getKeyword()));
|
|
@@ -238,7 +240,8 @@ public class DocumentsServiceImpl extends ServiceImpl<DocumentsMapper, Documents
|
|
|
ContractVo contractVo = BeanUtil.toBean(contract, ContractVo.class);
|
|
|
setContractArea(contractVo);
|
|
|
//查询收费项目
|
|
|
- List<ContractProject> contractProjectList = contractProjectService.list(Wrappers.<ContractProject>query().lambda().eq(ContractProject::getContractId, contractVo.getId()));
|
|
|
+// List<ContractProject> contractProjectList = contractProjectService.list(Wrappers.<ContractProject>query().lambda().eq(ContractProject::getContractId, contractVo.getId()));
|
|
|
+ List<ContractProject> contractProjectList = new ArrayList<>();
|
|
|
//查询买方
|
|
|
Customer customer = customerService.getById(contractVo.getBuyCorporationId());
|
|
|
//查询卖方
|
|
@@ -252,7 +255,7 @@ public class DocumentsServiceImpl extends ServiceImpl<DocumentsMapper, Documents
|
|
|
item.setProductName(product.getName());
|
|
|
item.setProductSpec(product.getSpec());
|
|
|
});
|
|
|
- //查询包装出货主合同
|
|
|
+ Map<Long, List<DocumentsProduct>> docuProductMap = documentsProducts.stream().collect(Collectors.groupingBy(DocumentsProduct::getPackDetailId));
|
|
|
PackShipment packShipment = packShipmentService.getById(documents.getPackShipmentId());
|
|
|
//装箱单
|
|
|
List<PackDetail> packDetailList = new ArrayList<>();
|
|
@@ -267,17 +270,38 @@ public class DocumentsServiceImpl extends ServiceImpl<DocumentsMapper, Documents
|
|
|
//装箱商品明细
|
|
|
List<PackDetailGoods> packDetailGoodsList = new ArrayList<>();
|
|
|
if (ObjectUtil.isNotEmpty(packShipment)) {//查询装箱单
|
|
|
- packDetailList = packDetailService.list(Wrappers.<PackDetail>query().lambda().in(PackDetail::getId, Arrays.asList(packShipment.getPackDetailIds())));
|
|
|
+ packDetailList = packDetailService.list(Wrappers.<PackDetail>query().lambda().in(PackDetail::getId, Arrays.asList(packShipment.getPackDetailIds().split(","))));
|
|
|
List<Long> packDetailIds = packDetailList.stream().map(PackDetail::getId).collect(Collectors.toList());
|
|
|
packDetailGoodsList = packDetailGoodsService.list(Wrappers.<PackDetailGoods>query().lambda().in(PackDetailGoods::getPackDetailId, packDetailIds));
|
|
|
Map<Long, List<PackDetailGoods>> packGoodMap = packDetailGoodsList.stream().collect(Collectors.groupingBy(PackDetailGoods::getPackDetailId));
|
|
|
for (PackDetail p : packDetailList) {
|
|
|
p.setPackDetailGoodsList(packGoodMap.getOrDefault(p.getId(), null));
|
|
|
+ p.setDocumentsProductList(docuProductMap.getOrDefault(p.getId(), null));
|
|
|
+
|
|
|
+ sumPackQuantity = sumPackQuantity.add(p.getPackQuantity());
|
|
|
+ sumRoughWeight = sumRoughWeight.add(p.getRoughWeight().multiply(p.getPackQuantity()));
|
|
|
+ sumNetWeight = sumNetWeight.add(p.getNetWeight().multiply(p.getPackQuantity()));
|
|
|
+ sumBomVolume = sumBomVolume.add(p.getBomVolume().multiply(p.getPackQuantity()));
|
|
|
}
|
|
|
- sumPackQuantity = packDetailList.stream().map(PackDetail::getPackQuantity).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
- sumRoughWeight = packDetailList.stream().map(PackDetail::getRoughWeight).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
- sumNetWeight = packDetailList.stream().map(PackDetail::getNetWeight).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
- sumBomVolume = packDetailList.stream().map(PackDetail::getBomVolume).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+
|
|
|
+ //查询收费项目
|
|
|
+ String packDetailId = Arrays.asList(packShipment.getPackDetailIds().split(",")).get(0);
|
|
|
+ PackDetail packDetail = packDetailService.getById(packDetailId);
|
|
|
+ Pack pack = packService.getById(packDetail.getPackId());
|
|
|
+ List<String> contractIds = Arrays.asList(pack.getContractIds().split(","));//获取装箱的所有合同id
|
|
|
+ List<ContractProject> contractProjectLists = contractProjectService.list(Wrappers.<ContractProject>query().lambda().in(ContractProject::getContractId, contractIds));
|
|
|
+ //合并同名收费项目
|
|
|
+ Map<String, ContractProject> contractProjectMap = new ConcurrentHashMap<>();
|
|
|
+ for (ContractProject project : contractProjectLists) {
|
|
|
+ ContractProject contractProject = contractProjectMap.getOrDefault(project.getPayName(), new ContractProject());
|
|
|
+ if (ObjectUtil.isEmpty(contractProject.getAmount())) {
|
|
|
+ contractProject.setAmount(BigDecimal.ZERO);
|
|
|
+ }
|
|
|
+ contractProject.setAmount(contractProject.getAmount().add(project.getAmount()));
|
|
|
+ contractProject.setPayName(project.getPayName());
|
|
|
+ contractProjectMap.put(project.getPayName(), contractProject);
|
|
|
+ }
|
|
|
+ contractProjectList = contractProjectMap.values().stream().collect(Collectors.toList());
|
|
|
}
|
|
|
map.put("contract", contractVo);//合同信息
|
|
|
map.put("date", sdf.format(contractVo.getCreateTime()));//日期
|
|
@@ -376,7 +400,7 @@ public class DocumentsServiceImpl extends ServiceImpl<DocumentsMapper, Documents
|
|
|
//贸易国(合同买方所在国)
|
|
|
data.put("tradingCountry", buyCountryName);
|
|
|
//运抵国
|
|
|
- data.put("arrivalCountry", documents.getCountryName());
|
|
|
+ data.put("arrivalCountry", buyCountryName);//原来是documents.getCountryName()
|
|
|
//指运港(不用填写)
|
|
|
data.put("portOfDestination", "");
|
|
|
//离境口岸(不用填写)
|
|
@@ -416,6 +440,8 @@ public class DocumentsServiceImpl extends ServiceImpl<DocumentsMapper, Documents
|
|
|
JSONObject object = new JSONObject();
|
|
|
// 项号
|
|
|
object.put("num", num);
|
|
|
+ //产品id
|
|
|
+ object.put("productId", product.getProductId());
|
|
|
// 商品编号(13位)原10位海关编码+3位检验检疫附加编码
|
|
|
object.put("customsCode", product.getCustomsCode());
|
|
|
// 商品名称
|
|
@@ -433,17 +459,17 @@ public class DocumentsServiceImpl extends ServiceImpl<DocumentsMapper, Documents
|
|
|
//各项净重
|
|
|
object.put("netWeight", "");//暂无
|
|
|
//成交数量
|
|
|
- object.put("quantity", product.getQuantity());
|
|
|
+ object.put("quantity", product.getSumQuantity());
|
|
|
//成交单位
|
|
|
object.put("unit", product.getProductUnit());
|
|
|
//原产国(地区)
|
|
|
object.put("countryChinese", sellCountryName);
|
|
|
//总价与币制
|
|
|
- object.put("sumPrice", "");
|
|
|
+ object.put("sumPrice", ObjectUtil.defaultIfNull(product.getPrice(), BigDecimal.ZERO).multiply(ObjectUtil.defaultIfNull(product.getSumQuantity(), BigDecimal.ZERO)));
|
|
|
//成交单价
|
|
|
- object.put("declaredPrice", "");//暂无
|
|
|
+ object.put("declaredPrice", ObjectUtil.defaultIfNull(product.getPrice(), BigDecimal.ZERO));//暂无
|
|
|
//EXW单价
|
|
|
- object.put("exwPrice", "");//暂无
|
|
|
+ object.put("exwPrice", ObjectUtil.defaultIfNull(product.getPrice(), BigDecimal.ZERO));//暂无
|
|
|
productData.add(object);
|
|
|
num++;
|
|
|
}
|
|
@@ -459,6 +485,17 @@ public class DocumentsServiceImpl extends ServiceImpl<DocumentsMapper, Documents
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * 获取合同数据
|
|
|
+ *
|
|
|
+ * @param id
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public Map<String, Object> getContractDataById(Long id) {
|
|
|
+ return baseMapper.getContractDataById(id);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* 赋值买卖公司国家省市区名称
|
|
|
*/
|
|
|
private void setContractArea(ContractVo contractVo) {
|
|
@@ -472,12 +509,12 @@ public class DocumentsServiceImpl extends ServiceImpl<DocumentsMapper, Documents
|
|
|
contractVo.getSellCityId()
|
|
|
);
|
|
|
Map<Long, String> areaMap = CustomizeAreaUtil.getAreaMapByIds(areaIdList);
|
|
|
- contractVo.setBuyCountryName(areaMap.getOrDefault(contractVo.getBuyCountryId(),contractVo.getBuyCountryName()));
|
|
|
- contractVo.setBuyProvinceName(areaMap.getOrDefault(contractVo.getBuyProvinceId(),contractVo.getBuyProvinceName()));
|
|
|
- contractVo.setBuyCityName(areaMap.getOrDefault(contractVo.getBuyCityId(),contractVo.getBuyCityName()));
|
|
|
- contractVo.setSellCountryName(areaMap.getOrDefault(contractVo.getSellCountryId(),contractVo.getSellCountryName()));
|
|
|
- contractVo.setSellProvinceName(areaMap.getOrDefault(contractVo.getSellProvinceId(),contractVo.getSellProvinceName()));
|
|
|
- contractVo.setSellCityName(areaMap.getOrDefault(contractVo.getSellCityId(),contractVo.getSellCityName()));
|
|
|
+ contractVo.setBuyCountryName(areaMap.getOrDefault(contractVo.getBuyCountryId(), contractVo.getBuyCountryName()));
|
|
|
+ contractVo.setBuyProvinceName(areaMap.getOrDefault(contractVo.getBuyProvinceId(), contractVo.getBuyProvinceName()));
|
|
|
+ contractVo.setBuyCityName(areaMap.getOrDefault(contractVo.getBuyCityId(), contractVo.getBuyCityName()));
|
|
|
+ contractVo.setSellCountryName(areaMap.getOrDefault(contractVo.getSellCountryId(), contractVo.getSellCountryName()));
|
|
|
+ contractVo.setSellProvinceName(areaMap.getOrDefault(contractVo.getSellProvinceId(), contractVo.getSellProvinceName()));
|
|
|
+ contractVo.setSellCityName(areaMap.getOrDefault(contractVo.getSellCityId(), contractVo.getSellCityName()));
|
|
|
}
|
|
|
|
|
|
/**
|