gongchunyi
10 小时以前 11bc2a4737a526b803959dfdd7c522b056425fe2
fix: 日期判空操作,默认赋值当天日期
已修改2个文件
83 ■■■■ 文件已修改
src/main/java/com/ruoyi/production/service/impl/ProductionProductMainServiceImpl.java 15 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/production/ProductionProductMainMapper.xml 68 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/production/service/impl/ProductionProductMainServiceImpl.java
@@ -342,7 +342,18 @@
    }
    @Override
    public IPage<HashMap<String, Object>> queryProductInputAndOutput(Page page, ProductionProductMainDto productionProductMainDto) {
        return productionProductMainMapper.queryProductInputAndOutput(page, productionProductMainDto);
    public IPage<HashMap<String, Object>> queryProductInputAndOutput(Page page, ProductionProductMainDto dto) {
        if (isEmptyDate(dto.getStartTime())) {
            dto.setStartTime(LocalDate.now().toString());
        }
        if (isEmptyDate(dto.getEndTime())) {
            dto.setEndTime(LocalDate.now().plusDays(1).toString());
        }
        return productionProductMainMapper.queryProductInputAndOutput(page, dto);
    }
    private boolean isEmptyDate(String date) {
        return date == null || date.trim().isEmpty() || "Invalid Date".equals(date);
    }
}
src/main/resources/mapper/production/ProductionProductMainMapper.xml
@@ -121,27 +121,51 @@
    <select id="queryProductInputAndOutput" resultType="Hashmap">
        select *
        from (select p.product_name      as productName,
                     pm.model            as model,
                     pm.unit             as unit,
                     temp.inputQuantity  as inputQuantity,
                     temp.outputQuantity as outputQuantity
              from (select product_model_id,
                           coalesce(sum(inputQuantity), 0)  as inputQuantity,
                           coalesce(sum(outputQuantity), 0) as outputQuantity
                    from ((select product_model_id, coalesce(sum(quantity), 0) as inputQuantity, 0 as outputQuantity
                           from production_product_input
                           where create_time &gt;= #{ew.startTime}
                             and create_time &lt; #{ew.endTime}
                           group by product_model_id)
                          union all
                          (select product_model_id, 0 as inputQuantity, coalesce(sum(quantity), 0) as outputQuantity
                           from production_product_output
                           where create_time &gt;= #{ew.startTime}
                             and create_time &lt; #{ew.endTime}
                           group by product_model_id)) t
                    group by product_model_id) temp
                       left join product_model pm on temp.product_model_id = pm.id
                       left join product p on pm.product_id = p.id) tmp
        from (
        select p.product_name as productName,
        pm.model as model,
        pm.unit as unit,
        temp.inputQuantity as inputQuantity,
        temp.outputQuantity as outputQuantity
        from (
        select product_model_id,
        coalesce(sum(inputQuantity),0) as inputQuantity,
        coalesce(sum(outputQuantity),0) as outputQuantity
        from (
        (select product_model_id,
        coalesce(sum(quantity),0) as inputQuantity,
        0 as outputQuantity
        from production_product_input
        <where>
            <if test="ew.startTime != null and ew.startTime != ''">
                and create_time &gt;= #{ew.startTime}
            </if>
            <if test="ew.endTime != null and ew.endTime != ''">
                and create_time &lt; #{ew.endTime}
            </if>
        </where>
        group by product_model_id)
        union all
        (select product_model_id,
        0 as inputQuantity,
        coalesce(sum(quantity),0) as outputQuantity
        from production_product_output
        <where>
            <if test="ew.startTime != null and ew.startTime != ''">
                and create_time &gt;= #{ew.startTime}
            </if>
            <if test="ew.endTime != null and ew.endTime != ''">
                and create_time &lt; #{ew.endTime}
            </if>
        </where>
        group by product_model_id)
        ) t
        group by product_model_id
        ) temp
        left join product_model pm on temp.product_model_id = pm.id
        left join product p on pm.product_id = p.id
        ) tmp
    </select>
</mapper>