Quellcode durchsuchen

新增BI大屏摄像头接口、协议提醒

Sun vor 3 Jahren
Ursprung
Commit
ce9c69abc8

+ 3 - 3
ruoyi-admin/src/main/java/com/ruoyi/web/controller/warehouse/agreement/TWarehouseAgreementController.java

@@ -27,10 +27,10 @@ public class TWarehouseAgreementController extends BaseController {
     /**
      * 查询协议提醒列表
      */
-    @GetMapping("/list")
-    public TableDataInfo list(TWarehouseAgreement tWarehouseAgreement) {
+    @GetMapping("/remindList")
+    public TableDataInfo remindList(TWarehouseAgreement tWarehouseAgreement) {
         startPage();
-        List<Map<String, Object>> list = tWarehouseAgreementService.selectTWarehouseAgreementList1(tWarehouseAgreement);
+        List<Map<String, Object>> list = tWarehouseAgreementService.agreementRemind(tWarehouseAgreement);
         return getDataTable(list);
     }
 

+ 8 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/controller/warehouse/basicData/TWarehouseWebcamController.java

@@ -64,6 +64,14 @@ public class TWarehouseWebcamController extends BaseController {
     }
 
     /**
+     * 获取摄像头流地址
+     */
+    @GetMapping("/getWebcamUrlList")
+    public AjaxResult getWebcamUrlList(Long fWarehouseId) {
+        return AjaxResult.success(tWarehouseWebcamService.getWebcamUrlList(fWarehouseId));
+    }
+
+    /**
      * 批量修改仓库摄像头
      */
     @Log(title = "仓库摄像头", businessType = BusinessType.UPDATE)

+ 0 - 1
ruoyi-admin/src/main/java/com/ruoyi/web/controller/warehouse/reportManagement/TWhgenlegController.java

@@ -37,7 +37,6 @@ public class TWhgenlegController extends BaseController {
     /**
      * 出库、调拨、货转查询库存总账列表
      */
-    @DataScope(deptAlias = "d", userAlias = "u")
     @GetMapping("/list")
     public TableDataInfo list(TWhgenleg tWhgenleg) {
         startPage();

+ 2 - 2
ruoyi-warehouse/src/main/java/com/ruoyi/basicData/mapper/TWarehouseWebcamMapper.java

@@ -72,8 +72,8 @@ public interface TWarehouseWebcamMapper {
      * APP查询仓库摄像头列表
      *
      * @param fWarehouseId 仓库ID
-     * @param corpId 客户ID
+     * @param external 客户名
      * @return 仓库摄像头集合
      */
-    public List<TWarehouseWebcam> selectAppTWarehouseWebcamList(@Param("fWarehouseId") Long fWarehouseId, @Param("corpId") Long corpId);
+    public List<TWarehouseWebcam> selectAppTWarehouseWebcamList(@Param("fWarehouseId") Long fWarehouseId, @Param("external") String external);
 }

+ 9 - 0
ruoyi-warehouse/src/main/java/com/ruoyi/basicData/service/ITWarehouseWebcamService.java

@@ -1,6 +1,7 @@
 package com.ruoyi.basicData.service;
 
 import java.util.List;
+import java.util.Map;
 
 import com.ruoyi.basicData.domain.TWarehouseWebcam;
 import com.ruoyi.common.core.domain.AjaxResult;
@@ -83,4 +84,12 @@ public interface ITWarehouseWebcamService {
      * @return 结果
      */
     public int deleteTWarehouseWebcamById(Long fId);
+
+    /**
+     * 获取摄像头流地址
+     *
+     * @param fWarehouseId 仓库ID
+     * @return 摄像头流地址集合
+     */
+    public List<Map<String, Object>> getWebcamUrlList(Long fWarehouseId);
 }

+ 104 - 17
ruoyi-warehouse/src/main/java/com/ruoyi/basicData/service/impl/TWarehouseWebcamServiceImpl.java

@@ -1,22 +1,28 @@
 package com.ruoyi.basicData.service.impl;
 
-import java.util.List;
-
-import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
-import com.ruoyi.basicData.domain.TCustomerContact;
-import com.ruoyi.basicData.mapper.TCustomerContactMapper;
+import cn.hutool.http.HttpRequest;
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import com.ruoyi.basicData.domain.TWarehouseWebcam;
+import com.ruoyi.basicData.mapper.TWarehouseWebcamMapper;
+import com.ruoyi.basicData.service.ITWarehouseWebcamService;
 import com.ruoyi.common.core.domain.AjaxResult;
 import com.ruoyi.common.core.domain.entity.SysUser;
+import com.ruoyi.common.exception.BaseException;
 import com.ruoyi.common.utils.DateUtils;
 import com.ruoyi.common.utils.SecurityUtils;
 import com.ruoyi.common.utils.StringUtils;
+import com.ruoyi.system.domain.SysConfig;
+import com.ruoyi.system.mapper.SysConfigMapper;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
-import com.ruoyi.basicData.mapper.TWarehouseWebcamMapper;
-import com.ruoyi.basicData.domain.TWarehouseWebcam;
-import com.ruoyi.basicData.service.ITWarehouseWebcamService;
 import org.springframework.transaction.annotation.Transactional;
 
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
 /**
  * 仓库摄像头Service业务层处理
  *
@@ -29,7 +35,7 @@ public class TWarehouseWebcamServiceImpl implements ITWarehouseWebcamService {
     private TWarehouseWebcamMapper tWarehouseWebcamMapper;
 
     @Autowired
-    private TCustomerContactMapper customerContactMapper;
+    private SysConfigMapper sysConfigMapper;
 
     /**
      * 查询仓库摄像头
@@ -76,18 +82,13 @@ public class TWarehouseWebcamServiceImpl implements ITWarehouseWebcamService {
             return tWarehouseWebcamMapper.selectAppTWarehouseWebcamList(tWarehouseWebcam.getfWarehouseId(), null);
         }
 
-        TCustomerContact customerContact = new TCustomerContact();
+        String external = null;
         SysUser user = SecurityUtils.getLoginUser().getUser();
-        Long corpId = null;
         if ("外部用户".equals(user.getDept().getDeptName())) {
-            customerContact.setfTel(SecurityUtils.getLoginUser().getUser().getUserName());
-            List<TCustomerContact> tCustomerContacts = customerContactMapper.selectTCustomerContactList(customerContact);
-            if (CollectionUtils.isNotEmpty(tCustomerContacts)) {
-                corpId = tCustomerContacts.get(0).getfPid();
-            }
+            external = user.getUserName();
         }
 
-        return tWarehouseWebcamMapper.selectAppTWarehouseWebcamList(null, corpId);
+        return tWarehouseWebcamMapper.selectAppTWarehouseWebcamList(null, external);
     }
 
     /**
@@ -153,4 +154,90 @@ public class TWarehouseWebcamServiceImpl implements ITWarehouseWebcamService {
     public int deleteTWarehouseWebcamById(Long fId) {
         return tWarehouseWebcamMapper.deleteTWarehouseWebcamById(fId);
     }
+
+    /**
+     * 获取摄像头流地址
+     *
+     * @param warehouseId 仓库ID
+     * @return 摄像头流地址集合
+     */
+    @Override
+    public List<Map<String, Object>> getWebcamUrlList(Long fWarehouseId) {
+        String external = null;
+        SysUser user = SecurityUtils.getLoginUser().getUser();
+        if ("外部用户".equals(user.getDept().getDeptName())) {
+            external = user.getUserName();
+        }
+
+        List<Map<String, Object>> data = new ArrayList<>();
+        Map<String, Object> temp;
+
+        List<TWarehouseWebcam> tWarehouseWebcams = tWarehouseWebcamMapper.selectAppTWarehouseWebcamList(fWarehouseId, external);
+        if (tWarehouseWebcams.size() > 0) {
+            // 获取摄像头token
+            String token = getToken();
+            for (TWarehouseWebcam tWarehouseWebcam : tWarehouseWebcams) {
+                String projectId = tWarehouseWebcam.getProjectId();
+                String deviceSerial = tWarehouseWebcam.getDeviceSerial();
+                String streamUrl = getWebcamUrl(token, projectId, deviceSerial);
+                temp = new HashMap<>();
+                temp.put("warehouseName", tWarehouseWebcam.getfWarehouseName());
+                temp.put("deviceName", tWarehouseWebcam.getDeviceName());
+                temp.put("streamUrl", streamUrl);
+                data.add(temp);
+            }
+        }
+        return data;
+    }
+
+    private String getConfigValue(String key) {
+        SysConfig sysConfig = sysConfigMapper.checkConfigKeyUnique(key);
+        if (StringUtils.isNull(sysConfig)) {
+            throw new BaseException("系统参数异常,未找到" + key + "参数");
+        }
+        return sysConfig.getConfigValue();
+    }
+
+    private String getToken() {
+        // 从参数里获取请求地址、参数
+        String tokenUrl = getConfigValue("warehouse.webcam.tokenUrl");
+
+        JSONObject values = new JSONObject();
+        values.put("accessKey", getConfigValue("warehouse.webcam.accessKey"));
+        values.put("secretKey", getConfigValue("warehouse.webcam.secretKey"));
+        values.put("productCode", getConfigValue("warehouse.webcam.productCode"));
+
+        String response = HttpRequest.post(tokenUrl)
+                .body(values.toString())
+                .execute().body();
+        JSONObject json = JSON.parseObject(response);
+        if ("200".equals(json.getString("code"))) {
+            throw new BaseException(json.getString("msg"));
+        }
+        JSONObject data = JSON.parseObject(json.getString("data"));
+        return data.getString("access_token");
+    }
+
+    private String getWebcamUrl(String token, String projectId, String deviceSerial) {
+        // 从参数里获取请求地址、参数
+        String streamUrl = getConfigValue("warehouse.webcam.streamUrl");
+
+        JSONObject values = new JSONObject();
+        values.put("projectId", projectId);
+        values.put("deviceSerial", deviceSerial);
+        values.put("protocol", 3);
+        values.put("supportH265", 1);
+
+        String response = HttpRequest.post(streamUrl)
+                .header("access_token", token)
+                .body(values.toString())
+                .execute().body();
+        JSONObject json = JSON.parseObject(response);
+        if ("200".equals(json.getString("code"))) {
+            throw new BaseException(json.getString("msg"));
+        }
+        JSONObject data = JSON.parseObject(json.getString("data"));
+        return data.getString("url");
+    }
+
 }

+ 13 - 0
ruoyi-warehouse/src/main/java/com/ruoyi/warehouseBusiness/domain/TWarehouseAgreement.java

@@ -143,6 +143,11 @@ public class TWarehouseAgreement extends BaseEntity {
     @Excel(name = "仓库")
     private String fWarehouseid;
 
+    /**
+     * 提醒天数
+     */
+    private Long remindDays;
+
     public String getfWarehouseid() {
         return fWarehouseid;
     }
@@ -311,6 +316,14 @@ public class TWarehouseAgreement extends BaseEntity {
         this.fDc = fDc;
     }
 
+    public Long getRemindDays() {
+        return remindDays;
+    }
+
+    public void setRemindDays(Long remindDays) {
+        this.remindDays = remindDays;
+    }
+
     @Override
     public String toString() {
         return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)

+ 3 - 2
ruoyi-warehouse/src/main/java/com/ruoyi/warehouseBusiness/service/impl/TWarehouseAgreementServiceImpl.java

@@ -687,11 +687,12 @@ public class TWarehouseAgreementServiceImpl implements ITWarehouseAgreementServi
     @Override
     public List<Map<String, Object>> agreementRemind(TWarehouseAgreement tWarehouseAgreement) {
         // 从参数里获取通知时间
-        SysConfig sysConfig = sysConfigMapper.checkConfigKeyUnique("data_print_title");
+        SysConfig sysConfig = sysConfigMapper.checkConfigKeyUnique("agreement.remind");
         if (StringUtils.isNull(sysConfig)) {
             throw new BaseException("系统参数异常,未找到协议到期提醒时间");
         }
-        String days = sysConfig.getConfigValue();
+        Long remindDays = Long.parseLong(sysConfig.getConfigValue());
+        tWarehouseAgreement.setRemindDays(remindDays);
         return tWarehouseAgreementMapper.agreementRemind(tWarehouseAgreement);
     }
 

+ 5 - 4
ruoyi-warehouse/src/main/resources/mapper/basicData/TWarehouseWebcamMapper.xml

@@ -136,10 +136,11 @@
         <include refid="selectTWarehouseWebcamVo"/>
         <where>
             <if test="fWarehouseId != null ">and f_warehouse_id = #{fWarehouseId}</if>
-            <if test="corpId != null">
-                and f_warehouse_id in (select f_id from t_warehouse where parent_id = 100 and f_id in (
-                    select distinct f_warehouseid from t_whgenleg where f_corpid = #{corpId})
-                )
+            <if test="external != null and external != ''">
+                and f_warehouse_id in (
+                    select distinct f_warehouseid
+                    from t_customer_contact t1 left join t_whgenleg t2 on t1.f_pid = t2.f_corpid
+                    where f_tel = #{external})
             </if>
         </where>
     </select>

+ 20 - 26
ruoyi-warehouse/src/main/resources/mapper/reportManagement/TWhgenlegMapper.xml

@@ -744,7 +744,6 @@
                 and ware.ancestors  LIKE  concat('%', #{fWarehouseLocationid}, '%')
             </if>
         </where>
-        ${params.dataScope}
     </select>
 
     <select id="selectInventoryMapList" parameterType="TWhgenleg" resultType="Map">
@@ -754,7 +753,8 @@
             leg.f_corpid AS fCorpIds,
             corp.f_name AS fCorpid,
             leg.f_shipper AS fShipper,
-            ware.f_warehouse_information AS fWarehouseids,
+            <if test="isCntrno != null and isCntrno != 2 ">ware.f_warehouse_information AS fWarehouseids,</if>
+            <if test="isCntrno != null and isCntrno == 2 ">ware.f_name AS fWarehouseids,</if>
             area.f_name AS fWarehouseLocationids,
             leg.f_originalbillno AS fOriginalbillno,
             leg.f_warehouse_locationid AS fWarehouseLocationid,
@@ -793,7 +793,8 @@
             LEFT JOIN t_corps corp ON corp.f_id = leg.f_corpid
             LEFT JOIN t_customer_contact tc ON tc.f_pid = corp.f_id
             LEFT JOIN t_goods goods ON goods.f_id = leg.f_goodsid
-            LEFT JOIN t_warehouse ware ON ware.f_id = leg.f_warehouse_locationid
+            <if test="isCntrno != null and isCntrno != 2 ">LEFT JOIN t_warehouse ware ON ware.f_id = leg.f_warehouse_locationid</if>
+            <if test="isCntrno != null and isCntrno == 2 ">LEFT JOIN t_warehouse ware ON ware.f_id = leg.f_warehouseid</if>
             LEFT JOIN sys_dict_data dict ON dict.dict_value = leg.f_business_type
             LEFT JOIN t_warehouse_area area ON area.f_id = leg.f_warehouse_locationid
             LEFT JOIN sys_dict_data dict1 ON dict1.dict_value = leg.f_trademodeid
@@ -801,6 +802,11 @@
             dict.status = '0'
             AND dict1.status = '0'
             AND leg.f_qtyD != 0
+            <if test="isMblno != null and isMblno == 0 ">
+                AND leg.f_qtyblc != 0
+                AND leg.f_grossweightblc != 0
+                AND leg.f_netweightblc != 0
+            </if>
             AND dict.dict_type = 'storage_type'
             AND dict1.dict_type = 'data_trademodes'
             <if test="fOriginalbillno != null  and fOriginalbillno != ''">and leg.f_originalbillno = #{fOriginalbillno}</if>
@@ -809,12 +815,8 @@
             <if test="fCorpid != null ">and leg.f_corpid = #{fCorpid}</if>
             <if test="fShipper != null and fShipper != ''">and leg.f_shipper like concat('%', #{fShipper}, '%')</if>
             <if test="fMblno != null ">and leg.f_mblno LIKE  concat('%', #{fMblno}, '%') </if>
-            <if test='orgStorageDate != null and orgStorageDate[0] != null and orgStorageDate[0]!= ""'>
-                and leg.f_originalbilldate &gt;= #{orgStorageDate[0]}
-            </if>
-            <if test='orgStorageDate != null and orgStorageDate[1] != null and orgStorageDate[1]!= ""'>
-                and leg.f_originalbilldate &lt;= #{orgStorageDate[1]}
-            </if>
+            <if test='orgStorageDate != null and orgStorageDate[0] != null and orgStorageDate[0]!= ""'>and leg.f_originalbilldate &gt;= #{orgStorageDate[0]}</if>
+            <if test='orgStorageDate != null and orgStorageDate[1] != null and orgStorageDate[1]!= ""'>and leg.f_originalbilldate &lt;= #{orgStorageDate[1]}</if>
             <if test="fPregrossweight != null ">and leg.f_pregrossweight = #{fPregrossweight}</if>
             <if test="fPrenetweight != null ">and leg.f_prenetweight = #{fPrenetweight}</if>
             <if test="fQtyd != null ">and leg.f_qtyD = #{fQtyd}</if>
@@ -834,25 +836,17 @@
             <if test="fNetweightblc != null ">and leg.f_netweightblc = #{fNetweightblc}</if>
             <if test="fStatus != null  and fStatus != ''">and leg.f_status = #{fStatus}</if>
             <if test="fWarehouseid != null ">and leg.f_warehouseid = #{fWarehouseid} </if>
-            <if test="fLocation != null and fLocation ==1 ">
-                and leg.f_warehouse_locationid = #{fWarehouseLocationid}
-            </if>
-            <if test="fCntrno != null  and fCntrno != ''">
-                and leg.f_cntrno  LIKE  concat('%', #{fCntrno}, '%')
-            </if>
-            <if test="fLocalcntrno != null  and fLocalcntrno != ''">
-                and leg.f_localcntrno  LIKE  concat('%', #{fLocalcntrno}, '%')
-            </if>
-            <if test="fLocation != null  and fLocation ==0 ">
-                and ware.ancestors  LIKE  concat('%', #{fWarehouseLocationid}, '%')
+            <if test="fLocation != null and fLocation ==1 ">and leg.f_warehouse_locationid = #{fWarehouseLocationid}</if>
+            <if test="fCntrno != null  and fCntrno != ''">and leg.f_cntrno  LIKE  concat('%', #{fCntrno}, '%')</if>
+            <if test="fLocalcntrno != null  and fLocalcntrno != ''">and leg.f_localcntrno  LIKE  concat('%', #{fLocalcntrno}, '%')</if>
+            <if test="fLocation != null  and fLocation ==0 ">and ware.ancestors  LIKE  concat('%', #{fWarehouseLocationid}, '%')</if>
+            <if test="isCntrno == null">
+                GROUP BY leg.f_corpid, leg.f_originalbillno, leg.f_originalbilldate, leg.f_warehouse_locationid, leg.f_goodsid, leg.f_trademodeid
             </if>
-            GROUP BY leg.f_corpid,leg.f_originalbillno, leg.f_originalbilldate, leg.f_warehouse_locationid, leg.f_goodsid, leg.f_trademodeid
-            <if test="isCntrno != null and isCntrno == 0 ">
-                ,leg.f_cntrno
-            </if>
-            <if test="isMblno != null and isMblno == 0 ">
-                ,leg.f_mblno
+            <if test="isCntrno != null and isCntrno == 1 ">
+                GROUP BY leg.f_corpid, leg.f_originalbillno, leg.f_originalbilldate, leg.f_warehouse_locationid, leg.f_goodsid, leg.f_trademodeid,leg.f_cntrno
             </if>
+            <if test="isCntrno != null and isCntrno == 2 ">GROUP BY leg.f_corpid, leg.f_mblno, leg.f_goodsid, leg.f_warehouseid</if>
         </where>
         ${params.dataScope}
         order by leg.f_bsdate desc

+ 1 - 4
ruoyi-warehouse/src/main/resources/mapper/warehouseBusiness/TWarehouseAgreementMapper.xml

@@ -265,10 +265,7 @@
         left join t_corps corp on corp.f_id = agre.f_corpid
         where
             agre.f_status = '0'
-            and datediff(date_format(agre.f_enddate, '%Y-%m-%d'), date_format(now(), '%Y-%m-%d')) &lt;= 60
-            <if test="value != null  and value != ''">
-                and datediff(date_format(agre.f_enddate, '%Y-%m-%d'), date_format(now(), '%Y-%m-%d')) &lt;= #{value}
-            </if>
+            and datediff(date_format(agre.f_enddate, '%Y-%m-%d'), date_format(now(), '%Y-%m-%d')) &lt;= #{remindDays}
             <if test="fCorpid != null ">and agre.f_corpid = #{fCorpid}</if>
             <if test="fContractno != null  and fContractno != ''">and agre.f_contractno = #{fContractno}</if>
             <if test="fBegindate != null ">and agre.f_begindate = #{fBegindate}</if>

+ 2 - 1
ruoyi-warehouse/src/main/resources/mapper/warehouseBusiness/TWarehousebillsMapper.xml

@@ -652,8 +652,9 @@
         wi.f_qty AS fQtyD,
         wi.f_grossweight AS fGrossweightD
         FROM t_warehousebillsitems wi
+        LEFT JOIN t_warehousebills w ON wi.f_pid =  w.f_id
         LEFT JOIN t_goods tg ON wi.f_goodsid = tg.f_id
-        LEFT JOIN sys_dict_data dict ON wi.f_business_type = dict.dict_value
+        LEFT JOIN sys_dict_data dict ON w.f_business_type = dict.dict_value
         WHERE
             wi.f_billstatus = 40
             AND dict.status = 0

+ 1 - 1
ruoyi-warehouse/src/main/resources/mapper/warehouseBusiness/TWarehousebillsitemsMapper.xml

@@ -996,7 +996,7 @@
     <select id="biInAndOutStockList" resultType="map">
         select
             ifnull(tc.f_cname, tc.f_name) as customerName,
-            ifnull(ifnull(tb.f_shipper, tc.f_cname), tc.f_name)  as shipper,
+            ifnull(ifnull(ts.f_shipper, tc.f_cname), tc.f_name) as shipper,
             ts.f_warehouse_information as warehouseName,
             tg.f_name as goodsName,
             concat(ts.f_qty, '/',