czh 2 years ago
parent
commit
0c3767fe9b

+ 5 - 1
sckw-common/sckw-common-core/src/main/java/com/sckw/core/common/enums/enums/DictEnum.java

@@ -56,7 +56,11 @@ public enum DictEnum {
     PRODUCT_NAME_TYPE_0("product_name_type", "0", "毛石"),
     GOODS_STATUS_0("goods_status", "0", "已保存"),
     GOODS_STATUS_1("goods_status", "1", "已上架"),
-    GOODS_STATUS_2("goods_status", "2", "已下架");
+    GOODS_STATUS_2("goods_status", "2", "已下架"),
+    CHARGING_TYPE_1("charging_type", "1", "按装货量") ,
+    CHARGING_TYPE_2("charging_type", "2", "按卸货量") ,
+    CHARGING_TYPE_3("charging_type", "3", "按车次");
+
     private final String type;
     private final String value;
     private final String label;

+ 2 - 2
sckw-common/sckw-common-core/src/main/java/com/sckw/core/model/enums/EntTypeEnum.java

@@ -14,9 +14,9 @@ public enum EntTypeEnum {
     SUPPLIER(1, "供应商"),
     //采购商
     PURCHASER(2, "采购商"),
-    //4PL物流
+    //4PL物流  托运
     LOGISTICS3(3, "4PL物流"),
-    //3PL物流
+    //3PL物流  承运
     LOGISTICS4(4, "3PL物流");
 
     private final int code;

+ 3 - 2
sckw-modules/sckw-contract/src/main/java/com/sckw/contract/dao/KwcContractLogisticsMapper.java

@@ -2,6 +2,7 @@ package com.sckw.contract.dao;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 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.QueryListResVo;
@@ -23,9 +24,9 @@ public interface KwcContractLogisticsMapper extends BaseMapper<KwcContractLogist
      * @param: reqVo
      * @author: czh
      * @date 2023/7/17
-     * @return QueryListResVo
+     * @return QueryListResDto
      */
-    List<QueryListResVo> queryList(QueryListReqDto reqVo);
+    List<QueryListResDto> queryList(QueryListReqDto reqVo);
 }
 
 

+ 111 - 0
sckw-modules/sckw-contract/src/main/java/com/sckw/contract/model/dto/res/QueryListResDto.java

@@ -0,0 +1,111 @@
+package com.sckw.contract.model.dto.res;
+
+import lombok.Data;
+
+import java.math.BigDecimal;
+import java.util.Date;
+
+/**
+ * @author czh
+ * @desc 查询返参
+ * @date 2023/7/18
+ */
+@Data
+public class QueryListResDto {
+
+    /**
+     * 合同总量
+     */
+    private BigDecimal amount;
+
+    /**
+     * 计费方式(按装货量、按卸货量、按车次)
+     */
+    private Integer charging;
+
+    /**
+     * 合同名
+     */
+    private String contactName;
+
+    /**
+     * 合同号
+     */
+    private String contractNo;
+
+    /**
+     * 发起人id
+     */
+    private Long initiateBy;
+
+    /**
+     * 发起时间
+     */
+    private Date initiateTime;
+
+    /**
+     * 创建时间
+     */
+    private Date createTime;
+
+    /**
+     * 起始时间
+     */
+    private Date startTime;
+
+    /**
+     * 结束时间
+     */
+    private Date endTime;
+
+    /**
+     * 合同id
+     */
+    private Long id;
+
+    /**
+     * 备注
+     */
+    private String remark;
+
+    /**
+     * 签约方式
+     */
+    private String signingWay;
+
+    /**
+     * 签约时间
+     */
+    private Date signTime;
+
+    /**
+     * 合同状态
+     */
+    private Integer status;
+
+    /**
+     * 单位类型(3托运商,4承运商)
+     */
+    private Integer unitType;
+
+    /**
+     * 企业id
+     */
+    private Long entId;
+
+    /**
+     * 企业名
+     */
+    private String entName;
+
+    /**
+     * 对方企业id
+     */
+    private Long targetEntId;
+
+    /**
+     * 对方企业名
+     */
+    private String targetEntName;
+
+}

+ 51 - 7
sckw-modules/sckw-contract/src/main/java/com/sckw/contract/service/KwcContractLogisticsService.java

@@ -1,5 +1,7 @@
 package com.sckw.contract.service;
 
+import java.util.Date;
+
 import java.io.IOException;
 import java.math.BigDecimal;
 import java.util.*;
@@ -9,6 +11,7 @@ import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
 import com.sckw.contract.dao.KwcContractLogisticsMapper;
 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.entity.KwcContractLogisticsGoods;
 import com.sckw.contract.model.entity.KwcContractLogisticsUnit;
@@ -19,6 +22,7 @@ import com.sckw.contract.model.vo.res.ContractLogisticsDetailResVo;
 import com.sckw.contract.model.vo.res.LogisticsBaseInfoResVo;
 import com.sckw.contract.model.vo.res.LogisticsGoodsInfoResVo;
 import com.sckw.contract.model.vo.res.QueryListResVo;
+import com.sckw.core.common.enums.enums.DictEnum;
 import com.sckw.core.common.enums.enums.DictTypeEnum;
 import com.sckw.core.exception.SystemException;
 import com.sckw.core.model.constant.Global;
@@ -37,6 +41,7 @@ import com.sckw.core.web.context.LoginUserHolder;
 import com.sckw.excel.utils.EasyExcelUtil;
 import com.sckw.system.api.RemoteSystemService;
 import com.sckw.system.api.model.dto.res.SysDictResDto;
+import com.sckw.system.api.model.dto.res.UserCacheResDto;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.dubbo.config.annotation.DubboReference;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -146,9 +151,9 @@ public class KwcContractLogisticsService {
     }
 
     /**
+     * @param id 主键
      * @return ContractLogisticsDetailResVo
      * @desc 合同详情
-     * @param  id 主键
      * @author czh
      * @date 2023/7/16
      */
@@ -360,29 +365,68 @@ public class KwcContractLogisticsService {
     }
 
     /**
+     * @return PageResult
      * @desc: 分页查询
-     * @param:  reqVo
+     * @param: reqVo
      * @author: czh
      * @date 2023/7/17
-     * @return PageResult
      */
     public PageResult queryListByPage(QueryListReqVo reqVo) {
         PageHelper.startPage(reqVo.getPage(), reqVo.getPageSize());
         QueryListReqDto queryListReqDto = new QueryListReqDto();
         BeanUtils.copyProperties(reqVo, queryListReqDto);
-        List<QueryListResVo> list = kwcContractLogisticsMapper.queryList(queryListReqDto);
+        queryListReqDto.setEntId(LoginUserHolder.getEntId());
+        List<QueryListResVo> list = getQueryListResVos(queryListReqDto);
         return PageHelperUtil.getPageResult(new PageInfo<>(list));
     }
 
+
+    /**
+     * @param queryListReqDto 入参
+     * @return QueryListResVo
+     * @desc: 抽取公共部分
+     * @author: czh
+     * @date: 2023/7/18
+     */
+    private List<QueryListResVo> getQueryListResVos(QueryListReqDto queryListReqDto) {
+        List<QueryListResDto> queryListResDtos = kwcContractLogisticsMapper.queryList(queryListReqDto);
+        Map<Long, UserCacheResDto> longUserCacheResDtoMap = new HashMap<>();
+        List<Long> initiateByList = queryListResDtos.stream().map(QueryListResDto::getInitiateBy).toList();
+        if (CollectionUtils.isNotEmpty(initiateByList)) {
+            longUserCacheResDtoMap = remoteSystemService.queryUserCacheMapByIds(initiateByList);
+        }
+
+        List<QueryListResVo> list = new ArrayList<>();
+        for (QueryListResDto queryListResDto : queryListResDtos) {
+            QueryListResVo queryListResVo = new QueryListResVo();
+            queryListResVo.setCheckedEntName(queryListResDto.getUnitType().compareTo(EntTypeEnum.LOGISTICS3.getCode()) == 0 ? queryListResDto.getEntName() : queryListResDto.getTargetEntName());
+            queryListResVo.setCarrierEntName(queryListResDto.getUnitType().compareTo(EntTypeEnum.LOGISTICS3.getCode()) == 0 ? queryListResDto.getTargetEntName() : queryListResDto.getEntName());
+
+            UserCacheResDto userCacheResDto = longUserCacheResDtoMap.get(queryListResDto.getInitiateBy());
+            if (Objects.nonNull(userCacheResDto)) {
+                queryListResVo.setInitiateName(userCacheResDto.getName());
+                queryListResVo.setInitiateEntName(Objects.isNull(userCacheResDto.getEntInfo()) ? "" : userCacheResDto.getEntInfo().getFirmName());
+            }
+            queryListResVo.setChargingName(DictEnum.getLabel(DictTypeEnum.CHARGING_TYPE.getType(), String.valueOf(queryListResDto.getCharging())));
+            queryListResVo.setStatusName(ContractStatusEnum.getName(queryListResDto.getStatus()).getName());
+
+            // todo
+            queryListResVo.setPerformedAmount(new BigDecimal("0"));
+            list.add(queryListResVo);
+        }
+        return list;
+    }
+
     public void export(QueryListReqVo reqVo) {
         QueryListReqDto queryListReqDto = new QueryListReqDto();
         BeanUtils.copyProperties(reqVo, queryListReqDto);
-
+        queryListReqDto.setEntId(LoginUserHolder.getEntId());
         if (StringUtils.isNotBlank(reqVo.getIds())) {
             List<Long> idList = Arrays.stream(reqVo.getIds().split(Global.COMMA)).map(Long::parseLong).toList();
             queryListReqDto.setIdList(idList);
         }
-        List<QueryListResVo> queryListResVos = kwcContractLogisticsMapper.queryList(queryListReqDto);
+
+        List<QueryListResVo> queryListResVos = getQueryListResVos(queryListReqDto);
         try {
             EasyExcelUtil.writeSingleExcel("物流合同.xlsx", "sheet1", queryListResVos, QueryListResVo.class);
         } catch (IOException e) {
@@ -404,7 +448,7 @@ public class KwcContractLogisticsService {
         queryListReqDto.setEntId(entId);
         queryListReqDto.setStatus(ContractStatusEnum.SIGNED.getCode());
         queryListReqDto.setEntType(EntTypeEnum.LOGISTICS3.getCode());
-        return kwcContractLogisticsMapper.queryList(queryListReqDto);
+        return getQueryListResVos(queryListReqDto);
     }
 
 }

+ 25 - 9
sckw-modules/sckw-contract/src/main/resources/mapper/KwcContractLogisticsMapper.xml

@@ -40,18 +40,34 @@
         del_flag
     </sql>
 
-    <select id="queryList" resultType="com.sckw.contract.model.vo.res.QueryListResVo">
-        select distinct a.*
+    <select id="queryList" resultType="com.sckw.contract.model.dto.res.QueryListResDto">
+        select a.amount,
+                a.charging,
+                a.name contactName,
+                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
           from kwc_contract_logistics a
-          left join kwc_contract_logistics_unit b on a.id = b.contract_id
+          left join kwc_contract_logistics_unit b on a.id = b.contract_id and b.unit_type = #{entType}
+          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 = b.contract_id and b.unit_type != #{entType}
         where a.del_flag = 0
           and b.del_flag = 0
-          <if test="entType != null">
-              and b.unit_type = #{entType}
-          </if>
-          <if test="entId != null">
-              and b.ent_id = #{entId}
-          </if>
+          and b.ent_id = #{entId}
           <if test="startTime != null">
               and a.create_time >= #{startTime}
           </if>

+ 1 - 1
sckw-modules/sckw-manage/src/main/java/com/sckw/manage/controller/KwmAddressController.java

@@ -18,7 +18,7 @@ import org.springframework.web.bind.annotation.RestController;
  * @date 2023/7/10
  */
 @RestController
-@RequestMapping("/address")
+@RequestMapping("/kwmAddress")
 public class KwmAddressController {
 
     @Autowired

+ 0 - 2
sckw-modules/sckw-manage/src/main/java/com/sckw/manage/model/vo/req/AddressQueryReqVo.java

@@ -33,13 +33,11 @@ public class AddressQueryReqVo extends PageRequest implements Serializable {
     /**
      * 创建开始时间(时间戳)
      */
-    @NotNull(message = "开始时间不能为空")
     private Date startTime;
 
     /**
      * 创建结束时间(时间戳)
      */
-    @NotNull(message = "结束时间不能为空")
     private Date endTime;
 
     /**