Compare commits
No commits in common. "cc39e36c33475e657e7aa7cb4c832cbbb7cc709d" and "0a80b2b83c00e885584658efc0e7774a8ac9cdc9" have entirely different histories.
cc39e36c33
...
0a80b2b83c
|
@ -22,9 +22,9 @@ public class MybatisPlusConfig {
|
||||||
@Bean
|
@Bean
|
||||||
public MybatisPlusInterceptor mybatisPlusInterceptor() {
|
public MybatisPlusInterceptor mybatisPlusInterceptor() {
|
||||||
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
|
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
|
||||||
interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL)); //分页插件
|
interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
|
||||||
interceptor.addInnerInterceptor(new OptimisticLockerInnerInterceptor()); //乐观锁插件
|
interceptor.addInnerInterceptor(new OptimisticLockerInnerInterceptor());
|
||||||
interceptor.addInnerInterceptor(new BlockAttackInnerInterceptor()); //防全表更新删除插件
|
interceptor.addInnerInterceptor(new BlockAttackInnerInterceptor());
|
||||||
return interceptor;
|
return interceptor;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@ import java.time.*;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Jackson序列化配置以及Springboot Converter配置
|
* Jackson序列化配置,主要配置了{@link LocalDateTime} {@link LocalDate} {@link LocalTime}转为秒级时间戳的序列化
|
||||||
*
|
*
|
||||||
* @author 佘语殊
|
* @author 佘语殊
|
||||||
* @since 2022/6/28 23:59
|
* @since 2022/6/28 23:59
|
||||||
|
@ -103,6 +103,7 @@ public class SerializeConfig {
|
||||||
return javaTimeModule;
|
return javaTimeModule;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//TODO: Redis可能改成tostringSerializer
|
||||||
private SimpleModule customClassModule() {
|
private SimpleModule customClassModule() {
|
||||||
SimpleModule customClassModule = new SimpleModule("CustomClassModule");
|
SimpleModule customClassModule = new SimpleModule("CustomClassModule");
|
||||||
customClassModule.addSerializer(IPAddress.class, new JsonSerializer<>() {
|
customClassModule.addSerializer(IPAddress.class, new JsonSerializer<>() {
|
||||||
|
@ -116,7 +117,7 @@ public class SerializeConfig {
|
||||||
customClassModule.addDeserializer(IPAddress.class, new JsonDeserializer<>() {
|
customClassModule.addDeserializer(IPAddress.class, new JsonDeserializer<>() {
|
||||||
@Override
|
@Override
|
||||||
public IPAddress deserialize(JsonParser p, DeserializationContext ctxt) throws IOException {
|
public IPAddress deserialize(JsonParser p, DeserializationContext ctxt) throws IOException {
|
||||||
return IPAddress.of(Long.decode('#' + p.getValueAsString()));
|
return IPAddress.of(Long.decode(p.getValueAsString()));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return customClassModule;
|
return customClassModule;
|
||||||
|
|
|
@ -70,6 +70,7 @@ public class ProjectGroupController {
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//TODO: test
|
||||||
@Operation(description = "body中只传staffUsername和projectStaffPosition")
|
@Operation(description = "body中只传staffUsername和projectStaffPosition")
|
||||||
@SneakyThrows
|
@SneakyThrows
|
||||||
@PostMapping
|
@PostMapping
|
||||||
|
@ -97,6 +98,7 @@ public class ProjectGroupController {
|
||||||
throw new BadRequestException(BadRequestException.OPERATE_FAILED);
|
throw new BadRequestException(BadRequestException.OPERATE_FAILED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//TODO: test
|
||||||
@Operation(description = "body中只传projectStaffPosition")
|
@Operation(description = "body中只传projectStaffPosition")
|
||||||
@SneakyThrows
|
@SneakyThrows
|
||||||
@PutMapping("/{staffId}")
|
@PutMapping("/{staffId}")
|
||||||
|
@ -121,6 +123,7 @@ public class ProjectGroupController {
|
||||||
return ResponseMap.ofSuccess(projectGroupService.collectStatsForGroupPositions(token, projectId));
|
return ResponseMap.ofSuccess(projectGroupService.collectStatsForGroupPositions(token, projectId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//TODO: TEST
|
||||||
@Operation(description = "请求体是一个key为taskId,value为staffId的map")
|
@Operation(description = "请求体是一个key为taskId,value为staffId的map")
|
||||||
@SneakyThrows
|
@SneakyThrows
|
||||||
@PutMapping("/{staffId}/transfer")
|
@PutMapping("/{staffId}/transfer")
|
||||||
|
|
|
@ -4,6 +4,7 @@ import cn.edu.hfut.rmdjzz.projectmanagement.entity.Staff;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.exception.BadRequestException;
|
import cn.edu.hfut.rmdjzz.projectmanagement.exception.BadRequestException;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.exception.TokenException;
|
import cn.edu.hfut.rmdjzz.projectmanagement.exception.TokenException;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.service.IStaffService;
|
import cn.edu.hfut.rmdjzz.projectmanagement.service.IStaffService;
|
||||||
|
import cn.edu.hfut.rmdjzz.projectmanagement.utils.FileUtils;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.utils.TokenUtils;
|
import cn.edu.hfut.rmdjzz.projectmanagement.utils.TokenUtils;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.utils.http.HttpUtils;
|
import cn.edu.hfut.rmdjzz.projectmanagement.utils.http.HttpUtils;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.utils.http.ResponseMap;
|
import cn.edu.hfut.rmdjzz.projectmanagement.utils.http.ResponseMap;
|
||||||
|
@ -53,7 +54,7 @@ public class StaffController {
|
||||||
@PostMapping(value = "/import")
|
@PostMapping(value = "/import")
|
||||||
public ResponseMap importStaffs(
|
public ResponseMap importStaffs(
|
||||||
@RequestHeader(TokenUtils.HEADER_TOKEN) String token,
|
@RequestHeader(TokenUtils.HEADER_TOKEN) String token,
|
||||||
@RequestParam("fileDigest") String digest,
|
@RequestHeader(FileUtils.HEADER_FILE_DIGEST) String digest,
|
||||||
@RequestParam("uploadFile") MultipartFile uploadFile
|
@RequestParam("uploadFile") MultipartFile uploadFile
|
||||||
) {
|
) {
|
||||||
if (null == uploadFile) {
|
if (null == uploadFile) {
|
||||||
|
@ -92,6 +93,6 @@ public class StaffController {
|
||||||
public ResponseMap downloadTemplate() {
|
public ResponseMap downloadTemplate() {
|
||||||
return ResponseMap.of(HttpStatus.SEE_OTHER.value(),
|
return ResponseMap.of(HttpStatus.SEE_OTHER.value(),
|
||||||
HttpStatus.SEE_OTHER.getReasonPhrase())
|
HttpStatus.SEE_OTHER.getReasonPhrase())
|
||||||
.put("URI", "/public/账户导入模板.xlsx");
|
.put("URI","/public/账户导入模板.xlsx");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package cn.edu.hfut.rmdjzz.projectmanagement.controller;
|
package cn.edu.hfut.rmdjzz.projectmanagement.controller;
|
||||||
|
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.entity.Task;
|
import cn.edu.hfut.rmdjzz.projectmanagement.entity.Task;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.entity.dto.StaffProcessDTO;
|
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.entity.dto.TaskDTO;
|
import cn.edu.hfut.rmdjzz.projectmanagement.entity.dto.TaskDTO;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.exception.BadRequestException;
|
import cn.edu.hfut.rmdjzz.projectmanagement.exception.BadRequestException;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.service.IProjectService;
|
import cn.edu.hfut.rmdjzz.projectmanagement.service.IProjectService;
|
||||||
|
@ -123,9 +122,10 @@ public class TaskController {
|
||||||
return ResponseMap.ofSuccess("查询成功", taskService.getProjectProcessOfEveryone(token, projectId));
|
return ResponseMap.ofSuccess("查询成功", taskService.getProjectProcessOfEveryone(token, projectId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//TODO:
|
||||||
@SneakyThrows
|
@SneakyThrows
|
||||||
@GetMapping({"/stats", "/stats/{staffId}"})
|
@GetMapping({"/stats", "/stats/{staffId}"})
|
||||||
public ResponseList<StaffProcessDTO> getProjectStatistics(
|
public ResponseList getProjectStatistics(
|
||||||
@RequestHeader(TokenUtils.HEADER_TOKEN) String token,
|
@RequestHeader(TokenUtils.HEADER_TOKEN) String token,
|
||||||
@PathVariable Integer projectId,
|
@PathVariable Integer projectId,
|
||||||
@PathVariable(required = false) Integer staffId
|
@PathVariable(required = false) Integer staffId
|
||||||
|
|
|
@ -10,13 +10,10 @@ import cn.edu.hfut.rmdjzz.projectmanagement.utils.MapBuilder;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.utils.TimeUtils;
|
import cn.edu.hfut.rmdjzz.projectmanagement.utils.TimeUtils;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.utils.TokenUtils;
|
import cn.edu.hfut.rmdjzz.projectmanagement.utils.TokenUtils;
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.utils.http.IPAddress;
|
import cn.edu.hfut.rmdjzz.projectmanagement.utils.http.IPAddress;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
|
||||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.lang3.RandomStringUtils;
|
import org.apache.commons.lang3.RandomStringUtils;
|
||||||
import org.apache.poi.ss.usermodel.CellType;
|
|
||||||
import org.apache.poi.xssf.usermodel.XSSFCell;
|
|
||||||
import org.apache.poi.xssf.usermodel.XSSFSheet;
|
import org.apache.poi.xssf.usermodel.XSSFSheet;
|
||||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
@ -162,9 +159,11 @@ public class StaffServiceImpl extends ServiceImpl<StaffMapper, Staff> implements
|
||||||
throw new BadRequestException("读取列staffGlobalLevel失败");
|
throw new BadRequestException("读取列staffGlobalLevel失败");
|
||||||
}
|
}
|
||||||
System.out.println(staffGlobalLevelC);
|
System.out.println(staffGlobalLevelC);
|
||||||
if (staffGlobalLevelC.stream().anyMatch(level -> Integer.parseInt(level) < 2)) {
|
for (int i = 0; i < totalCount; i++) {
|
||||||
|
if (Integer.parseInt(staffGlobalLevelC.get(i)) != 2 && Integer.parseInt(staffGlobalLevelC.get(i)) != 3) {
|
||||||
throw new BadRequestException("列staffGlobalLevel无效");
|
throw new BadRequestException("列staffGlobalLevel无效");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (int i = 0; i < totalCount; i++) {
|
for (int i = 0; i < totalCount; i++) {
|
||||||
Staff staff = new Staff();
|
Staff staff = new Staff();
|
||||||
|
@ -199,12 +198,10 @@ public class StaffServiceImpl extends ServiceImpl<StaffMapper, Staff> implements
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
for (int i = 1; i <= sheet.getLastRowNum(); i++) {
|
for (int i = 1; i <= sheet.getLastRowNum(); i++) {
|
||||||
XSSFCell cell = sheet.getRow(i).getCell(columnIndex);
|
String value = sheet.getRow(i).getCell(columnIndex).getStringCellValue();
|
||||||
cell.setCellType(CellType.STRING);
|
if (value == null || value.length() <= 2)
|
||||||
String value = cell.getStringCellValue();
|
|
||||||
if (StringUtils.isEmpty(value))
|
|
||||||
return true;
|
return true;
|
||||||
result.add(value);
|
result.add(value.substring(1, value.length() - 1));
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
|
@ -16,7 +16,6 @@ public class IPAddress {
|
||||||
|
|
||||||
public static IPAddress of(String ip) {
|
public static IPAddress of(String ip) {
|
||||||
long ipHex = 0;
|
long ipHex = 0;
|
||||||
ip = ip.substring(0, ip.indexOf(':'));
|
|
||||||
String[] split = ip.split("\\.");
|
String[] split = ip.split("\\.");
|
||||||
for (String s : split) {
|
for (String s : split) {
|
||||||
ipHex = (ipHex << 8) + Integer.parseInt(s);
|
ipHex = (ipHex << 8) + Integer.parseInt(s);
|
||||||
|
@ -39,6 +38,6 @@ public class IPAddress {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return Long.toHexString(ipHex);
|
return "#" + Long.toHexString(ipHex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Binary file not shown.
|
@ -1,29 +0,0 @@
|
||||||
package cn.edu.hfut.rmdjzz.projectmanagement;
|
|
||||||
|
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.service.IStaffService;
|
|
||||||
import cn.edu.hfut.rmdjzz.projectmanagement.utils.FileUtils;
|
|
||||||
import lombok.SneakyThrows;
|
|
||||||
import org.junit.jupiter.api.Test;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
|
||||||
import org.springframework.mock.web.MockMultipartFile;
|
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author 佘语殊
|
|
||||||
* @since 2022/7/13 10:05
|
|
||||||
*/
|
|
||||||
@SpringBootTest
|
|
||||||
public class ExcelTests {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private IStaffService staffService;
|
|
||||||
|
|
||||||
@SneakyThrows
|
|
||||||
@Test
|
|
||||||
public void importTest() {
|
|
||||||
MultipartFile excelFile = new MockMultipartFile("账户导入模板.xlsx",
|
|
||||||
FileUtils.class.getClassLoader().getResourceAsStream("static/public/账户导入模板.xlsx"));
|
|
||||||
staffService.multiImport("", excelFile);
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue