init:米东项目初始化
This commit is contained in:
@@ -0,0 +1,353 @@
|
||||
package com.saye.hospitalgd.controller;
|
||||
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.saye.hospitalgd.commons.date.DateDUtil;
|
||||
import com.saye.hospitalgd.commons.string.StringDUtil;
|
||||
import com.saye.hospitalgd.model.Dicinfo;
|
||||
import com.saye.hospitalgd.service.BankbillHistoryService;
|
||||
import com.saye.hospitalgd.service.TransactionDetailService;
|
||||
import com.saye.hospitalgd.service.system.DicinfoService;
|
||||
import com.saye.hospitalgd.service.system.ServiceParamsService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.math.BigDecimal;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author thuang
|
||||
* @version 1.0
|
||||
* @description: 支付统计
|
||||
* @date 2021/9/18 16:32
|
||||
*/
|
||||
@Controller
|
||||
@Slf4j
|
||||
@RequestMapping("/paymentStatistics")
|
||||
@Api(tags = "支付统计相关接口")
|
||||
public class PaymentStatisticsController {
|
||||
|
||||
@Autowired
|
||||
private DicinfoService dicinfoService;
|
||||
|
||||
@Autowired
|
||||
private BankbillHistoryService bankbillHistoryService;
|
||||
|
||||
@Autowired
|
||||
private TransactionDetailService transactionDetailService;
|
||||
|
||||
@Autowired
|
||||
private ServiceParamsService serviceParamsService;
|
||||
|
||||
@RequestMapping("/toPaymentStatistics")
|
||||
public String toPaymentStatistics(ModelMap modelMap) {
|
||||
return "paymentStatistics/paymentStatistics";
|
||||
}
|
||||
|
||||
/**
|
||||
* @description: 查询支付统计页面数据
|
||||
* @author thuang
|
||||
* @date 2021/10/22 16:55
|
||||
* @version 1.0
|
||||
*/
|
||||
@PostMapping("/findpaymentStatisticsData")
|
||||
@ResponseBody
|
||||
@ApiOperation(value = "查询支付统计页面数据")
|
||||
public HashMap<Object, Object> findpaymentStatisticsData(@RequestBody HashMap<Object, Object> map) {
|
||||
HashMap<Object, Object> responseMap = new HashMap<Object, Object>();
|
||||
String errCode = "0";
|
||||
String errMsg = "";
|
||||
|
||||
try {
|
||||
String startTime = StringDUtil.changeNullToEmpty(map.get("startTime"));
|
||||
String endTime = StringDUtil.changeNullToEmpty(map.get("endTime"));
|
||||
|
||||
List<String> betweenDate = DateDUtil.getBetweenDate(startTime, endTime);
|
||||
|
||||
// 查询字典表支付方式
|
||||
List<Dicinfo> pay_type = dicinfoService.findDicinfoTreeNodeList("THIRD_PAY");
|
||||
HashMap<String, String> payMethodMap = new HashMap<>();
|
||||
for (Dicinfo dicinfo : pay_type) {
|
||||
String dicname = dicinfo.getDicname();
|
||||
String dicvalue = dicinfo.getDicvalue();
|
||||
|
||||
// 微信支付支付宝支付 其他剩下的全算其他
|
||||
if ("支付宝支付".equals(dicname) || "微信支付".equals(dicname)) {
|
||||
payMethodMap.put(dicvalue, dicname);
|
||||
}
|
||||
}
|
||||
|
||||
// 先组织好map
|
||||
LinkedHashMap<String, LinkedHashMap<String, String>> numMap = new LinkedHashMap<>();
|
||||
LinkedHashMap<String, LinkedHashMap<String, String>> moneyMap = new LinkedHashMap<>();
|
||||
LinkedHashMap<String, String> addMap = new LinkedHashMap<>();
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("MM/dd");
|
||||
List<String> betweenDateList = new ArrayList<>();
|
||||
for (String s : betweenDate) {
|
||||
addMap.put(s, "0");
|
||||
|
||||
Date date = DateDUtil.strToDate(DateDUtil.yyyy_MM_dd, s);
|
||||
betweenDateList.add(sdf.format(date));
|
||||
}
|
||||
|
||||
numMap.put("支付宝支付", new LinkedHashMap<String, String>() {{
|
||||
putAll(addMap);
|
||||
}});
|
||||
numMap.put("微信支付", new LinkedHashMap<String, String>() {{
|
||||
putAll(addMap);
|
||||
}});
|
||||
numMap.put("其他", new LinkedHashMap<String, String>() {{
|
||||
putAll(addMap);
|
||||
}});
|
||||
|
||||
moneyMap.put("支付宝支付", new LinkedHashMap<String, String>() {{
|
||||
putAll(addMap);
|
||||
}});
|
||||
moneyMap.put("微信支付", new LinkedHashMap<String, String>() {{
|
||||
putAll(addMap);
|
||||
}});
|
||||
moneyMap.put("其他", new LinkedHashMap<String, String>() {{
|
||||
putAll(addMap);
|
||||
}});
|
||||
|
||||
// 返回格式化后的日期数组
|
||||
responseMap.put("betweenDate", betweenDateList);
|
||||
|
||||
List<HashMap<Object, Object>> thirdNumList = bankbillHistoryService.findBankBillNumByTime(map);
|
||||
|
||||
for (HashMap<Object, Object> hashMap : thirdNumList) {
|
||||
String num1 = StringDUtil.changeNullToEmpty(hashMap.get("NUM"));
|
||||
String c_jyrq = StringDUtil.changeNullToEmpty(hashMap.get("I_JYRQ"));
|
||||
String c_zffs = StringDUtil.changeNullToEmpty(hashMap.get("I_FXK"));
|
||||
String str_zffs = "";
|
||||
String s = payMethodMap.get(c_zffs);
|
||||
if (s == null) {
|
||||
str_zffs = "其他";
|
||||
} else {
|
||||
str_zffs = s;
|
||||
}
|
||||
LinkedHashMap<String, String> zffsMap = numMap.get(str_zffs);
|
||||
String countNum = zffsMap.get(c_jyrq);
|
||||
countNum = new BigDecimal(countNum).add(new BigDecimal(num1)).toString();
|
||||
zffsMap.put(c_jyrq, countNum);
|
||||
}
|
||||
|
||||
// 将linkedHashMap转为list<hashMap<>> hashMap 中 name 支付方式,data list集合 内容为计算的数据
|
||||
List<HashMap<String, Object>> resultNumList = new ArrayList<>();
|
||||
for (String key : numMap.keySet()) {
|
||||
LinkedHashMap<String, String> linkedHashMap = numMap.get(key);
|
||||
List<String> newList = new ArrayList<>();
|
||||
for (String key2 : linkedHashMap.keySet()) {
|
||||
String s = linkedHashMap.get(key2);
|
||||
newList.add(s);
|
||||
}
|
||||
HashMap<String, Object> newMap = new HashMap<>();
|
||||
newMap.put("name", key);
|
||||
newMap.put("data", newList);
|
||||
resultNumList.add(newMap);
|
||||
}
|
||||
responseMap.put("resultNumList", resultNumList);
|
||||
|
||||
|
||||
List<HashMap<Object, Object>> thirdMoneyList = bankbillHistoryService.findBankBillMoneyByTime(map);
|
||||
for (HashMap<Object, Object> hashMap : thirdMoneyList) {
|
||||
String money = StringDUtil.changeNullToEmpty(hashMap.get("MONEY"));
|
||||
String c_jyrq = StringDUtil.changeNullToEmpty(hashMap.get("I_JYRQ"));
|
||||
String c_zffs = StringDUtil.changeNullToEmpty(hashMap.get("I_FXK"));
|
||||
String str_zffs = "";
|
||||
String s = payMethodMap.get(c_zffs);
|
||||
if (s == null) {
|
||||
str_zffs = "其他";
|
||||
} else {
|
||||
str_zffs = s;
|
||||
}
|
||||
LinkedHashMap<String, String> zffsMap = moneyMap.get(str_zffs);
|
||||
String countNum = zffsMap.get(c_jyrq);
|
||||
countNum = new BigDecimal(countNum).add(new BigDecimal(money)).toString();
|
||||
zffsMap.put(c_jyrq, countNum);
|
||||
}
|
||||
|
||||
// 将linkedHashMap转为list<hashMap<>> hashMap 中 name 支付方式,data list集合 内容为计算的数据
|
||||
List<HashMap<String, Object>> resultMoneyList = new ArrayList<>();
|
||||
for (String key : moneyMap.keySet()) {
|
||||
LinkedHashMap<String, String> linkedHashMap = moneyMap.get(key);
|
||||
List<String> newList = new ArrayList<>();
|
||||
for (String key2 : linkedHashMap.keySet()) {
|
||||
String s = linkedHashMap.get(key2);
|
||||
newList.add(s);
|
||||
}
|
||||
HashMap<String, Object> newMap = new HashMap<>();
|
||||
newMap.put("name", key);
|
||||
newMap.put("data", newList);
|
||||
resultMoneyList.add(newMap);
|
||||
}
|
||||
responseMap.put("resultMoneyList", resultMoneyList);
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
errCode = "999";
|
||||
errMsg = "查询统计数据失败,原因:" + e.getMessage();
|
||||
}
|
||||
|
||||
responseMap.put("errCode", errCode);
|
||||
responseMap.put("errMsg", errMsg);
|
||||
return responseMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description: 对账汇总统计
|
||||
* @author thuang
|
||||
* @date 2021/12/1 14:53
|
||||
* @version 1.0
|
||||
*/
|
||||
@RequestMapping("/toSummary")
|
||||
@ApiOperation("对账汇总统计")
|
||||
public String toPrint(HttpServletRequest request, ModelMap modelMap) {
|
||||
|
||||
String trade_date = StringDUtil.changeNullToEmpty(request.getParameter("trade_date"));
|
||||
|
||||
|
||||
if ("".equals(trade_date)) {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(new Date());
|
||||
|
||||
calendar.add(Calendar.DATE, -1);
|
||||
Date startDate = calendar.getTime();
|
||||
|
||||
String startTime = DateDUtil.DateToStr(DateDUtil.yyyy_MM_dd, startDate);
|
||||
String endTime = DateDUtil.getCurrentDate(DateDUtil.yyyy_MM_dd);
|
||||
|
||||
modelMap.addAttribute("startTime", startTime);
|
||||
modelMap.addAttribute("endTime", endTime);
|
||||
} else {
|
||||
modelMap.addAttribute("startTime", trade_date);
|
||||
modelMap.addAttribute("endTime", trade_date);
|
||||
modelMap.addAttribute("isClick", "1");
|
||||
}
|
||||
|
||||
List<HashMap<Object, Object>> serviceParams = serviceParamsService.findParamValByParamCode("dzhz_table_name");
|
||||
String dzhz_table_name = StringDUtil.changeNullToEmpty(serviceParams.get(0).get("PARAM_VAL"));
|
||||
modelMap.addAttribute("table_name", dzhz_table_name);
|
||||
|
||||
return "paymentStatistics/summary";
|
||||
}
|
||||
|
||||
/**
|
||||
* @description: 查询汇总表数据
|
||||
* @author thuang
|
||||
* @date 2021/12/3 16:29
|
||||
* @version 1.0
|
||||
*/
|
||||
@PostMapping("/findSummaryData")
|
||||
@ResponseBody
|
||||
@ApiOperation("查询汇总表数据")
|
||||
public HashMap<Object, Object> findSummaryData(@RequestBody HashMap<Object, Object> map) {
|
||||
HashMap<Object, Object> resultMap = new HashMap<>();
|
||||
String errCode = "0";
|
||||
String errMsg = "";
|
||||
|
||||
try {
|
||||
|
||||
map.put("is_active", "1");
|
||||
List<HashMap<Object, Object>> list = transactionDetailService.findHisAndThirdJoinData(map);
|
||||
|
||||
// his需要统计 1扫码支付 2银行卡支付 3掌医支付 4现金支付 5其他
|
||||
// 三方需要统计 1_1微信支付 1_2支付宝支付 云闪付支付 其他支付 2银行卡支付 3掌医支付 4现金支付 5其他
|
||||
|
||||
HashMap<Object, Object> hisMoneyData = new HashMap<>();
|
||||
hisMoneyData.put("1", "0");
|
||||
hisMoneyData.put("2", "0");
|
||||
hisMoneyData.put("3", "0");
|
||||
hisMoneyData.put("4", "0");
|
||||
hisMoneyData.put("5", "0");
|
||||
|
||||
HashMap<Object, Object> thirdMoneyData = new HashMap<>();
|
||||
thirdMoneyData.put("1_1", "0");
|
||||
thirdMoneyData.put("1_2", "0");
|
||||
thirdMoneyData.put("1_3", "0");
|
||||
thirdMoneyData.put("1_4", "0");
|
||||
thirdMoneyData.put("2", "0");
|
||||
thirdMoneyData.put("3", "0");
|
||||
thirdMoneyData.put("4", "0");
|
||||
thirdMoneyData.put("5", "0");
|
||||
|
||||
HashMap<Object, Object> hisNumData = new HashMap<>();
|
||||
hisNumData.put("1", "0");
|
||||
hisNumData.put("2", "0");
|
||||
hisNumData.put("3", "0");
|
||||
hisNumData.put("4", "0");
|
||||
hisNumData.put("5", "0");
|
||||
|
||||
|
||||
HashMap<Object, Object> thirdNumData = new HashMap<>();
|
||||
thirdNumData.put("1_1", "0");
|
||||
thirdNumData.put("1_2", "0");
|
||||
thirdNumData.put("1_3", "0");
|
||||
thirdNumData.put("1_4", "0");
|
||||
thirdNumData.put("2", "0");
|
||||
thirdNumData.put("3", "0");
|
||||
thirdNumData.put("4", "0");
|
||||
thirdNumData.put("5", "0");
|
||||
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
HashMap<Object, Object> hashMap = list.get(i);
|
||||
|
||||
String i_jyje = StringDUtil.changeNullToEmpty(hashMap.get("I_JYJE")).trim();
|
||||
String i_zffs = StringDUtil.changeNullToEmpty(hashMap.get("I_JYQD")).trim();
|
||||
|
||||
String amount = StringDUtil.changeNullToEmpty(hashMap.get("AMOUNT")).trim();
|
||||
String paytype = StringDUtil.changeNullToEmpty(hashMap.get("PAYTYPE")).trim();
|
||||
|
||||
// 如果银行端金额不为空
|
||||
|
||||
if (StrUtil.isNotBlank(i_jyje)) {
|
||||
log.info("hashMap is :" + hashMap);
|
||||
log.info("aaa is : " + thirdMoneyData.get(i_zffs));
|
||||
BigDecimal money = Convert.toBigDecimal(thirdMoneyData.get(i_zffs));
|
||||
money = money.add(new BigDecimal(i_jyje));
|
||||
thirdMoneyData.put(i_zffs, money.toString());
|
||||
|
||||
int num = Integer.parseInt(StringDUtil.changeNullToEmpty(thirdNumData.get(i_zffs)));
|
||||
num++;
|
||||
thirdNumData.put(i_zffs, num + "");
|
||||
}
|
||||
|
||||
// 如果his端金额不为空
|
||||
|
||||
if (StrUtil.isNotBlank(amount)) {
|
||||
log.info("hashMap is :" + hashMap);
|
||||
BigDecimal money = new BigDecimal(StringDUtil.changeNullToEmpty(hisMoneyData.get(paytype)));
|
||||
money = money.add(new BigDecimal(amount));
|
||||
hisMoneyData.put(paytype, money.toString());
|
||||
|
||||
int num = Integer.parseInt(StringDUtil.changeNullToEmpty(hisNumData.get(paytype)));
|
||||
num++;
|
||||
hisNumData.put(paytype, num + "");
|
||||
}
|
||||
}
|
||||
|
||||
resultMap.put("hisMoneyData", hisMoneyData);
|
||||
resultMap.put("thirdMoneyData", thirdMoneyData);
|
||||
resultMap.put("hisNumData", hisNumData);
|
||||
resultMap.put("thirdNumData", thirdNumData);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
errCode = "999";
|
||||
errMsg = "查询对账汇总表信息失败,原因:" + e.getMessage();
|
||||
}
|
||||
resultMap.put("errCode", errCode);
|
||||
resultMap.put("errMsg", errMsg);
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user