xucaiqin il y a 1 mois
Parent
commit
81b3f7ebba

+ 25 - 5
sckw-modules/sckw-contract/src/main/java/com/sckw/contract/controller/KwcLogisticsContractController.java

@@ -6,13 +6,12 @@ import com.sckw.contract.model.vo.req.ContractDetailReq;
 import com.sckw.contract.model.vo.req.LogisticListReq;
 import com.sckw.contract.model.vo.req.QueryLogisticListReq;
 import com.sckw.contract.model.vo.req.UpdateLogisticsReq;
-import com.sckw.contract.model.vo.res.ContractStatusCountResp;
-import com.sckw.contract.model.vo.res.QueryLogisticDetailResp;
-import com.sckw.contract.model.vo.res.QueryLogisticListResp;
+import com.sckw.contract.model.vo.res.*;
 import com.sckw.contract.service.operateService.KwcContractLogisticsService;
 import com.sckw.core.web.response.BaseResult;
 import com.sckw.core.web.response.result.PageDataResult;
 import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.Parameter;
 import io.swagger.v3.oas.annotations.tags.Tag;
 import lombok.RequiredArgsConstructor;
 import org.springframework.web.bind.annotation.*;
@@ -33,11 +32,11 @@ public class KwcLogisticsContractController {
     private final KwcContractLogisticsService kwcContractLogisticsService;
 
     /**
+     * @return HttpResult
      * @desc: 分页查询
      * @param: reqVo 分页入参
      * @author: sky
      * @date 2023/7/13
-     * @return HttpResult
      */
     @PostMapping("/queryListByPage")
     @Operation(summary = "分页查询物流合同")
@@ -65,7 +64,7 @@ public class KwcLogisticsContractController {
     @PostMapping("/queryLogisticsContractDetail")
     @Operation(summary = "查询物流合同明细")
     public BaseResult<QueryLogisticDetailResp> queryLogisticsContractDetail(@RequestBody ContractDetailReq req) {
-       return BaseResult.success(kwcContractLogisticsService.queryLogisticsContractDetail(req)) ;
+        return BaseResult.success(kwcContractLogisticsService.queryLogisticsContractDetail(req));
     }
 
     /**
@@ -85,4 +84,25 @@ public class KwcLogisticsContractController {
     public BaseResult<ContractStatusCountResp> queryLogisticContractStatusCount(@RequestBody QueryLogisticListReq req) {
         return BaseResult.success(kwcContractLogisticsService.queryLogisticContractStatusCount(req));
     }
+
+    /**
+     * 查询物流合同明细
+     */
+    @GetMapping("/queryLogisticsContract")
+    @Operation(summary = "查询原矿物流合同")
+    @Parameter(name = "keyword", description = "筛选参数")
+    public BaseResult<List<LogisticsEntDto>> queryLogisticsContract(@RequestParam(value = "keyword", required = false) String keyword) {
+        return BaseResult.success(kwcContractLogisticsService.queryLogisticsContract(keyword));
+    }
+
+    /**
+     * 查询物流合同明细
+     */
+    @GetMapping("/queryLogisticsGoods")
+    @Operation(summary = "查询物流合同下的商品信息")
+    @Parameter(name = "contractId", description = "物流合同id", required = true)
+    @Parameter(name = "keyword", description = "筛选参数")
+    public BaseResult<List<ContractGoodsVo>> queryLogisticsGoods(@RequestParam("contractId") Long contractId, @RequestParam(value = "keyword",required = false) String keyword) {
+        return BaseResult.success(kwcContractLogisticsService.queryLogisticsGoods(contractId, keyword));
+    }
 }

+ 10 - 0
sckw-modules/sckw-contract/src/main/java/com/sckw/contract/dao/KwcContractLogisticsMapper.java

@@ -6,6 +6,8 @@ import com.sckw.contract.model.dto.req.QueryListReqDto;
 import com.sckw.contract.model.dto.res.QueryListResDto;
 import com.sckw.contract.model.entity.KwcContractLogistics;
 import com.sckw.contract.model.vo.req.QueryListReqVo;
+import com.sckw.contract.model.vo.res.ContractGoodsVo;
+import com.sckw.contract.model.vo.res.LogisticsEntDto;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 
@@ -55,6 +57,14 @@ public interface KwcContractLogisticsMapper extends BaseMapper<KwcContractLogist
     List<ContractVo> logisticsList(@Param("ids") List<Long> ids, @Param("all") Boolean all, @Param("entId") Long entId);
 
     Long selectSignCount(@Param("entId") Long entId, @Param("type") Integer type);
+
+    /**
+     * 查询原矿合同
+     * @return
+     */
+    List<LogisticsEntDto> queryContract(@Param("entId") Long entId, @Param("keyword") String keyword);
+
+    List<ContractGoodsVo> selectGoods(@Param("contractId")Long contractId,@Param("keyword") String keyword);
 }
 
 

