|
@@ -1,22 +1,17 @@
|
|
package com.management.platform.service.impl;
|
|
package com.management.platform.service.impl;
|
|
|
|
|
|
-import java.time.LocalDateTime;
|
|
|
|
-import java.time.LocalDate;
|
|
|
|
-
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.management.platform.entity.Company;
|
|
import com.management.platform.entity.Company;
|
|
import com.management.platform.entity.User;
|
|
import com.management.platform.entity.User;
|
|
import com.management.platform.entity.vo.UserVO;
|
|
import com.management.platform.entity.vo.UserVO;
|
|
import com.management.platform.mapper.CompanyMapper;
|
|
import com.management.platform.mapper.CompanyMapper;
|
|
import com.management.platform.mapper.UserMapper;
|
|
import com.management.platform.mapper.UserMapper;
|
|
import com.management.platform.service.UserService;
|
|
import com.management.platform.service.UserService;
|
|
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
import com.management.platform.util.HttpRespMsg;
|
|
import com.management.platform.util.HttpRespMsg;
|
|
import com.management.platform.util.MD5Util;
|
|
import com.management.platform.util.MD5Util;
|
|
import com.management.platform.util.SnowFlake;
|
|
import com.management.platform.util.SnowFlake;
|
|
-import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
|
|
|
-import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
|
|
|
|
-import org.apache.poi.ss.usermodel.*;
|
|
|
|
|
|
+import org.apache.poi.ss.usermodel.CellType;
|
|
import org.apache.poi.xssf.usermodel.XSSFCell;
|
|
import org.apache.poi.xssf.usermodel.XSSFCell;
|
|
import org.apache.poi.xssf.usermodel.XSSFRow;
|
|
import org.apache.poi.xssf.usermodel.XSSFRow;
|
|
import org.apache.poi.xssf.usermodel.XSSFSheet;
|
|
import org.apache.poi.xssf.usermodel.XSSFSheet;
|
|
@@ -28,6 +23,8 @@ import org.springframework.web.multipart.MultipartFile;
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import java.io.*;
|
|
import java.io.*;
|
|
|
|
+import java.math.BigDecimal;
|
|
|
|
+import java.time.LocalDateTime;
|
|
import java.time.ZoneOffset;
|
|
import java.time.ZoneOffset;
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
@@ -252,10 +249,13 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
|
|
|
|
|
|
//新增或修改用户
|
|
//新增或修改用户
|
|
@Override
|
|
@Override
|
|
- public HttpRespMsg insertUser(String targetId, String name, String phone, Integer role, HttpServletRequest request) {
|
|
|
|
|
|
+ public HttpRespMsg insertUser(String targetId, String name, String phone, Integer role, Double cost,
|
|
|
|
+ HttpServletRequest request) {
|
|
HttpRespMsg httpRespMsg = new HttpRespMsg();
|
|
HttpRespMsg httpRespMsg = new HttpRespMsg();
|
|
try {
|
|
try {
|
|
User creator = userMapper.selectById(request.getHeader("Token"));
|
|
User creator = userMapper.selectById(request.getHeader("Token"));
|
|
|
|
+ //处理时薪
|
|
|
|
+ BigDecimal costValue = cost == null ? null : BigDecimal.valueOf(cost);
|
|
if (targetId == null) {
|
|
if (targetId == null) {
|
|
//新增
|
|
//新增
|
|
if (creator.getRole() == 2 && role != 0) {
|
|
if (creator.getRole() == 2 && role != 0) {
|
|
@@ -274,7 +274,8 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
|
|
.setPassword(MD5Util.getPassword("000000"))
|
|
.setPassword(MD5Util.getPassword("000000"))
|
|
.setPhone(phone)
|
|
.setPhone(phone)
|
|
.setRole(role)
|
|
.setRole(role)
|
|
- .setCompanyId(creator.getCompanyId());
|
|
|
|
|
|
+ .setCompanyId(creator.getCompanyId())
|
|
|
|
+ .setCost(costValue);
|
|
if (userMapper.selectCount(new QueryWrapper<User>().eq("company_id", creator.getCompanyId())) >= (companyMapper.selectById(creator.getCompanyId()).getStaffCountMax())) {
|
|
if (userMapper.selectCount(new QueryWrapper<User>().eq("company_id", creator.getCompanyId())) >= (companyMapper.selectById(creator.getCompanyId()).getStaffCountMax())) {
|
|
httpRespMsg.setError("公司人员已达上限");
|
|
httpRespMsg.setError("公司人员已达上限");
|
|
return httpRespMsg;
|
|
return httpRespMsg;
|
|
@@ -286,7 +287,11 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
//修改
|
|
//修改
|
|
- userMapper.updateById(userMapper.selectById(targetId).setName(name).setPhone(phone).setRole(role));
|
|
|
|
|
|
+ userMapper.updateById(userMapper.selectById(targetId)
|
|
|
|
+ .setName(name)
|
|
|
|
+ .setPhone(phone)
|
|
|
|
+ .setRole(role)
|
|
|
|
+ .setCost(costValue));
|
|
}
|
|
}
|
|
} catch (NullPointerException e) {
|
|
} catch (NullPointerException e) {
|
|
httpRespMsg.setError("数据有误 验证失败");
|
|
httpRespMsg.setError("数据有误 验证失败");
|
|
@@ -330,17 +335,21 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
|
|
if (row == null) {
|
|
if (row == null) {
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
- //此处新建账号 默认密码为000000 默认 姓名第一列 手机号第二列
|
|
|
|
|
|
+ //此处新建账号 默认密码为000000 默认 姓名第一列 手机号第二列 时薪第三列
|
|
Long id = SnowFlake.nextId();
|
|
Long id = SnowFlake.nextId();
|
|
XSSFCell nameCell = row.getCell(0);
|
|
XSSFCell nameCell = row.getCell(0);
|
|
XSSFCell phoneCell = row.getCell(1);
|
|
XSSFCell phoneCell = row.getCell(1);
|
|
|
|
+ XSSFCell costCell = row.getCell(2);
|
|
nameCell.setCellType(CellType.STRING);
|
|
nameCell.setCellType(CellType.STRING);
|
|
phoneCell.setCellType(CellType.STRING);
|
|
phoneCell.setCellType(CellType.STRING);
|
|
- if ("姓名".equals(nameCell.getStringCellValue()) && "手机号".equals(phoneCell.getStringCellValue()) && rowIndex == 0) {
|
|
|
|
- continue;
|
|
|
|
- }
|
|
|
|
|
|
+ costCell.setCellType(CellType.STRING);
|
|
String name = nameCell.getStringCellValue();
|
|
String name = nameCell.getStringCellValue();
|
|
String phone = phoneCell.getStringCellValue();
|
|
String phone = phoneCell.getStringCellValue();
|
|
|
|
+ if (name.equals("姓名") && phone.equals("手机号") && rowIndex == 0) {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ String costString = costCell.getStringCellValue();
|
|
|
|
+ BigDecimal cost = costString != null ? new BigDecimal(costString) : null;
|
|
phoneList.add(phone);
|
|
phoneList.add(phone);
|
|
userList.add(new User()
|
|
userList.add(new User()
|
|
.setId(id.toString())
|
|
.setId(id.toString())
|
|
@@ -348,7 +357,8 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
|
|
.setPassword(MD5Util.getPassword("000000"))
|
|
.setPassword(MD5Util.getPassword("000000"))
|
|
.setPhone(phone)
|
|
.setPhone(phone)
|
|
.setRole(0)
|
|
.setRole(0)
|
|
- .setCompanyId(companyId));
|
|
|
|
|
|
+ .setCompanyId(companyId)
|
|
|
|
+ .setCost(cost));
|
|
}
|
|
}
|
|
//最后删掉这个文件
|
|
//最后删掉这个文件
|
|
// if (!file.delete()) {
|
|
// if (!file.delete()) {
|
|
@@ -369,7 +379,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
|
|
return httpRespMsg;
|
|
return httpRespMsg;
|
|
} catch (NullPointerException e) {
|
|
} catch (NullPointerException e) {
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
- httpRespMsg.setError("数据格式有误或存在空数据 导出失败");
|
|
|
|
|
|
+ httpRespMsg.setError("数据格式有误或存在空数据 导入失败");
|
|
return httpRespMsg;
|
|
return httpRespMsg;
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|