Преглед на файлове

1、运力查询;
2、企业联系;

zk преди 2 години
родител
ревизия
a0f3ae44cc

+ 2 - 1
sckw-common/sckw-common-core/src/main/java/com/sckw/core/model/page/PageResult.java

@@ -2,6 +2,7 @@ package com.sckw.core.model.page;
 
 import com.github.pagehelper.PageInfo;
 
+import java.io.Serializable;
 import java.util.List;
 import java.util.Map;
 
@@ -10,7 +11,7 @@ import java.util.Map;
  * @Author zk
  * @Date 2019/5/14
  */
-public class PageResult {
+public class PageResult implements Serializable {
 
     /**
      * 当前页数

+ 7 - 0
sckw-common/sckw-common-core/src/main/java/com/sckw/core/utils/NumberUtils.java

@@ -24,6 +24,13 @@ public class NumberUtils {
         }
     }
 
+    public static Integer parseIntV1(Object obj) {
+        if (obj == null) {
+            return null;
+        }
+        return parseInt(obj, 0);
+    }
+
     public static int parseInt(Object obj) {
         return parseInt(obj, 0);
     }

+ 8 - 0
sckw-modules-api/sckw-fleet-api/src/main/java/com/sckw/fleet/api/RemoteFleetService.java

@@ -3,6 +3,7 @@ package com.sckw.fleet.api;
 import com.sckw.fleet.api.model.vo.RDriverDetailVo;
 import com.sckw.fleet.api.model.vo.RDriverVo;
 import com.sckw.fleet.api.model.vo.RTruckVo;
+import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
 import java.util.Map;
@@ -70,4 +71,11 @@ public interface RemoteFleetService {
      **/
     int updateById(RTruckVo params);
 
+    /**
+     * @param entIds 企业ID
+     * @desc 企业运力统计
+     * @author zk
+     * @date 2023/9/4
+     **/
+    List<Map<String, Object>> capacityStatistics(List entIds);
 }

+ 8 - 0
sckw-modules/sckw-fleet/src/main/java/com/sckw/fleet/dao/KwfTruckMapper.java

@@ -6,6 +6,7 @@ import com.sckw.fleet.model.vo.KwfDriverVo;
 import com.sckw.fleet.model.vo.KwfTableTopCount;
 import com.sckw.fleet.model.vo.KwfTruckVo;
 import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
 import java.util.Map;
@@ -45,4 +46,11 @@ public interface KwfTruckMapper extends BaseMapper<KwfTruck> {
      * @return
      */
     List<KwfTruck> findTruck(Map<String, Object> params);
+
+    /**
+     * 企业运力统计
+     * @param entIds
+     * @return
+     */
+    List<Map<String, Object>> capacityStatistics(@Param("entIds") List entIds);
 }

+ 11 - 0
sckw-modules/sckw-fleet/src/main/java/com/sckw/fleet/dubbo/RemoteFleetServiceImpl.java

@@ -168,4 +168,15 @@ public class RemoteFleetServiceImpl implements RemoteFleetService {
         BeanUtils.copyProperties(params, truck);
         return truckDao.updateById(truck);
     }
+
+    /**
+     * @param entIds 企业ID
+     * @desc 企业运力统计
+     * @author zk
+     * @date 2023/9/4
+     **/
+    @Override
+    public List<Map<String, Object>> capacityStatistics(List entIds) {
+        return truckDao.capacityStatistics(entIds);
+    }
 }

+ 16 - 0
sckw-modules/sckw-fleet/src/main/resources/mapper/KwfTruckMapper.xml

@@ -218,4 +218,20 @@
         and tr.id = #{id, jdbcType=VARCHAR}
     </select>
 
+    <select id="capacityStatistics" resultType="java.util.Map" >
+        SELECT
+        ent_id entId, count(1) capacityTotal, sum(auth_status) capacityAmount
+        from kwf_truck
+        where del_flag = 0
+        <choose>
+            <when test="entIds != null and entIds.size() > 0">
+                and ent_id in
+                <foreach collection="entIds" item="item" open="(" close=")" separator=",">
+                    #{item,jdbcType=BIGINT}
+                </foreach>
+            </when>
+        </choose>
+        GROUP BY ent_id
+    </select>
+
 </mapper>

