Kaynağa Gözat

Merge branch 'master' of huangrui/CostAccount into dev

lijiaxi 4 yıl önce
ebeveyn
işleme
f08f49598b
32 değiştirilmiş dosya ile 2712 ekleme ve 121 silme
  1. 1792 0
      src/main/java/com/imed/costaccount/common/util/DateUtils.java
  2. 2 0
      src/main/java/com/imed/costaccount/constants/CommonConstant.java
  3. 11 2
      src/main/java/com/imed/costaccount/mapper/CostIncomeGroupMapper.java
  4. 1 1
      src/main/java/com/imed/costaccount/mapper/RoleMenuMapper.java
  5. 8 0
      src/main/java/com/imed/costaccount/model/CostIncomeGroup.java
  6. 1 1
      src/main/java/com/imed/costaccount/model/ReportForm.java
  7. 1 1
      src/main/java/com/imed/costaccount/model/ReportRelation.java
  8. 42 0
      src/main/java/com/imed/costaccount/model/dto/ReportFormEditDTO.java
  9. 26 1
      src/main/java/com/imed/costaccount/model/dto/ReportFormSaveDTO.java
  10. 27 0
      src/main/java/com/imed/costaccount/model/dto/ReportRelationDTO.java
  11. 16 0
      src/main/java/com/imed/costaccount/model/vo/CostIncomeGroupAllAmountVO.java
  12. 71 0
      src/main/java/com/imed/costaccount/model/vo/CostIncomeGroupBeforeVO.java
  13. 5 0
      src/main/java/com/imed/costaccount/model/vo/RelationVO.java
  14. 12 1
      src/main/java/com/imed/costaccount/service/CostIncomeGroupService.java
  15. 16 0
      src/main/java/com/imed/costaccount/service/ReportFormService.java
  16. 17 1
      src/main/java/com/imed/costaccount/service/ReportRelationService.java
  17. 1 1
      src/main/java/com/imed/costaccount/service/RoleMenuService.java
  18. 1 4
      src/main/java/com/imed/costaccount/service/UserRoleService.java
  19. 15 2
      src/main/java/com/imed/costaccount/service/impl/AccountingProductServiceImpl.java
  20. 3 2
      src/main/java/com/imed/costaccount/service/impl/AccountingServiceImpl.java
  21. 12 10
      src/main/java/com/imed/costaccount/service/impl/CostAccountShareServiceImpl.java
  22. 115 2
      src/main/java/com/imed/costaccount/service/impl/CostIncomeGroupServiceImpl.java
  23. 136 3
      src/main/java/com/imed/costaccount/service/impl/ReportFormServiceImpl.java
  24. 150 0
      src/main/java/com/imed/costaccount/service/impl/ReportRelationServiceImpl.java
  25. 34 33
      src/main/java/com/imed/costaccount/service/impl/RoleMenuServiceImpl.java
  26. 2 24
      src/main/java/com/imed/costaccount/service/impl/UserRoleServiceImpl.java
  27. 8 4
      src/main/java/com/imed/costaccount/web/CostIncomeGroupController.java
  28. 108 10
      src/main/java/com/imed/costaccount/web/ExcelController.java
  29. 60 12
      src/main/java/com/imed/costaccount/web/ReportFormController.java
  30. 3 5
      src/main/java/com/imed/costaccount/web/RoleController.java
  31. 15 0
      src/main/resources/mapper/CostIncomeGroupMapper.xml
  32. 1 1
      src/main/resources/mapper/RoleMenuMapper.xml

+ 1792 - 0
src/main/java/com/imed/costaccount/common/util/DateUtils.java

