xuxiaofei пре 2 година
родитељ
комит
d92a79434a

+ 13 - 0
zd-modules/zd-airbottle/src/main/java/com/zd/airbottle/controller/DbStockController.java

@@ -117,6 +117,7 @@ public class DbStockController extends AbstractController {
     }
 
 
+
     /**
      * 更新库存信息
      *
@@ -239,4 +240,16 @@ public class DbStockController extends AbstractController {
         List<DbStock> list = dbStockService.list(queryWrapper);
         return ResultData.success(list);
     }
+
+    /***
+     *
+     * @param
+     * @return
+     */
+    @ApiOperation(value = "查询气体按名称分组")
+    @GetMapping(value = "/groupBottleName")
+    public ResultData findBySubId(DbStockBo bo) {
+        return ResultData.success(dbStockService.selectStockListGroupBy(bo));
+    }
+
 }

+ 24 - 0
zd-modules/zd-airbottle/src/main/java/com/zd/airbottle/mapper/DbInOutRecordMapper.java

@@ -2,8 +2,12 @@ package com.zd.airbottle.mapper;
 
 import com.zd.airbottle.domain.DbInOutRecord;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.zd.airbottle.domain.bo.DbInOutRecordBo;
+import com.zd.airbottle.domain.vo.DbInOutRecordVo;
 import org.apache.ibatis.annotations.Mapper;
 
+import java.util.List;
+
 /**
  * <p>
  * 出入库记录表 Mapper 接口
@@ -15,4 +19,24 @@ import org.apache.ibatis.annotations.Mapper;
 @Mapper
 public interface DbInOutRecordMapper extends BaseMapper<DbInOutRecord> {
 
+    /**
+     * 出入库数量统计
+     * @param bo
+     * @return
+     */
+    List<DbInOutRecordVo> selectInOutListCount(DbInOutRecordBo bo);
+
+    /**
+     * 用气数统计
+     * @param bo
+     * @return
+     */
+    List<DbInOutRecordVo> selectOutListCount(DbInOutRecordBo bo);
+
+    /**
+     * 用气量统计
+     * @param bo
+     * @return
+     */
+    List<DbInOutRecordVo> selectApplyListCount(DbInOutRecordBo bo);
 }

+ 16 - 0
zd-modules/zd-airbottle/src/main/java/com/zd/airbottle/mapper/DbStockMapper.java

@@ -2,8 +2,12 @@ package com.zd.airbottle.mapper;
 
 import com.zd.airbottle.domain.DbStock;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.zd.airbottle.domain.bo.DbStockBo;
+import com.zd.airbottle.domain.vo.DbStockVo;
 import org.apache.ibatis.annotations.Mapper;
 
+import java.util.List;
+
 /**
  * <p>
  * 库存表 Mapper 接口
@@ -15,4 +19,16 @@ import org.apache.ibatis.annotations.Mapper;
 @Mapper
 public interface DbStockMapper extends BaseMapper<DbStock> {
 
+    /**
+     * 气瓶库存数统计
+     * @return
+     */
+    List<DbStockVo> selectStockListGroupBy(DbStockBo bo);
+
+    /***
+     * 实验室库存统计
+     * @param bo
+     * @return
+     */
+    List<DbStockVo> selectSubjectListGroupBy(DbStockBo bo);
 }

+ 24 - 0
zd-modules/zd-airbottle/src/main/java/com/zd/airbottle/service/DbInOutRecordService.java

@@ -2,6 +2,10 @@ package com.zd.airbottle.service;
 
 import com.zd.airbottle.domain.DbInOutRecord;
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.zd.airbottle.domain.bo.DbInOutRecordBo;
+import com.zd.airbottle.domain.vo.DbInOutRecordVo;
+
+import java.util.List;
 
 /**
  * <p>
@@ -13,4 +17,24 @@ import com.baomidou.mybatisplus.extension.service.IService;
  */
 public interface DbInOutRecordService extends IService<DbInOutRecord> {
 
+    /***
+     * 按月份统计出入库数量
+     * @param bo
+     * @return
+     */
+    List<DbInOutRecordVo> selectInOutListCount(DbInOutRecordBo bo);
+
+    /**
+     * 用气数统计
+     * @param bo
+     * @return
+     */
+    List<DbInOutRecordVo> selectOutListCount(DbInOutRecordBo bo);
+
+    /**
+     * 用气量统计
+     * @param bo
+     * @return
+     */
+    List<DbInOutRecordVo> selectApplyListCount(DbInOutRecordBo bo);
 }

+ 17 - 0
zd-modules/zd-airbottle/src/main/java/com/zd/airbottle/service/DbStockService.java