+ 39 - 0
sckw-modules/sckw-contract/src/main/java/com/sckw/contract/model/vo/res/ContractGoodsVo.java

@@ -0,0 +1,39 @@
+package com.sckw.contract.model.vo.res;
+
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.sckw.core.utils.LongToStringUtils;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+import java.io.Serial;
+import java.io.Serializable;
+import java.math.BigDecimal;
+
+/**
+ * @author czh
+ * @desc 合同查询返参
+ * @date 2023/7/13
+ */
+@Data
+public class ContractGoodsVo implements Serializable {
+
+    @Serial
+    private static final long serialVersionUID = -8699172452542787584L;
+    /**
+     * 商品id
+     */
+    @JsonSerialize(using = LongToStringUtils.class)
+    @Schema(description = "商品id")
+    private Long id;
+
+    /**
+     * 商品名称
+     */
+    @Schema(description = "商品名称")
+    private String goodsName;
+
+    @Schema(description = "数量")
+    private BigDecimal amount;
+
+
+}

+ 62 - 0
sckw-modules/sckw-contract/src/main/java/com/sckw/contract/model/vo/res/LogisticsEntDto.java

@@ -0,0 +1,62 @@
+package com.sckw.contract.model.vo.res;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import jakarta.validation.constraints.NotBlank;
+import jakarta.validation.constraints.NotNull;
+import lombok.Getter;
+import lombok.Setter;
+import lombok.ToString;
+
+import java.math.BigDecimal;
+
+
+@Getter
+@Setter
+@ToString
+public class LogisticsEntDto {
+
+    /**
+     * 合同id
+     */
+    @NotNull(message = "物流合同不能为空")
+    @Schema(description = "合同id")
+    private Long contractId;
+
+    /**
+     * 合同编号
+     */
+    @NotBlank(message = "合同编号不能为空")
+    @Schema(description = "合同编号")
+    private String contractNo;
+
+    @NotNull(message = "承运单位不能为空")
+    private Long entId;
+
+    @NotBlank(message = "承运企业名称不能为空")
+    private String entName;
+    /**
+     * 运输单价
+     */
+    @NotNull(message = "运输单价不能为空")
+    @Schema(description = "运输单价")
+    private BigDecimal transportPrice;
+
+    /**
+     * 联系人ID
+     */
+    @Schema(description = "联系人ID")
+    private Long contactsId;
+
+    /**
+     * 联系人姓名
+     */
+    @Schema(description = "联系人姓名")
+    private String contacts;
+
+    /**
+     * 联系电话
+     */
+    @Schema(description = "联系电话")
+    private String phone;
+
+}

+ 50 - 44
sckw-modules/sckw-contract/src/main/java/com/sckw/contract/service/operateService/KwcContractLogisticsService.java

@@ -10,13 +10,15 @@ import com.github.pagehelper.PageInfo;
 import com.google.common.collect.Lists;
 import com.google.common.collect.Maps;
 import com.google.common.collect.Sets;
+import com.sckw.contract.api.model.dto.req.TradeEntListQueryFeignDto;
+import com.sckw.contract.api.model.dto.res.TradeEntInfoResVo;
 import com.sckw.contract.dao.KwcContractLogisticsMapper;
 import com.sckw.contract.model.dto.req.QueryListReqDto;
-import com.sckw.contract.model.dto.req.TradeEntListQueryFeignDto;
 import com.sckw.contract.model.dto.res.QueryListResDto;
-import com.sckw.contract.model.dto.res.TradeEntInfoResVo;
-import com.sckw.contract.model.entity.*;
-import com.sckw.contract.model.enums.LogisticsTransportBizTypeEnum;
+import com.sckw.contract.model.entity.KwcContractLogistics;
+import com.sckw.contract.model.entity.KwcContractLogisticsGoods;
+import com.sckw.contract.model.entity.KwcContractLogisticsUnit;
+import com.sckw.contract.model.entity.KwcContractTrade;
 import com.sckw.contract.model.report.LogisticsListExport;
 import com.sckw.contract.model.vo.req.*;
 import com.sckw.contract.model.vo.res.*;