@@ -0,0 +1,1792 @@
+package com.imed.costaccount.common.util;
+
+import com.imed.costaccount.enums.DateStyleEnum;
+import com.imed.costaccount.enums.WeekEnum;
+import lombok.extern.slf4j.Slf4j;
+
+import java.sql.Timestamp;
+import java.text.DateFormat;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.*;
+
+@Slf4j
+public class DateUtils {
+    public static final SimpleDateFormat DATE_FORMAT_YYYY_MM_DD_HH_MM_SS = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+    public static final SimpleDateFormat monthSdf = new SimpleDateFormat("yyyy-MM");
+    public static final SimpleDateFormat yearSdf = new SimpleDateFormat("yyyy");
+    public static final SimpleDateFormat DATE_FORMAT_YYYY_MM_DD = new SimpleDateFormat("yyyy-MM-dd");
+
+    /**
+     * 通用的一个DateFormat
+     */
+    public final static SimpleDateFormat commonDateFormat = new SimpleDateFormat("yyyy-MM-dd");
+
+    /**
+     * 处理时分秒的DateFormat
+     */
+    public final static SimpleDateFormat timeFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+
+    /**
+     * 不显示秒的DateFormat
+     */
+    public final static SimpleDateFormat noSecondFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm");
+
+
+    /**
+     * 获取SimpleDateFormat
+     *
+     * @param parttern 日期格式
+     * @return SimpleDateFormat对象
+     * @throws RuntimeException 异常:非法日期格式
+     */
+    private static SimpleDateFormat getDateFormat(String parttern) throws RuntimeException {
+        return new SimpleDateFormat(parttern);
+    }
+
+    /**
+     * 获取日期中的某数值。如获取月份
+     *
+     * @param date     日期
+     * @param dateType 日期格式
+     * @return 数值
+     */
+    public static int getInteger(Date date, int dateType) {
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTime(date);
+        return calendar.get(dateType);
+    }
+
+    /**
+     * 当前时间转换.
+     *
+     * @return 时间字符串
+     */
+    public static String getDateString() {
+        Date date = new Date();
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
+        String strDate = sdf.format(date);
+        return strDate;
+    }
+
+    /**
+     * 获取时间的字符串
+     *
+     * @param date
+     * @param simpleDateFormat
+     * @return 时间字符串
+     */
+    public static String getDateString(Date date, SimpleDateFormat simpleDateFormat) {
+        String strDate = simpleDateFormat.format(date);
+        return strDate;
+    }
+
+    /**
+     * 增加日期中某类型的某数值。如增加日期
+     *
+     * @param date     日期字符串
+     * @param dateType 类型
+     * @param amount   数值
+     * @return 计算后日期字符串
+     */
+    private static String addInteger(String date, int dateType, int amount) {
+        String dateString = null;
+        DateStyleEnum dateStyle = getDateStyle(date);
+        if (dateStyle != null) {
+            Date myDate = StringToDate(date, dateStyle);
+            myDate = addInteger(myDate, dateType, amount);
+            dateString = DateToString(myDate, dateStyle);
+        }
+        return dateString;
+    }
+
+    /**
+     * 增加日期中某类型的某数值。如增加日期
+     *
+     * @param date     日期字符串
+     * @param dateType 类型
+     * @param amount   数值
+     * @return 计算后日期字符串
+     */
+    private static String addInteger(String date, DateStyleEnum dateStyle, int dateType, int amount) {
+        String dateString = null;
+        if (dateStyle != null) {
+            Date myDate = StringToDate(date, dateStyle);
+            myDate = addInteger(myDate, dateType, amount);
+            dateString = DateToString(myDate, dateStyle);
+        }
+        return dateString;
+    }
+
+    /**
+     * 增加日期中某类型的某数值。如增加日期
+     *
+     * @param date     日期
+     * @param dateType 类型
+     * @param amount   数值
+     * @return 计算后日期
+     */
+    private static Date addInteger(Date date, int dateType, int amount) {
+        Date myDate = null;
+        if (date != null) {
+            Calendar calendar = Calendar.getInstance();
+            calendar.setTime(date);
+            calendar.add(dateType, amount);
+            myDate = calendar.getTime();
+        }
+        return myDate;
+    }
+
+    /**
+     * 获取本周开始时间
+     *
+     * @param date
+     *
+     * @return
+     */
+    public static Date getBeginDayOfWeek(Date date) {
+        Calendar cal = Calendar.getInstance();
+        cal.setTime(date);
+        int dayofweek = cal.get(Calendar.DAY_OF_WEEK);
+        if (dayofweek == 1) {
+            dayofweek += 7;
+        }
+        cal.add(Calendar.DATE, 2 - dayofweek);
+        return getDayStartTime(cal.getTime());
+    }
+
+    /**
+     * 获取某个日期的开始时间
+     *
+     * @param date
+     *
+     * @return
+     */
+    public static Timestamp getDayStartTime(Date date) {
+        Calendar calendar = Calendar.getInstance();
+        if (null != date) {
+            calendar.setTime(date);
+        }
+        calendar.set(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.get(Calendar.DAY_OF_MONTH), 0, 0, 0);
+        calendar.set(Calendar.MILLISECOND, 0);
+        return new Timestamp(calendar.getTimeInMillis());
+    }
+
+    /**
+     * 获取本周结束时间
+     *
+     * @param date
+     *
+     * @return
+     */
+    public static Date getEndDayOfWeek(Date date) {
+        Calendar cal = Calendar.getInstance();
+        cal.setTime(getBeginDayOfWeek(date));
+        cal.add(Calendar.DAY_OF_WEEK, 6);
+        Date weekEndSta = cal.getTime();
+        return getDayEndTime(weekEndSta);
+    }
+
+    /**
+     * 获取某个日期的结束时间
+     *
+     * @param date
+     *
+     * @return
+     */
+    private static Date getDayEndTime(Date date) {
+        Calendar calendar = Calendar.getInstance();
+         if(null != date){
+             calendar.setTime(date);
+         }
+         calendar.set(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH),    calendar.get(Calendar.DAY_OF_MONTH), 23, 59, 59);
+         calendar.set(Calendar.MILLISECOND, 999);
+         return new Timestamp(calendar.getTimeInMillis());
+    }
+
+    /**
+     * 获取精确的日期
+     *
+     * @param timestamps 时间long集合
+     * @return 日期
+     */
+    private static Date getAccurateDate(List<Long> timestamps) {
+        Date date = null;
+        long timestamp = 0;
+        Map<Long, long[]> map = new HashMap<Long, long[]>();
+        List<Long> absoluteValues = new ArrayList<Long>();
+        if (timestamps != null && timestamps.size() > 0) {
+            if (timestamps.size() > 1) {
+                for (int i = 0; i < timestamps.size(); i++) {
+                    for (int j = i + 1; j < timestamps.size(); j++) {
+                        long absoluteValue = Math.abs(timestamps.get(i) - timestamps.get(j));
+                        absoluteValues.add(absoluteValue);
+                        long[] timestampTmp = {timestamps.get(i), timestamps.get(j)};
+                        map.put(absoluteValue, timestampTmp);
+                    }
+                }
+                // 有可能有相等的情况。如2012-11和2012-11-01。时间戳是相等的
+                long minAbsoluteValue = -1;
+                if (!absoluteValues.isEmpty()) {
+                    // 如果timestamps的size为2,这是差值只有一个,因此要给默认值
+                    minAbsoluteValue = absoluteValues.get(0);
+                }
+                for (int i = 0; i < absoluteValues.size(); i++) {
+                    for (int j = i + 1; j < absoluteValues.size(); j++) {
+                        if (minAbsoluteValue > absoluteValues.get(j)) {
+                            minAbsoluteValue = absoluteValues.get(j);
+                        }
+                    }
+                }
+                if (minAbsoluteValue != -1) {
+                    long[] timestampsLastTmp = map.get(minAbsoluteValue);
+                    if (absoluteValues.size() > 1) {
+                        timestamp = Math.max(timestampsLastTmp[0], timestampsLastTmp[1]);
+                    } else if (absoluteValues.size() == 1) {
+                        // 当timestamps的size为2,需要与当前时间作为参照
+                        long dateOne = timestampsLastTmp[0];
+                        long dateTwo = timestampsLastTmp[1];
+                        if ((Math.abs(dateOne - dateTwo)) < 100000000000L) {
+                            timestamp = Math.max(timestampsLastTmp[0], timestampsLastTmp[1]);
+                        } else {
+                            long now = new Date().getTime();
+                            if (Math.abs(dateOne - now) <= Math.abs(dateTwo - now)) {
+                                timestamp = dateOne;
+                            } else {
+                                timestamp = dateTwo;
+                            }
+                        }
+                    }
+                }
+            } else {
+                timestamp = timestamps.get(0);
+            }
+        }
+        if (timestamp != 0) {
+            date = new Date(timestamp);
+        }
+        return date;
+    }
+
+    /**
+     * 判断字符串是否为日期字符串
+     *
+     * @param date 日期字符串
+     * @return true or false
+     */
+    public static boolean isDate(String date) {
+        boolean isDate = false;
+        if (date != null) {
+            if (StringToDate(date) != null) {
+                isDate = true;
+            }
+        }
+        return isDate;
+    }
+
+
+    /**
+     * 获取日期字符串的日期风格。失敗返回null。
+     *
+     * @param date 日期字符串
+     * @return 日期风格
+     */
+    public static DateStyleEnum getDateStyle(String date) {
+        DateStyleEnum dateStyle = null;
+        Map<Long, DateStyleEnum> map = new HashMap<Long, DateStyleEnum>();
+        List<Long> timestamps = new ArrayList<Long>();
+        for (DateStyleEnum style : DateStyleEnum.values()) {
+            Date dateTmp = StringToDate(date, style.getValue());
+            if (dateTmp != null) {
+                timestamps.add(dateTmp.getTime());
+                map.put(dateTmp.getTime(), style);
+            }
+        }
+        dateStyle = map.get(getAccurateDate(timestamps).getTime());
+        return dateStyle;
+    }
+
+    /**
+     * 将日期字符串转化为日期。失败返回null。
+     *
+     * @param date 日期字符串
+     * @return 日期
+     */
+    public static Date StringToDate(String date) {
+        DateStyleEnum dateStyle = null;
+        return StringToDate(date, dateStyle);
+    }
+
+    /**
+     * 将日期字符串转化为日期。失败返回null。
+     *
+     * @param date     日期字符串
+     * @param parttern 日期格式
+     * @return 日期
+     */
+    public static Date StringToDate(String date, String parttern) {
+        Date myDate = null;
+        if (date != null) {
+            try {
+                myDate = getDateFormat(parttern).parse(date);
+            } catch (Exception e) {
+            }
+        }
+        return myDate;
+    }
+
+
+    /**
+     * 将日期字符串转化为日期。失败返回null。
+     *
+     * @param date      日期字符串
+     * @param dateStyle 日期风格
+     * @return 日期
+     */
+    public static Date StringToDate(String date, DateStyleEnum dateStyle) {
+        Date myDate = null;
+        if (dateStyle == null) {
+            List<Long> timestamps = new ArrayList<Long>();
+            for (DateStyleEnum style : DateStyleEnum.values()) {
+                Date dateTmp = StringToDate(date, style.getValue());
+                if (dateTmp != null) {
+                    timestamps.add(dateTmp.getTime());
+                }
+            }
+            myDate = getAccurateDate(timestamps);
+        } else {
+            myDate = StringToDate(date, dateStyle.getValue());
+        }
+        return myDate;
+    }
+
+    /**
+     * 将日期转化为日期字符串。失败返回null。
+     *
+     * @param date     日期
+     * @param parttern 日期格式
+     * @return 日期字符串
+     */
+    public static String DateToString(Date date, String parttern) {
+        String dateString = null;
+        if (date != null) {
+            try {
+                dateString = getDateFormat(parttern).format(date);
+            } catch (Exception e) {
+            }
+        }
+        return dateString;
+    }
+
+    /**
+     * 将日期转化为日期字符串。失败返回null。
+     *
+     * @param date      日期
+     * @param dateStyle 日期风格
+     * @return 日期字符串
+     */
+    public static String DateToString(Date date, DateStyleEnum dateStyle) {
+        String dateString = null;
+        if (dateStyle != null) {
+            dateString = DateToString(date, dateStyle.getValue());
+        }
+        return dateString;
+    }
+
+    /**
+     * 将日期字符串转化为另一日期字符串。失败返回null。
+     *
+     * @param date     旧日期字符串
+     * @param parttern 新日期格式
+     * @return 新日期字符串
+     */
+    public static String StringToString(String date, String parttern) {
+        return StringToString(date, null, parttern);
+    }
+
+    /**
+     * 将日期字符串转化为另一日期字符串。失败返回null。
+     *
+     * @param date      旧日期字符串
+     * @param dateStyle 新日期风格
+     * @return 新日期字符串
+     */
+    public static String StringToString(String date, DateStyleEnum dateStyle) {
+        return StringToString(date, null, dateStyle);
+    }
+
+    /**
+     * 将日期字符串转化为另一日期字符串。失败返回null。
+     *
+     * @param date         旧日期字符串
+     * @param olddParttern 旧日期格式
+     * @param newParttern  新日期格式
+     * @return 新日期字符串
+     */
+    public static String StringToString(String date, String olddParttern, String newParttern) {
+        String dateString = null;
+        if (olddParttern == null) {
+            DateStyleEnum style = getDateStyle(date);
+            if (style != null) {
+                Date myDate = StringToDate(date, style.getValue());
+                dateString = DateToString(myDate, newParttern);
+            }
+        } else {
+            Date myDate = StringToDate(date, olddParttern);
+            dateString = DateToString(myDate, newParttern);
+        }
+        return dateString;
+    }
+
+    /**
+     * 将日期字符串转化为另一日期字符串。失败返回null。
+     *
+     * @param date         旧日期字符串
+     * @param olddDteStyle 旧日期风格
+     * @param newDateStyle 新日期风格
+     * @return 新日期字符串
+     */
+    public static String StringToString(String date, DateStyleEnum olddDteStyle, DateStyleEnum newDateStyle) {
+        String dateString = null;
+        if (olddDteStyle == null) {
+            DateStyleEnum style = getDateStyle(date);
+            dateString = StringToString(date, style.getValue(), newDateStyle.getValue());
+        } else {
+            dateString = StringToString(date, olddDteStyle.getValue(), newDateStyle.getValue());
+        }
+        return dateString;
+    }
+
+    /**
+     * 增加日期的年份。失败返回null。
+     *
+     * @param date       日期
+     * @param yearAmount 增加数量。可为负数
+     * @return 增加年份后的日期字符串
+     */
+    public static String addYear(String date, int yearAmount) {
+        return addInteger(date, Calendar.YEAR, yearAmount);
+    }
+
+    /**
+     * 增加日期的年份。失败返回null。
+     *
+     * @param date       日期
+     * @param yearAmount 增加数量。可为负数
+     * @return 增加年份后的日期
+     */
+    public static Date addYear(Date date, int yearAmount) {
+        return addInteger(date, Calendar.YEAR, yearAmount);
+    }
+
+    /**
+     * 增加日期的月份。失败返回null。
+     *
+     * @param date       日期
+     * @param yearAmount 增加数量。可为负数
+     * @return 增加月份后的日期字符串
+     */
+    public static String addMonth(String date, int yearAmount) {
+        return addInteger(date, Calendar.MONTH, yearAmount);
+    }
+
+    /**
+     * 增加日期的月份。失败返回null。
+     *
+     * @param date       日期
+     * @param yearAmount 增加数量。可为负数
+     * @return 增加月份后的日期
+     */
+    public static Date addMonth(Date date, int yearAmount) {
+        return addInteger(date, Calendar.MONTH, yearAmount);
+    }
+
+    /**
+     * 增加日期的天数。失败返回null。
+     *
+     * @param date      日期字符串
+     * @param dayAmount 增加数量。可为负数
+     * @return 增加天数后的日期字符串
+     * @deprecated use {@link #addDay(String, int, DateStyleEnum)}
+     */
+    @Deprecated
+    public static String addDay(String date, int dayAmount) {
+        return addInteger(date, Calendar.DATE, dayAmount);
+    }
+
+    /**
+     * 增加日期的天数。失败返回null。
+     *
+     * @param date      日期字符串
+     * @param dayAmount 增加数量。可为负数
+     * @param style     日期样式
+     * @return 增加天数后的日期字符串
+     */
+    public static String addDay(String date, int dayAmount, DateStyleEnum style) {
+        return addInteger(date, style, Calendar.DATE, dayAmount);
+    }
+
+    /**
+     * 增加日期的天数。失败返回null。
+     *
+     * @param date      日期
+     * @param dayAmount 增加数量。可为负数
+     * @return 增加天数后的日期
+     */
+    public static Date addDay(Date date, int dayAmount) {
+        return addInteger(date, Calendar.DATE, dayAmount);
+    }
+
+    /**
+     * 增加日期的小时。失败返回null。
+     *
+     * @param date       日期字符串
+     * @param hourAmount 增加数量。可为负数
+     * @return 增加小时后的日期字符串
+     */
+    public static String addHour(String date, int hourAmount) {
+        return addInteger(date, Calendar.HOUR_OF_DAY, hourAmount);
+    }
+
+    /**
+     * 增加日期的小时。失败返回null。
+     *
+     * @param date       日期
+     * @param hourAmount 增加数量。可为负数
+     * @return 增加小时后的日期
+     */
+    public static Date addHour(Date date, int hourAmount) {
+        return addInteger(date, Calendar.HOUR_OF_DAY, hourAmount);
+    }
+
+    /**
+     * 增加日期的分钟。失败返回null。
+     *
+     * @param date       日期字符串
+     * @param hourAmount 增加数量。可为负数
+     * @return 增加分钟后的日期字符串
+     */
+    public static String addMinute(String date, int hourAmount) {
+        return addInteger(date, Calendar.MINUTE, hourAmount);
+    }
+
+    /**
+     * 增加日期的分钟。失败返回null。
+     *
+     * @param date       日期
+     * @param hourAmount 增加数量。可为负数
+     * @return 增加分钟后的日期
+     */
+    public static Date addMinute(Date date, int hourAmount) {
+        return addInteger(date, Calendar.MINUTE, hourAmount);
+    }
+
+    /**
+     * 增加日期的秒钟。失败返回null。
+     *
+     * @param date       日期字符串
+     * @param hourAmount 增加数量。可为负数
+     * @return 增加秒钟后的日期字符串
+     */
+    public static String addSecond(String date, int hourAmount) {
+        return addInteger(date, Calendar.SECOND, hourAmount);
+    }
+
+    /**
+     * 增加日期的秒钟。失败返回null。
+     *
+     * @param date       日期
+     * @param hourAmount 增加数量。可为负数
+     * @return 增加秒钟后的日期
+     */
+    public static Date addSecond(Date date, int hourAmount) {
+        return addInteger(date, Calendar.SECOND, hourAmount);
+    }
+
+    /**
+     * 获取日期的年份。失败返回0。
+     *
+     * @param date 日期字符串
+     * @return 年份
+     */
+    public static int getYear(String date) {
+        return getYear(StringToDate(date));
+    }
+
+    /**
+     * 获取日期的年份。失败返回0。
+     *
+     * @param date 日期
+     * @return 年份
+     */
+    public static int getYear(Date date) {
+        return getInteger(date, Calendar.YEAR);
+    }
+
+    /**
+     * 获取日期的月份。失败返回0。
+     *
+     * @param date 日期字符串
+     * @return 月份
+     */
+    public static int getMonth(String date) {
+        return getMonth(StringToDate(date));
+    }
+
+    /**
+     * 获取日期的月份
+     *
+     * @param date 日期字符串
+     * @return 月份
+     */
+    public static String getMonthStr(Date date) {
+        return monthSdf.format(date);
+    }
+
+    /**
+     * 获取日期的月份。失败返回0。
+     *
+     * @param date 日期
+     * @return 月份
+     */
+    public static int getMonth(Date date) {
+        return getInteger(date, Calendar.MONTH);
+    }
+
+    /**
+     * 获取日期的天数。失败返回0。
+     *
+     * @param date 日期字符串
+     * @return 天
+     */
+    public static int getDay(String date) {
+        return getDay(StringToDate(date));
+    }
+
+    /**
+     * 获取日期的天数。失败返回0。
+     *
+     * @param date 日期
+     * @return 天
+     */
+    public static int getDay(Date date) {
+        return getInteger(date, Calendar.DATE);
+    }
+
+    /**
+     * 获取日期的小时。失败返回0。
+     *
+     * @param date 日期字符串
+     * @return 小时
+     */
+    public static int getHour(String date) {
+        return getHour(StringToDate(date));
+    }
+
+    /**
+     * 获取日期的小时。失败返回0。
+     *
+     * @param date 日期
+     * @return 小时
+     */
+    public static int getHour(Date date) {
+        return getInteger(date, Calendar.HOUR_OF_DAY);
+    }
+
+    /**
+     * 获取日期的分钟。失败返回0。
+     *
+     * @param date 日期字符串
+     * @return 分钟
+     */
+    public static int getMinute(String date) {
+        return getMinute(StringToDate(date));
+    }
+
+    /**
+     * 获取日期的分钟。失败返回0。
+     *
+     * @param date 日期
+     * @return 分钟
+     */
+    public static int getMinute(Date date) {
+        return getInteger(date, Calendar.MINUTE);
+    }
+
+    /**
+     * 获取日期的秒钟。失败返回0。
+     *
+     * @param date 日期字符串
+     * @return 秒钟
+     */
+    public static int getSecond(String date) {
+        return getSecond(StringToDate(date));
+    }
+
+    /**
+     * 获取日期的秒钟。失败返回0。
+     *
+     * @param date 日期
+     * @return 秒钟
+     */
+    public static int getSecond(Date date) {
+        return getInteger(date, Calendar.SECOND);
+    }
+
+    /**
+     * 获取日期 。默认yyyy-MM-dd格式。失败返回null。
+     *
+     * @param date 日期字符串
+     * @return 日期
+     */
+    public static String getDate(String date) {
+        return StringToString(date, DateStyleEnum.YYYY_MM_DD);
+    }
+
+    /**
+     * 获取日期。默认yyyy-MM-dd格式。失败返回null。
+     *
+     * @param date 日期
+     * @return 日期
+     */
+    public static String getDate(Date date) {
+        return DateToString(date, DateStyleEnum.YYYY_MM_DD);
+    }
+
+    /**
+     * 获取日期。默认yyyy-MM-dd HH:mm:ss格式。失败返回null。
+     *
+     * @param date 日期
+     * @return 日期
+     */
+    public static String getDateTime(Date date) {
+        return DateToString(date, DateStyleEnum.YYYY_MM_DD_HH_MM_SS);
+    }
+
+    /**
+     * 获取日期。默认yyyy-MM-dd HH:mm格式。失败返回null。
+     *
+     * @param date 日期
+     * @return 日期
+     */
+    public static String getDateTimeExcludeSec(Date date) {
+        return DateToString(date, DateStyleEnum.YYYY_MM_DD_HH_MM);
+    }
+
+    /**
+     * 获取日期。默认yyyy-MM-dd HH:mm格式。失败返回null。
+     *
+     * @param date 日期
+     * @return 日期
+     */
+    public static Date getDateTimeExcludeSec(String date) {
+        return StringToDate(date, DateStyleEnum.YYYY_MM_DD_HH_MM);
+    }
+
+    /**
+     * 获取日期的时间。默认HH:mm:ss格式。失败返回null。
+     *
+     * @param date 日期字符串
+     * @return 时间
+     */
+    public static String getTime(String date) {
+        return StringToString(date, DateStyleEnum.HH_MM_SS);
+    }
+
+    /**
+     * 获取日期的时间。默认HH:mm:ss格式。失败返回null。
+     *
+     * @param date 日期
+     * @return 时间
+     */
+    public static String getTime(Date date) {
+        return DateToString(date, DateStyleEnum.HH_MM_SS);
+    }
+
+    /**
+     * 获取日期的星期。失败返回null。
+     *
+     * @param date 日期字符串
+     * @return 星期
+     */
+    public static WeekEnum getWeek(String date) {
+        WeekEnum week = null;
+        DateStyleEnum dateStyle = getDateStyle(date);
+        if (dateStyle != null) {
+            Date myDate = StringToDate(date, dateStyle);
+            week = getWeek(myDate);
+        }
+        return week;
+    }
+
+    /**
+     * 获取日期的星期。失败返回null。
+     *
+     * @param date 日期
+     * @return 星期
+     */
+    public static WeekEnum getWeek(Date date) {
+        WeekEnum week = null;
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTime(date);
+        int weekNumber = calendar.get(Calendar.DAY_OF_WEEK) - 1;
+        switch (weekNumber) {
+            case 0:
+                week = WeekEnum.SUNDAY;
+                break;
+            case 1:
+                week = WeekEnum.MONDAY;
+                break;
+            case 2:
+                week = WeekEnum.TUESDAY;
+                break;
+            case 3:
+                week = WeekEnum.WEDNESDAY;
+                break;
+            case 4:
+                week = WeekEnum.THURSDAY;
+                break;
+            case 5:
+                week = WeekEnum.FRIDAY;
+                break;
+            case 6:
+                week = WeekEnum.SATURDAY;
+                break;
+        }
+        return week;
+    }
+
+    /**
+     * 获取两个日期相差的天数
+     *
+     * @param date      日期字符串
+     * @param otherDate 另一个日期字符串
+     * @return 相差天数
+     */
+    public static int getIntervalDays(String date, String otherDate) {
+        return getIntervalDays(StringToDate(date), StringToDate(otherDate));
+    }
+
+    /**
+     * @param date      日期
+     * @param otherDate 另一个日期mingt
+     * @return 相差天数
+     */
+    public static int getIntervalDays(Date date, Date otherDate) {
+        //date = DateUtil.StringToDate(DateUtil.getDate(date));
+        long time = Math.abs(date.getTime() - otherDate.getTime());
+        long day = time / (24 * 60 * 60 * 1000);
+        return (int) day;
+    }
+
+
+    /**
+     * @param date
+     * @param otherDate
+     * @return 相差年数
+     */
+    public static long getIntervalYear(Date date, Date otherDate) {
+        Calendar cal = Calendar.getInstance();
+        int yearNow = cal.get(Calendar.YEAR);
+        cal.setTime(otherDate);
+        int yearOther = cal.get(Calendar.YEAR);
+        long year = yearNow - yearOther;
+        return year;
+    }
+
+    /**
+     * 获取月份差
+     *
+     * @param date
+     * @param otherDate
+     * @return
+     */
+    public static long getIntervalMonths(Date date, Date otherDate) {
+        long months;
+        Calendar cal = Calendar.getInstance();
+        int yearNow = cal.get(Calendar.YEAR);
+        int monthNow = cal.get(Calendar.MONTH);
+        cal.setTime(otherDate);
+        int yearOther = cal.get(Calendar.YEAR);
+        int monthOther = cal.get(Calendar.MONTH);
+        long year = yearNow - yearOther;
+        if (year >= 1) {
+            months = year * 12 + monthNow - monthOther;
+        } else {
+            months = monthNow - monthOther;
+        }
+
+
+        return months;
+    }
+
+    public static String getWeekFromDate(Date date) {
+        Calendar c = Calendar.getInstance();
+        c.setTime(date);
+        int week = c.get(Calendar.DAY_OF_WEEK);
+        switch (week) {
+            case 1:
+                return "星期日";
+            case 2:
+                return "星期一";
+            case 3:
+                return "星期二";
+            case 4:
+                return "星期三";
+            case 5:
+                return "星期四";
+            case 6:
+                return "星期五";
+            case 7:
+                return "星期六";
+            default:
+                return "";
+        }
+    }
+
+    /**
+     * 获取指定天数之前的时间(相对于当前天数)
+     *
+     * @param currentDate 当前时间
+     * @param dayNo       当前时间的几天之前
+     * @return
+     * @Title: getLastDays
+     * @date 2014-3-26 下午11:23:57
+     * @author Lawrence
+     */
+    public static Date getLastTimeForDays(Date currentDate, Integer dayNo) {
+        if (null == currentDate || null == dayNo) {
+            return null;
+        }
+        Calendar c = Calendar.getInstance();
+        c.setTime(currentDate);
+        c.add(Calendar.DATE, -dayNo);
+        return c.getTime();
+    }
+
+    /**
+     * 获取指定月数之前的时间(相对于当前天数)
+     *
+     * @param currentDate 当前时间
+     * @param monthNo     当前时间的几月之前
+     * @return
+     * @Title: getLastDays
+     * @date 2014-3-26 下午11:23:57
+     * @author Lawrence
+     */
+    public static Date getLastTimeForMonths(Date currentDate, Integer monthNo) {
+        if (null == currentDate || null == monthNo) {
+            return null;
+        }
+        Calendar c = Calendar.getInstance();
+        c.setTime(currentDate);
+        c.add(Calendar.MONTH, -monthNo);
+        return c.getTime();
+    }
+
+    /**
+     * 获取指定月数之前的时间(相对于当前天数)
+     *
+     * @param currentDate 当前时间
+     * @param yearNo      当前时间的几年之前
+     * @return
+     * @Title: getLastDays
+     * @date 2014-3-26 下午11:23:57
+     * @author Lawrence
+     */
+    public static Date getLastTimeForYears(Date currentDate, Integer yearNo) {
+        Calendar c = Calendar.getInstance();
+        c.setTime(currentDate);
+        c.add(Calendar.YEAR, -yearNo);
+        return c.getTime();
+    }
+
+
+    /**
+     * 获取当天00:00:00
+     *
+     * @param currentDate
+     * @return
+     * @Title: getZeroPoint
+     * @Description: (这里用一句话描述这个方法的作用)
+     * @date 2014年10月10日 上午11:09:35
+     * @author Administrator
+     */
+    public static Date getZeroPoint(Date currentDate) {
+        Calendar cal = Calendar.getInstance();
+        cal.setTime(currentDate);
+        cal.set(Calendar.HOUR_OF_DAY, 0); // 把当前时间小时变成0
+        cal.set(Calendar.MINUTE, 0); // 把当前时间分钟变成0
+        cal.set(Calendar.SECOND, 0); // 把当前时间秒数变成0
+        cal.set(Calendar.MILLISECOND, 0); // 把当前时间毫秒变成0
+        return cal.getTime();
+    }
+
+    /**
+     * 获取当天00:00:00
+     *
+     * @param currentDate
+     * @return
+     * @Title: getZeroPoint
+     * @Description: (这里用一句话描述这个方法的作用)
+     * @date 2014年10月10日 上午11:09:35
+     * @author Administrator
+     */
+    public static Date getZeroPoint(String currentDate) {
+        return getZeroPoint(DateUtils.StringToDate(currentDate, DateStyleEnum.YYYY_MM_DD));
+    }
+
+    /**
+     * 获取日期的最后一秒时间
+     *
+     * @param currentDate
+     * @return
+     */
+    public static Date getLastPoint(String currentDate) {
+        return getLastPoint(DateUtils.StringToDate(currentDate, DateStyleEnum.YYYY_MM_DD));
+    }
+
+    /**
+     * 获取日期的最后一秒时间
+     *
+     * @param currentDate
+     * @return
+     */
+    public static Date getLastPoint(Date currentDate) {
+        Calendar cal = Calendar.getInstance();
+        cal.setTime(currentDate);
+        cal.set(Calendar.HOUR_OF_DAY, 23); // 把当前时间小时变成
+        cal.set(Calendar.MINUTE, 59); // 把当前时间分钟变成
+        cal.set(Calendar.SECOND, 59); // 把当前时间秒数变成
+        return cal.getTime();
+    }
+
+
+    /**
+     * 获取指定分钟最后一秒时间
+     *
+     * @param currentDate
+     * @return
+     */
+    public static Date getDateEndTime(Date currentDate) {
+        Calendar cal = Calendar.getInstance();
+        cal.setTime(currentDate);
+        cal.set(Calendar.SECOND, 59); // 把当前时间秒数变成
+        return cal.getTime();
+    }
+
+    /**
+     * 获取指定分钟最后一秒时间
+     *
+     * @param currentDate
+     * @return
+     */
+    public static Date getDateBegTime(Date currentDate) {
+        Calendar cal = Calendar.getInstance();
+        cal.setTime(currentDate);
+        cal.set(Calendar.SECOND, 00); // 把当前时间秒数变成
+        return cal.getTime();
+    }
+
+    /**
+     * 时间比较大小工具类
+     *
+     * @param date1
+     * @param date2
+     * @return
+     */
+    public static Boolean compareDate(Date date1, Date date2) {
+        try {
+            if (date1.getTime() >= date2.getTime()) {
+                return true;
+            } else if (date1.getTime() < date2.getTime()) {
+                return false;
+            }
+        } catch (Exception e) {
+            log.error(e.toString(), e);
+        }
+        return false;
+    }
+
+    /**
+     * 把毫秒转化成日期
+     *
+     * @param millSec(毫秒数)
+     * @return
+     */
+    public static Date LongToDate(Long millSec) {
+        return LongToDate(millSec, "yyyy-MM-dd HH:mm:ss");
+    }
+
+    /**
+     * 把毫秒转化成日期
+     *
+     * @param parttern(日期格式,例如:MM/ dd/yyyy HH:mm:ss)
+     * @param millSec(毫秒数)
+     * @return
+     */
+    public static Date LongToDate(Long millSec, String parttern) {
+        return new Date(millSec);
+    }
+
+/*    public static void main(String[] args){
+//    	Long currentTime = System.currentTimeMillis();
+//    	System.out.println(LongToDate(currentTime));
+    	
+        // Date currentDate = new Date();
+        // currentDate = getZeroPoint(currentDate);
+        // //得到一天前
+        // Date dd = getLastTimeForDays(currentDate, 1);
+        // System.out.println(dd.toLocaleString());
+        // //得到前一周
+        // Date dw = getLastTimeForDays(currentDate, 7);
+        // System.out.println(dw.toLocaleString());
+        // //得到前一个月
+        // Date dm = getLastTimeForMonths(currentDate, 1);
+        // System.out.println(dm.toLocaleString());
+        // //得到前一年
+        // Date dy = getLastTimeForYears(currentDate, 1);
+        // System.out.println(dy.toLocaleString());
+        String date = DateToString(new Date(), "yyyyMMddHHmmss");
+        System.out.println(date);
+        System.out.println(getZeroPoint(new Date()));
+    }*/
+
+    /**
+     * 截取时间getTime的后N位
+     *
+     * @param time 时间
+     * @return
+     * @Title: getTimeToSix
+     * @date 2016年9月21日 下午5:14:00
+     * @author Chris_He
+     */
+    public static String getTimeToNumber(Date time, Integer n) {
+        String s = String.valueOf(time.getTime());
+        return s.substring(s.length() - n, s.length());
+    }
+
+    /**
+     * 获取当前时间上下午
+     *
+     * @return
+     * @Title: getNowDateAmPm
+     * @date 2017年8月29日 下午5:08:37
+     * @author Chris_He
+     */
+    public static DateStyleEnum getNowDateAmPm() {
+        GregorianCalendar ca = new GregorianCalendar();
+        int i = ca.get(GregorianCalendar.AM_PM);
+        if (i == 0) {
+            return DateStyleEnum.AM;
+        } else {
+            return DateStyleEnum.PM;
+        }
+    }
+
+    public static Date getAfterMinuteDate(Date date, int amount) {
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        Calendar cal = Calendar.getInstance();
+        cal.setTime(date);
+        cal.add(Calendar.MINUTE, amount);
+        date = cal.getTime();
+//        String theDate = sdf.format(date);
+        return date;
+    }
+
+    public static Date getAfterSecondDate(Date date, int amount) {
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        Calendar cal = Calendar.getInstance();
+        cal.setTime(date);
+        cal.add(Calendar.SECOND, amount);
+        date = cal.getTime();
+//        String theDate = sdf.format(date);
+        return date;
+    }
+
+    public static String formatFull(Date date) {
+        if (date != null) {
+            return DATE_FORMAT_YYYY_MM_DD_HH_MM_SS.format(date);
+        }
+        return null;
+    }
+
+    /**
+     * 获取下一天00:00:00
+     *
+     * @return
+     * @Title: getNextDay
+     * @date 2018年12月22日 下午5:08:37
+     * @author Chris_He
+     */
+    public static Date getNextDay(Date date) {
+        return addDay(StringToDate(DateToString(date, DateStyleEnum.YYYY_MM_DD), DateStyleEnum.YYYY_MM_DD), 1);
+    }
+
+    public static void main(String[] args) {
+//        System.out.println(DateUtil.getYear(new Date()));
+        System.out.println(getHour("7:00"));
+    }
+
+
+    /**
+     * 获取下一天指定时间
+     *
+     * @return
+     * @Title: getNextDay
+     * @date 2018年12月22日 下午5:08:37
+     * @author Chris_He
+     */
+    public static Date getNextDayHour(Date date, int hour, int amount) {
+        Date myDate = null;
+        if (date != null) {
+            Calendar calendar = Calendar.getInstance();
+            calendar.setTime(date);
+            calendar.add(Calendar.DATE, amount);
+            calendar.set(Calendar.HOUR_OF_DAY, hour); // 把当前时间小时变成0
+            calendar.set(Calendar.MINUTE, 0); // 把当前时间分钟变成0
+            calendar.set(Calendar.SECOND, 0); // 把当前时间秒数变成0
+            calendar.set(Calendar.MILLISECOND, 0); // 把当前时间毫秒变成0
+            myDate = calendar.getTime();
+        }
+        return myDate;
+    }
+
+    /**
+     * 获取yyyy-MM
+     *
+     * @return
+     */
+    public static String getMonthStr() {
+        return monthSdf.format(new Date());
+    }
+
+    /**
+     * 获取时间范围内所有天数 yyyy-MM-dd
+     *
+     * @param startDate
+     * @param endDate
+     * @return
+     */
+    public static List<Date> getDayList(String startDate, String endDate) {
+        Date dBegin = getZeroPoint(startDate);
+        Date dEnd = getZeroPoint(endDate);
+        List<Date> dateList = new ArrayList<>();
+        Calendar calBegin = Calendar.getInstance();
+        // 使用给定的 Date 设置此 Calendar 的时间
+        calBegin.setTime(dBegin);
+        Calendar calEnd = Calendar.getInstance();
+        // 使用给定的 Date 设置此 Calendar 的时间
+        calEnd.setTime(dEnd);
+        // 此日期是否在指定日期之后
+        dateList.add(dBegin);
+        while (dEnd.after(calBegin.getTime())) {
+            // 根据日历的规则,为给定的日历字段添加或减去指定的时间量
+            calBegin.add(Calendar.DAY_OF_MONTH, 1);
+            dateList.add(calBegin.getTime());
+        }
+        return dateList;
+    }
+
+    /**
+     * 获取时间范围内所有天 yyyy-MM-dd
+     *
+     * @param startDate
+     * @param endDate
+     * @return
+     */
+    public static List<Date> getDayList(Date startDate, Date endDate) {
+        Date dBegin = getZeroPoint(startDate);
+        Date dEnd = getZeroPoint(endDate);
+        List<Date> dateList = new ArrayList<>();
+        Calendar calBegin = Calendar.getInstance();
+        // 使用给定的 Date 设置此 Calendar 的时间
+        calBegin.setTime(dBegin);
+        Calendar calEnd = Calendar.getInstance();
+        // 使用给定的 Date 设置此 Calendar 的时间
+        calEnd.setTime(dEnd);
+        // 此日期是否在指定日期之后
+        dateList.add(dBegin);
+        while (dEnd.after(calBegin.getTime())) {
+            // 根据日历的规则,为给定的日历字段添加或减去指定的时间量
+            calBegin.add(Calendar.DAY_OF_MONTH, 1);
+            dateList.add(calBegin.getTime());
+        }
+        return dateList;
+    }
+
+    /**
+     * 获取时间范围内所有天 yyyy-MM-dd
+     *
+     * @param startDate
+     * @param endDate
+     * @return
+     */
+    public static List<String> getDayStrList(Date startDate, Date endDate) {
+        Date dBegin = getZeroPoint(startDate);
+        Date dEnd = getZeroPoint(endDate);
+        List<String> dateList = new ArrayList<>();
+        Calendar calBegin = Calendar.getInstance();
+        // 使用给定的 Date 设置此 Calendar 的时间
+        calBegin.setTime(dBegin);
+        Calendar calEnd = Calendar.getInstance();
+        // 使用给定的 Date 设置此 Calendar 的时间
+        calEnd.setTime(dEnd);
+        // 此日期是否在指定日期之后
+        dateList.add(getDate(dBegin));
+        while (dEnd.after(calBegin.getTime())) {
+            // 根据日历的规则,为给定的日历字段添加或减去指定的时间量
+            calBegin.add(Calendar.DAY_OF_MONTH, 1);
+            dateList.add(getDate(calBegin.getTime()));
+        }
+        return dateList;
+    }
+
+    /**
+     * 获取某个时间段内所有月份
+     *
+     * @param startDate
+     * @param endDate
+     * @return
+     */
+    public static List<Date> getMonthList(String startDate, String endDate) {
+        List<Date> result = new ArrayList<>();
+        Calendar min = Calendar.getInstance();
+        Calendar max = Calendar.getInstance();
+        min.setTime(StringToDate(startDate, DateStyleEnum.YYYY_MM));
+        min.set(min.get(Calendar.YEAR), min.get(Calendar.MONTH), 1);
+        max.setTime(StringToDate(endDate, DateStyleEnum.YYYY_MM));
+        max.set(max.get(Calendar.YEAR), max.get(Calendar.MONTH), 2);
+        Calendar curr = min;
+        while (curr.before(max)) {
+            result.add(curr.getTime());
+            curr.add(Calendar.MONTH, 1);
+        }
+        return result;
+    }
+
+    /**
+     * 1 第一季度 2 第二季度 3 第三季度 4 第四季度
+     *
+     * @param date
+     * @return
+     */
+    public static int getSeason(Date date) {
+
+        int season = 0;
+
+        Calendar c = Calendar.getInstance();
+        c.setTime(date);
+        int month = c.get(Calendar.MONTH);
+        switch (month) {
+            case Calendar.JANUARY:
+            case Calendar.FEBRUARY:
+            case Calendar.MARCH:
+                season = 1;
+                break;
+            case Calendar.APRIL:
+            case Calendar.MAY:
+            case Calendar.JUNE:
+                season = 2;
+                break;
+            case Calendar.JULY:
+            case Calendar.AUGUST:
+            case Calendar.SEPTEMBER:
+                season = 3;
+                break;
+            case Calendar.OCTOBER:
+            case Calendar.NOVEMBER:
+            case Calendar.DECEMBER:
+                season = 4;
+                break;
+            default:
+                break;
+        }
+        return season;
+    }
+
+    /**
+     * 取得季度月
+     *
+     * @param date
+     * @return
+     */
+    public static Date[] getSeasonDate(Date date) {
+        Date[] season = new Date[3];
+
+        Calendar c = Calendar.getInstance();
+        c.setTime(date);
+
+        int nSeason = getSeason(date);
+        if (nSeason == 1) {// 第一季度
+            c.set(Calendar.MONTH, Calendar.JANUARY);
+            season[0] = c.getTime();
+            c.set(Calendar.MONTH, Calendar.FEBRUARY);
+            season[1] = c.getTime();
+            c.set(Calendar.MONTH, Calendar.MARCH);
+            season[2] = c.getTime();
+        } else if (nSeason == 2) {// 第二季度
+            c.set(Calendar.MONTH, Calendar.APRIL);
+            season[0] = c.getTime();
+            c.set(Calendar.MONTH, Calendar.MAY);
+            season[1] = c.getTime();
+            c.set(Calendar.MONTH, Calendar.JUNE);
+            season[2] = c.getTime();
+        } else if (nSeason == 3) {// 第三季度
+            c.set(Calendar.MONTH, Calendar.JULY);
+            season[0] = c.getTime();
+            c.set(Calendar.MONTH, Calendar.AUGUST);
+            season[1] = c.getTime();
+            c.set(Calendar.MONTH, Calendar.SEPTEMBER);
+            season[2] = c.getTime();
+        } else if (nSeason == 4) {// 第四季度
+            c.set(Calendar.MONTH, Calendar.OCTOBER);
+            season[0] = c.getTime();
+            c.set(Calendar.MONTH, Calendar.NOVEMBER);
+            season[1] = c.getTime();
+            c.set(Calendar.MONTH, Calendar.DECEMBER);
+            season[2] = c.getTime();
+        }
+        return season;
+    }
+
+    /**
+     * 取得季度第一天
+     *
+     * @param date
+     * @return
+     */
+    public static Date getFirstDateOfSeason(Date date) {
+        return getFirstDateOfMonth(getSeasonDate(date)[0]);
+    }
+
+    /**
+     * 取得季度最后一天
+     *
+     * @param date
+     * @return
+     */
+    public static Date getLastDateOfSeason(Date date) {
+        return getLastDateOfMonth(getSeasonDate(date)[2]);
+    }
+
+    /**
+     * 取得月第一天
+     *
+     * @param date
+     * @return
+     */
+    public static Date getFirstDateOfMonth(Date date) {
+        Calendar c = Calendar.getInstance();
+        c.setTime(date);
+        c.set(Calendar.DAY_OF_MONTH, c.getActualMinimum(Calendar.DAY_OF_MONTH));
+        return c.getTime();
+    }
+
+    /**
+     * 取得月最后一天
+     *
+     * @param date
+     * @return
+     */
+    public static Date getLastDateOfMonth(Date date) {
+        Calendar c = Calendar.getInstance();
+        c.setTime(date);
+        c.set(Calendar.DAY_OF_MONTH, c.getActualMaximum(Calendar.DAY_OF_MONTH));
+        return c.getTime();
+    }
+
+    /**
+     * 时间范围内的每个季度开始时间
+     *
+     * @param startDate
+     * @param endDate
+     * @return
+     */
+    public static List<Date> getSeasonDateList(Date startDate, Date endDate) {
+        List<Date> list = new ArrayList<>();
+        Date firstDateOfSeason = getFirstDateOfSeason(startDate);
+        list.add(firstDateOfSeason);
+        Date lastDateOfSeason = getFirstDateOfSeason(endDate);
+        Calendar c = Calendar.getInstance();
+        c.setTime(firstDateOfSeason);
+        while (c.getTime().before(lastDateOfSeason)) {
+            c.add(Calendar.MONTH, 3);
+            list.add(c.getTime());
+        }
+        return list;
+    }
+
+    /**
+     * 获取所在年第一天
+     *
+     * @param date
+     * @return
+     */
+    public static Date getFirstDayOfYear(Date date) {
+        final Calendar cal = Calendar.getInstance();
+        cal.setTime(date);
+        cal.set(Calendar.DAY_OF_YEAR, cal.getActualMinimum(Calendar.DAY_OF_YEAR));
+        return cal.getTime();
+    }
+
+    /**
+     * 获取所在年第一天
+     *
+     * @param
+     * @return
+     */
+    public static Date getFirstDayOfYear(String year) {
+        final Calendar cal = Calendar.getInstance();
+        cal.setTime(StringToDate(year, DateStyleEnum.YYYY));
+        cal.set(Calendar.DAY_OF_YEAR, cal.getActualMinimum(Calendar.DAY_OF_YEAR));
+        return cal.getTime();
+    }
+
+    /**
+     * 获取所在年最后一天
+     *
+     * @param date
+     * @return
+     */
+    public static Date getLastDayOfYear(Date date) {
+        final Calendar cal = Calendar.getInstance();
+        cal.setTime(date);
+        cal.set(Calendar.DAY_OF_YEAR, cal.getActualMaximum(Calendar.DAY_OF_YEAR));
+        return cal.getTime();
+    }
+
+    /**
+     * 获取所在年最后一天
+     *
+     * @param year
+     * @return
+     */
+    public static Date getLastDayOfYear(String year) {
+        final Calendar cal = Calendar.getInstance();
+        cal.setTime(StringToDate(year, DateStyleEnum.YYYY));
+        cal.set(Calendar.DAY_OF_YEAR, cal.getActualMaximum(Calendar.DAY_OF_YEAR));
+        return cal.getTime();
+    }
+
+    /**
+     * 时间范围内的每个年开始时间列表
+     *
+     * @param startDate
+     * @param endDate
+     * @return
+     */
+    public static List<Date> getYearDateList(Date startDate, Date endDate) {
+        List<Date> list = new ArrayList<>();
+        Date firstDate = getFirstDayOfYear(startDate);
+        list.add(firstDate);
+        Date lastDate = getFirstDayOfYear(endDate);
+        Calendar c = Calendar.getInstance();
+        c.setTime(firstDate);
+        while (c.getTime().before(lastDate)) {
+            c.add(Calendar.YEAR, 1);
+            list.add(c.getTime());
+        }
+        return list;
+    }
+
+
+    public static String getChineseDate(Date date) {
+        String chineseDate = null;
+        SimpleDateFormat sdf = new SimpleDateFormat("YYYY-MM-DD");
+
+
+        return chineseDate;
+    }
+
+    public static StringBuilder getChineseTime(Date date) {
+        String sign;
+        StringBuilder chineseTime = new StringBuilder();
+        SimpleDateFormat sdf = new SimpleDateFormat("HH:mm");
+        String time = sdf.format(date);
+
+        String[] split = time.split(":");
+
+
+        if(split[0].equals("00")){
+            chineseTime.append("零时");
+        }else{
+            String s = formatDigit(split[0]);
+            String substring1 = s.substring(0, 1);
+            String substring2 = s.substring(1, 2);
+            if(substring1.equals("零")){
+
+            }else if(substring1.equals("一")){
+                chineseTime.append("十");
+            }else{
+                chineseTime.append(substring1).append("十");
+            }
+
+            if(!substring2.equals("零")){
+                chineseTime.append(substring2);
+            }
+
+
+            chineseTime.append("时");
+
+        }
+
+        if(split[1].equals("00")){
+            chineseTime.append("整");
+        }else {
+
+            String s = formatDigit(split[1]);
+
+            String substring1 = s.substring(0, 1);
+            String substring2 = s.substring(1, 2);
+
+            if(substring1.equals("零")){
+
+            }else if(substring1.equals("一")){
+                chineseTime.append("十");
+            }else{
+                chineseTime.append(substring1).append("十");
+            }
+
+            if(!substring2.equals("零")){
+                chineseTime.append(substring2);
+            }
+
+
+
+            chineseTime.append("分");
+        }
+//
+
+        return chineseTime;
+    }
+
+
+    private static String formatDigit(String sign) {
+        StringBuilder sb = new StringBuilder();
+        for(int i=0;i<sign.length();i++){
+            String substring = sign.substring(i, i + 1);
+            switch (substring){
+                case "0":
+                    sb.append("零");
+                    break;
+                case "1":
+                    sb.append("一");
+                    break;
+                case "2":
+                    sb.append("二");
+                    break;
+                case "3":
+                    sb.append("三");
+                    break;
+                case "4":
+                    sb.append("四");
+                    break;
+                case "5":
+                    sb.append("五");
+                    break;
+                case "6":
+                    sb.append("六");
+                    break;
+                case "7":
+                    sb.append("七");
+                    break;
+                case "8":
+                    sb.append("八");
+                    break;
+                case "9":
+                    sb.append("九");
+                    break;
+            }
+
+
+        }
+
+        sign = sb.toString();
+
+
+        return sign;
+    }
+
+    /**
+     * 取出当前日期到指定日期的周数据差值
+     *
+     * @param date      指日 定日期
+     * @param otherDate 当前日期
+     * @return 周数差
+     */
+    public static long intervalWeeks(Date date, Date otherDate) {
+        int intervalDays = getIntervalDays(date, otherDate) + 1;
+        int i = intervalDays % 7;
+        long weekNum = Math.abs((date.getTime() - otherDate.getTime()) / (7 * 60 * 60 * 24 * 1000));
+
+        weekNum += 1;
+
+        return weekNum;
+
+
+    }
+
+    public static long intervalWeeks(String date, String otherDate) {
+        Date date1 = DateUtils.StringToDate(date, DateStyleEnum.YYYY_MM_DD);
+        Date date2 = DateUtils.StringToDate(otherDate, DateStyleEnum.YYYY_MM_DD);
+
+
+        return intervalWeeks(date1, date2);
+
+
+    }
+
+    /**
+     * 获取两个时间相差多少小时多少分钟
+     *
+     * @param startTime
+     * @param endTime
+     * @return
+     */
+    public static String getDistanceHourMin(Date startTime, Date endTime) {
+        long hour = 0;
+        long min = 0;
+        try {
+            long time1 = startTime.getTime();
+            long time2 = endTime.getTime();
+            long diff;
+            if (time1 < time2) {
+                diff = time2 - time1;
+            } else {
+                diff = time1 - time2;
+            }
+            hour = (diff / (60 * 60 * 1000));
+            min = ((diff / (60 * 1000)) - hour * 60);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return hour + "小时" + min + "分";
+    }
+
+    public static Date getDateHourMin(Date date) {
+        if (date == null) {
+            return null;
+        }
+        return StringToDate(DateToString(date, DateStyleEnum.YYYY_MM_DD_HH_MM), DateStyleEnum.YYYY_MM_DD_HH_MM);
+    }
+
+    /**
+     * 判断一个日期是否是周六、周日
+     * @param date
+     * @return
+     * @throws ParseException
+     */
+    public static int isWeekend(String date) throws ParseException {
+        DateFormat format1 = new SimpleDateFormat("yyyy-MM-dd");
+        Date bdate = format1.parse(date);
+        Calendar cal = Calendar.getInstance();
+        cal.setTime(bdate);
+        if (cal.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY || cal.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY) {
+            return 1;
+        } else {
+            return 0;
+        }
+    }
+
+}

