|
|
@@ -17,18 +17,21 @@
|
|
|
package org.springblade.bank.checklist.controller;
|
|
|
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import io.swagger.annotations.ApiParam;
|
|
|
-import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
-import javax.validation.Valid;
|
|
|
-
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
-import org.springblade.bank.keypwd.entity.KeyPwd;
|
|
|
-import org.springblade.bank.sealhandover.entity.SealHandover;
|
|
|
+import org.springblade.bank.checklist.entity.Checklist;
|
|
|
+import org.springblade.bank.checklist.service.IChecklistService;
|
|
|
+import org.springblade.bank.checklist.vo.ChecklistVO;
|
|
|
+import org.springblade.bank.checklist.wrapper.ChecklistWrapper;
|
|
|
import org.springblade.bank.userlog.entity.UserLog;
|
|
|
import org.springblade.bank.userlog.service.IUserLogService;
|
|
|
+import org.springblade.common.utils.CommonUtil;
|
|
|
+import org.springblade.core.boot.ctrl.BladeController;
|
|
|
import org.springblade.core.mp.support.Condition;
|
|
|
import org.springblade.core.mp.support.Query;
|
|
|
import org.springblade.core.secure.BladeUser;
|
|
|
@@ -43,16 +46,11 @@ import org.springblade.modules.system.service.IDeptService;
|
|
|
import org.springblade.modules.system.service.IDictService;
|
|
|
import org.springblade.modules.system.service.IUserService;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
-import org.springframework.web.bind.annotation.RequestParam;
|
|
|
-import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
-import org.springblade.bank.checklist.entity.Checklist;
|
|
|
-import org.springblade.bank.checklist.vo.ChecklistVO;
|
|
|
-import org.springblade.bank.checklist.wrapper.ChecklistWrapper;
|
|
|
-import org.springblade.bank.checklist.service.IChecklistService;
|
|
|
-import org.springblade.core.boot.ctrl.BladeController;
|
|
|
|
|
|
-import java.text.SimpleDateFormat;
|
|
|
-import java.util.*;
|
|
|
+import javax.validation.Valid;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
|
|
|
/**
|
|
|
* 每日/週/月核對記錄表 控制器
|
|
|
@@ -72,8 +70,6 @@ public class ChecklistController extends BladeController {
|
|
|
private final IUserLogService userLogService;
|
|
|
private final IDictService dictService;
|
|
|
|
|
|
- private final String pattern = "yyyy-MM-dd";
|
|
|
-
|
|
|
/**
|
|
|
* 详情
|
|
|
*/
|
|
|
@@ -244,39 +240,39 @@ public class ChecklistController extends BladeController {
|
|
|
// checklist.setDate_end(getNextDay(checklist.getDate_end()));
|
|
|
}else{
|
|
|
// 默认是当天
|
|
|
- String today = DateUtil.format(DateUtil.now(), pattern);
|
|
|
+ String today = DateUtil.format(DateUtil.now(), CommonUtil.pattern);
|
|
|
checklist.setDate_begin(today);
|
|
|
checklist.setDate_end(today);
|
|
|
}
|
|
|
|
|
|
String dateBegin = checklist.getDate_begin();
|
|
|
String dateEnd = checklist.getDate_end();
|
|
|
- long days = getInterval(dateBegin, dateEnd);
|
|
|
+ long days = CommonUtil.getInterval(dateBegin, dateEnd);
|
|
|
|
|
|
String dataType = checklist.getCycle();
|
|
|
if (dataType.equals("day")){
|
|
|
for (int i = 0; i <= days; i++) {
|
|
|
- String theDay = getDay(dateBegin, i);
|
|
|
+ String theDay = CommonUtil.getDay(dateBegin, i);
|
|
|
// 延长一天,是为了sql可以查询出最后一天的记录
|
|
|
- String nextDay = getDay(dateBegin, i + 1);
|
|
|
+ String nextDay = CommonUtil.getDay(dateBegin, i + 1);
|
|
|
checklist.setDate_begin(theDay);
|
|
|
checklist.setDate_end(nextDay);
|
|
|
|
|
|
- List<Map> reportData = getReportData(checklist, dataType, theDay, dept, check_category, check_item);
|
|
|
+ List<Map> reportData = checklistService.getReportData(checklist, dataType, theDay, dept, check_category, check_item);
|
|
|
list.addAll(reportData);
|
|
|
}
|
|
|
}else if (dataType.equals("week")){
|
|
|
- String[] weekRange = getWeekRange(checklist.getDate_begin());
|
|
|
+ String[] weekRange = CommonUtil.getWeekRange(checklist.getDate_begin());
|
|
|
checklist.setDate_begin(weekRange[0]);
|
|
|
checklist.setDate_end(weekRange[1]);
|
|
|
|
|
|
- List<Map> reportData = getReportData(checklist, dataType, null, dept, check_category, check_item);
|
|
|
+ List<Map> reportData = checklistService.getReportData(checklist, dataType, null, dept, check_category, check_item);
|
|
|
list.addAll(reportData);
|
|
|
}else {
|
|
|
- String[] monthRange = getMonthRange(checklist.getDate_begin());
|
|
|
+ String[] monthRange = CommonUtil.getMonthRange(checklist.getDate_begin());
|
|
|
checklist.setDate_begin(monthRange[0]);
|
|
|
checklist.setDate_end(monthRange[1]);
|
|
|
- List<Map> reportData = getReportData(checklist, dataType, null, dept, check_category, check_item);
|
|
|
+ List<Map> reportData = checklistService.getReportData(checklist, dataType, null, dept, check_category, check_item);
|
|
|
list.addAll(reportData);
|
|
|
}
|
|
|
|
|
|
@@ -290,124 +286,10 @@ public class ChecklistController extends BladeController {
|
|
|
@ApiOperation(value = "分页", notes = "传入checklist")
|
|
|
public R getReport(ChecklistVO checklist) {
|
|
|
|
|
|
- List<Map> list = new ArrayList<>();
|
|
|
- List<Dict> check_category = dictService.getList("check_category");
|
|
|
- List<Dict> check_item = dictService.getList("check_item");
|
|
|
- List<Long> deptChildIds = new ArrayList<>();
|
|
|
- if (checklist.getOrgNo() == null){
|
|
|
- Dept dept = deptService.getById(AuthUtil.getDeptId());
|
|
|
- deptChildIds = deptService.getDeptChildIds(dept.getId());
|
|
|
- }else {
|
|
|
- Dept dept = deptService.getByOrgNo(checklist.getOrgNo());
|
|
|
- deptChildIds.add(dept.getId());
|
|
|
- }
|
|
|
-
|
|
|
- if (checklist.getCycle() == null){
|
|
|
- checklist.setCycle("day");
|
|
|
- }
|
|
|
-
|
|
|
- if (StringUtils.isNotBlank(checklist.getDate_begin()) && StringUtils.isNotBlank(checklist.getDate_end())){
|
|
|
- // 延长一天,是为了sql可以查询出最后一天的记录
|
|
|
-// checklist.setDate_end(getNextDay(checklist.getDate_end()));
|
|
|
- }else{
|
|
|
- // 默认是当天
|
|
|
- String today = DateUtil.format(DateUtil.now(), pattern);
|
|
|
- checklist.setDate_begin(today);
|
|
|
- checklist.setDate_end(today);
|
|
|
- }
|
|
|
-
|
|
|
- String dateBegin = checklist.getDate_begin();
|
|
|
- String dateEnd = checklist.getDate_end();
|
|
|
- long days = getInterval(dateBegin, dateEnd);
|
|
|
-
|
|
|
- String dataType = checklist.getCycle();
|
|
|
- if (dataType.equals("day")){
|
|
|
- for (int i = 0; i <= days; i++) {
|
|
|
- String theDay = getDay(dateBegin, i);
|
|
|
- // 延长一天,是为了sql可以查询出最后一天的记录
|
|
|
-// String nextDay = getDay(dateBegin, i + 1);
|
|
|
- checklist.setDate_begin(theDay);
|
|
|
- checklist.setDate_end(theDay);
|
|
|
-
|
|
|
- deptChildIds.forEach(deptId -> {
|
|
|
- List<Map> reportData = getReportData(checklist, dataType, theDay, deptService.getById(deptId), check_category, check_item);
|
|
|
- list.addAll(reportData);
|
|
|
- });
|
|
|
- }
|
|
|
- }else if (dataType.equals("week")){
|
|
|
- String[] weekRange = getWeekRange(checklist.getDate_begin());
|
|
|
- checklist.setDate_begin(weekRange[0]);
|
|
|
- checklist.setDate_end(weekRange[1]);
|
|
|
-
|
|
|
-
|
|
|
- deptChildIds.forEach(deptId -> {
|
|
|
- List<Map> reportData = getReportData(checklist, dataType, null, deptService.getById(deptId), check_category, check_item);
|
|
|
- list.addAll(reportData);
|
|
|
- });
|
|
|
- }else {
|
|
|
- String[] monthRange = getMonthRange(checklist.getDate_begin());
|
|
|
- checklist.setDate_begin(monthRange[0]);
|
|
|
- checklist.setDate_end(monthRange[1]);
|
|
|
-
|
|
|
- deptChildIds.forEach(deptId -> {
|
|
|
- List<Map> reportData = getReportData(checklist, dataType, null, deptService.getById(deptId), check_category, check_item);
|
|
|
- list.addAll(reportData);
|
|
|
- });
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- return R.data(list);
|
|
|
+ List<Map> reportList = checklistService.getReport(checklist);
|
|
|
+ return R.data(reportList);
|
|
|
}
|
|
|
|
|
|
- private List<Map> getReportData(ChecklistVO checklist, String dataType, String theDay, Dept dept, List<Dict> check_category, List<Dict> check_item){
|
|
|
- List<Map> list = new ArrayList<>();
|
|
|
- check_category.forEach(category -> {
|
|
|
- check_item.forEach(item -> {
|
|
|
- if (category.getIsSealed().equals(0) && item.getIsSealed().equals(0)){
|
|
|
- if (category.getDictKey().contains(dataType) && item.getDictKey().contains(dataType) && item.getDictKey().contains(category.getDictKey())){
|
|
|
- if (!dept.getOrgNo().startsWith("999") && !dept.getOrgNo().equals("51614")){
|
|
|
- Map row = new HashMap();
|
|
|
- row.put("orgNo", dept.getOrgNo());
|
|
|
- row.put("deptName", dept.getDeptName());
|
|
|
- row.put("type", category.getDictKey());
|
|
|
- row.put("item", item.getDictKey());
|
|
|
-
|
|
|
- checklist.setType(category.getDictKey());
|
|
|
- checklist.setItem(item.getDictKey());
|
|
|
- checklist.setOrgNo(dept.getOrgNo());
|
|
|
- // checklist.setIsChecked(1);
|
|
|
- List<ChecklistVO> dataList = checklistService.getDataList(checklist);
|
|
|
- int checkedCount = dataList.size();
|
|
|
- List<ChecklistVO> dlistOver = checklistService.getOverList(checklist);
|
|
|
- int overCount = dlistOver.size();
|
|
|
- int nocheckCount = (checkedCount > 0 || overCount > 0) ? 0 : 1;
|
|
|
- if (checkedCount > 0){
|
|
|
- Checklist one = dataList.get(0);
|
|
|
- row.put("checkDate", DateUtil.format(one.getCheckDate(), pattern));
|
|
|
- }
|
|
|
- if (overCount > 0){
|
|
|
- Checklist one = dlistOver.get(0);
|
|
|
- row.put("checkDate", DateUtil.format(one.getCheckDate(), pattern));
|
|
|
- }
|
|
|
-
|
|
|
- if ("day".equals(dataType)){
|
|
|
- row.put("needCheckDate", theDay);
|
|
|
- }
|
|
|
-
|
|
|
- row.put("checked", checkedCount);
|
|
|
- row.put("nocheck", nocheckCount);
|
|
|
- row.put("over", dlistOver.size());
|
|
|
- list.add(row);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
- });
|
|
|
-
|
|
|
- return list;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
@GetMapping("/getList")
|
|
|
@ApiOperationSupport(order = 3)
|
|
|
@ApiOperation(value = "分页", notes = "传入checklist")
|
|
|
@@ -438,89 +320,4 @@ public class ChecklistController extends BladeController {
|
|
|
return R.data(list);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- /**
|
|
|
- * 获取传入时间的第二天
|
|
|
- * @param today
|
|
|
- * @return
|
|
|
- */
|
|
|
- private String getNextDay(String today){
|
|
|
- Calendar cd = Calendar.getInstance();
|
|
|
- cd.setTime(DateUtil.parse(today, pattern));
|
|
|
- cd.add(Calendar.DATE, 1);
|
|
|
- String nextDay = DateUtil.format(cd.getTime(), pattern);
|
|
|
- return nextDay;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 计算传入时间的相对位移时间,后几天或者前几天
|
|
|
- * @param theDay
|
|
|
- * @param interval
|
|
|
- * @return
|
|
|
- */
|
|
|
- private String getDay(String theDay, int interval){
|
|
|
- Calendar cd = Calendar.getInstance();
|
|
|
- cd.setTime(DateUtil.parse(theDay, pattern));
|
|
|
- cd.add(Calendar.DATE, interval);
|
|
|
- String ThatDay = DateUtil.format(cd.getTime(), pattern);
|
|
|
- return ThatDay;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 计算两个日期相差天数
|
|
|
- * @param beginDate
|
|
|
- * @param endDate
|
|
|
- * @return
|
|
|
- */
|
|
|
- private long getInterval(String beginDate, String endDate){
|
|
|
- Date begin = DateUtil.parse(beginDate, pattern);
|
|
|
- Date end = DateUtil.parse(endDate, pattern);
|
|
|
- return (end.getTime() - begin.getTime()) / (24 * 60 * 60 * 1000);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 根据传入时间,算出这周开始日期和结束日期
|
|
|
- * @param theDay
|
|
|
- * @return
|
|
|
- */
|
|
|
- private String[] getWeekRange(String theDay){
|
|
|
- SimpleDateFormat format = new SimpleDateFormat(pattern);
|
|
|
- Calendar cal = Calendar.getInstance();
|
|
|
- cal.setTime(DateUtil.parse(theDay, pattern));
|
|
|
- int w = cal.get(Calendar.DAY_OF_WEEK) - 1; // 指示一个星期中的某天。
|
|
|
- int[] weekDays = { 7, 1, 2, 3, 4, 5, 6 };
|
|
|
- int today = weekDays[w];
|
|
|
- int begin = today == 7 ? 0 : -today;
|
|
|
- int end = today == 7 ? 6 : 6 - today;
|
|
|
-
|
|
|
- Calendar beginDate = Calendar.getInstance();
|
|
|
- beginDate.setTime(DateUtil.parse(theDay, pattern));
|
|
|
- Calendar endDate = Calendar.getInstance();
|
|
|
- endDate.setTime(DateUtil.parse(theDay, pattern));
|
|
|
- beginDate.add(Calendar.DAY_OF_MONTH, begin);
|
|
|
- endDate.add(Calendar.DAY_OF_MONTH, end);
|
|
|
-
|
|
|
- String beginDateStr = format.format(beginDate.getTime());
|
|
|
- String endDateStr = format.format(endDate.getTime());
|
|
|
- return new String[]{beginDateStr, endDateStr};
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 根据传入时间,算出这个月的开始日期和结束日期
|
|
|
- * @param theDay
|
|
|
- * @return
|
|
|
- */
|
|
|
- private String[] getMonthRange(String theDay){
|
|
|
- String[] split = theDay.split("-");
|
|
|
- String beginDateStr = split[0] + "-" + split[1] + "-" + "01";
|
|
|
-
|
|
|
- Calendar endDate = Calendar.getInstance();
|
|
|
- endDate.setTime(DateUtil.parse(theDay, pattern));
|
|
|
- endDate.add(Calendar.MONTH, 1);
|
|
|
- endDate.add(Calendar.DATE, -1);
|
|
|
- String endDateStr = DateUtil.format(endDate.getTime(), pattern);
|
|
|
-
|
|
|
- return new String[]{beginDateStr, endDateStr};
|
|
|
- }
|
|
|
-
|
|
|
}
|