bug描述:
在小月份(月末为28、29、30时)的任意一天,登录后进入首页,后台日志报错。
bug原因:
DepotItemMapperEx.xml中日期条件参数问题(中'${MonthTime}-01 00:00:00'和'${MonthTime}-31 23:59:59')

    <select id="buyOrSaleNumber" resultType="java.math.BigDecimal">
        select ifnull(sum(BasicNumber),0) as BasicNumber from jsh_depotitem di,jsh_depothead dh
        where di.HeaderId = dh.id
        and dh.type='${type}' and dh.subType='${subType}'
        and di.MaterialId =${MId}
        and dh.OperTime &gt;= '${MonthTime}-01 00:00:00'
        and dh.OperTime &lt;= '${MonthTime}-31 23:59:59'
        and ifnull(dh.delete_Flag,'0') !='1'
        and ifnull(di.delete_Flag,'0') !='1'
    </select>

    <select id="buyOrSalePrice" resultType="java.math.BigDecimal">
        select ifnull(sum(AllPrice),0) as AllPrice from jsh_depotitem di,jsh_depothead dh
        where di.HeaderId = dh.id
        and dh.type='${type}' and dh.subType='${subType}'
        and di.MaterialId =${MId}
        and dh.OperTime &gt;= '${MonthTime}-01 00:00:00'
        and dh.OperTime &lt;= '${MonthTime}-31 23:59:59'
        and ifnull(dh.delete_Flag,'0') !='1'
        and ifnull(di.delete_Flag,'0') !='1'
    </select>

    <select id="inOrOutPrice" resultType="java.math.BigDecimal">
        select ifnull(sum(DiscountLastMoney),0) as allMoney from jsh_depothead dh
        where 1=1
        and dh.type='${type}' and dh.subType='${subType}'
        and dh.OperTime &gt;= '${MonthTime}-01 00:00:00'
        and dh.OperTime &lt;= '${MonthTime}-31 23:59:59'
        and ifnull(dh.delete_Flag,'0') !='1'
    </select>

bug解决:

  1. 在Tools工具类添加日期处理方法(获取指定日期的月初和月末日期字符串)
  2. 修改DepotItemMapperEx.xml中有相关问题的sql
  3. 修改DepotItemMapperEx.java类中相关方法的参数(将“年月”MonthTime替换为“月初”monthStartDateStr和“月末”monthEndDateStr)
  4. 修改Service类中调用到上述相关方法的代码