bug修改
This commit is contained in:
parent
380fabe2bb
commit
1532f10d97
|
|
@ -3,10 +3,13 @@ package com.bonus.bmw.controller;
|
||||||
import com.bonus.bmw.domain.dto.FileBasicMsgDto;
|
import com.bonus.bmw.domain.dto.FileBasicMsgDto;
|
||||||
import com.bonus.bmw.domain.dto.WebFileDto;
|
import com.bonus.bmw.domain.dto.WebFileDto;
|
||||||
import com.bonus.bmw.domain.po.BmSubContract;
|
import com.bonus.bmw.domain.po.BmSubContract;
|
||||||
|
import com.bonus.bmw.domain.po.PmSubCompany;
|
||||||
import com.bonus.bmw.domain.vo.BmSubContractVo;
|
import com.bonus.bmw.domain.vo.BmSubContractVo;
|
||||||
|
import com.bonus.bmw.domain.vo.PmWorker;
|
||||||
import com.bonus.bmw.domain.vo.TreeVo;
|
import com.bonus.bmw.domain.vo.TreeVo;
|
||||||
import com.bonus.bmw.service.AppService;
|
import com.bonus.bmw.service.AppService;
|
||||||
import com.bonus.bmw.service.BmSubContractService;
|
import com.bonus.bmw.service.BmSubContractService;
|
||||||
|
import com.bonus.common.core.utils.encryption.Sm4Utils;
|
||||||
import com.bonus.common.core.utils.json.FastJsonHelper;
|
import com.bonus.common.core.utils.json.FastJsonHelper;
|
||||||
import com.bonus.common.core.utils.poi.ExcelUtil;
|
import com.bonus.common.core.utils.poi.ExcelUtil;
|
||||||
import com.bonus.common.core.web.controller.BaseController;
|
import com.bonus.common.core.web.controller.BaseController;
|
||||||
|
|
@ -82,6 +85,42 @@ public class AppController extends BaseController {
|
||||||
return error("系统异常,请联系管理员");
|
return error("系统异常,请联系管理员");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@RequiresPermissionsOrInnerAuth(innerAuth = @InnerAuth(isUser = false))
|
||||||
|
@PostMapping("/uploadFile")
|
||||||
|
@SysLog(title = "单文件上传", businessType = OperaType.QUERY, logType = 0, module = "APP->单文件上传", details = "单文件上传")
|
||||||
|
public AjaxResult uploadFile(@RequestParam(value = "file") MultipartFile file,@RequestParam(value = "type") String type) {
|
||||||
|
try {
|
||||||
|
return service.uploadFile(file, type);
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error(e.toString(), e);
|
||||||
|
}
|
||||||
|
return error("系统异常,请联系管理员");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@RequiresPermissionsOrInnerAuth(innerAuth = @InnerAuth)
|
||||||
|
@PostMapping("/appWorkerInsert")
|
||||||
|
@SysLog(title = "新增app人员入场", businessType = OperaType.UPDATE, logType = 0, module = "施工人员->出入场管理->app人员入场", details = "新增人员入场")
|
||||||
|
public AjaxResult appWorkerInsert(@Validated @RequestBody PmWorker pmWorker) {
|
||||||
|
try {
|
||||||
|
return service.appWorkerInsert(pmWorker);
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error(e.toString(), e);
|
||||||
|
}
|
||||||
|
return error("系统异常,请联系管理员");
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequiresPermissionsOrInnerAuth(innerAuth = @InnerAuth, requiresPermissions = @RequiresPermissions("worker:ein:edit"))
|
||||||
|
@PostMapping("/appWorkerEdit")
|
||||||
|
@SysLog(title = "人员入场管理", businessType = OperaType.UPDATE, logType = 0, module = "施工人员->出入场管理->人员入场管理", details = "修改人员入场")
|
||||||
|
public AjaxResult appWorkerEdit(@Validated @RequestBody PmWorker pmWorker) {
|
||||||
|
try {
|
||||||
|
return service.appWorkerEdit(pmWorker);
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error(e.toString(), e);
|
||||||
|
}
|
||||||
|
return error("系统异常,请联系管理员");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,7 @@ import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Base64;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
@ -81,6 +82,7 @@ public class PmWorkerController extends BaseController {
|
||||||
List<WebFileDto> listFile = FastJsonHelper.jsonArrStrToBeanList(fileMsg, WebFileDto.class);
|
List<WebFileDto> listFile = FastJsonHelper.jsonArrStrToBeanList(fileMsg, WebFileDto.class);
|
||||||
// 验证对应关系
|
// 验证对应关系
|
||||||
if (listFile.size() != files.length) {
|
if (listFile.size() != files.length) {
|
||||||
|
logger.error("文件信息:{}文件数量:{}", listFile.size(), files.length);
|
||||||
throw new IllegalArgumentException("文件信息与文件数量不匹配");
|
throw new IllegalArgumentException("文件信息与文件数量不匹配");
|
||||||
}
|
}
|
||||||
//先将数据对应关系处理还
|
//先将数据对应关系处理还
|
||||||
|
|
@ -124,6 +126,7 @@ public class PmWorkerController extends BaseController {
|
||||||
listFile = FastJsonHelper.jsonArrStrToBeanList(fileMsg, WebFileDto.class);
|
listFile = FastJsonHelper.jsonArrStrToBeanList(fileMsg, WebFileDto.class);
|
||||||
// 验证对应关系
|
// 验证对应关系
|
||||||
if (listFile.size() != files.length) {
|
if (listFile.size() != files.length) {
|
||||||
|
logger.error("文件信息:{}文件数量:{}", listFile.size(), files.length);
|
||||||
throw new IllegalArgumentException("文件信息与文件数量不匹配");
|
throw new IllegalArgumentException("文件信息与文件数量不匹配");
|
||||||
}
|
}
|
||||||
//先将数据对应关系处理
|
//先将数据对应关系处理
|
||||||
|
|
|
||||||
|
|
@ -22,4 +22,6 @@ public class WebFileDto {
|
||||||
|
|
||||||
private MultipartFile file;
|
private MultipartFile file;
|
||||||
|
|
||||||
|
private String base64File;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -148,4 +148,6 @@ public class BmWorkerContract {
|
||||||
private Integer subComId;
|
private Integer subComId;
|
||||||
private Integer orgId;
|
private Integer orgId;
|
||||||
|
|
||||||
|
private String photoIds;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -91,4 +91,6 @@ public class BmWorkerWageCard {
|
||||||
*/
|
*/
|
||||||
private String delIds;
|
private String delIds;
|
||||||
|
|
||||||
|
private String photoIds;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -192,4 +192,6 @@ public class PmWorker {
|
||||||
*/
|
*/
|
||||||
private List<UploadFileVo> files;
|
private List<UploadFileVo> files;
|
||||||
|
|
||||||
|
private String photoIds;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -2,6 +2,7 @@ package com.bonus.bmw.mapper;
|
||||||
|
|
||||||
import com.bonus.bmw.domain.vo.TreeVo;
|
import com.bonus.bmw.domain.vo.TreeVo;
|
||||||
import com.bonus.system.api.domain.SysUser;
|
import com.bonus.system.api.domain.SysUser;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
@ -14,4 +15,6 @@ public interface AppMapper {
|
||||||
List<TreeVo> getComList(TreeVo vo);
|
List<TreeVo> getComList(TreeVo vo);
|
||||||
|
|
||||||
List<TreeVo> getSubComList(TreeVo company);
|
List<TreeVo> getSubComList(TreeVo company);
|
||||||
|
|
||||||
|
int updateFileMsg(@Param("id") String facePhotoId,@Param("sourceTable") String sourceTable,@Param("sourceId") Integer id);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,8 @@ public interface AppRecognitionService {
|
||||||
|
|
||||||
String uploadFaceRecognition(MultipartFile facePhoto, FaceRecognitionBean bean);
|
String uploadFaceRecognition(MultipartFile facePhoto, FaceRecognitionBean bean);
|
||||||
|
|
||||||
|
String uploadFaceRecognition(String facePhoto, FaceRecognitionBean bean);
|
||||||
|
|
||||||
AjaxResult getFaceRecognition(MultipartFile facePhoto);
|
AjaxResult getFaceRecognition(MultipartFile facePhoto);
|
||||||
|
|
||||||
AjaxResult bankCardRecognition(BankCardBean bean);
|
AjaxResult bankCardRecognition(BankCardBean bean);
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,10 @@
|
||||||
package com.bonus.bmw.service;
|
package com.bonus.bmw.service;
|
||||||
|
|
||||||
|
import com.bonus.bmw.domain.vo.PmWorker;
|
||||||
import com.bonus.bmw.domain.vo.TreeVo;
|
import com.bonus.bmw.domain.vo.TreeVo;
|
||||||
import com.bonus.common.core.web.domain.AjaxResult;
|
import com.bonus.common.core.web.domain.AjaxResult;
|
||||||
import com.bonus.system.api.domain.SysUser;
|
import com.bonus.system.api.domain.SysUser;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
public interface AppService {
|
public interface AppService {
|
||||||
|
|
||||||
|
|
@ -23,4 +25,25 @@ public interface AppService {
|
||||||
|
|
||||||
|
|
||||||
AjaxResult getComWorkerTree(TreeVo vo);
|
AjaxResult getComWorkerTree(TreeVo vo);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 文件上传
|
||||||
|
* @param file
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
AjaxResult uploadFile(MultipartFile file, String type);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增人员入场
|
||||||
|
* @param pmWorker
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
AjaxResult appWorkerInsert(PmWorker pmWorker) throws Exception;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改人员入场
|
||||||
|
* @param pmWorker
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
AjaxResult appWorkerEdit(PmWorker pmWorker) throws Exception;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -106,6 +106,51 @@ public class AppRecognitionServiceImpl implements AppRecognitionService {
|
||||||
return "公司内部人脸识别服务处理异常";
|
return "公司内部人脸识别服务处理异常";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 人脸识别-人脸照片采集入库
|
||||||
|
* @param facePhoto url
|
||||||
|
* @param bean
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String uploadFaceRecognition(String facePhoto, FaceRecognitionBean bean) {
|
||||||
|
try {
|
||||||
|
// 最多尝试两次,避免无限循环 ,删除无需重复
|
||||||
|
int maxRetries = 1;
|
||||||
|
if(!"delete".equals(bean.getOptMode())){
|
||||||
|
bean.setImg(facePhoto);
|
||||||
|
maxRetries = 2;
|
||||||
|
}else{
|
||||||
|
bean.setImg("data:image/jpeg;base64,fddsdafretrthwuwtrewyewtrweet");
|
||||||
|
}
|
||||||
|
log.error("进人脸服务器的人脸图片:{}", facePhoto);
|
||||||
|
for (int i = 0; i < maxRetries; i++) {
|
||||||
|
String body = HttpUtil.post(IpAndPathConfig.getFaceRecognitionUrl() + "/updatedb",
|
||||||
|
FastJsonHelper.beanToJsonStr(bean));
|
||||||
|
log.error(body);
|
||||||
|
JSONObject jsonObject = FastJsonHelper.jsonStrToJsonObj(body);
|
||||||
|
String code = jsonObject.getString("code");
|
||||||
|
if(StringUtils.isEmpty(code)){
|
||||||
|
log.error("公司人脸识别大傻逼,code不放一起");
|
||||||
|
code = jsonObject.getJSONObject("detail").getString("code");
|
||||||
|
}
|
||||||
|
if ("30019".equals(code) && i == 0) {
|
||||||
|
// 第一次遇到30019错误时,设置replace模式再试一次
|
||||||
|
bean.setOptMode("replace");
|
||||||
|
} else {
|
||||||
|
// 其他情况直接返回结果
|
||||||
|
return "30002".equals(code) ? FaceStatusCodeReturn.faceStatusCodeReturn(30002)
|
||||||
|
: FaceStatusCodeReturn.faceStatusCodeReturn(Integer.parseInt(code));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("上传文件失败", e);
|
||||||
|
return "公司内部人脸识别服务处理异常";
|
||||||
|
}
|
||||||
|
return "公司内部人脸识别服务处理异常";
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AjaxResult getFaceRecognition(MultipartFile facePhoto) {
|
public AjaxResult getFaceRecognition(MultipartFile facePhoto) {
|
||||||
try {
|
try {
|
||||||
|
|
|
||||||
|
|
@ -1,17 +1,38 @@
|
||||||
package com.bonus.bmw.service.impl;
|
package com.bonus.bmw.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.date.DateUtil;
|
||||||
|
import com.bonus.bmw.domain.dto.WebFileDto;
|
||||||
|
import com.bonus.bmw.domain.po.FaceRecognitionBean;
|
||||||
|
import com.bonus.bmw.domain.vo.BmWorkerContract;
|
||||||
|
import com.bonus.bmw.domain.vo.BmWorkerWageCard;
|
||||||
|
import com.bonus.bmw.domain.vo.PmWorker;
|
||||||
import com.bonus.bmw.domain.vo.TreeVo;
|
import com.bonus.bmw.domain.vo.TreeVo;
|
||||||
import com.bonus.bmw.mapper.AppMapper;
|
import com.bonus.bmw.mapper.AppMapper;
|
||||||
|
import com.bonus.bmw.mapper.BmWorkerContractMapper;
|
||||||
|
import com.bonus.bmw.mapper.BmWorkerWageCardMapper;
|
||||||
|
import com.bonus.bmw.mapper.PmWorkerMapper;
|
||||||
|
import com.bonus.bmw.service.AppRecognitionService;
|
||||||
import com.bonus.bmw.service.AppService;
|
import com.bonus.bmw.service.AppService;
|
||||||
|
import com.bonus.bmw.service.BmWorkerWageCardService;
|
||||||
|
import com.bonus.bmw.service.UrkSendService;
|
||||||
|
import com.bonus.common.core.constant.Constants;
|
||||||
import com.bonus.common.core.utils.StringUtils;
|
import com.bonus.common.core.utils.StringUtils;
|
||||||
import com.bonus.common.core.web.domain.AjaxResult;
|
import com.bonus.common.core.web.domain.AjaxResult;
|
||||||
import com.bonus.common.security.utils.SecurityUtils;
|
import com.bonus.common.security.utils.SecurityUtils;
|
||||||
import com.bonus.system.api.domain.SysUser;
|
import com.bonus.system.api.domain.SysUser;
|
||||||
|
import com.bonus.system.api.model.LoginUser;
|
||||||
|
import com.bonus.system.api.model.UploadFileVo;
|
||||||
|
import com.github.pagehelper.util.StringUtil;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.math.RoundingMode;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author 马三炮
|
* @author 马三炮
|
||||||
|
|
@ -24,6 +45,26 @@ public class AppServiceImpl implements AppService {
|
||||||
@Resource
|
@Resource
|
||||||
private AppMapper mapper;
|
private AppMapper mapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private FileUploadUtils fileUploadUtils;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private PmWorkerMapper pmWorkerMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 引入urk服务 调用考勤机服务
|
||||||
|
*/
|
||||||
|
@Autowired
|
||||||
|
private UrkSendService urkSendService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private AppRecognitionService appRecognitionService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private BmWorkerWageCardMapper wageCardMapper;
|
||||||
|
@Autowired
|
||||||
|
private BmWorkerContractMapper contractMapper;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AjaxResult validatePassword(SysUser sysUser) {
|
public AjaxResult validatePassword(SysUser sysUser) {
|
||||||
|
|
@ -45,7 +86,7 @@ public class AppServiceImpl implements AppService {
|
||||||
int i = mapper.updatePassword(sysUser);
|
int i = mapper.updatePassword(sysUser);
|
||||||
if (i > 0) {
|
if (i > 0) {
|
||||||
return AjaxResult.success();
|
return AjaxResult.success();
|
||||||
}else{
|
} else {
|
||||||
return AjaxResult.error("修改失败");
|
return AjaxResult.error("修改失败");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -63,4 +104,228 @@ public class AppServiceImpl implements AppService {
|
||||||
});
|
});
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AjaxResult uploadFile(MultipartFile file, String type) {
|
||||||
|
UploadFileVo noTable = fileUploadUtils.uploadFile(file, "no_table", "-1", type, "", "");
|
||||||
|
return AjaxResult.success("上传成功", noTable.getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AjaxResult appWorkerInsert(PmWorker record) throws Exception {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
//是否失信人员名单
|
||||||
|
PmWorker worker2 = pmWorkerMapper.getBlackWorkerByNumber(record.getIdNumber());
|
||||||
|
if (worker2 != null && worker2.getName() != null) {
|
||||||
|
return new AjaxResult(500, worker2.getName() + "施工人员在失信人员名单,无法入场");
|
||||||
|
}
|
||||||
|
//如果是以前被删除的人员,自动恢复以前的数据
|
||||||
|
PmWorker delWorker = pmWorkerMapper.getWorkerByNumber(record.getIdNumber(), 0);
|
||||||
|
if (delWorker != null && delWorker.getId() != null) {
|
||||||
|
// 添加员工时,判断员工编号是否已存在
|
||||||
|
PmWorker worker3 = pmWorkerMapper.getWorkerByPhone(record.getPhone(), record.getIdNumber());
|
||||||
|
if (worker3 != null && worker3.getName() != null) {
|
||||||
|
return new AjaxResult(500, "注册的手机号已存在,手机号拥有者姓名为" + worker3.getName() + ",请去确认手机号是否有误");
|
||||||
|
}
|
||||||
|
pmWorkerMapper.updateIsActiveById(delWorker.getId(), 1);
|
||||||
|
record.setId(delWorker.getId());
|
||||||
|
record.setEinStatus(0);
|
||||||
|
//将数据还原,并去修改
|
||||||
|
appWorkerEdit(record);
|
||||||
|
} else {
|
||||||
|
// 添加员工时,判断员工编号是否已存在
|
||||||
|
PmWorker worker = pmWorkerMapper.getWorkerByNumber(record.getIdNumber(), 1);
|
||||||
|
if (worker != null && worker.getId() != null) {
|
||||||
|
return new AjaxResult(500, "施工人员身份证已存在,当前系统姓名为" + worker.getName() + "如果想入场请去修改数据即可");
|
||||||
|
}
|
||||||
|
// 添加员工时,手机号是否重复
|
||||||
|
PmWorker worker3 = pmWorkerMapper.getWorkerByPhone(record.getPhone(), record.getIdNumber());
|
||||||
|
if (worker3 != null && worker3.getName() != null) {
|
||||||
|
return new AjaxResult(500, "注册的手机号已存在,手机号拥有者姓名为" + worker3.getName() + ",请去确认手机号是否有误");
|
||||||
|
}
|
||||||
|
record.setCreateUser(SecurityUtils.getLoginUser().getSysUser().getUserName());
|
||||||
|
int insert = pmWorkerMapper.insert(record);
|
||||||
|
if (insert > 0) {
|
||||||
|
//单独上传的,修改数据
|
||||||
|
if (!StringUtils.isEmpty(record.getPhotoIds())) {
|
||||||
|
int i = mapper.updateFileMsg(record.getPhotoIds(), Constants.FILE_UPLOAD_WORKER, record.getId());
|
||||||
|
log.error("app更新人员人脸图片信息成功条数:{}", i);
|
||||||
|
//下发人脸到考勤机
|
||||||
|
urkSendService.sendUserToDevice(record.getId(), record.getProId(), "0");
|
||||||
|
// //下发人脸到人脸库
|
||||||
|
// FaceRecognitionBean faceRecognitionBean = new FaceRecognitionBean();
|
||||||
|
// faceRecognitionBean.setUniqueKey(record.getIdNumber());
|
||||||
|
// faceRecognitionBean.setOptMode("add");
|
||||||
|
// List<UploadFileVo> fileList = fileUploadUtils.getFileList(record.getPhotoIds(), "", Constants.FILE_UPLOAD_WORKER, "");
|
||||||
|
// if (!fileList.isEmpty()) {
|
||||||
|
// sb.append(appRecognitionService.uploadFaceRecognition(fileList.get(0).getLsUrl(), faceRecognitionBean));
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
//入场相关数据添加
|
||||||
|
addWorkerEinData(record);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return AjaxResult.success(sb.append(",基础数据添加成功").toString(), record.getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AjaxResult appWorkerEdit(PmWorker record) throws Exception {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
//是否失信人员名单
|
||||||
|
PmWorker worker2 = pmWorkerMapper.getBlackWorkerByNumber(record.getIdNumber());
|
||||||
|
if(worker2 != null && worker2.getName() != null){
|
||||||
|
return new AjaxResult(500, worker2.getName()+"施工人员在失信人员名单,无法入场");
|
||||||
|
}
|
||||||
|
// 添加员工时,判断员工编号是否已存在
|
||||||
|
PmWorker worker3 = pmWorkerMapper.getWorkerByPhone(record.getPhone(),record.getIdNumber());
|
||||||
|
if(worker3 != null && worker3.getName() != null){
|
||||||
|
return new AjaxResult(500, "注册的手机号已存在,手机号拥有者姓名为"+worker3.getName()+",请去确认手机号是否有误");
|
||||||
|
}
|
||||||
|
//更新基础数据
|
||||||
|
record.setUpdateUser(SecurityUtils.getLoginUser().getSysUser().getUserName());
|
||||||
|
int update = pmWorkerMapper.updateByPrimaryKey(record);
|
||||||
|
|
||||||
|
//单独上传的,修改数据
|
||||||
|
//人脸照片是否修改
|
||||||
|
if(!StringUtils.isEmpty(record.getPhotoIds())){
|
||||||
|
//删除旧人脸
|
||||||
|
String s = fileUploadUtils.delFileListById("", record.getId().toString(), Constants.FILE_UPLOAD_WORKER, "");
|
||||||
|
//更新新人脸信息
|
||||||
|
int i = mapper.updateFileMsg(record.getPhotoIds(), Constants.FILE_UPLOAD_WORKER, record.getId());
|
||||||
|
log.error("app更新人员人脸图片信息成功条数:{}", i);
|
||||||
|
//下发人脸到考勤机
|
||||||
|
if(record.getEinStatus() == 1){
|
||||||
|
//没换工程换人脸
|
||||||
|
urkSendService.sendUserToDevice(record.getId(),record.getProId(),"1");
|
||||||
|
}else{
|
||||||
|
//换工程换人脸
|
||||||
|
urkSendService.sendUserToDevice(record.getId(),record.getProId(),"0");
|
||||||
|
}
|
||||||
|
//下发人脸到人脸库
|
||||||
|
// FaceRecognitionBean faceRecognitionBean = new FaceRecognitionBean();
|
||||||
|
// faceRecognitionBean.setUniqueKey(record.getIdNumber());
|
||||||
|
// faceRecognitionBean.setOptMode("add");
|
||||||
|
// List<UploadFileVo> fileList = fileUploadUtils.getFileList(record.getPhotoIds(), "", Constants.FILE_UPLOAD_WORKER, "");
|
||||||
|
// if (!fileList.isEmpty()) {
|
||||||
|
// sb.append(appRecognitionService.uploadFaceRecognition(fileList.get(0).getLsUrl(), faceRecognitionBean));
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
if(record.getEinStatus() == 1){
|
||||||
|
//已经入过场了
|
||||||
|
addWorkerWageCardDataAndContract(record);
|
||||||
|
}else {
|
||||||
|
//重新入场 再入场,清除最新标识
|
||||||
|
pmWorkerMapper.updateEinRecordLast(record.getId());
|
||||||
|
//换工程没换人脸
|
||||||
|
urkSendService.sendUserToDevice(record.getId(),record.getProId(),"0");
|
||||||
|
addWorkerEinData(record);
|
||||||
|
}
|
||||||
|
return AjaxResult.success(sb.append(",基础数据更新成功").toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 基础数据添加完毕,在进行入场数据添加
|
||||||
|
*
|
||||||
|
* @param record
|
||||||
|
*/
|
||||||
|
private void addWorkerEinData(PmWorker record) {
|
||||||
|
//工资卡和合同数据
|
||||||
|
addWorkerWageCardDataAndContract(record);
|
||||||
|
record.setEinTime(DateUtil.now());
|
||||||
|
record.setEinStatus(1);
|
||||||
|
//1.bm_worker_ein_msg
|
||||||
|
int i = pmWorkerMapper.insertEinMsg(record);
|
||||||
|
//2.bm_worker_ein_pro 忽略新增
|
||||||
|
int j = pmWorkerMapper.insertEinPro(record);
|
||||||
|
//3.bm_worker_ein_pro_record
|
||||||
|
int k = pmWorkerMapper.insertEinProRecord(record);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addWorkerWageCardDataAndContract(PmWorker record) {
|
||||||
|
BmWorkerWageCard bmWorkerWageCard = record.getBmWorkerWageCard();
|
||||||
|
BmWorkerContract bmWorkerContract = record.getBmWorkerContract();
|
||||||
|
if (bmWorkerWageCard != null && StringUtil.isNotEmpty(bmWorkerWageCard.getBankCardCode())) {
|
||||||
|
bmWorkerWageCard.setCreateUser(SecurityUtils.getLoginUser().getSysUser().getUserName());
|
||||||
|
bmWorkerWageCard.setWorkerId(record.getId());
|
||||||
|
updateWageCard(bmWorkerWageCard);
|
||||||
|
}
|
||||||
|
if (bmWorkerContract != null && StringUtil.isNotEmpty(bmWorkerContract.getContractCode())) {
|
||||||
|
bmWorkerContract.setCreateUser(SecurityUtils.getLoginUser().getSysUser().getUserName());
|
||||||
|
bmWorkerContract.setWorkerId(record.getId());
|
||||||
|
updateWorkerContract(bmWorkerContract);
|
||||||
|
record.setContractId(bmWorkerContract.getId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateWorkerContract(BmWorkerContract record) {
|
||||||
|
//如果有旧的有效合同执行删除
|
||||||
|
if (record.getId() != null) {
|
||||||
|
contractMapper.deleteByPrimaryKey(record.getId());
|
||||||
|
}
|
||||||
|
record.setCreateUser(SecurityUtils.getUsername());
|
||||||
|
//判断是日合同还是月合同
|
||||||
|
if ("月".equals(record.getWageApprovedWay())) {
|
||||||
|
BigDecimal wageCriterion = BigDecimal.valueOf(record.getWageCriterion());
|
||||||
|
BigDecimal dayRate = wageCriterion.divide(BigDecimal.valueOf(30), 2, RoundingMode.HALF_UP);
|
||||||
|
record.setDayRate(dayRate.doubleValue());
|
||||||
|
} else {
|
||||||
|
// 保持原值,也建议保留两位小数以统一精度
|
||||||
|
BigDecimal wageCriterion = BigDecimal.valueOf(record.getWageCriterion());
|
||||||
|
BigDecimal dayRate = wageCriterion.setScale(2, RoundingMode.HALF_UP);
|
||||||
|
record.setDayRate(dayRate.doubleValue());
|
||||||
|
}
|
||||||
|
Integer oldContractId = null;
|
||||||
|
if (record.getId() != null) {
|
||||||
|
oldContractId = record.getId();
|
||||||
|
}
|
||||||
|
int insert = contractMapper.insert(record);
|
||||||
|
//属于废弃上一个合同重新签一个,需要修改掉之前考情绑定
|
||||||
|
contractMapper.updateEinDayRecordContractId(oldContractId, record.getWorkerId(), record.getId());
|
||||||
|
if (insert > 0) {
|
||||||
|
if (!StringUtils.isEmpty(record.getPhotoIds())) {
|
||||||
|
String[] split = record.getPhotoIds().split(",");
|
||||||
|
for (int x = 0; x < split.length; x++) {
|
||||||
|
int i = mapper.updateFileMsg(split[x], Constants.FILE_UPLOAD_CONTRACT, record.getId());
|
||||||
|
log.error("app更新合同图片:第{}条,{}", x, i > 0 ? "更新成功" : "更新失败");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//将合同id保存到入场表和入场实时表
|
||||||
|
contractMapper.updateEinRecordContractId(record.getId(), record.getWorkerId());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateWageCard(BmWorkerWageCard record) {
|
||||||
|
//存在则删除后新增,不存在则新增
|
||||||
|
if (record.getId() != null) {
|
||||||
|
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||||
|
if (record.getDelIds() != null) {
|
||||||
|
//修改时删除部分图片
|
||||||
|
String[] split = record.getDelIds().split(",");
|
||||||
|
fileUploadUtils.delFileList(split, null, null, null);
|
||||||
|
}
|
||||||
|
if (!StringUtils.isEmpty(record.getPhotoIds())) {
|
||||||
|
String[] split = record.getPhotoIds().split(",");
|
||||||
|
for (int x = 0; x < split.length; x++) {
|
||||||
|
int i = mapper.updateFileMsg(split[x], Constants.FILE_UPLOAD_WAGE_CARD, record.getId());
|
||||||
|
log.error("app更新发工资卡图片:第{}条,{}", x, i > 0 ? "更新成功" : "更新失败");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
wageCardMapper.updateByPrimaryKeySelective(record);
|
||||||
|
} else {
|
||||||
|
//新增
|
||||||
|
record.setCreateUser(SecurityUtils.getLoginUser().getUsername());
|
||||||
|
int insert = wageCardMapper.insert(record);
|
||||||
|
//添加到文件库和minio上
|
||||||
|
if (insert > 0) {
|
||||||
|
if (!StringUtils.isEmpty(record.getPhotoIds())) {
|
||||||
|
String[] split = record.getPhotoIds().split(",");
|
||||||
|
for (int x = 0; x < split.length; x++) {
|
||||||
|
int i = mapper.updateFileMsg(split[x], Constants.FILE_UPLOAD_WAGE_CARD, record.getId());
|
||||||
|
log.error("app更新发工资卡图片:第{}条,{}", x, i > 0 ? "更新成功" : "更新失败");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -98,7 +98,7 @@ public class PmWorkerExitServiceImpl implements PmWorkerExitService {
|
||||||
FaceRecognitionBean faceRecognitionBean = new FaceRecognitionBean();
|
FaceRecognitionBean faceRecognitionBean = new FaceRecognitionBean();
|
||||||
faceRecognitionBean.setUniqueKey(idNumber);
|
faceRecognitionBean.setUniqueKey(idNumber);
|
||||||
faceRecognitionBean.setOptMode("delete");
|
faceRecognitionBean.setOptMode("delete");
|
||||||
appRecognitionService.uploadFaceRecognition(null, faceRecognitionBean);
|
appRecognitionService.uploadFaceRecognition("", faceRecognitionBean);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,105 @@
|
||||||
|
package com.bonus.bmw.utils;
|
||||||
|
|
||||||
|
import cn.hutool.core.codec.Base64;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
import sun.misc.BASE64Decoder;
|
||||||
|
|
||||||
|
import javax.imageio.ImageIO;
|
||||||
|
import java.awt.image.BufferedImage;
|
||||||
|
import java.io.*;
|
||||||
|
|
||||||
|
public class BASE64DecodedMultipartFile implements MultipartFile {
|
||||||
|
|
||||||
|
private final byte[] imgContent;
|
||||||
|
private final String header;
|
||||||
|
|
||||||
|
public BASE64DecodedMultipartFile(byte[] imgContent, String header) {
|
||||||
|
this.imgContent = imgContent;
|
||||||
|
this.header = header.split(";")[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return System.currentTimeMillis() + Math.random() + "." + header.split("/")[1];
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getOriginalFilename() {
|
||||||
|
return System.currentTimeMillis() + (int) Math.random() * 10000 + "." + header.split("/")[1];
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getContentType() {
|
||||||
|
return header.split(":")[1];
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isEmpty() {
|
||||||
|
return imgContent == null || imgContent.length == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getSize() {
|
||||||
|
return imgContent.length;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public byte[] getBytes() throws IOException {
|
||||||
|
return imgContent;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public InputStream getInputStream() throws IOException {
|
||||||
|
return new ByteArrayInputStream(imgContent);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void transferTo(File dest) throws IOException, IllegalStateException {
|
||||||
|
new FileOutputStream(dest).write(imgContent);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static MultipartFile base64ToMultipart(String base64) {
|
||||||
|
try {
|
||||||
|
String[] baseStrs = base64.split(",");
|
||||||
|
|
||||||
|
BASE64Decoder decoder = new BASE64Decoder();
|
||||||
|
byte[] b = new byte[0];
|
||||||
|
b = decoder.decodeBuffer(baseStrs[1]);
|
||||||
|
|
||||||
|
for (int i = 0; i < b.length; ++i) {
|
||||||
|
if (b[i] < 0) {
|
||||||
|
b[i] += 256;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return new BASE64DecodedMultipartFile(b, baseStrs[0]);
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static String getBase64(String path) {
|
||||||
|
File file = new File(path);
|
||||||
|
String base64 = null;
|
||||||
|
try {
|
||||||
|
BufferedImage image = ImageIO.read(file);
|
||||||
|
Integer width = image.getWidth();
|
||||||
|
Integer height = image.getHeight();
|
||||||
|
System.out.println("宽:" + width + " 高:" + height);
|
||||||
|
|
||||||
|
//输出流
|
||||||
|
ByteArrayOutputStream stream = new ByteArrayOutputStream();
|
||||||
|
ImageIO.write(image, "png", stream);
|
||||||
|
base64 = Base64.encode(stream.toByteArray());
|
||||||
|
System.out.println(base64);
|
||||||
|
} catch (IOException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return base64;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -20,4 +20,8 @@
|
||||||
|
|
||||||
select id,sub_company_name as name from pm_sub_company where is_active = 1 and is_enable = 1 and com_id = #{id}
|
select id,sub_company_name as name from pm_sub_company where is_active = 1 and is_enable = 1 and com_id = #{id}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<update id="updateFileMsg">
|
||||||
|
update bm_files set source_table = #{sourceTable},source_id = #{sourceId} where id = #{id}
|
||||||
|
</update>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
|
||||||
|
|
@ -258,6 +258,7 @@
|
||||||
<if test="idNumber != null and idNumber != ''">
|
<if test="idNumber != null and idNumber != ''">
|
||||||
AND pw.id_number != #{idNumber}
|
AND pw.id_number != #{idNumber}
|
||||||
</if>
|
</if>
|
||||||
|
limit 1
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<update id="updateIsActiveById">
|
<update id="updateIsActiveById">
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue