init:米东项目初始化

This commit is contained in:
Yuan
2025-07-23 09:55:50 +08:00
commit 6b49fbfaca
355 changed files with 392953 additions and 0 deletions

View File

@@ -0,0 +1,41 @@
package com.saye.hospitalgd;
import org.apache.coyote.http11.AbstractHttp11Protocol;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.embedded.tomcat.TomcatConnectorCustomizer;
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.transaction.annotation.EnableTransactionManagement;
@SpringBootApplication
@MapperScan("com.saye.hospitalgd.mapper")
@EnableTransactionManagement //开启事务
@EnableScheduling
public class HospitalgdApplication {
public static void main(String[] args) {
SpringApplication.run(HospitalgdApplication.class, args);
}
/**
* @description 解决文件上传超过10m报错
* @author dqzhang
* @created 2019年10月14日 上午11:23:58
* @return
*/
@Bean
public TomcatServletWebServerFactory tomcatEmbedded() {
TomcatServletWebServerFactory tomcat = new TomcatServletWebServerFactory();
tomcat.addConnectorCustomizers((TomcatConnectorCustomizer) connector -> {
if ((connector.getProtocolHandler() instanceof AbstractHttp11Protocol<?>)) {
//-1 means unlimited
((AbstractHttp11Protocol<?>) connector.getProtocolHandler()).setMaxSwallowSize(-1);
}
});
return tomcat;
}
}

View File

@@ -0,0 +1,13 @@
package com.saye.hospitalgd;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
public class ServletInitializer extends SpringBootServletInitializer {
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(HospitalgdApplication.class);
}
}

View File

@@ -0,0 +1,120 @@
package com.saye.hospitalgd.commons;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.io.Serializable;
/**
* 用于封装AJAX调用以后的JSON返回值
* 其中正确返回值:
* {state:0, data:返回数据, message:错误消息}
* 错误返回值:
* {state:1, data:null, message:错误消息}
**/
public class JsonResult implements Serializable {
private static final long serialVersionUID = -3644950655568598241L;
//定义jackson对象
private static final ObjectMapper MAPPER = new ObjectMapper();
/**
* 返回是否成功的状态, 0表示成功,
* 1或其他值 表示失败
*/
private boolean state;
/**
* 成功时候,返回的JSON数据
*/
private Object data;
/**
* 是错误时候的错误消息
*/
private String message;
public JsonResult() {
}
public JsonResult(boolean state, Object data, String message) {
this.state = state;
this.data = data;
this.message = message;
}
public JsonResult(Throwable e){
state = false;
data=null;
message=e.getMessage();
}
public JsonResult(Object data){
state = true;
this.data=data;
message="";
}
public boolean isState() {
return state;
}
public void setState(boolean state) {
this.state = state;
}
public Object getData() {
return data;
}
public void setData(Object data) {
this.data = data;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public static String jsonResultSuccess(Object data, String message){
JsonResult jsonResult=new JsonResult();
jsonResult.setState(true);
jsonResult.setMessage(message);
jsonResult.setData(data);
return ObjectToJson(jsonResult);
}
public static String jsonResultFalse(String message){
JsonResult jsonResult=new JsonResult();
jsonResult.setState(false);
jsonResult.setMessage(message);
return ObjectToJson(jsonResult);
}
/**
* 将对象转化为json字符串
* @param data
* @return
*/
public static String ObjectToJson(Object data){
try{
String string = MAPPER.writeValueAsString(data);
return string;
} catch (JsonProcessingException e) {
e.printStackTrace();
}
return null;
}
@Override
public String toString() {
return "JsonResult [state=" + state + ", data=" + data + ", message=" + message + "]";
}
}

View File

@@ -0,0 +1,95 @@
package com.saye.hospitalgd.commons;
import org.apache.commons.codec.CharEncoding;
import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
/**
* <p>
* token生成工具类
* </p>
*
* @author caoshiyan
* @version V1.0
* @date 2015年12月29日 上午10:16:14
* @modificationHistory=========================逻辑或功能性重大变更记录
* @modify by user: {修改人} 2015年12月29日
* @since
*/
public class TokenGenerateUtil {
/**
* <p>
* MD5加密工具类
* </p>
* @author caoshiyan
* @version V1.0
* @date 2015年11月30日 下午4:40:16
* @param s
* @return
*
* @modificationHistory=========================逻辑或功能性重大变更记录
* @modify by user: {修改人} 2015年11月30日
* @modify by reason:{方法名}:{原因}
* @since
*/
public final static String md5(String s) {
char hexDigits[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
try {
MessageDigest mdTemp = MessageDigest.getInstance("MD5");
try {
// 最重要的是这句,需要加上编码类型
mdTemp.update(s.getBytes(CharEncoding.UTF_8));
} catch (UnsupportedEncodingException e) {
mdTemp.update(s.getBytes());
}
byte[] md = mdTemp.digest();
int j = md.length;
char str[] = new char[j * 2];
int k = 0;
for (int i = 0; i < j; i++) {
byte byte0 = md[i];
str[k++] = hexDigits[byte0 >>> 4 & 0xf];
str[k++] = hexDigits[byte0 & 0xf];
}
return new String(str).toUpperCase();
} catch (Exception e) {
return null;
}
}
/**
* <p>
* 生成token
* </p>
* @author caoshiyan
* @version V1.0
* @date 2015年11月18日 下午6:28:01
* @param url GET请求URL带参数串POST请求URL不带参数串参数以JSON格式传入paramJson
* @param paramJson POST参数JSON格式
* @param secret 加密secret
* @return String 生成的token值
*
* @modificationHistory=========================逻辑或功能性重大变更记录
* @modify by user: {修改人} 2015年11月18日
* @modify by reason:{方法名}:{原因}
* @since
*/
public final static String buildToken(String url, String paramJson, String secret) {
String tempUrl = null;
tempUrl = url.substring("http://".length());
int index = tempUrl.indexOf("/");
String URI = tempUrl.substring(index);
String[] ss = URI.split("\\?");
if (ss.length > 1) {
return md5(ss[0] + ss[1] + secret);
} else {
return md5(ss[0] + paramJson + secret);
}
}
public static void main(String[] args) {
System.out.println(md5("/webapi/service/vss/getPlatEncodeDeviceResList{\"pageNo\":1,\"pageSize\":1000,\"appkey\":\"8a3018ac\",\"time\":1610594097178}69befa1eca0644af8000fd23d7b8c0f7"));
}
}
///webapi/service/vss/getPlatEncodeDeviceResList{"pageNo":1,"pageSize":1000,"appkey":"8a3018ac","time":1610594044620}69befa1eca0644af8000fd23d7b8c0f7

View File

@@ -0,0 +1,332 @@
package com.saye.hospitalgd.commons.date;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
public class DateDUtil {
public static String yyyy_MM_dd = "yyyy-MM-dd";
public static String yyyyMMdd = "yyyyMMdd";
public static String yyyyMM = "yyyyMM";
public static String yyyy_MM = "yyyy-MM";
public static String yyyy_MM_dd_HH_00 = "yyyy-MM-dd HH:00";
public static String yyyy_MM_dd_HH_mm = "yyyy-MM-dd HH:mm";
public static String yyyy_MM_dd_HH_mm_ss = "yyyy-MM-dd HH:mm:ss";
public static String yyyy_MM_dd_HH_mm_ss_SS = "yyyy-MM-dd HH:mm:ss.SS";
public static String yyyyMMddHHmm = "yyyyMMddHHmm";
public static String yyyyMMddHHmmss = "yyyyMMddHHmmss";
public static String yyyyMMddHHmmssSS = "yyyyMMddHHmmssSS";
public static String yyyyMMddHHmmssSSS = "yyyyMMddHHmmssSSS";
public static String yyMMdd = "yyMMdd";
public static String yyyy_MM_dd_00_00 = "yyyy-MM-dd 00:00";
public static String yyyyMMddHH_mm_ss = "yyyyMMddHH:mm:ss";
/**
* 将字符串时间改成Date类型
* @param format
* @param dateStr
* @return
*/
public static Date strToDate(String format,String dateStr) {
Date date = null;
try {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(format);
date = simpleDateFormat.parse(dateStr);
} catch (ParseException e) {
e.printStackTrace();
}
return date;
}
/**
* 将Date时间转成字符串
* @param format
* @param date
* @return
*/
public static String DateToStr(String format,Date date){
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(format);
return simpleDateFormat.format(date);
}
/**
* 获取2个字符日期的天数差
* @param p_startDate
* @param p_endDate
* @return 天数差
*/
public static long getDaysOfTowDiffDate( String p_startDate, String p_endDate ){
Date l_startDate = DateDUtil.strToDate(DateDUtil.yyyy_MM_dd, p_startDate);
Date l_endDate = DateDUtil.strToDate(DateDUtil.yyyy_MM_dd, p_endDate);
long l_startTime = l_startDate.getTime();
long l_endTime = l_endDate.getTime();
long betweenDays = (long) ( ( l_endTime - l_startTime ) / ( 1000 * 60 * 60 * 24 ) );
return betweenDays;
}
/**
* 获取2个字符日期的天数差
* @param l_startDate
* @param l_endDate
* @return 天数差
*/
public static long getDaysOfTowDiffDate( Date l_startDate, Date l_endDate ){
long l_startTime = l_startDate.getTime();
long l_endTime = l_endDate.getTime();
long betweenDays = (long) ( ( l_endTime - l_startTime ) / ( 1000 * 60 * 60 * 24 ) );
return betweenDays;
}
/**
* 给出日期添加一段时间后的日期
* @param dateStr
* @param plus
* @return
*/
public static String getPlusDays(String format,String dateStr,long plus){
Date date = DateDUtil.strToDate(format, dateStr);
long time = date.getTime()+ plus*24*60*60*1000;
return DateDUtil.DateToStr(format,new Date(time));
}
/**
* 给出日期添加一段时间后的日期
* @param format
* @param date
* @param plus
* @return
*/
public static String getPlusDays(String format,Date date,long plus){
long time = date.getTime()+ plus*24*60*60*1000;
return DateDUtil.DateToStr(format,new Date(time));
}
/**
* 给出日期添加一段时间前的日期
* @param format
* @param date
* @param forth
* @return
*/
public static String getForthDays(String format,Date date,long forth){
long time = date.getTime()- forth*24*60*60*1000;
return DateDUtil.DateToStr(format,new Date(time));
}
/**
* 给出时间添加几个小时后的时间
* @param format
* @param dateStr
* @param plus
* @return
*/
public static String getPlusHours(String format,String dateStr,long plus){
Date date = DateDUtil.strToDate(format, dateStr);
long time = date.getTime()+ plus*60*60*1000;
return DateDUtil.DateToStr(format,new Date(time));
}
/**
* 给出时间添加几个分钟后的时间
* @param format
* @param dateStr
* @param plus
* @return
*/
public static String getPlusMinutes(String format,String dateStr,long plus){
Date date = DateDUtil.strToDate(format, dateStr);
long time = date.getTime()+ plus*60*1000;
return DateDUtil.DateToStr(format,new Date(time));
}
/**
* 得到当前时间格式如yyyy-MM-dd HH:mm:ss:SS
* @return
*/
public static String getCurrentTime(){
String nowTime = DateDUtil.DateToStr(DateDUtil.yyyy_MM_dd_HH_mm_ss_SS, new Date());
return nowTime;
}
/**
* 得到当前时间格式如yyyy-MM-dd HH:mm:ss
* @return
*/
public static String getTheCurrentTime(){
String nowTime = DateDUtil.DateToStr(DateDUtil.yyyy_MM_dd_HH_mm_ss, new Date());
return nowTime;
}
/**
* 得到当前日期格式如yyyyMMdd
* @return
*/
public static String getCurrentDate(){
String nowDate = DateDUtil.DateToStr(DateDUtil.yyyyMMdd, new Date());
return nowDate;
}
/**
* 得到当前日期格式如yyyyMMdd
* @return
*/
public static String getCurrentDate(String format){
String nowDate = DateDUtil.DateToStr(format, new Date());
return nowDate;
}
/**
* 获取2个字符日期的分钟数差
* @param p_startDate
* @param p_endDate
* @return 相差的分钟
*/
public static long getMinutesOfTowDiffDate(String p_startDate, String p_endDate ){
Date l_startDate = DateDUtil.strToDate(DateDUtil.yyyy_MM_dd_HH_mm_ss_SS, p_startDate);
Date l_endDate = DateDUtil.strToDate(DateDUtil.yyyy_MM_dd_HH_mm_ss_SS, p_endDate);
long l_startTime = l_startDate.getTime();
long l_endTime = l_endDate.getTime();
long betweenMinutes = (long) ( ( l_endTime - l_startTime ) / ( 1000 * 60) );
return betweenMinutes;
}
/**
* 获取2个字符日期的分钟数差
* @param p_startDate
* @param p_endDate
* @return 相差的分钟
*/
public static long getMinutesOfTowDiffDateMin(String format,String p_startDate, String p_endDate ){
Date l_startDate = DateDUtil.strToDate(format, p_startDate);
Date l_endDate = DateDUtil.strToDate(format, p_endDate);
long l_startTime = l_startDate.getTime();
long l_endTime = l_endDate.getTime();
long betweenMinutes = (long) ( ( l_endTime - l_startTime ) / ( 1000 * 60) );
return betweenMinutes;
}
public static long getMonthIntervalOfTowDiffDate(String p_startMonth, String p_endMonth){
Date l_startDate = DateDUtil.strToDate(DateDUtil.yyyy_MM, p_startMonth);
Date l_endDate = DateDUtil.strToDate(DateDUtil.yyyy_MM, p_endMonth);
Calendar calender = Calendar.getInstance();
calender.setTime(l_startDate);
long l_startMonth = calender.get(Calendar.MONTH)+1;
long l_startYear = calender.get(Calendar.YEAR);
calender.setTime(l_endDate);
long l_endMonth =calender.get(Calendar.MONTH)+1;
long l_endYear = calender.get(Calendar.YEAR);
long betweenYear = l_endYear - l_startYear;
long betweenMonth = (long) ( l_endMonth - l_startMonth ) ;
return betweenYear * 12 + betweenMonth;
}
/**
* 将字符串日期转为cron表达式
*/
public static String getCron(String execute_time) throws Exception{
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(yyyy_MM_dd_HH_mm_ss);
Date date = simpleDateFormat.parse(execute_time);
SimpleDateFormat dateFormat = new SimpleDateFormat("ss mm HH dd MM ? yyyy");
return dateFormat.format(date);
}
/**
* 获取当前年月日日期
*/
public static String getCDate(){
Calendar now = Calendar.getInstance();
String year=now.get(Calendar.YEAR)+"";
String month=(now.get(Calendar.MONTH) + 1) + "";
String day=now.get(Calendar.DAY_OF_MONTH)+"";
if ((now.get(Calendar.MONTH) + 1) < 10) month = "0" + month;
if (now.get(Calendar.DAY_OF_MONTH) < 10) day= "0" + day;
String nowDate = year+""+month+""+day+"";
return nowDate;
}
/**
* 获取两个日期字符串之间的日期集合
* @param startTime:String
* @param endTime:String
* @return list:yyyy-MM-dd
*/
public static List<String> getBetweenDate(String startTime, String endTime){
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
// 声明保存日期集合
List<String> list = new ArrayList<String>();
try {
// 转化成日期类型
Date startDate = sdf.parse(startTime);
Date endDate = sdf.parse(endTime);
//用Calendar 进行日期比较判断
Calendar calendar = Calendar.getInstance();
while (startDate.getTime()<=endDate.getTime()){
// 把日期添加到集合
list.add(sdf.format(startDate));
// 设置日期
calendar.setTime(startDate);
//把日期增加一天
calendar.add(Calendar.DATE, 1);
// 获取增加后的日期
startDate=calendar.getTime();
}
} catch (ParseException e) {
e.printStackTrace();
}
return list;
}
}

View File

@@ -0,0 +1,31 @@
package com.saye.hospitalgd.commons.encrypt;
import org.apache.commons.codec.binary.Base64;
import javax.crypto.Cipher;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;
public class EncryptUtil {
// AES ecb模式解密 key:秘钥 initVector:偏移量 encrypted加密内容
public static String decrypt(String key,String initVector,String encrypted) {
try {
IvParameterSpec iv = new IvParameterSpec(initVector.getBytes("UTF-8"));
SecretKeySpec skeySpec = new SecretKeySpec(key.getBytes("UTF-8"), "AES");
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5PADDING");
cipher.init(Cipher.DECRYPT_MODE, skeySpec, iv);
byte[] original = cipher.doFinal(Base64.decodeBase64(encrypted));
return new String(original);
} catch (Exception ex) {
ex.printStackTrace();
}
return null;
}
public static void main(String[] args) throws Exception {
System.out.println(decrypt("a6xdabhysfescfbu","encryptionIntVec","oYzamqnnyJ8GG6646PDYBQ=="));
}
}

View File

@@ -0,0 +1,37 @@
package com.saye.hospitalgd.commons.entity;
import java.util.List;
public class DepartEntity {
private String id;
private String title;
private boolean spread;
private List<DepartEntity> children;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public boolean isSpread() {
return spread;
}
public void setSpread(boolean spread) {
this.spread = spread;
}
public List<DepartEntity> getChildren() {
return children;
}
public void setChildren(List<DepartEntity> children) {
this.children = children;
}
}

View File

@@ -0,0 +1,37 @@
package com.saye.hospitalgd.commons.entity;
import java.util.List;
public class RoleEntity {
private String id;
private String title;
private boolean spread;
private List<RoleEntity> children;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public boolean isSpread() {
return spread;
}
public void setSpread(boolean spread) {
this.spread = spread;
}
public List<RoleEntity> getChildren() {
return children;
}
public void setChildren(List<RoleEntity> children) {
this.children = children;
}
}

View File

@@ -0,0 +1,785 @@
package com.saye.hospitalgd.commons.excel;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.poi.hssf.usermodel.*;
import org.apache.poi.hssf.util.HSSFColor;
import org.apache.poi.ss.util.CellRangeAddress;
import javax.servlet.http.HttpServletResponse;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.math.BigDecimal;
import java.sql.Date;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.*;
public class ExportXLS implements IExport ,ISetExport{
Log logger = LogFactory.getLog(this.getClass());
public final static short ROWHEIGHT = 20; /*行高*/
public final static double PAGEMARGIN = 0.1;/*页边距*/
public final static short TITLESIZE = 16;/*标题文字大小*/
public final static short HEADERSIZE = 12;/*列头文字大小*/
public final static short DATA_CHARACTERSIZE = 9;/*汉字大小*/
public final static short DATA_NUMSIZE = 9;/*数字大小*/
public final static short DATA_DATESIZE = 9;/*日期大小*/
public final static String ALIGN_LEFT = "LEFT";/*水平居左*/
public final static String ALIGN_RIGHT = "RIGHT";/*水平居右*/
public final static String ALIGN_CENTER = "CENTER";/*水平居右*/
public final static String VERTICAL_TOP = "TOP";/*垂直居上*/
public final static String VERTICAL_CENTER = "MIDDLE";/*垂直居中*/
public final static String VERTICAL_BOTTOM = "BOTTOM";/*垂直居下*/
public final static short A4 = HSSFPrintSetup.A4_PAPERSIZE;
public final static short A5 = HSSFPrintSetup.A5_PAPERSIZE;
public final static short A3 = 8;
public final static String MERGEDEND = "_mergedend_";//表示合并次单元格
private List<Object> data;
private Object[] statisticData;
private String titleName;
private short titleHeight = 500;
private short headerHeight = 300;
private short cellHeight = 300;
private HSSFWorkbook wb;
private HSSFSheet sheet;
private HSSFCellStyle headerCellStyle;
private HSSFCellStyle cellStyle;
private String[] header;
private String[] subHeader;
private String[] width;
private String[] sqlKey;
private IConversionByExport conversion;
private List<int[]> mergeRanges = new ArrayList<int[]>();
private Boolean isHeaderMergeTwo = Boolean.FALSE;
private int headerRowIndex = 1;
private int subHeaderRowIndex = 2;
private int titleMergeColumnIndex = 0;
private HashMap<Integer, Integer> modifiedDataHeightHM = new HashMap<Integer, Integer>(); //要修改的数据行的高度
private short subHeaderHeight = 300;
private Boolean isCreateFreezePane = true;
private HashMap<Integer, Integer> skipedDataIndexMap; //要空行的数据列序号:KEY为data的序号 VALUE默认为1
private List<HashMap<Integer, Integer>> resetCellStyleList = new ArrayList<HashMap<Integer,Integer>>(); //要重新设置样式的单元格:KEY为行号,VALUE为列号
private HSSFCellStyle resetCellStyle;
/**
*
*构造函数:得到一个纵向打印在A4纸上的xls
*
*/
public ExportXLS(String[] header){
this.wb = new HSSFWorkbook();
this.sheet = this.createSheet(false, ExportXLS.A4);
this.headerCellStyle = this.createCellStyle(ExportXLS.ALIGN_CENTER, VERTICAL_CENTER, 1111, HEADERSIZE, new HSSFColor.GREY_25_PERCENT().getIndex());
this.cellStyle = this.createCellStyle(ExportXLS.ALIGN_CENTER, VERTICAL_CENTER, 1111, HEADERSIZE, new HSSFColor.WHITE().getIndex());
this.setTitleName("export");
this.setHeader(header);
}
/**
* 设置打印纸大小,横向还是纵向
* @param header
* @param sqlKey
* @param pageSize
* @param landscapeFlag
*/
public ExportXLS(String[] header,String[] sqlKey,Short pageSize,boolean landscapeFlag){
this.wb = new HSSFWorkbook();
this.sheet = this.createSheet(landscapeFlag, pageSize);
this.headerCellStyle = this.createCellStyle(ExportXLS.ALIGN_CENTER, VERTICAL_CENTER, 1111, HEADERSIZE, new HSSFColor.GREY_25_PERCENT().getIndex());
HSSFFont titlefont = this.wb.createFont(); //设置字体
titlefont.setFontHeightInPoints(ExportXLS.HEADERSIZE);
titlefont.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
headerCellStyle.setFont(titlefont);
this.cellStyle = this.createCellStyle(ExportXLS.ALIGN_CENTER, VERTICAL_CENTER, 1111, HEADERSIZE, new HSSFColor.WHITE().getIndex());
this.setTitleName("export");
this.setHeader(header);
this.setSqlKey(sqlKey);
}
private void setHeader(String[] header){
this.header = header;
//默认设置每个单元格的宽度为3500
int length = this.header.length;
this.width = new String[length];
for(int i=0;i<length;i++){
this.width[i] = "3500";
}
}
public void setSqlKey(String[] sqlKey) {
this.sqlKey = sqlKey;
}
/**
* 创建工作簿
* @param
* @param landscapeFlag 横向标记 // true横向 false纵向
* @param pageSize 纸张大小
* @return
*/
private HSSFSheet createSheet(boolean landscapeFlag,Short pageSize) {
HSSFPrintSetup ps = null;
HSSFSheet sheet = null;
sheet = this.wb.createSheet();
sheet.setHorizontallyCenter(true);
sheet.setMargin(HSSFSheet.LeftMargin,PAGEMARGIN); //设置页边距
sheet.setMargin(HSSFSheet.RightMargin,PAGEMARGIN);
sheet.setMargin(HSSFSheet.TopMargin,PAGEMARGIN*3);
sheet.setMargin(HSSFSheet.BottomMargin,PAGEMARGIN*3);
ps = sheet.getPrintSetup();
ps.setLandscape(landscapeFlag);
ps.setPaperSize(pageSize);
return sheet;
}
/**
* 创建单元格格式
*/
private HSSFCellStyle createCellStyle(String alignPosition,String verticalPosotion,Integer border,short fontSize,short color) {
HSSFCellStyle cellStyle = wb.createCellStyle();
/*
* 设置水平位置
*/
if(alignPosition.equals(ALIGN_LEFT)){
cellStyle.setAlignment(HSSFCellStyle.ALIGN_LEFT);
}
if(alignPosition.equals(ALIGN_RIGHT)){
cellStyle.setAlignment(HSSFCellStyle.ALIGN_RIGHT);
}
if(alignPosition.equals(ALIGN_CENTER)){
cellStyle.setAlignment(HSSFCellStyle.ALIGN_CENTER);
}
/*
* 设置垂直位置
*/
if(alignPosition.equals(VERTICAL_TOP)){
cellStyle.setAlignment(HSSFCellStyle.VERTICAL_TOP);
}
if(alignPosition.equals(VERTICAL_CENTER)){
cellStyle.setAlignment(HSSFCellStyle.VERTICAL_CENTER);
}
if(alignPosition.equals(VERTICAL_BOTTOM)){
cellStyle.setAlignment(HSSFCellStyle.VERTICAL_BOTTOM);
}
/*
* 设置边框
*/
if((border/1000)%10==1){
cellStyle.setBorderTop(HSSFCellStyle.BORDER_THIN);// 上边框
}
if((border/100)%10==1){
cellStyle.setBorderRight(HSSFCellStyle.BORDER_THIN);// 右边框
}
if((border/10)%10==1){
cellStyle.setBorderBottom(HSSFCellStyle.BORDER_THIN);// 下边框
}
if(border%10==1){
cellStyle.setBorderLeft(HSSFCellStyle.BORDER_THIN);// 左边框
}
/*
* 设置字体大小
*/
HSSFFont font = wb.createFont();
font.setFontHeightInPoints(fontSize);// 字体大小
cellStyle.setFont(font);
/*
* 设置背景色
*/
cellStyle.setFillForegroundColor(color);
cellStyle.setFillBackgroundColor(color);
cellStyle.setFillPattern(HSSFCellStyle.SPARSE_DOTS);
/*
* 自动换行
*/
cellStyle.setWrapText(true);
return cellStyle;
}
/**
* 根据不同的类型给cell赋值
*
* @param data 数据
* @param cell
* @throws SQLException
*/
private void obtainPropList(Object data, HSSFCell cell){
if(data == null){
data = "";
}
String type = data.getClass().getName();
if(type.equalsIgnoreCase("java.lang.String")) {
String value = (String)data;
cell.setCellValue(new HSSFRichTextString(value));
}else if(type.equalsIgnoreCase("java.lang.Integer") || type.equalsIgnoreCase("int")) {
int value = (Integer)data;
cell.setCellValue(value);
}else if(type.equalsIgnoreCase("java.lang.Long") || type.equalsIgnoreCase("long")) {
long value = (Long)data;
cell.setCellValue(value);
}else if(type.equalsIgnoreCase("java.lang.Float") || type.equalsIgnoreCase("float")){
float value = (Float)data;
cell.setCellValue(value);
}else if(type.equalsIgnoreCase("java.lang.Double") || type.equalsIgnoreCase("double")){
double value = (Double)data;
cell.setCellValue(value);
}else if(type.equalsIgnoreCase("java.lang.Byte") || type.equalsIgnoreCase("byte")) {
byte value = (Byte)data;
cell.setCellValue(value);
}else if(type.equalsIgnoreCase("java.lang.Character") || type.equalsIgnoreCase("char")) {
char value = (Character)data;
cell.setCellValue(value);
}else if(type.equalsIgnoreCase("java.lang.Boolean") || type.equalsIgnoreCase("boolean")) {
boolean value = (Boolean)data;
cell.setCellValue(value);
}else if(type.equalsIgnoreCase("java.math.BigDecimal")) {
BigDecimal value = (BigDecimal)data;
cell.setCellValue(value.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
}else if(type.equalsIgnoreCase("java.util.Date")) {
Date value = (Date)data;
cell.setCellValue(value);
}else if(type.equalsIgnoreCase("java.sql.Timestamp")) {
Timestamp timestamp = (Timestamp)data;
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String value = dateFormat.format(timestamp.getTime());
cell.setCellValue(value);
}else if(type.equalsIgnoreCase("java.lang.Short") || type.equalsIgnoreCase("short")) {
short value = (Short)data;
cell.setCellValue(value);
}
}
private void fillSheet(){
int addRowNum = 1;
if(!isHeaderMergeTwo){
addRowNum = 0;
}
if(isCreateFreezePane){
sheet.createFreezePane(0,this.headerRowIndex + addRowNum + 1);
}
//设置行宽
for(int i=0;i<this.width.length;i++){
this.sheet.setColumnWidth(i,Integer.parseInt(this.width[i]));
}
//填入抬头数据
HSSFRow titleRow = this.sheet.createRow(0);
titleRow.setHeight(this.titleHeight);
HSSFCell titleCell = titleRow.createCell(0);
titleCell.setCellValue(new HSSFRichTextString(this.titleName));
HSSFCellStyle titleCellStyle = this.wb.createCellStyle(); //设置单元格style
titleCellStyle.setAlignment(HSSFCellStyle.ALIGN_CENTER);
titleCellStyle.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);
HSSFFont titlefont = this.wb.createFont(); //设置字体
titlefont.setFontHeightInPoints(ExportXLS.TITLESIZE);
titlefont.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
titleCellStyle.setFont(titlefont);
titleCellStyle.setWrapText(true);
titleCell.setCellStyle(titleCellStyle);
if(0 == this.titleMergeColumnIndex){
this.titleMergeColumnIndex = this.header.length-1;
}
this.sheet.addMergedRegion(new CellRangeAddress(0,addRowNum,0,this.titleMergeColumnIndex));
//填入标题数据
HSSFRow headerRow = this.sheet.createRow(this.headerRowIndex);
headerRow.setHeight(this.headerHeight);
for(int i=0;i<this.header.length;i++){
HSSFCell headerCell = headerRow.createCell(i);
headerCell.setCellStyle(this.headerCellStyle);
this.obtainPropList(this.header[i], headerCell);
}
Integer dataBeginIndex = this.headerRowIndex + 1;
if(null != subHeader && 0 != subHeader.length){
if(this.subHeader.length > this.header.length){
for (int i = this.header.length; i < this.subHeader.length; i++) {
HSSFCell headerCell = headerRow.createCell(i);
headerCell.setCellStyle(this.headerCellStyle);
headerCell.setCellValue("");
}
}
//填入副标题数据
HSSFRow subHeaderRow = this.sheet.createRow(this.subHeaderRowIndex);
subHeaderRow.setHeight(this.subHeaderHeight);
for(int i=0;i<this.subHeader.length;i++){
HSSFCell headerCell = subHeaderRow.createCell(i);
headerCell.setCellStyle(this.headerCellStyle);
this.obtainPropList(this.subHeader[i], headerCell);
}
if(isCreateFreezePane){
this.sheet.createFreezePane(0,this.subHeaderRowIndex+1);
}
dataBeginIndex++;
}
//填入数据
if(this.data != null){
for(int i=0;i<this.data.size();i++){
Boolean tf = true;
if(null != skipedDataIndexMap){
if(!skipedDataIndexMap.isEmpty() && null != skipedDataIndexMap.get(i)){
tf = false;
}
}
if(tf){
//将数据转为数组类型数据
Object[] array = null;
//如果不存在转换对象,则使用默认的转换方法
if(this.conversion != null){
array = this.conversion.conversion(this.data.get(i), this.sqlKey);
}else{
array = this.conversion(this.data.get(i));
}
HSSFRow dataRow = this.sheet.createRow(dataBeginIndex+i);
dataRow.setHeight(this.cellHeight);
if(null != this.modifiedDataHeightHM){
Integer rowHeight = this.modifiedDataHeightHM.get(i);
if(null != rowHeight){
dataRow.setHeight(Short.valueOf(rowHeight.toString()));
}
}
for(int j=0;j<array.length;j++){
HSSFCell dataCell = dataRow.createCell(j);
dataCell.setCellStyle(this.cellStyle);
this.obtainPropList(array[j],dataCell);
}
}else {
HSSFRow dataRow = this.sheet.createRow(dataBeginIndex+i);
}
}
}
if(null != resetCellStyleList && !resetCellStyleList.isEmpty()){
int len = resetCellStyleList.size();
for (int i = 0; i < len; i++) {
HashMap<Integer, Integer> resetCellStyleHM = resetCellStyleList.get(i);
Iterator<Map.Entry<Integer, Integer>> it = resetCellStyleHM.entrySet().iterator();
while (it.hasNext()) {
Map.Entry<Integer, Integer> entry = it.next();
Integer rowIndex = entry.getKey();
Integer columnIndex = entry.getValue();
this.sheet.getRow(rowIndex).getCell(columnIndex).setCellStyle(this.resetCellStyle);
}
}
}
//设置合并开始标识
boolean mergedStartFlag = false;
int[] startAndEnd = null;
List mergedIndex = new ArrayList();
if(null != this.statisticData){
//追加统计行
HSSFRow appendRow = this.sheet.createRow(this.sheet.getLastRowNum()+1);
for(int i=0;i<this.statisticData.length;i++){
//记录合并开始位置
if(!mergedStartFlag){
mergedStartFlag = true;
startAndEnd = new int[2];
startAndEnd[0] = i;
}
//记录合并结束位置
if(ExportXLS.MERGEDEND.equals(this.statisticData[i]) && mergedStartFlag){
mergedStartFlag = false;
startAndEnd[1] = i;
mergedIndex.add(startAndEnd);
}
//生成单元格,如果是合并单元格,内容置空
HSSFCell dataCell = appendRow.createCell(i);
dataCell.setCellStyle(this.cellStyle);
if(!ExportXLS.MERGEDEND.equals(this.statisticData[i])){
this.obtainPropList(this.statisticData[i],dataCell);
}
}
}
//根据合并位置记录 合并单元格
for(int i=0;i<mergedIndex.size();i++){
startAndEnd = (int[])mergedIndex.get(i);
this.sheet.addMergedRegion(new CellRangeAddress(this.sheet.getLastRowNum(),this.sheet.getLastRowNum(),startAndEnd[0],startAndEnd[1]));
}
//处理要合并的单元格区域
if(null != this.mergeRanges && 0 != this.mergeRanges.size()){
for (int i = 0; i < this.mergeRanges.size(); i++) {
int[] ranges = this.mergeRanges.get(i);
this.sheet.addMergedRegion(new CellRangeAddress(ranges[0], ranges[1], ranges[2], ranges[3]));
}
}
}
/**
* 默认数据转换方法(只转换数组类型对象)
* @return
*/
private Object[] conversion(Object obj){
try {
return (Object[])obj;
} catch (ClassCastException e) {
if(this.logger.isErrorEnabled()){
this.logger.error("导出工具转换数据对象错误!要转换的数据不是数组型的!");
}
}
return null;
}
/* (非 Javadoc
* @see com.saye.common.export.IEport#setConversion(IConversionByExport conversion)
*/
public void setConversion(IConversionByExport conversion){
this.conversion = conversion;
}
/* (非 Javadoc
* @see com.saye.common.export.IEport#setTitleName(java.lang.String)
*/
public void setTitleName(String titleName){
this.titleName = titleName;
}
/* (非 Javadoc
* @see com.saye.common.export.IEport#modifyHeader(java.lang.String, int)
*/
public void modifyHeader(String header, int index){
this.header[index] = header;
}
/* (非 Javadoc
* @see com.saye.common.export.IEport#modifyWidthOfHeader(java.lang.String, int)
*/
public void modifyWidthOfHeader(String width, int index){
this.width[index] = width;
}
/* (非 Javadoc
* @see com.saye.common.export.IEport#setData(java.util.List)
*/
public void setData(List<Object> dataList){
this.data = dataList;
}
/* (非 Javadoc
* @see com.saye.common.export.IEport#appendStatisticRow(Object StatisticData)
*/
public void appendStatisticRow(Object statisticData) {
//如果不存在转换对象,则使用默认的转换方法
if(this.conversion != null){
this.statisticData = this.conversion.conversion(statisticData, this.sqlKey);
}else{
this.statisticData = this.conversion(statisticData);
}
}
/* (非 Javadoc
* @see com.saye.common.export.IEport#returnClientDownload(javax.servlet.http.HttpServletResponse)
*/
public void returnClientDownload(HttpServletResponse response) throws IOException{
//将数据装填到sheet中
this.fillSheet();
response.reset();
response.setContentType("application/vnd.ms-excel");
response.setHeader("Content-Disposition","attachment; filename=" + new String(this.titleName.getBytes("gb2312"),"ISO8859-1")+".xls");
OutputStream os = null;
try {
os = response.getOutputStream();
this.wb.write(os);
} catch (Exception e) {
} finally {
if(os != null) {
os.close();
os = null;
}
}
}
/* (非 Javadoc
* @see com.saye.common.export.IEport#returnClientOpen(javax.servlet.http.HttpServletResponse)
*/
public void returnClientOpen(HttpServletResponse response) throws IOException{
//将数据装填到sheet中
this.fillSheet();
response.reset();
response.setContentType("application/vnd.ms-excel");
response.setHeader("Content-Disposition","online; filename=" + new String(this.titleName.getBytes("gb2312"),"ISO8859-1")+".xls");
try {
wb.write(response.getOutputStream());
} catch (Exception e) {
e.printStackTrace();
}
}
/* (非 Javadoc
* @see com.saye.common.export.IEport#modifTitleHeight(short height)
*/
public void modifTitleHeight(short height) {
this.titleHeight = height;
}
/**
* 设置副标题
* @param subHeader
*/
public void setSubHeader(String[] subHeader){
this.subHeader = subHeader;
//默认设置每个单元格的宽度为3500
int headerLength = this.header.length;
int subHeaderLength = 0;
if(null != subHeader && 0 != subHeader.length){
subHeaderLength = this.subHeader.length;
}
int length = headerLength > subHeaderLength ? headerLength : subHeaderLength;
this.width = new String[length];
for(int i=0;i<length;i++){
this.width[i] = "3500";
}
}
/**
* 设置要合并的单元格区域
* @param firstRow 开始行
* @param lastRow 结束行
* @param firstCol 开始列
* @param lastCol 结束列
*/
public void setMergeRange(int firstRow, int lastRow, int firstCol, int lastCol){
int[] range = new int[4];
range[0] = firstRow;
range[1] = lastRow;
range[2] = firstCol;
range[3] = lastCol;
this.mergeRanges.add(range);
}
/*
*
*/
public void execGenerateExcel(String exportFilePath) throws IOException{
//将数据装填到sheet中
this.fillSheet();
// 设置输入流
FileOutputStream fOut = new FileOutputStream(exportFilePath);
// 将模板的内容写到输出文件上
wb.write(fOut);
fOut.flush();
// 操作结束,关闭文件
fOut.close();
}
/**
* 设置头部高度
* @param height
*/
public void modifyHeaderHeight(short height) {
this.headerHeight = height;
}
/**
* 设置头部标题所处行序号
* @param headerRowIndex
*/
public void modifyHeaderRowIndex(short headerRowIndex) {
this.headerRowIndex = headerRowIndex;
}
/**
* 设置头部副标题序号
* @param subHeaderRowIndex
*/
public void modifySubHeaderRowIndex(short subHeaderRowIndex) {
this.subHeaderRowIndex = subHeaderRowIndex;
}
/**
* 设置标题合并列号
* @param titleMergeColumnIndex
*/
public void setTitleMergeColumnIndex(int titleMergeColumnIndex) {
this.titleMergeColumnIndex = titleMergeColumnIndex;
}
/**
* 设置数据行高
* @param modifiedDataHeightHM数据序号和行高
*/
public void setModifiedDataHeightHM(HashMap<Integer, Integer> modifiedDataHeightHM) {
this.modifiedDataHeightHM = modifiedDataHeightHM;
}
/**
* 设置头部副标题高度
* @param subHeaderHeight
*/
public void modifySubHeaderHeight(short subHeaderHeight) {
this.subHeaderHeight = subHeaderHeight;
}
/**
* 设置是否创建冻结窗体
* @param isCreateFreezePane
*/
public void setIsCreateFreezePane(Boolean isCreateFreezePane) {
this.isCreateFreezePane = isCreateFreezePane;
}
/**
* 设置要空行的数据列序号
* @param skipedDataIndexMap
*/
public void setSkipedDataIndexMap(HashMap<Integer, Integer> skipedDataIndexMap) {
this.skipedDataIndexMap = skipedDataIndexMap;
}
/**
* 设置 重新设置样式的单元格序号及样式:样式为空时,默认为头部标题样式
* @param resetCellStyleList
* @param resetCellStyle
*/
public void resetCellForCellStyle(List<HashMap<Integer, Integer>> resetCellStyleList, HSSFCellStyle resetCellStyle) {
this.resetCellStyleList = resetCellStyleList;
if(null == resetCellStyle){
resetCellStyle = this.headerCellStyle;
}
this.resetCellStyle = resetCellStyle;
}
/**
* 设置 工作薄 密码保护
* @param pwd
*/
public void protectSheet(String pwd) {
this.sheet.protectSheet(pwd);
}
/**
* 设定抬头是否合并两行:在new ExportXLS之后就SET
* @param isHeaderMergeTwo
*/
public void setIsHeaderMergeTwo(Boolean isHeaderMergeTwo) {
this.isHeaderMergeTwo = isHeaderMergeTwo;
if(!this.isHeaderMergeTwo){
this.headerRowIndex = 1;
this.subHeaderRowIndex = 2;
}
}
}

View File

@@ -0,0 +1,790 @@
package com.saye.hospitalgd.commons.excel;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.xssf.usermodel.*;
import javax.servlet.http.HttpServletResponse;
import java.awt.*;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.math.BigDecimal;
import java.sql.Date;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.List;
import java.util.*;
public class ExportXLSX implements IExport ,ISetExport{
Log logger = LogFactory.getLog(this.getClass());
public final static short ROWHEIGHT = 20; /*行高*/
public final static double PAGEMARGIN = 0.1;/*页边距*/
public final static short TITLESIZE = 16;/*标题文字大小*/
public final static short HEADERSIZE = 12;/*列头文字大小*/
public final static short DATA_CHARACTERSIZE = 9;/*汉字大小*/
public final static short DATA_NUMSIZE = 9;/*数字大小*/
public final static short DATA_DATESIZE = 9;/*日期大小*/
public final static String ALIGN_LEFT = "LEFT";/*水平居左*/
public final static String ALIGN_RIGHT = "RIGHT";/*水平居右*/
public final static String ALIGN_CENTER = "CENTER";/*水平居右*/
public final static String VERTICAL_TOP = "TOP";/*垂直居上*/
public final static String VERTICAL_CENTER = "MIDDLE";/*垂直居中*/
public final static String VERTICAL_BOTTOM = "BOTTOM";/*垂直居下*/
public final static short A4 = XSSFPrintSetup.A4_PAPERSIZE;
public final static short A5 = XSSFPrintSetup.A5_PAPERSIZE;
public final static short A3 = 8;
public final static String MERGEDEND = "_mergedend_";//表示合并次单元格
private List<Object> data;
private Object[] statisticData;
private String titleName;
private short titleHeight = 500;
private short headerHeight = 300;
private short cellHeight = 300;
private XSSFWorkbook wb;
private XSSFSheet sheet;
private XSSFCellStyle headerCellStyle;
private XSSFCellStyle cellStyle;
private String[] header;
private String[] subHeader;
private String[] width;
private String[] sqlKey;
private IConversionByExport conversion;
private List<int[]> mergeRanges = new ArrayList<int[]>();
private Boolean isHeaderMergeTwo = Boolean.FALSE;
private int headerRowIndex = 1;
private int subHeaderRowIndex = 2;
private int titleMergeColumnIndex = 0;
private HashMap<Integer, Integer> modifiedDataHeightHM = new HashMap<Integer, Integer>(); //要修改的数据行的高度
private short subHeaderHeight = 300;
private Boolean isCreateFreezePane = true;
private HashMap<Integer, Integer> skipedDataIndexMap; //要空行的数据列序号:KEY为data的序号 VALUE默认为1
private List<HashMap<Integer, Integer>> resetCellStyleList = new ArrayList<HashMap<Integer,Integer>>(); //要重新设置样式的单元格:KEY为行号,VALUE为列号
private XSSFCellStyle resetCellStyle;
/**
*
*构造函数:得到一个纵向打印在A4纸上的xlsx
*
*/
public ExportXLSX(String[] header){
this.wb = new XSSFWorkbook();
this.sheet = this.createSheet(false, ExportXLSX.A4);
this.headerCellStyle = this.createCellStyle(ExportXLSX.ALIGN_CENTER, VERTICAL_CENTER, 1111, HEADERSIZE, new XSSFColor(new Color(192, 192, 192)));
this.cellStyle = this.createCellStyle(ExportXLSX.ALIGN_CENTER, VERTICAL_CENTER, 1111, HEADERSIZE, new XSSFColor(new Color(255, 255, 255)));
this.setTitleName("export");
this.setHeader(header);
}
/**
* 设置打印纸大小,横向还是纵向
* @param header
* @param sqlKey
* @param pageSize
* @param landscapeFlag
*/
public ExportXLSX(String[] header,String[] sqlKey,Short pageSize,boolean landscapeFlag){
XSSFWorkbook x= new XSSFWorkbook();
this.wb = x;
this.sheet = this.createSheet(landscapeFlag, pageSize);
this.headerCellStyle = this.createCellStyle(ExportXLSX.ALIGN_CENTER, VERTICAL_CENTER, 1111, HEADERSIZE, new XSSFColor(new Color(192, 192, 192)));
XSSFFont titlefont = this.wb.createFont(); //设置字体
titlefont.setFontHeightInPoints(ExportXLSX.HEADERSIZE);
titlefont.setBoldweight(XSSFFont.BOLDWEIGHT_BOLD);
headerCellStyle.setFont(titlefont);
this.cellStyle = this.createCellStyle(ExportXLSX.ALIGN_CENTER, VERTICAL_CENTER, 1111, HEADERSIZE, new XSSFColor(new Color(255, 255, 255)));
this.setTitleName("export");
this.setHeader(header);
this.setSqlKey(sqlKey);
}
private void setHeader(String[] header){
this.header = header;
//默认设置每个单元格的宽度为3500
int length = this.header.length;
this.width = new String[length];
for(int i=0;i<length;i++){
this.width[i] = "3500";
}
}
public void setSqlKey(String[] sqlKey) {
this.sqlKey = sqlKey;
}
/**
* 创建工作簿
* @param landscapeFlag 横向标记 // true横向 false纵向
* @param pageSize 纸张大小
* @return
*/
private XSSFSheet createSheet(boolean landscapeFlag,Short pageSize) {
XSSFPrintSetup ps = null;
XSSFSheet sheet = null;
sheet = this.wb.createSheet();
sheet.setHorizontallyCenter(true);
sheet.setMargin(XSSFSheet.LeftMargin,PAGEMARGIN); //设置页边距
sheet.setMargin(XSSFSheet.RightMargin,PAGEMARGIN);
sheet.setMargin(XSSFSheet.TopMargin,PAGEMARGIN*3);
sheet.setMargin(XSSFSheet.BottomMargin,PAGEMARGIN*3);
ps = sheet.getPrintSetup();
ps.setLandscape(landscapeFlag);
ps.setPaperSize(pageSize);
return sheet;
}
/**
* 创建单元格格式
*/
private XSSFCellStyle createCellStyle(String alignPosition,String verticalPosotion,Integer border,short fontSize,XSSFColor color) {
XSSFCellStyle cellStyle = wb.createCellStyle();
/*
* 设置水平位置
*/
if(alignPosition.equals(ALIGN_LEFT)){
cellStyle.setAlignment(XSSFCellStyle.ALIGN_LEFT);
}
if(alignPosition.equals(ALIGN_RIGHT)){
cellStyle.setAlignment(XSSFCellStyle.ALIGN_RIGHT);
}
if(alignPosition.equals(ALIGN_CENTER)){
cellStyle.setAlignment(XSSFCellStyle.ALIGN_CENTER);
}
/*
* 设置垂直位置
*/
if(alignPosition.equals(VERTICAL_TOP)){
cellStyle.setAlignment(XSSFCellStyle.VERTICAL_TOP);
}
if(alignPosition.equals(VERTICAL_CENTER)){
cellStyle.setAlignment(XSSFCellStyle.VERTICAL_CENTER);
}
if(alignPosition.equals(VERTICAL_BOTTOM)){
cellStyle.setAlignment(XSSFCellStyle.VERTICAL_BOTTOM);
}
/*
* 设置边框
*/
if((border/1000)%10==1){
cellStyle.setBorderTop(XSSFCellStyle.BORDER_THIN);// 上边框
}
if((border/100)%10==1){
cellStyle.setBorderRight(XSSFCellStyle.BORDER_THIN);// 右边框
}
if((border/10)%10==1){
cellStyle.setBorderBottom(XSSFCellStyle.BORDER_THIN);// 下边框
}
if(border%10==1){
cellStyle.setBorderLeft(XSSFCellStyle.BORDER_THIN);// 左边框
}
/*
* 设置字体大小
*/
XSSFFont font = wb.createFont();
font.setFontHeightInPoints(fontSize);// 字体大小
cellStyle.setFont(font);
/*
* 设置背景色
*/
cellStyle.setFillForegroundColor(color);
cellStyle.setFillBackgroundColor(color);
cellStyle.setFillPattern(XSSFCellStyle.SPARSE_DOTS);
/*
* 自动换行
*/
cellStyle.setWrapText(true);
return cellStyle;
}
/**
* 根据不同的类型给cell赋值
*
* @param data 数据
* @param cell
* @throws SQLException
*/
private void obtainPropList(Object data, XSSFCell cell){
if(data == null){
data = "";
}
String type = data.getClass().getName();
if(type.equalsIgnoreCase("java.lang.String")) {
String value = (String)data;
cell.setCellValue(new XSSFRichTextString(value));
}else if(type.equalsIgnoreCase("java.lang.Integer") || type.equalsIgnoreCase("int")) {
int value = (Integer)data;
cell.setCellValue(value);
}else if(type.equalsIgnoreCase("java.lang.Long") || type.equalsIgnoreCase("long")) {
long value = (Long)data;
cell.setCellValue(value);
}else if(type.equalsIgnoreCase("java.lang.Float") || type.equalsIgnoreCase("float")){
float value = (Float)data;
cell.setCellValue(value);
}else if(type.equalsIgnoreCase("java.lang.Double") || type.equalsIgnoreCase("double")){
double value = (Double)data;
cell.setCellValue(value);
}else if(type.equalsIgnoreCase("java.lang.Byte") || type.equalsIgnoreCase("byte")) {
byte value = (Byte)data;
cell.setCellValue(value);
}else if(type.equalsIgnoreCase("java.lang.Character") || type.equalsIgnoreCase("char")) {
char value = (Character)data;
cell.setCellValue(value);
}else if(type.equalsIgnoreCase("java.lang.Boolean") || type.equalsIgnoreCase("boolean")) {
boolean value = (Boolean)data;
cell.setCellValue(value);
}else if(type.equalsIgnoreCase("java.math.BigDecimal")) {
BigDecimal value = (BigDecimal)data;
cell.setCellValue(value.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
}else if(type.equalsIgnoreCase("java.util.Date")) {
Date value = (Date)data;
cell.setCellValue(value);
}else if(type.equalsIgnoreCase("java.sql.Timestamp")) {
Timestamp timestamp = (Timestamp)data;
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String value = dateFormat.format(timestamp.getTime());
cell.setCellValue(value);
}else if(type.equalsIgnoreCase("java.lang.Short") || type.equalsIgnoreCase("short")) {
short value = (Short)data;
cell.setCellValue(value);
}
}
private void fillSheet(){
int addRowNum = 1;
if(!isHeaderMergeTwo){
addRowNum = 0;
}
if(isCreateFreezePane){
sheet.createFreezePane(0,this.headerRowIndex + addRowNum + 1);
}
//设置行宽
for(int i=0;i<this.width.length;i++){
this.sheet.setColumnWidth(i,Integer.parseInt(this.width[i]));
}
//填入抬头数据
XSSFRow titleRow = this.sheet.createRow(0);
titleRow.setHeight(this.titleHeight);
XSSFCell titleCell = titleRow.createCell(0);
titleCell.setCellValue(new XSSFRichTextString(this.titleName));
XSSFCellStyle titleCellStyle = this.wb.createCellStyle(); //设置单元格style
titleCellStyle.setAlignment(XSSFCellStyle.ALIGN_CENTER);
titleCellStyle.setVerticalAlignment(XSSFCellStyle.VERTICAL_CENTER);
XSSFFont titlefont = this.wb.createFont(); //设置字体
titlefont.setFontHeightInPoints(ExportXLSX.TITLESIZE);
titlefont.setBoldweight(XSSFFont.BOLDWEIGHT_BOLD);
titleCellStyle.setFont(titlefont);
titleCellStyle.setWrapText(true);
titleCell.setCellStyle(titleCellStyle);
if(0 == this.titleMergeColumnIndex){
this.titleMergeColumnIndex = this.header.length-1;
}
this.sheet.addMergedRegion(new CellRangeAddress(0,addRowNum,0,this.titleMergeColumnIndex));
//填入标题数据
XSSFRow headerRow = this.sheet.createRow(this.headerRowIndex);
headerRow.setHeight(this.headerHeight);
for(int i=0;i<this.header.length;i++){
XSSFCell headerCell = headerRow.createCell(i);
headerCell.setCellStyle(this.headerCellStyle);
this.obtainPropList(this.header[i], headerCell);
}
Integer dataBeginIndex = this.headerRowIndex + 1;
if(null != subHeader && 0 != subHeader.length){
if(this.subHeader.length > this.header.length){
for (int i = this.header.length; i < this.subHeader.length; i++) {
XSSFCell headerCell = headerRow.createCell(i);
headerCell.setCellStyle(this.headerCellStyle);
headerCell.setCellValue("");
}
}
//填入副标题数据
XSSFRow subHeaderRow = this.sheet.createRow(this.subHeaderRowIndex);
subHeaderRow.setHeight(this.subHeaderHeight);
for(int i=0;i<this.subHeader.length;i++){
XSSFCell headerCell = subHeaderRow.createCell(i);
headerCell.setCellStyle(this.headerCellStyle);
this.obtainPropList(this.subHeader[i], headerCell);
}
if(isCreateFreezePane){
this.sheet.createFreezePane(0,this.subHeaderRowIndex+1);
}
dataBeginIndex++;
}
//填入数据
if(this.data != null){
for(int i=0;i<this.data.size();i++){
Boolean tf = true;
if(null != skipedDataIndexMap){
if(!skipedDataIndexMap.isEmpty() && null != skipedDataIndexMap.get(i)){
tf = false;
}
}
if(tf){
//将数据转为数组类型数据
Object[] array = null;
//如果不存在转换对象,则使用默认的转换方法
if(this.conversion != null){
array = this.conversion.conversion(this.data.get(i), this.sqlKey);
}else{
array = this.conversion(this.data.get(i));
}
XSSFRow dataRow = this.sheet.createRow(dataBeginIndex+i);
dataRow.setHeight(this.cellHeight);
if(null != this.modifiedDataHeightHM){
Integer rowHeight = this.modifiedDataHeightHM.get(i);
if(null != rowHeight){
dataRow.setHeight(Short.valueOf(rowHeight.toString()));
}
}
for(int j=0;j<array.length;j++){
XSSFCell dataCell = dataRow.createCell(j);
dataCell.setCellStyle(this.cellStyle);
this.obtainPropList(array[j],dataCell);
}
}else {
XSSFRow dataRow = this.sheet.createRow(dataBeginIndex+i);
}
}
}
if(null != resetCellStyleList && !resetCellStyleList.isEmpty()){
int len = resetCellStyleList.size();
for (int i = 0; i < len; i++) {
HashMap<Integer, Integer> resetCellStyleHM = resetCellStyleList.get(i);
Iterator<Map.Entry<Integer, Integer>> it = resetCellStyleHM.entrySet().iterator();
while (it.hasNext()) {
Map.Entry<Integer, Integer> entry = it.next();
Integer rowIndex = entry.getKey();
Integer columnIndex = entry.getValue();
this.sheet.getRow(rowIndex).getCell(columnIndex).setCellStyle(this.resetCellStyle);
}
}
}
//设置合并开始标识
boolean mergedStartFlag = false;
int[] startAndEnd = null;
List mergedIndex = new ArrayList();
if(null != this.statisticData){
//追加统计行
XSSFRow appendRow = this.sheet.createRow(this.sheet.getLastRowNum()+1);
for(int i=0;i<this.statisticData.length;i++){
//记录合并开始位置
if(!mergedStartFlag){
mergedStartFlag = true;
startAndEnd = new int[2];
startAndEnd[0] = i;
}
//记录合并结束位置
if(ExportXLSX.MERGEDEND.equals(this.statisticData[i]) && mergedStartFlag){
mergedStartFlag = false;
startAndEnd[1] = i;
mergedIndex.add(startAndEnd);
}
//生成单元格,如果是合并单元格,内容置空
XSSFCell dataCell = appendRow.createCell(i);
dataCell.setCellStyle(this.cellStyle);
if(!ExportXLSX.MERGEDEND.equals(this.statisticData[i])){
this.obtainPropList(this.statisticData[i],dataCell);
}
}
}
//根据合并位置记录 合并单元格
for(int i=0;i<mergedIndex.size();i++){
startAndEnd = (int[])mergedIndex.get(i);
this.sheet.addMergedRegion(new CellRangeAddress(this.sheet.getLastRowNum(),this.sheet.getLastRowNum(),startAndEnd[0],startAndEnd[1]));
}
//处理要合并的单元格区域
if(null != this.mergeRanges && 0 != this.mergeRanges.size()){
for (int i = 0; i < this.mergeRanges.size(); i++) {
int[] ranges = this.mergeRanges.get(i);
this.sheet.addMergedRegion(new CellRangeAddress(ranges[0], ranges[1], ranges[2], ranges[3]));
}
}
}
/**
* 默认数据转换方法(只转换数组类型对象)
* @return
*/
private Object[] conversion(Object obj){
try {
return (Object[])obj;
} catch (ClassCastException e) {
if(this.logger.isErrorEnabled()){
this.logger.error("导出工具转换数据对象错误!要转换的数据不是数组型的!");
}
}
return null;
}
/* (非 Javadoc
* @see com.saye.common.export.IEport#setConversion(IConversionByExport conversion)
*/
public void setConversion(IConversionByExport conversion){
this.conversion = conversion;
}
/* (非 Javadoc
* @see com.saye.common.export.IEport#setTitleName(java.lang.String)
*/
public void setTitleName(String titleName){
this.titleName = titleName;
}
/* (非 Javadoc
* @see com.saye.common.export.IEport#modifyHeader(java.lang.String, int)
*/
public void modifyHeader(String header, int index){
this.header[index] = header;
}
/* (非 Javadoc
* @see com.saye.common.export.IEport#modifyWidthOfHeader(java.lang.String, int)
*/
public void modifyWidthOfHeader(String width, int index){
this.width[index] = width;
}
/* (非 Javadoc
* @see com.saye.common.export.IEport#setData(java.util.List)
*/
public void setData(List<Object> dataList){
this.data = dataList;
}
/* (非 Javadoc
* @see com.saye.common.export.IEport#appendStatisticRow(Object StatisticData)
*/
public void appendStatisticRow(Object statisticData) {
//如果不存在转换对象,则使用默认的转换方法
if(this.conversion != null){
this.statisticData = this.conversion.conversion(statisticData, this.sqlKey);
}else{
this.statisticData = this.conversion(statisticData);
}
}
/* (非 Javadoc
* @see com.saye.common.export.IEport#returnClientDownload(javax.servlet.http.HttpServletResponse)
*/
public void returnClientDownload(HttpServletResponse response) throws IOException{
//将数据装填到sheet中
this.fillSheet();
response.reset();
response.setContentType("application/vnd.ms-excel");
response.setHeader("Content-Disposition","attachment; filename=" + new String(this.titleName.getBytes("gb2312"),"ISO8859-1")+".xlsx");
OutputStream os = null;
try {
os = response.getOutputStream();
this.wb.write(os);
} catch (Exception e) {
} finally {
if(os != null) {
os.close();
os = null;
}
}
}
/* (非 Javadoc
* @see com.saye.common.export.IEport#returnClientOpen(javax.servlet.http.HttpServletResponse)
*/
public void returnClientOpen(HttpServletResponse response) throws IOException{
//将数据装填到sheet中
this.fillSheet();
response.reset();
response.setContentType("application/vnd.ms-excel");
response.setHeader("Content-Disposition","online; filename=" + new String(this.titleName.getBytes("gb2312"),"ISO8859-1")+".xlsx");
try {
wb.write(response.getOutputStream());
} catch (Exception e) {
e.printStackTrace();
}
}
/* (非 Javadoc
* @see com.saye.common.export.IEport#modifTitleHeight(short height)
*/
public void modifTitleHeight(short height) {
this.titleHeight = height;
}
/**
* 设置副标题
* @param subHeader
*/
public void setSubHeader(String[] subHeader){
this.subHeader = subHeader;
//默认设置每个单元格的宽度为3500
int headerLength = this.header.length;
int subHeaderLength = 0;
if(null != subHeader && 0 != subHeader.length){
subHeaderLength = this.subHeader.length;
}
int length = headerLength > subHeaderLength ? headerLength : subHeaderLength;
this.width = new String[length];
for(int i=0;i<length;i++){
this.width[i] = "3500";
}
}
/**
* 设置要合并的单元格区域
* @param firstRow 开始行
* @param lastRow 结束行
* @param firstCol 开始列
* @param lastCol 结束列
*/
public void setMergeRange(int firstRow, int lastRow, int firstCol, int lastCol){
int[] range = new int[4];
range[0] = firstRow;
range[1] = lastRow;
range[2] = firstCol;
range[3] = lastCol;
this.mergeRanges.add(range);
}
/*
*
*/
public void execGenerateExcel(String exportFilePath) throws IOException{
//将数据装填到sheet中
this.fillSheet();
// 设置输入流
FileOutputStream fOut = new FileOutputStream(exportFilePath);
// 将模板的内容写到输出文件上
wb.write(fOut);
fOut.flush();
// 操作结束,关闭文件
fOut.close();
}
/**
* 设置头部高度
* @param height
*/
public void modifyHeaderHeight(short height) {
this.headerHeight = height;
}
/**
* 设置头部标题所处行序号
* @param headerRowIndex
*/
public void modifyHeaderRowIndex(short headerRowIndex) {
this.headerRowIndex = headerRowIndex;
}
/**
* 设置头部副标题序号
* @param subHeaderRowIndex
*/
public void modifySubHeaderRowIndex(short subHeaderRowIndex) {
this.subHeaderRowIndex = subHeaderRowIndex;
}
/**
* 设置标题合并列号
* @param titleMergeColumnIndex
*/
public void setTitleMergeColumnIndex(int titleMergeColumnIndex) {
this.titleMergeColumnIndex = titleMergeColumnIndex;
}
/**
* 设置数据行高
* @param modifiedDataHeightHM数据序号和行高
*/
public void setModifiedDataHeightHM(HashMap<Integer, Integer> modifiedDataHeightHM) {
this.modifiedDataHeightHM = modifiedDataHeightHM;
}
/**
* 设置头部副标题高度
* @param subHeaderHeight
*/
public void modifySubHeaderHeight(short subHeaderHeight) {
this.subHeaderHeight = subHeaderHeight;
}
/**
* 设置是否创建冻结窗体
* @param isCreateFreezePane
*/
public void setIsCreateFreezePane(Boolean isCreateFreezePane) {
this.isCreateFreezePane = isCreateFreezePane;
}
/**
* 设置要空行的数据列序号
* @param skipedDataIndexMap
*/
public void setSkipedDataIndexMap(HashMap<Integer, Integer> skipedDataIndexMap) {
this.skipedDataIndexMap = skipedDataIndexMap;
}
/**
* 设置 重新设置样式的单元格序号及样式:样式为空时,默认为头部标题样式
* @param resetCellStyleList
* @param resetCellStyle
*/
public void resetCellForCellStyle(List<HashMap<Integer, Integer>> resetCellStyleList, XSSFCellStyle resetCellStyle) {
this.resetCellStyleList = resetCellStyleList;
if(null == resetCellStyle){
resetCellStyle = this.headerCellStyle;
}
this.resetCellStyle = resetCellStyle;
}
/**
* 设置 工作薄 密码保护
* @param pwd
*/
public void protectSheet(String pwd) {
this.sheet.protectSheet(pwd);
}
/**
* 设定抬头是否合并两行:在new ExportXLS之后就SET
* @param isHeaderMergeTwo
*/
public void setIsHeaderMergeTwo(Boolean isHeaderMergeTwo) {
this.isHeaderMergeTwo = isHeaderMergeTwo;
if(!this.isHeaderMergeTwo){
this.headerRowIndex = 1;
this.subHeaderRowIndex = 2;
}
}
}

View File

@@ -0,0 +1,27 @@
package com.saye.hospitalgd.commons.excel;
import java.util.HashMap;
public class HashMapConversionImpl implements IConversionByExport {
@Override
public Object[] conversion(Object obj) {
// TODO Auto-generated method stub
return null;
}
@Override
public Object[] conversion(Object obj, String[] sqlArray) {
HashMap<Object, Object> hm = (HashMap<Object, Object>) obj;
int len = sqlArray.length;
Object[] result = new Object[len];
for (int i = 0; i < len; i++) {
result[i] = hm.get(sqlArray[i]);
}
return result;
}
}

View File

@@ -0,0 +1,6 @@
package com.saye.hospitalgd.commons.excel;
public interface IConversionByExport {
public Object[] conversion(Object obj);
public Object[] conversion(Object obj, String[] sqlArray);
}

View File

@@ -0,0 +1,53 @@
package com.saye.hospitalgd.commons.excel;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.sql.SQLException;
import java.util.List;
public interface IExport {
/**
* 设置转换对象
* @param conversion
*/
public void setConversion(IConversionByExport conversion);
/**
* 设置数据数据
* @param dataList
* @throws SQLException
*/
public void setData(List<Object> dataList);
/**
* 在表格尾部追加数据,主要用于统计数据
*/
public void appendStatisticRow(Object statisticData);
/**
* 以下载形式导出
* @param response
* @throws IOException
*/
public void returnClientDownload(HttpServletResponse response)
throws IOException;
/**
* 以打开方式导出
* @param response
*/
public void returnClientOpen(HttpServletResponse response)
throws IOException;
/**
* 后台生成EXCEL文件
* @param exportFilePath
* @throws IOException
*/
public void execGenerateExcel(String exportFilePath) throws IOException;
}

View File

@@ -0,0 +1,58 @@
package com.saye.hospitalgd.commons.excel;
public interface ISetExport {
/**
* 设置台头
* @param titleName
*/
public void setTitleName(String titleName);
/**
* 设置标题高
* @param height
*/
public void modifTitleHeight(short height);
/**
* 修改某个位置的标题栏名称
* @param header
* @param index
*/
public void modifyHeader(String header, int index);
/**
* 修改某个位置的标题栏宽度
* @param width
* @param index
*/
public void modifyWidthOfHeader(String width, int index);
/**
* 设置副标题
* @param subHeader
*/
public void setSubHeader(String[] subHeader);
/**
* 设置要合并的单元格区域
* @param firstRow 开始行
* @param lastRow 结束行
* @param firstCol 开始列
* @param lastCol 结束列
*/
public void setMergeRange(int firstRow, int lastRow, int firstCol, int lastCol);
/**
* 设置 工作薄 密码保护
* @param pwd
*/
public void protectSheet(String pwd);
/**
* 设定抬头是否合并两行:在new ExportXLS之后就SET
* @param isHeaderMergeTwo
*/
public void setIsHeaderMergeTwo(Boolean isHeaderMergeTwo);
}

View File

@@ -0,0 +1,36 @@
package com.saye.hospitalgd.commons.file;
import java.io.File;
public class FileDUtil {
/**
* 得到文件的扩展名:大写字母的自动转换为小写字母
* @param f
* @return
*/
public static String getExtension(File f) {
return (f != null) ? getExtension(f.getName()) : "";
}
public static String getExtension(String filename) {
return getExtension(filename,"");
}
public static String getExtension(String filename, String defExt) {
if ((filename != null) && (filename.length() > 0)) {
int i = filename.lastIndexOf('.');
if ((i >-1) && (i < (filename.length() - 1))) {
return filename.substring(i + 1).trim().toLowerCase();
}
}
return defExt;
}
public static void main(String[] args) {
File f = new File("d:\test.XLSX");
System.out.println(getExtension(f));
}
}

View File

@@ -0,0 +1,29 @@
package com.saye.hospitalgd.commons.getBean;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;
@Component
public class GetBeanUtil implements ApplicationContextAware {
protected static ApplicationContext applicationContext ;
@Override
public void setApplicationContext(ApplicationContext arg0) throws BeansException {
if (applicationContext == null) {
applicationContext = arg0;
}
}
public static Object getBean(String name) {
//name表示其他要注入的注解name名
return applicationContext.getBean(name);
}
/**
* 拿到ApplicationContext对象实例后就可以手动获取Bean的注入实例对象
*/
public static <T> T getBean(Class<T> clazz) {
return applicationContext.getBean(clazz);
}
}

View File

@@ -0,0 +1,150 @@
package com.saye.hospitalgd.commons.image;
import sun.misc.BASE64Decoder;
import sun.misc.BASE64Encoder;
import java.io.*;
import java.net.HttpURLConnection;
import java.net.URL;
/**
* Description: 图片与base64的转换
* @author dqzhang
* @created 2018-10-9 下午4:07:55
*/
public class ImageBase64DUtil {
/**
* 本地图片转换成base64字符串
* @param imgFile 图片本地路径
* @return
* @dateTime 2018-02-23 14:40:46
*/
public static String ImageToBase64ByLocal(String imgFile) throws Exception{// 将图片文件转化为字节数组字符串并对其进行Base64编码处理
InputStream in = null;
byte[] data = null;
// 读取图片字节数组
try {
in = new FileInputStream(imgFile);
data = new byte[in.available()];
in.read(data);
in.close();
} catch (IOException e) {
// e.printStackTrace();
}
// 对字节数组Base64编码
BASE64Encoder encoder = new BASE64Encoder();
return encoder.encode(data);// 返回Base64编码过的字节数组字符串
}
/**
* 在线图片转换成base64字符串
* @param imgURL 图片线上路径
* @return
* @dateTime 2018-02-23 14:43:18
*/
public static String ImageToBase64ByOnline(String imgURL) {
ByteArrayOutputStream data = new ByteArrayOutputStream();
try {
// 创建URL
URL url = new URL(imgURL);
byte[] by = new byte[1024];
// 创建链接
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("GET");
conn.setConnectTimeout(5000);
InputStream is = conn.getInputStream();
// 将内容读取内存中
int len = -1;
while ((len = is.read(by)) != -1) {
data.write(by, 0, len);
}
// 关闭流
is.close();
} catch (IOException e) {
e.printStackTrace();
}
// 对字节数组Base64编码
BASE64Encoder encoder = new BASE64Encoder();
return encoder.encode(data.toByteArray());
}
/**
* base64字符串转换成图片
* @param imgStr base64字符串
* @param imgFilePath 图片存放路径
* @return
* @dateTime 2018-02-23 14:42:17
*/
public static boolean Base64ToImage(String imgStr,String imgFilePath) { // 对字节数组字符串进行Base64解码并生成图片
BASE64Decoder decoder = new BASE64Decoder();
try {
// Base64解码
byte[] b = decoder.decodeBuffer(imgStr);
for (int i = 0; i < b.length; ++i) {
if (b[i] < 0) {// 调整异常数据
b[i] += 256;
}
}
OutputStream out = new FileOutputStream(imgFilePath);
out.write(b);
out.flush();
out.close();
return true;
} catch (Exception e) {
return false;
}
}
/**
* @description 下载在线图片到本地
*/
public static void readInputStream(URL url,File file) throws Exception {
// 打开链接
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
// 设置请求方式为"GET"
conn.setRequestMethod("GET");
// 超时响应时间为5秒
conn.setConnectTimeout(5 * 1000);
// 通过输入流获取图片数据
InputStream inStream = conn.getInputStream();
ByteArrayOutputStream outStream = new ByteArrayOutputStream();
// 创建一个Buffer字符串
byte[] buffer = new byte[1024];
// 每次读取的字符串长度,如果为-1代表全部读取完毕
int len = 0;
// 使用一个输入流从buffer里把数据读取出来
while ((len = inStream.read(buffer)) != -1) {
// 用输出流往buffer里写入数据中间参数代表从哪个位置开始读len代表读取的长度
outStream.write(buffer, 0, len);
}
// 关闭输入流
inStream.close();
// 创建输出流
FileOutputStream outStream2 = new FileOutputStream(file);
// 写入数据
outStream2.write(outStream.toByteArray());
// 关闭输出流
outStream2.close();
}
public static void main(String[] args) throws Exception{
}
}

View File

@@ -0,0 +1,27 @@
package com.saye.hospitalgd.commons.log;
public class ExceptionDUtil {
/**
* 返回异常的详细信息
* @param e
* @return
*/
public static String getDetailExceptionMsg(Exception e){
StringBuffer exceptionMessage = new StringBuffer();
StackTraceElement[] stackTraceElementes = e.getStackTrace();
int length = stackTraceElementes.length;
StackTraceElement ste;
//只要最顶上的错误栈
for(int i=0;i<length;i++){
ste = stackTraceElementes[i];
exceptionMessage.append(ste.getClassName()+":"+ste.getLineNumber()+"\r\n");
//break;
}
String result = e.toString()+"\r\n"+exceptionMessage.toString();
return result;
}
}

View File

@@ -0,0 +1,128 @@
package com.saye.hospitalgd.commons.log;
import com.saye.hospitalgd.commons.date.DateDUtil;
import com.saye.hospitalgd.mapper.system.LoggerMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.HashMap;
@Component
public class LogUtil {
private static LoggerMapper loggerMapper;
@Autowired
public void setLoggerMapper(LoggerMapper loggerMapper) {
LogUtil.loggerMapper = loggerMapper;
}
public static void debug(Class c,String msg) {
Logger logger=LoggerFactory.getLogger(c);
logger.debug(msg);
}
// public static void info(Class c,String msg) {
// Logger logger=LoggerFactory.getLogger(c);
// logger.info(msg);
// }
//
// public static void error(Class c,String msg) {
// Logger logger=LoggerFactory.getLogger(c);
// logger.error(msg);
// }
public static void info(Class c,String msg){
HashMap<Object, Object> map=new HashMap<Object, Object>();
try {
String name = c.getName();
if(name.indexOf("Controller")!=-1){
map.put("logtype", "INFO");
map.put("information",msg);
map.put("create_time", DateDUtil.getCurrentDate(DateDUtil.yyyy_MM_dd_HH_mm_ss));
map.put("user_id","");
map.put("ip", "");
loggerMapper.addLog(map);
}
} catch (Exception e) {
e.printStackTrace();
}finally {
Logger logger=LoggerFactory.getLogger(c);
logger.info(msg);
}
}
public static void info(Class c,String msg,String ip,String userName){
HashMap<Object, Object> map=new HashMap<Object, Object>();
try {
String name = c.getName();
if(name.indexOf("Controller")!=-1){
map.put("logtype", "INFO");
map.put("information",msg);
map.put("create_time", DateDUtil.getCurrentDate(DateDUtil.yyyy_MM_dd_HH_mm_ss));
map.put("user_id",userName);
map.put("ip", ip);
loggerMapper.addLog(map);
}
} catch (Exception e) {
e.printStackTrace();
}finally {
Logger logger=LoggerFactory.getLogger(c);
logger.info(msg);
}
}
public static void error(Class c,String msg){
HashMap<Object, Object> map=new HashMap<Object, Object>();
try {
String name = c.getName();
if(name.indexOf("Controller")!=-1){
map.put("logtype", "ERROR");
map.put("information",msg);
map.put("create_time", DateDUtil.getCurrentDate(DateDUtil.yyyy_MM_dd_HH_mm_ss));
map.put("user_id","");
map.put("ip", "");
loggerMapper.addLog(map);
}
} catch (Exception e) {
e.printStackTrace();
}finally {
Logger logger=LoggerFactory.getLogger(c);
logger.error(msg);
}
}
public static void error(Class c,String msg,String ip,String userName){
HashMap<Object, Object> map=new HashMap<Object, Object>();
try {
String name = c.getName();
if(name.indexOf("Controller")!=-1){
map.put("logtype", "ERROR");
map.put("information",msg);
map.put("create_time", DateDUtil.getCurrentDate(DateDUtil.yyyy_MM_dd_HH_mm_ss));
map.put("user_id",userName);
map.put("ip", ip);
loggerMapper.addLog(map);
}
} catch (Exception e) {
e.printStackTrace();
}finally {
Logger logger=LoggerFactory.getLogger(c);
logger.error(msg);
}
}
}

View File

@@ -0,0 +1,23 @@
package com.saye.hospitalgd.commons.page;
import com.github.pagehelper.PageInfo;
import java.util.List;
public class PageUtil {
public static TemplatePage loadJsonPage(PageInfo pageInfo){
TemplatePage templetJson = new TemplatePage();
try {
List list = pageInfo.getList();
int i = (int) pageInfo.getTotal();
templetJson.setCount(i);
templetJson.setCode(0);
templetJson.setMsg("");
templetJson.setData(list);
} catch (Exception e) {
templetJson.setCode(1);
}
return templetJson;
}
}

View File

@@ -0,0 +1,44 @@
package com.saye.hospitalgd.commons.page;
/**
* layui 的模板数据bean
*/
public class TemplatePage {
private Integer code;
private String msg;
private Integer count;
private Object data;
public Integer getCode() {
return code;
}
public void setCode(Integer code) {
this.code = code;
}
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
public Integer getCount() {
return count;
}
public void setCount(Integer count) {
this.count = count;
}
public Object getData() {
return data;
}
public void setData(Object data) {
this.data = data;
}
}

View File

@@ -0,0 +1,415 @@
package com.saye.hospitalgd.commons.string;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.regex.Pattern;
public class StringDUtil {
/**
* 去掉给定字符串前和后的空格,返回干净的字符串
* @param str
* @return String
*/
public static String removeSpaces(Object args) {
String argsStr = changeNullToEmpty(args);
if(args!=null){
args = argsStr.trim();
while (argsStr.startsWith(" ")) {
argsStr = argsStr.substring(1, argsStr.length()).trim();
}
while (argsStr.endsWith(" ")) {
argsStr = argsStr.substring(0, argsStr.length() - 1).trim();
}
}else{
argsStr = "";
}
return argsStr;
}
/**
* 转全角的函数
* @param str
* @return String
*/
public static String toSBC(String input) {
//半角转全角:
char[] c = input.toCharArray();
for (int i = 0; i < c.length; i++) {
if (c[i] == 32) {
c[i] = (char) 12288;
continue;
}
if (c[i] < 127) {
c[i] = (char) (c[i] + 65248);
}
}
return new String(c);
}
/**
* 转半角的函数
* @param str
* @return String
*/
public static String toDBC(String input) {
char[] c = input.toCharArray();
for (int i = 0; i < c.length; i++) {
if (c[i] == 12288) {
c[i] = (char) 32;
continue;
}
if (c[i] > 65280 && c[i] < 65375){
c[i] = (char) (c[i] - 65248);
}
}
return new String(c);
}
/**
* 为每添加一个元素前面增加指定的分隔 除第一个元素之外
* @param str
* @param appStr
* @param compart
* @return
*/
public static StringBuffer appendElement(StringBuffer strB,String appStr,String compart){
//当出入参数为NULL时
if(strB == null){
return new StringBuffer(appStr);
}
//当没有元素时直接添加追加元素 否则先添加分隔符
if(strB.length() == 0){
strB.append(appStr);
}else{
strB.append(compart);
strB.append(appStr);
}
return strB;
}
/**
* 移除元素
* @param str
* @param moveStr
* @param compart
* @return
*/
public static StringBuffer moveElement(StringBuffer strB,String moveStr,String compart){
//当出入参数为NULL时
if(strB == null){
return strB;
}
StringBuffer newStrB = new StringBuffer();
String[] strArray = strB.toString().split(compart);
for(int i=0;i<strArray.length;i++){
if(moveStr.equals(strArray[i])){
continue;
}
if(i == 0){
newStrB.append(strArray[i]);
}else{
newStrB.append(compart);
newStrB.append(strArray[i]);
}
}
return newStrB;
}
/**
* 移除第一个匹配的元素
* @param str
* @param moveStr
* @param compart
* @return
*/
public static StringBuffer moveFirstElement(StringBuffer strB,String moveStr,String compart){
//当出入参数为NULL时
if(strB == null){
return strB;
}
StringBuffer newStrB = new StringBuffer();
String[] strArray = strB.toString().split(compart);
boolean tag = false;
for(int i=0;i<strArray.length;i++){
if(moveStr.equals(strArray[i]) == true && tag == false){
tag = true;
continue;
}
if(i == 0){
newStrB.append(strArray[i]);
}else{
newStrB.append(compart);
newStrB.append(strArray[i]);
}
}
return newStrB;
}
/**
* 从给定字符中 返回所含的中文字符 并按每组以以字符串数组的形式返回
* @param src
* @return
*/
public static String[] getChinese(String src){
List list = new ArrayList();
byte[] srcByte = src.getBytes();
int srcLength = srcByte.length;
int begin = -1;
int end = -1;
for(int i=0;i<srcLength;i++){
//设置中文的开始位
if(srcByte[i] < 0 && begin == -1){
begin = i;
}
//设置中文的结束位
if(srcByte[i] > 0 && begin != -1 && end == -1){
end = i;
}
//如果已经找到中文的开始 但直到最后也没找到中文的结束,则将字符的结束位当成中文的截止位
if(begin != -1 && i == srcLength - 1){
end = i;
}
//将中文提取出来
if(begin != -1 && end != -1){
int tempLength = end-begin+1;
if(tempLength % 2 != 0){
tempLength = tempLength - 1;
}
byte[] tempByte = new byte[tempLength];
System.arraycopy(srcByte, begin, tempByte, 0, tempLength);
list.add(new String(tempByte));
begin = -1;
end = -1;
}
}
//将中文以数组输出
int size = list.size();
String[] chineseArray = new String[size];
for(int i=0;i<size;i++){
chineseArray[i] = list.get(i).toString();
}
return chineseArray;
}
/**
* 产生指定长度的随机码(由字母和数字组成)
* @param len
* @return
*/
public static String generateRandomCodeForLength(int len){
String s = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
StringBuffer sRand = new StringBuffer();
Random random=new Random();
for (int i = 0; i < len; i++) {
String ch = String.valueOf(s.charAt(random.nextInt(s.length())));
sRand.append(ch);
}
return sRand.toString();
}
/**
* 将字符串NULL转换为空:""
* @param args
* @return
*/
public static String changeNullToEmpty(Object args) {
String result = null == args ? "" : String.valueOf(args);
if("\"null\"".equals(result) || "null".equals(result)){
result = "";
}
return result;
}
/**
* 将字符串NULL转换为空:"",并且去字符串中的转义字符
* @param args
* @return
*/
public static String changeNullToEmptyReplaceEscape(Object args) {
String result = null == args ? "" : String.valueOf(args);
result = result.replaceAll("'", "");
result = result.replaceAll("", "{");
result = result.replaceAll("", "}");
return result;
}
/**
* 验证字符串是否为空NULL或""
* @param str
* @return 返回值为true说明是为空。
*/
public static Boolean isEmpty(Object args) {
String result = "";
String str = changeNullToEmpty(args);
if("".equals(removeSpaces(str)) || "\"null\"".equals(removeSpaces(str)) || "null".equals(removeSpaces(str))){
return true;
}
return false;
}
/**
* 验证MAP中要验证的字段是否为空NULL或""
* @param hm 要验证的MAP
* @param fieldString 传入方式(以,将字段进行分割)personid,sysid
* @return 返回值为空,则验证成功,说明都不为空;否则返回为空的该字段名。
*/
public static String isExistEmpty(Map<Object, Object> hm, String fieldString) {
String[] strArr = fieldString.split(",");
for (int i = 0; i < strArr.length; i++) {
String key = strArr[i];
Object obj = hm.get(key);
if(isEmpty(obj)){
return key;
}
}
return "";
}
/**
* 判断字符串是否为正整数
* @param str
* @return
*/
public static boolean isPositiveInteger (String str){
Pattern pattern = Pattern.compile("^[0-9]*[1-9][0-9]*$");
return pattern.matcher(str).matches();
}
/**
* 判断字符串是否为正整数或正浮点数
* @param str
* @return
*/
public static boolean isPositiveIntegerOrPositiveFloat (String str){
Pattern pattern = Pattern.compile("^(([0-9]+\\.[0-9]*[1-9][0-9]*)|([0-9]*[1-9][0-9]*\\.[0-9]+)|([0-9]*[1-9][0-9]*))$");
return pattern.matcher(str).matches();
}
/**
*
* @description 截取字符串
* @author mczheng
* @created 2016-6-25 下午6:13:29
* @param str 要截取的字符串
* @param maxLength 字符长度英文字符算0.5个长度当截取剩下最后一位是0.5个长度而最后一个字符是中文时,则舍弃掉。
* @return
*/
public static String substring(String str, int maxLength) {
if (!hasLength(str))
return str;
int subSLength = maxLength * 2;
int tempSubLength = subSLength;//截取字符数
String subStr = "";
try {
int strLen = str.getBytes("GBK").length;
if (strLen <= subSLength) return str;
subStr = str.substring(0, str.length() < subSLength ? str.length() : subSLength); //截取的子串
int subStrByetsL = subStr.getBytes("GBK").length; //截取子串的字节长度
//说明截取的字符串中包含有汉字
while (subStrByetsL > tempSubLength) {
int subSLengthTemp = --subSLength;
subStr = str.substring(0, subSLengthTemp > str.length() ? str.length() : subSLengthTemp);
subStrByetsL = subStr.getBytes("GBK").length;
}
subStr += "...";
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
return subStr;
}
public static boolean hasLength(String str) {
return (str != null) && (str.length() > 0);
}
public static void main(String[] args) {
//
// StringBuffer str = new StringBuffer("a,c,d,c");
// str = StringDUtil.moveFirstElement(str, "c", ",");
// System.out.println(str.toString());
//
// System.out.println(isEmpty("\"null\""));
System.out.println(StringDUtil.substring("一二三四五六七八九十一二三四五六七八九十一二三四五六七八九十", 15));
}
/**
* @description 判断字符串是否有值且值不为空格
* @author thuang
* @created 2020年1月7日 下午1:09:49
* @param str
* @return
*/
public static boolean isNotBlank(String str) {
if (str != null && str.length() > 0 && str.trim().length() > 0) {
return true;
}
return false;
}
}

View File

@@ -0,0 +1,24 @@
package com.saye.hospitalgd.commons.uuid;
import java.util.UUID;
public class UUIDGenerator {
public UUIDGenerator() {
}
/**
* 获得一个UUID
* @return String UUID
*/
public static String getUUID(){
String s = UUID.randomUUID().toString();
//去掉“-”符号
return s.substring(0,8)+s.substring(9,13)+s.substring(14,18)+s.substring(19,23)+s.substring(24);
}
public static void main(String[] args){
String ss = UUIDGenerator.getUUID();
System.out.println(ss);
System.out.println(ss.length());
}
}

View File

@@ -0,0 +1,20 @@
package com.saye.hospitalgd.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;
/**
* @author thuang
* @version 1.0
* @description: TODO
* @date 2021/9/17 16:40
*/
@Configuration
public class ApplicationConfig {
@Bean
public RestTemplate getRestTemplate(){
return new RestTemplate();
}
}

View File

@@ -0,0 +1,50 @@
package com.saye.hospitalgd.config;
import com.saye.hospitalgd.model.ServiceParams;
import com.saye.hospitalgd.model.StatusDefine;
import com.saye.hospitalgd.service.system.ServiceParamsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;
import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.List;
@Component
public class LoadStatusDefine implements ApplicationRunner {
@Autowired
private ServiceParamsService serviceParamsService;
@Override
public void run(ApplicationArguments args) throws Exception {
System.out.println("/************************************开始加载系统默认参数*************************************************/");
StatusDefine sd = new StatusDefine();
List<ServiceParams> paramsList = this.serviceParamsService.selectServiceParams(new HashMap<String, String>());
for (int i = 0; i < paramsList.size(); i++) {
ServiceParams param = paramsList.get(i);
String paramName = param.getParamCode();
Field declaredField = null;
try {
declaredField = sd.getClass().getDeclaredField(paramName);
} catch (Exception e) {
//e.printStackTrace();
}
if (declaredField != null) {
declaredField.setAccessible(true);
declaredField.set(sd, param.getParamVal());
}
}
System.out.println("/************************************加载系统默认参数完成*************************************************/");
}
}

View File

@@ -0,0 +1,79 @@
package com.saye.hospitalgd.config;
import com.saye.hospitalgd.commons.date.DateDUtil;
import com.saye.hospitalgd.commons.string.StringDUtil;
import com.saye.hospitalgd.model.Users;
import com.saye.hospitalgd.service.system.UsersService;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.*;
import org.apache.shiro.authz.AuthorizationInfo;
import org.apache.shiro.crypto.hash.Md5Hash;
import org.apache.shiro.realm.AuthorizingRealm;
import org.apache.shiro.session.Session;
import org.apache.shiro.subject.PrincipalCollection;
import org.apache.shiro.subject.Subject;
import org.apache.shiro.util.ByteSource;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.List;
public class MyShiroRealm extends AuthorizingRealm {
@Autowired
private UsersService usersService;
/*主要是用来进行身份认证的,也就是说验证用户输入的账号和密码是否正确。*/
@Override
protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken token)
throws AuthenticationException {
//获取用户的输入的账号.
UsernamePasswordToken up = (UsernamePasswordToken)token;
String username = String.valueOf(up.getUsername());
String password = String.valueOf(up.getPassword());
List<Users> list = usersService.searchByName(username);
if(list.isEmpty()){
return null;
}
Subject subject = SecurityUtils.getSubject();
Session session = subject.getSession();
Users user = list.get(0);
//判断账户是否锁定
String lockTime = user.getLockTime();
String currentTime = DateDUtil.getTheCurrentTime();
if(lockTime.compareTo(currentTime) == 1) {
throw new ExcessiveAttemptsException();
}
//连续输入错误超过6次锁定10分钟
String truePassword = user.getPassword();
String encryptPassword = new Md5Hash(password,"hospitalgd",2).toString();
if(!truePassword.equals(encryptPassword)) {
String num = StringDUtil.changeNullToEmpty(session.getAttribute(username));
int failNum = Integer.valueOf(num.equals("")?"0":num);
session.setAttribute(username, ++failNum);
if(failNum>6) {
lockTime = DateDUtil.getPlusMinutes("yyyy-MM-dd HH:mm:ss", currentTime, 10);
this.usersService.modifyLockTime(username, lockTime);
throw new ExcessiveAttemptsException();
}
}
SimpleAuthenticationInfo authenticationInfo = new SimpleAuthenticationInfo(
user,
truePassword,
ByteSource.Util.bytes("hospitalgd"),
getName() //realm name
);
return authenticationInfo;
}
public static void main(String[] args) {
String result = new Md5Hash("1234Saye","hospitalgd",2).toString();
System.out.println(result);
System.out.println(result.length());
}
@Override
protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principals) {
// 配置权限
return null;
}
}

View File

@@ -0,0 +1,98 @@
package com.saye.hospitalgd.config;
import org.apache.shiro.authc.credential.HashedCredentialsMatcher;
import org.apache.shiro.mgt.SecurityManager;
import org.apache.shiro.spring.security.interceptor.AuthorizationAttributeSourceAdvisor;
import org.apache.shiro.spring.web.ShiroFilterFactoryBean;
import org.apache.shiro.web.mgt.DefaultWebSecurityManager;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.handler.SimpleMappingExceptionResolver;
import javax.servlet.Filter;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Properties;
@Configuration
public class ShiroConfig {
@Bean
public ShiroFilterFactoryBean shirFilter(SecurityManager securityManager) {
System.out.println("ShiroConfiguration.shirFilter()");
ShiroFilterFactoryBean shiroFilterFactoryBean = new ShiroFilterFactoryBean();
shiroFilterFactoryBean.setSecurityManager(securityManager);
//过滤器
Map<String, Filter> filterMap = new LinkedHashMap<>();
filterMap.put("authc", new com.saye.hospitalgd.config.ShiroFilter());
shiroFilterFactoryBean.setFilters(filterMap);
Map<String, String> filterChainDefinitionMap = new LinkedHashMap<String, String>();
//配置所有请求都走shiroFilter
filterChainDefinitionMap.put("/receiveData/**", "anon");
filterChainDefinitionMap.put("/**", "authc");
//如果不设置默认会自动寻找Web工程根目录下的"/login.jsp"页面
shiroFilterFactoryBean.setLoginUrl("/toLogin");
//登录成功后要跳转的链接
shiroFilterFactoryBean.setSuccessUrl("/index");
//未授权界面;
shiroFilterFactoryBean.setUnauthorizedUrl("/403");
shiroFilterFactoryBean.setFilterChainDefinitionMap(filterChainDefinitionMap);
return shiroFilterFactoryBean;
}
/**
* 凭证匹配器
* 由于我们的密码校验交给Shiro的SimpleAuthenticationInfo进行处理了
*
* @return
*/
@Bean
public HashedCredentialsMatcher hashedCredentialsMatcher() {
HashedCredentialsMatcher hashedCredentialsMatcher = new HashedCredentialsMatcher();
hashedCredentialsMatcher.setHashAlgorithmName("md5");//散列算法:这里使用MD5算法;
hashedCredentialsMatcher.setHashIterations(2);//散列的次数,比如散列两次,相当于 md5(md5(""));
return hashedCredentialsMatcher;
}
@Bean
public MyShiroRealm myShiroRealm() {
MyShiroRealm myShiroRealm = new MyShiroRealm();
myShiroRealm.setCredentialsMatcher(hashedCredentialsMatcher());
return myShiroRealm;
}
@Bean
public SecurityManager securityManager() {
DefaultWebSecurityManager securityManager = new DefaultWebSecurityManager();
securityManager.setRealm(myShiroRealm());
return securityManager;
}
/**
* 开启shiro aop注解支持.
* 使用代理方式;所以需要开启代码支持;
*
* @param securityManager
* @return
*/
@Bean
public AuthorizationAttributeSourceAdvisor authorizationAttributeSourceAdvisor(SecurityManager securityManager) {
AuthorizationAttributeSourceAdvisor authorizationAttributeSourceAdvisor = new AuthorizationAttributeSourceAdvisor();
authorizationAttributeSourceAdvisor.setSecurityManager(securityManager);
return authorizationAttributeSourceAdvisor;
}
@Bean(name = "simpleMappingExceptionResolver")
public SimpleMappingExceptionResolver createSimpleMappingExceptionResolver() {
SimpleMappingExceptionResolver r = new SimpleMappingExceptionResolver();
Properties mappings = new Properties();
mappings.setProperty("DatabaseException", "databaseError");//数据库异常处理
mappings.setProperty("UnauthorizedException", "403");
r.setExceptionMappings(mappings); // None by default
r.setDefaultErrorView("error"); // No default
r.setExceptionAttribute("ex"); // Default is "exception"
//r.setWarnLogCategory("example.MvcLogger"); // No default
return r;
}
}

View File

@@ -0,0 +1,88 @@
package com.saye.hospitalgd.config;
import com.saye.hospitalgd.commons.string.StringDUtil;
import com.saye.hospitalgd.mapper.system.MenuMapper;
import com.saye.hospitalgd.model.Users;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.web.filter.authz.AuthorizationFilter;
import org.springframework.context.ApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;
import javax.servlet.ServletContext;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
public class ShiroFilter extends AuthorizationFilter{
private MenuMapper menuMapper;
static List<String> list= null;
static {
list = new ArrayList<String>();
list.add("/getCode");
list.add("/toLogin");
list.add("/login");
list.add("/logout");
list.add("/favicon.ico");
list.add("/image/sgl.png");
list.add("/js/common.js");
}
@Override
protected boolean isAccessAllowed(ServletRequest srequest, ServletResponse sresponse, Object mappedValue)
throws Exception {
// TODO Auto-generated method stub
return false;
}
@Override
protected boolean onAccessDenied(ServletRequest srequest, ServletResponse sresponse) throws IOException {
if(menuMapper == null) {
ServletContext context = srequest.getServletContext();
ApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(context);
if(ctx != null) {
menuMapper= (MenuMapper ) ctx.getBean("menuMapper");
}
}
HttpServletRequest request = (HttpServletRequest) srequest;
HttpServletResponse response = (HttpServletResponse) sresponse;
String url = request.getRequestURI();
System.out.println("this is MyFilter,url :"+url);
if(!list.contains(url) && url.indexOf("/layui/")==-1 && url.indexOf("/showFile/")==-1) {
Users user = (Users)SecurityUtils.getSubject().getPrincipal();
String requestType = StringDUtil.changeNullToEmpty(request.getHeader("X-Requested-With"));
if(user == null) {
if(!"".equals(requestType) && requestType.equalsIgnoreCase("XMLHttpRequest")) {
response.setHeader("sessionstatus", "timeout");
response.sendError(403, "session timeout.");
}else{
response.sendRedirect("/toLogin");
}
}else {
//判断用户是否有此菜单权限
HashMap<Object,Object> map = new HashMap<Object,Object>();
map.put("userid", user.getUserId());
map.put("url", url);
List<HashMap<Object,Object>> menuList = this.menuMapper.findMenuByUrl(map);
if(!menuList.isEmpty()) {
String menu_id = StringDUtil.changeNullToEmpty(menuList.get(0).get("MENU_ID"));
map.put("menu_id", menu_id);
List<HashMap<Object,Object>> roleList = this.menuMapper.findRoleByUserAndMenu(map);
if(roleList.isEmpty()) {
response.sendRedirect("/toNoAuthority");
}
}
}
}
return true;
}
}

View File

@@ -0,0 +1,58 @@
package com.saye.hospitalgd.config;
import org.apache.ibatis.executor.result.ResultMapException;
import org.apache.ibatis.type.BaseTypeHandler;
import org.apache.ibatis.type.JdbcType;
import org.apache.ibatis.type.MappedJdbcTypes;
import org.apache.ibatis.type.MappedTypes;
import java.sql.CallableStatement;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
/**
* Description: 实体类数据返回时将null转成"" <result column="name" property="name" jdbcType="VARCHAR" typeHandler="com.saye.hospitalgd.config.StringTypeHandler"/>
* @author dqzhang
* @created 2021年3月10日 下午3:29:00
*/
@MappedTypes({String.class})
@MappedJdbcTypes(JdbcType.VARCHAR)
public class StringTypeHandler extends BaseTypeHandler<String> {
@Override
public String getResult(ResultSet rs, String columnName) {
String result;
try {
result = getNullableResult(rs, columnName);
} catch (Exception e) {
throw new ResultMapException("Error attempting to get column '" + columnName + "' from result set. Cause: " + e, e);
}
return result;
}
@Override
public void setNonNullParameter(PreparedStatement ps, int i, String parameter, JdbcType jdbcType)
throws SQLException {
ps.setString(i, parameter);
}
@Override
public String getNullableResult(ResultSet rs, String columnName)
throws SQLException {
return rs.getString(columnName) == null? "" : rs.getString(columnName);
}
@Override
public String getNullableResult(ResultSet rs, int columnIndex)
throws SQLException {
return rs.getString(columnIndex) == null? "" : rs.getString(columnIndex);
}
@Override
public String getNullableResult(CallableStatement cs, int columnIndex)
throws SQLException {
return cs.getString(columnIndex) == null? "" : cs.getString(columnIndex);
}
}

View File

@@ -0,0 +1,39 @@
package com.saye.hospitalgd.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
/**
* @author thuang
* @version 1.0
* @description: Swagger配置用来生成接口查看页面
* @date 2021/10/13 8:41
*/
@Configuration
@EnableSwagger2
public class SwaggerConfig {
@Bean
public Docket createRestApi() {
return new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo())
.select()
.apis(RequestHandlerSelectors.any())
.paths(PathSelectors.any()).build();
}
private ApiInfo apiInfo() {
return new ApiInfoBuilder()
.title("对账平台接口文档")
.description("对账系统前后端接口说明")
.version("1.0")
.build();
}
}

View File

@@ -0,0 +1,28 @@
package com.saye.hospitalgd.config;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;
/**
* Description: 配置虚拟路径
* @author dqzhang
* @created 2019年11月19日 下午3:26:06
*/
@Configuration
public class VirtualPathConfig extends WebMvcConfigurationSupport{
@Override
protected void addResourceHandlers(ResourceHandlerRegistry registry) {
//这样会在项目当前盘符下创建saye文件夹
registry.addResourceHandler("/showFile/**").addResourceLocations("file:/saye/");
registry.addResourceHandler("/**").addResourceLocations("classpath:/static/");
/*swagger 404静态资源配置*/
registry.addResourceHandler("/swagger-ui.html").addResourceLocations("classpath:/META-INF/resources/");
registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/");
super.addResourceHandlers(registry);
}
}

View File

@@ -0,0 +1,58 @@
package com.saye.hospitalgd.config;
import org.springframework.stereotype.Component;
import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;
@Component
public class XssFilter implements Filter {
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain filterChain) throws IOException, ServletException {
HttpServletRequest httpRequest = (HttpServletRequest)request;
HttpSession session = httpRequest.getSession(false);
String requestURI = httpRequest.getRequestURI();
if("/login".equals(requestURI)){
if ( session != null && !session.isNew() ) {
//首先将原session中的数据转移至一临时map中
Map<String,Object> tempMap = new HashMap();
Enumeration<String> sessionNames = session.getAttributeNames();
while(sessionNames.hasMoreElements()){
String sessionName = sessionNames.nextElement();
tempMap.put(sessionName, session.getAttribute(sessionName));
}
//注销原session为的是重置sessionId
session.invalidate();
//将临时map中的数据转移至新session
session = httpRequest.getSession();
for(Map.Entry<String, Object> entry : tempMap.entrySet()){
session.setAttribute(entry.getKey(), entry.getValue());
}
}
}
XssHttpServletRequestWrapper xssRequest = new XssHttpServletRequestWrapper((HttpServletRequest) request);
filterChain.doFilter(xssRequest, response);
}
@Override
public void destroy() {
}
@Override
public void init(FilterConfig filterConfig) {
}
}

View File

@@ -0,0 +1,131 @@
package com.saye.hospitalgd.config;
import com.alibaba.fastjson.JSONObject;
import com.alipay.api.internal.util.file.IOUtils;
import com.saye.hospitalgd.commons.string.StringDUtil;
import org.jsoup.Jsoup;
import org.jsoup.safety.Whitelist;
import javax.servlet.ReadListener;
import javax.servlet.ServletInputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletRequestWrapper;
import java.io.ByteArrayInputStream;
import java.io.IOException;
public class XssHttpServletRequestWrapper extends HttpServletRequestWrapper{
HttpServletRequest orgRequest = null;
private static final Whitelist whitelist = Whitelist.basicWithImages();
public XssHttpServletRequestWrapper(HttpServletRequest request) {
super(request);
orgRequest = request;
}
@Override
public ServletInputStream getInputStream() throws IOException {
ServletInputStream stream = null;
try {
stream = orgRequest.getInputStream();
String requestBody = IOUtils.toString(stream, "utf-8");
requestBody = Jsoup.clean(requestBody,whitelist);
JSONObject resultJson = JSONObject.parseObject(requestBody);
byte[] array = resultJson.toString().getBytes("utf-8");
if (array == null) {
array = new byte[0];
}
final ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(array);
return new ServletInputStream() {
@Override
public boolean isFinished() {
return false;
}
@Override
public boolean isReady() {
return false;
}
@Override
public void setReadListener(ReadListener readListener) {
}
@Override
public int read() {
return byteArrayInputStream.read();
}
};
} catch (IOException e) {
e.printStackTrace();
}
return super.getInputStream();
}
/**
* 覆盖getParameter方法将参数名和参数值都做xss过滤.
* 如果需要获得原始的值则通过super.getParameterValues(name)来获取
* getParameterNames,getParameterValues和getParameterMap也可能需要覆盖
*/
@Override
public String getParameter(String name) {
if (("content".equals(name) || name.endsWith("WithHtml"))) {
return super.getParameter(name);
}
name = Jsoup.clean(name,whitelist);
String value = super.getParameter(name);
if (StringDUtil.isNotBlank(value)) {
value = Jsoup.clean(value,whitelist);
}
return value;
}
@Override
public String[] getParameterValues(String name) {
String[] arr = super.getParameterValues(name);
if (arr != null) {
for (int i = 0; i < arr.length; i++) {
arr[i] = Jsoup.clean(arr[i],whitelist);
}
}
return arr;
}
/**
* 覆盖getHeader方法将参数名和参数值都做xss过滤。<br/>
* 如果需要获得原始的值则通过super.getHeaders(name)来获取<br/>
* getHeaderNames 也可能需要覆盖
*/
@Override
public String getHeader(String name) {
name = Jsoup.clean(name,whitelist);
String value = super.getHeader(name);
if (StringDUtil.isNotBlank(value)) {
value = Jsoup.clean(value,whitelist);
}
return value;
}
/**
* 获取最原始的request
*
* @return
*/
public HttpServletRequest getOrgRequest() {
return orgRequest;
}
/**
* 获取最原始的request的静态方法
*
* @return
*/
public static HttpServletRequest getOrgRequest(HttpServletRequest req) {
if (req instanceof XssHttpServletRequestWrapper) {
return ((XssHttpServletRequestWrapper) req).getOrgRequest();
}
return req;
}
}

View File

@@ -0,0 +1,23 @@
package com.saye.hospitalgd.config.dataSourceConfig;
import org.apache.ibatis.reflection.MetaObject;
import org.apache.ibatis.reflection.wrapper.MapWrapper;
import java.util.Map;
/**
* @author thuang
* @version 1.0
* @description: 用来将查询结果的key全转为大写
* @date 2021/5/8 10:05
*/
public class MapKeyUpperWrapper extends MapWrapper {
public MapKeyUpperWrapper(MetaObject metaObject, Map<String, Object> map) {
super(metaObject, map);
}
@Override
public String findProperty(String name, boolean useCamelCaseMapping) {
return name==null?"":name.toUpperCase() ;
}
}

View File

@@ -0,0 +1,26 @@
package com.saye.hospitalgd.config.dataSourceConfig;
import org.apache.ibatis.reflection.MetaObject;
import org.apache.ibatis.reflection.wrapper.ObjectWrapper;
import org.apache.ibatis.reflection.wrapper.ObjectWrapperFactory;
import java.util.Map;
/**
* @author thuang
* @version 1.0
* @description: 重写工厂类使用自定义的MapKeyUpperWrapper
* @date 2021/5/8 10:08
*/
public class MapWrapperFactory implements ObjectWrapperFactory {
@Override
public boolean hasWrapperFor(Object object) {
return object != null && object instanceof Map;
}
@Override
public ObjectWrapper getWrapperFor(MetaObject metaObject, Object object) {
return new MapKeyUpperWrapper(metaObject, (Map) object);
}
}

View File

@@ -0,0 +1,25 @@
package com.saye.hospitalgd.config.dataSourceConfig;
import org.apache.ibatis.reflection.wrapper.ObjectWrapperFactory;
import org.springframework.boot.context.properties.ConfigurationPropertiesBinding;
import org.springframework.core.convert.converter.Converter;
import org.springframework.stereotype.Component;
/**
* @author thuang
* @version 1.0
* @description: 自定义Convert 转换类 springboot只认ObjectWrapperFactory 自定义的那名字不认
* @date 2021/5/8 10:27
*/
@Component
@ConfigurationPropertiesBinding
public class ObjectWrapperFactoryConverter implements Converter<String, ObjectWrapperFactory> {
@Override
public ObjectWrapperFactory convert(String source) {
try {
return (ObjectWrapperFactory) Class.forName(source).newInstance();
} catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) {
throw new RuntimeException(e);
}
}
}

View File

@@ -0,0 +1,51 @@
package com.saye.hospitalgd.controller;
import com.saye.hospitalgd.commons.date.DateDUtil;
import com.saye.hospitalgd.model.Dicinfo;
import com.saye.hospitalgd.service.CashUnilateralService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
/**
* @author thuang
* @version 1.0
* @description: 现金单边账 废弃
* @date 2021/11/8 14:34
*/
@Controller
@RequestMapping("/cashUnilateral")
public class CashUnilateralController_delete {
@Autowired
private CashUnilateralService cashUnilateralService;
/**
* @description: 到单边账页面
* @author thuang
* @date 2021/11/8 14:40
* @version 1.0
*/
@RequestMapping("/toCashUnilateral")
public String toCashUnilateral(ModelMap modelMap){
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);
return "financialReconciliation/cashUnilateral";
}
}

View File

@@ -0,0 +1,315 @@
package com.saye.hospitalgd.controller.FinancialReconciliation;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.saye.hospitalgd.commons.date.DateDUtil;
import com.saye.hospitalgd.commons.log.ExceptionDUtil;
import com.saye.hospitalgd.commons.log.LogUtil;
import com.saye.hospitalgd.commons.string.StringDUtil;
import com.saye.hospitalgd.model.StatusDefine;
import com.saye.hospitalgd.service.ReconciliationResultService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.xssf.usermodel.*;
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 java.awt.*;
import java.io.File;
import java.io.FileOutputStream;
import java.util.List;
import java.util.*;
/**
* @author thuang
* @version 1.0
* @description: 对账结果
* @date 2021/8/31 10:17
*/
@Api(tags = "对账结果相关接口")
@Controller
@RequestMapping("/reconciliationResult")
public class ReconciliationResultController {
@Autowired
private ReconciliationResultService reconciliationResultService;
@RequestMapping("/toReconciliationResult")
public String toReconciliationResult(ModelMap modelMap) {
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);
return "financialReconciliation/reconciliationResult";
}
/**
* @description: 查询对账的结果记录
* @author thuang
* @date 2021/8/30 14:30
* @version 1.0
*/
@RequestMapping("/findReconciliationResultPageList")
@ResponseBody
@ApiOperation(value = "查询对账的结果记录")
public HashMap<Object, Object> findReconciliationResultPageList(@ApiParam(name = "开始时间") String startTime,
@ApiParam(name = "结束时间") String endTime,
@ApiParam(name = "页码") int page,
@ApiParam(name = "每页限制个数") int limit) {
HashMap<Object, Object> responseMap = new HashMap<Object, Object>();
try {
HashMap<Object, Object> map = new HashMap<Object, Object>();
map.put("startTime", startTime);
map.put("endTime", endTime);
PageHelper.startPage(page, limit);
PageInfo<HashMap<Object, Object>> pageInfo = new PageInfo<HashMap<Object, Object>>(reconciliationResultService.findReconciliationResultPageList(map));
responseMap.put("code", 0);
responseMap.put("msg", "OK");
responseMap.put("count", pageInfo.getTotal());
responseMap.put("data", pageInfo.getList());
} catch (Exception e) {
e.printStackTrace();
String msg = e.getMessage();
responseMap.put("code", 1);
responseMap.put("msg", "查询失败,原因:" + msg);
}
return responseMap;
}
/**
* @description: 导出对账结果excel
* @author thuang
* @date 2021/10/22 10:43
* @version 1.0
*/
@PostMapping("/exportReconciliationResult")
@ResponseBody
@ApiOperation(value = "导出对账结果excel")
public HashMap<Object, Object> exportReconciliationResult(@RequestBody HashMap<Object, Object> map) {
HashMap<Object, Object> responseMap = new HashMap<Object, Object>();
String errCode = "0";
String errMsg = "";
String dlName = "";
String fileName = "";
String dowloadName = StringDUtil.changeNullToEmpty(map.get("dowloadName"));
try {
String startTime = StringDUtil.changeNullToEmpty(map.get("startTime"));
String endTime = StringDUtil.changeNullToEmpty(map.get("endTime"));
List<HashMap<Object, Object>> list = reconciliationResultService.findReconciliationResultPageList(map);
if (list != null && list.size() > 0) {
//创建工作薄对象
XSSFWorkbook xwb = new XSSFWorkbook();//这里也可以设置sheet的Name
//创建工作表对象
XSSFSheet sheet = xwb.createSheet("sheet0");
//设置主标题样式
XSSFFont mainTitleFont = xwb.createFont();
mainTitleFont.setFontName("宋体");
mainTitleFont.setBoldweight(XSSFFont.BOLDWEIGHT_BOLD);//字体加粗
mainTitleFont.setFontHeightInPoints((short) 14);// 字体大小
XSSFCellStyle mainTitleStyle = xwb.createCellStyle();
mainTitleStyle.setFont(mainTitleFont);
mainTitleStyle.setAlignment(XSSFCellStyle.ALIGN_CENTER);// 左右居中
mainTitleStyle.setVerticalAlignment(XSSFCellStyle.VERTICAL_CENTER);// 上下居中
mainTitleStyle.setLocked(true);
//标题样式
XSSFFont titleFont = xwb.createFont();
titleFont.setFontName("宋体");
titleFont.setBoldweight(XSSFFont.BOLDWEIGHT_BOLD);//字体加粗
titleFont.setFontHeightInPoints((short) 10);// 字体大小
XSSFCellStyle titleStyle = xwb.createCellStyle();
titleStyle.setFont(titleFont);
titleStyle.setAlignment(XSSFCellStyle.ALIGN_CENTER);// 左右居中
titleStyle.setVerticalAlignment(XSSFCellStyle.VERTICAL_CENTER);// 上下居中
titleStyle.setFillForegroundColor(new XSSFColor(new Color(225, 225, 225)));
titleStyle.setFillBackgroundColor(new XSSFColor(new Color(225, 225, 225)));
titleStyle.setFillPattern(XSSFCellStyle.SPARSE_DOTS);
titleStyle.setBorderBottom(XSSFCellStyle.BORDER_THIN); // 下边框
titleStyle.setBorderLeft(XSSFCellStyle.BORDER_THIN);// 左边框
titleStyle.setBorderTop(XSSFCellStyle.BORDER_THIN);// 上边框
titleStyle.setBorderRight(XSSFCellStyle.BORDER_THIN);// 右边框
titleStyle.setLocked(true);
//内容样式
XSSFFont contentFont = xwb.createFont();
contentFont.setFontName("宋体");
contentFont.setFontHeightInPoints((short) 10);// 字体大小
XSSFCellStyle contentStyle = xwb.createCellStyle();
contentStyle.setFont(contentFont);
contentStyle.setAlignment(XSSFCellStyle.ALIGN_CENTER);// 左右居中
contentStyle.setVerticalAlignment(XSSFCellStyle.VERTICAL_CENTER);// 上下居中
contentStyle.setBorderBottom(XSSFCellStyle.BORDER_THIN); // 下边框
contentStyle.setBorderLeft(XSSFCellStyle.BORDER_THIN);// 左边框
contentStyle.setBorderTop(XSSFCellStyle.BORDER_THIN);// 上边框
contentStyle.setBorderRight(XSSFCellStyle.BORDER_THIN);// 右边框
contentStyle.setWrapText(true);
contentStyle.setLocked(true);
//标题
LinkedHashMap<String, String> titleMap = new LinkedHashMap<>();
// titleMap.put("院区", "1,2");//一列两行
titleMap.put("日期", "1,2");
titleMap.put("结算金额", "4,1");
titleMap.put("单边账", "2,1");
titleMap.put("对账情况", "1,1");
//第二行标题
List<String> titleList2 = new ArrayList<>();
titleList2.add("第三方支付结算");
titleList2.add("HIS结算金额");
titleList2.add("三方单边账");
titleList2.add("HIS单边账");
titleList2.add("处理历史单边账金额");
titleList2.add("当日结算单边账条数");
titleList2.add("是否通过");
//内容key
List<String> contentKey = new ArrayList<>();
// contentKey.add("AREA");
contentKey.add("TRADE_DATE");
contentKey.add("THIRD_MONEY");
contentKey.add("HIS_MONEY");
contentKey.add("THIRD_UNILATERAL");
contentKey.add("HIS_UNILATERAL");
contentKey.add("MANAGER_HISTORY_UNILATERAL");
contentKey.add("UNILATERAL_NUM");
contentKey.add("STATUS_STR");
//定义列宽
sheet.setColumnWidth(0, 5000);
sheet.setColumnWidth(1, 5000);
sheet.setColumnWidth(2, 5000);
sheet.setColumnWidth(3, 5000);
sheet.setColumnWidth(4, 5000);
sheet.setColumnWidth(5, 5000);
sheet.setColumnWidth(6, 5000);
sheet.setColumnWidth(7, 5000);
// sheet.setColumnWidth(8, 5000);
//刚开始先创建大标题
//设置行单元格合并
sheet.addMergedRegion(new CellRangeAddress(0, 0, 0, 7));
//创建工作表的行
XSSFRow mainRow = sheet.createRow(0);//设置第一行,从零开始
mainRow.setHeight((short) 375);
XSSFCell mainCell = mainRow.createCell(0);
mainCell.setCellStyle(mainTitleStyle);
mainCell.setCellValue(startTime + "~" + endTime + "对账结果表(金额单位:元)");
//创建标题行
XSSFRow titleRow1 = sheet.createRow(1);
XSSFRow titleRow2 = sheet.createRow(2);
int thisColNum = 0;
for (String title : titleMap.keySet()) {
String value = titleMap.get(title);
String[] split = value.split(",");
int colNum = Integer.parseInt(split[0]);
int rowNum = Integer.parseInt(split[1]);
XSSFCell cell = titleRow1.createCell(thisColNum);
cell.setCellStyle(titleStyle);
cell.setCellValue(title);
if (rowNum != 1) {
XSSFCell cell2 = titleRow2.createCell(thisColNum);
cell2.setCellStyle(titleStyle);
sheet.addMergedRegion(new CellRangeAddress(1, rowNum, thisColNum, thisColNum));
}
if (colNum != 1) {
for (int i = 1; i < colNum; i++) {
XSSFCell cell2 = titleRow1.createCell(thisColNum + i);
cell2.setCellStyle(titleStyle);
}
sheet.addMergedRegion(new CellRangeAddress(1, 1, thisColNum, thisColNum + colNum - 1));
}
//将大小加上 之后计算起始要用到
thisColNum = thisColNum + colNum;
}
//第二行标题
int title2StartCol = 1; //第二行标题开始列是第三列
for (int i = 0; i < titleList2.size(); i++) {
String title2 = titleList2.get(i);
XSSFCell cell2 = titleRow2.createCell(title2StartCol + i);
cell2.setCellStyle(titleStyle);
cell2.setCellValue(title2);
}
//循环内容
int startRow = 3; //标题加上抬头名称 共用了三行
for (int i = 0; i < list.size(); i++) {
int thisRow = startRow + i;
XSSFRow contentRow = sheet.createRow(thisRow);
HashMap<Object, Object> hashMap = list.get(i);
for (int j = 0; j < contentKey.size(); j++) {
String s = contentKey.get(j);
String content = StringDUtil.changeNullToEmpty(hashMap.get(s));
XSSFCell otherCell = contentRow.createCell(j);
otherCell.setCellStyle(contentStyle);
otherCell.setCellValue(content);
}
}
String randomStr = StringDUtil.generateRandomCodeForLength(4);
dlName = DateDUtil.DateToStr(DateDUtil.yyyyMMddHHmmss, new Date()) + randomStr;
fileName = dlName + ".xlsx";
String uploadPath = StatusDefine.filePath + "/ReconciliaionResult/";
File uploadPathFile = new File(uploadPath);
if (!uploadPathFile.exists()) uploadPathFile.mkdirs();
String savePath = uploadPath + fileName;
// 设置输入流
FileOutputStream fOut = new FileOutputStream(savePath);
// 将模板的内容写到输出文件上
xwb.write(fOut);
fOut.flush();
// 操作结束,关闭文件
fOut.close();
}
} catch (Exception e) {
errCode = "999";
errMsg = "未知异常:" + ExceptionDUtil.getDetailExceptionMsg(e);
LogUtil.error(this.getClass(), "@@@系统出错!【" + errMsg + "");
}
responseMap.put("errCode", errCode);
responseMap.put("errMsg", errMsg);
responseMap.put("dlName", "ReconciliaionResult/" + fileName);
return responseMap;
}
}

View File

@@ -0,0 +1,261 @@
package com.saye.hospitalgd.controller;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.saye.hospitalgd.commons.date.DateDUtil;
import com.saye.hospitalgd.commons.excel.ExportXLSX;
import com.saye.hospitalgd.commons.excel.HashMapConversionImpl;
import com.saye.hospitalgd.commons.excel.IConversionByExport;
import com.saye.hospitalgd.commons.log.ExceptionDUtil;
import com.saye.hospitalgd.commons.log.LogUtil;
import com.saye.hospitalgd.commons.string.StringDUtil;
import com.saye.hospitalgd.model.Dicinfo;
import com.saye.hospitalgd.model.StatusDefine;
import com.saye.hospitalgd.service.HisDetailService;
import com.saye.hospitalgd.service.system.DicinfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;
import java.io.File;
import java.util.*;
/**
* @author thuang
* @version 1.0
* @description: his账单明细
* @date 2021/9/28 11:13
*/
@Api(value = "his账单明细相关接口")
@Controller
@RequestMapping("/hisDetail")
public class HisDetailController {
@Autowired
private HisDetailService hisDetailService;
@Autowired
private DicinfoService dicinfoService;
@RequestMapping("/toHisDetail")
public String toHisDetail(ModelMap modelMap) {
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);
// 支付方式
List<Dicinfo> pay_type = dicinfoService.findDicinfoTreeNodeList("PAY_TYPE");
modelMap.addAttribute("payTypeList", pay_type);
// 业务类型
List<Dicinfo> biz_type = dicinfoService.findDicinfoTreeNodeList("BIZ_TYPE");
modelMap.addAttribute("bizTypeList", biz_type);
return "financialReconciliation/hisDetail";
}
/**
* @description: 查询his 详细记录
* @author thuang
* @date 2021/9/17 8:55
* @version 1.0
*/
@ApiOperation(value = "查询his详细记录", notes = "")
@GetMapping("/findHisDetail")
@ResponseBody
public HashMap<Object, Object> findHisDetail(@ApiParam(value = "付款方式") String payType, String startTime, String endTime, String likeFiled, int page, int limit) {
HashMap<Object, Object> responseMap = new HashMap<>();
try {
HashMap<Object, Object> map = new HashMap<Object, Object>();
map.put("payType", payType);
map.put("startTime", startTime);
map.put("endTime", endTime);
map.put("likeFiled", likeFiled);
PageHelper.startPage(page, limit);
PageInfo<HashMap<Object, Object>> pageInfo = new PageInfo<HashMap<Object, Object>>(hisDetailService.findHisDetail(map));
responseMap.put("code", 0);
responseMap.put("msg", "OK");
responseMap.put("count", pageInfo.getTotal());
responseMap.put("data", pageInfo.getList());
} catch (Exception e) {
e.printStackTrace();
String msg = e.getMessage();
responseMap.put("code", 1);
responseMap.put("msg", "查询失败,原因:" + msg);
}
return responseMap;
}
/**
* @description: 查询his记录统计数据
* @author thuang
* @date 2022/1/7 9:46
* @version 1.0
*/
@RequestMapping("/findHisCountData")
@ResponseBody
@ApiOperation(value = "查询his记录统计数据", notes = "")
public HashMap<Object, Object> findHisCountData(@RequestBody HashMap<Object, Object> map) {
HashMap<Object, Object> responseMap = new HashMap<Object, Object>();
String errCode = "0";
String errMsg = "";
try {
List<HashMap<Object, Object>> hisDetailCount = hisDetailService.findHisDetailCountData(map);
responseMap.put("money", hisDetailCount.get(0).get("MONEY"));
responseMap.put("num", hisDetailCount.get(0).get("NUM"));
} catch (Exception e) {
e.printStackTrace();
errCode = "999";
errMsg = "查询his记录统计数据原因" + e.getMessage();
}
responseMap.put("errCode", errCode);
responseMap.put("errMsg", errMsg);
return responseMap;
}
/**
* @description: 导出HIS明细
* @author thuang
* @date 2021/10/22 15:12
* @version 1.0
*/
@RequestMapping("/exportHisDetail")
@ResponseBody
@ApiOperation(value = "导出HIS明细", notes = "")
public HashMap<Object, Object> exportHisDetail(@RequestBody HashMap<Object, Object> map) {
HashMap<Object, Object> responseMap = new HashMap<Object, Object>();
String errCode = "0";
String errMsg = "";
String dlName = "";
String fileName = "";
String dowloadName = StringDUtil.changeNullToEmpty(map.get("dowloadName"));
try {
List<HashMap<Object, Object>> list = hisDetailService.findHisDetail(map);
// 支付方式
List<Dicinfo> pay_type = dicinfoService.findDicinfoTreeNodeList("PAY_TYPE");
HashMap<String, String> peyTypeMap = new HashMap<>();
for (Dicinfo dicinfo : pay_type) {
peyTypeMap.put(dicinfo.getDicvalue(), dicinfo.getDicname());
}
// 业务类型
List<Dicinfo> biz_type = dicinfoService.findDicinfoTreeNodeList("BIZ_TYPE");
HashMap<String, String> bizTypeMap = new HashMap<>();
for (Dicinfo dicinfo : biz_type) {
bizTypeMap.put(dicinfo.getDicvalue(), dicinfo.getDicname());
}
for (HashMap<Object, Object> hashMap : list) {
String paymethod = StringDUtil.changeNullToEmpty(hashMap.get("VISITZORG"));
if ("1".equals(paymethod)) {
hashMap.put("VISITZORG", "门诊");
} else if ("2".equals(paymethod)) {
hashMap.put("VISITZORG", "住院");
} else {
hashMap.put("VISITZORG", "");
}
String tradingStatus = StringDUtil.changeNullToEmpty(hashMap.get("H_JYLX"));
if ("1".equals(tradingStatus)) {
hashMap.put("H_JYLX", "收款记录");
} else if ("2".equals(tradingStatus)) {
hashMap.put("H_JYLX", "退款记录");
} else {
hashMap.put("H_JYLX", "");
}
String biztype = StringDUtil.changeNullToEmpty(hashMap.get("BIZTYPE"));
hashMap.put("BIZTYPE", bizTypeMap.get(biztype));
String paytype = StringDUtil.changeNullToEmpty(hashMap.get("PAYTYPE"));
hashMap.put("PAYTYPE", peyTypeMap.get(paytype));
}
if (list.size() > 0) {
// 定义标题头和文件名
String[] DISTANCE_HEADERNAME = {"交易状态", "业务类型", "支付方式", "交易时间", "交易日期", "操作员", "总金额", "平台交易号", "his订单号", "患者id", "患者姓名", "来源"};
String[] sqlKey = {"TRADINGSTATUS", "BIZTYPE", "PAYTYPE", "TRADETIME", "TRADE_DATE", "HISOPERCODE", "AMOUNT", "PLATFORMTRANSID", "HISTRANSID", "PATIENTID", "PATIENTNAME", "SOURCE"};
List<Object> rulList = new ArrayList<Object>(list);
// 创建工作表
ExportXLSX exportXLS = new ExportXLSX(DISTANCE_HEADERNAME, sqlKey, ExportXLSX.A3, false);
exportXLS.setTitleName(dowloadName);
IConversionByExport conversion = new HashMapConversionImpl();
exportXLS.setConversion(conversion);
exportXLS.setData(rulList);
exportXLS.modifyWidthOfHeader("5000", 0);
exportXLS.modifyWidthOfHeader("5000", 1);
exportXLS.modifyWidthOfHeader("5000", 2);
exportXLS.modifyWidthOfHeader("5000", 3);
exportXLS.modifyWidthOfHeader("5000", 4);
exportXLS.modifyWidthOfHeader("5000", 5);
exportXLS.modifyWidthOfHeader("8000", 6);
exportXLS.modifyWidthOfHeader("5000", 7);
exportXLS.modifyWidthOfHeader("5000", 8);
exportXLS.modifyWidthOfHeader("5000", 9);
exportXLS.modifyWidthOfHeader("5000", 10);
exportXLS.modifyWidthOfHeader("10000", 11);
// exportXLS.modifyWidthOfHeader("5000", 12);
// 文件名称
// 产生4位长度的随机码由字母和数字组成
String randomStr = StringDUtil.generateRandomCodeForLength(4);
dlName = DateDUtil.DateToStr(DateDUtil.yyyyMMddHHmmss, new Date()) + randomStr;
fileName = dlName + ".xlsx";
String uploadPath = StatusDefine.filePath + "/HisDetail/";
File uploadPathFile = new File(uploadPath);
if (!uploadPathFile.exists()) uploadPathFile.mkdirs();
String savePath = uploadPath + fileName;
exportXLS.execGenerateExcel(savePath);
}
} catch (Exception e) {
errCode = "999";
errMsg = "未知异常:" + ExceptionDUtil.getDetailExceptionMsg(e);
LogUtil.error(this.getClass(), "@@@系统出错!【" + errMsg + "");
}
responseMap.put("errCode", errCode);
responseMap.put("errMsg", errMsg);
responseMap.put("dlName", "HisDetail/" + fileName);
return responseMap;
}
}

View File

@@ -0,0 +1,730 @@
package com.saye.hospitalgd.controller;
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.*;
import com.saye.hospitalgd.service.system.DicinfoService;
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 java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.*;
/**
* @author thuang
* @version 1.0
* @description: 主页数据
* @date 2021/10/15 15:54
*/
@RequestMapping("/home")
@Controller
@Slf4j
@Api(tags = "主页数据")
public class HomeDateController {
@Autowired
private UnilateralService unilateralService;
@Autowired
private DicinfoService dicinfoService;
@Autowired
private BankbillHistoryService bankbillHistoryService;
@Autowired
private HisInterFaceConfigService hisInterFaceConfigService;
@Autowired
private HisDetailService hisDetailService;
@Autowired
private TransactionDetailService transactionDetailService;
/**
* @param modelMap
* @return
* @description 主页面
* @author dqzhang
* @created 2019年11月13日 下午5:10:21
*/
@RequestMapping("/toHome")
public String home(ModelMap modelMap) {
return "home/home";
}
/**
* @description: 查询对账总览数据
* @author thuang
* @date 2021/9/18 16:26
* @version 1.0
*/
@RequestMapping("/findDZData")
@ResponseBody
@ApiOperation(value = "查询对账总览数据")
public HashMap<Object, Object> findDZData(@RequestBody HashMap<Object, Object> map) {
HashMap<Object, Object> responseMap = new HashMap<>();
String errCode = "0";
String errMsg = "";
try {
//查询关联表数据
map.put("is_active", "1");
map.put("check_result", "1");
List<HashMap<Object, Object>> hisAndThirdJoinData = transactionDetailService.findHisAndThirdJoinData(map);
int unilateralNum = hisAndThirdJoinData.size();
BigDecimal his_unilateral = new BigDecimal(0);
BigDecimal third_unilateral = new BigDecimal(0);
for (int i = 0; i < hisAndThirdJoinData.size(); i++) {
HashMap<Object, Object> hashMap = hisAndThirdJoinData.get(i);
String his_money = StringDUtil.changeNullToEmpty(hashMap.get("AMOUNT"));
if (!"".equals(his_money)) {
his_unilateral = his_unilateral.add(new BigDecimal(his_money));
}
String third_money = StringDUtil.changeNullToEmpty(hashMap.get("I_JYJE"));
if (!"".equals(third_money)) {
third_unilateral = third_unilateral.add(new BigDecimal(third_money));
}
}
responseMap.put("unilateralNum", unilateralNum);
responseMap.put("his_unilateral", his_unilateral);
responseMap.put("third_unilateral", third_unilateral);
} catch (Exception e) {
e.printStackTrace();
}
responseMap.put("errCode", errCode);
responseMap.put("errMsg", errMsg);
return responseMap;
}
/**
* @description: 查询交易总览数据
* @author thuang
* @date 2021/10/15 16:08
* @version 1.0
*/
@RequestMapping("/findJYData")
@ResponseBody
@ApiOperation(value = "查询交易总览数据")
public HashMap<Object, Object> findJYData(@RequestBody HashMap<Object, Object> map) {
HashMap<Object, Object> responseMap = new HashMap<>();
String errCode = "0";
String errMsg = "";
try {
String startTime = StringDUtil.changeNullToEmpty(map.get("startTime"));
String endTime = StringDUtil.changeNullToEmpty(map.get("endTime"));
//计算两个日期间总共的天
//先计算相差几天
long daysOfTowDiffDate = DateDUtil.getDaysOfTowDiffDate(startTime, endTime);
//补充被减的当天
daysOfTowDiffDate++;
//从关联表查询交易笔数和金额
List<HashMap<Object, Object>> list = transactionDetailService.findAllBankDetailNum(map);
int num = 0;
if (list.size() > 0) {
num = Integer.parseInt(StringDUtil.changeNullToEmpty(list.get(0).get("NUM")));
}
BigDecimal avgNum = new BigDecimal(num).divide(new BigDecimal(daysOfTowDiffDate), 0, BigDecimal.ROUND_HALF_UP);
List<HashMap<Object, Object>> list2 = transactionDetailService.findAllBankDetailSum(map);
BigDecimal money = new BigDecimal(0);
if (list2.size() > 0) {
money = new BigDecimal(StringDUtil.changeNullToEmpty(list2.get(0).get("MONEY")));
}
BigDecimal avgMoney = money.divide(new BigDecimal(daysOfTowDiffDate), 2, BigDecimal.ROUND_HALF_UP);
money = money.setScale(2, BigDecimal.ROUND_HALF_UP);
responseMap.put("allNum", num);
responseMap.put("avgNum", avgNum);
responseMap.put("allMoney", money);
responseMap.put("avgMoney", avgMoney);
} catch (Exception e) {
e.printStackTrace();
}
responseMap.put("errCode", errCode);
responseMap.put("errMsg", errMsg);
return responseMap;
}
/**
* @description: 查询单边账数量
* @author thuang
* @date 2021/10/18 13:14
* @version 1.0
*/
@PostMapping("/findDBZNum")
@ResponseBody
@ApiOperation(value = "查询单边账数量")
public HashMap<Object, Object> findDBZNum(@RequestBody HashMap<Object, Object> map) {
HashMap<Object, Object> responseMap = new HashMap<>();
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);
//先生成key为日期的linkhashMap
LinkedHashMap<String, Integer> numMap = new LinkedHashMap<String, Integer>();
for (String day : betweenDate) {
numMap.put(day, 0);
}
List<HashMap<Object, Object>> list = transactionDetailService.findDBZNum(map);
for (HashMap<Object, Object> hashMap : list) {
String trade_date = StringDUtil.changeNullToEmpty(hashMap.get("TRADE_DATE"));
String num = StringDUtil.changeNullToEmpty(hashMap.get("NUM"));
numMap.put(trade_date, Integer.parseInt(num));
}
List<String> betweenDateList = new ArrayList<>();
List<Integer> numList = new ArrayList<>();
SimpleDateFormat sdf = new SimpleDateFormat("MM/dd");
for (String key : numMap.keySet()) {
Date date = DateDUtil.strToDate(DateDUtil.yyyy_MM_dd, key);
betweenDateList.add(sdf.format(date));
Integer integer = numMap.get(key);
numList.add(integer);
}
responseMap.put("betweenDate", betweenDateList);
responseMap.put("numList", numList);
} 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/10/18 14:10
* @version 1.0
*/
@PostMapping("/findDBZPro")
@ResponseBody
@ApiOperation(value = "查询单边账概率")
public HashMap<Object, Object> findDBZPro(@RequestBody HashMap<Object, Object> map) {
HashMap<Object, Object> responseMap = new HashMap<>();
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 ((dicname).contains("微信支付") || (dicname).contains("支付宝支付")) {
payMethodMap.put(dicvalue, dicname);
}
}
//先组织好map
LinkedHashMap<String, LinkedHashMap<String, String>> managerMap = new LinkedHashMap<>();// 每天每种数量map
LinkedHashMap<String, LinkedHashMap<String, String>> unilateralMap = new LinkedHashMap<>();// 单边账记录数map
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));
}
managerMap.put("微信支付", new LinkedHashMap<String, String>() {{
putAll(addMap);
}});
managerMap.put("支付宝支付", new LinkedHashMap<String, String>() {{
putAll(addMap);
}});
managerMap.put("其他", new LinkedHashMap<String, String>() {{
putAll(addMap);
}});
unilateralMap.put("微信支付", new LinkedHashMap<String, String>() {{
putAll(addMap);
}});
unilateralMap.put("支付宝支付", new LinkedHashMap<String, String>() {{
putAll(addMap);
}});
unilateralMap.put("其他", new LinkedHashMap<String, String>() {{
putAll(addMap);
}});
//返回格式化后的日期数组
responseMap.put("betweenDate", betweenDateList);
//查询能对上的数量 对不上的都不能确定该记录是否存在 所以除以对的上的数量
map.put("is_active", "1");
List<HashMap<Object, Object>> list = transactionDetailService.findJoinDataNumByTime(map);
for (HashMap<Object, Object> hashMap : list) {
String i_jyqd = StringDUtil.changeNullToEmpty(hashMap.get("I_ZFFS"));
String i_jyrq = StringDUtil.changeNullToEmpty(hashMap.get("TRADE_DATE"));
String totalNum = StringDUtil.changeNullToEmpty(hashMap.get("TOTALNUM"));
String str_zffs = "";
String s = payMethodMap.get(i_jyqd);
if (s == null) {
str_zffs = "其他";
} else {
str_zffs = s;
}
LinkedHashMap<String, String> zffsMap = managerMap.get(str_zffs);
/*if (zffsMap==null){
managerMap.put(str_zffs,new LinkedHashMap<String,String>(){{putAll(addMap);}});
zffsMap = managerMap.get(str_zffs);
}*/
String countNum = zffsMap.get(i_jyrq);
countNum = new BigDecimal(countNum).add(new BigDecimal(totalNum)).toString();
zffsMap.put(i_jyrq, countNum);
}
//查询单边账记录
List<HashMap<Object, Object>> dbzList = transactionDetailService.findDBZFLNumByTime(map);
for (HashMap<Object, Object> hashMap : dbzList) {
String payType = StringDUtil.changeNullToEmpty(hashMap.get("I_ZFFS"));
String trade_date = StringDUtil.changeNullToEmpty(hashMap.get("TRADE_DATE"));
String num = StringDUtil.changeNullToEmpty(hashMap.get("NUM"));
String str_zffs = "";
String s = payMethodMap.get(payType);
if (s == null) {
str_zffs = "其他";
} else {
str_zffs = s;
}
LinkedHashMap<String, String> zffsMap = unilateralMap.get(str_zffs);
/*if (zffsMap==null){
unilateralMap.put(str_zffs,new LinkedHashMap<String,String>(){{putAll(addMap);}});
zffsMap = unilateralMap.get(str_zffs);
}*/
String countNum = zffsMap.get(trade_date);
countNum = new BigDecimal(countNum).add(new BigDecimal(num)).toString();
zffsMap.put(trade_date, countNum);
}
LinkedHashMap<String, String> alldayNumMap = new LinkedHashMap<>();
LinkedHashMap<String, String> allDBZMap = new LinkedHashMap<>();
List<HashMap<String, Object>> resultManagerList = new ArrayList<>();
//key 支付方式
for (String key : unilateralMap.keySet()) {
LinkedHashMap<String, String> dbzMap = unilateralMap.get(key);
LinkedHashMap<String, String> allMap = managerMap.get(key);
List<String> newList = new ArrayList<>();
//key2 日期
for (String key2 : dbzMap.keySet()) {
String dbzNum = dbzMap.get(key2);
String allNum = allMap.get(key2);
//统计总共
String num = alldayNumMap.get(key2);
if (num != null) {
alldayNumMap.put(key2, new BigDecimal(num).add(new BigDecimal(allNum)).toString());
} else {
alldayNumMap.put(key2, allNum);
}
//统计单边账总共
String dbz = allDBZMap.get(key2);
if (dbz != null) {
allDBZMap.put(key2, new BigDecimal(dbz).add(new BigDecimal(dbzNum)).toString());
} else {
allDBZMap.put(key2, dbzNum);
}
//计算不同支付方式的数据
if ("0".equals(dbzNum)) {
newList.add("0");
} else {
if ("0".equals(allNum)) {
newList.add("100");
} else {
BigDecimal divide = new BigDecimal(dbzNum).multiply(new BigDecimal(100)).divide(new BigDecimal(allNum), 2, BigDecimal.ROUND_HALF_UP);
if (divide.compareTo(new BigDecimal(100)) > 0) {
newList.add("100");
} else {
newList.add(divide.toString());
}
}
}
}
HashMap<String, Object> newMap = new HashMap<>();
newMap.put("name", key);
newMap.put("data", newList);
resultManagerList.add(newMap);
}
List<HashMap<String, Object>> resultList = new ArrayList<>();
//计算总共的
HashMap<String, Object> newMap = new HashMap<>();
List<String> newList = new ArrayList<>();
newMap.put("name", "全部");
for (String s : allDBZMap.keySet()) {
String dbzNum = allDBZMap.get(s);
String allNum = alldayNumMap.get(s);
//计算不同支付方式的数据
if ("0".equals(dbzNum)) {
newList.add("0");
} else {
if ("0".equals(allNum)) {
newList.add("100");
} else {
BigDecimal divide = new BigDecimal(dbzNum).multiply(new BigDecimal(100)).divide(new BigDecimal(allNum), 2, BigDecimal.ROUND_HALF_UP);
if (divide.compareTo(new BigDecimal(100)) > 0) {
newList.add("100");
} else {
newList.add(divide.toString());
}
}
}
}
newMap.put("data", newList);
resultList.add(newMap);
resultList.addAll(resultManagerList);
responseMap.put("resultList", resultList);
} 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/10/18 14:51
* @version 1.0
*/
@PostMapping("/findjyqsChartsData")
@ResponseBody
@ApiOperation(value = "查询交易趋势")
public HashMap<Object, Object> findjyqsChartsData(@RequestBody HashMap<Object, Object> map) {
HashMap<Object, Object> responseMap = new HashMap<>();
String errCode = "0";
String errMsg = "";
try {
String startTime = StringDUtil.changeNullToEmpty(map.get("startTime"));
String endTime = StringDUtil.changeNullToEmpty(map.get("endTime"));
String num = StringDUtil.changeNullToEmpty(map.get("num")); //1笔数 2金额
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 ((dicname).contains("微信支付") || (dicname).contains("支付宝支付")) {
payMethodMap.put(dicvalue, dicname);
}
}
//先组织好map
LinkedHashMap<String, LinkedHashMap<String, String>> managerMap = 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));
}
managerMap.put("微信支付", new LinkedHashMap<String, String>() {{
putAll(addMap);
}});
managerMap.put("支付宝支付", new LinkedHashMap<String, String>() {{
putAll(addMap);
}});
managerMap.put("其他", new LinkedHashMap<String, String>() {{
putAll(addMap);
}});
//返回格式化后的日期数组
responseMap.put("betweenDate", betweenDateList);
//查询一段时间内每种支付方式的笔数或金额 以银行端为主要数据 num为区分查询笔数还是金额
if ("1".equals(num)) {
List<HashMap<Object, Object>> thirdList = transactionDetailService.findBankBillNumByTime(map);
for (HashMap<Object, Object> hashMap : thirdList) {
String num1 = StringDUtil.changeNullToEmpty(hashMap.get("NUM"));
String i_jyrq = StringDUtil.changeNullToEmpty(hashMap.get("TRADE_DATE"));
String i_zffs = StringDUtil.changeNullToEmpty(hashMap.get("I_JYQD"));
String str_zffs = "";
String s = payMethodMap.get(i_zffs);
if (s == null) {
str_zffs = "其他";
} else {
str_zffs = s;
}
LinkedHashMap<String, String> zffsMap = managerMap.get(str_zffs);
/*if (zffsMap==null){
managerMap.put(str_zffs,new LinkedHashMap<String,String>(){{putAll(addMap);}});
zffsMap = managerMap.get(str_zffs);
}*/
String countNum = zffsMap.get(i_jyrq);
countNum = new BigDecimal(countNum).add(new BigDecimal(num1)).toString();
zffsMap.put(i_jyrq, countNum);
}
} else if ("2".equals(num)) {
List<HashMap<Object, Object>> thirdList = transactionDetailService.findBankBillMoneyByTime(map);
for (HashMap<Object, Object> hashMap : thirdList) {
String money = StringDUtil.changeNullToEmpty(hashMap.get("MONEY"));
log.info("hhuoqude money is :" + money);
String i_jyrq = StringDUtil.changeNullToEmpty(hashMap.get("TRADE_DATE"));
String i_zffs = StringDUtil.changeNullToEmpty(hashMap.get("I_JYQD"));
String str_zffs = "";
String s = payMethodMap.get(i_zffs);
if (s == null) {
str_zffs = "其他";
} else {
str_zffs = s;
}
LinkedHashMap<String, String> zffsMap = managerMap.get(str_zffs);
/*if (zffsMap==null){
managerMap.put(str_zffs,new LinkedHashMap<String,String>(){{putAll(addMap);}});
zffsMap = managerMap.get(str_zffs);
}*/
String countNum = zffsMap.get(i_jyrq);
countNum = new BigDecimal(countNum).add(new BigDecimal(money)).toString();
zffsMap.put(i_jyrq, countNum);
}
}
//将linkedHashMap转为list<hashMap<>> hashMap 中 name 支付方式data list集合 内容为计算的数据
List<HashMap<String, Object>> resultList = new ArrayList<>();
for (String key : managerMap.keySet()) {
LinkedHashMap<String, String> linkedHashMap = managerMap.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);
resultList.add(newMap);
}
responseMap.put("resultList", resultList);
} 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/10/18 14:51
* @version 1.0
*/
@PostMapping("/findjyzbChartsData")
@ResponseBody
@ApiOperation(value = "查询交易占比")
public HashMap<Object, Object> findjyzbChartsData(@RequestBody HashMap<Object, Object> map) {
HashMap<Object, Object> responseMap = new HashMap<>();
String errCode = "0";
String errMsg = "";
try {
String startTime = StringDUtil.changeNullToEmpty(map.get("startTime"));
String endTime = StringDUtil.changeNullToEmpty(map.get("endTime"));
String num = StringDUtil.changeNullToEmpty(map.get("num"));//1笔数 2金额
//查询字典表支付方式
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 (dicname.contains("微信") || dicname.contains("支付宝")) {
payMethodMap.put(dicvalue, dicname);
}
}
//查询一段时间内每种支付方式的笔数或金额 以银行端为主要数据
List<HashMap<Object, Object>> resultList = new ArrayList<>();
String allDataNum = "";
if ("1".equals(num)) {
List<HashMap<Object, Object>> thirdList = transactionDetailService.findBankBillNumByTime(map);
//循环记录 只分为支付宝和其他
String oldZffs = "";
HashMap<String, String> newMap = new HashMap<>();
int jyNum = 0;
int allNum = 0;
for (int i = 0; i < thirdList.size(); i++) {
HashMap<Object, Object> hashMap = thirdList.get(i);
String num1 = StringDUtil.changeNullToEmpty(hashMap.get("NUM"));
String i_jyrq = StringDUtil.changeNullToEmpty(hashMap.get("TRADE_DATE"));
String i_zffs = StringDUtil.changeNullToEmpty(hashMap.get("I_JYQD"));
allNum = allNum + Integer.parseInt(num1);
String s = payMethodMap.get(i_zffs);
if (s == null) {
s = "其他";
}
String numStr = newMap.get(s);
if (numStr == null) {
newMap.put(s, "0");
}
numStr = newMap.get(s);
int thisNum = Integer.parseInt(numStr) + Integer.parseInt(num1);
newMap.put(s, "" + thisNum);
}
for (String key : newMap.keySet()) {
String s = newMap.get(key);
HashMap<Object, Object> addMap = new HashMap<>();
addMap.put("name", key);
addMap.put("value", s);
resultList.add(addMap);
}
allDataNum = "" + allNum;
} else if ("2".equals(num)) {
List<HashMap<Object, Object>> thirdList = transactionDetailService.findBankBillMoneyByTime(map);
String oldZffs = "";
HashMap<String, String> newMap = new HashMap<>();
BigDecimal addMoney = new BigDecimal(0);
BigDecimal allMoney = new BigDecimal(0);
for (int i = 0; i < thirdList.size(); i++) {
HashMap<Object, Object> hashMap = thirdList.get(i);
String money = StringDUtil.changeNullToEmpty(hashMap.get("MONEY"));
String i_jyrq = StringDUtil.changeNullToEmpty(hashMap.get("TRADE_DATE"));
String i_zffs = StringDUtil.changeNullToEmpty(hashMap.get("I_JYQD"));
addMoney = addMoney.add(new BigDecimal(money));
allMoney = allMoney.add(new BigDecimal(money));
String s = payMethodMap.get(i_zffs);
if (s == null) {
s = "其他";
}
String moneyStr = newMap.get(s);
if (moneyStr == null) {
newMap.put(s, "0");
}
moneyStr = newMap.get(s);
BigDecimal thisMoney = new BigDecimal(moneyStr).add(new BigDecimal(money));
newMap.put(s, thisMoney.toString());
}
for (String key : newMap.keySet()) {
String s = newMap.get(key);
HashMap<Object, Object> addMap = new HashMap<>();
addMap.put("name", key);
addMap.put("value", s);
resultList.add(addMap);
}
allDataNum = allMoney.toString();
}
responseMap.put("resultList", resultList);
responseMap.put("allDataNum", allDataNum);
//厂商
// List<HashMap<Object, Object>> firmlist = hisInterFaceConfigService.findAllconfig();
// HashMap<String, String> firmMap = new HashMap<>();
// for (HashMap<Object, Object> hashMap : firmlist) {
// String id = StringDUtil.changeNullToEmpty(hashMap.get("ID"));
// String his_interface_name = StringDUtil.changeNullToEmpty(hashMap.get("HIS_INTERFACE_NAME"));
// firmMap.put(id, his_interface_name);
// }
//
// List<HashMap<Object, Object>> firmNumList = hisDetailService.findHisDetailFirmNumByTime(map);
// List<HashMap<Object, Object>> firmNumResultList = new ArrayList<>();
// for (HashMap<Object, Object> hashMap : firmNumList) {
// String his_wsdl_id = StringDUtil.changeNullToEmpty(hashMap.get("HIS_WSDL_ID"));
// String firmNum = StringDUtil.changeNullToEmpty(hashMap.get("FIRMNUM"));
//
// HashMap<Object, Object> newMap = new HashMap<>();
// newMap.put("name", firmMap.get(his_wsdl_id));
// newMap.put("value", firmNum);
// firmNumResultList.add(newMap);
// }
//
// responseMap.put("firmNumResultList", firmNumResultList);
} catch (Exception e) {
e.printStackTrace();
errCode = "999";
errMsg = "查询交易趋势失败,原因:" + e.getMessage();
}
responseMap.put("errCode", errCode);
responseMap.put("errMsg", errMsg);
return responseMap;
}
}

View File

@@ -0,0 +1,157 @@
package com.saye.hospitalgd.controller;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.saye.hospitalgd.service.OperatorService;
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.HashMap;
/**
* @author thuang
* @version 1.0
* @description: 操作员
* @date 2021/9/29 14:51
*/
@Controller
@RequestMapping("/operator")
@Api(tags = "操作员相关接口")
public class OperatorController {
@Autowired
private OperatorService operatorService;
@RequestMapping("/toOperator")
public String toOperator(ModelMap modelMap) {
return "operator/operator";
}
/**
* @description: 查询操作员
* @author thuang
* @date 2021/9/17 8:55
* @version 1.0
*/
@RequestMapping("/findOperator")
@ResponseBody
@ApiOperation("查询操作员")
public HashMap<Object, Object> findOperator(String likeFiled, String is_active, int page, int limit) {
HashMap<Object, Object> responseMap = new HashMap<>();
try {
HashMap<Object, Object> map = new HashMap<Object, Object>();
map.put("likeFiled", likeFiled);
map.put("is_active", is_active);
PageHelper.startPage(page, limit);
PageInfo<HashMap<Object, Object>> pageInfo = new PageInfo<HashMap<Object, Object>>(operatorService.findAllOperator(map));
responseMap.put("code", 0);
responseMap.put("msg", "OK");
responseMap.put("count", pageInfo.getTotal());
responseMap.put("data", pageInfo.getList());
} catch (Exception e) {
e.printStackTrace();
String msg = e.getMessage();
responseMap.put("code", 1);
responseMap.put("msg", "查询失败,原因:" + msg);
}
return responseMap;
}
/**
* @description: 添加操作员 根据操作员号如果已有 更新,并且设置启用
* @author thuang
* @date 2021/9/30 10:17
* @version 1.0
*/
@RequestMapping("/addOperator")
@ResponseBody
@ApiOperation(value = "添加操作员 根据操作员号如果已有 更新,并且设置启用")
public HashMap<Object, Object> addOperator(@RequestBody HashMap<Object, Object> map) {
HashMap<Object, Object> responseMap = new HashMap<>();
String errCode = "0";
String errMsg = "";
try {
operatorService.addOperator(map);
} 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/9/30 10:44
* @version 1.0
*/
@RequestMapping("/modifyOperator")
@ResponseBody
@ApiOperation(value = "修改操作员")
public HashMap<Object, Object> modifyOperator(@RequestBody HashMap<Object, Object> map) {
HashMap<Object, Object> responseMap = new HashMap<>();
String errCode = "0";
String errMsg = "";
try {
operatorService.modifyOperator(map);
} 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/9/30 10:44
* @version 1.0
*/
@RequestMapping("/deleteOperator")
@ResponseBody
@ApiOperation(value = "删除操作员")
public HashMap<Object, Object> deleteOperator(@RequestBody HashMap<Object, Object> map) {
HashMap<Object, Object> responseMap = new HashMap<>();
String errCode = "0";
String errMsg = "";
try {
operatorService.deleteOperator(map);
} catch (Exception e) {
e.printStackTrace();
errCode = "999";
errMsg = "删除操作员失败,原因:" + e.getMessage();
}
responseMap.put("errCode", errCode);
responseMap.put("errMsg", errMsg);
return responseMap;
}
}

View File

@@ -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;
}
}

View File

@@ -0,0 +1,180 @@
package com.saye.hospitalgd.controller;
import com.saye.hospitalgd.commons.date.DateDUtil;
import com.saye.hospitalgd.service.BankbillsHistoryService;
import com.saye.hospitalgd.service.HisbillsHistoryService;
import com.saye.hospitalgd.service.HisbillsOriginalService;
import com.saye.hospitalgd.util.CSVUtils;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
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 org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
import java.io.InputStream;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.regex.Pattern;
/**
* Created with IntelliJ IDEA.
*
* @author Mr.zs
* @date 2022/12/2
* @description
* @modifiedBy
* @version: 1.0
*/
@Slf4j
@Controller
@RequestMapping("/receiveData")
public class ReceiveDataController {
@Autowired
private BankbillsHistoryService bankbillsHistoryService;
@Autowired
private HisbillsHistoryService hisbillsHistoryService;
@Autowired
private HisbillsOriginalService hisbillsOriginalService;
// @Autowired
// private HisInterfaceCountService hisInterfaceCountService;
@PostMapping("/receiveHisData")
@ResponseBody
public Map<Object, Object> receiveHisData(@RequestBody HashMap<Object, Object> hisbillsOriginal) {
log.info("接收到数据:" + hisbillsOriginal);
Map<Object, Object> responseMap = new HashMap<>();
try {
//保存一份最初的
hisbillsOriginalService.saveHisOriginalData(hisbillsOriginal);
//保存一份历史的
hisbillsHistoryService.saveHisHistoryData(hisbillsOriginal);
log.info("his数据保存完毕");
// //查看数据库今日接口统计是否记录
// int i = hisInterfaceCountService.searchToday();
// if (i > 0) {
// hisInterfaceCountService.updateConut();
// } else {
// hisInterfaceCountService.insertCount();
// }
responseMap.put("code", 0);
responseMap.put("msg", "OK");
//记录接口调用情况
} catch (Exception e) {
log.error("his数据保存失败原因" + e.getMessage());
responseMap.put("code", 999);
responseMap.put("msg", e.getMessage());
}
return responseMap;
}
@PostMapping("/receiveBankData")
@ResponseBody
public Map<Object, Object> receiveHisData(@RequestBody MultipartFile spareFile) {
String errCode = "0";
String errMsg = "";
List<HashMap<Object, Object>> savList = new ArrayList<>();
//校验文件名是否正确
String fileName = spareFile.getOriginalFilename();
Pattern pattern = Pattern.compile("^[-\\+]?[\\d]*$");
String substring = fileName.substring(0, 8);
boolean matches = pattern.matcher(substring).matches();
log.info("match is :" + matches);
if (matches) {
log.info("切割出来的字符串是" + substring);
String year = substring.substring(0, 4);
String month = substring.substring(4, 6);
String day = substring.substring(6, 8);
String rq = year + "-" + month + "-" + day;
log.info("日期是: " + rq);
} else {
errCode = "999";
errMsg = "文件名不合法";
}
if (!spareFile.isEmpty()) {
List<String[]> list = null;
try {
InputStream inputStream = spareFile.getInputStream();
list = CSVUtils.getCsvData(inputStream);
} catch (IOException e) {
errCode = "999";
errMsg = "获取文件失败";
e.printStackTrace();
}
if (list.size() != 0) {
for (int i = 5; i < list.size() - 2; i++) {
String[] s = list.get(i);
//遍历去除读取文件时字段前面读取的等号
for (int i1 = 0; i1 < s.length; i1++) {
if (s[i1].contains("=")) {
s[i1] = StringUtils.substringAfter(s[i1], "=");
}
if (s[i1].contains("\"")) {
s[i1] = s[i1].replace("\"", "");
}
}
HashMap<Object, Object> resultMap = new HashMap<>();
resultMap.put("I_ZDBH", s[1]);
resultMap.put("I_DSFZFMC", s[2]);
resultMap.put("I_JYLX", s[3]);
resultMap.put("I_DSFDDH", s[4]);
resultMap.put("I_ZFFS", s[5]);
resultMap.put("I_SPMC", s[6]);
resultMap.put("I_DDJE", s[7]);
resultMap.put("I_JYSJ", s[8]);
String[] s1 = s[8].split(" ");
resultMap.put("I_JYRQ", s1[0]);
resultMap.put("I_HBZL", s[9]);
resultMap.put("I_XFJE", s[10]);
resultMap.put("I_THJE", s[11]);
resultMap.put("I_GHDDH", s[12]);
resultMap.put("I_WBDDH", s[13]);
resultMap.put("I_XFSXFJE", s[14]);
resultMap.put("I_THSXFJE", s[15]);
resultMap.put("I_RZJE", s[16]);
resultMap.put("I_FKYH", s[18]);
resultMap.put("I_YHBS", s[19]);
savList.add(resultMap);
// log.info("接收到的数据是: " + resultMap);
}
// int i = bankbillsHistoryService.saveOriginalData(savList);
// int o = bankbillsHistoryService.saveHistoryData(savList);
} else {
errCode = "999";
errMsg = "读取失败";
}
// log.info("接收到数据:" + spareFile.getOriginalFilename());
}
Map<Object, Object> responseMap = new HashMap<>();
responseMap.put("errCode", errCode);
responseMap.put("errMsg", errMsg);
return responseMap;
}
}

View File

@@ -0,0 +1,302 @@
package com.saye.hospitalgd.controller;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.saye.hospitalgd.commons.date.DateDUtil;
import com.saye.hospitalgd.commons.excel.ExportXLSX;
import com.saye.hospitalgd.commons.excel.HashMapConversionImpl;
import com.saye.hospitalgd.commons.excel.IConversionByExport;
import com.saye.hospitalgd.commons.log.ExceptionDUtil;
import com.saye.hospitalgd.commons.log.LogUtil;
import com.saye.hospitalgd.commons.string.StringDUtil;
import com.saye.hospitalgd.model.Dicinfo;
import com.saye.hospitalgd.model.StatusDefine;
import com.saye.hospitalgd.service.BankbillHistoryService;
import com.saye.hospitalgd.service.system.DicinfoService;
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.io.File;
import java.util.*;
/**
* @author thuang
* @version 1.0
* @description: 三方账单明细
* @date 2021/9/13 15:52
*/
@Controller
@RequestMapping("/thirdDetail")
@Api(tags = "三方账单明细")
public class ThirdDetailController {
@Autowired
private BankbillHistoryService bankbillHistoryService;
@Autowired
private DicinfoService dicinfoService;
/**
* @description: 到三方对账页面
* @author thuang
* @date 2021/9/22 14:59
* @version 1.0
*/
@RequestMapping("/toThirdDetail")
public String toThirdDetail(ModelMap modelMap) {
try {
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);
/*//查询现有支付方式
List<HashMap<Object,Object>> list = bankbillHistoryService.findCzffs();
modelMap.addAttribute("zffsList",list);*/
//支付方式
List<Dicinfo> pay_type = dicinfoService.findDicinfoTreeNodeList("THIRD_PAY");
modelMap.addAttribute("payTypeList", pay_type);
} catch (Exception e) {
e.printStackTrace();
}
return "financialReconciliation/thirdDetail";
}
/**
* @description: 查询三方对账记录
* @author thuang
* @date 2021/9/17 8:55
* @version 1.0
*/
@RequestMapping("/findThirdDetail")
@ResponseBody
@ApiOperation("查询三方对账记录")
public HashMap<Object, Object> findThirdDetail(String c_zffs, String startTime, String endTime, String likeFiled, int page, int limit) {
HashMap<Object, Object> responseMap = new HashMap<>();
try {
HashMap<Object, Object> map = new HashMap<Object, Object>();
map.put("c_zffs", c_zffs);
map.put("startTime", startTime);
map.put("endTime", endTime);
map.put("likeFiled", likeFiled);
PageHelper.startPage(page, limit);
PageInfo<HashMap<Object, Object>> pageInfo = new PageInfo<HashMap<Object, Object>>(bankbillHistoryService.findBankbillHistoryList(map));
responseMap.put("code", 0);
responseMap.put("msg", "OK");
responseMap.put("count", pageInfo.getTotal());
responseMap.put("data", pageInfo.getList());
} catch (Exception e) {
e.printStackTrace();
String msg = e.getMessage();
responseMap.put("code", 1);
responseMap.put("msg", "查询失败,原因:" + msg);
}
return responseMap;
}
// /**
// * @description: 统计第三方数据
// * @author thuang
// * @date 2021/9/17 8:55
// * @version 1.0
// */
// @RequestMapping("/findThirdDetailCount")
// @ResponseBody
// public HashMap<Object, Object> findThirdDetailCount(String c_zffs, String startTime, String endTime, String likeFiled, int page, int limit) {
// HashMap<Object, Object> responseMap = new HashMap<>();
//
// try {
// HashMap<Object, Object> map = new HashMap<Object, Object>();
// map.put("c_zffs", c_zffs);
// map.put("startTime", startTime);
// map.put("endTime", endTime);
// map.put("likeFiled", likeFiled);
//
//
// List<HashMap<Object, Object>> bankbillHistoryList = bankbillHistoryService.findBankbillHistoryList(map);
//
// int thirdNum = 0;
// BigDecimal thirdMoney = new BigDecimal(0);
//
// for (HashMap<Object, Object> hashMap : bankbillHistoryList) {
// String i_jyje = StringDUtil.changeNullToEmpty(hashMap.get("I_JYJE"));
// if (!StringUtils.isEmpty(i_jyje)) {
// thirdMoney = thirdMoney.add(new BigDecimal(i_jyje));
// thirdNum++;
// }
// }
// responseMap.put("code", 0);
// responseMap.put("msg", "OK");
// responseMap.put("thirdNum", thirdNum);
// responseMap.put("thirdMoney", thirdMoney);
// } catch (Exception e) {
// e.printStackTrace();
// String msg = e.getMessage();
// responseMap.put("code", 1);
// responseMap.put("msg", "查询失败,原因:" + msg);
// }
//
//
// return responseMap;
// }
/**
* @description: 统计第三方数据
* @author thuang
* @date 2022/1/7 9:46
* @version 1.0
*/
@RequestMapping("/findThirdCountData")
@ResponseBody
@ApiOperation("统计第三方数据")
public HashMap<Object, Object> findThirdCountData(@RequestBody HashMap<Object, Object> map) {
HashMap<Object, Object> responseMap = new HashMap<Object, Object>();
String errCode = "0";
String errMsg = "";
try {
List<HashMap<Object, Object>> thirdDetailCount = bankbillHistoryService.findBankbillCountData(map);
responseMap.put("money", thirdDetailCount.get(0).get("MONEY"));
responseMap.put("num", thirdDetailCount.get(0).get("NUM"));
} catch (Exception e) {
e.printStackTrace();
errCode = "999";
errMsg = "查询his记录统计数据原因" + e.getMessage();
}
responseMap.put("errCode", errCode);
responseMap.put("errMsg", errMsg);
return responseMap;
}
/**
* @description: 导出三方账单明细
* @author thuang
* @date 2021/10/22 15:38
* @version 1.0
*/
@RequestMapping("/exportThirdDetail")
@ResponseBody
@ApiOperation("导出三方账单明细")
public HashMap<Object, Object> exportThirdDetail(@RequestBody HashMap<Object, Object> map) {
HashMap<Object, Object> responseMap = new HashMap<Object, Object>();
String errCode = "0";
String errMsg = "";
String dlName = "";
String fileName = "";
String dowloadName = StringDUtil.changeNullToEmpty(map.get("dowloadName"));
try {
List<HashMap<Object, Object>> thirdDetailCount = bankbillHistoryService.findBankbillCountData(map);
List<HashMap<Object, Object>> list = bankbillHistoryService.findBankbillHistoryList(map);
//支付方式
List<Dicinfo> pay_type = dicinfoService.findDicinfoTreeNodeList("THIRD_PAY");
HashMap<String, String> peyTypeMap = new HashMap<>();
for (Dicinfo dicinfo : pay_type) {
peyTypeMap.put(dicinfo.getDicvalue(), dicinfo.getDicname());
}
for (HashMap<Object, Object> hashMap : list) {
String i_fxk = StringDUtil.changeNullToEmpty(hashMap.get("I_FXK"));
hashMap.put("I_FXK", peyTypeMap.get(i_fxk));
}
HashMap<Object, Object> tjMap = new HashMap<>();
tjMap.put("I_JZRQ", "合计:");
tjMap.put("I_YHLSH", "交易笔数共" + thirdDetailCount.get(0).get("NUM") + "笔,汇总金额" + thirdDetailCount.get(0).get("MONEY") + "");
list.add(tjMap);
if (list.size() > 0) {
//定义标题头和文件名
String[] DISTANCE_HEADERNAME = {"交易时间", "交易日期", "记账日期", "银行流水号", "商户流水号", "订单号", "订单状态", "付款方账号/客户号", "付款方户名", "订单金额", "交易金额", "手续费", "结算金额", "柜台代码", "发卡行/通道", "支付卡种", "交易类型", "期数", "授权号", "项目号", "基本户", "备注一"};
String[] sqlKey = {"I_JYSJ", "I_JYRQ", "I_JZRQ", "I_YHLSH", "I_SHLSH", "I_DDH", "I_DDZT", "I_FKFZH", "I_FKFHM", "I_DDJE", "I_JYJE", "I_SXF", "I_JSJE", "I_GTDM", "I_FXK", "I_ZFKZ", "I_JYLX", "I_QS", "I_SQH", "I_XMH", "I_JBH", "I_BZ"};
List<Object> rulList = new ArrayList<Object>(list);
//创建工作表
ExportXLSX exportXLS = new ExportXLSX(DISTANCE_HEADERNAME, sqlKey, ExportXLSX.A3, false);
exportXLS.setTitleName(dowloadName);
IConversionByExport conversion = new HashMapConversionImpl();
exportXLS.setConversion(conversion);
exportXLS.setData(rulList);
exportXLS.modifyWidthOfHeader("5000", 0);
exportXLS.modifyWidthOfHeader("5000", 1);
exportXLS.modifyWidthOfHeader("5000", 2);
exportXLS.modifyWidthOfHeader("10000", 3);
exportXLS.modifyWidthOfHeader("6000", 4);
exportXLS.modifyWidthOfHeader("10000", 5);
exportXLS.modifyWidthOfHeader("5000", 6);
exportXLS.modifyWidthOfHeader("5000", 7);
exportXLS.modifyWidthOfHeader("5000", 8);
exportXLS.modifyWidthOfHeader("5000", 9);
exportXLS.modifyWidthOfHeader("5000", 10);
exportXLS.modifyWidthOfHeader("5000", 11);
exportXLS.modifyWidthOfHeader("5000", 12);
exportXLS.modifyWidthOfHeader("5000", 13);
exportXLS.modifyWidthOfHeader("5000", 14);
exportXLS.modifyWidthOfHeader("10000", 15);
exportXLS.modifyWidthOfHeader("6000", 16);
exportXLS.modifyWidthOfHeader("5000", 17);
exportXLS.modifyWidthOfHeader("5000", 18);
exportXLS.modifyWidthOfHeader("5000", 19);
exportXLS.modifyWidthOfHeader("5000", 20);
exportXLS.modifyWidthOfHeader("5000", 21);
// 文件名称
//产生4位长度的随机码由字母和数字组成
String randomStr = StringDUtil.generateRandomCodeForLength(4);
dlName = DateDUtil.DateToStr(DateDUtil.yyyyMMddHHmmss, new Date()) + randomStr;
fileName = dlName + ".xlsx";
String uploadPath = StatusDefine.filePath + "/HisDetail/";
File uploadPathFile = new File(uploadPath);
if (!uploadPathFile.exists()) uploadPathFile.mkdirs();
String savePath = uploadPath + fileName;
exportXLS.execGenerateExcel(savePath);
}
} catch (Exception e) {
errCode = "999";
errMsg = "未知异常:" + ExceptionDUtil.getDetailExceptionMsg(e);
LogUtil.error(this.getClass(), "@@@系统出错!【" + errMsg + "");
}
responseMap.put("errCode", errCode);
responseMap.put("errMsg", errMsg);
responseMap.put("dlName", "HisDetail/" + fileName);
return responseMap;
}
}

View File

@@ -0,0 +1,406 @@
package com.saye.hospitalgd.controller;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.saye.hospitalgd.commons.date.DateDUtil;
import com.saye.hospitalgd.commons.excel.ExportXLSX;
import com.saye.hospitalgd.commons.excel.HashMapConversionImpl;
import com.saye.hospitalgd.commons.excel.IConversionByExport;
import com.saye.hospitalgd.commons.log.ExceptionDUtil;
import com.saye.hospitalgd.commons.log.LogUtil;
import com.saye.hospitalgd.commons.string.StringDUtil;
import com.saye.hospitalgd.model.Dicinfo;
import com.saye.hospitalgd.model.StatusDefine;
import com.saye.hospitalgd.service.OperatorService;
import com.saye.hospitalgd.service.TransactionDetailService;
import com.saye.hospitalgd.service.system.DicinfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
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 java.io.File;
import java.math.BigDecimal;
import java.util.*;
/**
* @author thuang
* @version 1.0
* @description: 交易明细
* @date 2021/9/13 15:52
*/
@Controller
@RequestMapping("/transactionDetail")
@Api(tags = "交易明细")
public class TransactionDetailController {
@Autowired
private TransactionDetailService transactionDetailService;
@Autowired
private DicinfoService dicinfoService;
@Autowired
private OperatorService operatorService;
@RequestMapping("/toTransactionDetail")
public String toTransactionDetail(ModelMap modelMap) {
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);
//支付方式
List<Dicinfo> pay_type = dicinfoService.findDicinfoTreeNodeList("PAY_TYPE");
modelMap.addAttribute("payTypeList", pay_type);
//三方支付方式
List<Dicinfo> third_pay = dicinfoService.findDicinfoTreeNodeList("THIRD_PAY");
// System.out.println("!!!!!!!!!"+third_pay);
modelMap.addAttribute("thirdPayList", third_pay);
List<Dicinfo> biz_type = dicinfoService.findDicinfoTreeNodeList("BIZ_TYPE");
modelMap.addAttribute("bizTypeList", biz_type);
//操作员选择
HashMap<Object, Object> map = new HashMap<>();
map.put("is_active", "1");
List<HashMap<Object, Object>> allOperator = null;
try {
allOperator = operatorService.findAllOperator(map);
} catch (Exception e) {
e.printStackTrace();
}
modelMap.addAttribute("operList", allOperator);
// System.out.println("_________"+allOperator);
return "financialReconciliation/transactionDetail";
}
/**
* @description: 交易明细
* @author thuang
* @date 2021/9/28 10:55
* @version 1.0
*/
@RequestMapping("/findHisAndThirdJoinData")
@ResponseBody
@ApiOperation("交易明细")
public HashMap<Object, Object> findHisAndThirdJoinData(String BizType, String operCode, String payType, String thirdPay, String startTime, String endTime, int page, int limit) {
HashMap<Object, Object> responseMap = new HashMap<>();
try {
HashMap<Object, Object> map = new HashMap<Object, Object>();
map.put("payType", payType);
map.put("BizType", BizType);
map.put("thirdPay", thirdPay);
map.put("startTime", startTime);
map.put("endTime", endTime);
map.put("operCode", operCode);
PageHelper.startPage(page, limit);
PageInfo<HashMap<Object, Object>> pageInfo = new PageInfo<HashMap<Object, Object>>(transactionDetailService.findHisAndThirdJoinData(map));
List<HashMap<Object, Object>> list = pageInfo.getList();
responseMap.put("code", 0);
responseMap.put("msg", "OK");
responseMap.put("count", pageInfo.getTotal());
responseMap.put("data", list);
} catch (Exception e) {
e.printStackTrace();
String msg = e.getMessage();
responseMap.put("code", 1);
responseMap.put("msg", "查询失败,原因:" + msg);
}
return responseMap;
}
/**
* @description: 交易明细统计
* @author thuang
* @date 2021/10/15 9:52
* @version 1.0
*/
@PostMapping("/findHisAndThirdJoinCountData")
@ResponseBody
@ApiOperation("交易明细统计")
public HashMap<Object, Object> findHisAndThirdJoinData(@RequestBody HashMap<Object, Object> map) {
HashMap<Object, Object> responseMap = new HashMap<>();
String errCode = "0";
String errMsg = "";
try {
//查询所有
List<HashMap<Object, Object>> list = transactionDetailService.findHisAndThirdJoinData(map);
int thirdNum = 0;
int HISNum = 0;
BigDecimal thirdMoney = new BigDecimal(0);
BigDecimal thirdReceiveMoney = new BigDecimal(0);
BigDecimal thirdRefundMoney = new BigDecimal(0);
BigDecimal HISMoney = new BigDecimal(0);
BigDecimal HISReceiveMoney = new BigDecimal(0);
BigDecimal HISRefundMoney = new BigDecimal(0);
for (HashMap<Object, Object> hashMap : list) {
String amount = StringDUtil.changeNullToEmpty(hashMap.get("AMOUNT"));
String i_jyje = StringDUtil.changeNullToEmpty(hashMap.get("I_JYJE"));
if (!StringUtils.isEmpty(i_jyje)) {
thirdMoney = thirdMoney.add(new BigDecimal(i_jyje));
if (new BigDecimal(i_jyje).compareTo(BigDecimal.ZERO) > 0) {
thirdReceiveMoney = thirdReceiveMoney.add(new BigDecimal(i_jyje));
} else {
thirdRefundMoney = thirdRefundMoney.add(new BigDecimal(i_jyje));
}
thirdNum++;
}
if (!StringUtils.isEmpty(amount)) {
HISMoney = HISMoney.add(new BigDecimal(amount));
if (new BigDecimal(amount).compareTo(BigDecimal.ZERO) > 0) {
HISReceiveMoney = HISReceiveMoney.add(new BigDecimal(amount));
} else {
HISRefundMoney = HISRefundMoney.add(new BigDecimal(amount));
}
HISNum++;
}
}
responseMap.put("thirdNum", thirdNum);
responseMap.put("thirdMoney", thirdMoney);
responseMap.put("thirdReceiveMoney", thirdReceiveMoney);
responseMap.put("thirdRefundMoney", thirdRefundMoney);
responseMap.put("HISNum", HISNum);
responseMap.put("HISMoney", HISMoney);
responseMap.put("HISReceiveMoney", HISReceiveMoney);
responseMap.put("HISRefundMoney", HISRefundMoney);
} 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/10/22 8:52
* @version 1.0
*/
@RequestMapping("/exportHisAndThirdJoinCount")
@ResponseBody
@ApiOperation("导出交易明细")
public HashMap<Object, Object> exportHisAndThirdJoinCount(@RequestBody HashMap<Object, Object> map) {
HashMap<Object, Object> responseMap = new HashMap<Object, Object>();
String errCode = "0";
String errMsg = "";
String dlName = "";
String fileName = "";
String dowloadName = StringDUtil.changeNullToEmpty(map.get("dowloadName"));
try {
List<HashMap<Object, Object>> list = transactionDetailService.findHisAndThirdJoinData(map);
HashMap<Object, Object> hm = new HashMap<>();
int thirdNum = 0;
int HISNum = 0;
BigDecimal thirdMoney = new BigDecimal(0);
BigDecimal thirdReceiveMoney = new BigDecimal(0);
BigDecimal thirdRefundMoney = new BigDecimal(0);
BigDecimal HISMoney = new BigDecimal(0);
BigDecimal HISReceiveMoney = new BigDecimal(0);
BigDecimal HISRefundMoney = new BigDecimal(0);
for (HashMap<Object, Object> hashMap : list) {
String amount = StringDUtil.changeNullToEmpty(hashMap.get("AMOUNT"));
String i_jyje = StringDUtil.changeNullToEmpty(hashMap.get("I_JYJE"));
if (!StringUtils.isEmpty(i_jyje)) {
thirdMoney = thirdMoney.add(new BigDecimal(i_jyje));
if (new BigDecimal(i_jyje).compareTo(BigDecimal.ZERO) > 0) {
thirdReceiveMoney = thirdReceiveMoney.add(new BigDecimal(i_jyje));
} else {
thirdRefundMoney = thirdRefundMoney.add(new BigDecimal(i_jyje));
}
thirdNum++;
}
if (!StringUtils.isEmpty(amount)) {
HISMoney = HISMoney.add(new BigDecimal(amount));
if (new BigDecimal(amount).compareTo(BigDecimal.ZERO) > 0) {
HISReceiveMoney = HISReceiveMoney.add(new BigDecimal(amount));
} else {
HISRefundMoney = HISRefundMoney.add(new BigDecimal(amount));
}
HISNum++;
}
}
// responseMap.put("thirdNum", thirdNum);
// responseMap.put("thirdMoney", thirdMoney);
// responseMap.put("thirdReceiveMoney", thirdReceiveMoney);
// responseMap.put("thirdRefundMoney", thirdRefundMoney);
// responseMap.put("HISNum", HISNum);
// responseMap.put("HISMoney", HISMoney);
// responseMap.put("HISReceiveMoney", HISReceiveMoney);
// responseMap.put("HISRefundMoney", HISRefundMoney);
//支付方式
List<Dicinfo> pay_type = dicinfoService.findDicinfoTreeNodeList("PAY_TYPE");
HashMap<String, String> peyTypeMap = new HashMap<>();
for (Dicinfo dicinfo : pay_type) {
peyTypeMap.put(dicinfo.getDicvalue(), dicinfo.getDicname());
}
//支付方式
List<Dicinfo> third_pay = dicinfoService.findDicinfoTreeNodeList("THIRD_PAY");
HashMap<String, String> thirdPayMap = new HashMap<>();
for (Dicinfo dicinfo : third_pay) {
thirdPayMap.put(dicinfo.getDicvalue(), dicinfo.getDicname());
}
//业务类型
List<Dicinfo> biz_type = dicinfoService.findDicinfoTreeNodeList("BIZ_TYPE");
HashMap<String, String> bizTypeMap = new HashMap<>();
for (Dicinfo dicinfo : biz_type) {
bizTypeMap.put(dicinfo.getDicvalue(), dicinfo.getDicname());
}
//操作员选择
HashMap<Object, Object> activeMap = new HashMap<>();
activeMap.put("is_active", "1");
List<HashMap<Object, Object>> allOperator = null;
try {
allOperator = operatorService.findAllOperator(activeMap);
} catch (Exception e) {
e.printStackTrace();
}
for (HashMap<Object, Object> hashMap : list) {
String paytype = StringDUtil.changeNullToEmpty(hashMap.get("PAYTYPE"));
hashMap.put("PAYTYPE", peyTypeMap.get(paytype));
String i_jyqd = StringDUtil.changeNullToEmpty(hashMap.get("I_JYQD"));
hashMap.put("I_JYQD", thirdPayMap.get(i_jyqd));
String bizType = StringDUtil.changeNullToEmpty(hashMap.get("BIZTYPE"));
hashMap.put("BIZTYPE", bizTypeMap.get(bizType));
String hisopernum = StringDUtil.changeNullToEmpty(hashMap.get("HISOPERNUM"));
HashMap<Object, Object> hisOper = allOperator.stream().filter(h -> h.get("HISOPERCODE").equals(hisopernum)).findAny().orElse(null);
if (hisOper != null) {
hashMap.put("HISOPERNUM", hisOper.get("USER_NAME"));
}
// String paymethod = StringDUtil.changeNullToEmpty(hashMap.get("PAYMETHOD"));
// String paymethodStr="";
// if ("1".equals(paymethod)){
// paymethodStr="门诊";
// }else if ("2".equals(paymethod)){
// paymethodStr="住院";
// }
// hashMap.put("PAYMETHOD",paymethodStr);
String tradingStatus = StringDUtil.changeNullToEmpty(hashMap.get("H_JYLX"));
String tradingStatusStr = "";
if ("1".equals(tradingStatus)) {
tradingStatusStr = "收款记录";
} else if ("2".equals(tradingStatus)) {
tradingStatusStr = "退款记录";
}
hashMap.put("H_JYLX", tradingStatusStr);
}
hm.put("PAYTYPE", "合计结果:");
hm.put("TRANID", "第三方交易笔数共" + thirdNum + "笔,收款总计" + thirdReceiveMoney + "元,退款总计" + thirdRefundMoney + "元,汇总金额" + thirdMoney + "HIS交易共" + HISNum + "笔,收款总计" + HISReceiveMoney + "元,退款总计" + HISRefundMoney + "元,汇总金额" + HISMoney + "元;");
list.add(hm);
if (list.size() > 0) {
//定义标题头和文件名
String[] DISTANCE_HEADERNAME = {"业务类型", "交易状态", "支付方式", "HIS订单号", "金额", "交易时间", "操作员号", "患者姓名", "支付方式", "订单号", "金额", "交易时间"};
String[] sqlKey = {"BIZTYPE", "H_JYLX", "PAYTYPE", "TRANID", "AMOUNT", "TRADETIME", "HISOPERNUM", "PATIENTNAME", "I_JYQD", "I_DDH", "I_JYJE", "JYSJ"};
List<Object> rulList = new ArrayList<Object>(list);
//创建工作表
ExportXLSX exportXLS = new ExportXLSX(DISTANCE_HEADERNAME, sqlKey, ExportXLSX.A3, false);
exportXLS.setTitleName(dowloadName);
IConversionByExport conversion = new HashMapConversionImpl();
exportXLS.setConversion(conversion);
exportXLS.setData(rulList);
exportXLS.modifyWidthOfHeader("5000", 0);
exportXLS.modifyWidthOfHeader("5000", 1);
exportXLS.modifyWidthOfHeader("5000", 2);
exportXLS.modifyWidthOfHeader("10000", 3);
exportXLS.modifyWidthOfHeader("5000", 4);
exportXLS.modifyWidthOfHeader("5000", 5);
exportXLS.modifyWidthOfHeader("5000", 6);
exportXLS.modifyWidthOfHeader("5000", 7);
exportXLS.modifyWidthOfHeader("5000", 8);
exportXLS.modifyWidthOfHeader("10000", 9);
exportXLS.modifyWidthOfHeader("5000", 10);
exportXLS.modifyWidthOfHeader("5000", 11);
// exportXLS.modifyWidthOfHeader("5000", 11);
// 文件名称
//产生4位长度的随机码由字母和数字组成
String randomStr = StringDUtil.generateRandomCodeForLength(4);
dlName = DateDUtil.DateToStr(DateDUtil.yyyyMMddHHmmss, new Date()) + randomStr;
fileName = dlName + ".xlsx";
String uploadPath = StatusDefine.filePath + "/TranscationDetail/";
File uploadPathFile = new File(uploadPath);
if (!uploadPathFile.exists()) uploadPathFile.mkdirs();
String savePath = uploadPath + fileName;
exportXLS.execGenerateExcel(savePath);
}
} catch (Exception e) {
errCode = "999";
errMsg = "未知异常:" + ExceptionDUtil.getDetailExceptionMsg(e);
LogUtil.error(this.getClass(), "@@@系统出错!【" + errMsg + "");
}
responseMap.put("errCode", errCode);
responseMap.put("errMsg", errMsg);
responseMap.put("dlName", "TranscationDetail/" + fileName);
return responseMap;
}
}

View File

@@ -0,0 +1,522 @@
package com.saye.hospitalgd.controller;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.saye.hospitalgd.commons.date.DateDUtil;
import com.saye.hospitalgd.commons.excel.ExportXLSX;
import com.saye.hospitalgd.commons.excel.HashMapConversionImpl;
import com.saye.hospitalgd.commons.excel.IConversionByExport;
import com.saye.hospitalgd.commons.log.ExceptionDUtil;
import com.saye.hospitalgd.commons.log.LogUtil;
import com.saye.hospitalgd.commons.string.StringDUtil;
import com.saye.hospitalgd.commons.uuid.UUIDGenerator;
import com.saye.hospitalgd.model.Dicinfo;
import com.saye.hospitalgd.model.StatusDefine;
import com.saye.hospitalgd.model.Users;
import com.saye.hospitalgd.scheduler.jobMethod.ReconciliationMethod;
import com.saye.hospitalgd.service.BankbillHistoryService;
import com.saye.hospitalgd.service.RefundService;
import com.saye.hospitalgd.service.TransactionDetailService;
import com.saye.hospitalgd.service.UnilateralService;
import com.saye.hospitalgd.service.system.DicinfoService;
import com.saye.hospitalgd.service.system.ServiceParamsService;
import com.saye.hospitalgd.util.IpUtil;
import com.saye.hospitalgd.util.RefundUtil;
import com.saye.hospitalgd.util.SeriesNumUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.SecurityUtils;
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.io.File;
import java.util.*;
/**
* @author thuang
* @version 1.0
* @description: 单边账
* @date 2021/9/28 11:15
*/
@Controller
@RequestMapping("/unilateral")
@Api(tags = "单边账")
public class UnilateralController {
@Autowired
private UnilateralService unilateralService;
@Autowired
private TransactionDetailService transactionDetailService;
@Autowired
private DicinfoService dicinfoService;
@Autowired
private ServiceParamsService serviceParamsService;
@Autowired
private BankbillHistoryService bankbillHistoryService;
@Autowired
private RefundService refundService;
@RequestMapping("/toUnilateral")
public String toUnilateral(ModelMap modelMap) {
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);
//支付方式
List<Dicinfo> pay_type = dicinfoService.findDicinfoTreeNodeList("PAY_TYPE");
modelMap.addAttribute("payTypeList", pay_type);
//三方支付方式
List<Dicinfo> third_pay = dicinfoService.findDicinfoTreeNodeList("THIRD_PAY");
modelMap.addAttribute("thirdPayList", third_pay);
return "financialReconciliation/unilateral";
}
/**
* @description: 查询单边账记录
* @author thuang
* @date 2021/9/28 14:14
* @version 1.0
*/
@RequestMapping("/findAllUnilateral")
@ResponseBody
@ApiOperation("查询单边账记录")
public HashMap<Object, Object> findAllUnilateral(String payType, String thirdPay, String startTime, String endTime, String err_type, int page, int limit) {
HashMap<Object, Object> responseMap = new HashMap<>();
try {
HashMap<Object, Object> map = new HashMap<Object, Object>();
map.put("payType", payType);
map.put("thirdPay", thirdPay);
map.put("startTime", startTime);
map.put("endTime", endTime);
map.put("err_type", err_type);
PageHelper.startPage(page, limit);
PageInfo<HashMap<Object, Object>> pageInfo = new PageInfo<HashMap<Object, Object>>(unilateralService.findAllUnilateral(map));
responseMap.put("code", 0);
responseMap.put("msg", "OK");
responseMap.put("count", pageInfo.getTotal());
responseMap.put("data", pageInfo.getList());
} catch (Exception e) {
e.printStackTrace();
String msg = e.getMessage();
responseMap.put("code", 1);
responseMap.put("msg", "查询失败,原因:" + msg);
}
return responseMap;
}
/**
* @description: 导出单边账明细
* @author thuang
* @date 2021/10/22 8:52
* @version 1.0
*/
@RequestMapping("/exportUnilateral")
@ResponseBody
@ApiOperation("导出单边账明细")
public HashMap<Object, Object> exportUnilateral(@RequestBody HashMap<Object, Object> map) {
HashMap<Object, Object> responseMap = new HashMap<Object, Object>();
String errCode = "0";
String errMsg = "";
String dlName = "";
String fileName = "";
String dowloadName = StringDUtil.changeNullToEmpty(map.get("dowloadName"));
try {
List<HashMap<Object, Object>> list = unilateralService.findAllUnilateral(map);
//支付方式
List<Dicinfo> pay_type = dicinfoService.findDicinfoTreeNodeList("PAY_TYPE");
HashMap<String, String> peyTypeMap = new HashMap<>();
for (Dicinfo dicinfo : pay_type) {
peyTypeMap.put(dicinfo.getDicvalue(), dicinfo.getDicname());
}
//三方支付方式
List<Dicinfo> third_pay = dicinfoService.findDicinfoTreeNodeList("THIRD_PAY");
HashMap<String, String> thirdPayMap = new HashMap<>();
for (Dicinfo dicinfo : third_pay) {
thirdPayMap.put(dicinfo.getDicvalue(), dicinfo.getDicname());
}
for (HashMap<Object, Object> hashMap : list) {
//处理支付方式
String paytype = StringDUtil.changeNullToEmpty(hashMap.get("PAYTYPE"));
hashMap.put("PAYTYPE", peyTypeMap.get(paytype));
String i_jyqd = StringDUtil.changeNullToEmpty(hashMap.get("I_JYQD"));
hashMap.put("I_JYQD", thirdPayMap.get(i_jyqd));
//处理错账类型
String err_type = StringDUtil.changeNullToEmpty(hashMap.get("ERR_TYPE"));
if ("1".equals(err_type)) {
hashMap.put("ERR_TYPE", "HIS单边账");
} else if ("2".equals(err_type)) {
hashMap.put("ERR_TYPE", "三方单边账");
} else if ("3".equals(err_type)) {
hashMap.put("ERR_TYPE", "差异账");
} else if ("4".equals(err_type)) {
hashMap.put("ERR_TYPE", "跨天差异账");
}
String is_manager = StringDUtil.changeNullToEmpty(hashMap.get("IS_MANAGER"));
if ("1".equals(is_manager)) {
hashMap.put("IS_MANAGER", "已处理");
} else {
hashMap.put("IS_MANAGER", "未处理");
}
}
if (list.size() > 0) {
//定义标题头和文件名
String[] DISTANCE_HEADERNAME = {"交易日期", "HIS金额", "支付方式", "三方金额", "支付方式", "错账类型", "平台交易号", "银商订单号", "操作员号", "交易时间", "是否已处理", "处理时间"};
String[] sqlKey = {"TRADE_DATE", "AMOUNT", "PAYTYPE", "I_JYJE", "I_JYQD", "ERR_TYPE", "TRANID", "I_DDH", "HISOPERNUM", "TRADE_TIME", "IS_MANAGER", "MANAGER_TIME"};
List<Object> rulList = new ArrayList<Object>(list);
//创建工作表
ExportXLSX exportXLS = new ExportXLSX(DISTANCE_HEADERNAME, sqlKey, ExportXLSX.A3, false);
exportXLS.setTitleName(dowloadName);
IConversionByExport conversion = new HashMapConversionImpl();
exportXLS.setConversion(conversion);
exportXLS.setData(rulList);
exportXLS.modifyWidthOfHeader("5000", 0);
exportXLS.modifyWidthOfHeader("5000", 1);
exportXLS.modifyWidthOfHeader("5000", 2);
exportXLS.modifyWidthOfHeader("5000", 3);
exportXLS.modifyWidthOfHeader("5000", 4);
exportXLS.modifyWidthOfHeader("5000", 5);
exportXLS.modifyWidthOfHeader("10000", 6);
exportXLS.modifyWidthOfHeader("10000", 7);
exportXLS.modifyWidthOfHeader("5000", 8);
exportXLS.modifyWidthOfHeader("5000", 9);
exportXLS.modifyWidthOfHeader("5000", 10);
exportXLS.modifyWidthOfHeader("5000", 11);
// 文件名称
//产生4位长度的随机码由字母和数字组成
String randomStr = StringDUtil.generateRandomCodeForLength(4);
dlName = DateDUtil.DateToStr(DateDUtil.yyyyMMddHHmmss, new Date()) + randomStr;
fileName = dlName + ".xlsx";
String uploadPath = StatusDefine.filePath + "/Unilateral/";
File uploadPathFile = new File(uploadPath);
if (!uploadPathFile.exists()) uploadPathFile.mkdirs();
String savePath = uploadPath + fileName;
exportXLS.execGenerateExcel(savePath);
}
} catch (Exception e) {
errCode = "999";
errMsg = "未知异常:" + ExceptionDUtil.getDetailExceptionMsg(e);
LogUtil.error(this.getClass(), "@@@系统出错!【" + errMsg + "");
}
responseMap.put("errCode", errCode);
responseMap.put("errMsg", errMsg);
responseMap.put("dlName", "Unilateral/" + fileName);
return responseMap;
}
/**
* @description: 处理单边账
* @author thuang
* @date 2021/11/29 15:01
* @version 1.0
*/
@PostMapping("/managerUnilateral")
@ResponseBody
@ApiOperation("处理单边账")
public HashMap<Object, Object> managerUnilateral(HttpServletRequest request, @RequestBody HashMap<Object, Object> map) {
HashMap<Object, Object> responseMap = new HashMap<>();
String errCode = "0";
String errMsg = "处理完成";
Users user = (Users) SecurityUtils.getSubject().getPrincipal();
String userId = user.getUserId();
String userName = user.getUserName();
String trueName = user.getTrueName();
String ipAddr = IpUtil.getIpAddr(request);
try {
String id = StringDUtil.changeNullToEmpty(map.get("id"));
String errType = StringDUtil.changeNullToEmpty(map.get("errType"));
String managerType = StringDUtil.changeNullToEmpty(map.get("managerType"));
String remark = StringDUtil.changeNullToEmpty(map.get("remark"));
String payType = StringDUtil.changeNullToEmpty(map.get("payType"));
String c_zffs = StringDUtil.changeNullToEmpty(map.get("c_zffs"));
String trade_date = StringDUtil.changeNullToEmpty(map.get("trade_date"));
String platformTransId = StringDUtil.changeNullToEmpty(map.get("platformTransId"));
String c_ysddh = StringDUtil.changeNullToEmpty(map.get("c_ysddh"));
//查询系统中设置的现金类型
List<HashMap<Object, Object>> serviceParams = serviceParamsService.findParamValByParamCode("cash_code");
String cash_code = StringDUtil.changeNullToEmpty(serviceParams.get(0).get("PARAM_VAL"));
map.put("cash_code", cash_code);
//判断 单边账情况和处理情况
if ("1".equals(errType)) {
//如果是his单边账
//判断是否不计统计
if ("2".equals(managerType)) {
//如果是2 不计统计 处理不计统计
map.put("is_active", "0");
transactionDetailService.updateJoinSetActiveByHis(map);
//重新计算对账结果记录表
ReconciliationMethod.managerReconciliation(transactionDetailService, new HashMap<Object, Object>() {{
put("trade_date", trade_date);
}});
}
} else if ("2".equals(errType)) {
//如果是三方单边账
//判断是否需要退账
if ("1".equals(managerType)) {
//原路退回
if (cash_code.equals(payType)) {
//如果是现金 直接退出
throw new RuntimeException("现金帐无法直接退款");
}
//需要先记录退款操作 再调用退款接口 然后更新退款操作状态
//支付方式
//先在数据中查询这条记录
HashMap<Object, Object> searchMap = new HashMap<>();
searchMap.put("i_ddh", c_ysddh);
List<HashMap<Object, Object>> bankbillHistoryById = bankbillHistoryService.findBankbillHistoryById(searchMap);
HashMap<Object, Object> bankbillObj = bankbillHistoryById.get(0);
//全部走外联退费,不走九聚退费
// String bill_table_name = StringDUtil.changeNullToEmpty(bankbillHistoryById.get(0).get("bill_table_name"));
//先生成refundRequestId
String refundRequestId = "T" + DateDUtil.getCurrentDate(DateDUtil.yyyyMMddHHmmssSSS) + SeriesNumUtil.generateByRandom(3);
boolean isOk = true;
//调用掌医后台接口
List<HashMap<Object, Object>> palm_hospitalList = serviceParamsService.findParamValByParamCode("palm_hospital");
String palm_hospital = StringDUtil.changeNullToEmpty(palm_hospitalList.get(0).get("PARAM_VAL"));
// 九聚接口
// List<HashMap<Object, Object>> jfjk_wsdlList = serviceParamsService.findParamValByParamCode("jfjk_wsdl");
// String jfjk_wsdl = StringDUtil.changeNullToEmpty(jfjk_wsdlList.get(0).get("PARAM_VAL"));
try {
//根据excel表名名字选择退款方式
// if ("商户对账单".equals(bill_table_name)) {
HashMap<Object, Object> hashMap = new RefundUtil().refundPalmHospital(bankbillObj, palm_hospital, refundRequestId);
String errCode1 = StringDUtil.changeNullToEmpty(hashMap.get("errCode"));
//如果处理正常 保存返回信息
if ("0".equals(errCode1)) {
// hashMap.put("bill_table_name", bill_table_name);
hashMap.put("userName", userName);
hashMap.put("trueName", trueName);
hashMap.put("request_ip", ipAddr);
hashMap.put("c_ysddh", c_ysddh);
hashMap.put("id", UUIDGenerator.getUUID());
LogUtil.info(this.getClass(), trueName + "执行退款成功,内容" + hashMap.toString());
refundService.addRefundInfo(hashMap);
} else {
//如果不正常 返回错误信息 记录错误信息日志
errCode = errCode1;
errMsg = StringDUtil.changeNullToEmpty(hashMap.get("errMsg"));
LogUtil.error(this.getClass(), trueName + "执行退款失败,原因:" + errMsg);
}
// }
// else {
//
// //调用九聚接口
// HashMap<Object, Object> hashMap = new RefundUtil().refundThird(bankbillObj, jfjk_wsdl,refundRequestId);
// String errCode1 = StringDUtil.changeNullToEmpty(hashMap.get("errCode"));
// //如果处理正常 保存返回信息
// if ("0".equals(errCode1)) {
// hashMap.put("bill_table_name", bill_table_name);
// hashMap.put("userName", userName);
// hashMap.put("trueName", trueName);
// hashMap.put("request_ip", ipAddr);
// hashMap.put("c_ysddh", c_ysddh);
// hashMap.put("id", UUIDGenerator.getUUID());
//
// LogUtil.info(this.getClass(), trueName + "执行退款成功,内容" + hashMap.toString());
//
// refundService.addRefundInfo(hashMap);
// } else {
// //如果不正常 返回错误信息 记录错误信息日志
// errCode = errCode1;
// errMsg = StringDUtil.changeNullToEmpty(hashMap.get("errMsg"));
//
// LogUtil.error(this.getClass(), trueName + "执行退款失败,原因:" + errMsg);
// }
// }
} catch (Exception e) {
//连接直接断了等没有返回的情况
isOk = false;
e.printStackTrace();
}
//使用id查询扣款是否真的成功
if (!isOk) {
try {
//根据excel表名名字选择退款方式
// if ("商户对账单".equals(bill_table_name)) {
HashMap<Object, Object> hashMap = new RefundUtil().searchRefundPalmHospital(bankbillObj, palm_hospital, refundRequestId);
String errCode1 = StringDUtil.changeNullToEmpty(hashMap.get("errCode"));
//如果处理正常
if ("0".equals(errCode1)) {
// 分析其中数据
String queryResCode = StringDUtil.changeNullToEmpty(hashMap.get("queryResCode"));
if ("0".equals(queryResCode)) {
//说明之前退款成功 记录数据
// hashMap.put("bill_table_name", bill_table_name);
hashMap.put("userName", userName);
hashMap.put("trueName", trueName);
hashMap.put("request_ip", ipAddr);
hashMap.put("c_ysddh", c_ysddh);
hashMap.put("id", UUIDGenerator.getUUID());
LogUtil.info(this.getClass(), trueName + "执行退款成功,内容" + hashMap.toString());
refundService.addRefundInfo(hashMap);
//重新将errCode改为0
errCode = "0";
// }
// else {
// //说明之前退款失败 返回错误信息 不用记录
// errCode = queryResCode;
// String queryResInfo = StringDUtil.changeNullToEmpty(hashMap.get("queryResInfo"));
// errMsg = queryResInfo;
//
// LogUtil.error(this.getClass(), trueName + "执行退款失败,原因:" + errMsg);
// }
} else {
//查询都失败
String errMsg1 = StringDUtil.changeNullToEmpty(hashMap.get("errMsg"));
throw new RuntimeException("查询之前退款记录失败,原因:" + errMsg1);
}
}
// else {
// //调用九聚接口
// HashMap<Object, Object> hashMap = new RefundUtil().searchRefundThird(bankbillObj, jfjk_wsdl, refundRequestId);
// String errCode1 = StringDUtil.changeNullToEmpty(hashMap.get("errCode"));
// //如果处理正常
// if ("0".equals(errCode1)) {
//
// // 分析其中数据
// String queryResCode = StringDUtil.changeNullToEmpty(hashMap.get("queryResCode"));
// if ("00".equals(queryResCode)) {
// hashMap.put("bill_table_name", bill_table_name);
// hashMap.put("userName", userName);
// hashMap.put("trueName", trueName);
// hashMap.put("request_ip", ipAddr);
// hashMap.put("c_ysddh", c_ysddh);
// hashMap.put("id", UUIDGenerator.getUUID());
//
// LogUtil.info(this.getClass(), trueName + "执行退款成功,内容" + hashMap.toString());
//
// refundService.addRefundInfo(hashMap);
//
// //重新将errCode改为0
// errCode = "0";
// } else {
// //如果不正常 返回错误信息 记录错误信息日志
// errCode = queryResCode;
// String queryResInfo = StringDUtil.changeNullToEmpty(hashMap.get("queryResInfo"));
// errMsg = queryResInfo;
// LogUtil.error(this.getClass(), trueName + "执行退款失败,原因:" + errMsg);
// }
// } else {
// //查询都失败
// String errMsg1 = StringDUtil.changeNullToEmpty(hashMap.get("errMsg"));
// throw new RuntimeException("查询九聚之前退款记录失败,原因:" + errMsg1);
// }
// }
} catch (Exception e) {
e.printStackTrace();
//连查询都错误 或者整个接口都没调通 那就先记录下生成的id以防之后要查
HashMap<Object, Object> hashMap = new HashMap<>();
// hashMap.put("bill_table_name", bill_table_name);
hashMap.put("userName", userName);
hashMap.put("trueName", trueName);
hashMap.put("request_ip", ipAddr);
hashMap.put("c_ysddh", c_ysddh);
hashMap.put("id", UUIDGenerator.getUUID());
hashMap.put("transactionAmount", "");
hashMap.put("refundInvoiceAmount", "查询扣款及扣款信息均失败");
hashMap.put("refundRequestId", refundRequestId);
hashMap.put("retrievalRefNum", "");
refundService.addRefundInfo(hashMap);
}
}
} else if ("2".equals(managerType)) {
//不计统计
map.put("is_active", "0");
transactionDetailService.updateJoinSetActiveByThird(map);
//重新计算对账结果记录表
ReconciliationMethod.managerReconciliation(transactionDetailService, new HashMap<Object, Object>() {{
put("trade_date", trade_date);
}});
}
}
//更新表状态为已处理 ,以及说明。
if ("0".equals(errCode)) {
map.put("manager_time", DateDUtil.getCurrentDate(DateDUtil.yyyy_MM_dd_HH_mm_ss));
unilateralService.updateUnilateralManagerStatus(map);
}
} catch (Exception e) {
//e.printStackTrace();
errCode = "999";
errMsg = "处理单边账失败,原因:" + e.getMessage();
LogUtil.error(this.getClass(), userName + "[" + trueName + "]处理单边账失败,原因:" + e.getMessage());
}
responseMap.put("errCode", errCode);
responseMap.put("errMsg", errMsg);
return responseMap;
}
}

View File

@@ -0,0 +1,130 @@
package com.saye.hospitalgd.controller.historyLog;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.saye.hospitalgd.commons.date.DateDUtil;
import com.saye.hospitalgd.model.Dicinfo;
import com.saye.hospitalgd.service.TranscationsService;
import com.saye.hospitalgd.service.system.DicinfoService;
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;
import java.util.List;
/**
* Created with IntelliJ IDEA.
*
* @author Mr.zs
* @date 2023/10/9
* @description
* @modifiedBy
* @version: 1.0
*/
@Controller
@RequestMapping("/ActionableTrading")
public class ActionableTradingController {
@Autowired
private DicinfoService dicinfoService;
@Autowired
private TranscationsService transcationsService;
@RequestMapping("/toActionableTrading")
public String toActionableTrading(ModelMap modelMap) {
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);
//服务渠道
List<Dicinfo> serCh = dicinfoService.findDicinfoTreeNodeList("SER_CH");
modelMap.addAttribute("serChs", serCh);
//支付来源
List<Dicinfo> tra_type = dicinfoService.findDicinfoTreeNodeList("TRA_TYPE");
modelMap.addAttribute("tra_types", tra_type);
//聚合支付标识
List<Dicinfo> payLog = dicinfoService.findDicinfoTreeNodeList("PAY_LOG");
modelMap.addAttribute("payLogs", payLog);
//支付方式
List<Dicinfo> paySou = dicinfoService.findDicinfoTreeNodeList("PAY_SOU");
modelMap.addAttribute("paySous", paySou);
//退款状态
List<Dicinfo> reState = dicinfoService.findDicinfoTreeNodeList("RE_STATE");
modelMap.addAttribute("reStates", reState);
return "financialReconciliation/ActionableTrading";
}
@RequestMapping("/findActionableTrading")
@ResponseBody
public HashMap<Object, Object> findActionableTrading(String jyly, String startTime, String endTime, String likeFiled, int page, int limit) {
HashMap<Object, Object> responseMap = new HashMap<Object, Object>();
try {
HashMap<Object, Object> map = new HashMap<Object, Object>();
map.put("jyly", jyly);
map.put("startTime", startTime);
map.put("endTime", endTime);
map.put("likeFiled", likeFiled);
PageHelper.startPage(page, limit);
PageInfo<HashMap<Object, Object>> pageInfo = new PageInfo<HashMap<Object, Object>>(transcationsService.findActionableTrading(map));
responseMap.put("code", 0);
responseMap.put("msg", "OK");
responseMap.put("count", pageInfo.getTotal());
responseMap.put("data", pageInfo.getList());
} catch (Exception e) {
e.printStackTrace();
String msg = e.getMessage();
responseMap.put("code", 1);
responseMap.put("msg", "查询失败,原因:" + msg);
}
return responseMap;
}
@RequestMapping("/refundTrade")
@ResponseBody
public HashMap<Object, Object> refundTrade(@RequestBody HashMap<String, String> jylsh) {
System.out.println("jylsh is:" + jylsh);
HashMap<Object, Object> responseMap = new HashMap<>();
try {
HashMap<Object, Object> map = new HashMap<>();
map.put("jylsh", jylsh.get("jylsh"));
List<HashMap<Object, Object>> list = transcationsService.findActionableTrading(map);
HashMap<String, String> resultMap = transcationsService.refundTrade(list);
if (resultMap.get("errCode").equals("0")) {
responseMap.put("code", 0);
responseMap.put("msg", "OK");
} else {
responseMap.put("code", 1);
responseMap.put("msg", "退款失败:" + resultMap.get("errMsg"));
}
} catch (Exception e) {
e.printStackTrace();
String msg = e.getMessage();
responseMap.put("code", 1);
responseMap.put("msg", "退款失败:" + msg);
}
return responseMap;
}
}

View File

@@ -0,0 +1,265 @@
package com.saye.hospitalgd.controller.historyLog;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.saye.hospitalgd.commons.date.DateDUtil;
import com.saye.hospitalgd.commons.log.ExceptionDUtil;
import com.saye.hospitalgd.commons.log.LogUtil;
import com.saye.hospitalgd.service.historyLog.CashDetailService;
import io.swagger.annotations.Api;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.*;
/**
* @author thuang
* @version 1.0
* @description: 现金记录
* @date 2021/11/5 13:07
*/
@Controller
@Api(tags = "")
@RequestMapping("/cashLog")
public class CashLogController {
@Autowired
private CashDetailService cashDetailService;
/**
* @description: 查询现金记录
* @author thuang
* @date 2021/11/5 13:10
* @version 1.0
*/
@RequestMapping("/toCashLog")
public String toHisBillLog(ModelMap modelMap){
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);
return "historyLog/cashLog";
}
/**
* @description: 查询现金记录
* @author thuang
* @date 2021/11/5 17:02
* @version 1.0
*/
@RequestMapping("/findCashList")
@ResponseBody
public HashMap<Object,Object> findCashList(String startTime,String endTime,int page,int limit){
HashMap<Object,Object> responseMap=new HashMap<Object,Object>();
try {
HashMap<Object,Object> map=new HashMap<>();
map.put("startTime",startTime);
map.put("endTime",endTime);
PageHelper.startPage(page, limit);
PageInfo<HashMap<Object, Object>> pageInfo = new PageInfo<HashMap<Object, Object>>(cashDetailService.findCashDetailPageList(map));
responseMap.put("code", 0);
responseMap.put("msg", "OK");
responseMap.put("count", pageInfo.getTotal());
responseMap.put("data", pageInfo.getList());
}catch (Exception e){
e.printStackTrace();
String msg=e.getMessage();
responseMap.put("code", 1);
responseMap.put("msg", "查询失败,原因:"+msg);
}
return responseMap;
}
/**
* @description: 上传现金记录
* @author thuang
* @date 2021/11/5 17:03
* @version 1.0
*/
@RequestMapping("/uploadCash")
@ResponseBody
public HashMap<Object, Object> uploadSpecialEvent(@RequestParam("spareFile") MultipartFile file, HttpServletRequest request, HttpServletResponse response)throws Exception{
HashMap<Object, Object> responseMap=new HashMap<Object, Object>();
String errCode="0";
String errMsg="";
String input_trade_date="";
//添加人员
if (!file.isEmpty()) {
XSSFWorkbook workbook =null;
//创建Excel读取文件内容
workbook = new XSSFWorkbook(file.getInputStream());
//获取第一个工作表
XSSFSheet sheet = workbook.getSheetAt(0);
//获取sheet中第一行行号
int firstRowNum = sheet.getFirstRowNum();
//获取sheet中最后一行行号
int lastRowNum = sheet.getLastRowNum();
try {
//时间
String create_time = DateDUtil.getCurrentDate(DateDUtil.yyyy_MM_dd_HH_mm_ss);
//循环数据
boolean isOK=true;
List<HashMap<Object,Object>> addList =new ArrayList<>();
for(int i=firstRowNum+2;i<=lastRowNum;i++) {//因为表格中第一行为说明,第二行为列标题
XSSFRow row = sheet.getRow(i);
HashMap<Object,Object> addMap=new HashMap<>();
//操作员号
XSSFCell czyh = row.getCell(0);
if (czyh != null) {
czyh.setCellType(Cell.CELL_TYPE_STRING);
String czyhStr = czyh.getStringCellValue();
czyhStr = czyhStr.trim();
addMap.put("czyh",czyhStr);
} else {
isOK = false;
break;
}
//交易日期
XSSFCell trade_date = row.getCell(1);
if (trade_date != null) {
trade_date.setCellType(Cell.CELL_TYPE_STRING);
String trade_dateStr = trade_date.getStringCellValue();
trade_dateStr = trade_dateStr.trim();
addMap.put("trade_date",trade_dateStr);
if (i==2){
input_trade_date=trade_dateStr;
}
} else {
isOK = false;
break;
}
//交易金额
XSSFCell jyje = row.getCell(2);
if (jyje != null) {
jyje.setCellType(Cell.CELL_TYPE_STRING);
String jyjeStr = jyje.getStringCellValue();
addMap.put("jyje",jyjeStr);
}else{
isOK = false;
break;
}
//添加日期
addMap.put("create_time",create_time);
addList.add(addMap);
}
if(isOK){
errCode="999";
errMsg="导入失败,请检查数据内容";
}else{
cashDetailService.insertCash(addList);
LogUtil.info(this.getClass(),"导入"+input_trade_date+"金额记录成功");
}
} catch (Exception e) {
errCode="999";
errMsg="导入金额记录失败!原因:"+e.getMessage();
e.printStackTrace();
LogUtil.error(this.getClass(), "导入"+input_trade_date+"金额记录失败,原因:"+ ExceptionDUtil.getDetailExceptionMsg(e));
} finally {
workbook.close();
}
}
responseMap.put("errCode", errCode);
responseMap.put("errMsg", errMsg);
return responseMap;
}
/**
* @description: 修改修改现金金额
* @author thuang
* @date 2021/11/8 9:21
* @version 1.0
*/
@PostMapping("/editCash")
@ResponseBody
public HashMap<Object,Object> editCash(@RequestBody HashMap<Object,Object> map){
HashMap<Object, Object> responseMap=new HashMap<Object, Object>();
String errCode="0";
String errMsg="";
try{
cashDetailService.editCash(map);
} catch (Exception e) {
errCode="999";
errMsg="修改金额记录失败!原因:"+e.getMessage();
e.printStackTrace();
LogUtil.error(this.getClass(), "修改金额记录失败,原因:"+ ExceptionDUtil.getDetailExceptionMsg(e));
}
responseMap.put("errCode", errCode);
responseMap.put("errMsg", errMsg);
return responseMap;
}
/**
* @description: 删除现金金额
* @author thuang
* @date 2021/11/8 9:22
* @version 1.0
*/
@PostMapping("/deleteCash")
@ResponseBody
public HashMap<Object,Object> deleteCash(@RequestBody HashMap<Object,Object> map){
HashMap<Object, Object> responseMap=new HashMap<Object, Object>();
String errCode="0";
String errMsg="";
try{
cashDetailService.deleteCash(map);
} catch (Exception e) {
errCode="999";
errMsg="删除金额记录失败!原因:"+e.getMessage();
e.printStackTrace();
LogUtil.error(this.getClass(), "删除金额记录失败,原因:"+ ExceptionDUtil.getDetailExceptionMsg(e));
}
responseMap.put("errCode", errCode);
responseMap.put("errMsg", errMsg);
return responseMap;
}
}

View File

@@ -0,0 +1,164 @@
package com.saye.hospitalgd.controller.historyLog;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.saye.hospitalgd.commons.date.DateDUtil;
import com.saye.hospitalgd.commons.string.StringDUtil;
import com.saye.hospitalgd.scheduler.jobMethod.HISGetDataMethodByHY;
import com.saye.hospitalgd.scheduler.jobMethod.HISGetDataMethodByWN;
import com.saye.hospitalgd.scheduler.jobMethod.HISGetDataMethodByZL;
import com.saye.hospitalgd.service.HisInterFaceConfigService;
import com.saye.hospitalgd.service.historyLog.HisBillLogService;
import com.saye.hospitalgd.service.system.ServiceParamsService;
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.*;
/**
* @author thuang
* @version 1.0
* @description: his对账数据结果查询信息类
* @date 2021/8/30 10:54
*/
@Controller
@RequestMapping("/hisBillLog")
@Api(tags = "his对账数据结果查询信息类")
public class HisBillLogController {
@Autowired
private HisBillLogService hisBillLogService;
@Autowired
private ServiceParamsService serviceParamsService;
@Autowired
private HisInterFaceConfigService hisInterFaceConfigService;
@RequestMapping("/toHisBillLog")
public String toHisBillLog(ModelMap modelMap){
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);
try {
//厂商
List<HashMap<Object,Object>> firmlist = hisInterFaceConfigService.findAllconfig();
HashMap<String,String> firmMap=new HashMap<>();
for (HashMap<Object, Object> hashMap : firmlist) {
String id = StringDUtil.changeNullToEmpty(hashMap.get("ID"));
String his_interface_name = StringDUtil.changeNullToEmpty(hashMap.get("HIS_INTERFACE_NAME"));
firmMap.put(id,his_interface_name);
}
modelMap.addAttribute("firmlist",firmlist);
}catch (Exception e){
System.out.println("返回厂商信息出错,原因"+e.getMessage());
}
return "historyLog/hisBillLog";
}
/**
* @description: 查询HIS调用的日志
* @author thuang
* @date 2021/8/30 14:30
* @version 1.0
*/
@RequestMapping("/findHisBillLogPageList")
@ResponseBody
@ApiOperation(value = "查询HIS调用的日志")
public HashMap<Object,Object> findHisBillLogPageList(String business,String status,String startTime,String endTime,int page,int limit) {
HashMap<Object,Object> responseMap=new HashMap<Object,Object>();
try {
HashMap<Object,Object> map=new HashMap<Object,Object>();
map.put("is_ok",status);
map.put("startTime",startTime);
map.put("endTime",endTime);
map.put("his_wsdl_id",business);
PageHelper.startPage(page, limit);
PageInfo<HashMap<Object, Object>> pageInfo = new PageInfo<HashMap<Object, Object>>(hisBillLogService.findHisBillLogPageList(map));
responseMap.put("code", 0);
responseMap.put("msg", "OK");
responseMap.put("count", pageInfo.getTotal());
responseMap.put("data", pageInfo.getList());
} catch (Exception e) {
e.printStackTrace();
String msg=e.getMessage();
responseMap.put("code", 1);
responseMap.put("msg", "查询失败,原因:"+msg);
}
return responseMap;
}
/**
* @description: his重新获取数
* @author thuang
* @date 2021/10/9 15:30
* @version 1.0
*/
@RequestMapping("/restartGetBill")
@ResponseBody
@ApiOperation(value = "his重新获取数")
public HashMap<Object,Object> restartGetBill(@RequestBody HashMap<Object,Object> map){
HashMap<Object,Object> responseMap=new HashMap<>();
String errCode="0";
String errMsg="";
try {
//交易时间
String trade_date = StringDUtil.changeNullToEmpty(map.get("trade_date"));
//根据交易时间获取交易生成的定时任务
HashMap<Object,Object> searchMap=new HashMap<>();
searchMap.put("trade_date",trade_date);
List<HashMap<Object, Object>> hisBillLogByParam = hisBillLogService.findHisBillLogByParam(searchMap);
HashMap<Object, Object> hisBillLog = hisBillLogByParam.get(0);
String quartz_id = StringDUtil.changeNullToEmpty(hisBillLog.get("QUARTZ_ID"));
String quartz_name = StringDUtil.changeNullToEmpty(hisBillLog.get("QUARTZ_NAME"));
HashMap<Object, Object> resultMap = null;
List<HashMap<Object, Object>> serviceParams = serviceParamsService.findParamValByParamCode("his_wsdl_id");
String his_wsdl_id = StringDUtil.changeNullToEmpty(serviceParams.get(0).get("PARAM_VAL"));
if ("1".equals(his_wsdl_id)){
resultMap = new HISGetDataMethodByZL().getDate(quartz_id,quartz_name,trade_date,his_wsdl_id);
}else if ("2".equals(his_wsdl_id)){
resultMap = new HISGetDataMethodByWN().getDate(quartz_id,quartz_name,trade_date,his_wsdl_id);
}else if("3".equals(his_wsdl_id)){
resultMap = new HISGetDataMethodByHY().getDate(quartz_id,quartz_name,trade_date,his_wsdl_id);
}
errCode=StringDUtil.changeNullToEmpty(resultMap.get("errCode"));
errMsg=StringDUtil.changeNullToEmpty(resultMap.get("errMsg"));
}catch (Exception e){
e.printStackTrace();
errCode="999";
errMsg="重新执行定时任务失败,原因:"+e.getMessage();
}
responseMap.put("errCode",errCode);
responseMap.put("errMsg",errMsg);
return responseMap;
}
}

View File

@@ -0,0 +1,137 @@
package com.saye.hospitalgd.controller.historyLog;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.saye.hospitalgd.commons.date.DateDUtil;
import com.saye.hospitalgd.commons.string.StringDUtil;
import com.saye.hospitalgd.model.Users;
import com.saye.hospitalgd.scheduler.jobMethod.ReconciliationMethod;
import com.saye.hospitalgd.service.historyLog.ReconciliationLogService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.SecurityUtils;
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;
import java.util.List;
/**
* @author thuang
* @version 1.0
* @description: 对账情况信息
* @date 2021/8/31 10:17
*/
@Controller
@RequestMapping("/reconciliationLog")
@Api(tags = "对账情况信息")
public class ReconciliationLogController {
@Autowired
private ReconciliationLogService reconciliationLogService;
@RequestMapping("/toReconciliationLog")
public String toReconciliationLog(ModelMap modelMap) {
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);
return "historyLog/reconciliationLog";
}
/**
* @description: 查询对账的日志
* @author thuang
* @date 2021/8/30 14:30
* @version 1.0
*/
@RequestMapping("/findReconciliationLogPageList")
@ResponseBody
@ApiOperation(value = "查询对账的日志")
public HashMap<Object, Object> findReconciliationLogPageList(String status, String startTime, String endTime, int page, int limit) {
HashMap<Object, Object> responseMap = new HashMap<Object, Object>();
try {
HashMap<Object, Object> map = new HashMap<Object, Object>();
map.put("status", status);
map.put("startTime", startTime);
map.put("endTime", endTime);
PageHelper.startPage(page, limit);
PageInfo<HashMap<Object, Object>> pageInfo = new PageInfo<HashMap<Object, Object>>(reconciliationLogService.findReconciliationLogPageList(map));
responseMap.put("code", 0);
responseMap.put("msg", "OK");
responseMap.put("count", pageInfo.getTotal());
responseMap.put("data", pageInfo.getList());
} catch (Exception e) {
e.printStackTrace();
String msg = e.getMessage();
responseMap.put("code", 1);
responseMap.put("msg", "查询失败,原因:" + msg);
}
return responseMap;
}
/**
* @description: 重新开始对账
* @author thuang
* @date 2021/10/9 15:49
* @version 1.0
*/
@RequestMapping("/restartManager")
@ResponseBody
@ApiOperation(value = "重新开始对账")
public HashMap<Object, Object> restartManager(@RequestBody HashMap<Object, Object> map) {
HashMap<Object, Object> responseMap = new HashMap<>();
String errCode = "0";
String errMsg = "";
try {
//交易时间
String trade_date = StringDUtil.changeNullToEmpty(map.get("trade_date"));
//根据交易时间获取交易生成的定时任务
HashMap<Object, Object> searchMap = new HashMap<>();
searchMap.put("trade_date", trade_date);
List<HashMap<Object, Object>> hisBillLogByParam = reconciliationLogService.findReconciliationLogByParam(searchMap);
HashMap<Object, Object> hisBillLog = hisBillLogByParam.get(0);
String quartz_id = StringDUtil.changeNullToEmpty(hisBillLog.get("QUARTZ_ID"));
String quartz_name = StringDUtil.changeNullToEmpty(hisBillLog.get("QUARTZ_NAME"));
Users user = (Users) SecurityUtils.getSubject().getPrincipal();
String trueName = user.getTrueName();
HashMap<Object, Object> resultMap = new ReconciliationMethod().getDate(quartz_id, quartz_name, trade_date, trueName);
errCode = StringDUtil.changeNullToEmpty(resultMap.get("errCode"));
errMsg = StringDUtil.changeNullToEmpty(resultMap.get("errMsg"));
} catch (Exception e) {
e.printStackTrace();
errCode = "999";
errMsg = "重新执行定时任务失败,原因:" + e.getMessage();
}
responseMap.put("errCode", errCode);
responseMap.put("errMsg", errMsg);
return responseMap;
}
}

View File

@@ -0,0 +1,103 @@
package com.saye.hospitalgd.controller.historyLog;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.saye.hospitalgd.commons.date.DateDUtil;
import com.saye.hospitalgd.model.Dicinfo;
import com.saye.hospitalgd.service.RefundOrderService;
import com.saye.hospitalgd.service.system.DicinfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
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;
import java.util.List;
/**
* Created with IntelliJ IDEA.
*
* @author Mr.zs
* @date 2023/10/9
* @description
* @modifiedBy
* @version: 1.0
*/
@Controller
@RequestMapping("/refundOrder")
public class RefundOrderController {
@Autowired
private DicinfoService dicinfoService;
@Autowired
RefundOrderService refundOrderService;
@RequestMapping("/toRefundOrder")
public String toRefundOrder(ModelMap modelMap) {
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);
//服务渠道
List<Dicinfo> serCh = dicinfoService.findDicinfoTreeNodeList("SER_CH");
modelMap.addAttribute("serChs", serCh);
//支付来源
List<Dicinfo> tra_type = dicinfoService.findDicinfoTreeNodeList("TRA_TYPE");
modelMap.addAttribute("tra_types", tra_type);
//聚合支付标识
List<Dicinfo> payLog = dicinfoService.findDicinfoTreeNodeList("PAY_LOG");
modelMap.addAttribute("payLogs", payLog);
//支付方式
List<Dicinfo> paySou = dicinfoService.findDicinfoTreeNodeList("PAY_SOU");
modelMap.addAttribute("paySous", paySou);
//退款状态
List<Dicinfo> reState = dicinfoService.findDicinfoTreeNodeList("RE_STATE");
modelMap.addAttribute("reStates", reState);
return "financialReconciliation/RefundOrder";
}
@RequestMapping("/findRefundOrder")
@ResponseBody
public HashMap<Object, Object> findTradeRecords(String jyly, String startTime, String endTime, String likeFiled, int page, int limit) {
HashMap<Object, Object> responseMap = new HashMap<Object, Object>();
try {
HashMap<Object, Object> map = new HashMap<Object, Object>();
map.put("jyly", jyly);
map.put("startTime", startTime);
map.put("endTime", endTime);
map.put("likeFiled", likeFiled);
PageHelper.startPage(page, limit);
PageInfo<HashMap<Object, Object>> pageInfo = new PageInfo<HashMap<Object, Object>>(refundOrderService.findRefundOrder(map));
responseMap.put("code", 0);
responseMap.put("msg", "OK");
responseMap.put("count", pageInfo.getTotal());
responseMap.put("data", pageInfo.getList());
} catch (Exception e) {
e.printStackTrace();
String msg = e.getMessage();
responseMap.put("code", 1);
responseMap.put("msg", "查询失败,原因:" + msg);
}
return responseMap;
}
}

View File

@@ -0,0 +1,158 @@
package com.saye.hospitalgd.controller.historyLog;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.saye.hospitalgd.commons.date.DateDUtil;
import com.saye.hospitalgd.commons.string.StringDUtil;
import com.saye.hospitalgd.scheduler.MySchedulerFactory;
import com.saye.hospitalgd.scheduler.job.BankGetData;
import com.saye.hospitalgd.service.BankbillGetinfoService;
import com.saye.hospitalgd.service.ThirdFtpConfigService;
import com.saye.hospitalgd.service.ThirdSftpConfigService;
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;
import java.util.List;
/**
* @author thuang
* @version 1.0
* @description: 三方账单查询信息
* @date 2021/8/31 9:04
*/
@Controller
@RequestMapping("/thirdBillLog")
@Api(tags = "三方账单查询信息")
public class ThirdBillLogController {
@Autowired
private BankbillGetinfoService bankbillGetinfoService;
@Autowired
private MySchedulerFactory mySchedulerFactory;
@Autowired
private ThirdFtpConfigService thirdFtpConfigService;
@Autowired
private ThirdSftpConfigService thirdSftpConfigService;
@RequestMapping("/toThirdBillLog")
public String toThirdBillLog(ModelMap modelMap) {
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);
return "historyLog/thirdBillLog";
}
/**
* @description: 查询三方调用的日志
* @author thuang
* @date 2021/8/30 14:30
* @version 1.0
*/
@RequestMapping("/findThirdBillLogPageList")
@ResponseBody
@ApiOperation(value = "查询三方调用的日志")
public HashMap<Object, Object> findThirdBillLogPageList(String business, String status, String startTime, String endTime, int page, int limit) {
HashMap<Object, Object> responseMap = new HashMap<Object, Object>();
try {
HashMap<Object, Object> map = new HashMap<Object, Object>();
map.put("business", business);
map.put("is_ok", status);
map.put("startTime", startTime);
map.put("endTime", endTime);
PageHelper.startPage(page, limit);
PageInfo<HashMap<Object, Object>> pageInfo = new PageInfo<HashMap<Object, Object>>(bankbillGetinfoService.findBankbillGetinfoList(map));
responseMap.put("code", 0);
responseMap.put("msg", "OK");
responseMap.put("count", pageInfo.getTotal());
responseMap.put("data", pageInfo.getList());
} catch (Exception e) {
e.printStackTrace();
String msg = e.getMessage();
responseMap.put("code", 1);
responseMap.put("msg", "查询失败,原因:" + msg);
}
return responseMap;
}
/**
* @description: 重新执行定时任务
* @author thuang
* @date 2021/9/13 13:08
* @version 1.0
*/
@RequestMapping("/restartGetBill")
@ResponseBody
@ApiOperation(value = "重新执行定时任务")
public HashMap<Object, Object> restartGetBill(@RequestBody HashMap<Object, Object> map) {
HashMap<Object, Object> responseMap = new HashMap<>();
String errCode = "0";
String errMsg = "";
try {
//交易时间
String trade_date = StringDUtil.changeNullToEmpty(map.get("trade_date"));
String bill_table_name = StringDUtil.changeNullToEmpty(map.get("bill_table_name"));
//根据交易时间获取交易生成的定时任务
HashMap<Object, Object> searchMap = new HashMap<>();
searchMap.put("trade_date", trade_date);
searchMap.put("bill_table_name", bill_table_name);
HashMap<Object, Object> bankbillGetinfo = bankbillGetinfoService.findBankbillGetinfoById(searchMap);
String quartz_id = StringDUtil.changeNullToEmpty(bankbillGetinfo.get("QUARTZ_ID"));
String quartz_name = StringDUtil.changeNullToEmpty(bankbillGetinfo.get("QUARTZ_NAME"));
String thirdConfigId = StringDUtil.changeNullToEmpty(bankbillGetinfo.get("THIRDCONFIGID"));
//查询配置
HashMap<Object, Object> searchThirdMap = new HashMap<>();
searchThirdMap.put("FUBS", "1");
List<HashMap<Object, Object>> wlConfigList = thirdSftpConfigService.findWLIF(searchThirdMap);
//
// HashMap<Object, Object> searchConfigMap = new HashMap<>();
// searchConfigMap.put("thirdConfigId", thirdConfigId);
// List<HashMap<Object, Object>> thirdFtpConfigList = thirdFtpConfigService.findThirdFtpConfigList(searchConfigMap);
HashMap<Object, Object> resultMap = BankGetData.oneExecute(quartz_id, quartz_name, trade_date, wlConfigList.get(0));
errCode = StringDUtil.changeNullToEmpty(resultMap.get("errCode"));
errMsg = StringDUtil.changeNullToEmpty(resultMap.get("errMsg"));
} catch (Exception e) {
e.printStackTrace();
errCode = "999";
errMsg = "重新执行定时任务失败,原因:" + e.getMessage();
}
responseMap.put("errCode", errCode);
responseMap.put("errMsg", errMsg);
return responseMap;
}
}

View File

@@ -0,0 +1,109 @@
package com.saye.hospitalgd.controller.historyLog;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.saye.hospitalgd.commons.date.DateDUtil;
import com.saye.hospitalgd.model.Dicinfo;
import com.saye.hospitalgd.service.TranscationsService;
import com.saye.hospitalgd.service.system.DicinfoService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
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;
import java.util.List;
/**
* Created with IntelliJ IDEA.
*
* @author Mr.zs
* @date 2023/10/8
* @description
* @modifiedBy
* @version: 1.0
*/
@Controller
@RequestMapping("/transcationsLog")
@Api(tags = "交易记录")
public class TranscationsController {
@Autowired
private DicinfoService dicinfoService;
@Autowired
private TranscationsService transcationsService;
@RequestMapping("/toTranscationLog")
public String toTranscationLog(ModelMap modelMap) {
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);
//服务渠道
List<Dicinfo> serCh = dicinfoService.findDicinfoTreeNodeList("SER_CH");
modelMap.addAttribute("serChs", serCh);
//支付来源
List<Dicinfo> tra_type = dicinfoService.findDicinfoTreeNodeList("TRA_TYPE");
modelMap.addAttribute("tra_types", tra_type);
//聚合支付标识
List<Dicinfo> payLog = dicinfoService.findDicinfoTreeNodeList("PAY_LOG");
modelMap.addAttribute("payLogs", payLog);
//支付方式
List<Dicinfo> paySou = dicinfoService.findDicinfoTreeNodeList("PAY_SOU");
modelMap.addAttribute("paySous", paySou);
//退款状态
List<Dicinfo> reState = dicinfoService.findDicinfoTreeNodeList("RE_STATE");
modelMap.addAttribute("reStates", reState);
return "financialReconciliation/Transactions";
}
@RequestMapping("/findTradeRecords")
@ResponseBody
public HashMap<Object, Object> findTradeRecords(String jyly, String startTime, String endTime, String likeFiled, int page, int limit) {
HashMap<Object, Object> responseMap = new HashMap<Object, Object>();
try {
HashMap<Object, Object> map = new HashMap<Object, Object>();
map.put("jyly", jyly);
map.put("startTime", startTime);
map.put("endTime", endTime);
map.put("likeFiled", likeFiled);
PageHelper.startPage(page, limit);
PageInfo<HashMap<Object, Object>> pageInfo = new PageInfo<HashMap<Object, Object>>(transcationsService.findTradeRecords(map));
responseMap.put("code", 0);
responseMap.put("msg", "OK");
responseMap.put("count", pageInfo.getTotal());
responseMap.put("data", pageInfo.getList());
} catch (Exception e) {
e.printStackTrace();
String msg = e.getMessage();
responseMap.put("code", 1);
responseMap.put("msg", "查询失败,原因:" + msg);
}
return responseMap;
}
}

View File

@@ -0,0 +1,386 @@
package com.saye.hospitalgd.controller.quartz;
import java.util.*;
import com.saye.hospitalgd.commons.log.LogUtil;
import com.saye.hospitalgd.service.system.DicinfoService;
import org.apache.shiro.SecurityUtils;
import org.quartz.CronTrigger;
import org.quartz.JobKey;
import org.quartz.Scheduler;
import org.quartz.TriggerKey;
import org.quartz.impl.JobDetailImpl;
import org.quartz.impl.matchers.GroupMatcher;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.quartz.SchedulerFactoryBean;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.github.pagehelper.PageInfo;
import com.saye.hospitalgd.commons.date.DateDUtil;
import com.saye.hospitalgd.commons.log.ExceptionDUtil;
import com.saye.hospitalgd.commons.page.PageUtil;
import com.saye.hospitalgd.commons.page.TemplatePage;
import com.saye.hospitalgd.commons.string.StringDUtil;
import com.saye.hospitalgd.model.BaseQuartzConfigEntity;
import com.saye.hospitalgd.model.Users;
import com.saye.hospitalgd.scheduler.MySchedulerFactory;
import com.saye.hospitalgd.service.quartz.BaseQuartzConfigService;
/**
* @description: 定时任务
* @author thuang
* @date 2021/10/18 9:46
* @version 1.0
*/
@Controller
@RequestMapping("/quartzConfig")
public class BaseQuartzConfigController{
@Autowired
private BaseQuartzConfigService baseQuartzConfigService;
@Autowired
private MySchedulerFactory mySchedulerFactory;
@Autowired
private DicinfoService dicinfoService;
/**
* @description 查询所有的定时任务
* @author thuang
* @created 2020年1月7日 下午5:10:21
* @param configId
* @param quartz_name
* @return
*/
@RequestMapping("/findQuartzConfig")
@ResponseBody
public TemplatePage findQuartzConfig(String configId,String quartz_name,String quartz_type){
PageInfo<BaseQuartzConfigEntity> appsPageInfo=null;
try {
HashMap<Object, Object> map=new HashMap<Object, Object>();
map.put("configId", configId);
map.put("quartz_name", quartz_name);
map.put("quartz_type", quartz_type);
appsPageInfo = new PageInfo<BaseQuartzConfigEntity>(baseQuartzConfigService.findAll(map));
} catch (Exception e) {
e.printStackTrace();
}
return PageUtil.loadJsonPage(appsPageInfo);
}
/**
* @description 修改定时任务设置
* @author thuang
* @created 2020年1月7日 下午2:10:04
* @param map
* @return
*/
@RequestMapping("/changestatus")
@ResponseBody
public HashMap<Object, Object> changestatus(@RequestBody Map<Object, Object> map){
HashMap<Object, Object> responseMap=new HashMap<Object, Object>();
String errCode="0";
String errMsg="";
try {
Users user = (Users) SecurityUtils.getSubject().getPrincipal();
String status = StringDUtil.changeNullToEmpty(map.get("status"));
String configid = StringDUtil.changeNullToEmpty(map.get("quartzId"));
if (StringDUtil.isNotBlank(configid) && StringDUtil.isNotBlank(status)) {
BaseQuartzConfigEntity quartzConfigEntity = baseQuartzConfigService.get(configid);
if ("0".equals(status)) {
//修改为0并且恢复运行
quartzConfigEntity.setStatus("1");
mySchedulerFactory.resumeJob(configid);
}else {
//修改为1并且暂停
quartzConfigEntity.setStatus("0");
mySchedulerFactory.pauseJob(configid);
}
baseQuartzConfigService.updateQuartzConfig(quartzConfigEntity);
LogUtil.debug(this.getClass(),"用户"+ user.getTrueName()+"修改定时任务:"+configid);
}else {
errCode="998";
errMsg="修改定时任务参数不全";
}
} catch (Exception e) {
errCode="999";
errMsg="修改定时任务失败";
LogUtil.error(this.getClass(), "修改定时任务失败,原因:"+ExceptionDUtil.getDetailExceptionMsg(e));
}
responseMap.put("errCode", errCode);
responseMap.put("errMsg", errMsg);
return responseMap;
}
/**
* @description 新增定时任务
* @author thuang
* @created 2020年1月7日 下午2:10:04
* @param map
* @return
*/
@RequestMapping("/addNewQuartz")
@ResponseBody
public HashMap<Object, Object> addNewQuartz(@RequestBody HashMap<Object, Object> map){
HashMap<Object, Object> responseMap=new HashMap<Object, Object>();
String errCode="0";
String errMsg="";
try{
String time = StringDUtil.changeNullToEmpty(map.get("time"));
String dataStr = StringDUtil.changeNullToEmpty(map.get("dataStr"));
String remark = StringDUtil.changeNullToEmpty(map.get("remark"));
String jobType = StringDUtil.changeNullToEmpty(map.get("jobType"));
String quartz_class = StringDUtil.changeNullToEmpty(map.get("quartz_class"));
String quartzName = StringDUtil.changeNullToEmpty(map.get("quartzName"));
Users user = (Users) SecurityUtils.getSubject().getPrincipal();
String userId = user.getUserId();
String cronStr = getCron(map);
//查询任务最大任务id号 生成新的id号
List<HashMap<Object, Object>> list =this.baseQuartzConfigService.findMaxId();
String id="";
if(list!=null && list.size()>0){
id=""+(Integer.parseInt(StringDUtil.changeNullToEmpty(list.get(0).get("ID")))+1);
}else {
id="1";
}
HashMap<Object, Object> addMap=new HashMap<Object, Object>();
addMap.put("id", id);
addMap.put("quartzName", quartzName);
addMap.put("status", "0");
addMap.put("quartz_class", quartz_class);
addMap.put("remark", remark);
addMap.put("createuserid", userId);
addMap.put("expression", cronStr);
addMap.put("create_time", DateDUtil.getCurrentDate(DateDUtil.yyyy_MM_dd_HH_mm_ss));
addMap.put("quartz_type", jobType);
this.baseQuartzConfigService.addQuartz(addMap);
mySchedulerFactory.addJob(id,quartzName, null, cronStr, quartz_class);
LogUtil.debug(this.getClass(),"用户"+ user.getTrueName()+"新增定时任务:"+id);
} catch (Exception e) {
errCode="999";
errMsg="新增定时任务失败";
LogUtil.error(this.getClass(), "新增定时任务失败,原因:"+ExceptionDUtil.getDetailExceptionMsg(e));
}
responseMap.put("errCode", errCode);
responseMap.put("errMsg", errMsg);
return responseMap;
}
/**
* @description 删除定时任务
* @author thuang
* @created 2020年1月7日 下午2:10:04
* @param map
* @return
*/
@RequestMapping("/deleteQuartz")
@ResponseBody
public HashMap<Object, Object> deleteQuartz(@RequestBody HashMap<Object, Object> map){
HashMap<Object, Object> responseMap=new HashMap<Object, Object>();
String errCode="0";
String errMsg="";
try{
Users user = (Users) SecurityUtils.getSubject().getPrincipal();
String id = StringDUtil.changeNullToEmpty(map.get("configId"));
mySchedulerFactory.pauseJob(id);
this.baseQuartzConfigService.deleteQuartzConfigById(id);
LogUtil.debug(this.getClass(),"用户"+ user.getTrueName()+"删除定时任务:"+id);
} catch (Exception e) {
errCode="999";
errMsg="删除定时任务失败";
LogUtil.error(this.getClass(), "删除定时任务失败,原因:"+ExceptionDUtil.getDetailExceptionMsg(e));
}
responseMap.put("errCode", errCode);
responseMap.put("errMsg", errMsg);
return responseMap;
}
/**
* @description 修改定时任务
* @author thuang
* @created 2020年1月7日 下午2:10:04
* @param map
* @return
*/
@RequestMapping("/modifyQuartz")
@ResponseBody
public HashMap<Object, Object> modifyQuartz(@RequestBody HashMap<Object, Object> map){
HashMap<Object, Object> responseMap=new HashMap<Object, Object>();
String errCode="0";
String errMsg="";
try{
Users user = (Users) SecurityUtils.getSubject().getPrincipal();
String configId = StringDUtil.changeNullToEmpty(map.get("configId"));
String quartzName = StringDUtil.changeNullToEmpty(map.get("quartzName"));
String quartzGroup = StringDUtil.changeNullToEmpty(map.get("quartzGroup"));
String quartzClass = StringDUtil.changeNullToEmpty(map.get("quartz_class"));
String remark = StringDUtil.changeNullToEmpty(map.get("remark"));
String quartzType=StringDUtil.changeNullToEmpty(map.get("jobType"));
String time=StringDUtil.changeNullToEmpty(map.get("time"));
String status=StringDUtil.changeNullToEmpty(map.get("status"));
if(time==null || "".equals(time)){
throw new RuntimeException("time为空");
}
String cronStr = getCron(map);
HashMap<Object, Object> updateMap=new HashMap<Object, Object>();
updateMap.put("configId", configId);
updateMap.put("quartzName", quartzName);
updateMap.put("quartzGroup", quartzGroup);
updateMap.put("quartzClass", quartzClass);
updateMap.put("remark", remark);
updateMap.put("expression", cronStr);
updateMap.put("quartzType", quartzType);
this.baseQuartzConfigService.updateQuartzConfigById(updateMap);
if("0".equals(status)){
mySchedulerFactory.pauseJob(configId);
Thread.sleep(100);
mySchedulerFactory.resumeJob(configId);
}
LogUtil.debug(this.getClass(),"用户"+ user.getTrueName()+"修改定时任务:"+configId);
} catch (Exception e) {
errCode="999";
errMsg="修改定时任务失败";
LogUtil.error(this.getClass(), "修改定时任务失败,原因:"+ExceptionDUtil.getDetailExceptionMsg(e));
}
responseMap.put("errCode", errCode);
responseMap.put("errMsg", errMsg);
return responseMap;
}
/**
* @description: 获取定时任务工厂中所有的任务
* @author thuang
* @date 2021/9/9 14:28
* @version 1.0
*/
@RequestMapping("/get_all_jobs")
@ResponseBody
public HashMap<Object,Object> getAllJobs() {
HashMap<Object,Object> responseMap=new HashMap<>();
List<HashMap<Object,Object>> quartzJobsVOList = new ArrayList<>();
try {
//获取Scheduler
Scheduler scheduler = mySchedulerFactory.getScheduler();
//再获取Scheduler下的所有group
List<String> triggerGroupNames = scheduler.getTriggerGroupNames();
for (String groupName : triggerGroupNames) {
//组装group的匹配为了模糊获取所有的triggerKey或者jobKey
GroupMatcher groupMatcher = GroupMatcher.groupEquals(groupName);
//获取所有的triggerKey
Set<TriggerKey> triggerKeySet = scheduler.getTriggerKeys(groupMatcher);
for (TriggerKey triggerKey : triggerKeySet) {
//通过triggerKey在scheduler中获取trigger对象
CronTrigger trigger = (CronTrigger) scheduler.getTrigger(triggerKey);
//获取trigger拥有的Job
JobKey jobKey = trigger.getJobKey();
JobDetailImpl jobDetail = (JobDetailImpl) scheduler.getJobDetail(jobKey);
//组装页面需要显示的数据
HashMap<Object,Object> map=new HashMap<>();
map.put("configId",jobDetail.getName());
map.put("groupName",groupName);
map.put("cron",trigger.getCronExpression());
quartzJobsVOList.add(map);
}
}
responseMap.put("quartzJobsVOList",quartzJobsVOList);
} catch (Exception e) {
LogUtil.error(this.getClass(),"获取定时任务信息出错,原因:"+e.getMessage());
}
return responseMap;
}
//获取cron表达式
public String getCron(HashMap<Object, Object> map){
String dataStr = StringDUtil.changeNullToEmpty(map.get("dataStr"));
String time = StringDUtil.changeNullToEmpty(map.get("time"));
//拼接cron表达式
String cronStr= "";
//拆分时分秒
String[] split = dataStr.split(":");
if(split.length==3){
//先秒
cronStr=cronStr+split[2]+" ";
//分
cronStr=cronStr+split[1]+" ";
//时
cronStr=cronStr+split[0]+" ";
}
//每周
if("1".equals(time)){
String weekTime = StringDUtil.changeNullToEmpty(map.get("weekTime"));//周几
cronStr=cronStr+"? * ";
//国外第一天是礼拜天国内是礼拜一所以转一下
if("7".equals(weekTime)){
weekTime="1";
}else{
int week = Integer.parseInt(weekTime);
weekTime=""+(week+1);
}
cronStr=cronStr+weekTime;
}
//每月
if("2".equals(time)){
String dayOfMonth = StringDUtil.changeNullToEmpty(map.get("dayOfMonth"));
cronStr=cronStr+dayOfMonth+" * ?";
}
//每季度
if ("3".equals(time)) {
String month = StringDUtil.changeNullToEmpty(map.get("month"));//第几个月
String dayOfMonth = StringDUtil.changeNullToEmpty(map.get("dayOfMonth"));
cronStr=cronStr+dayOfMonth+" "+month+"/3 ?";
}
//每年
if ("4".equals(time)) {
String month = StringDUtil.changeNullToEmpty(map.get("month"));//那一个月
String dayOfMonth = StringDUtil.changeNullToEmpty(map.get("dayOfMonth"));
cronStr=cronStr+dayOfMonth+" "+month+" ?";
}
return cronStr;
}
}

View File

@@ -0,0 +1,210 @@
package com.saye.hospitalgd.controller.system;
import com.saye.hospitalgd.commons.JsonResult;
import com.saye.hospitalgd.commons.date.DateDUtil;
import com.saye.hospitalgd.commons.log.ExceptionDUtil;
import com.saye.hospitalgd.commons.log.LogUtil;
import com.saye.hospitalgd.commons.string.StringDUtil;
import com.saye.hospitalgd.model.Users;
import com.saye.hospitalgd.service.system.DepartService;
import org.apache.shiro.SecurityUtils;
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.HashMap;
import java.util.List;
import java.util.Map;
@Controller
public class DepartController {
@Autowired
private DepartService departService;
/**
* @description 到部门页面
* @author thuang
* @created 2019年11月13日 下午5:26:53
* @param modelMap
* @return
*/
@RequestMapping("/toDepartManager")
public String toDepartManager(ModelMap modelMap){
String parentId="10330001";
List<HashMap<Object, Object>> resourceInfo = this.departService.findDepartTreeNodeList(parentId);
modelMap.addAttribute("departInfo", resourceInfo);
return "system/departManager";
}
/**
*
* @description 新增部门
* @author qfqi
* @created 2019年11月5日 下午3:42:26
* @return
*/
@RequestMapping("/addDepart")
@ResponseBody
public JsonResult addDepart(@RequestBody Map requestMap){
HashMap<String,String> map=new HashMap<String,String>();
map.put("parentId", StringDUtil.changeNullToEmpty(requestMap.get("parentId")));
map.put("departName", StringDUtil.changeNullToEmpty(requestMap.get("departName")));
map.put("departId", StringDUtil.changeNullToEmpty(requestMap.get("departId")));
Users user = (Users) SecurityUtils.getSubject().getPrincipal();
String userName = user.getUserName();
String userTrueName = user.getTrueName();
map.put("modifyUserName", userName);
map.put("modifyTrueName", userTrueName);
String createTime = DateDUtil.getCurrentDate(DateDUtil.yyyy_MM_dd_HH_mm_ss);
String createDate = DateDUtil.getCurrentDate();
map.put("createTime", createTime);
map.put("createDate", createDate);
map.put("modifyTime",createTime);
int result=0;
JsonResult j=new JsonResult();
try {
result = departService.addDepart(map);
LogUtil.debug(this.getClass(),"用户"+ user.getTrueName()+"新增部门map:"+map.toString());
} catch (Exception e) {
e.printStackTrace();
LogUtil.error(this.getClass(), "新增部门失败,原因:"+ExceptionDUtil.getDetailExceptionMsg(e));
}
if(result>0){
j.setState(true);
j.setMessage("新增成功!");
}else{
j.setState(false);
j.setMessage("新增失败!");
}
return j;
}
/**
*
* @description 部门信息修改
* @author qfqi
* @created 2019年11月5日 下午3:45:34
* @return
*/
@RequestMapping("/modifyDepart")
@ResponseBody
public JsonResult modifyDepart(@RequestBody Map requestMap){
HashMap<String,String> map=new HashMap<String,String>();
map.put("departId", StringDUtil.changeNullToEmpty(requestMap.get("departId")));
map.put("departName", StringDUtil.changeNullToEmpty(requestMap.get("departName")));
Users user = (Users) SecurityUtils.getSubject().getPrincipal();
String userName = user.getUserName();
String userTrueName = user.getTrueName();
map.put("modifyUserName", userName);
map.put("modifyTrueName", userTrueName);
String modifyTime = DateDUtil.getCurrentDate(DateDUtil.yyyy_MM_dd_HH_mm_ss);
map.put("modifyTime",modifyTime);
int result=0;
try {
result=departService.modifyDepart(map);
LogUtil.debug(this.getClass(),"用户"+ user.getTrueName()+"修改部门map:"+map.toString());
} catch (Exception e) {
e.printStackTrace();
LogUtil.error(this.getClass(), "修改部门失败,原因:"+ExceptionDUtil.getDetailExceptionMsg(e));
}
JsonResult j=new JsonResult();
if(result>0){
j.setState(true);
j.setMessage("修改成功!");
}else{
j.setState(false);
j.setMessage("修改失败!");
}
return j;
}
/**
*
* @description 删除某部门及其下的所有子结点,并更新其父部门的是否叶子结点信息
* @author qfqi
* @created 2019年11月5日 下午3:48:04
* @return
*/
@RequestMapping("/removeDepart")
@ResponseBody
public JsonResult removeDepart(@RequestBody Map requestMap){
HashMap<String,String> map=new HashMap<String,String>();
map.put("departId", StringDUtil.changeNullToEmpty(requestMap.get("departId")));
Users user = (Users) SecurityUtils.getSubject().getPrincipal();
String userName = user.getUserName();
String userTrueName = user.getTrueName();
map.put("modifyUserName", userName);
map.put("modifyTrueName", userTrueName);
String modifyTime = DateDUtil.getCurrentDate(DateDUtil.yyyy_MM_dd_HH_mm_ss);
map.put("modifyTime",modifyTime);
int result=0;
try {
result=departService.removeDepart(map);
LogUtil.debug(this.getClass(),"用户"+ user.getTrueName()+"删除部门map:"+map.toString());
} catch (Exception e) {
e.printStackTrace();
LogUtil.error(this.getClass(), "删除部门失败,原因:"+ExceptionDUtil.getDetailExceptionMsg(e));
}
JsonResult j=new JsonResult();
if(result>0){
j.setState(true);
j.setMessage("删除成功!");
}else{
j.setState(false);
j.setMessage("删除失败!");
}
return j;
}
/**
* @description: 根据上级部门查询部门
* @author thuang
* @date 2021/7/8 10:10
* @version 1.0
*/
@RequestMapping("/findDepartByParentId")
@ResponseBody
public HashMap<Object,Object> findDepartByParentId(@RequestBody HashMap<Object,Object> map){
HashMap<Object,Object> responseMap=new HashMap<>();
String errCode="0";
String errMsg="";
try {
String parentId=StringDUtil.changeNullToEmpty(map.get("parentId"));
List<HashMap<Object, Object>> resourceInfo = this.departService.findDepartTreeNodeList(parentId);
responseMap.put("resourceInfo",resourceInfo);
}catch (Exception e){
e.printStackTrace();
}
responseMap.put("errCode",errCode);
responseMap.put("errMsg",errMsg);
return responseMap;
}
}

View File

@@ -0,0 +1,269 @@
package com.saye.hospitalgd.controller.system;
import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.saye.hospitalgd.commons.JsonResult;
import com.saye.hospitalgd.commons.date.DateDUtil;
import com.saye.hospitalgd.commons.log.ExceptionDUtil;
import com.saye.hospitalgd.commons.log.LogUtil;
import com.saye.hospitalgd.commons.page.PageUtil;
import com.saye.hospitalgd.commons.page.TemplatePage;
import com.saye.hospitalgd.commons.string.StringDUtil;
import com.saye.hospitalgd.commons.uuid.UUIDGenerator;
import com.saye.hospitalgd.model.Dicinfo;
import com.saye.hospitalgd.model.ResourceInfo;
import com.saye.hospitalgd.model.Users;
import com.saye.hospitalgd.service.system.DicinfoService;
import org.apache.shiro.SecurityUtils;
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.HashMap;
import java.util.List;
import java.util.Map;
@Controller
public class DicinfoController {
@Autowired
private DicinfoService dicinfoService;
/**
*
* @description 跳转到字典管理页面
* @author qfqi
* @created 2019年12月23日 下午1:47:21
* @param modelMap
* @return
*/
@RequestMapping("/toDicinfoManager")
public String toDepartManager(ModelMap modelMap){
String parentCode="0";
List<Dicinfo> list= dicinfoService.findDicinfoTreeNodeList(parentCode);
ResourceInfo resource = new ResourceInfo();
resource.setTitle("字典");
resource.setId("0");
for (Dicinfo dicinfo : list) {
//生成主节点
ResourceInfo resourceInfo = new ResourceInfo();
resourceInfo.setTitle(dicinfo.getDicname());
resourceInfo.setId(dicinfo.getDiccode());
resourceInfo.setSysid(dicinfo.getParentCode());
resource.getChildren().add(resourceInfo);
}
String jsonString = JSONObject.toJSONString(resource);
modelMap.addAttribute("departInfo", jsonString);
return "system/dicinfoManage";
}
/**
*
* @description 新增字典
* @author qfqi
* @created 2019年12月19日 下午5:20:28
* @param
* @return
*/
@RequestMapping("/dicinfoManager/addDicinfoManager")
@ResponseBody
public JsonResult addDicinfoManager(String dicname,String diccode,String dicvalue,String parentCode,String sortNo){
HashMap<String,String> map=new HashMap<String,String>();
JsonResult j=new JsonResult();
map.put("dicname", dicname);
map.put("dicvalue", dicvalue);
map.put("parentCode", parentCode);
map.put("sortNo", sortNo);
if(diccode!=null && !"".equals(diccode)){
//代表新增的是字典树父级 需要验证字点编码是否重复
map.put("diccode", diccode);
List<Dicinfo> list= dicinfoService.findDicinfoBydiccode(diccode);
if(list.size()>0){
//代表在相同的父类下有相同的value值
j.setState(false);
j.setMessage("字典编码重复,请重新输入!");
return j;
}
}else{
//代表新增的是子类需要查询该父类下是否存在相同的val值
map.put("diccode", UUIDGenerator.getUUID());
List<Dicinfo> list= dicinfoService.findDicinfoTreeByCode(map);
if(list.size()>0){
//代表在相同的父类下有相同的value值
j.setState(false);
j.setMessage("字典值重复,请重新输入!");
return j;
}
}
int result=0;
try {
Users user = (Users) SecurityUtils.getSubject().getPrincipal();
map.put("create_time",DateDUtil.getCurrentDate(DateDUtil.yyyy_MM_dd_HH_mm_ss));
result = dicinfoService.addDicinfo(map);
LogUtil.debug(this.getClass(),"用户"+ user.getTrueName()+"新增字典map:"+map.toString());
} catch (Exception e) {
e.printStackTrace();
LogUtil.error(this.getClass(), "新增字典失败,原因:"+ExceptionDUtil.getDetailExceptionMsg(e));
}
if(result>0){
j.setState(true);
j.setMessage("新增成功!");
}else{
j.setState(false);
j.setMessage("新增失败!");
}
return j;
}
/**
*
* @description 修改字典名称
* @author qfqi
* @created 2019年12月19日 下午5:50:45
* @param requestMap
* @return
*/
@RequestMapping("/dicinfoManager/updateDicinfoManager")
@ResponseBody
public JsonResult updateDicinfoManager(String diccode,String dicname,String parentCode,String dicvalue,String sortNo){
HashMap<String,String> map=new HashMap<String,String>();
JsonResult j=new JsonResult();
map.put("dicname", dicname);
map.put("diccode", diccode);
map.put("modifyTime", DateDUtil.getTheCurrentTime());
map.put("dicvalue", dicvalue);
map.put("parentCode", parentCode);
map.put("sortNo", sortNo);
int result=0;
try {
Users user = (Users) SecurityUtils.getSubject().getPrincipal();
result = dicinfoService.modifyDicinfo(map);
LogUtil.debug(this.getClass(),"用户"+ user.getTrueName()+"修改字典map:"+map.toString());
} catch (Exception e) {
e.printStackTrace();
LogUtil.error(this.getClass(), "修改字典失败,原因:"+ExceptionDUtil.getDetailExceptionMsg(e));
}
if(result>0){
j.setState(true);
j.setMessage("修改成功!");
}else{
j.setState(false);
j.setMessage("修改失败!");
}
return j;
}
/**
*
* @description 删除字典
* @author qfqi
* @created 2019年12月19日 下午5:50:25
* @param requestMap
* @return
*/
@RequestMapping("/dicinfoManager/deleteDicinfoManager")
@ResponseBody
public JsonResult deleteDicinfoManager(@RequestBody Map requestMap){
String diccode= StringDUtil.changeNullToEmpty(requestMap.get("diccode"));
int result=0;
JsonResult j=new JsonResult();
try {
Users user = (Users) SecurityUtils.getSubject().getPrincipal();
result = dicinfoService.deleteDicinfo(diccode);
LogUtil.debug(this.getClass(),"用户"+ user.getTrueName()+"删除字典diccode:"+diccode);
} catch (Exception e) {
e.printStackTrace();
LogUtil.error(this.getClass(), "删除字典失败,原因:"+ExceptionDUtil.getDetailExceptionMsg(e));
}
if(result>0){
j.setState(true);
j.setMessage("删除成功!");
}else{
j.setState(false);
j.setMessage("删除失败!");
}
return j;
}
//根据父id分页查询字典
@RequestMapping("/dicinfoManager/selectDicinfoManager")
@ResponseBody
public TemplatePage selectDicinfoManager(String parentCode,Integer page,Integer limit){
PageHelper.startPage(page, limit);
PageInfo<Dicinfo> appsPageInfo = new PageInfo<Dicinfo>(dicinfoService.findDicinfoTreeNodeList(parentCode));
return PageUtil.loadJsonPage(appsPageInfo);
}
//根据上级编码查询所有数据
@RequestMapping("/dicinfoManager/selectDicinfoListByCode")
@ResponseBody
public List<HashMap<Object, Object>> selectDicinfoListByCode(String parent_code){
List<HashMap<Object, Object>> list = this.dicinfoService.selectDicinfoListByCode(parent_code);
return list;
}
//根据条件分页查询字典
@RequestMapping("/dicinfoManager/selectDicinfoPageListByCondition")
@ResponseBody
public TemplatePage selectDicinfoPageListByCondition(String parentCode,String dicname,Integer page,Integer limit){
HashMap<String, String> map = new HashMap<String,String>();
map.put("parentCode", parentCode);
map.put("dicname", dicname);
PageHelper.startPage(page, limit);
PageInfo<HashMap<Object, Object>> appsPageInfo = new PageInfo<HashMap<Object, Object>>(dicinfoService.selectDicinfoListByCondition(map));
return PageUtil.loadJsonPage(appsPageInfo);
}
//根据条件查询所有字典
@RequestMapping("/dicinfoManager/selectDicinfoListByCondition")
@ResponseBody
public List<HashMap<Object, Object>> selectDicinfoListByCondition(@RequestBody HashMap<String, String> map){
List<HashMap<Object, Object>> list = this.dicinfoService.selectDicinfoListByCondition(map);
return list;
}
/**
*
* @description 获取最大字典顺序
* @author qfqi
* @created 2021年1月13日 下午2:56:03
* @param requestMap
* @return
*/
@RequestMapping("/dicinfoManager/getMaxDicValue")
@ResponseBody
public JsonResult getMaxDicValue(@RequestBody Map requestMap){
String diccode= StringDUtil.changeNullToEmpty(requestMap.get("diccode"));
JsonResult j=new JsonResult();
try {
HashMap<String, String> map = new HashMap<String,String>();
map.put("parentCode", diccode);
HashMap<Object, Object> result = dicinfoService.getMaxDicValue(map);
j.setState(true);
j.setData(result.get("MAXDICVALUE"));
j.setMessage("成功!");
} catch (Exception e) {
j.setState(false);
j.setMessage("查询字典最大值失败!");
e.printStackTrace();
LogUtil.error(this.getClass(), "查询字典最大值失败,原因:"+ExceptionDUtil.getDetailExceptionMsg(e));
}
return j;
}
}

View File

@@ -0,0 +1,72 @@
package com.saye.hospitalgd.controller.system;
import java.util.HashMap;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.saye.hospitalgd.commons.log.ExceptionDUtil;
import com.saye.hospitalgd.commons.log.LogUtil;
import com.saye.hospitalgd.model.Logger;
import com.saye.hospitalgd.service.system.LoggerService;
@Controller
public class LoggerController {
@Autowired
private LoggerService loggerService;
/**
* @description 到日志管理页面
* @author thuang
* @created 2019年11月13日 下午5:27:29
* @param modelMap
* @return
*/
@RequestMapping("/toLogger")
public String toLogger(ModelMap modelMap){
return "system/logger";
}
/**
* @description 查询所有日志数据
* @author thuang
* @created 2019年11月13日 下午5:41:56
* @return
*/
@RequestMapping("/findLogger")
@ResponseBody
public HashMap<String, Object> findLogger(String loggerType,String startTime,String endTime,Integer page,Integer limit ){
HashMap<Object, Object> map=new HashMap<Object, Object>();
map.put("loggerType", loggerType);
map.put("startTime", startTime);
map.put("endTime", endTime);
HashMap<String, Object> responseMap = new HashMap<String,Object>();
try {
PageHelper.startPage(page, limit);
// PageInfo<HashMap<Object, Object>> appsPageInfo = new PageInfo<HashMap<Object,Object>>(loggerService.hospitalgd(map));
PageInfo<Logger> appsPageInfo = new PageInfo<Logger>(loggerService.findLogger(map));
responseMap.put("code", 0);
responseMap.put("msg", "");
responseMap.put("count", appsPageInfo.getTotal());
responseMap.put("data", appsPageInfo.getList());
} catch (Exception e) {
e.printStackTrace();
LogUtil.error(this.getClass(), "查询所有日志数据失败,原因:"+ExceptionDUtil.getDetailExceptionMsg(e));
}
return responseMap;
}
}

View File

@@ -0,0 +1,306 @@
package com.saye.hospitalgd.controller.system;
import com.saye.hospitalgd.commons.date.DateDUtil;
import com.saye.hospitalgd.commons.log.ExceptionDUtil;
import com.saye.hospitalgd.commons.log.LogUtil;
import com.saye.hospitalgd.commons.string.StringDUtil;
import com.saye.hospitalgd.model.ResourceInfo;
import com.saye.hospitalgd.model.Users;
import com.saye.hospitalgd.service.UnilateralService;
import com.saye.hospitalgd.service.system.MenuService;
import com.saye.hospitalgd.service.system.ServiceParamsService;
import com.saye.hospitalgd.service.system.UsersService;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.AuthenticationException;
import org.apache.shiro.authc.ExcessiveAttemptsException;
import org.apache.shiro.authc.ExpiredCredentialsException;
import org.apache.shiro.authc.UsernamePasswordToken;
import org.apache.shiro.session.Session;
import org.apache.shiro.subject.Subject;
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 javax.imageio.ImageIO;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;
@Controller
public class LoginController {
@Autowired
private MenuService menuService;
@Autowired
private UsersService usersService;
@Autowired
private ServiceParamsService serviceParamsService;
/**
* @description 去登录页面
* @author dqzhang
* @created 2019年11月13日 下午4:22:48
* @param map
* @return
*/
@RequestMapping("/toLogin")
public String toLogin(ModelMap map) {
List<HashMap<Object, Object>> list = serviceParamsService.findParamValByParamCode("prj_name");
map.addAttribute("prj_name",list.get(0).get("PARAM_VAL"));
return "login";
}
/**
* @description 登录
* @author dqzhang
* @created 2019年11月13日 下午5:03:11
* @return
*/
@RequestMapping("/login")
@ResponseBody
public HashMap<Object,Object> signin(@RequestBody Map map) {
String key = StringDUtil.removeSpaces(map.get("key"));
String username = StringDUtil.removeSpaces(map.get("username"));
String password = StringDUtil.removeSpaces(map.get("password"));
String vercode = StringDUtil.removeSpaces(map.get("vercode"));
String initVector = StringDUtil.removeSpaces(map.get("initVector"));
String errCode = "0";
String errMsg = "";
Subject subject = SecurityUtils.getSubject();
try {
String code = (String) subject.getSession().getAttribute("verify_code");
if(!code.equalsIgnoreCase(vercode)) {
errCode = "CodeError";
errMsg = "验证码不正确!";
}
if("0".equals(errCode)) {
UsernamePasswordToken usernamePasswordToken = new UsernamePasswordToken(username, password);
subject.login(usernamePasswordToken);
LogUtil.info(getClass(), "用户:"+username+"登录系统");
}
} catch (ExcessiveAttemptsException e) {
errCode = "ExcessiveAttempts";
errMsg = "账户已锁定,请稍后再试!";
LogUtil.error(this.getClass(), "登录失败,原因:"+errMsg);
} catch (ExpiredCredentialsException e) {
errCode = "ExpiredCredentials";
errMsg = "账号已过期!";
LogUtil.error(this.getClass(), "登录失败,原因:"+errMsg);
} catch (AuthenticationException e) {
errCode = "Authentication";
errMsg = "账号或密码错误!";
LogUtil.error(this.getClass(), "登录失败,原因:"+errMsg);
} catch (Exception e) {
errCode = e.getLocalizedMessage();
errMsg = "未知异常!";
LogUtil.error(this.getClass(), "登录失败,原因:"+ExceptionDUtil.getDetailExceptionMsg(e));
}
HashMap<Object,Object> resultMap = new HashMap<Object,Object>();
resultMap.put("errCode", errCode);
resultMap.put("errMsg", errMsg);
return resultMap;
}
/**
* @description 首页
* @author dqzhang
* @created 2019年11月13日 下午5:10:21
* @param modelMap
* @return
*/
@RequestMapping("/index")
public String index(ModelMap modelMap) {
HashMap<Object,Object> map = new HashMap<Object,Object>();
Subject subject = SecurityUtils.getSubject();
Users user = (Users) subject.getPrincipal();
String user_id = user.getUserId();
map.put("user_id", user_id);
ResourceInfo resourceInfo=null;
modelMap.addAttribute("expired",false);
try {
//上次密码修改时间
String modifyTime = user.getModifyTime();
String modifyDate = modifyTime.substring(0, 10);
String today = DateDUtil.getCurrentDate("yyyy-MM-dd");
long differDay = DateDUtil.getDaysOfTowDiffDate(modifyDate, today);
if(differDay>90) { //密码90天过期
modelMap.addAttribute("expired",true);
}
resourceInfo = this.menuService.getMenuByRole(map);
String userTrueName = user.getTrueName();
String userName = user.getUserName();
modelMap.addAttribute("userTrueName",userTrueName);
modelMap.addAttribute("userName",userName);
modelMap.addAttribute("userId",user_id);
List<HashMap<Object, Object>> list = serviceParamsService.findParamValByParamCode("prj_name");
modelMap.addAttribute("prj_name",list.get(0).get("PARAM_VAL"));
} catch (Exception e) {
e.printStackTrace();
LogUtil.error(this.getClass(), "跳转首页失败,原因:"+ExceptionDUtil.getDetailExceptionMsg(e));
}
modelMap.addAttribute("resourceInfo", resourceInfo.getChildren());
return "index";
}
/**
* @description 查询菜单
* @author thuang
* @created 2019年11月6日 下午3:55:20
* @return
*/
@RequestMapping("/menu")
@ResponseBody
public ResourceInfo findMenu(){
HashMap<Object,Object> map = new HashMap<Object,Object>();
map.put("user_id", "admin");
map.put("firstNode", "0");
ResourceInfo resourceInfo=null;
try {
resourceInfo = this.menuService.getMenuByRole(map);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
LogUtil.error(this.getClass(), "查询菜单失败,原因:"+ExceptionDUtil.getDetailExceptionMsg(e));
}
return resourceInfo;
}
@RequestMapping("/logout")
public void logout(HttpServletResponse response) throws IOException {
Subject subject = SecurityUtils.getSubject();
if(subject.isAuthenticated()) {
subject.logout();
}
response.sendRedirect("/toLogin");
}
/**
* @description 获取验证码
* @author dqzhang
* @created 2019年11月27日 下午3:15:32
* @param reuqest
* @param response
* @throws Exception
*/
@RequestMapping("/getCode")
public void verify(HttpServletRequest reuqest,HttpServletResponse response) throws Exception {
String name = reuqest.getParameter("name");
response.setContentType("image/jpeg");
response.setHeader("Pragma", "No-cache");
response.setHeader("Cache-Control", "no-cache");
response.setDateHeader("Expires", 0L);
Subject subject = SecurityUtils.getSubject();
Session session = subject.getSession();
try {
int width = 73;
int height = 27;
BufferedImage image = new BufferedImage(width, height, 1);
Graphics g = image.getGraphics();
Random random = new Random();
g.setColor(getRandColor(200, 250));
g.fillRect(0, 0, width, height);
g.setFont(new Font("Times New Roman", 0, 24));
g.setColor(getRandColor(160, 200));
for (int i = 0; i < 155; i++) {
int x = random.nextInt(width);
int y = random.nextInt(height);
int xl = random.nextInt(12);
int yl = random.nextInt(12);
g.drawLine(x, y, x + xl, y + yl);
}
String sRand = "";
for (int i = 0; i < 4; i++) {
String rand = randomInt(1).toUpperCase();
sRand = sRand + rand;
g.setColor(new Color(20 + random.nextInt(110), 20 + random
.nextInt(110), 20 + random.nextInt(110)));
g.drawString(rand, 13 * i + 6, 24);
}
if (StringDUtil.changeNullToEmpty(name).equals(""))
session.setAttribute("verify_code", sRand);
else {
session.setAttribute(name, sRand);
}
g.dispose();
ServletOutputStream responseOutputStream = response.getOutputStream();
ImageIO.write(image, "JPEG", responseOutputStream);
responseOutputStream.flush();
responseOutputStream.close();
}catch (Exception e){
e.printStackTrace();
}
}
private Color getRandColor(int fc, int bc) {
Random random = new Random();
if (fc > 255)
fc = 255;
if (bc > 255)
bc = 255;
int r = fc + random.nextInt(bc - fc);
int g = fc + random.nextInt(bc - fc);
int b = fc + random.nextInt(bc - fc);
return new Color(r, g, b);
}
public static final String randomInt(int length) {
if (length < 1) {
return null;
}
Random randGen = new Random();
// char[] numbersAndLetters = "0123456789abcdefghijklmnopqrstuvwxyz".toCharArray();
char[] numbersAndLetters = "0123456789".toCharArray();
char[] randBuffer = new char[length];
for (int i = 0; i < randBuffer.length; i++) {
// randBuffer[i] = numbersAndLetters[randGen.nextInt(36)];
randBuffer[i] = numbersAndLetters[randGen.nextInt(10)];
}
return new String(randBuffer);
}
@RequestMapping("/toNoAuthority")
public String toNoAuthority(ModelMap modelMap) {
return "/noAuthority";
}
}

View File

@@ -0,0 +1,220 @@
package com.saye.hospitalgd.controller.system;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.saye.hospitalgd.commons.JsonResult;
import com.saye.hospitalgd.commons.log.ExceptionDUtil;
import com.saye.hospitalgd.commons.log.LogUtil;
import com.saye.hospitalgd.model.MenuRole;
import com.saye.hospitalgd.model.ResourceInfo;
import com.saye.hospitalgd.model.Role;
import com.saye.hospitalgd.model.Users;
import com.saye.hospitalgd.service.system.DepartService;
import com.saye.hospitalgd.service.system.MenuService;
import com.saye.hospitalgd.service.system.RoleService;
import org.apache.shiro.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@Controller
public class RoleController {
@Autowired
private RoleService roleService;
@Autowired
private MenuService menuService;
@Autowired
private DepartService departService;
/**
* @description 到角色管理页面
* @author thuang
* @created 2019年11月11日 上午10:50:40
* @return
*/
@RequestMapping("/toRoleManager")
public String toRoleManager(ModelMap modelMap){
HashMap<Object,Object> responseMap = new HashMap<Object,Object>();
responseMap.put("firstNode", "0");
ResourceInfo resourceInfo=null;
try {
resourceInfo = this.menuService.getMenuByRole(responseMap);
} catch (Exception e) {
e.printStackTrace();
}
modelMap.addAttribute("resourceInfo", resourceInfo);
HashMap<String, Object> map = new HashMap<String, Object>();
map.put("parent_id","10330701");
List<HashMap<Object, Object>> departList = this.departService.findDepartByParentId(map);
for (HashMap<Object, Object> departMap : departList) {
departMap.put("id",departMap.get("DEPART_ID"));
departMap.put("title",departMap.get("DEPART_NAME"));
}
modelMap.put("departList",departList);
return "system/roleManager";
}
/**
*
* @description 查询列表
* @author qfqi
* @created 2019年11月5日 下午3:07:41
* @return
*/
@RequestMapping("/searchRole")
@ResponseBody
public HashMap<String, Object> searchRole(String roleName,String date,Integer page, Integer limit){
HashMap<String,String> map=new HashMap<String,String>();
map.put("roleName", roleName);
map.put("date", date);
PageHelper.startPage(page, limit);
PageInfo<Role> appsPageInfo = new PageInfo<Role>(roleService.searchRole(map));
HashMap<String, Object> map1 = new HashMap<String,Object>();
map1.put("code", 0);
map1.put("msg", "你好");
map1.put("count", appsPageInfo.getTotal());
map1.put("data", appsPageInfo.getList());
return map1;
}
/**
* @description 添加角色
* @author thuang
* @created 2019年11月11日 下午3:58:24
* @return
*/
@RequestMapping("/insertRoles")
@ResponseBody
public HashMap<Object, Object> insertRoles(String roleName,String menuId){
HashMap<String, String> map=new HashMap<String, String>();
HashMap<Object, Object> response=new HashMap<Object, Object>();
String errCode="0";
String errMsg="";
Users user = (Users) SecurityUtils.getSubject().getPrincipal();
map.put("roleName",roleName);
map.put("menuId",menuId);
String userName = user.getUserName();
String userTrueName = user.getTrueName();
map.put("userName", userName);
map.put("userTrueName", userTrueName);
//新增角色
try {
String status = roleService.addRole(map);
LogUtil.info(this.getClass(),"用户"+ user.getTrueName()+"添加角色map:"+map.toString());
if ("true".equals(status)) {
}else {
errCode="998";
errMsg=status;
}
} catch (Exception e) {
e.printStackTrace();
errCode="999";
errMsg=e.getMessage();
LogUtil.error(this.getClass(), "新增角色失败,原因:"+ExceptionDUtil.getDetailExceptionMsg(e));
}
response.put("errCode", errCode);
response.put("errMsg", errMsg);
return response;
}
/**
*
* @description 删除用户角色
* @author qfqi
* @created 2019年11月5日 下午3:07:54
* @return
*/
@RequestMapping("/deleteRole")
@ResponseBody
public JsonResult deleteRole(String roleId){
Users user = (Users) SecurityUtils.getSubject().getPrincipal();
int result=roleService.deleteRole(roleId);
LogUtil.info(this.getClass(),"用户"+ user.getTrueName()+"删除角色roleId:"+roleId);
JsonResult j=new JsonResult();
if(result>0){
j.setState(true);
j.setMessage("删除成功!");
}else{
j.setState(false);
j.setMessage("删除失败!");
}
return j;
}
/**
* @description 根据角色id获取角色权限菜单id
* @author thuang
* @created 2019年11月12日 上午9:51:08
* @return
*/
@RequestMapping("/getSelectMenuId")
@ResponseBody
public List<String> getSelectMenuId(String roleId){
HashMap<Object, Object> map=new HashMap<Object, Object>();
map.put("roleId",roleId);
List<MenuRole> menuIdByRoleId = menuService.getMenuIdByRoleId(map);
List<String> menuIdList=new ArrayList<String>();
for (int i = 0; i < menuIdByRoleId.size(); i++) {
MenuRole menuRole = menuIdByRoleId.get(i);
menuIdList.add(menuRole.getMenuId());
}
return menuIdList;
}
/**
*
* @description 修改用户角色权限信息
* @author qfqi
* @created 2019年11月5日 下午3:08:05
* @return
*/
@RequestMapping("/modifyRoleResource")
@ResponseBody
public JsonResult modifyRoleResource(String roleId,String roleName,String menuId,String departId,String pointDelete) {
HashMap<String,String> map=new HashMap<String,String>();
map.put("roleName", roleName);
map.put("roleId", roleId);
map.put("menuId", menuId);
map.put("departId", departId);
map.put("pointDelete", pointDelete);
Users user = (Users) SecurityUtils.getSubject().getPrincipal();
int result=roleService.modifyRoleResource(map);
LogUtil.info(this.getClass(),"用户"+ user.getTrueName()+"修改用户角色权限信息map:"+map.toString());
JsonResult j=new JsonResult();
if(result>0){
j.setState(true);
j.setMessage("修改成功!");
}else{
j.setState(false);
j.setMessage("修改失败!");
}
return j;
}
}

View File

@@ -0,0 +1,714 @@
package com.saye.hospitalgd.controller.system;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.saye.hospitalgd.commons.JsonResult;
import com.saye.hospitalgd.commons.date.DateDUtil;
import com.saye.hospitalgd.commons.log.ExceptionDUtil;
import com.saye.hospitalgd.commons.log.LogUtil;
import com.saye.hospitalgd.commons.string.StringDUtil;
import com.saye.hospitalgd.model.*;
import com.saye.hospitalgd.service.system.DepartService;
import com.saye.hospitalgd.service.system.RoleService;
import com.saye.hospitalgd.service.system.UsersService;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.crypto.hash.Md5Hash;
import org.apache.shiro.subject.Subject;
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.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@Controller
public class UsersController {
@Autowired
private UsersService usersService;
@Autowired
private RoleService roleService;
@Autowired
private DepartService departService;
/**
* @description 到用户管理页面
* @author thuang
* @created 2019年11月15日 上午10:12:12
* @return
*/
@RequestMapping("/toUserManager")
public String toUserManager(ModelMap modelMap){
//查询所有部门
String parentId="10330001";
List<HashMap<Object, Object>> resourceInfo = this.departService.findDepartTreeNodeList(parentId);
modelMap.addAttribute("departInfo", resourceInfo);
//查询所有角色
List<Role> roleList = this.roleService.findRoleList();
modelMap.addAttribute("roleList",roleList);
//查询所有一级地市
List<HashMap<Object, Object>> departList = departService.findDepartByParentId(new HashMap<String,Object>(){{put("parent_id","10330701");}});
modelMap.addAttribute("departList",departList);
return "system/userManager";
}
/**
*
* @description user表分页查询
* @author qfqi
* @created 2019年11月5日 下午3:06:12
* @return
*/
@RequestMapping("/selectUser")
@ResponseBody
public HashMap<String, Object> searchUsers(String departId,String trueName,String isactive,String roleId,String dtRoleId,Integer page, Integer limit) {
HashMap<Object,Object> map=new HashMap<Object,Object>();
HashMap<String, Object> resultMap = new HashMap<String,Object>();
try{
String[] departIds=null;
if (departId !=null && !"".equals(departId)) {
departIds = departId.split(",");
}
map.put("departId", departIds);
map.put("trueName", trueName);
map.put("isactive", isactive);
map.put("roleId", roleId);
map.put("dtRoleId", dtRoleId);
PageHelper.startPage(page, limit);
PageInfo<Users> appsPageInfo = new PageInfo<Users>(usersService.searchUsers(map));
resultMap.put("code", 0);
resultMap.put("msg", "OK");
resultMap.put("count", appsPageInfo.getTotal());
resultMap.put("data", appsPageInfo.getList());
}catch (Exception e){
resultMap.put("code", 999);
resultMap.put("msg", e.getMessage());
}
return resultMap;
}
/**
*
* @description 新增用户
* @author qfqi
* @created 2019年11月5日 下午3:05:10
* @return
*/
@RequestMapping("/insertUsers")
@ResponseBody
public JsonResult insertUsers(@RequestBody HashMap<Object, Object> requestMap){
int i;
JsonResult j=new JsonResult();
try {
Users user = (Users) SecurityUtils.getSubject().getPrincipal();
String userName = user.getUserName();
String userTrueName = user.getTrueName();
requestMap.put("userName", userName);
requestMap.put("userTrueName", userTrueName);
i = usersService.insertUser(requestMap);
if(i>0){
LogUtil.debug(this.getClass(),"用户"+ user.getTrueName()+"新增用户的方法requestMap:"+requestMap.toString());
j.setState(true);
j.setMessage("新增成功!");
}else{
j.setState(false);
j.setMessage("新增失败!");
}
} catch (Exception e) {
e.printStackTrace();
j.setState(false);
j.setMessage(e.getMessage());
LogUtil.error(this.getClass(), "新增用户失败,原因:"+ExceptionDUtil.getDetailExceptionMsg(e));
}
return j;
}
/**
*
* @description 修改用户
* @author qfqi
* @created 2019年11月5日 下午3:04:28
* @return
*/
@RequestMapping("/modifyUsers")
@ResponseBody
public JsonResult modifyUsers(@RequestBody HashMap<Object, Object> requestMap){
JsonResult j=new JsonResult();
try {
Users user = (Users) SecurityUtils.getSubject().getPrincipal();
String userName = user.getUserName();
String userTrueName = user.getTrueName();
requestMap.put("userName", userName);
requestMap.put("userTrueName", userTrueName);
String createTime = DateDUtil.getCurrentDate(DateDUtil.yyyy_MM_dd_HH_mm_ss);
String createDate = DateDUtil.getCurrentDate();
/*requestMap.put("modifyTime", createTime);
requestMap.put("createTime", createTime);*/
requestMap.put("createDate", createDate);
int result=usersService.modifyUsers(requestMap);
if(result>0){
LogUtil.debug(this.getClass(),"用户"+ user.getTrueName()+"修改用户的方法requestMap:"+requestMap.toString());
j.setState(true);
j.setMessage("修改成功!");
}else{
j.setState(false);
j.setMessage("修改失败!");
}
} catch (Exception e) {
e.printStackTrace();
j.setState(false);
j.setMessage(e.getMessage());
LogUtil.error(this.getClass(), "修改用户失败,原因:"+ExceptionDUtil.getDetailExceptionMsg(e));
}
return j;
}
/**
*
* @description 密码重置
* @author qfqi
* @created 2019年11月5日 下午3:06:37
* @return
*/
@RequestMapping("/reSetPassword")
@ResponseBody
public JsonResult reSetPassword(@RequestBody HashMap<Object, Object> requestMap){
JsonResult j=new JsonResult();
try {
Users user = (Users) SecurityUtils.getSubject().getPrincipal();
String userName = user.getUserName();
String userTrueName = user.getTrueName();
requestMap.put("modifyUserName", userName);
requestMap.put("modifyTrueName", userTrueName);
String createTime = DateDUtil.getCurrentDate(DateDUtil.yyyy_MM_dd_HH_mm_ss);
String createDate = DateDUtil.getCurrentDate();
requestMap.put("createTime", createTime);
requestMap.put("createDate", createDate);
//产生6位长度的随机密码由字母和数字组成
String password = StringDUtil.generateRandomCodeForLength(6);
String addPasswordMd5 = new Md5Hash(password,"hospitalgd",2).toString();
requestMap.put("password", addPasswordMd5);
int result=usersService.reSetPassword(requestMap);
if(result>0){
LogUtil.debug(this.getClass(),"用户"+ user.getTrueName()+"重置用户的密码方法requestMap:"+requestMap.toString());
j.setState(true);
j.setMessage("修改成功!");
j.setData(password);
}else{
j.setState(false);
j.setMessage("修改失败!");
}
} catch (Exception e) {
e.printStackTrace();
j.setState(false);
j.setMessage(e.getMessage());
LogUtil.error(this.getClass(), "密码重置失败,原因:"+ExceptionDUtil.getDetailExceptionMsg(e));
}
return j;
}
/**
*
* @description 启用/禁用
* @author qfqi
* @created 2019年11月5日 下午3:06:54
* @return
*/
@RequestMapping("/unableUser")
@ResponseBody
public JsonResult unableUser(@RequestBody HashMap<Object, Object> requestMap){
JsonResult j=new JsonResult();
try{
Users user = (Users) SecurityUtils.getSubject().getPrincipal();
String userName = user.getUserName();
String userTrueName = user.getTrueName();
requestMap.put("modifyUserName", userName);
requestMap.put("modifyTrueName", userTrueName);
String createTime = DateDUtil.getCurrentDate(DateDUtil.yyyy_MM_dd_HH_mm_ss);
String createDate = DateDUtil.getCurrentDate();
requestMap.put("createTime", createTime);
requestMap.put("createDate", createDate);
int result=usersService.unableUser(requestMap);
if(result>0){
LogUtil.debug(this.getClass(),"用户"+ user.getTrueName()+"启用禁用用户的方法requestMap:"+requestMap.toString());
j.setState(true);
j.setMessage("修改成功!");
}else{
j.setState(false);
j.setMessage("修改失败!");
}
}catch (Exception e) {
e.printStackTrace();
j.setState(false);
j.setMessage(e.getMessage());
LogUtil.error(this.getClass(), "禁用启用失败,原因:"+ExceptionDUtil.getDetailExceptionMsg(e));
}
return j;
}
/**
*
* @description 查询角色
* @author qfqi
* @created 2019年11月5日 下午3:07:09
* @return
*/
// @RequestMapping("/findRoleList")
// @ResponseBody
// public JsonResult findRoleList(){
// List<Role> list =roleService.findRoleList();
// JsonResult j=new JsonResult();
// j.setState(true);
// j.setMessage("查询成功");
// j.setData(list);
// return j;
// }
/**
*
* @description 新增用户名验证
* @author qfqi
* @created 2019年11月5日 下午3:07:22
* @param userName
* @return
*/
@RequestMapping("/searchByName")
@ResponseBody
public JsonResult searchByName(String userName){
List<Users> list=usersService.searchByName(userName);
JsonResult j=new JsonResult();
j.setState(true);
j.setMessage("查询成功");
j.setData(list);
return j;
}
/**
* @description 修改密码
* @author thuang
* @created 2019年11月27日 下午6:13:05
* @param requestMap
* @return
*/
@RequestMapping("/modifyPassword")
@ResponseBody
public JsonResult modifyPassword(@RequestBody HashMap<Object, Object> requestMap){
String password = StringDUtil.changeNullToEmpty(requestMap.get("password"));
String key = StringDUtil.removeSpaces(requestMap.get("key"));
String initVector = StringDUtil.removeSpaces(requestMap.get("initVector"));
JsonResult j=new JsonResult();
try {
Subject subject = SecurityUtils.getSubject();
Users user = (Users) subject.getPrincipal();
String username = user.getUserName();
String passwordMd5 = new Md5Hash(password,"hospitalgd",2).toString();
String addPasswordMd5 = new Md5Hash(password,"hospitalgd",2).toString();
String modifyTime = DateDUtil.getTheCurrentTime();
this.usersService.modifyPassword(username,passwordMd5,modifyTime);
user.setModifyTime(modifyTime);
j.setState(true);
j.setMessage("更改密码成功");
LogUtil.debug(this.getClass(),"用户修改用户的密码方法requestMap:"+requestMap.toString());
} catch (Exception e) {
j.setState(false);
j.setMessage("更改密码失败");
e.printStackTrace();
LogUtil.error(this.getClass(), "修改密码失败,原因:"+ExceptionDUtil.getDetailExceptionMsg(e));
}
return j;
}
/**
* @description: 导入人员信息
* @author thuang
* @date 2021/5/19 9:57
* @version 1.0
*/
@RequestMapping("/uploadUsers")
@ResponseBody
public HashMap<Object, Object> uploadUsers(@RequestParam("spareFile") MultipartFile file, HttpServletRequest request, HttpServletResponse response)throws Exception{
HashMap<Object, Object> responseMap=new HashMap<Object, Object>();
String errCode="0";
String errMsg="";
if (!file.isEmpty()) {
XSSFWorkbook workbook =null;
//创建Excel读取文件内容
workbook = new XSSFWorkbook(file.getInputStream());
//获取第一个工作表
XSSFSheet sheet = workbook.getSheetAt(0);
//获取sheet中第一行行号
int firstRowNum = sheet.getFirstRowNum();
//获取sheet中最后一行行号
int lastRowNum = sheet.getLastRowNum();
try {
//查询部门
List<HashMap<Object,Object>> departs = departService.selectAllDeparts();
HashMap<String,HashMap<Object,Object>> departTreeMap=new HashMap<>();
HashMap<String,List<HashMap<Object,Object>>> parentIdMap=new HashMap<>();
HashMap<String,HashMap<Object,Object>> departIdMap=new HashMap<>();
//处理部门组织方便查询
for (int i=0;i<departs.size();i++){
HashMap<Object, Object> map = departs.get(i);
String depart_id = StringDUtil.changeNullToEmpty(map.get("DEPART_ID"));
String depart_name = StringDUtil.changeNullToEmpty(map.get("DEPART_NAME"));
String parent_id = StringDUtil.changeNullToEmpty(map.get("PARENT_ID"));
String parent_name = StringDUtil.changeNullToEmpty(map.get("PARENT_NAME"));
//如果上级名称为空说明没有上级部门,就是第一级 当然也有错误数据的情况,不过要出问题要满足名称相同,且上级都为空
departIdMap.put(depart_id,map);
if ("".equals(parent_name)){
departTreeMap.put(depart_id,map);
continue;
}
List<HashMap<Object, Object>> pidList = parentIdMap.get(parent_id);
if (pidList == null){
pidList=new ArrayList<>();
parentIdMap.put(parent_id,pidList);
}
pidList.add(map);
}
for (String key : parentIdMap.keySet()){
List<HashMap<Object, Object>> list = parentIdMap.get(key);
HashMap<Object, Object> map = departIdMap.get(key);
map.put("childen",list);
}
//时间
String create_time = DateDUtil.getCurrentDate(DateDUtil.yyyy_MM_dd_HH_mm_ss);
String create_date = DateDUtil.getCurrentDate(DateDUtil.yyyy_MM_dd);
//添加人员
Subject subject = SecurityUtils.getSubject();
Users user = (Users) subject.getPrincipal();
String modify_user_name = user.getUserName();
String modify_true_name = user.getTrueName();
//循环插入数据
int errNum=0;
List<String> errNumList=new ArrayList<String>();
List<HashMap<Object,Object>> addList=new ArrayList<>();
for(int i=firstRowNum+2;i<=lastRowNum;i++){//因为表格中第一行为标题,第二行为列标题
XSSFRow row = sheet.getRow(i);
HashMap<Object, Object> addMap=new HashMap<Object, Object>();
//用户id
XSSFCell user_id = row.getCell(0);
if(user_id==null){
errNum++;
errNumList.add(""+(i+1));
continue;
}else {
user_id.setCellType(Cell.CELL_TYPE_STRING);
addMap.put("user_id",user_id.getStringCellValue());
addMap.put("user_name",user_id.getStringCellValue());
}
//姓名
XSSFCell true_name = row.getCell(1);
if(true_name==null){
errNum++;
errNumList.add(""+(i+1));
continue;
}else {
true_name.setCellType(Cell.CELL_TYPE_STRING);
addMap.put("true_name",true_name.getStringCellValue());
}
//性别
XSSFCell sex = row.getCell(2);
if(sex==null){
addMap.put("sex","");
}else {
sex.setCellType(Cell.CELL_TYPE_STRING);
addMap.put("sex",sex.getStringCellValue());
}
//公司
String companyId="";
XSSFCell company = row.getCell(3);
if(company==null){
errNum++;
errNumList.add(""+(i+1));
continue;
}else {
company.setCellType(Cell.CELL_TYPE_STRING);
String companyStr = company.getStringCellValue();
//第一层是最上一级
boolean isHas=false;
for(String key:departTreeMap.keySet()){
HashMap<Object, Object> hashMap = departTreeMap.get(key);
List<HashMap<Object,Object>> departList = (List<HashMap<Object,Object>>)hashMap.get("childen");
//要循环的级别
for (int j=0;j<departList.size();j++){
HashMap<Object, Object> departObj = departList.get(j);
String depart_id = StringDUtil.changeNullToEmpty(departObj.get("DEPART_ID"));
String depart_name = StringDUtil.changeNullToEmpty(departObj.get("DEPART_NAME"));
if(companyStr.equals(depart_name)){
addMap.put("company",depart_id);
companyId=depart_id;
isHas=true;
break;
}
}
}
//判断对错 错的错误记录加1
if (!isHas){
errNum++;
errNumList.add(""+(i+1));
continue;
}
}
//部门
XSSFCell depart = row.getCell(4);
if(depart==null){
errNum++;
errNumList.add(""+(i+1));
continue;
}else {
depart.setCellType(Cell.CELL_TYPE_STRING);
String departStr = depart.getStringCellValue();
//从部门树中找到部门
HashMap<Object, Object> hashMap = departIdMap.get(companyId);
List<HashMap<Object,Object>> departList = (List<HashMap<Object,Object>>)hashMap.get("childen");
List<String> data=new ArrayList<>();
getDepartIdByMapTree(data,departStr,departList);
if (data.size()>0){
addMap.put("depart_id",data.get(0));
}else{
errNum++;
errNumList.add(""+(i+1));
continue;
}
}
//岗位
XSSFCell post = row.getCell(5);
if(post==null){
addMap.put("post","");
}else {
post.setCellType(Cell.CELL_TYPE_STRING);
addMap.put("post",post.getStringCellValue());
}
//政治面貌
XSSFCell policital_status = row.getCell(6);
if(policital_status==null){
addMap.put("policital_status","");
}else {
policital_status.setCellType(Cell.CELL_TYPE_STRING);
addMap.put("policital_status",policital_status.getStringCellValue());
}
//专业技术资格
XSSFCell positional_titles = row.getCell(7);
if(positional_titles==null){
addMap.put("positional_titles","");
}else {
positional_titles.setCellType(Cell.CELL_TYPE_STRING);
addMap.put("positional_titles",positional_titles.getStringCellValue());
}
//学历
XSSFCell education = row.getCell(8);
if(education==null){
addMap.put("education","");
}else {
education.setCellType(Cell.CELL_TYPE_STRING);
addMap.put("education",education.getStringCellValue());
}
//职业技能名称
XSSFCell vocational_name = row.getCell(9);
if(vocational_name==null){
addMap.put("vocational_name","");
}else {
vocational_name.setCellType(Cell.CELL_TYPE_STRING);
addMap.put("vocational_name",vocational_name.getStringCellValue());
}
//职业技术等级级别
XSSFCell level = row.getCell(10);
if(level==null){
addMap.put("level","");
}else {
level.setCellType(Cell.CELL_TYPE_STRING);
addMap.put("level",level.getStringCellValue());
}
//把固定的参数添加到map 默认密码先设置123
addMap.put("password",new Md5Hash("123","hospitalgd",2).toString());
addMap.put("isactive", "1");
addMap.put("modify_user_name", modify_user_name);
addMap.put("modify_true_name", modify_true_name);
addMap.put("create_time", create_time);
addMap.put("create_date", create_date);
addList.add(addMap);
}
if(errNum>0){
errCode="999";
errMsg="导入失败,有"+errNum+"行导入错误";
responseMap.put("errNumList", errNumList);
}else{
try {
usersService.insertExcelUsers(addList);//往数据库插入数据
} catch (Exception e) {
LogUtil.error(this.getClass(), "上传人员列表失败,原因:"+ExceptionDUtil.getDetailExceptionMsg(e));
}
}
} catch (Exception e) {
errCode="999";
errMsg="上传备件列表失败!"+e.getMessage();
e.printStackTrace();
LogUtil.error(this.getClass(), "上传人员列表失败,原因:"+ExceptionDUtil.getDetailExceptionMsg(e));
} finally {
workbook.close();
}
}
responseMap.put("errCode", errCode);
responseMap.put("errMsg", errMsg);
return responseMap;
}
/**
* @description: 根据部门id查询相关人员
* @author thuang
* @date 2021/8/3 10:15
* @version 1.0
*/
@RequestMapping("/findUserByDepartId")
@ResponseBody
public HashMap<Object,Object> findUserByDepartId(@RequestBody HashMap<Object,Object> map){
HashMap<Object, Object> responseMap=new HashMap<Object, Object>();
String errCode="0";
String errMsg="";
try {
String departIds = StringDUtil.changeNullToEmpty(map.get("departIds"));
//如果是空的就直接返回个空集合 不查询
if ("".equals(departIds)){
responseMap.put("userList",new ArrayList<>());
}else {
String[] split = departIds.split(",");
List<String> idList=new ArrayList<>();
for (int i = 0; i < split.length; i++) {
idList.add(split[i]);
}
List<HashMap<Object, Object>> userByDepartIds = usersService.findUserByDepartIds(idList);
//循环数据生成所要格式 list 中 {namevalue}
List<HashMap<Object, Object>> userList =new ArrayList<>();
for (int i = 0; i < userByDepartIds.size(); i++) {
HashMap<Object, Object> hashMap = userByDepartIds.get(i);
HashMap<Object, Object> selectObj=new HashMap<>();
selectObj.put("name",hashMap.get("TRUE_NAME"));
selectObj.put("value",hashMap.get("USER_ID"));
userList.add(selectObj);
}
responseMap.put("userList",userList);
}
}catch (Exception e){
e.printStackTrace();
errCode="999";
errMsg="查询部门相关人员失败,原因:"+e.getMessage();
}
responseMap.put("errCode", errCode);
responseMap.put("errMsg", errMsg);
return responseMap;
}
/**
* @description: 从上面生成的部门Map中根据部门名称获取部门id
* @author thuang
* @date 2021/7/14 13:45
* @version 1.0
* @param data
*/
public void getDepartIdByMapTree(List<String> data, String departStr, List<HashMap<Object, Object>> departList){
for (int i=0;i<departList.size();i++){
HashMap<Object, Object> departObj = departList.get(i);
String depart_id = StringDUtil.changeNullToEmpty(departObj.get("DEPART_ID"));
String depart_name = StringDUtil.changeNullToEmpty(departObj.get("DEPART_NAME"));
List<HashMap<Object,Object>> departChildenList = (List<HashMap<Object,Object>>)departObj.get("childen");
if(departStr.equals(depart_name)){
data.add(depart_id);
return;
}
if(departChildenList!=null && departChildenList.size()>0){
getDepartIdByMapTree(data,departStr,departChildenList);
}
}
}
}

View File

@@ -0,0 +1,50 @@
package com.saye.hospitalgd.controller.system;
import com.saye.hospitalgd.commons.date.DateDUtil;
import com.saye.hospitalgd.model.StatusDefine;
import com.saye.hospitalgd.commons.string.StringDUtil;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.FileInputStream;
import java.io.OutputStream;
import java.net.URLEncoder;
/**
* @author thuang
* @version 1.0
* @description: TODO
* @date 2021/5/24 13:56
*/
@Controller
public class downloadController {
@RequestMapping("/download")
public void downloadFile(HttpServletRequest request, HttpServletResponse response) throws Exception{
try {
String fileName = StringDUtil.changeNullToEmpty(request.getParameter("fileName"));
String dowloadName = StringDUtil.changeNullToEmpty(request.getParameter("dowloadName"));
//过滤相对路径../
int lastIndex = fileName.lastIndexOf(".");
//fileName = fileName.substring(0, lastIndex).replaceAll(".", "")+fileName.substring(lastIndex);
String savePath = StatusDefine.filePath + fileName ;
File file = new File(savePath);
FileInputStream fis = new FileInputStream(file);
response.setContentType("application/force-download");
response.addHeader("Content-disposition", "attachment;fileName=" + URLEncoder.encode(dowloadName+ DateDUtil.getCurrentDate(DateDUtil.yyyy_MM_dd)+".xlsx", "UTF-8"));
OutputStream os = response.getOutputStream();
byte[] buf = new byte[1024];
int len = 0;
while((len = fis.read(buf)) != -1) {
os.write(buf, 0, len);
}
fis.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}

View File

@@ -0,0 +1,142 @@
package com.saye.hospitalgd.entity;
import java.io.Serializable;
import lombok.Getter;
import lombok.Setter;
/**
* (BankbillHistory)实体类
*
* @author makejava
* @since 2021-09-09 16:03:37
*/
@Getter
@Setter
public class BankbillHistory implements Serializable {
private static final long serialVersionUID = -33254602055133483L;
/**
* 清算日期
*/
private String cQsrq;
/**
* 交易日期
*/
private String cJyrq;
/**
* 交易时间
*/
private String cJysj;
/**
* 终端号
*/
private String cZdh;
/**
* 卡号(部分加密 应该没用
*/
private String cCard;
/**
* 交易类型
*/
private String cJylx;
/**
* 交易金额
*/
private String cJyje;
/**
* 清算金额
*/
private String cQsje;
/**
* 手续费
*/
private String cSxf;
/**
* 实际支付金额
*/
private String cSjzfje;
/**
* 参考号
*/
private String cCkh;
/**
* 流水号
*/
private String cLsh;
/**
* 卡类型
*/
private String cKlx;
/**
* 发卡行
*/
private String cFkh;
/**
* 支付方式
*/
private String cZffs;
/**
* 银商订单号
*/
private String cYsddh;
/**
* 商户订单号
*/
private String cShddh;
/**
* 备注字段
*/
private String cBzzd;
/**
* 钱包优惠金额
*/
private String cQbyhje;
/**
* 商户优惠金额
*/
private String cShyhje;
/**
* 原交易流水号
*/
private String cYjylsh;
/**
* 分期期数
*/
private String cFqqs;
/**
* 分期手续费
*/
private String cFqsxf;
/**
* 分期服务方
*/
private String cFqfwf;
/**
* 分期付息方
*/
private String cFqfxf;
/**
* 其他优惠金额
*/
private String cQtyhje;
/**
* 退货订单号
*/
private String cThddh;
/**
* 付款附言
*/
private String cFkfy;
/**
* 分店简称
*/
private String cFdjc;
/**
* 子订单号
*/
private String cZddh;
/**
* 对账表名
*/
private String billTableName;
}

View File

@@ -0,0 +1,147 @@
package com.saye.hospitalgd.entity;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* Created with IntelliJ IDEA.
*
* @author Mr.zs
* @date 2022/11/7
* @description
* @modifiedBy
* @version: 1.0
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class BankbillsHistory {
private static final long serialVersionUID = -33254602055133484L;
/*
*对账单日期
*/
private String iDzdrq;
/*
*集团编号
*/
private String iJtbh;
/*
*集团名称
*/
private String iJtmc;
/*
*特约单位编号
*/
private String iTydwbh;
/*
*特约单位名称
*/
private String iTydwmc;
/*
*微信编号
*/
private String iWxbh;
/*
*支付宝编号
*/
private String iZfbbh;
/*
*线上线下标志
*/
private String iXsxxbz;
/*
*交易日期
*/
private String iJyrq;
/*
*交易时间
*/
private String iJysj;
/*
*商户入帐帐号
*/
private String iShrzzh;
/*
*pos编号
*/
private String iPosbh;
/*
*交易类型
*/
private String iJylx;
/*
*交易渠道
*/
private String iJyqd;
/*
*交易方式
*/
private String iJyfs;
/*
*工行订单号
*/
private String iGhddh;
/*
*商户订单号
*/
private String iShddh;
/*
*第三方订单号
*/
private String iDsfddh;
/*
*关联订单号
*/
private String iGlddh;
/*
*手续费清算方式
*/
private String iSxfqsfs;
/*
*订单总金额
*/
private String iDdzje;
/*
*交易金额
*/
private String iJyje;
/*
*入账金额
*/
private String iRzje;
/*
*付款卡号
*/
private String iFkkh;
/*
*付款银行
*/
private String iFkyh;
/*
*借贷记标志
*/
private String iJdjbz;
/*
*用户标识
*/
private String iYhbs;
/*
*货币种类
*/
private String iHbzl;
/*
*商户名称
*/
private String iSpmc;
/*
*附言
*/
private String iFy;
}

View File

@@ -0,0 +1,26 @@
package com.saye.hospitalgd.entity;
import lombok.Data;
/**
* @description: his账单实体类
* @author: Mr.zs
* @create: 2024-05-15 15:57
**/
@Data
public class HisbillsHistory {
private String HisOperCode;
private String PayMethod;
private String TradingStatus;
private String BizType;
private String PayType;
private String TradeTime;
private String Amount;
private String PlatformTransId;
private String HisTransId;
private String patientId;
private String PatientName;
private String source;
private String trade_date;
}

View File

@@ -0,0 +1,26 @@
package com.saye.hospitalgd.mapper;
import org.apache.ibatis.annotations.Param;
import java.util.HashMap;
import java.util.List;
/**
* 银行对账单下载记录(BankbillGetinfo)表数据库访问层
*
* @author makejava
* @since 2021-09-10 09:21:53
*/
public interface BankbillGetinfoMapper {
HashMap<Object,Object> findBankbillGetinfoById(HashMap<Object,Object> map);
List<HashMap<Object, Object>> findBankbillGetinfoList(HashMap<Object,Object> map);
int insertBankbillGetinfo(HashMap<Object,Object> map);
int updateBankbillGetinfo(HashMap<Object,Object> map);
int deleteBankbillGetinfoById(HashMap<Object,Object> map);
List<HashMap<Object, Object>> findBankbillGetinfoByParam(HashMap<Object, Object> map) throws Exception;
}

View File

@@ -0,0 +1,47 @@
package com.saye.hospitalgd.mapper;
import com.saye.hospitalgd.entity.BankbillHistory;
import java.util.HashMap;
import java.util.List;
/**
* (BankbillHistory)表数据库访问层
*
* @author makejava
* @since 2021-09-09 15:35:48
*/
public interface BankbillHistoryMapper {
List<HashMap<Object,Object>> findBankbillHistoryById(HashMap<Object,Object> map);
List<HashMap<Object, Object>> findBankbillHistoryList(HashMap<Object,Object> map);
void insertAllBankHistory(List<BankbillHistory> list) throws Exception;
List<HashMap<Object, Object>> findCzffs()throws Exception;
void deleteBankbillHistoryByParam(HashMap<Object, Object> deleteMap) throws Exception;
void findBankbillHistoryToTemp(HashMap<Object, Object> map) throws Exception;
void deleteTempTable() throws Exception;
List<HashMap<Object, Object>> findBankbillHistoryByParam(HashMap<Object, Object> map) throws Exception;
List<HashMap<Object, Object>> findBankbillHistoryByTimeAndPlatformTransId(HashMap<Object, Object> map) throws Exception;
List<HashMap<Object, Object>> findBankBillNumByTime(HashMap<Object, Object> map) throws Exception;
List<HashMap<Object, Object>> findBankBillMoneyByTime(HashMap<Object, Object> map) throws Exception;
List<HashMap<Object, Object>> findbankbillHistoryCount(HashMap<Object, Object> map) throws Exception;
List<HashMap<Object, Object>> findbankbillHistorySum(HashMap<Object, Object> map) throws Exception;
void deleteBankbillOriginalByParam(HashMap<Object, Object> deleteMap) throws Exception;
void insertBankbillOriginal(List<BankbillHistory> addList) throws Exception;
List<HashMap<Object, Object>> findBankbillCountData(HashMap<Object, Object> map) throws Exception;
}

View File

@@ -0,0 +1,33 @@
package com.saye.hospitalgd.mapper;
import com.saye.hospitalgd.entity.BankbillsHistory;
import java.util.HashMap;
import java.util.List;
/**
* Created with IntelliJ IDEA.
*
* @author Mr.zs
* @date 2022/12/7
* @description
* @modifiedBy
* @version: 1.0
*/
public interface BankbillsHistoryMapper {
List<HashMap<Object, Object>> findBankbillHistoryByParam(HashMap<Object, Object> searchNotUniqueObjMap);
List<HashMap<Object, Object>> findBankBillsByDate(HashMap<Object, Object> searchMap);
int saveOriginalData(List<HashMap<Object, Object>> savList);
int saveHistoryData(List<HashMap<Object, Object>> savList);
void deleteOriginalByParam(HashMap<Object, Object> deleteMap);
void insertOriginal(List<BankbillsHistory> addList);
void deleteHistoryByParam(HashMap<Object, Object> deleteMap);
void insertHistory(List<BankbillsHistory> addList);
}

View File

@@ -0,0 +1,7 @@
package com.saye.hospitalgd.mapper;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface CashUnilateralMapper {
}

View File

@@ -0,0 +1,42 @@
package com.saye.hospitalgd.mapper;
import org.apache.ibatis.annotations.Mapper;
import java.util.HashMap;
import java.util.List;
@Mapper
public interface HisDetailMapper {
List<HashMap<Object, Object>> findHisDetail(HashMap<Object, Object> map) throws Exception;
void deleteHisBillOriginalByParam(HashMap<Object, Object> deleteMap) throws Exception;
void deleteHisBillByParam(HashMap<Object, Object> deleteMap) throws Exception;
void insertAllHisBillOriginal(List<HashMap<Object, Object>> list)throws Exception;
void insertAllHisBillHistory(List<HashMap<Object, Object>> list) throws Exception;
void deleteTempTable() throws Exception;
void findHisDetailToTemp(HashMap<Object, Object> map) throws Exception;
List<HashMap<Object, Object>> findHisDetailByParam(HashMap<Object, Object> map) throws Exception;
List<HashMap<Object, Object>> findHisDetailByTimeAndYSDDH(HashMap<Object, Object> map) throws Exception;
List<HashMap<Object, Object>> findHisDetailFirmNumByTime(HashMap<Object, Object> map) throws Exception;
List<HashMap<Object, Object>> findHisCashDetail(HashMap<Object, Object> map) throws Exception;
void deleteHisBillOriginalWNByParam(HashMap<Object, Object> deleteMap) throws Exception;
void insertAllHisBillOriginalWN(List<HashMap<Object, Object>> addList) throws Exception;
List<HashMap<Object, Object>> findHisDetailCountData(HashMap<Object, Object> map) throws Exception;
void deleteHisBillOriginalHYByParam(HashMap<Object, Object> deleteMap) throws Exception;
void insertAllHisBillOriginalHY(List<HashMap<Object, Object>> addList) throws Exception;
}

View File

@@ -0,0 +1,13 @@
package com.saye.hospitalgd.mapper;
import org.apache.ibatis.annotations.Mapper;
import java.util.HashMap;
import java.util.List;
@Mapper
public interface HisInterFaceConfigMapper {
List<HashMap<Object, Object>> findConfigById(String id) throws Exception;
List<HashMap<Object, Object>> findAllconfig() throws Exception;
}

View File

@@ -0,0 +1,34 @@
package com.saye.hospitalgd.mapper;
import com.saye.hospitalgd.entity.HisbillsHistory;
import org.mapstruct.Mapper;
import java.util.HashMap;
import java.util.List;
/**
* Created with IntelliJ IDEA.
*
* @author Mr.zs
* @date 2022/12/2
* @description
* @modifiedBy
* @version: 1.0
*/
@Mapper
public interface HisbillsHistoryMapper {
void saveHisHistoryData(HashMap<Object, Object> hisbillsOriginal);
List<HashMap<Object, Object>> findHisBillsByDate(HashMap<Object, Object> searchMap);
List<HashMap<Object, Object>> findHisDetailByParam(HashMap<Object, Object> searchNotUniqueObjMap);
void deleteOriginalDataByDate(HashMap<Object, Object> delMap);
void insertHisBillsOriginalList(List<HisbillsHistory> hisBillList);
void deleteHistoryDataByDate(HashMap<Object, Object> delMap);
void insertHisbillsHistoryList(List<HisbillsHistory> list);
}

View File

@@ -0,0 +1,25 @@
package com.saye.hospitalgd.mapper;
import org.apache.ibatis.annotations.Mapper;
import java.util.HashMap;
import java.util.List;
/**
* @author thuang
* @version 1.0
* @description: TODO
* @date 2021/9/29 14:57
*/
@Mapper
public interface OperatorMapper {
List<HashMap<Object, Object>> findAllOperator(HashMap<Object, Object> map) throws Exception;
List<HashMap<Object, Object>> findAllOperatorByCode(HashMap<Object, Object> map) throws Exception;
void addOperator(HashMap<Object, Object> map) throws Exception;
void updateOperatorByCode(HashMap<Object, Object> map) throws Exception;
}

View File

@@ -0,0 +1,13 @@
package com.saye.hospitalgd.mapper;
import org.apache.ibatis.annotations.Mapper;
import java.util.HashMap;
import java.util.List;
@Mapper
public interface ReconciliationResultMapper {
List<HashMap<Object, Object>> findReconciliationResultPageList(HashMap<Object, Object> map) throws Exception;
void insertReconciliationResult(HashMap<Object, Object> map) throws Exception;
}

View File

@@ -0,0 +1,18 @@
package com.saye.hospitalgd.mapper;
import org.apache.ibatis.annotations.Mapper;
import java.util.HashMap;
/**
* @author thuang
* @version 1.0
* @description: TODO
* @date 2021/12/3 13:21
*/
@Mapper
public interface RefundMapper {
public void addRefundInfo(HashMap<Object, Object> map) throws Exception;
}

View File

@@ -0,0 +1,21 @@
package com.saye.hospitalgd.mapper;
import org.apache.ibatis.annotations.Mapper;
import java.util.HashMap;
import java.util.List;
/**
* Created with IntelliJ IDEA.
*
* @author Mr.zs
* @date 2023/10/9
* @description
* @modifiedBy
* @version: 1.0
*/
@Mapper
public interface RefundOrderMapper {
List<HashMap<Object, Object>> findRefundOrder(HashMap<Object, Object> map);
}

View File

@@ -0,0 +1,26 @@
package com.saye.hospitalgd.mapper;
import java.util.HashMap;
import java.util.List;
/**
* (ThirdFtpConfig)表数据库访问层
*
* @author makejava
* @since 2021-09-16 14:37:43
*/
public interface ThirdFtpConfigMapper {
HashMap<Object,Object> findThirdFtpConfigById(HashMap<Object,Object> map);
List<HashMap<Object, Object>> findThirdFtpConfigList(HashMap<Object,Object> map);
List<HashMap<Object, Object>> findWLIF(HashMap<Object, Object> searchMap);
int insertThirdFtpConfig(HashMap<Object,Object> map);
int updateThirdFtpConfig(HashMap<Object,Object> map);
int deleteThirdFtpConfigById(HashMap<Object,Object> map);
}

View File

@@ -0,0 +1,20 @@
package com.saye.hospitalgd.mapper;
import java.util.HashMap;
import java.util.List;
/**
* Created with IntelliJ IDEA.
*
* @author Mr.zs
* @date 2022/11/7
* @description
* @modifiedBy
* @version: 1.0
*/
public interface ThirdSftpConfigMapper {
List<HashMap<Object, Object>> findThirdSftpConfigList(HashMap<Object, Object> map);
List<HashMap<Object, Object>> findWLIF(HashMap<Object, Object> searchMap);
}

View File

@@ -0,0 +1,78 @@
package com.saye.hospitalgd.mapper;
import org.apache.ibatis.annotations.Mapper;
import java.util.HashMap;
import java.util.List;
/**
* @author thuang
* @version 1.0
* @description: TODO
* @date 2021/9/28 11:05
*/
@Mapper
public interface TransactionDetailMapper {
List<HashMap<Object, Object>> findHisAndThirdJoinData(HashMap<Object, Object> map) throws Exception;
List<HashMap<Object, Object>> findHisUnilateral() throws Exception;
List<HashMap<Object, Object>> findBankUnilateral() throws Exception;
List<HashMap<Object, Object>> findDiff()throws Exception;
List<HashMap<Object, Object>> findHisAndThirdJoinDataNumByTime(HashMap<Object, Object> map) throws Exception;
void insertJoinDataToHisAndThird(HashMap<Object, Object> map) throws Exception;
void insertHisUnilateral(HashMap<Object, Object> map) throws Exception;
void insertThirdUnilateral(HashMap<Object, Object> map) throws Exception;
void deleteHisAndThirdJoinData(HashMap<Object, Object> map) throws Exception;
void updateHisAndThirdError(HashMap<Object, Object> map) throws Exception;
List<HashMap<Object, Object>> findHisAndThirdJoinDataByParam(HashMap<Object, Object> map) throws Exception;
void insertHisAndThirdJoinData(HashMap<Object, Object> map) throws Exception;
void insertJoinDataToHisAndCash(HashMap<Object, Object> map) throws Exception;
void insertHisCashUnilateral(HashMap<Object, Object> map) throws Exception;
void insertCashUnilateral(HashMap<Object, Object> map) throws Exception;
void updateJoinDate(HashMap<Object, Object> map) throws Exception;
void updateJoinSetActiveByThird(HashMap<Object, Object> map) throws Exception;
void updateJoinSetActiveByHis(HashMap<Object, Object> map)throws Exception;
void updateJoinSetActiveByThirdCash(HashMap<Object, Object> map)throws Exception;
void updateJoinSetActiveByHisCash(HashMap<Object, Object> map)throws Exception;
List<HashMap<Object, Object>> findAllBankDetailNum(HashMap<Object, Object> map) throws Exception;
List<HashMap<Object, Object>> findAllBankDetailSum(HashMap<Object, Object> map) throws Exception;
List<HashMap<Object, Object>> findDBZNum(HashMap<Object, Object> map) throws Exception;
List<HashMap<Object, Object>> findJoinDataNumByTime(HashMap<Object, Object> map) throws Exception;
List<HashMap<Object, Object>> findDBZFLNumByTime(HashMap<Object, Object> map) throws Exception;
List<HashMap<Object, Object>> findBankBillNumByTime(HashMap<Object, Object> map) throws Exception;
List<HashMap<Object, Object>> findBankBillMoneyByTime(HashMap<Object, Object> map) throws Exception;
void updateJoinSetActiveByZhiPiao(HashMap<Object, Object> map) throws Exception;
List<HashMap<Object, Object>> findHisAndThirdJoinDataByParamAndNotUnique(HashMap<Object, Object> map) throws Exception;
void deleteHisAndThirdJoinDataByParamAndNotUnique(HashMap<Object, Object> map) throws Exception;
void addNotUniqueData(List<HashMap<Object, Object>> list) throws Exception;
}

View File

@@ -0,0 +1,25 @@
package com.saye.hospitalgd.mapper;
import org.apache.ibatis.annotations.Mapper;
import java.util.HashMap;
import java.util.List;
/**
* Created with IntelliJ IDEA.
*
* @author Mr.zs
* @date 2023/10/8
* @description
* @modifiedBy
* @version: 1.0
*/
@Mapper
public interface TranscationsMapper {
List<HashMap<Object, Object>> findTradeRecords(HashMap<Object, Object> map);
List<HashMap<Object, Object>> findActionableTrading(HashMap<Object, Object> map);
HashMap<Object, Object> findActionableTradingByJylsh(HashMap<Object, Object> map);
}

View File

@@ -0,0 +1,31 @@
package com.saye.hospitalgd.mapper;
import org.apache.ibatis.annotations.Mapper;
import java.util.HashMap;
import java.util.List;
@Mapper
public interface UnilateralMapper {
List<HashMap<Object, Object>> findAllUnilateral(HashMap<Object, Object> map) throws Exception;
void insertUnilateral(HashMap<Object, Object> map) throws Exception;
void updateUnilateral(HashMap<Object, Object> map)throws Exception;
List<HashMap<Object, Object>> findDBZNum(HashMap<Object, Object> map) throws Exception;
List<HashMap<Object, Object>> findDBZFLNumByTime(HashMap<Object, Object> map) throws Exception;
void deleteUnilateral(HashMap<Object, Object> map)throws Exception;
List<HashMap<Object, Object>> findUnilateralByParam(HashMap<Object, Object> map) throws Exception;
void deleteUnilateralByNoManager(HashMap<Object, Object> map) throws Exception;
void updateUnilateralManagerStatus(HashMap<Object, Object> map) throws Exception;
void deleteUnilateralByJoinIdNotNull(HashMap<Object, Object> map) throws Exception;
void deleteUnilateralByIdandStatus(HashMap<Object, Object> map) throws Exception;
}

View File

@@ -0,0 +1,20 @@
package com.saye.hospitalgd.mapper;
import org.mapstruct.Mapper;
import java.util.HashMap;
/**
* Created with IntelliJ IDEA.
*
* @author Mr.zs
* @date 2022/12/2
* @description
* @modifiedBy
* @version: 1.0
*/
@Mapper
public interface hisbillsOriginalMapper {
void saveHisOriginalData(HashMap<Object, Object> hisbillsOriginal);
}

View File

@@ -0,0 +1,19 @@
package com.saye.hospitalgd.mapper.historyLog;
import org.apache.ibatis.annotations.Mapper;
import java.util.HashMap;
import java.util.List;
@Mapper
public interface CashDetailMapper {
List<HashMap<Object, Object>> findCashDetailPageList(HashMap<Object, Object> map) throws Exception;
void insertCash(List<HashMap<Object, Object>> addList) throws Exception;
void editCash(HashMap<Object, Object> map) throws Exception;
void deleteCash(HashMap<Object, Object> map) throws Exception;
List<HashMap<Object, Object>> findCashDetailList(HashMap<Object, Object> map)throws Exception;
}

View File

@@ -0,0 +1,16 @@
package com.saye.hospitalgd.mapper.historyLog;
import org.apache.ibatis.annotations.Mapper;
import java.util.HashMap;
import java.util.List;
@Mapper
public interface HisBillLogMapper {
List<HashMap<Object, Object>> findHisBillLogPageList(HashMap<Object, Object> map) throws Exception;
void insertHisbillGetinfo(HashMap<Object, Object> map) throws Exception;
List<HashMap<Object, Object>> findHisBillLogByParam(HashMap<Object, Object> map) throws Exception;
}

View File

@@ -0,0 +1,22 @@
package com.saye.hospitalgd.mapper.historyLog;
import org.apache.ibatis.annotations.Mapper;
import java.util.HashMap;
import java.util.List;
/**
* @author thuang
* @version 1.0
* @description: TODO
* @date 2021/8/31 10:22
*/
@Mapper
public interface ReconciliationLogMapper {
List<HashMap<Object, Object>> findReconciliationLogPageList(HashMap<Object, Object> map) throws Exception;
List<HashMap<Object, Object>> findReconciliationLogByParam(HashMap<Object, Object> map) throws Exception;
void insertReconciliationLog(HashMap<Object, Object> map) throws Exception;
}

View File

@@ -0,0 +1,32 @@
package com.saye.hospitalgd.mapper.quzrtz;
import java.util.HashMap;
import java.util.List;
import com.saye.hospitalgd.model.BaseQuartzConfigEntity;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface BaseQuartzConfigMapper {
public List<BaseQuartzConfigEntity> findAll(HashMap<Object, Object> map) throws Exception;
public BaseQuartzConfigEntity findEntityById(String id) throws Exception;
public void updateQuartzConfigByEntity(BaseQuartzConfigEntity quartzConfigEntity) throws Exception;
public List<HashMap<Object, Object>> findMaxId() throws Exception;
public void addQuartz(HashMap<Object, Object> addMap) throws Exception;
public List<HashMap<Object, Object>> findOrderProjectList() throws Exception;
public void addQuartzToSparePart(HashMap<Object, Object> addMap) throws Exception;
public void deleteQuartzConfigById(String id) throws Exception;
public void updateQuartzConfigById(HashMap<Object, Object> updateMap) throws Exception;
}

View File

@@ -0,0 +1,45 @@
package com.saye.hospitalgd.mapper.system;
import com.saye.hospitalgd.model.Departs;
import org.apache.ibatis.annotations.Param;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
public interface DepartMapper {
//通过父节点查询
public List<Departs> findDepartTreeNodeList(String parentId);
//新增部门
public int addDepart(HashMap<String,String> map);
//修改部门
public int modifyDepart(HashMap<String,String> map);
//删除部门以及该部门的子节点
public int removeDepart(HashMap<String,String> map);
//查询所有的部门数据
public List<Departs> selectDepartTreeList();
/**
* @description 根据上级id查询部门树
* @author thuang
* @created 2019年11月12日 下午4:51:45
* @param parentId
* @return
*/
public List<HashMap<Object, Object>> selectDepartTreeListByParentId(String parentId);
//根据部门名称查询部门对象
public List<Departs> selectDepartBydepartName(String departName);
public List<HashMap<Object, Object>> findDepartByParentId(HashMap<String, Object> map);
List<HashMap<Object, Object>> selectAllDeparts();
List<HashMap<Object, Object>> findDepartById(@Param("set") HashSet<String> set) throws Exception;
}

View File

@@ -0,0 +1,37 @@
package com.saye.hospitalgd.mapper.system;
import com.saye.hospitalgd.model.Dicinfo;
import org.apache.ibatis.annotations.Mapper;
import java.util.HashMap;
import java.util.List;
@Mapper
public interface DicinfoMapper {
//字典表管理
//通过父节点查询
public List<Dicinfo> findDicinfoTreeNodeList(String parentCode);
//通过diccode查询字典
public List<Dicinfo> findDicinfoBydiccode(String diccode);
//新增
public int addDicinfo(HashMap<String,String> map);
//修改
public int modifyDicinfo(HashMap<String,String> map);
//删除
public int deleteDicinfo(String diccode);
public List<HashMap<Object, Object>> selectDicinfoListByCode(String parent_code);
//通过parentCode和val值查询该父类下值是否重复
public List<Dicinfo> findDicinfoTreeByCode(HashMap<String,String> map);
public List<HashMap<Object, Object>> selectDicinfoListByCondition(HashMap<String, String> map);
//通过parentCode查询该字典下的最大值
public HashMap<Object, Object> getMaxDicValue(HashMap<String,String> map) throws Exception;
}

View File

@@ -0,0 +1,24 @@
package com.saye.hospitalgd.mapper.system;
import java.util.HashMap;
import java.util.List;
import org.springframework.stereotype.Repository;
import com.saye.hospitalgd.model.Logger;
@Repository
public interface LoggerMapper {
/**
* @description 查询所有日志
* @author thuang
* @created 2019年11月14日 下午2:06:22
* @param map
* @return
*/
public List<Logger> findLoggers(HashMap<Object, Object> map);
public void addLog(HashMap<Object, Object> map) throws Exception;
}

View File

@@ -0,0 +1,19 @@
package com.saye.hospitalgd.mapper.system;
import org.apache.ibatis.annotations.Mapper;
import java.util.HashMap;
import java.util.List;
@Mapper
public interface MenuMapper {
public List<HashMap<Object,Object>> findMenuByRole(HashMap<Object, Object> map);
public List<HashMap<String,Object>> findMenuById(String id);
public List<HashMap<Object, Object>> findMenuByUrl(HashMap<Object, Object> map);
public List<HashMap<Object, Object>> findRoleByUserAndMenu(HashMap<Object, Object> map);
}

View File

@@ -0,0 +1,26 @@
package com.saye.hospitalgd.mapper.system;
import com.saye.hospitalgd.model.MenuRole;
import org.apache.ibatis.annotations.Mapper;
import java.util.HashMap;
import java.util.List;
@Mapper
public interface MenuRoleMapper {
/**删除角色权限信息 通过roleID
* */
public int deleteMenuRole(String roleId);
//插入角色权限表记录
public int insertMenuRole(String roleId,String menuId);
/**
* @description 根据角色id获取信息
* @author thuang
* @created 2019年11月12日 上午11:26:33
* @param map
* @return
*/
public List<MenuRole> getMenuRolesByRoleId(HashMap<Object, Object> map);
}

View File

@@ -0,0 +1,48 @@
package com.saye.hospitalgd.mapper.system;
import com.saye.hospitalgd.model.Role;
import java.util.HashMap;
import java.util.List;
public interface RoleMapper {
/**查询角色列表
* */
public List<Role> findRoleList();
/**多条件查询角色列表
* */
public List<Role> searchRole(HashMap<String,String>map);
/**删除角色
* */
public int deleteRole(String roleId);
/**
* @description 添加角色
* @author thuang
* @created 2019年11月11日 下午4:47:47
* @param map
* @return
*/
public int addRole(HashMap<String,String>map);
/**
* 根据条件查询人员是否在管理员角色下
* @param map
* @return
* @throws Exception
*/
public List<HashMap<Object, Object>> findUserRoleListByParam(HashMap<Object, Object> map) throws Exception;
void updateRole(HashMap<String, String> map) ;
/**
* @description: 根据用户id 查询用户权限
* @author thuang
* @date 2021/5/24 17:11
* @version 1.0
*/
List<HashMap<Object, Object>> findUserRoleListByUserId(HashMap<Object, Object> map) throws Exception;
}

View File

@@ -0,0 +1,28 @@
package com.saye.hospitalgd.mapper.system;
import com.saye.hospitalgd.model.ServiceParams;
import java.util.HashMap;
import java.util.List;
public interface ServiceParamsMapper {
//对业务参数列表进行增删查改
public List<ServiceParams> selectServiceParams(HashMap<String,String> map);
//新增
public int insertServiceParams(ServiceParams sp);
//修改
public int updateServiceParams(ServiceParams sp);
//删除
public int deleteServiceParams(String paramId);
public List<HashMap<Object,Object>> findParamVal()throws Exception;
public List<HashMap<Object, Object>> findParamValByParamCode(String code) throws Exception;
public void updateServiceParamsValBycode(HashMap<String, String> map);
}

View File

@@ -0,0 +1,28 @@
package com.saye.hospitalgd.mapper.system;
import com.saye.hospitalgd.model.UserRole;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
@Mapper
public interface UserRoleMapper {
/**
* 插入用户角色表
*/
public int insertUserRole(String userId, String roleId);
/**
* 根据userId删除记录
*/
public void deleteUserRole(String userId);
// 根据userId查询记录
public List<UserRole> selectUserRoleByUserId(String userId);
// 根据roleId查询记录
public List<UserRole> selectUserRoleByRoleId(String roleId);
int insertNewUserRole(String userId, String roleId, String userRoleId);
}

View File

@@ -0,0 +1,67 @@
package com.saye.hospitalgd.mapper.system;
import com.saye.hospitalgd.model.Users;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.HashMap;
import java.util.List;
@Mapper
public interface UsersMapper {
/**
* 分页查询用户列表
* */
public List<Users> searchUsers(HashMap<Object, Object> map);
/**新增用户
* */
public int insertUser(HashMap<Object, Object> map);
/**修改用户信息
* */
public int modifyUsers(HashMap<Object, Object> map);
/**user用户密码重置
* */
public int reSetPassword(HashMap<Object, Object> map);
/**
* 修改状态 启用禁用
* */
public int unableUser(HashMap<Object, Object> map);
/**新增用户名验证
* */
public List<Users> searchByName(String userName);
/**
* @description 修改用户密码
* @author thuang
* @created 2019年11月28日 上午8:41:34
* @param password
* @throws Exception
*/
public void modifyPassword(String username, String password, String modifyTime) throws Exception;
public void modifyLockTime(String username, String lockTime);
void insertExcelUsers(List<HashMap<Object, Object>> list);
List<HashMap<Object, Object>> findUserByDepartIds(@Param("idList") List<String> idList)throws Exception;
/**
* @description: 根据部门id查询人员信息
* @author thuang
* @date 2021/8/24 10:33
* @version 1.0
*/
List<HashMap<Object, Object>> findUserByDepartIdsAndIsactive(@Param("idList") List<String> idList) throws Exception;
/**
* @description: 查询用户及部门的详细信息
* @author thuang
* @date 2021/8/24 10:21
* @version 1.0
*/
List<HashMap<Object, Object>> findUserAndIsactive() throws Exception;
}

View File

@@ -0,0 +1,69 @@
package com.saye.hospitalgd.model;
public class BaseQuartzConfigEntity {
private String configId;
private String quartzName;
private String quartzGroup;
private String status;
private String quartzClass;
private String remark;
private String createUserId;
private String expression;
private String createTime;
public String getConfigId() {
return configId;
}
public void setConfigId(String configId) {
this.configId = configId;
}
public String getQuartzName() {
return quartzName;
}
public void setQuartzName(String quartzName) {
this.quartzName = quartzName;
}
public String getQuartzGroup() {
return quartzGroup;
}
public void setQuartzGroup(String quartzGroup) {
this.quartzGroup = quartzGroup;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public String getQuartzClass() {
return quartzClass;
}
public void setQuartzClass(String quartzClass) {
this.quartzClass = quartzClass;
}
public String getRemark() {
return remark;
}
public void setRemark(String remark) {
this.remark = remark;
}
public String getCreateUserId() {
return createUserId;
}
public void setCreateUserId(String createUserId) {
this.createUserId = createUserId;
}
public String getExpression() {
return expression;
}
public void setExpression(String expression) {
this.expression = expression;
}
public String getCreateTime() {
return createTime;
}
public void setCreateTime(String createTime) {
this.createTime = createTime;
}
}

View File

@@ -0,0 +1,107 @@
package com.saye.hospitalgd.model;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
public class Departs {
private String departId;
private String departName;
private String parentId;
private String leaf;
private String isactive;
private String modifyUserName;
private String modifyTrueName;
private String createTime;
private String createDate;
private String modifyTime;
private List<Departs> children;
private HashMap<Object, Object> attributes;
public Departs(){
children = new ArrayList<Departs>();
}
public List<Departs> getChildren() {
return children;
}
public void setChildren(List<Departs> list2) {
this.children = list2;
}
public HashMap<Object, Object> getAttributes() {
return attributes;
}
public void setAttributes(HashMap<Object, Object> attributes) {
this.attributes = attributes;
}
public String getDepartId() {
return departId;
}
public void setDepartId(String departId) {
this.departId = departId;
}
public String getDepartName() {
return departName;
}
public void setDepartName(String departName) {
this.departName = departName;
}
public String getParentId() {
return parentId;
}
public void setParentId(String parentId) {
this.parentId = parentId;
}
public String getLeaf() {
return leaf;
}
public void setLeaf(String leaf) {
this.leaf = leaf;
}
public String getIsactive() {
return isactive;
}
public void setIsactive(String isactive) {
this.isactive = isactive;
}
public String getModifyUserName() {
return modifyUserName;
}
public void setModifyUserName(String modifyUserName) {
this.modifyUserName = modifyUserName;
}
public String getModifyTrueName() {
return modifyTrueName;
}
public void setModifyTrueName(String modifyTrueName) {
this.modifyTrueName = modifyTrueName;
}
public String getCreateTime() {
return createTime;
}
public void setCreateTime(String createTime) {
this.createTime = createTime;
}
public String getCreateDate() {
return createDate;
}
public void setCreateDate(String createDate) {
this.createDate = createDate;
}
public String getModifyTime() {
return modifyTime;
}
public void setModifyTime(String modifyTime) {
this.modifyTime = modifyTime;
}
}

View File

@@ -0,0 +1,56 @@
package com.saye.hospitalgd.model;
public class Dicinfo {
private String diccode;
private String dicname;
private String dicvalue;
private String parentCode;
private String createTime;
private String modifyTime;
private Integer sortNo;
public String getDiccode() {
return diccode;
}
public void setDiccode(String diccode) {
this.diccode = diccode;
}
public String getDicname() {
return dicname;
}
public void setDicname(String dicname) {
this.dicname = dicname;
}
public String getDicvalue() {
return dicvalue;
}
public void setDicvalue(String dicvalue) {
this.dicvalue = dicvalue;
}
public String getParentCode() {
return parentCode;
}
public void setParentCode(String parentCode) {
this.parentCode = parentCode;
}
public String getCreateTime() {
return createTime;
}
public void setCreateTime(String createTime) {
this.createTime = createTime;
}
public String getModifyTime() {
return modifyTime;
}
public void setModifyTime(String modifyTime) {
this.modifyTime = modifyTime;
}
public Integer getSortNo() {
return sortNo;
}
public void setSortNo(Integer sortNo) {
this.sortNo = sortNo;
}
}

View File

@@ -0,0 +1,50 @@
package com.saye.hospitalgd.model;
public class Logger {
public String loggerId;
public String logType;
public String information;
public String create_time;
public String user_id;
public String ip;
public String getLoggerId() {
return loggerId;
}
public void setLoggerId(String loggerId) {
this.loggerId = loggerId;
}
public String getLogType() {
return logType;
}
public void setLogType(String logType) {
this.logType = logType;
}
public String getInformation() {
return information;
}
public void setInformation(String information) {
this.information = information;
}
public String getCreate_time() {
return create_time;
}
public void setCreate_time(String create_time) {
this.create_time = create_time;
}
public String getUser_id() {
return user_id;
}
public void setUser_id(String user_id) {
this.user_id = user_id;
}
public String getIp() {
return ip;
}
public void setIp(String ip) {
this.ip = ip;
}
}

View File

@@ -0,0 +1,77 @@
package com.saye.hospitalgd.model;
public class Menu {
private String menuId;
private String menuName;
private String parentId;
private Integer seq;
private String linkUrl;
private String isactive;
private String createTime;
private String reslevel;
private String linkImg;
private Integer linkImgSize;
public String getMenuId() {
return menuId;
}
public void setMenuId(String menuId) {
this.menuId = menuId;
}
public String getMenuName() {
return menuName;
}
public void setMenuName(String menuName) {
this.menuName = menuName;
}
public String getParentId() {
return parentId;
}
public void setParentId(String parentId) {
this.parentId = parentId;
}
public Integer getSeq() {
return seq;
}
public void setSeq(Integer seq) {
this.seq = seq;
}
public String getLinkUrl() {
return linkUrl;
}
public void setLinkUrl(String linkUrl) {
this.linkUrl = linkUrl;
}
public String getIsactive() {
return isactive;
}
public void setIsactive(String isactive) {
this.isactive = isactive;
}
public String getCreateTime() {
return createTime;
}
public void setCreateTime(String createTime) {
this.createTime = createTime;
}
public String getReslevel() {
return reslevel;
}
public void setReslevel(String reslevel) {
this.reslevel = reslevel;
}
public String getLinkImg() {
return linkImg;
}
public void setLinkImg(String linkImg) {
this.linkImg = linkImg;
}
public Integer getLinkImgSize() {
return linkImgSize;
}
public void setLinkImgSize(Integer linkImgSize) {
this.linkImgSize = linkImgSize;
}
}

View File

@@ -0,0 +1,27 @@
package com.saye.hospitalgd.model;
public class MenuRole {
private String menuRoleId;
private String roleId;
private String menuId;
public String getMenuRoleId() {
return menuRoleId;
}
public void setMenuRoleId(String menuRoleId) {
this.menuRoleId = menuRoleId;
}
public String getRoleId() {
return roleId;
}
public void setRoleId(String roleId) {
this.roleId = roleId;
}
public String getMenuId() {
return menuId;
}
public void setMenuId(String menuId) {
this.menuId = menuId;
}
}

Some files were not shown because too many files have changed in this diff Show More