@@ -40,23 +42,19 @@ import com.sckw.core.web.context.LoginUserHolder;
 import com.sckw.core.web.response.BaseResult;
 import com.sckw.core.web.response.result.PageDataResult;
 import com.sckw.excel.utils.ExcelUtil;
+import com.sckw.order.api.dubbo.TradeOrderInfoService;
+import com.sckw.order.api.model.TradeOrderContractVo;
 import com.sckw.payment.api.feign.PaymentFeignService;
 import com.sckw.payment.api.model.feign.WalletPayableDto;
 import com.sckw.product.api.dubbo.GoodsInfoService;
 import com.sckw.product.api.model.KwpGoods;
 import com.sckw.stream.enums.MessageEnum;
 import com.sckw.stream.model.UserInfo;
-import com.sckw.system.api.feign.DataPermissionFeignService;
 import com.sckw.system.api.RemoteSystemService;
 import com.sckw.system.api.RemoteUserService;
+import com.sckw.system.api.feign.DataPermissionFeignService;
 import com.sckw.system.api.model.dto.req.DataPermissionFilterReqDto;
-import com.sckw.system.api.model.dto.res.DataPermissionDTO;
-import com.sckw.system.api.model.dto.res.EntCacheResDto;
-import com.sckw.system.api.model.dto.res.KwsUserResDto;
-import com.sckw.system.api.model.dto.res.SysDictResDto;
-import com.sckw.system.api.model.dto.res.UserCacheResDto;
-import com.sckw.order.api.dubbo.TradeOrderInfoService;
-import com.sckw.order.api.model.TradeOrderContractVo;
+import com.sckw.system.api.model.dto.res.*;
 import com.sckw.transport.api.dubbo.TransportRemoteService;
 import com.sckw.transport.api.model.vo.KwtLogisticsOrderVO;
 import com.sckw.transport.api.model.vo.RWaybillSubOrderVo;
