|
@@ -29,11 +29,13 @@ import java.math.BigDecimal;
|
|
|
import java.math.RoundingMode;
|
|
|
import java.sql.Timestamp;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
+import java.time.LocalDate;
|
|
|
+import java.time.temporal.TemporalAdjusters;
|
|
|
import java.util.*;
|
|
|
|
|
|
/**
|
|
|
* <p>
|
|
|
- * 服务实现类
|
|
|
+ * 服务实现类
|
|
|
* </p>
|
|
|
*
|
|
|
* @author 沈晔浩
|
|
@@ -52,10 +54,10 @@ public class BorrowApplyServiceImpl extends ServiceImpl<BorrowApplyMapper, Borro
|
|
|
Integer pageSize = Integer.valueOf(map.get("pageSize").toString());
|
|
|
PageHelper.startPage(current, pageSize);
|
|
|
Page<Map> list = borrowApplyMapper.getList(map);
|
|
|
- if (list!=null) {
|
|
|
+ if (list != null) {
|
|
|
return new ResultMsg<>(ResultState.SUCCESS, null, JSONObject.toJSONString(list), list.getPageNum(), list.getTotal(), list.getPageSize(), list.getPages()).toPageJSON();
|
|
|
}
|
|
|
- }catch (Exception e){
|
|
|
+ } catch (Exception e) {
|
|
|
return new ResultMsg<String>().setCode(ResultState.ERROR).setMsg("服务器出错").toJSON();
|
|
|
}
|
|
|
return new ResultMsg<String>().setCode(ResultState.SUCCESS).setMsg("无数据").toJSON();
|
|
@@ -66,13 +68,13 @@ public class BorrowApplyServiceImpl extends ServiceImpl<BorrowApplyMapper, Borro
|
|
|
try {
|
|
|
Integer current = Integer.valueOf(map.get("current").toString());
|
|
|
Integer pageSize = Integer.valueOf(map.get("pageSize").toString());
|
|
|
- map.put("borrowStatus","");
|
|
|
+ map.put("borrowStatus", "");
|
|
|
PageHelper.startPage(current, pageSize);
|
|
|
Page<Map> list = borrowApplyMapper.getListForRange(map);
|
|
|
- if (list!=null) {
|
|
|
+ if (list != null) {
|
|
|
return new ResultMsg<>(ResultState.SUCCESS, null, JSONObject.toJSONString(list), list.getPageNum(), list.getTotal(), list.getPageSize(), list.getPages()).toPageJSON();
|
|
|
}
|
|
|
- }catch (Exception e){
|
|
|
+ } catch (Exception e) {
|
|
|
return new ResultMsg<String>().setCode(ResultState.ERROR).setMsg("服务器出错").toJSON();
|
|
|
}
|
|
|
return new ResultMsg<String>().setCode(ResultState.SUCCESS).setMsg("无数据").toJSON();
|
|
@@ -82,13 +84,13 @@ public class BorrowApplyServiceImpl extends ServiceImpl<BorrowApplyMapper, Borro
|
|
|
public String getInfoById(BorrowApply borrowApply) {
|
|
|
Map map1 = borrowApplyMapper.getInfoById(borrowApply.getBorrowApplyId());
|
|
|
Map data = TestData.getProjectInfo(map1.get("projectCode").toString());
|
|
|
- if (data!=null) {
|
|
|
+ if (data != null) {
|
|
|
for (Object obj : data.keySet()) {
|
|
|
map1.put(obj, data.get(obj));
|
|
|
}
|
|
|
}
|
|
|
List result = new ArrayList();
|
|
|
- if (map1!=null) {
|
|
|
+ if (map1 != null) {
|
|
|
result.add(map1);
|
|
|
}
|
|
|
return new ResultMsg<>().setCode(ResultState.SUCCESS).setData(result).toJSON();
|
|
@@ -96,24 +98,25 @@ public class BorrowApplyServiceImpl extends ServiceImpl<BorrowApplyMapper, Borro
|
|
|
|
|
|
@Override
|
|
|
public String saveFile(BorrowApply borrowApply) {
|
|
|
- String fileName = "常规申请"+(new Date().getTime())+".csv";
|
|
|
+ String fileName = "常规申请" + (new Date().getTime()) + ".csv";
|
|
|
List<Map> list = new ArrayList<>();
|
|
|
Map map = new HashMap();
|
|
|
- map.put("项目编号",borrowApply.getTmpCode()==null?borrowApply.getProjectCode():borrowApply.getTmpCode());
|
|
|
- map.put("数据范围",borrowApply.getDataRange());
|
|
|
- map.put("申请理由",borrowApply.getApplyReason());
|
|
|
- map.put("期限说明材料",borrowApply.getDeadlineMaterials());
|
|
|
- map.put("借阅期限",borrowApply.getBorrowDeadline());
|
|
|
- map.put("借阅数据",borrowApply.getBorrowData());
|
|
|
+ map.put("项目编号", borrowApply.getTmpCode() == null ? borrowApply.getProjectCode() : borrowApply.getTmpCode());
|
|
|
+ map.put("数据范围", borrowApply.getDataRange());
|
|
|
+ map.put("申请理由", borrowApply.getApplyReason());
|
|
|
+ map.put("期限说明材料", borrowApply.getDeadlineMaterials());
|
|
|
+ map.put("借阅期限", borrowApply.getBorrowDeadline());
|
|
|
+ map.put("借阅数据", borrowApply.getBorrowData());
|
|
|
list.add(map);
|
|
|
- CSVUtil.writeFileForMap("D:\\file\\"+fileName,list);
|
|
|
- String url = "http://47.101.207.123:8080/file/"+fileName;
|
|
|
+ CSVUtil.writeFileForMap("D:\\file\\" + fileName, list);
|
|
|
+ String url = "http://47.101.207.123:8080/file/" + fileName;
|
|
|
List result = new ArrayList();
|
|
|
Map map1 = new HashMap();
|
|
|
- map1.put("url",url);
|
|
|
+ map1.put("url", url);
|
|
|
result.add(map1);
|
|
|
return new ResultMsg<>().setCode(ResultState.SUCCESS).setData(result).toJSON();
|
|
|
}
|
|
|
+
|
|
|
//借阅量(常规)
|
|
|
@Override
|
|
|
public String getCountList() {
|
|
@@ -133,7 +136,7 @@ public class BorrowApplyServiceImpl extends ServiceImpl<BorrowApplyMapper, Borro
|
|
|
|
|
|
for (Map data : unitCountList) {
|
|
|
|
|
|
- BigDecimal borrowCount = new BigDecimal((Long)data.get("borrowCount"));
|
|
|
+ BigDecimal borrowCount = new BigDecimal((Long) data.get("borrowCount"));
|
|
|
|
|
|
total = total.add(borrowCount);
|
|
|
|
|
@@ -152,9 +155,9 @@ public class BorrowApplyServiceImpl extends ServiceImpl<BorrowApplyMapper, Borro
|
|
|
data.put("percentage", subtract);
|
|
|
|
|
|
} else {
|
|
|
- BigDecimal count = new BigDecimal((Long)data.get("borrowCount"));
|
|
|
+ BigDecimal count = new BigDecimal((Long) data.get("borrowCount"));
|
|
|
|
|
|
- BigDecimal percentage = count.divide(total, 4, RoundingMode.CEILING);
|
|
|
+ BigDecimal percentage = count.divide(total, 4, RoundingMode.CEILING);
|
|
|
|
|
|
temp = temp.add(percentage);
|
|
|
|
|
@@ -167,14 +170,58 @@ public class BorrowApplyServiceImpl extends ServiceImpl<BorrowApplyMapper, Borro
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public String getApplyTimeCountList(Integer start,Integer num) {
|
|
|
- List<Map> TimeCountList = borrowApplyMapper.getApplyTimeCountList(start,num);
|
|
|
- return new ResultMsg<>().setCode(ResultState.SUCCESS).setData(TimeCountList).toJSON();
|
|
|
+ public String getApplyTimeCountList(Integer start, Integer num) {
|
|
|
+ List<Map> timeCountList = borrowApplyMapper.getApplyTimeCountList(start, num);
|
|
|
+ List<Map> result = new ArrayList<>();
|
|
|
+ LocalDate date = LocalDate.now();
|
|
|
+ LocalDate lastDay = date.with(TemporalAdjusters.lastDayOfMonth());
|
|
|
+ System.out.println(lastDay.getDayOfMonth());
|
|
|
+ int MonthDay=lastDay.getDayOfMonth();
|
|
|
+ //年填充字段
|
|
|
+ if (start == 0 && num == 0) {
|
|
|
+ for (int i = 1; i <= 12; i++) {
|
|
|
+ Map<String,Integer> temp = new HashMap();
|
|
|
+ temp.put("applyTime", i);
|
|
|
+ temp.put("borrowCount", 0);
|
|
|
+ result.add(temp);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //日填充字段
|
|
|
+ else if(start == 6 && num == 6){
|
|
|
+ for (int i = 1; i <= 24; i++) {
|
|
|
+ Map<String,Integer> temp = new HashMap();
|
|
|
+ temp.put("applyTime", i);
|
|
|
+ temp.put("borrowCount", 0);
|
|
|
+ result.add(temp);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //月填充字段
|
|
|
+ else if(start == 3 && num == 3){
|
|
|
+ for (int i = 1; i <=MonthDay ; i++) {
|
|
|
+ Map<String,Integer> temp = new HashMap();
|
|
|
+ temp.put("applyTime", i);
|
|
|
+ temp.put("borrowCount", 0);
|
|
|
+ result.add(temp);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for (Map<String,String> data : timeCountList){
|
|
|
+
|
|
|
+ Integer idx=Integer.valueOf(data.get("applyTime"));
|
|
|
+
|
|
|
+ if (Integer.valueOf(data.get("applyTime")) == idx) {
|
|
|
+ Map map = result.get(idx - 1);
|
|
|
+
|
|
|
+ map.put("borrowCount",data.get("borrowCount"));
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ return new ResultMsg<>().setCode(ResultState.SUCCESS).setData(result).toJSON();
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public String getApplyTimeByPeriod(Timestamp start, Timestamp end) {
|
|
|
- List<Map> TimeByPeriodList = borrowApplyMapper.getApplyTimeByPeriod(start,end);
|
|
|
+ List<Map> TimeByPeriodList = borrowApplyMapper.getApplyTimeByPeriod(start, end);
|
|
|
return new ResultMsg<>().setCode(ResultState.SUCCESS).setData(TimeByPeriodList).toJSON();
|
|
|
}
|
|
|
|