+ 3 - 10
sckw-modules/sckw-report/src/main/java/com/sckw/report/controller/KwFleetController.java

@@ -1,18 +1,14 @@
 package com.sckw.report.controller;
 
-import com.github.pagehelper.PageHelper;
-import com.github.pagehelper.PageInfo;
 import com.sckw.core.exception.SystemException;
-import com.sckw.core.model.page.PageHelperUtil;
 import com.sckw.core.model.page.PageResult;
 import com.sckw.core.web.response.HttpResult;
-import com.sckw.report.model.vo.KwfCapacityVo;
 import com.sckw.report.service.KwFleetService;
 import lombok.AllArgsConstructor;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 import java.util.HashMap;
-import java.util.List;
+import java.util.Map;
 
 /**
  * @author zk
@@ -34,11 +30,8 @@ public class KwFleetController {
      * @date 2023/9/1
      **/
     @PostMapping("/capacity")
-    public HttpResult capacity(@RequestBody HashMap params) throws SystemException {
-        // 设置分页参数
-        PageHelper.startPage(PageResult.getPage(params), PageResult.getPageSize(params));
-        List<KwfCapacityVo> list = fleetService.capacity(params);
-        PageResult pageResult = PageHelperUtil.getPageResult(new PageInfo<>(list));
+    public HttpResult capacity(@RequestBody HashMap params) {
+        PageResult pageResult = fleetService.capacity(params);
         return HttpResult.ok(pageResult);
     }
 }

+ 2 - 2
sckw-modules/sckw-report/src/main/java/com/sckw/report/model/vo/KwfCapacityVo.java