+ 2 - 0
src/main/java/com/imed/costaccount/constants/CommonConstant.java

@@ -123,6 +123,8 @@ public final class CommonConstant {
      */
     public static final String MULTIPLICATION_SIGN = "×";
 
+    public static final String LIMIT_ONE = "limit 1";
+
 
     /**
      * 分隔符 - 加号

+ 11 - 2
src/main/java/com/imed/costaccount/mapper/CostIncomeGroupMapper.java

@@ -1,9 +1,13 @@
 package com.imed.costaccount.mapper;
 
-import com.imed.costaccount.model.CostIncomeGroup;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.imed.costaccount.model.CostIncomeGroup;
+import com.imed.costaccount.model.vo.CostIncomeGroupAllAmountVO;
+import com.imed.costaccount.model.vo.CostIncomeGroupBeforeVO;
 import org.apache.ibatis.annotations.Mapper;
 
+import java.util.List;
+
 /**
  * 收入归集
  * 
@@ -12,5 +16,10 @@ import org.apache.ibatis.annotations.Mapper;
  */
 @Mapper
 public interface CostIncomeGroupMapper extends BaseMapper<CostIncomeGroup> {
-	
+    /**
+     *  按照开单科室  执行科室 成本项目进行筛选相同的金额汇总
+     * @param costIncomeGroupBeforeVOList
+     * @return
+     */
+    List<CostIncomeGroupAllAmountVO> countMoney(List<CostIncomeGroupBeforeVO> costIncomeGroupBeforeVOList);
 }

+ 1 - 1
src/main/java/com/imed/costaccount/mapper/RoleMenuMapper.java

@@ -23,5 +23,5 @@ public interface RoleMenuMapper extends BaseMapper<RoleMenu> {
      * @param hospId 医院id
      * @return id name
      */
-    List<CommonVO> getUsersByRoleId(@Param("roleId") Long roleId, @Param("hospId") Long hospId);
+    List<CommonVO> getMenuByRoleId(@Param("roleId") Long roleId, @Param("hospId") Long hospId);
 }

+ 8 - 0
src/main/java/com/imed/costaccount/model/CostIncomeGroup.java

@@ -59,6 +59,14 @@ public class CostIncomeGroup implements Serializable {
 	 * 是否直接收入
 	 */
 	private Integer isIncome;
+	/**
+	 * 开单科室收到的钱
+	 */
+	private BigDecimal openDepartmentAmount;
+	/**
+	 * 执行科室收到的钱
+	 */
+	private BigDecimal startDepartmentAmount;
 	/**
 	 * 金额
 	 */

+ 1 - 1
src/main/java/com/imed/costaccount/model/ReportForm.java

@@ -33,7 +33,7 @@ public class ReportForm implements Serializable {
 	@TableId
 	private Long id;
 	/**
-	 * 报表项目编号(最大值不能超过127)一个医院中必须唯一
+	 * 报表项目编号一个医院中必须唯一
 	 */
 	private Integer num;
 	/**

+ 1 - 1
src/main/java/com/imed/costaccount/model/ReportRelation.java

@@ -39,7 +39,7 @@ public class ReportRelation implements Serializable {
 	/**
 	 * 对应关系的唯一code码
 	 */
-	private Long relationCode;
+	private String relationCode;
 	/**
 	 * 医院id
 	 */

+ 42 - 0
src/main/java/com/imed/costaccount/model/dto/ReportFormEditDTO.java

@@ -0,0 +1,42 @@
+package com.imed.costaccount.model.dto;
+
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.NotNull;
+
+@Data
+@ApiModel("编辑报表项目入参")
+public class ReportFormEditDTO {
+
+    @ApiModelProperty(name = "parentId",value = "当前报表项目id")
+    @NotNull(message = "报表项目id不能为空")
+    private Long id;
+
+    @ApiModelProperty(name = "parentId",value = "父级id,顶层传0")
+//    @NotNull(message = "父级id不为空")
+    private Long parentId;
+
+    @ApiModelProperty(name = "reportName",value = "报表名称")
+    @NotBlank(message = "报表名称不为空")
+    private String reportName;
+
+    @ApiModelProperty(name = "sort",value = "排序字段")
+    @NotNull(message = "排序字段不为空")
+    private Integer sort;
+
+    @ApiModelProperty(name = "reportType",value = "报表类型")
+    @NotNull(message = "报表类型不为空")
+    private Integer reportType;
+
+    @ApiModelProperty(name = "calcType",value = "计算类型")
+    @NotNull(message = "计算类型不为空")
+    private Integer calcType;
+
+    @ApiModelProperty(name = "calcFormula",value = "计算公式")
+    private String calcFormula;
+
+}

+ 26 - 1
src/main/java/com/imed/costaccount/model/dto/ReportFormSaveDTO.java

@@ -1,11 +1,36 @@
 package com.imed.costaccount.model.dto;
 
 import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.NotNull;
+
 @Data
-@ApiModel
+@ApiModel("报表项目新增")
 public class ReportFormSaveDTO {
 
+    @ApiModelProperty(name = "parentId",value = "父级id,顶层传0")
+    @NotNull(message = "父级id不为空")
+    private Long parentId;
+
+    @ApiModelProperty(name = "reportName",value = "报表名称")
+    @NotBlank(message = "报表名称不为空")
+    private String reportName;
+
+    @ApiModelProperty(name = "sort",value = "排序字段")
+    @NotNull(message = "排序字段不为空")
+    private Integer sort;
+
+    @ApiModelProperty(name = "reportType",value = "报表类型")
+    @NotNull(message = "报表类型不为空")
+    private Integer reportType;
+
+    @ApiModelProperty(name = "calcType",value = "计算类型")
+    @NotNull(message = "计算类型不为空")
+    private Integer calcType;
 
+    @ApiModelProperty(name = "calcFormula",value = "计算公式")
+    private String calcFormula;
 }

+ 27 - 0
src/main/java/com/imed/costaccount/model/dto/ReportRelationDTO.java

@@ -0,0 +1,27 @@
+package com.imed.costaccount.model.dto;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import org.hibernate.validator.constraints.Range;
+
+import javax.validation.constraints.Max;
+import javax.validation.constraints.Min;
+import javax.validation.constraints.NotNull;
+import java.util.List;
+
+@Data
+@ApiModel("报表关系编辑对象")
+public class ReportRelationDTO {
+
+    @ApiModelProperty(name = "reportId",value = "报表id")
+    @NotNull(message = "报表id不为空")
+    private Long reportId;
+
+    @ApiModelProperty(name = "relation",value = "1.对应会计科目设置,2.对应分摊参数设置")
+    @NotNull(message = "报表项目关联关系不能为空")
+    private Integer relation;
+
+    private List<String> relationCodes;
+
+}

+ 16 - 0
src/main/java/com/imed/costaccount/model/vo/CostIncomeGroupAllAmountVO.java

@@ -0,0 +1,16 @@
+package com.imed.costaccount.model.vo;
+
+import io.swagger.annotations.ApiModel;
+import lombok.Data;
+
+/**
+ * @author 李加喜
+ * @Package com.imed.costaccount.model.vo
+ * @date 2021-08-04 16:35
+ */
+@Data
+@ApiModel("收入归集统计归并后金额的返回实体类")
+public class CostIncomeGroupAllAmountVO extends CostIncomeGroupBeforeVO{
+
+    private String allMoney;
+}

+ 71 - 0
src/main/java/com/imed/costaccount/model/vo/CostIncomeGroupBeforeVO.java

@@ -0,0 +1,71 @@
+package com.imed.costaccount.model.vo;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.math.BigDecimal;
+
+/**
+ * @author 李加喜
+ * @Package com.imed.costaccount.model.vo
+ * @date 2021-08-04 9:29
+ */
+@Data
+@ApiModel("收入归集前返回实体类")
+public class CostIncomeGroupBeforeVO {
+
+    @ApiModelProperty(name = "收入归集id",value = "主键")
+    private Long id;
+
+    @ApiModelProperty(name = "openDepartmentCode",value = "开单科室的代码")
+    private String openDepartmentCode;
+
+    @ApiModelProperty(name = "openDepartmentCodeName",value = "开单科室的代码+名称")
+    private String openDepartmentCodeName;
+
+    @ApiModelProperty(name = "openResponsibilityCode",value = "开单责任中心的代码")
+    private String openResponsibilityCode;
+
+    @ApiModelProperty(name = "openResponsibilityCodeName",value = "开单责任中心的代码+名称")
+    private String openResponsibilityCodeName;
+
+    @ApiModelProperty(name = "startDepartmentCode",value = "执行科室的代码")
+    private String startDepartmentCode;
+
+    @ApiModelProperty(name = "startDepartmentCodeName",value = "执行科室代码+名称")
+    private String startDepartmentCodeName;
+
+    @ApiModelProperty(name = "startResponsibilityCode",value = "执行责任中心代码")
+    private String startResponsibilityCode;
+
+    @ApiModelProperty(name = "startResponsibilityCodeName",value = "执行责任中心代码+名称")
+    private String startResponsibilityCodeName;
+
+    @ApiModelProperty(name = "productCode",value = "成本项目的代码")
+    private String productCode;
+
+    @ApiModelProperty(name = "productCodeName",value = "成本项目的代码+名称")
+    private String productCodeName;
+
+    @ApiModelProperty(name = "accountCode",value = "会计科目的代码")
+    private String accountCode;
+
+    @ApiModelProperty(name = "accountCodeName",value = "会计科目的代码+名称")
+    private String accountCodeName;
+
+    @ApiModelProperty(name = "openDepartmentAmount",value = "开单科室金额")
+    private BigDecimal openDepartmentAmount;
+
+    @ApiModelProperty(name = "startDepartmentAmount",value = "执行科室金额")
+    private BigDecimal startDepartmentAmount;
+
+    @ApiModelProperty(name = "amount",value = "总金额")
+    private BigDecimal amount;
+
+    @ApiModelProperty(name = "dateYear",value = "年")
+    private Integer dateYear;
+
+    @ApiModelProperty(name = "dateMonth",value = "月")
+    private Integer dateMonth;
+}

+ 5 - 0
src/main/java/com/imed/costaccount/model/vo/RelationVO.java

@@ -1,5 +1,7 @@
 package com.imed.costaccount.model.vo;
 
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonInclude;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
@@ -16,4 +18,7 @@ public class RelationVO {
 
     @ApiModelProperty(name = "relation",value = "关联关系:1.关系为会计科目,2.关系为分摊参数")
     private Integer relation;
+
+    @JsonInclude(JsonInclude.Include.NON_NULL)
+    private Boolean isSelect;
 }

+ 12 - 1
src/main/java/com/imed/costaccount/service/CostIncomeGroupService.java

@@ -1,6 +1,7 @@
 package com.imed.costaccount.service;
 
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.imed.costaccount.common.util.PageUtils;
 import com.imed.costaccount.model.CostIncomeGroup;
 
 /**
@@ -11,6 +12,16 @@ import com.imed.costaccount.model.CostIncomeGroup;
  * @date 2021-08-03 16:15:20
  */
 public interface CostIncomeGroupService extends IService<CostIncomeGroup> {
-
+    /**
+     * 分页查询收入归集前的数据
+     * @param current 当前页
+     * @param pageSize 当前页大小
+     * @param dateTime 年月
+     * @param responsibilityCode 责任中心代码
+     * @param accountCode 会计科目的Code
+     * @param hospId 医院Id
+     * @return
+     */
+    PageUtils queryList(Integer current, Integer pageSize, String dateTime, String responsibilityCode, String accountCode, Long hospId);
 }
 

+ 16 - 0
src/main/java/com/imed/costaccount/service/ReportFormService.java

@@ -2,6 +2,8 @@ package com.imed.costaccount.service;
 
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.imed.costaccount.model.User;
+import com.imed.costaccount.model.dto.ReportFormEditDTO;
+import com.imed.costaccount.model.dto.ReportFormSaveDTO;
 import com.imed.costaccount.model.vo.ReportFormVO;
 import com.imed.costaccount.model.ReportForm;
 
@@ -24,5 +26,19 @@ public interface ReportFormService extends IService<ReportForm> {
      * @return
      */
     List<ReportFormVO> selectList(Integer reportType, User user);
+
+    /**
+     * 新增一个报表项目
+     * @param reportFormDTO {@link ReportFormSaveDTO}
+     * @param hospId 医院id
+     */
+    void saveReport(ReportFormSaveDTO reportFormDTO, Long hospId);
+
+    /**
+     * 更新某个报表项目
+     * @param formEditDTO
+     */
+    void updateReport(ReportFormEditDTO formEditDTO);
+
 }
 

+ 17 - 1
src/main/java/com/imed/costaccount/service/ReportRelationService.java

@@ -1,11 +1,11 @@
 package com.imed.costaccount.service;
 
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.imed.costaccount.model.dto.ReportRelationDTO;
 import com.imed.costaccount.model.vo.RelationVO;
 import com.imed.costaccount.model.ReportRelation;
 
 import java.util.List;
-import java.util.Map;
 
 /**
  * 报表对应项目设置关系
@@ -32,5 +32,21 @@ public interface ReportRelationService extends IService<ReportRelation> {
      */
     List<RelationVO> getShareParam(Long reportId, Long hospId);
 
+    /**
+     * 根据关系类型,获取可绑定的关系数据(包含回显)
+     * @param reportId  报表项目id
+     * @param relation 1.对应会计科目设置,2.对应分摊参数设置,根据列表中showAddRelation字段是否存在判断
+     * @param hospId 医院id
+     * @return 返回所有列表 并便是已选择的元素
+     */
+    List<RelationVO> getRelationList(Long reportId, Integer relation, Long hospId);
+
+    /**
+     * 编辑相关关系
+     * @param reportRelationDTO
+     * @param hospId
+     */
+    void saveReportRelation(ReportRelationDTO reportRelationDTO, Long hospId);
+
 }
 

+ 1 - 1
src/main/java/com/imed/costaccount/service/RoleMenuService.java

@@ -32,7 +32,7 @@ public interface RoleMenuService extends IService<RoleMenu> {
      * @param roleId 角色id
      * @return CommonSelectVO
      */
-    List<CommonSelectVO> roleMenuList(Long roleId, Long hospId);
+    List<CommonVO> roleMenuList(Long roleId, Long hospId);
 
     /**
      * 编辑角色和菜单关系

+ 1 - 4
src/main/java/com/imed/costaccount/service/UserRoleService.java

@@ -2,7 +2,6 @@ package com.imed.costaccount.service;
 
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.imed.costaccount.common.util.PageUtils;
-import com.imed.costaccount.model.dto.RoleMenuDTO;
 import com.imed.costaccount.model.dto.RoleUserDTO;
 import com.imed.costaccount.model.vo.CommonVO;
 import com.imed.costaccount.model.UserRole;
@@ -31,11 +30,9 @@ public interface UserRoleService extends IService<UserRole> {
      * 绑定角色和人员关系时选择列表(可回显)
      * @param roleId 角色id
      * @param hospId 医院id
-     * @param page
-     * @param pageSize
      * @return {"id":1,"username":"tom","isSelect": true}
      */
-    PageUtils roleUserList(Long roleId, Long hospId, Integer page, Integer pageSize);
+    List roleUserList(Long roleId, Long hospId);
 
     /**
      * 编辑角色和人员关系

+ 15 - 2
src/main/java/com/imed/costaccount/service/impl/AccountingProductServiceImpl.java

@@ -1,8 +1,10 @@
 package com.imed.costaccount.service.impl;
 
 import cn.hutool.core.collection.CollUtil;
+import cn.hutool.core.util.StrUtil;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.imed.costaccount.common.exception.CostException;
 import com.imed.costaccount.mapper.AccountingMapper;
 import com.imed.costaccount.mapper.AccountingProductMapper;
 import com.imed.costaccount.mapper.ProductMapper;
@@ -48,7 +50,7 @@ public class AccountingProductServiceImpl extends ServiceImpl<AccountingProductM
         List<Accounting> list = accountingMapper.selectList(
                 new LambdaQueryWrapper<Accounting>()
                         .eq(Accounting::getHospId, user.getHospId())
-                .orderByDesc(Accounting::getCreateTime)
+                        .orderByDesc(Accounting::getCreateTime)
         );
 
         if (CollUtil.isEmpty(list)) {
@@ -119,8 +121,9 @@ public class AccountingProductServiceImpl extends ServiceImpl<AccountingProductM
     @Override
     @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
     public void saveAccountProduct(AccountProductSaveDTO accountProductSaveDTO, User user) {
-        // 删除所有原来的关系
+        // TODO: 2021/8/4  校验这个 会计科目是否能绑定数据
         Long accountId = accountProductSaveDTO.getId();
+        // 删除所有原来的关系
         this.remove(new LambdaQueryWrapper<AccountingProduct>().eq(AccountingProduct::getAccountingId, accountId));
 
         List<Long> products = accountProductSaveDTO.getProducts();
@@ -133,6 +136,16 @@ public class AccountingProductServiceImpl extends ServiceImpl<AccountingProductM
             return accountingProduct;
         }).collect(Collectors.toList());
 
+        // 校验已经绑定过的数据 (1:n)
+        List<AccountingProduct> list = this.list(
+                new LambdaQueryWrapper<AccountingProduct>().select(AccountingProduct::getId)
+                        .eq(AccountingProduct::getAccountingId, accountId)
+                        .eq(AccountingProduct::getHospId, user.getHospId())
+                        .in(AccountingProduct::getProductId, accountProductSaveDTO.getProducts())
+        );
+        if (CollUtil.isNotEmpty(list)) {
+            throw new CostException("成本收入id为:" + StrUtil.join(StrUtil.COMMA, list) + "已被其他会计中心绑定,请重新选择");
+        }
         this.saveBatch(accountingProducts);
     }
 }

+ 3 - 2
src/main/java/com/imed/costaccount/service/impl/AccountingServiceImpl.java

@@ -145,6 +145,7 @@ public class AccountingServiceImpl extends ServiceImpl<AccountingMapper, Account
                 throw new CostException(500, "会计科目类型要与上层一致");
             }
             String oldParentIds = byId.getAllParentIds();
+
             if ("0".equals(oldParentIds)) {
                 allParentIds = parentId + "";
             } else {
@@ -260,8 +261,8 @@ public class AccountingServiceImpl extends ServiceImpl<AccountingMapper, Account
         if (Objects.nonNull(one) && !byId.getAccountingCode().equals(one.getAccountingCode())) {
             throw new CostException(500, "会计科目代码已存在,请重新生成");
         }
-        // 直接修改
-        byId.setAccountingCode(accountingEditDTO.getAccountingCode());
+        // 直接修改 TODO 不修改会计科目Code
+        byId.setAccountingCode(byId.getAccountingCode());
         byId.setAccountingName(accountingEditDTO.getAccountingName());
         byId.setCreateTime(System.currentTimeMillis());
 //        byId.setAccountingType(accountingEditDTO.getAccountingType());

+ 12 - 10
src/main/java/com/imed/costaccount/service/impl/CostAccountShareServiceImpl.java

@@ -16,10 +16,9 @@ import com.imed.costaccount.model.vo.CostAccountShareVO;
 import com.imed.costaccount.model.vo.CostShareParamStatusVO;
 import com.imed.costaccount.model.vo.CostShareParamVO;
 import com.imed.costaccount.model.vo.ShareParamProportionVO;
-import com.imed.costaccount.service.CostAccountShareService;
+import com.imed.costaccount.service.*;
 import com.imed.costaccount.utils.BeanUtil;
 import org.apache.shiro.SecurityUtils;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Propagation;
 import org.springframework.transaction.annotation.Transactional;
@@ -37,17 +36,20 @@ import java.util.stream.Collectors;
 @Service("costAccountShareService")
 public class CostAccountShareServiceImpl extends ServiceImpl<CostAccountShareMapper, CostAccountShare> implements CostAccountShareService {
 
-    @Autowired
-    private ResponsibilityServiceImpl responsibilityService;
+    private final ResponsibilityService responsibilityService;
 
-    @Autowired
-    private AccountingServiceImpl accountingService;
+    private final AccountingService accountingService;
 
-    @Autowired
-    private CostShareLevelServiceImpl costShareLevelService;
+    private final CostShareLevelService costShareLevelService;
 
-    @Autowired
-    private CostShareParamServiceImpl costShareParamService;
+    private final CostShareParamService costShareParamService;
+
+    public CostAccountShareServiceImpl(ResponsibilityService responsibilityService, AccountingService accountingService, CostShareLevelService costShareLevelService, CostShareParamService costShareParamService) {
+        this.responsibilityService = responsibilityService;
+        this.accountingService = accountingService;
+        this.costShareLevelService = costShareLevelService;
+        this.costShareParamService = costShareParamService;
+    }
 
     /**
      * 分页查询责任中心成本对照相关数据

+ 115 - 2
src/main/java/com/imed/costaccount/service/impl/CostIncomeGroupServiceImpl.java

@@ -1,14 +1,127 @@
 package com.imed.costaccount.service.impl;
 
+import cn.hutool.core.util.StrUtil;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.imed.costaccount.common.util.BeanUtil;
+import com.imed.costaccount.common.util.DateUtils;
+import com.imed.costaccount.common.util.PageUtils;
 import com.imed.costaccount.mapper.CostIncomeGroupMapper;
-import com.imed.costaccount.model.CostIncomeGroup;
-import com.imed.costaccount.service.CostIncomeGroupService;
+import com.imed.costaccount.model.*;
+import com.imed.costaccount.model.vo.CostIncomeGroupAllAmountVO;
+import com.imed.costaccount.model.vo.CostIncomeGroupBeforeVO;
+import com.imed.costaccount.service.*;
 import org.springframework.stereotype.Service;
+import org.springframework.util.StringUtils;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
 
 
 @Service("costIncomeGroupService")
 public class CostIncomeGroupServiceImpl extends ServiceImpl<CostIncomeGroupMapper, CostIncomeGroup> implements CostIncomeGroupService {
 
+    private final DepartmentService departmentService;
+
+    private final ResponsibilityService responsibilityService;
+
+    private final ProductService productService;
+
+    private final AccountingService accountingService;
+
+    private final CostIncomeGroupMapper costIncomeGroupMapper;
+
+    public CostIncomeGroupServiceImpl(DepartmentService departmentService, ResponsibilityService responsibilityService, ProductService productService, AccountingService accountingService, CostIncomeGroupMapper costIncomeGroupMapper) {
+        this.departmentService = departmentService;
+        this.responsibilityService = responsibilityService;
+        this.productService = productService;
+        this.accountingService = accountingService;
+        this.costIncomeGroupMapper = costIncomeGroupMapper;
+    }
+
+    /**
+     * 分页查询收入归集前的数据
+     *
+     * @param current            当前页
+     * @param pageSize           当前页大小
+     * @param dateTime           年月
+     * @param responsibilityCode 责任中心代码
+     * @param accountCode        会计科目的Code
+     * @param hospId             医院Id
+     * @return
+     */
+    @Override
+    public PageUtils queryList(Integer current, Integer pageSize, String dateTime, String responsibilityCode, String accountCode, Long hospId) {
+        int year = DateUtils.getYear(dateTime);
+        int month=DateUtils.getMonth(dateTime);
+        Page<CostIncomeGroup> costIncomeGroupPage = new Page<>(current, pageSize);
+        QueryWrapper<CostIncomeGroup> wrapper = new QueryWrapper<>();
+        wrapper.eq("hosp_id",hospId);
+        wrapper.eq("date_year",year);
+        wrapper.eq("date_month",month);
+        Page<CostIncomeGroup> pages = this.page(costIncomeGroupPage, wrapper);
+        List<CostIncomeGroup> records = pages.getRecords();
+        List<CostIncomeGroupBeforeVO> costIncomeGroupBeforeVOList = BeanUtil.convertList(records, CostIncomeGroupBeforeVO.class);
+        // 查询所有的责任中心 科室 会计科目  成本项目的数据  处理名字
+        setCodeName(hospId, costIncomeGroupBeforeVOList);
+        // 进行金额合并
+        List<CostIncomeGroupAllAmountVO> costIncomeGroupAllAmountVoS =costIncomeGroupMapper.countMoney(costIncomeGroupBeforeVOList);
+        // TODO 对,的金额进行合并
+        costIncomeGroupAllAmountVoS.forEach(i->{
+            String allMoney = i.getAllMoney();
+            if (allMoney.contains(StrUtil.COMMA)){
+                // 存在,在进行求和
+                Long sum;
+                List<Long> list = Arrays.stream(allMoney.split(StrUtil.COMMA)).map(Long::valueOf).collect(Collectors.toList());
+
+            }
+        });
+        List<CostIncomeGroupAllAmountVO> amountVOS = costIncomeGroupAllAmountVoS.stream().map(i -> {
+            if (!StringUtils.isEmpty(responsibilityCode)) {
+                boolean equalsBoolean = i.getOpenResponsibilityCode().equals(responsibilityCode);
+                if (!equalsBoolean) {
+                    i.getStartResponsibilityCode().equals(responsibilityCode);
+                }
+            }
+            if (!StringUtils.isEmpty(accountCode)) {
+                i.getAccountCode().equals(accountCode);
+            }
+            return i;
+        }).collect(Collectors.toList());
+        PageUtils pageUtils = new PageUtils(pages);
+        pageUtils.setList(amountVOS);
+        return pageUtils;
+    }
 
+    /**
+     * 设置相关名称
+     * @param hospId
+     * @param costIncomeGroupBeforeVOList
+     */
+    private void setCodeName(Long hospId, List<CostIncomeGroupBeforeVO> costIncomeGroupBeforeVOList) {
+        List<Responsibility> responsibilityList = responsibilityService.list(new QueryWrapper<Responsibility>().lambda().eq(Responsibility::getHospId, hospId));
+        Map<String, List<Responsibility>> responsibilityMap = responsibilityList.stream().collect(Collectors.groupingBy(Responsibility::getResponsibilityCode));
+        List<Department> departmentList = departmentService.list(new QueryWrapper<Department>().lambda().eq(Department::getHospId, hospId));
+        Map<String, List<Department>> departmentMap = departmentList.stream().collect(Collectors.groupingBy(Department::getDepartmentCode));
+        List<Product> productList = productService.list(new QueryWrapper<Product>().lambda().eq(Product::getHospId, hospId));
+        Map<String, List<Product>> productMap = productList.stream().collect(Collectors.groupingBy(Product::getProductCode));
+        List<Accounting> accountingList = accountingService.list(new QueryWrapper<Accounting>().lambda().eq(Accounting::getHospId, hospId));
+        Map<String, List<Accounting>> accountMap = accountingList.stream().collect(Collectors.groupingBy(Accounting::getAccountingCode));
+        costIncomeGroupBeforeVOList.forEach(i->{
+            // 以为这里的数据导入的  在导入的时候进行数据校验
+            // 设置开单科室名称 执行科室名称  开单责任中心名称  执行责任中心名称 成本项目的名称 会计科目名称
+            i.setOpenDepartmentCodeName("["+i.getOpenDepartmentCode()+"]"+departmentMap.get(i.getOpenDepartmentCode()).get(0).getDepartmentName());
+            i.setOpenResponsibilityCodeName("["+i.getOpenResponsibilityCode()+"]"+responsibilityMap.get(i.getOpenResponsibilityCode()).get(0).getResponsibilityName());
+            i.setStartDepartmentCodeName("["+i.getStartDepartmentCode()+"]"+departmentMap.get(i.getStartDepartmentCode()).get(0).getDepartmentName());
+            i.setStartResponsibilityCodeName("["+i.getStartResponsibilityCode()+"]"+responsibilityMap.get(i.getStartResponsibilityCode()).get(0).getResponsibilityName());
+            i.setProductCodeName("["+i.getProductCode()+"]"+productMap.get(i.getProductCode()).get(0).getProductName());
+            i.setAccountCodeName("["+i.getAccountCode()+"]"+accountMap.get(i.getAccountCode()).get(0).getAccountingName());
+        });
+    }
+    /**
+     * 根据年月查询所有的数据
+     */
 }

+ 136 - 3
src/main/java/com/imed/costaccount/service/impl/ReportFormServiceImpl.java

@@ -3,17 +3,21 @@ package com.imed.costaccount.service.impl;
 import cn.hutool.core.collection.CollUtil;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.imed.costaccount.common.exception.CostException;
 import com.imed.costaccount.mapper.ReportFormMapper;
 import com.imed.costaccount.model.ReportForm;
 import com.imed.costaccount.model.User;
+import com.imed.costaccount.model.dto.ReportFormEditDTO;
+import com.imed.costaccount.model.dto.ReportFormSaveDTO;
 import com.imed.costaccount.model.vo.RelationVO;
 import com.imed.costaccount.model.vo.ReportFormVO;
 import com.imed.costaccount.service.ReportFormService;
 import com.imed.costaccount.service.ReportRelationService;
 import com.imed.costaccount.utils.BeanUtil;
 import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Propagation;
+import org.springframework.transaction.annotation.Transactional;
 
 import java.util.ArrayList;
 import java.util.Collections;
@@ -21,6 +25,9 @@ import java.util.List;
 import java.util.Objects;
 import java.util.stream.Collectors;
 
+import static com.imed.costaccount.common.constants.NumberConstant.THREE;
+import static com.imed.costaccount.constants.CommonConstant.LIMIT_ONE;
+
 @Slf4j
 @Service("reportFormService")
 public class ReportFormServiceImpl extends ServiceImpl<ReportFormMapper, ReportForm> implements ReportFormService {
@@ -41,7 +48,10 @@ public class ReportFormServiceImpl extends ServiceImpl<ReportFormMapper, ReportF
     @Override
     public List<ReportFormVO> selectList(Integer reportType, User user) {
         List<ReportForm> list = this.list(
-                new LambdaQueryWrapper<ReportForm>().eq(ReportForm::getReportType, reportType).eq(ReportForm::getHospId, user.getHospId())
+                new LambdaQueryWrapper<ReportForm>()
+                        .eq(ReportForm::getReportType, reportType)
+                        .eq(ReportForm::getHospId, user.getHospId())
+                        .orderByAsc(ReportForm::getSort)
         );
         if (CollUtil.isEmpty(list)) {
             return Collections.emptyList();
@@ -65,7 +75,7 @@ public class ReportFormServiceImpl extends ServiceImpl<ReportFormMapper, ReportF
             for (ReportFormVO reportFormVO : reportFormVOS) {
                 if (reportFormVO.getParentId().equals(root.getId())) {
                     children.add(reportFormVO);
-                    this.setRelation(reportFormVO,user.getHospId());
+//                    this.setRelation(reportFormVO, user.getHospId());
                 }
             }
             root.setChildren(children);
@@ -75,6 +85,7 @@ public class ReportFormServiceImpl extends ServiceImpl<ReportFormMapper, ReportF
 
     /**
      * 填充对应的关联关系
+     *
      * @param reportFormVO {@link ReportFormVO}
      * @param hospId
      */
@@ -94,4 +105,126 @@ public class ReportFormServiceImpl extends ServiceImpl<ReportFormMapper, ReportF
         }
 
     }
+
+
+    /**
+     * 新增一个报表项目
+     *
+     * @param reportFormDTO {@link ReportFormSaveDTO}
+     * @param hospId        医院id
+     */
+    @Override
+    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Throwable.class)
+    public void saveReport(ReportFormSaveDTO reportFormDTO, Long hospId) {
+        ReportForm reportForm = BeanUtil.convertObj(reportFormDTO, ReportForm.class);
+        Integer num = this.createNum(hospId);
+        // TODO: 2021/8/4 控制唯一性
+        reportForm.setHospId(hospId)
+                .setNum(num)
+                .setCreateTime(System.currentTimeMillis());
+        // 如果新增的是父节点
+        Long parentId = reportFormDTO.getParentId();
+        // 根据是否父节点设置必要的数据
+        setDataByParentId(hospId, reportForm, parentId);
+
+        this.save(reportForm);
+    }
+
+    /**
+     * 根据是否父节点设置必要的数据
+     *    ***后台默认处理报表节点不一致的问题***
+     * @param hospId 医院id
+     * @param reportForm 需要构建的实体
+     * @param parentId 父级id
+     */
+    private void setDataByParentId(Long hospId, ReportForm reportForm, Long parentId) {
+        if (parentId == 0L) {
+            reportForm.setCalcType(0);
+            reportForm.setCalcFormula("");
+//            reportForm.setReportType(0);
+            // 如果编辑的时候子集的reportType 要和父级一致
+            Long id = reportForm.getId();
+            List<ReportForm> list = this.list(
+                    new LambdaQueryWrapper<ReportForm>().eq(ReportForm::getParentId, id).eq(ReportForm::getHospId, hospId)
+            );
+            if (!list.isEmpty()) {
+                list.forEach(i -> i.setReportType(reportForm.getReportType()));
+                this.updateBatchById(list);
+            }
+        } else {
+            // 父子节点报表类型必须一致
+            ReportForm byId = this.getById(parentId);
+            checkExist(byId,"选择的父报表层级不正确");
+            reportForm.setReportType(byId.getReportType());
+            // 如果子节点 小计只能存在一个
+            this.isSubtotal(parentId, hospId);
+        }
+    }
+
+    /**
+     * 子类型中小计计算类型只能存在一个
+     *    判断是否存在小计的计算类型,存在抛出异常
+     * @param parentId 父级id
+     * @param hospId 医院id
+     */
+    private void isSubtotal(Long parentId, Long hospId) {
+        List<ReportForm> list = this.list(
+                new LambdaQueryWrapper<ReportForm>().select(ReportForm::getId)
+                        .eq(ReportForm::getParentId, parentId).eq(ReportForm::getHospId, hospId).eq(ReportForm::getCalcType, THREE)
+        );
+        if (list.isEmpty()) {
+            return;
+        }
+        throw new CostException("小计类型已存在,请修改计算类型");
+    }
+
+    /**
+     * 创建最新的num 获取最大的num + 1
+     *
+     * @param hospId 医院id
+     * @return 返回本医院最新编号
+     */
+    private Integer createNum(Long hospId) {
+        ReportForm one = this.getOne(
+                new LambdaQueryWrapper<ReportForm>().select(ReportForm::getNum)
+                        .eq(ReportForm::getHospId, hospId)
+                        .orderByDesc(ReportForm::getNum).last(LIMIT_ONE)
+        );
+        if (Objects.isNull(one)) {
+            return 1;
+        }
+        return one.getNum() + 1;
+    }
+
+    /**
+     * 更新某个报表项目
+     *
+     * @param formEditDTO {@link ReportFormEditDTO}
+     */
+    @Override
+    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Throwable.class)
+    public void updateReport(ReportFormEditDTO formEditDTO) {
+        Long id = formEditDTO.getId();
+        ReportForm byId = this.getById(id);
+        checkExist(byId,"选择的报表项目不存在");
+
+        BeanUtil.convertObj(formEditDTO, byId);
+
+        Long parentId = byId.getParentId();
+        // 根据是否父节点设置必要的数据
+        this.setDataByParentId(byId.getHospId(), byId, parentId);
+
+        this.updateById(byId);
+    }
+
+    /**
+     * 抛出异常
+     * @param byId POJO类
+     * @param errorMsg 抛出信息
+     */
+    private void checkExist(ReportForm byId,String errorMsg) {
+        if (Objects.isNull(byId)) {
+            throw new CostException(errorMsg);
+        }
+    }
 }

