提交 e5967d9f authored 作者: gongwenjie's avatar gongwenjie

Merge branch 'master' of git.yfzx.zjtys.com.cn:zjm/notes2.0

# Conflicts: # notes-attendance/src/main/java/com/zjty/tynotes/attendance/controller/AttendanceController.java
...@@ -4,7 +4,6 @@ import com.zjty.tynotes.attendance.entity.ApprovalInformation; ...@@ -4,7 +4,6 @@ import com.zjty.tynotes.attendance.entity.ApprovalInformation;
import com.zjty.tynotes.attendance.entity.vo.request.AttenRequest; import com.zjty.tynotes.attendance.entity.vo.request.AttenRequest;
import com.zjty.tynotes.attendance.service.AttendanceDetailsService; import com.zjty.tynotes.attendance.service.AttendanceDetailsService;
import com.zjty.tynotes.misc.config.AutoDocument; import com.zjty.tynotes.misc.config.AutoDocument;
import com.zjty.tynotes.pas.entity.User;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -38,11 +37,4 @@ public class AttendanceController { ...@@ -38,11 +37,4 @@ public class AttendanceController {
return ok(attendanceDetailsService.findDepartment(request)); return ok(attendanceDetailsService.findDepartment(request));
} }
@ApiOperation(value = "根据权限查询可查看部门列表", response = User.class)
@GetMapping("/findDepartmentList/{id}")
public ResponseEntity findDepartmentList(@PathVariable("id") String id) {
return ok(attendanceDetailsService.findDepartmentList(id));
}
} }
package com.zjty.tynotes.attendance.entity.exl;
import cn.afterturn.easypoi.excel.annotation.Excel;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.data.mongodb.core.mapping.Document;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class DepartmentExl {
@Excel(name = "用户姓名", orderNum = "1", width = 20)
private String name;
@Excel(name = "应出勤天数", orderNum = "2", width = 20)
private Integer attendanceDay;
@Excel(name = "实际出勤天数", orderNum = "3", width = 20)
private Float realAttendanceDay;
@Excel(name = "公出天数", orderNum = "4", width = 20)
private Float reasonableOutWorkDay;
@Excel(name = "迟到天数", orderNum = "5", width = 20)
private Integer lateDay;
@Excel(name = "早退天数", orderNum = "6", width = 20)
private Integer earlyDay;
@Excel(name = "出差天数", orderNum = "7", width = 20)
private Float outWorkDay;
@Excel(name = "请假天数", orderNum = "8", width = 20)
private Float offFromWorkDay;
}
...@@ -4,6 +4,8 @@ import com.zjty.tynotes.job.basic.entity.database.Work; ...@@ -4,6 +4,8 @@ import com.zjty.tynotes.job.basic.entity.database.Work;
import com.zjty.tynotes.job.basic.repository.WorkRepository; import com.zjty.tynotes.job.basic.repository.WorkRepository;
import com.zjty.tynotes.job.basic.service.PriviceService; import com.zjty.tynotes.job.basic.service.PriviceService;
import com.zjty.tynotes.job.common.exception.NotFoundException; import com.zjty.tynotes.job.common.exception.NotFoundException;
import com.zjty.tynotes.pas.service.IUserService;
import org.reactivestreams.Publisher;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -11,6 +13,9 @@ import org.springframework.stereotype.Service; ...@@ -11,6 +13,9 @@ import org.springframework.stereotype.Service;
public class PriviceServiceImpl implements PriviceService { public class PriviceServiceImpl implements PriviceService {
@Autowired @Autowired
WorkRepository workRepository; WorkRepository workRepository;
@Autowired
IUserService iUserService;
@Override @Override
public Work findByWorkIdWorkVo(String superoirId) { public Work findByWorkIdWorkVo(String superoirId) {
return superoirIdWork(superoirId); return superoirIdWork(superoirId);
...@@ -27,6 +32,10 @@ public class PriviceServiceImpl implements PriviceService { ...@@ -27,6 +32,10 @@ public class PriviceServiceImpl implements PriviceService {
} }
Work work= workRepository.findById(superoirId).get(); Work work= workRepository.findById(superoirId).get();
if (work.getSuperiorId()==null|| "".equals(work.getSuperiorId())){ if (work.getSuperiorId()==null|| "".equals(work.getSuperiorId())){
String publisherName = iUserService.findUserById(work.getPublisher()).getUsername();
String executorName = iUserService.findUserById(work.getExecutor()).getUsername();
work.setPublisher(publisherName);
work.setExecutor(executorName);
return work; return work;
}else { }else {
return superoirIdWork(work.getSuperiorId()); return superoirIdWork(work.getSuperiorId());
......
...@@ -2,6 +2,7 @@ package com.zjty.tynotes.job.status.controller; ...@@ -2,6 +2,7 @@ package com.zjty.tynotes.job.status.controller;
import com.zjty.tynotes.job.status.entity.ActionHistory; import com.zjty.tynotes.job.status.entity.ActionHistory;
import com.zjty.tynotes.job.status.service.ActionHistoryService; import com.zjty.tynotes.job.status.service.ActionHistoryService;
import com.zjty.tynotes.job.status.service.RepairService;
import com.zjty.tynotes.misc.config.AutoDocument; import com.zjty.tynotes.misc.config.AutoDocument;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParam;
...@@ -26,6 +27,8 @@ public class ActionHistoryController { ...@@ -26,6 +27,8 @@ public class ActionHistoryController {
@Autowired @Autowired
private ActionHistoryService actionHistoryService; private ActionHistoryService actionHistoryService;
@Autowired
RepairService repairService;
@GetMapping("/history") @GetMapping("/history")
@ApiOperation(value = "事件操作历史") @ApiOperation(value = "事件操作历史")
...@@ -37,4 +40,10 @@ public class ActionHistoryController { ...@@ -37,4 +40,10 @@ public class ActionHistoryController {
return ResponseEntity.ok(actionHistoryService.findHistory(id)); return ResponseEntity.ok(actionHistoryService.findHistory(id));
} }
@GetMapping("/dcToredis")
public ResponseEntity<String> dcToRedis(){
repairService.dbAllToRedis();
return ResponseEntity.ok("ok");
}
} }
...@@ -42,7 +42,7 @@ public class RepairServiceImpl implements RepairService { ...@@ -42,7 +42,7 @@ public class RepairServiceImpl implements RepairService {
@Override @Override
public void dbAllToRedis() { public void dbAllToRedis() {
workService.findAll(); workService.findAll().forEach(this::dbToRedis);
} }
...@@ -92,6 +92,7 @@ public class RepairServiceImpl implements RepairService { ...@@ -92,6 +92,7 @@ public class RepairServiceImpl implements RepairService {
}else { }else {
personalWork.setIsNotCommission(1); personalWork.setIsNotCommission(1);
} }
personalWork.setExecutorEqualRelease(0);
break; break;
default: default:
...@@ -106,6 +107,7 @@ public class RepairServiceImpl implements RepairService { ...@@ -106,6 +107,7 @@ public class RepairServiceImpl implements RepairService {
uIds.remove(work.getPublisher()); uIds.remove(work.getPublisher());
uIds.remove(work.getExecutor()); uIds.remove(work.getExecutor());
personalWork.setWorkAttribution(WorkAttribution1.ME_RESOLVE_WORK); personalWork.setWorkAttribution(WorkAttribution1.ME_RESOLVE_WORK);
personalWork.setExecutorEqualRelease(0);
switch (work.getStatus()){ switch (work.getStatus()){
case WorkStatus case WorkStatus
.AUDIT: .AUDIT:
...@@ -150,12 +152,12 @@ public class RepairServiceImpl implements RepairService { ...@@ -150,12 +152,12 @@ public class RepairServiceImpl implements RepairService {
}else { }else {
personalWork.setIsNotCommission(0); personalWork.setIsNotCommission(0);
} }
break; break;
default: default:
personalWork.setIsNotCommission(0); personalWork.setIsNotCommission(0);
break; break;
} }
personalWork.setExecutorEqualRelease(0);
redisTemplate.opsForList().leftPush(Constants.REDIS_EVENT + work.getExecutor(), personalWork); redisTemplate.opsForList().leftPush(Constants.REDIS_EVENT + work.getExecutor(), personalWork);
...@@ -166,6 +168,7 @@ public class RepairServiceImpl implements RepairService { ...@@ -166,6 +168,7 @@ public class RepairServiceImpl implements RepairService {
personalWork.setWorkAttribution(WorkAttribution1.ME_RELATED_WORK); personalWork.setWorkAttribution(WorkAttribution1.ME_RELATED_WORK);
personalWork.setReadState(1); personalWork.setReadState(1);
personalWork.setIsNotCommission(0); personalWork.setIsNotCommission(0);
personalWork.setExecutorEqualRelease(0);
redisTemplate.opsForList().leftPush(Constants.REDIS_EVENT + id, personalWork); redisTemplate.opsForList().leftPush(Constants.REDIS_EVENT + id, personalWork);
} }
......
...@@ -16,6 +16,16 @@ ...@@ -16,6 +16,16 @@
<!--</properties>--> <!--</properties>-->
<dependencies> <dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!--swagger2 enable dependency--> <!--swagger2 enable dependency-->
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
...@@ -47,6 +57,24 @@ ...@@ -47,6 +57,24 @@
<artifactId>springfox-bean-validators</artifactId> <artifactId>springfox-bean-validators</artifactId>
<version>2.9.1</version> <version>2.9.1</version>
</dependency> </dependency>
<dependency>
<groupId>cn.afterturn</groupId>
<artifactId>easypoi-base</artifactId>
<version>3.2.0</version>
</dependency>
<dependency>
<groupId>cn.afterturn</groupId>
<artifactId>easypoi-web</artifactId>
<version>3.2.0</version>
</dependency>
<dependency>
<groupId>cn.afterturn</groupId>
<artifactId>easypoi-annotation</artifactId>
<version>3.2.0</version>
</dependency>
</dependencies> </dependencies>
<build> <build>
......
package com.zjty.tynotes.misc.utils;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
*
*
*/
@EqualsAndHashCode(callSuper = true)
@Data
public class CustomException extends RuntimeException {
private static final long serialVersionUID = 2974448974512157353L;
public CustomException(String message) {
super(message);
}
public CustomException() {
}
}
package com.zjty.tynotes.misc.utils;
import cn.afterturn.easypoi.excel.ExcelExportUtil;
import cn.afterturn.easypoi.excel.ExcelImportUtil;
import cn.afterturn.easypoi.excel.entity.ExportParams;
import cn.afterturn.easypoi.excel.entity.ImportParams;
import cn.afterturn.easypoi.excel.entity.enmus.ExcelType;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.ss.usermodel.Workbook;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
import java.net.URLEncoder;
import java.util.List;
import java.util.Map;
import java.util.NoSuchElementException;
/**
* fp-api.
*
* @author : Matrix [xhyrzldf@gmail.com]
* 18-11-15 .
*/
public class ExcelUtil {
public static void exportExcel(List<?> list, String title, String sheetName, Class<?> pojoClass, String fileName, boolean isCreateHeader, HttpServletResponse response) {
ExportParams exportParams = new ExportParams(title, sheetName);
exportParams.setCreateHeadRows(isCreateHeader);
defaultExport(list, pojoClass, fileName, response, exportParams);
}
public static void exportExcel(List<?> list, String title, String sheetName, Class<?> pojoClass, String fileName, HttpServletResponse response) {
defaultExport(list, pojoClass, fileName, response, new ExportParams(title, sheetName));
}
public static void exportExcel(List<Map<String, Object>> list, String fileName, HttpServletResponse response) {
defaultExport(list, fileName, response);
}
/**
* @param response HTTP response
* @param wb workbook
* @param excelName excelName名称
*/
public static void downloadExcel(HttpServletRequest request, HttpServletResponse response, Workbook wb, String excelName) {
// 判断数据
if (wb == null) {
throw new CustomException("workbook can not be null!");
}
// 重置响应对象
response.reset();
String dateStr = excelName + ".xls";
System.out.println(dateStr);
// 指定下载的文件名--设置响应头
response.addHeader("Content-Disposition", "attachment;filename=" + dateStr);
response.setContentType("application/octet-stream;charset=UTF-8");
response.setHeader("Pragma", "no-cache");
response.setDateHeader("Expires", 0);
response.setHeader("Access-Control-Allow-Origin", request.getHeader("Origin"));
response.setHeader("Access-Control-Allow-Credentials", "true");
response.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, PUT, PATCH, DELETE");
response.setHeader("Access-Control-Max-Age", "3600");
response.setHeader("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
// 写出数据输出流到页面
try {
OutputStream output = response.getOutputStream();
BufferedOutputStream bufferedOutPut = new BufferedOutputStream(output);
wb.write(bufferedOutPut);
bufferedOutPut.flush();
bufferedOutPut.close();
output.close();
} catch (IOException e) {
e.printStackTrace();
}
}
private static void defaultExport(List<?> list, Class<?> pojoClass, String fileName, HttpServletResponse response, ExportParams exportParams) {
Workbook workbook = ExcelExportUtil.exportExcel(exportParams, pojoClass, list);
downLoadExcel(fileName, response, workbook);
}
private static void downLoadExcel(String fileName, HttpServletResponse response, Workbook workbook) {
try {
response.setCharacterEncoding("UTF-8");
response.setHeader("content-Type", "application/vnd.ms-excel");
response.setHeader("Content-Disposition",
"attachment;filename=" + URLEncoder.encode(fileName, "UTF-8"));
workbook.write(response.getOutputStream());
} catch (IOException e) {
throw new CustomException(e.getMessage());
}
}
private static void defaultExport(List<Map<String, Object>> list, String fileName, HttpServletResponse response) {
Workbook workbook = ExcelExportUtil.exportExcel(list, ExcelType.HSSF);
downLoadExcel(fileName, response, workbook);
}
public static <T> List<T> importExcel(String filePath, Integer titleRows, Integer headerRows, Class<T> pojoClass) {
if (StringUtils.isBlank(filePath)) {
return null;
}
ImportParams params = new ImportParams();
params.setTitleRows(titleRows);
params.setHeadRows(headerRows);
List<T> list;
try {
list = ExcelImportUtil.importExcel(new File(filePath), pojoClass, params);
} catch (NoSuchElementException e) {
throw new CustomException("模板不能为空");
} catch (Exception e) {
e.printStackTrace();
throw new CustomException(e.getMessage());
}
return list;
}
public static <T> List<T> importExcel(MultipartFile file, Integer titleRows, Integer headerRows, Class<T> pojoClass) {
if (file == null) {
return null;
}
ImportParams params = new ImportParams();
params.setTitleRows(titleRows);
params.setHeadRows(headerRows);
List<T> list;
try {
list = ExcelImportUtil.importExcel(file.getInputStream(), pojoClass, params);
} catch (NoSuchElementException e) {
throw new CustomException("excel文件不能为空");
} catch (Exception e) {
throw new CustomException(e.getMessage());
}
return list;
}
}
...@@ -202,4 +202,5 @@ public class Init implements CommandLineRunner { ...@@ -202,4 +202,5 @@ public class Init implements CommandLineRunner {
// iJobService.addJob(job); // iJobService.addJob(job);
// } // }
} }
} }
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论