@@ -17,7 +17,7 @@ public class KwfCapacityVo implements Serializable {
     /**
      * 企业ID
      */
-    private String entId;
+    private Long entId;
 
     /**
      * 企业名称
@@ -32,7 +32,7 @@ public class KwfCapacityVo implements Serializable {
     /**
      * 总运量
      */
-    private Integer capacityAmount;
+    private Double capacityAmount;
 
     /**
      * 企业联系人

+ 56 - 4
sckw-modules/sckw-report/src/main/java/com/sckw/report/service/KwFleetService.java

@@ -1,9 +1,20 @@
 package com.sckw.report.service;
 
+import com.alibaba.fastjson.JSON;
+import com.github.pagehelper.PageHelper;
+import com.github.pagehelper.PageInfo;
+import com.sckw.core.model.constant.Global;
+import com.sckw.core.model.page.PageHelperUtil;
+import com.sckw.core.model.page.PageResult;
+import com.sckw.core.utils.NumberUtils;
+import com.sckw.fleet.api.RemoteFleetService;
 import com.sckw.report.model.vo.KwfCapacityVo;
+import com.sckw.system.api.RemoteUserService;
+import com.sckw.system.api.model.dto.res.KwsEnterpriseResDto;
+import org.apache.dubbo.config.annotation.DubboReference;
 import org.springframework.stereotype.Service;
-import java.util.HashMap;
-import java.util.List;
+
+import java.util.*;
 
 /**
  * @author zk
@@ -13,14 +24,55 @@ import java.util.List;
 @Service
 public class KwFleetService {
 
+    @DubboReference(version = "1.0.0", group = "design", check = false)
+    RemoteUserService userService;
+
+    @DubboReference(version = "1.0.0", group = "design", check = false)
+    RemoteFleetService fleetService;
+
     /**
      * @param params {page:页数、pageSize:每页条数、。。。}
      * @desc 分页查询
      * @author zk
      * @date 2023/9/1
      **/
-    public List<KwfCapacityVo> capacity(HashMap params) {
+    public PageResult capacity(HashMap<String, Object> params) {
+        //企业数据查询
+        List<KwfCapacityVo> list = new ArrayList<>();
+        List<Long> entIds = new ArrayList<>();
+        Integer cityCode = NumberUtils.parseIntV1(params.get("cityCode"));
+        List<Integer> entTypes = new ArrayList<>(Arrays.asList(3, 4));
+        Integer page = PageResult.getPage(params);
+        Integer pageSize = PageResult.getPageSize(params);
+        PageResult pageResult = userService.queryEntInfoByCityCodeAndEntTypesWithPage(cityCode, entTypes, page, pageSize);
+        List<KwsEnterpriseResDto> ents = JSON.parseArray(JSON.toJSONString(pageResult.getList()), KwsEnterpriseResDto.class);
+        for (KwsEnterpriseResDto ent:ents) {
+            KwfCapacityVo capacity = new KwfCapacityVo();
+            capacity.setEntId(ent.getId());
+            capacity.setFirmName(ent.getFirmName());
+            capacity.setCityCode(ent.getCityCode());
+            capacity.setCityName(ent.getCityName());
+            capacity.setDetailAddress(ent.getDetailAddress());
+            list.add(capacity);
+            entIds.add(ent.getId());
+        }
+
+        //企业运力统计
+        List<Map<String, Object>> statistics = fleetService.capacityStatistics(entIds);
+        Map<Long, Map<String, Object>> entMap = new HashMap<>(Global.NUMERICAL_SIXTEEN);
+        for (Map<String, Object> statistic:statistics) {
+            entMap.put(NumberUtils.parseLong(statistic.get("entId")), statistic);
+        }
 
-        return null;
+        //企业运力统计查询
+        for (KwfCapacityVo capacity:list) {
+            Map<String, Object> statistic = entMap.get(capacity.getEntId());
+            capacity.setCapacityTotal(statistic != null ? NumberUtils.parseInt(statistic.get("capacityTotal")) : Global.NUMERICAL_ZERO);
+            capacity.setCapacityAmount(statistic != null ? NumberUtils.parseDouble(statistic.get("capacityAmount")) : Global.NUMERICAL_ZERO);
+        }
+        pageResult.setList(list);
+        /*PageHelper.startPage(PageResult.getPage(params), PageResult.getPageSize(params));
+        pageResult = PageHelperUtil.getPageResult(new PageInfo<>(list));*/
+        return pageResult;
     }
 }

+ 11 - 0
sckw-modules/sckw-system/src/main/java/com/sckw/system/controller/KwsEnterpriseController.java

@@ -36,6 +36,17 @@ public class KwsEnterpriseController {
         return HttpResult.ok(kwsEntService.detail(id));
     }
 
+    /**
+     * @desc 企业联系人信息
+     * @param id 企业信息
+     * @author zk
+     * @date 2023/9/1
+     **/
+    @GetMapping("/detailOpen")
+    public HttpResult detailOpen(@RequestParam Long id) {
+        return HttpResult.ok(kwsEntService.detailOpen(id));
+    }
+
     /**
      * @param pageReqVo
      * @return HttpResult

+ 18 - 0
sckw-modules/sckw-system/src/main/java/com/sckw/system/service/KwsEnterpriseService.java

@@ -731,6 +731,24 @@ public class KwsEnterpriseService {
         return entDetailResVo;
     }
 
+    /**
+     * @desc 企业联系人信息
+     * @param id 企业信息
+     * @author zk
+     * @date 2023/9/1
+     **/
+    public Map<String, Object> detailOpen(Long id) {
+        KwsEnterprise kwsEnterprise = selectByKey(id);
+        if (Objects.isNull(kwsEnterprise)) {
+            throw new SystemException(HttpStatus.QUERY_FAIL_CODE, HttpStatus.ENT_NOT_EXISTS);
+        }
+
+        Map<String, Object> ent = new HashMap<>(Global.NUMERICAL_SIXTEEN);
+        ent.put("contacts", kwsEnterprise.getContacts());
+        ent.put("phone", kwsEnterprise.getPhone());
+        return ent;
+    }
+
     /**
      * @param reqVo 入参
      * @return FindEntUserPojo