收入和支出统计
This commit is contained in:
parent
fa166fa42b
commit
0212e22984
|
|
@ -6,9 +6,11 @@ import com.ghy.common.core.controller.BaseController;
|
|||
import com.ghy.common.core.domain.AjaxResult;
|
||||
import com.ghy.common.core.page.TableDataInfo;
|
||||
import com.ghy.common.enums.BusinessType;
|
||||
import com.ghy.common.utils.ExceptionUtil;
|
||||
import com.ghy.common.utils.poi.ExcelUtil;
|
||||
import com.ghy.payment.domain.FinancialDetail;
|
||||
import com.ghy.payment.service.FinancialDetailService;
|
||||
import com.ghy.web.pojo.vo.FinancialCountRequest;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.ModelMap;
|
||||
|
|
@ -38,6 +40,17 @@ public class FinancialDetailController extends BaseController {
|
|||
return prefix;
|
||||
}
|
||||
|
||||
@PostMapping("/count")
|
||||
@ResponseBody
|
||||
public AjaxResult count(@RequestBody FinancialCountRequest request){
|
||||
try {
|
||||
return AjaxResult.success(financialDetailService.count(request.getCountTime()));
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
return AjaxResult.error(ExceptionUtil.getExceptionMessage(e));
|
||||
}
|
||||
}
|
||||
|
||||
@RequiresPermissions("financial:detail:list")
|
||||
@PostMapping("/list")
|
||||
@ResponseBody
|
||||
|
|
|
|||
|
|
@ -0,0 +1,10 @@
|
|||
package com.ghy.web.pojo.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class FinancialCountRequest {
|
||||
|
||||
private String countTime;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
package com.ghy.web.pojo.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class FinancialCountResponse {
|
||||
|
||||
private String createTime;
|
||||
|
||||
private String payCount;
|
||||
|
||||
private String incomeCount;
|
||||
|
||||
}
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
package com.ghy.payment.mapper;
|
||||
|
||||
import com.ghy.payment.domain.FinancialDetail;
|
||||
import com.ghy.payment.response.FinancialCountResponse;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
|
@ -11,6 +12,11 @@ import java.util.List;
|
|||
*/
|
||||
public interface FinancialDetailMapper {
|
||||
|
||||
/**
|
||||
* @return 月份集合
|
||||
*/
|
||||
List<FinancialCountResponse> count(FinancialCountResponse response);
|
||||
|
||||
/**
|
||||
* @param financialDetail 财务细单属性
|
||||
* @return 成功条数
|
||||
|
|
|
|||
|
|
@ -0,0 +1,15 @@
|
|||
package com.ghy.payment.response;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class FinancialCountResponse {
|
||||
|
||||
private String createTime;
|
||||
|
||||
private String payCount;
|
||||
|
||||
private String incomeCount;
|
||||
|
||||
private String flag;
|
||||
}
|
||||
|
|
@ -1,8 +1,10 @@
|
|||
package com.ghy.payment.service;
|
||||
|
||||
import com.ghy.payment.domain.FinancialDetail;
|
||||
import com.ghy.payment.response.FinancialCountResponse;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 财务细单接口
|
||||
|
|
@ -11,6 +13,13 @@ import java.util.List;
|
|||
*/
|
||||
public interface FinancialDetailService {
|
||||
|
||||
/**
|
||||
* @param countTime 是否查询准确时间
|
||||
* @param flag 0收入 1支出
|
||||
* @return 月份集合
|
||||
*/
|
||||
List<FinancialCountResponse> count(String countTime);
|
||||
|
||||
/**
|
||||
* @param financialDetail 财务细单属性
|
||||
* @return 成功条数
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import com.ghy.common.constant.UserConstants;
|
|||
import com.ghy.common.core.text.Convert;
|
||||
import com.ghy.payment.domain.FinancialDetail;
|
||||
import com.ghy.payment.mapper.FinancialDetailMapper;
|
||||
import com.ghy.payment.response.FinancialCountResponse;
|
||||
import com.ghy.payment.service.FinancialDetailService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
|
@ -30,6 +31,24 @@ public class FinancialDetailServiceImpl implements FinancialDetailService {
|
|||
@Resource
|
||||
private FinancialDetailMapper financialDetailMapper;
|
||||
|
||||
|
||||
@Override
|
||||
public List<FinancialCountResponse> count(String countTime) {
|
||||
FinancialCountResponse request = new FinancialCountResponse();
|
||||
request.setCreateTime(countTime);
|
||||
request.setFlag("true");
|
||||
// 查询各月含有收入的费用
|
||||
List<FinancialCountResponse> list = financialDetailMapper.count(request);
|
||||
list.forEach(financialCountResponse->{
|
||||
// 查询指定月支出的
|
||||
request.setFlag("false");
|
||||
request.setCreateTime(financialCountResponse.getCreateTime());
|
||||
financialCountResponse.setPayCount(financialDetailMapper.count(request).get(0).getPayCount());
|
||||
});
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int insertFinancialDetail(FinancialDetail financialDetail) {
|
||||
return financialDetailMapper.insertFinancialDetail(financialDetail);
|
||||
|
|
|
|||
|
|
@ -28,6 +28,12 @@
|
|||
<result property="remark" column="remark"/>
|
||||
</resultMap>
|
||||
|
||||
<resultMap id="countResult" type="com.ghy.payment.response.FinancialCountResponse">
|
||||
<result property="createTime" column="create_time"/>
|
||||
<result property="payCount" column="pay_count"/>
|
||||
<result property="incomeCount" column="income_count"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectFinancialDetail">
|
||||
SELECT id, dept_id, code, financial_master_id, financial_master_code, order_detail_id, order_detail_code,
|
||||
total_money, discount_money, pay_money, financial_detail_type,payee_id, reverse_id, pay_type,
|
||||
|
|
@ -96,6 +102,23 @@
|
|||
WHERE reverse_id = #{reverseId}
|
||||
</update>
|
||||
|
||||
<select id="count" resultMap="countResult">
|
||||
select DATE_FORMAT(create_time,'%Y-%m') as create_time,
|
||||
sum(pay_money) as pay_count from financial_detail
|
||||
<where>
|
||||
<if test="createTime != null">
|
||||
and DATE_FORMAT(create_time,'%Y-%m') = #{createTime}
|
||||
</if>
|
||||
<if test="flag != 'true'">
|
||||
and pay_money >= 0
|
||||
</if>
|
||||
<if test="flag != 'false'">
|
||||
and pay_money <= 0
|
||||
</if>
|
||||
</where>
|
||||
group by DATE_FORMAT(create_time,'%Y-%m');
|
||||
</select>
|
||||
|
||||
<insert id="insertFinancialDetail" parameterType="com.ghy.payment.domain.FinancialDetail" useGeneratedKeys="true"
|
||||
keyProperty="id">
|
||||
INSERT INTO financial_detail(
|
||||
|
|
|
|||
Loading…
Reference in New Issue