报表功能查看

This commit is contained in:
lizhenhua 2025-09-19 16:25:38 +08:00
parent 324c53294f
commit dfdd2e2a69
3 changed files with 50 additions and 1 deletions

View File

@ -19,6 +19,7 @@ public class OrgConsume {
private String endPayTime;//结束支付时间
private String custName;
private String custNameLike;
private String remark;
private String flowId;
private Integer flowType;

View File

@ -11,7 +11,11 @@ import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.UnsupportedEncodingException;
import java.util.List;
import java.net.URLDecoder;
import java.nio.charset.StandardCharsets;
@RestController
@RequestMapping({"/api/v2/report"})
public class reportformsController extends BaseController {
@ -36,7 +40,17 @@ public class reportformsController extends BaseController {
* @return
*/
@PostMapping("/consume/exportExcel")
public void exportExcel(HttpServletResponse response, CanteenRecord orgConsume) {
public void exportExcel(HttpServletResponse response, CanteenRecord orgConsume) throws UnsupportedEncodingException {
if (orgConsume.getCustName() != null && !orgConsume.getCustName().trim().isEmpty()) {
try {
String decodedName = URLDecoder.decode(orgConsume.getCustName(), StandardCharsets.UTF_8.name());
orgConsume.setCustName(decodedName);
} catch (Exception e) {
// 出错时打印日志但不要影响后续逻辑
e.printStackTrace();
}
}
// 1. 查询数据
List<CanteenRecord> peoplelist = service.getPeoplelist(orgConsume);
// 2. flowTypeText 赋值
@ -45,8 +59,10 @@ public class reportformsController extends BaseController {
record.setAmount(record.getAmount()/100);
if ("110".equals(record.getFlowType())) {
record.setFlowTypeText("消费");
record.setAmount(-record.getAmount());
} else if ("120".equals(record.getFlowType())) {
record.setFlowTypeText("补助");
record.setAmount(-record.getAmount());
} else if ("130".equals(record.getFlowType())) {
record.setFlowTypeText("退款");
} else {

View File

@ -591,6 +591,38 @@
rf.flow_type AS flowType,
rf.pay_time AS payTime,
rf.ord_time AS ordTime,
(SELECT SUM(rf2.flow_amount)
FROM report_account_flow rf2
LEFT JOIN cust_info ci2 ON rf2.cust_id = ci2.cust_id
LEFT JOIN cust_org co2 ON ci2.org_id = co2.org_id
WHERE rf2.flow_type IN (110, 120)
<if test="custName != null">
AND rf2.cust_id = ci.cust_id
</if>
<if test="selectedOrg != null and selectedOrg.length > 0">
AND co2.org_id IN
<foreach collection="selectedOrg" item="orgId" open="(" separator="," close=")">
#{orgId}
</foreach>
</if>
AND rf2.pay_time &gt;= #{startPayTime}
AND rf2.pay_time &lt;= #{endPayTime}) AS totalConsume,
(SELECT SUM(rf3.flow_amount)
FROM report_account_flow rf3
LEFT JOIN cust_info ci3 ON rf3.cust_id = ci3.cust_id
LEFT JOIN cust_org co3 ON ci3.org_id = co3.org_id
WHERE rf3.flow_type = 130
<if test="custName != null">
AND rf3.cust_id = ci.cust_id
</if>
<if test="selectedOrg != null and selectedOrg.length > 0">
AND co3.org_id IN
<foreach collection="selectedOrg" item="orgId" open="(" separator="," close=")">
#{orgId}
</foreach>
</if>
AND rf3.pay_time &gt;= #{startPayTime}
AND rf3.pay_time &lt;= #{endPayTime}) AS totalRefund,
rf.remark AS remark
FROM report_account_flow rf
LEFT JOIN cust_info ci ON rf.cust_id = ci.cust_id