@@ -105,7 +103,7 @@ public class KwcContractLogisticsService {
     private CommonBusinessService commonBusinessService;
 
     @Autowired
-    private IKwcContractLogisticsScoreService  logisticsScoreService;
+    private IKwcContractLogisticsScoreService logisticsScoreService;
 
     @SuppressWarnings("SpringJavaInjectionPointsAutowiringInspection")
     @Autowired
@@ -820,7 +818,7 @@ public class KwcContractLogisticsService {
             if (Objects.nonNull(queryListResVo.getEndTime())) {
                 queryListResVo.setEndTime(DateUtils.getStartOfDay(queryListResVo.getEndTime()));
                 String endDate = DateUtils.format(queryListResVo.getEndTime(), DateUtils.DATE_PATTERN);
-                if (org.apache.commons.lang3.StringUtils.equals(endDate,"9999-12-30")){
+                if (org.apache.commons.lang3.StringUtils.equals(endDate, "9999-12-30")) {
                     queryListResVo.setEndTime(null);
                 }
             }
@@ -1078,35 +1076,35 @@ public class KwcContractLogisticsService {
     }
 
     public PageDataResult<QueryLogisticListResp> queryLogisticsContractListByPage(QueryLogisticListReq req) {
-        log.info("分页查询物流合同参数:{}", JSON.toJSONString( req));
+        log.info("分页查询物流合同参数:{}", JSON.toJSONString(req));
         Long entId;
         if (org.apache.commons.lang3.StringUtils.isNotBlank(req.getEntId())) {
             entId = Long.valueOf(req.getEntId());
-        }else{
+        } else {
             entId = LoginUserHolder.getEntId();
         }
 
         List<Long> entIdList = Lists.newArrayList();
         entIdList.add(entId);
         Integer type = null;
-        if (org.apache.commons.lang3.StringUtils.isNotBlank(req.getConsignCompanyId())){
+        if (org.apache.commons.lang3.StringUtils.isNotBlank(req.getConsignCompanyId())) {
             entIdList.add(Long.valueOf(req.getConsignCompanyId()));
             type = CooperateTypeEnum.CONSIGN.getCode();
         }
-        if (org.apache.commons.lang3.StringUtils.isNotBlank(req.getCarriageCompanyId())){
+        if (org.apache.commons.lang3.StringUtils.isNotBlank(req.getCarriageCompanyId())) {
             entIdList.add(Long.valueOf(req.getCarriageCompanyId()));
             type = CooperateTypeEnum.CARRIAGE.getCode();
         }
         //查询物流企业
         Set<Long> contractIdList = Sets.newHashSet();
-        if (org.apache.commons.collections4.CollectionUtils.isNotEmpty(entIdList)){
+        if (org.apache.commons.collections4.CollectionUtils.isNotEmpty(entIdList)) {
             List<KwcContractLogisticsUnit> units = kwcContractLogisticsUnitRepository.queryByEntIds(entIdList, type);
             if (CollectionUtils.isNotEmpty(units)) {
                 Set<Long> contractIds = units.stream().filter(x -> Objects.equals(x.getEntId(), entId))
                         .map(KwcContractLogisticsUnit::getContractId)
                         .collect(Collectors.toSet());
                 contractIdList = units.stream()
-                        .filter(x->contractIds.contains(x.getContractId()))
+                        .filter(x -> contractIds.contains(x.getContractId()))
                         .map(KwcContractLogisticsUnit::getContractId).collect(Collectors.toSet());
             }
         }
@@ -1123,12 +1121,12 @@ public class KwcContractLogisticsService {
             return PageDataResult.empty(req.getPageNum(), req.getPageSize());
         }
 
-        IPage<KwcContractLogistics> page =kwcContractLogisticsRepository.queryByPage(req.getPageNum(),req.getPageSize(),
+        IPage<KwcContractLogistics> page = kwcContractLogisticsRepository.queryByPage(req.getPageNum(), req.getPageSize(),
                 req.getContractNo(),
-                req.getContractName(),req.getStatus(),contractIdList);
+                req.getContractName(), req.getStatus(), contractIdList);
         List<KwcContractLogistics> records = page.getRecords();
         if (CollectionUtils.isEmpty(records)) {
-            return PageDataResult.empty(req.getPageNum(),req.getPageSize());
+            return PageDataResult.empty(req.getPageNum(), req.getPageSize());
         }
         //发起人id
         List<Long> userIds =
@@ -1137,7 +1135,7 @@ public class KwcContractLogisticsService {
                         .collect(Collectors.toList());
         Map<Long, UserCacheResDto> longUserCacheResDtoMap = Maps.newHashMap();
         //获取员工信息
-        if (org.apache.commons.collections4.CollectionUtils.isNotEmpty(userIds)){
+        if (org.apache.commons.collections4.CollectionUtils.isNotEmpty(userIds)) {
             longUserCacheResDtoMap = remoteSystemService.queryUserCacheMapByIds(userIds);
         }
 
@@ -1146,9 +1144,9 @@ public class KwcContractLogisticsService {
                 .map(KwcContractLogistics::getId)
                 .collect(Collectors.toSet());
         //查询物流商品信息
-        List<KwcContractLogisticsGoods> kwcContractLogisticsGoods =kwcContractLogisticsGoodsRepository.queryByContractIds(contractIds);
+        List<KwcContractLogisticsGoods> kwcContractLogisticsGoods = kwcContractLogisticsGoodsRepository.queryByContractIds(contractIds);
         Map<Long, List<KwcContractLogisticsGoods>> contractIdAndGoodsMap = Maps.newHashMap();
-        if (org.apache.commons.collections4.CollectionUtils.isNotEmpty(kwcContractLogisticsGoods)){
+        if (org.apache.commons.collections4.CollectionUtils.isNotEmpty(kwcContractLogisticsGoods)) {
             //按照合同id进行分组
             contractIdAndGoodsMap =
                     kwcContractLogisticsGoods.stream().collect(Collectors.groupingBy(KwcContractLogisticsGoods::getContractId));
@@ -1158,17 +1156,17 @@ public class KwcContractLogisticsService {
         List<KwcContractLogisticsUnit> kwcContractLogisticsUnits =
                 kwcContractLogisticsUnitRepository.queryByContractIds(contractIds);
         Map<String, KwcContractLogisticsUnit> contractUniTypeAndUnitMap = Maps.newHashMap();
-        if (org.apache.commons.collections4.CollectionUtils.isNotEmpty(kwcContractLogisticsUnits)){
+        if (org.apache.commons.collections4.CollectionUtils.isNotEmpty(kwcContractLogisticsUnits)) {
             //合同id和单位类型组合成key映射物流企业信息
-             contractUniTypeAndUnitMap = kwcContractLogisticsUnits.stream()
-                    .collect(Collectors.toMap(k->k.getContractId() + "-" + k.getUnitType(),
+            contractUniTypeAndUnitMap = kwcContractLogisticsUnits.stream()
+                    .collect(Collectors.toMap(k -> k.getContractId() + "-" + k.getUnitType(),
                             Function.identity(), (x, y) -> x));
         }
 
         // 根据物流合同查询运单
         List<RWaybillSubOrderVo> rWaybillSubOrderVos = transportRemoteService.queryWaybillOrderByLogContractIds(contractIds);
         Map<Long, RWaybillSubOrderVo> logTradeOrderIdAndWaybillMap = Maps.newHashMap();
-        if (CollectionUtils.isNotEmpty(rWaybillSubOrderVos)){
+        if (CollectionUtils.isNotEmpty(rWaybillSubOrderVos)) {
             logTradeOrderIdAndWaybillMap = rWaybillSubOrderVos.stream()
                     .collect(Collectors.toMap(RWaybillSubOrderVo::getLogContractId, Function.identity(), (x, y) -> x));
         }
@@ -1540,7 +1538,7 @@ public class KwcContractLogisticsService {
         } else if (Objects.isNull(x.getPrice())) {
             logisticsGoods.setPrice(Objects.nonNull(baseInfo.getCommonPrice())? baseInfo.getCommonPrice().setScale(2,
                     RoundingMode.HALF_UP) : null);
-        } else {
+        }else {
             logisticsGoods.setPrice(x.getPrice());
         }
         logisticsGoods.setPriceUnit(x.getAmountUnit());
@@ -1929,17 +1927,17 @@ public class KwcContractLogisticsService {
                 contractIdList.clear();
                 return contractIdList;
             }
-            
+
             // 查询可见企业下的所有物流合同单位
             List<KwcContractLogisticsUnit> permUnits =
                     kwcContractLogisticsUnitRepository.queryByEntIds(new ArrayList<>(perm.getVisibleEntIds()), null);
-            
+
             // 提取这些单位关联的合同ID
             Set<Long> entScopeContractIds = permUnits.stream()
                     .map(KwcContractLogisticsUnit::getContractId)
                     .filter(Objects::nonNull)
                     .collect(Collectors.toSet());
-            
+
             // 取交集:只保留在可见企业范围内的合同
             int beforeSize = contractIdList.size();
             contractIdList.retainAll(entScopeContractIds);
@@ -1959,17 +1957,17 @@ public class KwcContractLogisticsService {
                 contractIdList.clear();
                 return contractIdList;
             }
-            
+
             log.debug("开启个人数据权限过滤, 校验销售员ID: {}", uid);
             // 通过关联的贸易合同销售员进行过滤
             Set<Long> salesMatched = retainLogisticsContractIdsByLinkedTradeSalesman(contractIdList, uid);
-            
+
             // 更新原列表为过滤后的结果
             contractIdList.clear();
             contractIdList.addAll(salesMatched);
             log.debug("个人数据权限过滤完成, 最终合同数量: {}", contractIdList.size());
         }
-        
+
         return contractIdList;
     }
 
@@ -2002,7 +2000,7 @@ public class KwcContractLogisticsService {
                 .map(RWaybillSubOrderVo::getTradeId)
                 .filter(Objects::nonNull)
                 .collect(Collectors.toSet());
-        
+
         if (CollectionUtils.isEmpty(tradeOrderIds)) {
             log.debug("运单中未包含有效的贸易订单ID");
             return Collections.emptySet();
@@ -2038,18 +2036,18 @@ public class KwcContractLogisticsService {
             if (CollectionUtils.isEmpty(relTradeContractIds)) {
                 continue;
             }
-            
+
             // 只要有一个关联的贸易合同的销售员是指定用户,则该物流合同可见
             boolean ok = relTradeContractIds.stream()
                     .map(tradeMap::get)
                     .filter(Objects::nonNull)
                     .anyMatch(t -> salesmanUserId.equals(t.getSalesmanId()));
-            
+
             if (ok) {
                 result.add(logId);
             }
         }
-        
+
         log.debug("销售员权限过滤结束, 匹配到的物流合同数: {}", result.size());
         return result;
     }
@@ -2073,17 +2071,17 @@ public class KwcContractLogisticsService {
             if (link.getLogContractId() == null || link.getTradeId() == null) {
                 continue;
             }
-            
+
             // 获取运单关联的贸易订单对应的贸易合同ID
             Long tradeContractId = tradeOrderIdToContractId.get(link.getTradeId());
             if (tradeContractId == null) {
                 continue;
             }
-            
+
             // 将贸易合同ID加入该物流合同对应的集合中
             result.computeIfAbsent(link.getLogContractId(), k -> new HashSet<>()).add(tradeContractId);
         }
-        
+
         log.debug("构建物流合同-贸易合同映射完成, 映射数量: {}", result.size());
         return result;
     }
@@ -2109,4 +2107,12 @@ public class KwcContractLogisticsService {
             return null;
         }
     }
+
+    public List<ContractGoodsVo> queryLogisticsGoods(Long contractId, String keyword) {
+        return kwcContractLogisticsMapper.selectGoods(contractId,keyword);
+    }
+
+    public List<LogisticsEntDto> queryLogisticsContract(String keyword) {
+        return kwcContractLogisticsMapper.queryContract(LoginUserHolder.getEntId(), keyword);
+    }
 }

+ 142 - 116
sckw-modules/sckw-contract/src/main/resources/mapper/KwcContractLogisticsMapper.xml

@@ -3,125 +3,126 @@
         PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.sckw.contract.dao.KwcContractLogisticsMapper">
-
     <select id="queryList" resultType="com.sckw.contract.model.dto.res.QueryListResDto">
-         select a.amount,
-                a.charging,
-                a.name contractName,
-                a.contract_no,
-                c.create_by initiateBy,
-                c.create_time initiateTime,
-                a.create_time,
-                a.start_time,
-                a.end_time,
-                a.id,
-                a.remark,
-                a.signing_way,
-                d.create_time signTime,
-                a.status,
-                b.unit_type,
-                b.ent_id,
-                b.firm_name entName,
-                e.ent_id targetEntId,
-                e.firm_name targetEntName,
-                a.performed_amount performedAmount,
-                a.contract_pid contractPid,
-                f.name contractPname
-          from kwc_contract_logistics a
-          left join kwc_contract_logistics_unit b on a.id = b.contract_id
-           and b.unit_type = #{entType}
-           and case when a.status != 3 then b.ent_id in
-                <foreach collection="allEnt" separator="," open="(" close=")" item="item">
-                    #{item}
-                </foreach>
-               else 1 = 1
-                 end
+        select a.amount,
+               a.charging,
+               a.name             contractName,
+               a.contract_no,
+               c.create_by        initiateBy,
+               c.create_time      initiateTime,
+               a.create_time,
+               a.start_time,
+               a.end_time,
+               a.id,
+               a.remark,
+               a.signing_way,
+               d.create_time      signTime,
+               a.status,
+               b.unit_type,
+               b.ent_id,
+               b.firm_name        entName,
+               e.ent_id           targetEntId,
+               e.firm_name        targetEntName,
+               a.performed_amount performedAmount,
+               a.contract_pid     contractPid,
+               f.name             contractPname
+        from kwc_contract_logistics a
+            left join kwc_contract_logistics_unit b on a.id = b.contract_id
+            and b.unit_type = #{entType}
+            and case when a.status != 3 then b.ent_id in
+        <foreach collection="allEnt" separator="," open="(" close=")" item="item">
+            #{item}
+        </foreach>
+        else 1 = 1
+            end
             and b.del_flag = 0
-          left join kwc_contract_logistics_track c on a.id = c.contract_id and c.del_flag = 0 and c.type = 1
-          left join kwc_contract_logistics_track d on a.id = d.contract_id and d.del_flag = 0 and d.type = 0
-          left join kwc_contract_logistics_unit e on a.id = e.contract_id and e.unit_type != #{entType} and e.del_flag = 0
-          left join kwc_contract_logistics f on f.id = a.contract_pid
+            left join kwc_contract_logistics_track c on a.id = c.contract_id and c.del_flag = 0 and c.type = 1
+            left join kwc_contract_logistics_track d on a.id = d.contract_id and d.del_flag = 0 and d.type = 0
+            left join kwc_contract_logistics_unit e
+                      on a.id = e.contract_id and e.unit_type != #{entType} and e.del_flag = 0
+            left join kwc_contract_logistics f on f.id = a.contract_pid
         where a.del_flag = 0
-          and case when a.status = 3 then a.ent_id = #{entId} and #{entType} = 3
-                else (b.ent_id in
-                    <foreach collection="allEnt" separator="," open="(" close=")" item="item">
-                        #{item}
-                    </foreach>
-                     and b.id is not null)
-                end
-          <if test="startTime != null">
-              and a.create_time >= #{startTime}
-          </if>
-          <if test="endTime != null">
-              and a.create_time &lt;= #{endTime}
-          </if>
-          <if test="status != null">
-              and a.status = #{status}
-          </if>
-            <if test="charging != null">
-                and a.charging = #{charging}
-            </if>
-            <if test="signingWay != null">
-                and a.signing_way = #{signingWay}
+          and case
+            when a.status = 3 then a.ent_id = #{entId} and #{entType} = 3
+        else (b.ent_id in
+        <foreach collection="allEnt" separator="," open="(" close=")" item="item">
+            #{item}
+        </foreach>
+        and b.id is not null)
+            end
+        <if test="startTime != null">
+            and a.create_time >= #{startTime}
+        </if>
+        <if test="endTime != null">
+            and a.create_time &lt;= #{endTime}
+        </if>
+        <if test="status != null">
+            and a.status = #{status}
+        </if>
+        <if test="charging != null">
+            and a.charging = #{charging}
+        </if>
+        <if test="signingWay != null">
+            and a.signing_way = #{signingWay}
+        </if>
+        <if test="keywords != null and keywords != ''">
+            and (b.firm_name like concat('%', #{keywords}, '%') or
+                 e.firm_name like concat('%', #{keywords}, '%') or
+                 b.phone like concat('%', #{keywords}, '%') or
+                 b.sign_phone like concat('%', #{keywords}, '%') or
+                 a.contract_no like concat('%', #{keywords}, '%') or
+                 a.name like concat('%', #{keywords}, '%')
+            <if test="initiateList != null and initiateList.size() > 0">
+                or a.create_by in
+                <foreach collection="initiateList" item="item" open="(" close=")" separator=",">
+                    #{item}
+                </foreach>
             </if>
-          <if test="keywords != null and keywords != ''">
-              and (b.firm_name like concat('%', #{keywords}, '%') or
-                   e.firm_name like concat('%', #{keywords}, '%') or
-                   b.phone like concat('%', #{keywords}, '%') or
-                   b.sign_phone like concat('%', #{keywords}, '%') or
-                   a.contract_no like concat('%', #{keywords}, '%') or
-                   a.name like concat('%', #{keywords}, '%')
-                   <if test="initiateList != null and initiateList.size() > 0">
-                       or a.create_by in
-                       <foreach collection="initiateList" item="item" open="(" close=")" separator=",">
-                           #{item}
-                       </foreach>
-                   </if>
-                   )
-          </if>
-          <if test="idList != null and idList.size() > 0">
-              and a.id in
+            )
+        </if>
+        <if test="idList != null and idList.size() > 0">
+            and a.id in
             <foreach collection="idList" open="(" close=")" separator="," item="item">
                 #{item}
             </foreach>
-          </if>
-          <if test="targetEntId != null">
-              and e.ent_id = #{targetEntId}
-          </if>
+        </if>
+        <if test="targetEntId != null">
+            and e.ent_id = #{targetEntId}
+        </if>
         order by a.create_time desc
     </select>
 
     <select id="queryLogisticsList" resultType="com.sckw.contract.model.dto.res.QueryListResDto">
         select a.amount,
                a.charging,
-               a.name contractName,
+               a.name             contractName,
                a.contract_no,
-               c.create_by initiateBy,
-               c.create_time initiateTime,
+               c.create_by        initiateBy,
+               c.create_time      initiateTime,
                a.create_time,
                a.start_time,
                a.end_time,
                a.id,
                a.remark,
                a.signing_way,
-               d.create_time signTime,
+               d.create_time      signTime,
                a.status,
                b.unit_type,
-               b.ent_id checkedEntId,
-               b.firm_name checkedEntName,
-               e.ent_id carrierEntId,
-               e.firm_name carrierEntName,
+               b.ent_id           checkedEntId,
+               b.firm_name        checkedEntName,
+               e.ent_id           carrierEntId,
+               e.firm_name        carrierEntName,
                a.performed_amount performedAmount,
-               a.contract_pid contractPid,
-               f.name contractPname
-          from kwc_contract_logistics a
-          left join kwc_contract_logistics_unit b on a.id = b.contract_id and b.del_flag = 0 and b.unit_type = 3
-          left join kwc_contract_logistics_unit e on a.id = e.contract_id and e.del_flag = 0 and e.unit_type = 4
-          left join kwc_contract_logistics_track c on a.id = c.contract_id and c.del_flag = 0 and c.type = 1
-          left join kwc_contract_logistics_track d on a.id = d.contract_id and d.del_flag = 0 and d.type = 0
-          left join kwc_contract_logistics f on f.id = a.contract_pid
-         where a.del_flag = 0
-           and a.status != 3
+               a.contract_pid     contractPid,
+               f.name             contractPname
+        from kwc_contract_logistics a
+                 left join kwc_contract_logistics_unit b on a.id = b.contract_id and b.del_flag = 0 and b.unit_type = 3
+                 left join kwc_contract_logistics_unit e on a.id = e.contract_id and e.del_flag = 0 and e.unit_type = 4
+                 left join kwc_contract_logistics_track c on a.id = c.contract_id and c.del_flag = 0 and c.type = 1
+                 left join kwc_contract_logistics_track d on a.id = d.contract_id and d.del_flag = 0 and d.type = 0
+                 left join kwc_contract_logistics f on f.id = a.contract_pid
+        where a.del_flag = 0
+          and a.status != 3
         <if test="authEntIdList != null and authEntIdList.size() != 0">
             and a.ent_id in
             <foreach collection="authEntIdList" separator="," close=")" open="(" item="item">
@@ -161,32 +162,26 @@
     </select>
 
     <select id="checkContractIsSole" resultType="java.lang.String">
-        SELECT
-            DISTINCT CONCAT(a.contract_no,b.ent_id,c.ent_id)  as isSole
-        FROM
-            kwc_contract_logistics a
-                LEFT JOIN kwc_contract_logistics_unit b ON a.id = b.contract_id
-                LEFT JOIN kwc_contract_logistics_unit c ON a.id = c.contract_id
-        WHERE
-            a.del_flag = 0
+        SELECT DISTINCT CONCAT(a.contract_no, b.ent_id, c.ent_id) as isSole
+        FROM kwc_contract_logistics a
+                 LEFT JOIN kwc_contract_logistics_unit b ON a.id = b.contract_id
+                 LEFT JOIN kwc_contract_logistics_unit c ON a.id = c.contract_id
+        WHERE a.del_flag = 0
           AND b.unit_type = 4
           AND c.unit_type = 3
     </select>
 
     <select id="selectIsSole" resultType="com.sckw.contract.model.entity.KwcContractLogistics">
-        SELECT
-            a.*
-        FROM
-            kwc_contract_logistics a
-                LEFT JOIN kwc_contract_logistics_unit b ON a.id = b.contract_id
-                LEFT JOIN kwc_contract_logistics_unit c ON a.id = c.contract_id
-        WHERE
-            a.del_flag = 0
+        SELECT a.*
+        FROM kwc_contract_logistics a
+                 LEFT JOIN kwc_contract_logistics_unit b ON a.id = b.contract_id
+                 LEFT JOIN kwc_contract_logistics_unit c ON a.id = c.contract_id
+        WHERE a.del_flag = 0
           AND b.unit_type = 4
           AND c.unit_type = 3
-        and b.ent_id =#{acceptId}
-        and c.ent_id =#{consignId}
-        and a.contract_no=#{contractNo}
+          and b.ent_id = #{acceptId}
+          and c.ent_id = #{consignId}
+          and a.contract_no = #{contractNo}
     </select>
 
     <select id="count" resultType="java.lang.Long">
@@ -196,7 +191,7 @@
         <where>
             a.del_flag = 0
               and a.status = 1
-            and a.ent_id != #{entId}
+              and a.ent_id != #{entId}
             <if test="ids != null and ids.size() != 0">
                 and a.ent_id in
                 <foreach collection="ids" open="(" close=")" separator="," item="item">
@@ -239,4 +234,35 @@
               and (d.ent_id = #{entId} or b.ent_id = #{entId})
         </where>
     </select>
+
+    <select id="queryContract" resultType="com.sckw.contract.model.vo.res.LogisticsEntDto">
+        SELECT a.id contractId,
+               a.contract_no
+        FROM kwc_contract_logistics a
+                 LEFT JOIN kwc_contract_logistics_unit b ON a.id = b.contract_id and b.del_flag = 0 and b.unit_type = 3
+        <where>
+            a.del_flag = 0
+              and a.status = 1
+            and a.transport_biz_type = 2
+            and b.ent_id = #{entId}
+            <if test="keyword != null and keyword != ''">
+                and (a.contract_no like concat('%', #{keyword}, '%')
+                    or a.name like concat('%', #{keyword}, '%'))
+            </if>
+        </where>
+    </select>
+
+    <select id="selectGoods" resultType="com.sckw.contract.model.vo.res.ContractGoodsVo">
+        SELECT a.goods_id,
+               a.goods_name,
+               a.amount
+        FROM kwc_contract_logistics_goods a
+        <where>
+            a.del_flag = 0
+              and a.contract_id = #{contractId}
+            <if test="keyword != null and keyword != ''">
+                and a.goods_name like concat('%', #{keyword}, '%')
+            </if>
+        </where>
+    </select>
 </mapper>