@@ -2,6 +2,10 @@ package com.zd.airbottle.service;
 
 import com.zd.airbottle.domain.DbStock;
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.zd.airbottle.domain.bo.DbStockBo;
+import com.zd.airbottle.domain.vo.DbStockVo;
+
+import java.util.List;
 
 /**
  * <p>
@@ -13,4 +17,17 @@ import com.baomidou.mybatisplus.extension.service.IService;
  */
 public interface DbStockService extends IService<DbStock> {
 
+    /**
+     * 气瓶库存数统计
+     * @return
+     */
+    List<DbStockVo> selectStockListGroupBy(DbStockBo bo);
+
+    /***
+     * 实验室库存统计
+     * @param bo
+     * @return
+     */
+    List<DbStockVo> selectSubjectListGroupBy(DbStockBo bo);
+
 }

+ 39 - 0
zd-modules/zd-airbottle/src/main/java/com/zd/airbottle/service/impl/DbInOutRecordServiceImpl.java

@@ -1,11 +1,16 @@
 package com.zd.airbottle.service.impl;
 
 import com.zd.airbottle.domain.DbInOutRecord;
+import com.zd.airbottle.domain.bo.DbInOutRecordBo;
+import com.zd.airbottle.domain.vo.DbInOutRecordVo;
 import com.zd.airbottle.mapper.DbInOutRecordMapper;
 import com.zd.airbottle.service.DbInOutRecordService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.util.List;
+
 /**
  * <p>
  * 出入库记录表 服务实现类
@@ -17,4 +22,38 @@ import org.springframework.stereotype.Service;
 @Service
 public class DbInOutRecordServiceImpl extends ServiceImpl<DbInOutRecordMapper, DbInOutRecord> implements DbInOutRecordService {
 
+    @Autowired
+    private DbInOutRecordMapper dbInOutRecordMapper;
+
+    /***
+     * 按月份统计出入库数量
+     * @param bo
+     * @return
+     */
+    @Override
+    public List<DbInOutRecordVo> selectInOutListCount(DbInOutRecordBo bo) {
+        return dbInOutRecordMapper.selectInOutListCount(bo);
+    }
+
+    /**
+     * 用气数统计
+     *
+     * @param bo
+     * @return
+     */
+    @Override
+    public List<DbInOutRecordVo> selectOutListCount(DbInOutRecordBo bo) {
+        return dbInOutRecordMapper.selectOutListCount(bo);
+    }
+
+    /**
+     * 用气量统计
+     *
+     * @param bo
+     * @return
+     */
+    @Override
+    public List<DbInOutRecordVo> selectApplyListCount(DbInOutRecordBo bo) {
+        return dbInOutRecordMapper.selectApplyListCount(bo);
+    }
 }

+ 28 - 0
zd-modules/zd-airbottle/src/main/java/com/zd/airbottle/service/impl/DbStockServiceImpl.java

@@ -1,11 +1,16 @@
 package com.zd.airbottle.service.impl;
 
 import com.zd.airbottle.domain.DbStock;
+import com.zd.airbottle.domain.bo.DbStockBo;
+import com.zd.airbottle.domain.vo.DbStockVo;
 import com.zd.airbottle.mapper.DbStockMapper;
 import com.zd.airbottle.service.DbStockService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.util.List;
+
 /**
  * <p>
  * 库存表 服务实现类
@@ -17,4 +22,27 @@ import org.springframework.stereotype.Service;
 @Service
 public class DbStockServiceImpl extends ServiceImpl<DbStockMapper, DbStock> implements DbStockService {
 
+    @Autowired
+    private DbStockMapper dbStockMapper;
+
+    /**
+     * 气瓶库存数统计
+     *
+     * @param bo
+     * @return
+     */
+    @Override
+    public List<DbStockVo> selectStockListGroupBy(DbStockBo bo) {
+        return dbStockMapper.selectStockListGroupBy(bo);
+    }
+
+    /***
+     * 实验室库存统计
+     * @param bo
+     * @return
+     */
+    @Override
+    public List<DbStockVo> selectSubjectListGroupBy(DbStockBo bo) {
+        return dbStockMapper.selectSubjectListGroupBy(bo);
+    }
 }

+ 146 - 1
zd-modules/zd-airbottle/src/main/resources/mapper/airbottle/DbInOutRecordMapper.xml

@@ -32,7 +32,152 @@
 
     <!-- 通用查询结果列 -->
     <sql id="Base_Column_List">
-        id, type, gas_name, level, size, bottle_code, gas_composition, college_id, college_name, subject_id, subject_name, room_num, beacon_tag, operator_id, operator, phone, valid_period, gas_pressure, create_name, create_by, create_time, update_name, update_by, update_time, remark
+        id
+        , type, gas_name, level, size, bottle_code, gas_composition, college_id, college_name, subject_id, subject_name, room_num, beacon_tag, operator_id, operator, phone, valid_period, gas_pressure, create_name, create_by, create_time, update_name, update_by, update_time, remark
     </sql>
 