+ 150 - 0
src/main/java/com/imed/costaccount/service/impl/ReportRelationServiceImpl.java

@@ -1,20 +1,47 @@
 package com.imed.costaccount.service.impl;
 
+import cn.hutool.core.collection.CollUtil;
+import cn.hutool.core.util.StrUtil;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.imed.costaccount.common.exception.CostException;
+import com.imed.costaccount.mapper.ReportFormMapper;
 import com.imed.costaccount.mapper.ReportRelationMapper;
+import com.imed.costaccount.model.Accounting;
+import com.imed.costaccount.model.CostShareParam;
+import com.imed.costaccount.model.ReportForm;
 import com.imed.costaccount.model.ReportRelation;
+import com.imed.costaccount.model.dto.ReportRelationDTO;
 import com.imed.costaccount.model.vo.RelationVO;
+import com.imed.costaccount.service.AccountingService;
+import com.imed.costaccount.service.CostShareParamService;
+import com.imed.costaccount.service.ReportFormService;
 import com.imed.costaccount.service.ReportRelationService;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Propagation;
+import org.springframework.transaction.annotation.Transactional;
 
+import java.util.ArrayList;
 import java.util.List;
+import java.util.Objects;
+import java.util.stream.Collectors;
 
 
 @Slf4j
 @Service("reportRelationService")
 public class ReportRelationServiceImpl extends ServiceImpl<ReportRelationMapper, ReportRelation> implements ReportRelationService {
 
+    private final AccountingService accountingService;
+    private final CostShareParamService shareParamService;
+    private final ReportFormMapper reportFormMapper;
+
+    public ReportRelationServiceImpl(AccountingService accountingService, CostShareParamService shareParamService, ReportFormMapper reportFormMapper) {
+        this.accountingService = accountingService;
+        this.shareParamService = shareParamService;
+        this.reportFormMapper = reportFormMapper;
+    }
+
     /**
      * 报表项目关联的会计科目对象
      *
@@ -38,4 +65,127 @@ public class ReportRelationServiceImpl extends ServiceImpl<ReportRelationMapper,
     public List<RelationVO> getShareParam(Long reportId, Long hospId) {
         return baseMapper.getShareParam(reportId, hospId);
     }
+
+    /**
+     * 根据关系类型,获取可绑定的关系数据(包含回显)
+     *
+     * @param reportId 报表项目id
+     * @param relation 1.对应会计科目设置,2.对应分摊参数设置,根据列表中showAddRelation字段是否存在判断
+     * @param hospId   医院id
+     * @return 返回所有列表 并便是已选择的元素
+     */
+    @Override
+    public List<RelationVO> getRelationList(Long reportId, Integer relation, Long hospId) {
+        List<RelationVO> list = new ArrayList<>();
+        if (relation == 1) {
+            List<RelationVO> accountRelation = this.getAccountRelation(reportId, hospId);
+            List<Accounting> accounts = accountingService.list(new LambdaQueryWrapper<Accounting>().select(Accounting::getAccountingCode, Accounting::getAccountingName).eq(Accounting::getHospId, hospId));
+            if (accounts.isEmpty()) {
+                return list;
+            }
+            list = accounts.stream().map(i -> {
+                RelationVO relationVO = new RelationVO();
+                relationVO.setIsSelect(false);
+                relationVO.setRelation(1);
+                relationVO.setCode(i.getAccountingCode());
+                relationVO.setName(i.getAccountingName());
+                return relationVO;
+            }).collect(Collectors.toList());
+            for (RelationVO relationVO : accountRelation) {
+                for (RelationVO vo : list) {
+                    if (vo.getCode().equals(relationVO.getCode())) {
+                        vo.setIsSelect(true);
+                    }
+                }
+            }
+
+        } else if (relation == 2) {
+            List<RelationVO> accountRelation = this.getShareParam(reportId, hospId);
+            List<CostShareParam> accounts = shareParamService.list(new LambdaQueryWrapper<CostShareParam>().select(CostShareParam::getShareParamCode, CostShareParam::getShareParamName).eq(CostShareParam::getHospId, hospId));
+            if (accounts.isEmpty()) {
+                return list;
+            }
+            list = accounts.stream().map(i -> {
+                RelationVO relationVO = new RelationVO();
+                relationVO.setIsSelect(false);
+                relationVO.setRelation(1);
+                relationVO.setCode(i.getShareParamCode());
+                relationVO.setName(i.getShareParamName());
+                return relationVO;
+            }).collect(Collectors.toList());
+            for (RelationVO relationVO : accountRelation) {
+                for (RelationVO vo : list) {
+                    if (vo.getCode().equals(relationVO.getCode())) {
+                        vo.setIsSelect(true);
+                    }
+                }
+            }
+        }
+        return list;
+    }
+
+    /**
+     * 编辑相关关系
+     *
+     * @param reportRelationDTO {@link ReportRelationDTO}
+     * @param hospId
+     */
+    @Override
+    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Throwable.class)
+    public void saveReportRelation(ReportRelationDTO reportRelationDTO, Long hospId) {
+
+        Integer relation = reportRelationDTO.getRelation();
+        List<String> relationCodes = reportRelationDTO.getRelationCodes();
+        Long reportId = reportRelationDTO.getReportId();
+
+        // 校验这个report是否能绑定
+        ReportForm byId = reportFormMapper.selectById(reportId);
+        if (Objects.isNull(byId)) {
+            throw new CostException("选择的报表项目不存在");
+        }
+        Integer calcType = byId.getCalcType();
+        if (calcType != 1 && calcType != 2) {
+            throw new CostException("选择的报表项目不能绑定关联关系");
+        }
+
+        List<ReportRelation> list = this.list(
+                new LambdaQueryWrapper<ReportRelation>().eq(ReportRelation::getReportId, reportId).eq(ReportRelation::getHospId, hospId)
+        );
+        if (!list.isEmpty()) {
+            baseMapper.deleteBatchIds(list.stream().map(ReportRelation::getId).collect(Collectors.toList()));
+        }
+        List<ReportRelation> reportRelations = relationCodes.stream().map(code -> {
+            ReportRelation reportRelation = new ReportRelation();
+            reportRelation.setRelation(relation);
+            reportRelation.setReportId(reportId);
+            reportRelation.setHospId(hospId);
+            reportRelation.setRelationCode(code);
+            reportRelation.setCreateTime(System.currentTimeMillis());
+            return reportRelation;
+        }).collect(Collectors.toList());
+        // 校验 关联关系的id 是否已绑定过其他的报表项目
+        checkIfExist(hospId, relation, relationCodes);
+        this.saveBatch(reportRelations);
+    }
+
+    /**
+     * 校验 关联关系的id 是否已绑定过其他的报表项目
+     *
+     * @param hospId        医院id
+     * @param relation      关系
+     * @param relationCodes 所有需要绑定的code 列表
+     */
+    private void checkIfExist(Long hospId, Integer relation, List<String> relationCodes) {
+        List<ReportRelation> relations = this.list(
+                new LambdaQueryWrapper<ReportRelation>().select(ReportRelation::getRelationCode)
+                        .in(ReportRelation::getRelationCode, relationCodes)
+                        .eq(ReportRelation::getRelation, relation)
+                        .eq(ReportRelation::getHospId, hospId)
+        );
+        if (CollUtil.isNotEmpty(relations)) {
+            throw new CostException(500, "编码为:" +
+                    StrUtil.join(StrUtil.COMMA, relations.stream().map(ReportRelation::getRelationCode).collect(Collectors.toList())) +
+                    "已被其他项目代码绑定");
+        }
+    }
 }

