|
@@ -19,11 +19,14 @@ import com.fjhx.sale.mapper.intermediate.IntermediateContractMapper;
|
|
|
import com.fjhx.sale.service.contract.ContractService;
|
|
|
import com.fjhx.sale.service.documents.DocumentsService;
|
|
|
import com.fjhx.sale.service.intermediate.IntermediateContractService;
|
|
|
+import com.ruoyi.common.exception.ServiceException;
|
|
|
import com.ruoyi.common.utils.StringUtils;
|
|
|
import com.ruoyi.common.utils.wrapper.IWrapper;
|
|
|
import com.ruoyi.common.utils.wrapper.SqlField;
|
|
|
import com.ruoyi.system.utils.UserUtil;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.context.annotation.Bean;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.util.Arrays;
|
|
@@ -54,25 +57,34 @@ public class IntermediateContractServiceImpl extends ServiceImpl<IntermediateCon
|
|
|
|
|
|
@Override
|
|
|
public Page<IntermediateContractVo> getPage(IntermediateContractSelectDto dto) {
|
|
|
+ if(ObjectUtil.isEmpty(dto.getIsSet())){
|
|
|
+ throw new ServiceException("参数异常");
|
|
|
+ }
|
|
|
IWrapper<IntermediateContract> wrapper = getWrapper();
|
|
|
//买方公司过滤
|
|
|
wrapper.orderByDesc("d.create_time");
|
|
|
wrapper.eq(StringUtils.isNotEmpty(dto.getKeyword()),"c.code", dto.getKeyword());
|
|
|
wrapper.eq(ObjectUtil.isNotEmpty(dto.getBuyCorporationId()),"c.buy_corporation_id", dto.getBuyCorporationId());
|
|
|
wrapper.eq(ObjectUtil.isNotEmpty(dto.getSellCorporationId()),"c.sell_corporation_id", dto.getSellCorporationId());
|
|
|
- List<IntermediateContract> intermediateContracts = this.list(Wrappers.<IntermediateContract>query().lambda().select(IntermediateContract::getDocumentsId));
|
|
|
- List<Long> ids = intermediateContracts.stream().map(IntermediateContract::getDocumentsId).collect(Collectors.toList());
|
|
|
- wrapper.notIn("d.id",ids);
|
|
|
- //卖方公司过滤
|
|
|
- Page<IntermediateContractVo> page = this.baseMapper.getPage(dto.getPage(), wrapper);
|
|
|
+ Page<IntermediateContractVo> page;
|
|
|
+ if(dto.getIsSet()==1){//未创建
|
|
|
+ String ids = this.getAllIds();
|
|
|
+ wrapper.notIn("d.id",Arrays.asList(ids));
|
|
|
+ //卖方公司过滤
|
|
|
+ page = this.baseMapper.getPage(dto.getPage(), wrapper);
|
|
|
+ }else{//已创建
|
|
|
+ wrapper.groupBy("t1.id");
|
|
|
+ page = this.baseMapper.getPage2(dto.getPage(), wrapper);
|
|
|
+ }
|
|
|
+
|
|
|
List<IntermediateContractVo> records = page.getRecords();
|
|
|
//赋值原买方公司名称 客户
|
|
|
- customerService.attributeAssign(records, IntermediateContractVo::getOldBuyCorporationId, (item, customer) -> {
|
|
|
- item.setOldBuyCorporationName(customer.getName());
|
|
|
+ customerService.attributeAssign(records, IntermediateContractVo::getBuyCorporationId, (item, customer) -> {
|
|
|
+ item.setBuyCorporationName(customer.getName());
|
|
|
});
|
|
|
//赋值原卖方公司名称 多公司
|
|
|
- corporationService.attributeAssign(records, IntermediateContractVo::getOldSellCorporationId, (item, corporation) -> {
|
|
|
- item.setOldSellCorporationName(corporation.getName());
|
|
|
+ corporationService.attributeAssign(records, IntermediateContractVo::getSellCorporationId, (item, corporation) -> {
|
|
|
+ item.setSellCorporationName(corporation.getName());
|
|
|
});
|
|
|
// //赋值中间合同重新赋值过后的买方名称
|
|
|
// corporationService.attributeAssign(records, IntermediateContractVo::getBuyCorporationId, (item, corporation) -> {
|
|
@@ -97,8 +109,8 @@ public class IntermediateContractServiceImpl extends ServiceImpl<IntermediateCon
|
|
|
@Override
|
|
|
public void edit(IntermediateContractDto intermediateContractDto) {
|
|
|
intermediateContractDto.setId(null);
|
|
|
- Assert.notEmpty(intermediateContractDto.getDocumentsId(), "单证id不能为空");
|
|
|
- IntermediateContract intermediateContract = this.getOne(q -> q.eq(IntermediateContract::getDocumentsId, intermediateContractDto.getDocumentsId()));
|
|
|
+ Assert.notEmpty(intermediateContractDto.getDocumentsIds(), "单证id不能为空");
|
|
|
+ IntermediateContract intermediateContract = this.getOne(q -> q.eq(IntermediateContract::getDocumentsIds, intermediateContractDto.getDocumentsIds()));
|
|
|
if (ObjectUtil.isNotEmpty(intermediateContract)) {
|
|
|
//编辑 赋值id
|
|
|
intermediateContractDto.setId(intermediateContract.getId());
|
|
@@ -148,45 +160,42 @@ public class IntermediateContractServiceImpl extends ServiceImpl<IntermediateCon
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
- public ContractPdfInfoVo getPrintInfo(IntermediateContractDto dto) {
|
|
|
- Assert.notEmpty(dto.getDocumentsId(), "单证id不能为空");
|
|
|
- Documents documents = documentsService.getById(dto.getDocumentsId());
|
|
|
+ public IntermediateContract getPrintInfo(IntermediateContractDto dto) {
|
|
|
+ Assert.notEmpty(dto.getId(), "参数异常");
|
|
|
+ IntermediateContract in = this.getById(dto.getId());
|
|
|
+ IntermediateContractVo vo = new IntermediateContractVo();
|
|
|
+ BeanUtils.copyProperties(in,vo);
|
|
|
+ if(ObjectUtil.isEmpty(in)){
|
|
|
+ throw new ServiceException("合同不存在");
|
|
|
+ }
|
|
|
+ //赋值买方卖方公司名称
|
|
|
+ List<Long> corporationIds = Arrays.asList(in.getBuyCorporationId(), in.getSellCorporationId());
|
|
|
+ Map<Long, Corporation> corporationMap = corporationService.mapKEntity(Corporation::getId, q -> q.in(Corporation::getId, corporationIds));
|
|
|
+ Corporation buyCorporation = corporationMap.get(in.getBuyCorporationId());
|
|
|
+ Corporation sellCorporation = corporationMap.get(in.getSellCorporationId());
|
|
|
+ if (ObjectUtil.isNotEmpty(buyCorporation)) {
|
|
|
+ vo.setBuyCorporationName(buyCorporation.getName());
|
|
|
+ }
|
|
|
+ if (ObjectUtil.isNotEmpty(sellCorporation)) {
|
|
|
+ vo.setSellCorporationName(sellCorporation.getName());
|
|
|
+ }
|
|
|
+ //查询最新的一条单证信息
|
|
|
+ Documents documents = documentsService.getOne(Wrappers.<Documents>query().lambda().in(Documents::getId,Arrays.asList(in.getDocumentsIds().split(","))).orderByDesc(Documents::getCreateTime).last("limit 1"));
|
|
|
Assert.notEmpty(documents, "查询不到单证信息");
|
|
|
- ContractPdfInfoVo contractPdfInfo = contractService.getContractPdfInfo(documents.getContractId());
|
|
|
- //重新赋值买卖方信息为中间合同信息
|
|
|
- //获得多公司信息
|
|
|
- IntermediateContract intermediateContract = getOne(q -> q.eq(IntermediateContract::getDocumentsId, documents.getId()));
|
|
|
- if (ObjectUtil.isNotEmpty(intermediateContract)) {
|
|
|
- List<Long> corporationIds = Arrays.asList(intermediateContract.getBuyCorporationId(), intermediateContract.getSellCorporationId());
|
|
|
- Map<Long, Corporation> corporationMap = corporationService.mapKEntity(Corporation::getId, q -> q.in(Corporation::getId, corporationIds));
|
|
|
-
|
|
|
- Corporation buyCorporation = corporationMap.get(intermediateContract.getBuyCorporationId());
|
|
|
- //赋值买方信息
|
|
|
- contractPdfInfo.setBuyContactNumber(intermediateContract.getBuyContactNumber());
|
|
|
- contractPdfInfo.setBuyCorporationName(buyCorporation.getNameEn());
|
|
|
- if (ObjectUtil.isNotEmpty(buyCorporation)) {
|
|
|
- contractPdfInfo.setBuyContactName(intermediateContract.getBuyContactName());
|
|
|
- //赋值买方国家省市详细地址信息
|
|
|
- contractPdfInfo.setBuyCountryName(buyCorporation.getCountryEnStr());
|
|
|
- contractPdfInfo.setBuyProvinceName(buyCorporation.getProvinceEnStr());
|
|
|
- contractPdfInfo.setBuyCityName(buyCorporation.getCityEnStr());
|
|
|
- contractPdfInfo.setBuyDetailedAddress(buyCorporation.getAddressEn());
|
|
|
- }
|
|
|
+ List<Documents> documentsList = documentsService.list(Wrappers.<Documents>query().lambda().in(Documents::getId,Arrays.asList(in.getDocumentsIds().split(","))));
|
|
|
+ //查询合同
|
|
|
+ Map<String,Object> contractMap = contractService.getDocumentaryPdf(documents.getContractId(),documentsList.stream().map(Documents::getContractId).collect(Collectors.toList()));
|
|
|
+ vo.setContractMap(contractMap);
|
|
|
+ return vo;
|
|
|
+ }
|
|
|
|
|
|
- Corporation sellCorporation = corporationMap.get(intermediateContract.getSellCorporationId());
|
|
|
- //赋值卖方信息
|
|
|
- contractPdfInfo.setSellContactNumber(intermediateContract.getSellContactName());
|
|
|
- contractPdfInfo.setSellCorporationNameEn(intermediateContract.getSellContactNumber());
|
|
|
- if (ObjectUtil.isNotEmpty(sellCorporation)) {
|
|
|
- contractPdfInfo.setSellContactName(sellCorporation.getNameEn());
|
|
|
- //赋值卖方国家省市详细地址信息
|
|
|
- contractPdfInfo.setSellCountryName(sellCorporation.getCountryEnStr());
|
|
|
- contractPdfInfo.setSellProvinceName(sellCorporation.getProvinceEnStr());
|
|
|
- contractPdfInfo.setSellCityName(sellCorporation.getCityEnStr());
|
|
|
- contractPdfInfo.setSellDetailedAddress(sellCorporation.getAddressEn());
|
|
|
- }
|
|
|
- }
|
|
|
- return contractPdfInfo;
|
|
|
+ /**
|
|
|
+ * 获取所有单证ID
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public String getAllIds() {
|
|
|
+ return baseMapper.getAllIds();
|
|
|
}
|
|
|
|
|
|
}
|