+    <select id="selectInOutListCount" parameterType="com.zd.airbottle.domain.bo.DbInOutRecordBo"
+            resultType="com.zd.airbottle.domain.vo.DbInOutRecordVo">
+        select x1.yearMonth,
+        CASE
+        WHEN substring(x1.yearMonth, 6) >= 10 THEN concat(SUBSTRING(x1.yearMonth, 6, 7), '月')
+        ELSE concat(substring(x1.yearMonth, 6), '月') END recordMonth,
+        IFNULL(sum(x2.count), 0) totalNum
+        from (
+        SELECT CONCAT((SELECT YEAR (NOW())),'-01') yearMonth
+        FROM DUAL
+        UNION ALL
+        SELECT CONCAT((SELECT YEAR (NOW())),'-02') yearMonth
+        FROM DUAL
+        UNION ALL
+        SELECT CONCAT((SELECT YEAR (NOW())),'-03') yearMonth
+        FROM DUAL
+        UNION ALL
+        SELECT CONCAT((SELECT YEAR (NOW())),'-04') yearMonth
+        FROM DUAL
+        UNION ALL
+        SELECT CONCAT((SELECT YEAR (NOW())),'-05') yearMonth
+        FROM DUAL
+        UNION ALL
+        SELECT CONCAT((SELECT YEAR (NOW())),'-06') yearMonth
+        FROM DUAL
+        UNION ALL
+        SELECT CONCAT((SELECT YEAR (NOW())),'-07') yearMonth
+        FROM DUAL
+        UNION ALL
+        SELECT CONCAT((SELECT YEAR (NOW())),'-08') yearMonth
+        FROM DUAL
+        UNION ALL
+        SELECT CONCAT((SELECT YEAR (NOW())),'-09') yearMonth
+        FROM DUAL
+        UNION ALL
+        SELECT CONCAT((SELECT YEAR (NOW())),'-10') yearMonth
+        FROM DUAL
+        UNION ALL
+        SELECT CONCAT((SELECT YEAR (NOW())),'-11') yearMonth
+        FROM DUAL
+        UNION ALL
+        SELECT CONCAT((SELECT YEAR (NOW())),'-12') yearMonth
+        FROM DUAL
+        ) x1
+        left join (
+        select DATE_FORMAT(a.create_time, '%Y-%m') yearMonth, a.type, count(1) count
+        from db_in_out_record a
+        where a.type=#{type}
+        <if test="gasName!=null and gasName!=''">
+            and a.gas_name=#{gasName}
+        </if>
+        GROUP BY DATE_FORMAT(a.create_time, '%Y-%m'), a.type
+        ) x2 on x1.yearMonth = x2.yearMonth
+        group by x1.yearMonth
+        order by x1.yearMonth
+    </select>
+
+    <select id="selectOutListCount" parameterType="com.zd.airbottle.domain.bo.DbInOutRecordBo"
+            resultType="com.zd.airbottle.domain.vo.DbInOutRecordVo">
+        select x1.yearMonth,
+               CASE
+                   WHEN substring(x1.yearMonth, 6) >= 10 THEN concat(SUBSTRING(x1.yearMonth, 6, 7), '月')
+                   ELSE concat(substring(x1.yearMonth, 6), '月') END recordMonth,
+               IFNULL(sum(x2.count), 0)                             totalNum
+        from (
+                 select date_format(curdate(), '%Y-%m') AS `yearMonth`
+                 union
+                 select date_format((curdate() - interval 1 month), '%Y-%m') AS `yearMonth`
+                 union
+                 select date_format((curdate() - interval 2 month), '%Y-%m') AS `yearMonth`
+                 union
+                 select date_format((curdate() - interval 3 month), '%Y-%m') AS `yearMonth`
+                 union
+                 select date_format((curdate() - interval 4 month), '%Y-%m') AS `yearMonth`
+                 union
+                 select date_format((curdate() - interval 5 month), '%Y-%m') AS `yearMonth`
+                 union
+                 select date_format((curdate() - interval 6 month), '%Y-%m') AS `yearMonth`
+                 union
+                 select date_format((curdate() - interval 7 month), '%Y-%m') AS `yearMonth`
+                 union
+                 select date_format((curdate() - interval 8 month), '%Y-%m') AS `yearMonth`
+                 union
+                 select date_format((curdate() - interval 9 month), '%Y-%m') AS `yearMonth`
+                 union
+                 select date_format((curdate() - interval 10 month), '%Y-%m') AS `yearMonth`
+                 union
+                 select date_format((curdate() - interval 11 month), '%Y-%m') AS `yearMonth`) x1
+                 left join (
+            select DATE_FORMAT(a.create_time, '%Y-%m') yearMonth, a.type, count(1) count
+            from db_in_out_record a
+            where a.type=2
+        <if test="gasName!=null and gasName!=''">
+            and a.gas_name=#{gasName}
+        </if>
+            GROUP BY DATE_FORMAT(a.create_time, '%Y-%m'), a.type
+        ) x2 on x1.yearMonth = x2.yearMonth
+        group by x1.yearMonth
+        order by x1.yearMonth
+    </select>
+
+    <select id="selectApplyListCount" parameterType="com.zd.airbottle.domain.bo.DbInOutRecordBo"
+            resultType="com.zd.airbottle.domain.vo.DbInOutRecordVo">
+        select x1.yearMonth,
+        CASE
+        WHEN substring(x1.yearMonth, 6) >= 10 THEN concat(SUBSTRING(x1.yearMonth, 6, 7), '月')
+        ELSE concat(substring(x1.yearMonth, 6), '月') END recordMonth,
+        IFNULL(sum(x2.count), 0)                             totalNum
+        from (
+        select date_format(curdate(), '%Y-%m') AS `yearMonth`
+        union
+        select date_format((curdate() - interval 1 month), '%Y-%m') AS `yearMonth`
+        union
+        select date_format((curdate() - interval 2 month), '%Y-%m') AS `yearMonth`
+        union
+        select date_format((curdate() - interval 3 month), '%Y-%m') AS `yearMonth`
+        union
+        select date_format((curdate() - interval 4 month), '%Y-%m') AS `yearMonth`
+        union
+        select date_format((curdate() - interval 5 month), '%Y-%m') AS `yearMonth`
+        union
+        select date_format((curdate() - interval 6 month), '%Y-%m') AS `yearMonth`
+        union
+        select date_format((curdate() - interval 7 month), '%Y-%m') AS `yearMonth`
+        union
+        select date_format((curdate() - interval 8 month), '%Y-%m') AS `yearMonth`
+        union
+        select date_format((curdate() - interval 9 month), '%Y-%m') AS `yearMonth`
+        union
+        select date_format((curdate() - interval 10 month), '%Y-%m') AS `yearMonth`
+        union
+        select date_format((curdate() - interval 11 month), '%Y-%m') AS `yearMonth`) x1
+        left join (
+        select DATE_FORMAT(a.create_time,'%Y-%m') yearMonth ,sum(a.usage_amount)   count from db_usage_record a
+        <where>
+        <if test="gasName!=null and gasName!=''">
+            and a.gas_name=#{gasName}
+        </if>
+        </where>
+        GROUP BY DATE_FORMAT(a.create_time, '%Y-%m')
+        ) x2 on x1.yearMonth = x2.yearMonth
+        group by x1.yearMonth
+        order by x1.yearMonth
+    </select>
 </mapper>