+ 34 - 33
src/main/java/com/imed/costaccount/service/impl/RoleMenuServiceImpl.java

@@ -43,7 +43,7 @@ public class RoleMenuServiceImpl extends ServiceImpl<RoleMenuMapper, RoleMenu> i
      */
     @Override
     public List<CommonVO> getMenuByRoleId(Long roleId, Long hospId) {
-        return baseMapper.getUsersByRoleId(roleId, hospId);
+        return baseMapper.getMenuByRoleId(roleId, hospId);
     }
 
 
@@ -55,38 +55,39 @@ public class RoleMenuServiceImpl extends ServiceImpl<RoleMenuMapper, RoleMenu> i
      * @return CommonSelectVO
      */
     @Override
-    public List<CommonSelectVO> roleMenuList(Long roleId, Long hospId) {
-        List<Menu> list = menuService.list(
-                new LambdaQueryWrapper<Menu>().eq(Menu::getHospId, hospId)
-        );
-        if (CollUtil.isEmpty(list)) {
-            return Collections.emptyList();
-        }
-        List<CommonSelectVO> all = list.stream().map(i -> {
-            CommonSelectVO commonSelectVO = new CommonSelectVO();
-            commonSelectVO.setIsSelect(false);
-            commonSelectVO.setParentId(i.getParentId());
-            commonSelectVO.setId(i.getMenuId());
-            commonSelectVO.setName(i.getName());
-            return commonSelectVO;
-        }).collect(Collectors.toList());
-
-        List<RoleMenu> roleMenus = this.list(
-                new LambdaQueryWrapper<RoleMenu>().eq(RoleMenu::getRoleId, roleId)
-        );
-        for (CommonSelectVO commonSelectVO : all) {
-            for (RoleMenu roleMenu : roleMenus) {
-                if (roleMenu.getMenuId().equals(commonSelectVO.getId())) {
-                    commonSelectVO.setIsSelect(true);
-                }
-            }
-        }
-        List<CommonSelectVO> roots = all.stream().filter(i -> i.getParentId() == 0).collect(Collectors.toList());
-        List<CommonSelectVO> vos = new ArrayList<>();
-        for (CommonSelectVO root : roots) {
-            vos.addAll(this.getMenuVO(root, all));
-        }
-        return vos;
+    public List<CommonVO> roleMenuList(Long roleId, Long hospId) {
+        return baseMapper.getMenuByRoleId(roleId, hospId);
+//        List<Menu> list = menuService.list(
+//                new LambdaQueryWrapper<Menu>().eq(Menu::getHospId, hospId)
+//        );
+//        if (CollUtil.isEmpty(list)) {
+//            return Collections.emptyList();
+//        }
+//        List<CommonSelectVO> all = list.stream().map(i -> {
+//            CommonSelectVO commonSelectVO = new CommonSelectVO();
+//            commonSelectVO.setIsSelect(false);
+//            commonSelectVO.setParentId(i.getParentId());
+//            commonSelectVO.setId(i.getMenuId());
+//            commonSelectVO.setName(i.getName());
+//            return commonSelectVO;
+//        }).collect(Collectors.toList());
+//
+//        List<RoleMenu> roleMenus = this.list(
+//                new LambdaQueryWrapper<RoleMenu>().eq(RoleMenu::getRoleId, roleId)
+//        );
+//        for (CommonSelectVO commonSelectVO : all) {
+//            for (RoleMenu roleMenu : roleMenus) {
+//                if (roleMenu.getMenuId().equals(commonSelectVO.getId())) {
+//                    commonSelectVO.setIsSelect(true);
+//                }
+//            }
+//        }
+//        List<CommonSelectVO> roots = all.stream().filter(i -> i.getParentId() == 0).collect(Collectors.toList());
+//        List<CommonSelectVO> vos = new ArrayList<>();
+//        for (CommonSelectVO root : roots) {
+//            vos.addAll(this.getMenuVO(root, all));
+//        }
+//        return vos;
     }
 
     private List<CommonSelectVO> getMenuVO(CommonSelectVO root, List<CommonSelectVO> all) {

+ 2 - 24
src/main/java/com/imed/costaccount/service/impl/UserRoleServiceImpl.java

@@ -5,7 +5,6 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.imed.costaccount.common.util.PageUtils;
 import com.imed.costaccount.mapper.UserRoleMapper;
 import com.imed.costaccount.model.UserRole;
-import com.imed.costaccount.model.dto.RoleMenuDTO;
 import com.imed.costaccount.model.dto.RoleUserDTO;
 import com.imed.costaccount.model.vo.CommonSelectVO;
 import com.imed.costaccount.model.vo.CommonVO;
@@ -48,33 +47,12 @@ public class UserRoleServiceImpl extends ServiceImpl<UserRoleMapper, UserRole> i
      *
      * @param roleId 角色id
      * @param hospId 医院id
-     * @param page
-     * @param pageSize
      * @return {"id":1,"username":"tom","isSelect": true}
      */
     @Override
-    public PageUtils roleUserList(Long roleId, Long hospId, Integer page, Integer pageSize) {
+    public List<CommonVO> roleUserList(Long roleId, Long hospId) {
         // 得到这个角色下所有人员
-        List<CommonVO> users = this.getUsersByRoleId(roleId, hospId);
-        if (CollUtil.isEmpty(users)) {
-            return new PageUtils(Collections.emptyList(), 0, 0, 0);
-        }
-
-        PageUtils userPages = userService.queryList(page, pageSize, hospId, null);
-        List<UserVO> list = (List<UserVO>) userPages.getList();
-        List<Long> userIds = list.stream().map(UserVO::getId).collect(Collectors.toList());
-
-        List<CommonSelectVO> commonSelectVOS = new ArrayList<>();
-        for (Long userId : userIds) {
-            for (CommonVO user : users) {
-                CommonSelectVO commonSelectVO = new CommonSelectVO(user, false);
-                if (userId.equals(user.getId())) {
-                    commonSelectVO.setIsSelect(true);
-                }
-                commonSelectVOS.add(commonSelectVO);
-            }
-        }
-        return new PageUtils(commonSelectVOS, userPages.getTotalCount(), pageSize, page);
+        return baseMapper.getUsersByRoleId(roleId, hospId);
     }
 
     /**

+ 8 - 4
src/main/java/com/imed/costaccount/web/CostIncomeGroupController.java

@@ -1,9 +1,11 @@
 package com.imed.costaccount.web;
 
+import com.imed.costaccount.common.util.PageUtils;
 import com.imed.costaccount.common.util.Result;
 import com.imed.costaccount.common.util.UserContext;
 import com.imed.costaccount.model.CostIncomeGroup;
 import com.imed.costaccount.service.CostIncomeGroupService;
+import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
@@ -18,24 +20,26 @@ import java.util.Arrays;
  * @date 2021-08-03 16:15:20
  */
 @RestController
-@RequestMapping("/costincomegroup")
+@RequestMapping("/costAccount/costincomegroup")
+@Api(tags = "收入归集操作")
 public class CostIncomeGroupController {
     @Autowired
     private CostIncomeGroupService costIncomeGroupService;
 
     /**
      * 分页查询列表
+     * 根据年月  下拉选择的责任中心Code 会计科目的Code
      */
     @GetMapping("/list")
     @ApiOperation("分页获取收入归集前数据")
     public Result list(@RequestParam(defaultValue = "1", value = "current") Integer current,
                        @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,
-                       @RequestParam(value = "dateTime",required = false) String dateTime,
+                       @RequestParam(value = "dateTime") String dateTime,
                        @RequestParam(value = "responsibilityCode",required = false) String responsibilityCode,
                        @RequestParam(value = "accountCode",required = false) String accountCode){
         Long hospId = UserContext.getHospId();
-
-        return Result.ok();
+        PageUtils pageUtils = costIncomeGroupService.queryList(current,pageSize,dateTime,responsibilityCode,accountCode,hospId);
+        return Result.ok(pageUtils);
     }
 
 

+ 108 - 10
src/main/java/com/imed/costaccount/web/ExcelController.java

@@ -1,13 +1,22 @@
 package com.imed.costaccount.web;
 
+import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.io.FileUtil;
 import cn.hutool.core.io.IoUtil;
 import cn.hutool.poi.excel.ExcelReader;
 import cn.hutool.poi.excel.ExcelUtil;
 import cn.hutool.poi.excel.ExcelWriter;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.imed.costaccount.common.exception.CostException;
 import com.imed.costaccount.common.util.Result;
+import com.imed.costaccount.common.util.UserContext;
+import com.imed.costaccount.constants.NumberConstant;
+import com.imed.costaccount.model.Accounting;
+import com.imed.costaccount.model.AccountingProduct;
+import com.imed.costaccount.model.Product;
 import com.imed.costaccount.model.User;
+import com.imed.costaccount.service.AccountingProductService;
+import com.imed.costaccount.service.AccountingService;
 import com.imed.costaccount.service.UserService;
 import com.imed.costaccount.service.impl.DepartmentServiceImpl;
 import com.imed.costaccount.service.impl.ProductServiceImpl;
@@ -16,7 +25,6 @@ import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.poi.ss.usermodel.Sheet;
 import org.apache.shiro.SecurityUtils;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
 
@@ -25,9 +33,8 @@ import javax.servlet.http.HttpServletResponse;
 import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
-import java.util.Arrays;
-import java.util.List;
-import java.util.UUID;
+import java.util.*;
+import java.util.stream.Collectors;
 
 /**
  * 相关导入导出操作
@@ -38,16 +45,22 @@ import java.util.UUID;
 @RequestMapping("/costAccount/excel")
 public class ExcelController {
 
-    private UserService userService;
+    private final UserService userService;
 
-    @Autowired
-    private DepartmentServiceImpl departmentService;
+    private final DepartmentServiceImpl departmentService;
 
-    @Autowired
-    private ProductServiceImpl productService;
+    private final ProductServiceImpl productService;
 
-    public ExcelController(UserService userService) {
+    private final AccountingService accountingService;
+
+    private final AccountingProductService accountingProductService;
+
+    public ExcelController(UserService userService, DepartmentServiceImpl departmentService, ProductServiceImpl productService, AccountingService accountingService, AccountingProductService accountingProductService) {
         this.userService = userService;
+        this.departmentService = departmentService;
+        this.productService = productService;
+        this.accountingService = accountingService;
+        this.accountingProductService = accountingProductService;
     }
 
     @ApiOperation("用户导出模板设置")
@@ -210,4 +223,89 @@ public class ExcelController {
             throw new CostException(500, "导入失败");
         }
     }
+    /**
+     * 收入成本数据导出模板
+     * @param accountType 1收入数据  2 成本数据(支出数据)
+     */
+    @ApiOperation("收入数据导出模板设置")
+    @GetMapping("/getImportProductAccountTemplate")
+    public void getImportProductAccountTemplate(HttpServletResponse response,Integer accountType) throws IOException {
+        Long hospId = UserContext.getHospId();
+        String uuid = UUID.randomUUID().toString();
+        String url = System.getProperty("java.io.tmpdir") + File.separator + uuid + File.separator + uuid + ".xls";
+        FileUtil.del(FileUtil.file(url));
+
+        ExcelWriter writer = new ExcelWriter(url);
+        // 样式
+        Sheet sheet = writer.getSheet();
+        // 内容
+        writer.merge(0, 1, 0, 6, "为了保证成功导入,请勿修改模板格式", false);
+        writer.passCurrentRow();
+        writer.passCurrentRow();
+        String stateType= NumberConstant.ONE.equals(accountType)?"医院收入数据批量导入":"医院成本数据批量导入";
+        writer.merge(2, 2, 0, 6, stateType, false);
+        writer.passCurrentRow();
+        // 冻结前四行
+        writer.setFreezePane(4);
+        writer.writeRow(Arrays.asList("","","开单科室","开单科室代码", "执行科室","执行科室代码","金额"));
+        // 所有的成本项目
+        List<Product> productList = productService.list(new QueryWrapper<Product>().lambda().eq(Product::getHospId, hospId));
+        // 所有成本会计对照数据
+        List<AccountingProduct> accountingProductList = accountingProductService.list(new QueryWrapper<AccountingProduct>().lambda().eq(AccountingProduct::getHospId, hospId));
+        // 所有会计科目列表数据
+        List<Accounting> accountingList = accountingService.list(new QueryWrapper<Accounting>().lambda().eq(Accounting::getHospId, hospId));
+        List<Product> products = new ArrayList<>();
+        Map<Long, List<AccountingProduct>> accountProductMap = accountingProductList.stream().collect(Collectors.groupingBy(AccountingProduct::getProductId));
+        Map<Long, List<Accounting>> accountMap = accountingList.stream().collect(Collectors.groupingBy(Accounting::getId));
+        productList.forEach(i->{
+            Long productId = i.getId();
+            List<AccountingProduct> accountingProducts = accountProductMap.get(productId);
+            if (CollUtil.isNotEmpty(accountingProducts)){
+                Long accountingId = accountingProducts.get(0).getAccountingId();
+                List<Accounting> accountings = accountMap.get(accountingId);
+                if (CollUtil.isNotEmpty(accountings) && accountType.equals(accountings.get(0).getAccountingType())){
+                    products.add(i);
+                }
+            }
+        });
+        // 写入响应第一列 第二列的数据
+        for (int j = 0; j<products.size(); j++){
+            writer.writeCellValue(0,j+4,productList.get(j).getProductCode());
+            writer.writeCellValue(1,j+4,productList.get(j).getProductName());
+        }
+        writer.setColumnWidth(0,10);
+        writer.setColumnWidth(1,10);
+        writer.setColumnWidth(2,20);
+        writer.setColumnWidth(3,20);
+        writer.setColumnWidth(4,20);
+        writer.setColumnWidth(5,20);
+        writer.setColumnWidth(6,20);
+        response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8");
+        response.setHeader("Content-Disposition", "attachment;filename=" + uuid + ".xls");
+        ServletOutputStream out = null;
+        out = response.getOutputStream();
+        writer.flush(out, true);
+        writer.close();
+        IoUtil.close(out);
+    }
+    /**
+     *  收入成本项目批量导入
+     */
+    @PostMapping("/importProductAccount")
+    @ApiOperation("批量导入收入数据信息")
+    public Result importProductAccount(@RequestParam("file") MultipartFile file){
+        InputStream in;
+        try {
+            in = file.getInputStream();
+            ExcelReader reader = ExcelUtil.getReader(in);
+            List<List<Object>> read = reader.read();
+            log.info("最开始:read={}",read);
+            log.info("-------------------------------------------------------------------");
+            Long hospId = UserContext.getHospId();
+            return productService.importProduct(read, hospId);
+        }catch (IOException e){
+            e.printStackTrace();;
+            throw new CostException(500, "导入失败");
+        }
+    }
 }

+ 60 - 12
src/main/java/com/imed/costaccount/web/ReportFormController.java

@@ -2,15 +2,21 @@ package com.imed.costaccount.web;
 
 import com.imed.costaccount.common.util.PageUtils;
 import com.imed.costaccount.common.util.Result;
-import com.imed.costaccount.model.ReportForm;
+import com.imed.costaccount.model.dto.ReportFormEditDTO;
 import com.imed.costaccount.model.dto.ReportFormSaveDTO;
+import com.imed.costaccount.model.dto.ReportRelationDTO;
+import com.imed.costaccount.model.vo.RelationVO;
 import com.imed.costaccount.model.vo.ReportFormVO;
 import com.imed.costaccount.service.ReportFormService;
+import com.imed.costaccount.service.ReportRelationService;
 import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.web.bind.annotation.*;
 
 import javax.validation.Valid;
+import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
 
@@ -21,15 +27,17 @@ import java.util.List;
  * @author huangrui
  * @date 2021-08-03 13:53:52
  */
-@Api(tags="报表项目")
+@Api(tags = "报表项目")
 @RestController
 @RequestMapping("/costAccount/reportForm/")
-public class ReportFormController extends AbstractController{
+public class ReportFormController extends AbstractController {
 
     private final ReportFormService reportFormService;
+    private final ReportRelationService reportRelationService;
 
-    public ReportFormController(ReportFormService reportFormService) {
+    public ReportFormController(ReportFormService reportFormService, ReportRelationService reportRelationService) {
         this.reportFormService = reportFormService;
+        this.reportRelationService = reportRelationService;
     }
 
     /**
@@ -48,27 +56,67 @@ public class ReportFormController extends AbstractController{
      */
     @ApiOperation("保存报表项目")
     @PostMapping("/save")
-    public Result save(@RequestBody @Valid ReportFormSaveDTO reportFormDTO){
-//		reportFormService.save(reportForm);
+    public Result save(@RequestBody @Valid ReportFormSaveDTO reportFormDTO) {
+        reportFormService.saveReport(reportFormDTO, getHospId());
         return Result.ok();
     }
 
     /**
      * 修改
      */
-    @RequestMapping("/update")
-    public Result update(@RequestBody ReportForm reportForm){
-		reportFormService.updateById(reportForm);
+    @ApiOperation("修改报表项目设置")
+    @PostMapping("/edit")
+    public Result update(@RequestBody @Valid ReportFormEditDTO formEditDTO) {
+        reportFormService.updateReport(formEditDTO);
         return Result.ok();
     }
 
     /**
      * 删除
      */
-    @RequestMapping("/delete")
-    public Result delete(@RequestBody Long[] ids){
-		reportFormService.removeByIds(Arrays.asList(ids));
+    @ApiOperation("删除某个报表项目")
+    @PostMapping("/delete")
+    public Result delete(@RequestBody Long[] ids) {
+        reportFormService.removeByIds(Arrays.asList(ids));
         return Result.ok();
     }
 
+
+    @ApiOperation("编辑对应的报表项目和对应的会计或者分摊参数")
+    @PostMapping("/saveReportRelation")
+    public Result saveReportRelation(@RequestBody @Valid ReportRelationDTO reportRelationDTO) {
+        reportRelationService.saveReportRelation(reportRelationDTO,getHospId());
+        return Result.ok();
+    }
+
+    @ApiOperation("获取已绑定的关系列表")
+    @GetMapping("/getRelations")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "reportId", value = "报表项目id"),
+            @ApiImplicitParam(name = "relation", value = "1.对应会计科目设置,2.对应分摊参数设置,根据列表中showAddRelation字段是否存在判断")
+    })
+    public Result getRelations(@RequestParam Long reportId, @RequestParam Integer relation) {
+        List<RelationVO> list = new ArrayList<>();
+        Long hospId = getHospId();
+        if (relation == 1) {
+            list = reportRelationService.getAccountRelation(reportId, hospId);
+        }
+        if (relation == 2) {
+            list = reportRelationService.getShareParam(reportId, hospId);
+        }
+        return Result.ok(list);
+    }
+
+    @ApiOperation("根据关系类型,获取可绑定的关系数据(包含回显)")
+    @GetMapping("/getRelationList")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "reportId", value = "报表项目id"),
+            @ApiImplicitParam(name = "relation", value = "1.对应会计科目设置,2.对应分摊参数设置,根据列表中showAddRelation字段是否存在判断")
+    })
+    public Result getRelationList(@RequestParam Long reportId, @RequestParam Integer relation) {
+        List<RelationVO> list = reportRelationService.getRelationList(reportId, relation, getHospId());
+        return Result.ok(list);
+    }
+
+
 }

+ 3 - 5
src/main/java/com/imed/costaccount/web/RoleController.java

@@ -83,10 +83,8 @@ public class RoleController extends AbstractController {
 
     @ApiOperation("绑定角色和人员关系时选择列表(可回显)")
     @GetMapping("/roleUserList")
-    public Result roleUserList(@RequestParam Long roleId,
-                               @RequestParam(defaultValue = "1", value = "current") Integer page,
-                               @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
-        PageUtils list = userRoleService.roleUserList(roleId, getUser().getHospId(),page,pageSize);
+    public Result roleUserList(@RequestParam Long roleId) {
+        List<?> list = userRoleService.roleUserList(roleId, getUser().getHospId());
         return Result.ok(list);
     }
 
@@ -100,7 +98,7 @@ public class RoleController extends AbstractController {
     @ApiOperation("绑定角色和菜单关系时选择列表可回显")
     @GetMapping("/roleMenuList")
     public Result roleMenuList(@RequestParam Long roleId) {
-        List<CommonSelectVO> list = roleMenuService.roleMenuList(roleId, getUser().getHospId());
+        List<CommonVO> list = roleMenuService.roleMenuList(roleId, getUser().getHospId());
         return Result.ok(list);
     }
 

+ 15 - 0
src/main/resources/mapper/CostIncomeGroupMapper.xml

@@ -13,6 +13,8 @@
         <result property="productCode" column="product_code"/>
         <result property="accountCode" column="account_code"/>
         <result property="isIncome" column="is_income"/>
+        <result property="openDepartmentAmount" column="open_department_amount"/>
+        <result property="startDepartmentAmount" column="start_department_amount"/>
         <result property="amount" column="amount"/>
         <result property="hospId" column="hosp_id"/>
         <result property="dateYear" column="date_year"/>
@@ -20,6 +22,19 @@
         <result property="createTime" column="create_time"/>
         <result property="deleteTime" column="delete_time"/>
     </resultMap>
+    <sql id="Base_Column_List" >
+    id, open_department_code, open_responsibility_code, start_department_code, start_responsibility_code, product_code, account_code, is_income,
+    open_department_amount, start_department_amount, amount, hosp_id, date_year, date_month, create_time,
+    delete_time
+  </sql>
+
+    <select id="countMoney" resultType="com.imed.costaccount.model.vo.CostIncomeGroupAllAmountVO">
+        select
+        <include refid="Base_Column_List"/>
+        ,group_concat(amount) as addMoney
+        from cost_income_group
+        group by open_department_code , start_department_code , product_code;
+    </select>
 
 
 </mapper>

+ 1 - 1
src/main/resources/mapper/RoleMenuMapper.xml

@@ -10,7 +10,7 @@
         <result property="menuId" column="menu_id"/>
         <result property="hospId" column="hosp_id"/>
     </resultMap>
-    <select id="getUsersByRoleId" resultType="com.imed.costaccount.model.vo.CommonVO">
+    <select id="getMenuByRoleId" resultType="com.imed.costaccount.model.vo.CommonVO">
         select sm.menu_id as id, sm.name as name
         from sys_role_menu srm left join sys_menu sm
         on sm.menu_id = srm.menu_id