bugfix:移动医保对账
This commit is contained in:
@@ -0,0 +1,68 @@
|
||||
package com.saye.hospitalgd.controller;
|
||||
|
||||
import com.saye.hospitalgd.commons.date.DateDUtil;
|
||||
import com.saye.hospitalgd.commons.string.StringDUtil;
|
||||
import com.saye.hospitalgd.service.FinancialReconciliation.MobileYbReconciliationService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/mobileYbReconciliation")
|
||||
@Api(tags = "微信移动医保对账")
|
||||
public class MobileYbReconciliationController {
|
||||
|
||||
@Autowired
|
||||
private MobileYbReconciliationService mobileYbReconciliationService;
|
||||
|
||||
@RequestMapping("/toMobileYb")
|
||||
public String toMobileYb(ModelMap modelMap) {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(new Date());
|
||||
calendar.add(Calendar.DATE, -1);
|
||||
String startTime = DateDUtil.DateToStr(DateDUtil.yyyy_MM_dd, calendar.getTime());
|
||||
String endTime = DateDUtil.getCurrentDate(DateDUtil.yyyy_MM_dd);
|
||||
modelMap.addAttribute("startTime", startTime);
|
||||
modelMap.addAttribute("endTime", endTime);
|
||||
return "paymentStatistics/mobileYbReconciliation";
|
||||
}
|
||||
|
||||
@RequestMapping("/findData")
|
||||
@ResponseBody
|
||||
@ApiOperation("查询微信移动医保对账数据")
|
||||
public HashMap<Object, Object> findData(@RequestBody HashMap<Object, Object> map) {
|
||||
HashMap<Object, Object> resp = new HashMap<>();
|
||||
String errCode = "0";
|
||||
String errMsg = "";
|
||||
try {
|
||||
String tradeDate = StringDUtil.changeNullToEmpty(map.get("trade_date"));
|
||||
if ("".equals(tradeDate)) {
|
||||
errCode = "1";
|
||||
errMsg = "trade_date不能为空";
|
||||
} else {
|
||||
resp = mobileYbReconciliationService.reconcile(tradeDate);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
errCode = "999";
|
||||
errMsg = e.getMessage();
|
||||
}
|
||||
resp.put("errCode", errCode);
|
||||
resp.put("errMsg", errMsg);
|
||||
return resp;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -452,6 +452,16 @@ public class PaymentStatisticsController {
|
||||
public HashMap<Object, Object> findTenpaySummary(String startTime, String endTime) {
|
||||
HashMap<Object, Object> response = new HashMap<>();
|
||||
try {
|
||||
// 如果未选择日期,则默认查询昨日到今日,避免无条件查全量
|
||||
if ((startTime == null || "".equals(startTime.trim())) && (endTime == null || "".equals(endTime.trim()))) {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(new Date());
|
||||
calendar.add(Calendar.DATE, -1);
|
||||
Date startDate = calendar.getTime();
|
||||
startTime = DateDUtil.DateToStr(DateDUtil.yyyy_MM_dd, startDate);
|
||||
endTime = DateDUtil.getCurrentDate(DateDUtil.yyyy_MM_dd);
|
||||
}
|
||||
|
||||
HashMap<Object, Object> map = new HashMap<>();
|
||||
map.put("startTime", startTime);
|
||||
map.put("endTime", endTime);
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.saye.hospitalgd.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 微信移动医保对账结果
|
||||
*/
|
||||
@Data
|
||||
public class MobileYbReconciliationResult {
|
||||
private String id;
|
||||
private String tradeDate;
|
||||
|
||||
private String bankMedfee;
|
||||
private String bankAcctPay;
|
||||
private String bankFundPay;
|
||||
|
||||
private String hisMedfee;
|
||||
private String hisAcctPay;
|
||||
private String hisFundPay;
|
||||
|
||||
private String diffMedfee;
|
||||
private String diffAcctPay;
|
||||
private String diffFundPay;
|
||||
|
||||
/** 0-平,1-不平 */
|
||||
private String stmtRslt;
|
||||
private String stmtRsltDscr;
|
||||
private String createTime;
|
||||
private String modifyTime;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.saye.hospitalgd.mapper.FinancialReconciliation;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public interface MobileYbReconciliationMapper {
|
||||
|
||||
HashMap<Object, Object> sumBankMobileYb(HashMap<Object, Object> map);
|
||||
|
||||
HashMap<Object, Object> sumHisMobileYb(HashMap<Object, Object> map);
|
||||
|
||||
void insertResult(HashMap<Object, Object> map);
|
||||
|
||||
void deleteResultByDate(HashMap<Object, Object> map);
|
||||
|
||||
HashMap<Object, Object> findResultByDate(HashMap<Object, Object> map);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.saye.hospitalgd.scheduler.job;
|
||||
|
||||
import com.saye.hospitalgd.scheduler.jobMethod.MobileYbReconciliationMethod;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
/**
|
||||
* Quartz 调度入口:微信移动医保对账
|
||||
* 方法名:executeMobileYbReconciliation
|
||||
* 参数:trade_date(yyyy-MM-dd),为空则默认昨日
|
||||
*/
|
||||
public class MobileYbReconciliationJob {
|
||||
|
||||
public HashMap<Object, Object> executeMobileYbReconciliation(String trade_date) {
|
||||
MobileYbReconciliationMethod method = new MobileYbReconciliationMethod();
|
||||
return method.executeMobileYbReconciliation(trade_date);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
package com.saye.hospitalgd.scheduler.jobMethod;
|
||||
|
||||
import com.saye.hospitalgd.commons.date.DateDUtil;
|
||||
import com.saye.hospitalgd.commons.getBean.GetBeanUtil;
|
||||
import com.saye.hospitalgd.commons.log.LogUtil;
|
||||
import com.saye.hospitalgd.service.FinancialReconciliation.MobileYbReconciliationService;
|
||||
import com.saye.hospitalgd.service.impl.FinancialReconciliation.MobileYbReconciliationServiceImpl;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
|
||||
/**
|
||||
* 微信移动医保对账方法
|
||||
* 被调度任务调用,传入 trade_date(yyyy-MM-dd),为空则默认昨日
|
||||
*/
|
||||
@Slf4j
|
||||
public class MobileYbReconciliationMethod {
|
||||
|
||||
public HashMap<Object, Object> executeMobileYbReconciliation(String trade_date) {
|
||||
HashMap<Object, Object> resp = new HashMap<>();
|
||||
String errCode = "0";
|
||||
String errMsg = "";
|
||||
try {
|
||||
String targetDate = trade_date;
|
||||
if (targetDate == null || "".equals(targetDate.trim())) {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(new Date());
|
||||
calendar.add(Calendar.DATE, -1);
|
||||
targetDate = DateDUtil.DateToStr(DateDUtil.yyyy_MM_dd, calendar.getTime());
|
||||
}
|
||||
LogUtil.info(this.getClass(), "开始执行微信移动医保对账,日期:" + targetDate);
|
||||
MobileYbReconciliationService svc = GetBeanUtil.getBean(MobileYbReconciliationServiceImpl.class);
|
||||
resp = svc.reconcile(targetDate);
|
||||
LogUtil.info(this.getClass(), "微信移动医保对账结束,结果:" + resp);
|
||||
} catch (Exception e) {
|
||||
errCode = "999";
|
||||
errMsg = e.getMessage();
|
||||
log.error("微信移动医保对账失败:{}", errMsg, e);
|
||||
}
|
||||
resp.put("errCode", errCode);
|
||||
resp.put("errMsg", errMsg);
|
||||
return resp;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.saye.hospitalgd.service.FinancialReconciliation;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public interface MobileYbReconciliationService {
|
||||
|
||||
HashMap<Object, Object> reconcile(String tradeDate) throws Exception;
|
||||
|
||||
HashMap<Object, Object> findResult(String tradeDate);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,95 @@
|
||||
package com.saye.hospitalgd.service.impl.FinancialReconciliation;
|
||||
|
||||
import com.saye.hospitalgd.mapper.FinancialReconciliation.MobileYbReconciliationMapper;
|
||||
import com.saye.hospitalgd.service.FinancialReconciliation.MobileYbReconciliationService;
|
||||
import com.saye.hospitalgd.commons.uuid.UUIDGenerator;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.HashMap;
|
||||
|
||||
@Service
|
||||
public class MobileYbReconciliationServiceImpl implements MobileYbReconciliationService {
|
||||
|
||||
@Autowired
|
||||
private MobileYbReconciliationMapper mobileYbReconciliationMapper;
|
||||
|
||||
@Override
|
||||
public HashMap<Object, Object> reconcile(String tradeDate) throws Exception {
|
||||
HashMap<Object, Object> resp = new HashMap<>();
|
||||
String errCode = "0";
|
||||
String errMsg = "";
|
||||
|
||||
try {
|
||||
HashMap<Object, Object> param = new HashMap<>();
|
||||
param.put("trade_date", tradeDate);
|
||||
|
||||
HashMap<Object, Object> bank = mobileYbReconciliationMapper.sumBankMobileYb(param);
|
||||
HashMap<Object, Object> his = mobileYbReconciliationMapper.sumHisMobileYb(param);
|
||||
|
||||
BigDecimal bankMedfee = getDecimal(bank.get("bank_medfee"));
|
||||
BigDecimal bankAcct = getDecimal(bank.get("bank_acct_pay"));
|
||||
BigDecimal bankFund = getDecimal(bank.get("bank_fund_pay"));
|
||||
|
||||
BigDecimal hisMedfee = getDecimal(his.get("his_medfee"));
|
||||
BigDecimal hisAcct = getDecimal(his.get("his_acct_pay"));
|
||||
BigDecimal hisFund = getDecimal(his.get("his_fund_pay"));
|
||||
|
||||
BigDecimal diffMedfee = bankMedfee.subtract(hisMedfee);
|
||||
BigDecimal diffAcct = bankAcct.subtract(hisAcct);
|
||||
BigDecimal diffFund = bankFund.subtract(hisFund);
|
||||
|
||||
String stmtRslt = (diffMedfee.compareTo(BigDecimal.ZERO) == 0
|
||||
&& diffAcct.compareTo(BigDecimal.ZERO) == 0
|
||||
&& diffFund.compareTo(BigDecimal.ZERO) == 0) ? "0" : "1";
|
||||
|
||||
// 覆盖写结果
|
||||
mobileYbReconciliationMapper.deleteResultByDate(param);
|
||||
HashMap<Object, Object> insert = new HashMap<>();
|
||||
insert.put("id", UUIDGenerator.getUUID());
|
||||
insert.put("trade_date", tradeDate);
|
||||
insert.put("bank_medfee", bankMedfee);
|
||||
insert.put("bank_acct_pay", bankAcct);
|
||||
insert.put("bank_fund_pay", bankFund);
|
||||
insert.put("his_medfee", hisMedfee);
|
||||
insert.put("his_acct_pay", hisAcct);
|
||||
insert.put("his_fund_pay", hisFund);
|
||||
insert.put("diff_medfee", diffMedfee);
|
||||
insert.put("diff_acct_pay", diffAcct);
|
||||
insert.put("diff_fund_pay", diffFund);
|
||||
insert.put("stmt_rslt", stmtRslt);
|
||||
insert.put("stmt_rslt_dscr", stmtRslt.equals("0") ? "平" : "不平");
|
||||
|
||||
mobileYbReconciliationMapper.insertResult(insert);
|
||||
|
||||
resp.putAll(insert);
|
||||
} catch (Exception e) {
|
||||
errCode = "999";
|
||||
errMsg = e.getMessage();
|
||||
}
|
||||
resp.put("errCode", errCode);
|
||||
resp.put("errMsg", errMsg);
|
||||
return resp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HashMap<Object, Object> findResult(String tradeDate) {
|
||||
HashMap<Object, Object> param = new HashMap<>();
|
||||
param.put("trade_date", tradeDate);
|
||||
return mobileYbReconciliationMapper.findResultByDate(param);
|
||||
}
|
||||
|
||||
private BigDecimal getDecimal(Object obj) {
|
||||
if (obj == null || "".equals(obj.toString().trim())) {
|
||||
return BigDecimal.ZERO;
|
||||
}
|
||||
return new BigDecimal(obj.toString());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user