+ 25 - 1
zd-modules/zd-airbottle/src/main/resources/mapper/airbottle/DbStockMapper.xml

@@ -33,7 +33,31 @@
 
     <!-- 通用查询结果列 -->
     <sql id="Base_Column_List">
-        id, bottle_code, gas_name, level, size, bottle_colour, handwheel, fixed, status_label, electronic_tag, gas_pressure, valid_period, beacon_tag, college_id, college_name, subject_id, subject_name, room_num, create_name, create_by, create_time, update_name, update_by, update_time, remark
+        id
+        , bottle_code, gas_name, level, size, bottle_colour, handwheel, fixed, status_label, electronic_tag, gas_pressure, valid_period, beacon_tag, college_id, college_name, subject_id, subject_name, room_num, create_name, create_by, create_time, update_name, update_by, update_time, remark
     </sql>
 
+    <select id="selectStockListGroupBy" parameterType="com.zd.airbottle.domain.bo.DbStockBo"
+            resultType="com.zd.airbottle.domain.vo.DbStockVo">
+        select s.id,s.gas_name, count(1) totalNum
+        from db_stock s
+        GROUP BY s.gas_name
+    </select>
+
+    <select id="selectSubjectListGroupBy" parameterType="com.zd.airbottle.domain.bo.DbStockBo"
+            resultType="com.zd.airbottle.domain.vo.DbStockVo">
+        select s.subject_name,
+               s.room_num,
+               cl.type_name subjectType,
+               f.classified_name subjectLevel,
+               count(1) totalNum
+        from db_stock s
+                 LEFT JOIN lab_subject su on s.subject_id = su.id
+                 LEFT JOIN lab_safe_classtype cl on cl.id = su.type_id
+                 LEFT JOIN lab_safe_classified f on f.id = su.level
+        GROUP BY s.subject_id
+        ORDER BY totalNum desc
+    </select>
+
+
 </mapper>