入场,出场图片处理
This commit is contained in:
parent
c90df5e56b
commit
4c0c61cbc5
|
|
@ -14,3 +14,4 @@ logs
|
|||
|
||||
|
||||
|
||||
/EasyCode/
|
||||
|
|
|
|||
|
|
@ -149,4 +149,14 @@ public class Constants
|
|||
* 工资卡表
|
||||
*/
|
||||
public static final String FILE_UPLOAD_WAGE_CARD = "bm_worker_wage_card";
|
||||
|
||||
/**
|
||||
* 人员表
|
||||
*/
|
||||
public static final String FILE_UPLOAD_WORKER = "pm_worker";
|
||||
|
||||
/**
|
||||
* 人员出场表
|
||||
*/
|
||||
public static final String FILE_UPLOAD_WORKER_EXIT = "bm_worker_ein_pro_record";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -116,7 +116,11 @@ public class BmWorkerContractController extends BaseController {
|
|||
try {
|
||||
List<WebFileDto> listFile = FastJsonHelper.jsonArrStrToBeanList(fileMsg, WebFileDto.class);
|
||||
BmWorkerContract o = FastJsonHelper.jsonStrToBean(params, BmWorkerContract.class);
|
||||
return toAjax(service.updateByPrimaryKey(o,new FileBasicMsgDto(listFile, files)));
|
||||
//先将数据对应关系处理还
|
||||
for (int i = 0; i < listFile.size(); i++) {
|
||||
listFile.get(i).setFile(files[i]);
|
||||
}
|
||||
return toAjax(service.updateByPrimaryKey(o,listFile));
|
||||
} catch (Exception e) {
|
||||
logger.error(e.toString(), e);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,10 +12,8 @@ import com.bonus.common.core.web.page.TableDataInfo;
|
|||
import com.bonus.common.log.annotation.SysLog;
|
||||
import com.bonus.common.log.enums.OperaType;
|
||||
import com.bonus.common.security.annotation.InnerAuth;
|
||||
import com.bonus.common.security.annotation.RequiresPermissions;
|
||||
import com.bonus.common.security.annotation.RequiresPermissionsOrInnerAuth;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
|
|
@ -65,7 +63,11 @@ public class BmWorkerWageCardController extends BaseController {
|
|||
try {
|
||||
List<WebFileDto> listFile = FastJsonHelper.jsonArrStrToBeanList(fileMsg, WebFileDto.class);
|
||||
BmWorkerWageCard o = FastJsonHelper.jsonStrToBean(params, BmWorkerWageCard.class);
|
||||
return toAjax(service.updateByPrimaryKey(o,new FileBasicMsgDto(listFile, files)));
|
||||
//先将数据对应关系处理还
|
||||
for (int i = 0; i < listFile.size(); i++) {
|
||||
listFile.get(i).setFile(files[i]);
|
||||
}
|
||||
return toAjax(service.updateByPrimaryKey(o,listFile));
|
||||
} catch (Exception e) {
|
||||
logger.error(e.toString(), e);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
package com.bonus.bmw.controller;
|
||||
import com.bonus.bmw.domain.dto.FileBasicMsgDto;
|
||||
import com.bonus.bmw.domain.dto.PmWorkerDto;
|
||||
import com.bonus.bmw.domain.dto.WebFileDto;
|
||||
import com.bonus.bmw.domain.vo.BmWorkerContract;
|
||||
import com.bonus.bmw.domain.vo.BmWorkerWageCard;
|
||||
import com.bonus.bmw.domain.vo.PmWorker;
|
||||
|
|
@ -7,6 +9,7 @@ import com.bonus.bmw.service.PmWorkerService;
|
|||
import com.bonus.bmw.service.impl.PmWorkerServiceImpl;
|
||||
import com.bonus.common.core.utils.face.ArcFaceHelper;
|
||||
import com.bonus.common.core.utils.face.FaceResult;
|
||||
import com.bonus.common.core.utils.json.FastJsonHelper;
|
||||
import com.bonus.common.core.web.controller.BaseController;
|
||||
import com.bonus.common.core.web.domain.AjaxResult;
|
||||
import com.bonus.common.core.web.page.TableDataInfo;
|
||||
|
|
@ -63,9 +66,19 @@ public class PmWorkerController extends BaseController {
|
|||
@RequiresPermissionsOrInnerAuth(innerAuth = @InnerAuth)
|
||||
@PostMapping("/insert")
|
||||
@SysLog(title = "人员入场管理", businessType = OperaType.UPDATE, logType = 0, module = "施工人员->出入场管理->人员入场管理", details = "新增人员入场")
|
||||
public AjaxResult insert(@Validated @RequestBody PmWorker o) {
|
||||
public AjaxResult insert(@RequestParam(value = "files") MultipartFile[] files,@RequestParam(value = "fileMsg") String fileMsg, @RequestParam(value = "params")String params) {
|
||||
try {
|
||||
return service.insert(o);
|
||||
List<WebFileDto> listFile = FastJsonHelper.jsonArrStrToBeanList(fileMsg, WebFileDto.class);
|
||||
// 验证对应关系
|
||||
if (listFile.size() != files.length) {
|
||||
throw new IllegalArgumentException("文件信息与文件数量不匹配");
|
||||
}
|
||||
//先将数据对应关系处理还
|
||||
for (int i = 0; i < listFile.size(); i++) {
|
||||
listFile.get(i).setFile(files[i]);
|
||||
}
|
||||
PmWorker o = FastJsonHelper.jsonStrToBean(params, PmWorker.class);
|
||||
return service.insert(o,listFile);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.toString(), e);
|
||||
}
|
||||
|
|
@ -92,9 +105,19 @@ public class PmWorkerController extends BaseController {
|
|||
@RequiresPermissionsOrInnerAuth(innerAuth = @InnerAuth)
|
||||
@PostMapping("/edit")
|
||||
@SysLog(title = "人员入场管理", businessType = OperaType.UPDATE, logType = 0, module = "施工人员->出入场管理->人员入场管理", details = "修改人员入场")
|
||||
public AjaxResult edit(@Validated @RequestBody PmWorker o) {
|
||||
public AjaxResult edit(@RequestParam(value = "files") MultipartFile[] files,@RequestParam(value = "fileMsg") String fileMsg, @RequestParam(value = "params")String params) {
|
||||
try {
|
||||
return toAjax(service.updateByPrimaryKey(o));
|
||||
List<WebFileDto> listFile = FastJsonHelper.jsonArrStrToBeanList(fileMsg, WebFileDto.class);
|
||||
// 验证对应关系
|
||||
if (listFile.size() != files.length) {
|
||||
throw new IllegalArgumentException("文件信息与文件数量不匹配");
|
||||
}
|
||||
//先将数据对应关系处理
|
||||
for (int i = 0; i < listFile.size(); i++) {
|
||||
listFile.get(i).setFile(files[i]);
|
||||
}
|
||||
PmWorker o = FastJsonHelper.jsonStrToBean(params, PmWorker.class);
|
||||
return toAjax(service.updateByPrimaryKey(o,listFile));
|
||||
} catch (Exception e) {
|
||||
logger.error(e.toString(), e);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,12 @@
|
|||
package com.bonus.bmw.controller;
|
||||
|
||||
import com.bonus.bmw.domain.dto.PmWorkerDto;
|
||||
import com.bonus.bmw.domain.dto.WebFileDto;
|
||||
import com.bonus.bmw.domain.vo.BmWorkerWageCard;
|
||||
import com.bonus.bmw.domain.vo.PmWorker;
|
||||
import com.bonus.bmw.service.PmWorkerExitService;
|
||||
import com.bonus.bmw.service.impl.PmWorkerServiceImpl;
|
||||
import com.bonus.common.core.utils.json.FastJsonHelper;
|
||||
import com.bonus.common.core.web.controller.BaseController;
|
||||
import com.bonus.common.core.web.domain.AjaxResult;
|
||||
import com.bonus.common.core.web.page.TableDataInfo;
|
||||
|
|
@ -14,6 +17,7 @@ import com.bonus.common.security.annotation.RequiresPermissionsOrInnerAuth;
|
|||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
|
@ -54,11 +58,17 @@ public class PmWorkerExitController extends BaseController {
|
|||
|
||||
//, requiresPermissions = @RequiresPermissions("system:workerExit:exit")
|
||||
@RequiresPermissionsOrInnerAuth(innerAuth = @InnerAuth)
|
||||
@PostMapping("/exit/{id}/{workerId}")
|
||||
@PostMapping("/exit")
|
||||
@SysLog(title = "人员出场管理", businessType = OperaType.UPDATE, logType = 0, module = "施工人员->出入场管理->人员出场管理", details = "人员出场")
|
||||
public AjaxResult exit(@PathVariable("id") Integer id,@PathVariable("workerId") Integer workerId) {
|
||||
public AjaxResult exit(@RequestParam(value = "files") MultipartFile[] files, @RequestParam(value = "fileMsg") String fileMsg, @RequestParam(value = "params")String params) {
|
||||
try {
|
||||
return toAjax(service.updateWorkerExit(id,workerId));
|
||||
List<WebFileDto> listFile = FastJsonHelper.jsonArrStrToBeanList(fileMsg, WebFileDto.class);
|
||||
PmWorkerDto o = FastJsonHelper.jsonStrToBean(params, PmWorkerDto.class);
|
||||
//先将数据对应关系处理还
|
||||
for (int i = 0; i < listFile.size(); i++) {
|
||||
listFile.get(i).setFile(files[i]);
|
||||
}
|
||||
return toAjax(service.updateWorkerExit(o,listFile));
|
||||
} catch (Exception e) {
|
||||
logger.error(e.toString(), e);
|
||||
}
|
||||
|
|
@ -77,6 +87,45 @@ public class PmWorkerExitController extends BaseController {
|
|||
return error("系统异常,请联系管理员");
|
||||
}
|
||||
|
||||
/**
|
||||
* 人员补文件
|
||||
* @param
|
||||
* @return
|
||||
* , requiresPermissions = @RequiresPermissions("system:workerExit:batchExit")
|
||||
*/
|
||||
@RequiresPermissionsOrInnerAuth(innerAuth = @InnerAuth)
|
||||
@PostMapping("/exitFile")
|
||||
@SysLog(title = "人员出场管理", businessType = OperaType.UPDATE, logType = 0, module = "施工人员->出入场管理->人员出场管理", details = "人员出场")
|
||||
public AjaxResult exitFile(@RequestParam(value = "files") MultipartFile[] files, @RequestParam(value = "fileMsg") String fileMsg, @RequestParam(value = "params")String params) {
|
||||
try {
|
||||
List<WebFileDto> listFile = FastJsonHelper.jsonArrStrToBeanList(fileMsg, WebFileDto.class);
|
||||
PmWorkerDto o = FastJsonHelper.jsonStrToBean(params, PmWorkerDto.class);
|
||||
//先将数据对应关系处理还
|
||||
for (int i = 0; i < listFile.size(); i++) {
|
||||
listFile.get(i).setFile(files[i]);
|
||||
}
|
||||
return toAjax(service.exitFile(o,listFile));
|
||||
} catch (Exception e) {
|
||||
logger.error(e.toString(), e);
|
||||
}
|
||||
return error("系统异常,请联系管理员");
|
||||
}
|
||||
|
||||
/**
|
||||
* 单独查看文件
|
||||
*/
|
||||
//, requiresPermissions = @RequiresPermissions("system:contract:remove")
|
||||
@RequiresPermissionsOrInnerAuth(innerAuth = @InnerAuth)
|
||||
@PostMapping("/lookFile/{id}")
|
||||
@SysLog(title = "出场管理", businessType = OperaType.QUERY, logType = 0, module = "施工人员->红绿灯管理->出场管理", details = "单独查看文件")
|
||||
public AjaxResult lookFile(@PathVariable("id") Integer id) {
|
||||
try {
|
||||
return service.lookFileByPrimaryKey(id);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.toString(), e);
|
||||
}
|
||||
return error("系统异常,请联系管理员");
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询单人历史列表
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.bonus.bmw.domain.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
/**
|
||||
* @author: fly
|
||||
|
|
@ -18,4 +19,7 @@ public class WebFileDto {
|
|||
*/
|
||||
private String type;
|
||||
|
||||
|
||||
private MultipartFile file;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,10 @@
|
|||
package com.bonus.bmw.domain.vo;
|
||||
|
||||
import com.bonus.system.api.model.UploadFileVo;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 人员工资卡信息表
|
||||
*/
|
||||
|
|
@ -61,4 +64,9 @@ public class BmWorkerWageCard {
|
|||
* 手机号
|
||||
*/
|
||||
private String phone;
|
||||
|
||||
/**
|
||||
* 工资卡照片
|
||||
*/
|
||||
private List<UploadFileVo> files;
|
||||
}
|
||||
|
|
@ -29,7 +29,7 @@ public interface BmWorkerContractService{
|
|||
* @param record
|
||||
* @return
|
||||
*/
|
||||
int updateByPrimaryKey(BmWorkerContract record, FileBasicMsgDto files);
|
||||
int updateByPrimaryKey(BmWorkerContract record, List<WebFileDto> listFile);
|
||||
|
||||
/**
|
||||
* 查询合同列表
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.bonus.bmw.service;
|
||||
|
||||
import com.bonus.bmw.domain.dto.FileBasicMsgDto;
|
||||
import com.bonus.bmw.domain.dto.WebFileDto;
|
||||
import com.bonus.bmw.domain.vo.BmWorkerWageCard;
|
||||
import com.bonus.common.core.web.domain.AjaxResult;
|
||||
|
||||
|
|
@ -13,7 +14,7 @@ public interface BmWorkerWageCardService {
|
|||
* @param record
|
||||
* @return
|
||||
*/
|
||||
int updateByPrimaryKey(BmWorkerWageCard record, FileBasicMsgDto files);
|
||||
int updateByPrimaryKey(BmWorkerWageCard record, List<WebFileDto> listFile);
|
||||
|
||||
/**
|
||||
* 修改工资卡
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
package com.bonus.bmw.service;
|
||||
|
||||
import com.bonus.bmw.domain.dto.PmWorkerDto;
|
||||
import com.bonus.bmw.domain.dto.WebFileDto;
|
||||
import com.bonus.bmw.domain.vo.BmWorkerWageCard;
|
||||
import com.bonus.bmw.domain.vo.PmWorker;
|
||||
import com.bonus.common.core.web.domain.AjaxResult;
|
||||
|
||||
|
|
@ -18,11 +20,11 @@ public interface PmWorkerExitService {
|
|||
/**
|
||||
* 人员出场
|
||||
*
|
||||
* @param id
|
||||
* @param workerId
|
||||
* @param record
|
||||
* @param listFile
|
||||
* @return
|
||||
*/
|
||||
int updateWorkerExit(Integer id,Integer workerId);
|
||||
int updateWorkerExit(PmWorkerDto record, List<WebFileDto> listFile);
|
||||
|
||||
/**
|
||||
* 批量人员出场
|
||||
|
|
@ -39,4 +41,14 @@ public interface PmWorkerExitService {
|
|||
* @return
|
||||
*/
|
||||
List<PmWorker> selectWorkListByWorkerId(PmWorkerDto o);
|
||||
|
||||
int exitFile(PmWorkerDto o, List<WebFileDto> listFile);
|
||||
|
||||
/**
|
||||
* 单独查看文件
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
AjaxResult lookFileByPrimaryKey(Integer id);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
package com.bonus.bmw.service;
|
||||
|
||||
import com.bonus.bmw.domain.dto.FileBasicMsgDto;
|
||||
import com.bonus.bmw.domain.dto.PmWorkerDto;
|
||||
import com.bonus.bmw.domain.dto.WebFileDto;
|
||||
import com.bonus.bmw.domain.vo.BmWorkerWageCard;
|
||||
import com.bonus.bmw.domain.vo.PmWorker;
|
||||
import com.bonus.common.core.web.domain.AjaxResult;
|
||||
|
|
@ -11,11 +13,11 @@ public interface PmWorkerService{
|
|||
|
||||
int deleteByPrimaryKey(Integer id);
|
||||
|
||||
AjaxResult insert(PmWorker record);
|
||||
AjaxResult insert(PmWorker record, List<WebFileDto> listFile);
|
||||
|
||||
PmWorker selectByPrimaryKey(Integer id);
|
||||
|
||||
int updateByPrimaryKey(PmWorker record);
|
||||
int updateByPrimaryKey(PmWorker record,List<WebFileDto> listFile);
|
||||
|
||||
List<PmWorker> selectWorkList(PmWorkerDto o);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ public class BmWorkerContractServiceImpl implements BmWorkerContractService{
|
|||
*/
|
||||
@Transactional
|
||||
@Override
|
||||
public int updateByPrimaryKey(BmWorkerContract record,FileBasicMsgDto files) {
|
||||
public int updateByPrimaryKey(BmWorkerContract record, List<WebFileDto> listFile) {
|
||||
//如果有旧的有效合同执行删除
|
||||
if(record.getId() != null){
|
||||
deleteByPrimaryKey(record.getId());
|
||||
|
|
@ -66,13 +66,14 @@ public class BmWorkerContractServiceImpl implements BmWorkerContractService{
|
|||
}
|
||||
int insert = mapper.insert(record);
|
||||
if(insert > 0){
|
||||
//存文件
|
||||
List<WebFileDto> fileMsg = files.getFileMsg();
|
||||
String[] type = new String[fileMsg.size()];
|
||||
for (int i = 0; i < fileMsg.size(); i++) {
|
||||
type[i] = fileMsg.get(i).getType();
|
||||
//组装数据
|
||||
MultipartFile[] workerFiles = new MultipartFile[listFile.size()];
|
||||
String[] type = new String[listFile.size()];
|
||||
for (int i = 0; i < listFile.size(); i++) {
|
||||
workerFiles[i] = listFile.get(i).getFile();
|
||||
type[i] = listFile.get(i).getType();
|
||||
}
|
||||
List<UploadFileVo> uploadFileVos = fileUploadUtils.uploadFile(files.getFiles(), Constants.FILE_UPLOAD_CONTRACT, record.getId().toString(), type,"", "");
|
||||
List<UploadFileVo> uploadFileVos = fileUploadUtils.uploadFile(workerFiles, Constants.FILE_UPLOAD_CONTRACT, record.getId().toString(), type,"", "");
|
||||
}
|
||||
//将合同id保存到入场表
|
||||
mapper.updateEinRecordContractId(record.getId(),record.getWorkerId());
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ import org.slf4j.Logger;
|
|||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
|
@ -35,24 +36,39 @@ public class BmWorkerWageCardServiceImpl implements BmWorkerWageCardService {
|
|||
* @return
|
||||
*/
|
||||
@Override
|
||||
public int updateByPrimaryKey(BmWorkerWageCard record, FileBasicMsgDto files) {
|
||||
public int updateByPrimaryKey(BmWorkerWageCard record, List<WebFileDto> listFile) {
|
||||
//存在则删除后新增,不存在则新增
|
||||
if(record.getId() != null){
|
||||
deleteByPrimaryKey(record.getId());
|
||||
}
|
||||
record.setCreateUser(SecurityUtils.getUsername());
|
||||
int insert = mapper.insert(record);
|
||||
//添加到文件库和minio上
|
||||
if(insert > 0){
|
||||
//存文件
|
||||
List<WebFileDto> fileMsg = files.getFileMsg();
|
||||
String[] type = new String[fileMsg.size()];
|
||||
for (int i = 0; i < fileMsg.size(); i++) {
|
||||
type[i] = fileMsg.get(i).getType();
|
||||
log.info("存在则删除后新增,不存在则新增");
|
||||
//删除工资卡图片 删除minio文件
|
||||
fileUploadUtils.delFileListById("", record.getId().toString(), Constants.FILE_UPLOAD_WAGE_CARD,"");
|
||||
//组装数据
|
||||
MultipartFile[] workerFiles = new MultipartFile[listFile.size()];
|
||||
String[] type = new String[listFile.size()];
|
||||
for (int i = 0; i < listFile.size(); i++) {
|
||||
workerFiles[i] = listFile.get(i).getFile();
|
||||
type[i] = listFile.get(i).getType();
|
||||
}
|
||||
List<UploadFileVo> uploadFileVos = fileUploadUtils.uploadFile(files.getFiles(), Constants.FILE_UPLOAD_WAGE_CARD, record.getId().toString(), type,"", "");
|
||||
List<UploadFileVo> uploadFileVos = fileUploadUtils.uploadFile(workerFiles, Constants.FILE_UPLOAD_WAGE_CARD, record.getId().toString(), type,"", "");
|
||||
updateByPrimaryKeySelective(record);
|
||||
return 1;
|
||||
}else{
|
||||
//新增
|
||||
record.setCreateUser(SecurityUtils.getUsername());
|
||||
int insert = mapper.insert(record);
|
||||
//添加到文件库和minio上
|
||||
if(insert > 0){
|
||||
//组装数据
|
||||
MultipartFile[] workerFiles = new MultipartFile[listFile.size()];
|
||||
String[] type = new String[listFile.size()];
|
||||
for (int i = 0; i < listFile.size(); i++) {
|
||||
workerFiles[i] = listFile.get(i).getFile();
|
||||
type[i] = listFile.get(i).getType();
|
||||
}
|
||||
List<UploadFileVo> uploadFileVos = fileUploadUtils.uploadFile(workerFiles, Constants.FILE_UPLOAD_WAGE_CARD, record.getId().toString(), type,"", "");
|
||||
}
|
||||
return insert;
|
||||
}
|
||||
return insert;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -64,7 +80,6 @@ public class BmWorkerWageCardServiceImpl implements BmWorkerWageCardService {
|
|||
@Override
|
||||
public int updateByPrimaryKeySelective(BmWorkerWageCard record) {
|
||||
record.setUpdateUser(SecurityUtils.getUsername());
|
||||
//添加到文件库和minio上 TODO
|
||||
return mapper.updateByPrimaryKeySelective(record);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,12 +1,17 @@
|
|||
package com.bonus.bmw.service.impl;
|
||||
|
||||
import com.bonus.bmw.domain.dto.PmWorkerDto;
|
||||
import com.bonus.bmw.domain.dto.WebFileDto;
|
||||
import com.bonus.bmw.domain.vo.PmWorker;
|
||||
import com.bonus.bmw.mapper.PmWorkerExitMapper;
|
||||
import com.bonus.bmw.service.BmWorkerContractService;
|
||||
import com.bonus.bmw.service.PmWorkerExitService;
|
||||
import com.bonus.common.core.constant.Constants;
|
||||
import com.bonus.common.core.web.domain.AjaxResult;
|
||||
import com.bonus.system.api.model.UploadFileVo;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
|
@ -19,20 +24,31 @@ public class PmWorkerExitServiceImpl implements PmWorkerExitService {
|
|||
@Autowired
|
||||
private BmWorkerContractService contractService;
|
||||
|
||||
@Autowired
|
||||
private FileUploadUtils fileUploadUtils;
|
||||
|
||||
@Override
|
||||
public List<PmWorker> selectWorkList(PmWorkerDto o) {
|
||||
return mapper.selectWorkList(o);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int updateWorkerExit(Integer id, Integer workerId) {
|
||||
public int updateWorkerExit(PmWorkerDto record, List<WebFileDto> listFile) {
|
||||
//删除合同
|
||||
int i = contractService.deleteByWorkerId(workerId);
|
||||
int m = contractService.deleteByWorkerId(record.getWorkerId());
|
||||
//删除实时在场
|
||||
int j = mapper.deleteEinMsgByWorkerId(workerId);
|
||||
int n = mapper.deleteEinMsgByWorkerId(record.getWorkerId());
|
||||
//修改在场记录表状态
|
||||
int einStatus = 2;
|
||||
int k = mapper.updateEinProRecordStatus(id,einStatus);
|
||||
int k = mapper.updateEinProRecordStatus(record.getId(),einStatus);
|
||||
//组装数据
|
||||
MultipartFile[] workerFiles = new MultipartFile[listFile.size()];
|
||||
String[] type = new String[listFile.size()];
|
||||
for (int i = 0; i < listFile.size(); i++) {
|
||||
workerFiles[i] = listFile.get(i).getFile();
|
||||
type[i] = listFile.get(i).getType();
|
||||
}
|
||||
List<UploadFileVo> uploadFileVos = fileUploadUtils.uploadFile(workerFiles, Constants.FILE_UPLOAD_WORKER_EXIT, record.getId().toString(), type,"", "");
|
||||
return k;
|
||||
}
|
||||
|
||||
|
|
@ -61,4 +77,25 @@ public class PmWorkerExitServiceImpl implements PmWorkerExitService {
|
|||
return mapper.selectWorkListByWorkerId(o);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int exitFile(PmWorkerDto o, List<WebFileDto> listFile) {
|
||||
//删除文件
|
||||
fileUploadUtils.delFileListById("", o.getId().toString(), Constants.FILE_UPLOAD_WORKER_EXIT,"");
|
||||
//录入文件
|
||||
MultipartFile[] workerFiles = new MultipartFile[listFile.size()];
|
||||
String[] type = new String[listFile.size()];
|
||||
for (int i = 0; i < listFile.size(); i++) {
|
||||
workerFiles[i] = listFile.get(i).getFile();
|
||||
type[i] = listFile.get(i).getType();
|
||||
}
|
||||
List<UploadFileVo> uploadFileVos = fileUploadUtils.uploadFile(workerFiles, Constants.FILE_UPLOAD_WORKER_EXIT, o.getId().toString(), type,"", "");
|
||||
return !uploadFileVos.isEmpty() ?1:0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AjaxResult lookFileByPrimaryKey(Integer id) {
|
||||
List<UploadFileVo> contractFile = fileUploadUtils.getFileList("", id.toString(), Constants.FILE_UPLOAD_WORKER_EXIT, "");
|
||||
return AjaxResult.success(contractFile);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,14 +1,18 @@
|
|||
package com.bonus.bmw.service.impl;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.bonus.bmw.domain.dto.FileBasicMsgDto;
|
||||
import com.bonus.bmw.domain.dto.PmWorkerDto;
|
||||
import com.bonus.bmw.domain.dto.WebFileDto;
|
||||
import com.bonus.bmw.domain.vo.BmWorkerContract;
|
||||
import com.bonus.bmw.domain.vo.BmWorkerWageCard;
|
||||
import com.bonus.bmw.service.BmWorkerContractService;
|
||||
import com.bonus.bmw.service.BmWorkerWageCardService;
|
||||
import com.bonus.common.core.constant.Constants;
|
||||
import com.bonus.common.core.utils.StringUtils;
|
||||
import com.bonus.common.core.web.domain.AjaxResult;
|
||||
import com.bonus.common.security.utils.SecurityUtils;
|
||||
import com.bonus.system.api.model.UploadFileVo;
|
||||
import com.github.pagehelper.util.StringUtil;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
|
@ -18,10 +22,10 @@ import com.bonus.bmw.mapper.PmWorkerMapper;
|
|||
import com.bonus.bmw.domain.vo.PmWorker;
|
||||
import com.bonus.bmw.service.PmWorkerService;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
public class PmWorkerServiceImpl implements PmWorkerService{
|
||||
|
|
@ -35,6 +39,9 @@ public class PmWorkerServiceImpl implements PmWorkerService{
|
|||
@Autowired
|
||||
private BmWorkerContractService contractService;
|
||||
|
||||
@Autowired
|
||||
private FileUploadUtils fileUploadUtils;
|
||||
|
||||
@Override
|
||||
public int deleteByPrimaryKey(Integer id) {
|
||||
return mapper.deleteByPrimaryKey(id);
|
||||
|
|
@ -42,7 +49,7 @@ public class PmWorkerServiceImpl implements PmWorkerService{
|
|||
|
||||
@Override
|
||||
@Transactional
|
||||
public AjaxResult insert(PmWorker record) {
|
||||
public AjaxResult insert(PmWorker record,List<WebFileDto> fileMsg) {
|
||||
// 添加员工时,判断员工编号是否已存在
|
||||
PmWorker worker = mapper.getWorkerByNumber(record.getIdNumber());
|
||||
if(worker != null && worker.getId() != null){
|
||||
|
|
@ -51,8 +58,18 @@ public class PmWorkerServiceImpl implements PmWorkerService{
|
|||
record.setCreateUser(SecurityUtils.getUsername());
|
||||
int insert = mapper.insert(record);
|
||||
if(insert > 0){
|
||||
List<WebFileDto> collect = fileMsg.stream().filter(data -> "人脸".equals(data.getName())).collect(Collectors.toList());
|
||||
//组装数据
|
||||
MultipartFile[] workerFiles = new MultipartFile[collect.size()];
|
||||
String[] type = new String[collect.size()];
|
||||
for (int i = 0; i < collect.size(); i++) {
|
||||
workerFiles[i] = collect.get(i).getFile();
|
||||
type[i] = collect.get(i).getType();
|
||||
}
|
||||
//人脸的数据添加
|
||||
List<UploadFileVo> uploadFileVos = fileUploadUtils.uploadFile(workerFiles, Constants.FILE_UPLOAD_WORKER, record.getId().toString(), type,"", "");
|
||||
//入场相关数据添加
|
||||
addWorkerEinData(record);
|
||||
addWorkerEinData(record,fileMsg);
|
||||
}
|
||||
return new AjaxResult(200, "添加成功");
|
||||
}
|
||||
|
|
@ -61,9 +78,9 @@ public class PmWorkerServiceImpl implements PmWorkerService{
|
|||
* 基础数据添加完毕,在进行入场数据添加
|
||||
* @param record
|
||||
*/
|
||||
private void addWorkerEinData(PmWorker record) {
|
||||
private void addWorkerEinData(PmWorker record, List<WebFileDto> fileMsg) {
|
||||
//工资卡和合同数据
|
||||
addWorkerWageCardDataAndContract(record);
|
||||
addWorkerWageCardDataAndContract(record,fileMsg);
|
||||
record.setEinTime(DateUtil.now());
|
||||
record.setEinStatus(1);
|
||||
//1.bm_worker_ein_msg
|
||||
|
|
@ -75,22 +92,20 @@ public class PmWorkerServiceImpl implements PmWorkerService{
|
|||
//4.pm_user 添加人员登录表 TODO
|
||||
}
|
||||
|
||||
private void addWorkerWageCardDataAndContract(PmWorker record) {
|
||||
private void addWorkerWageCardDataAndContract(PmWorker record, List<WebFileDto> fileMsg) {
|
||||
BmWorkerWageCard bmWorkerWageCard = record.getBmWorkerWageCard();
|
||||
BmWorkerContract bmWorkerContract = record.getBmWorkerContract();
|
||||
if(bmWorkerWageCard != null && StringUtil.isNotEmpty(bmWorkerWageCard.getBankCardCode())){
|
||||
bmWorkerWageCard.setCreateUser(SecurityUtils.getUsername());
|
||||
bmWorkerWageCard.setWorkerId(record.getId());
|
||||
// if(bmWorkerWageCard.getId() != null){
|
||||
// wageCardService.updateByPrimaryKeySelective(bmWorkerWageCard);
|
||||
// }else{
|
||||
wageCardService.updateByPrimaryKey(bmWorkerWageCard);
|
||||
// }
|
||||
List<WebFileDto> collect = fileMsg.stream().filter(data -> "工资卡".equals(data.getName())).collect(Collectors.toList());
|
||||
wageCardService.updateByPrimaryKey(bmWorkerWageCard,collect);
|
||||
}
|
||||
if(bmWorkerContract != null && StringUtil.isNotEmpty(bmWorkerContract.getContractCode())){
|
||||
bmWorkerContract.setCreateUser(SecurityUtils.getUsername());
|
||||
bmWorkerContract.setWorkerId(record.getId());
|
||||
// contractService.updateByPrimaryKey(bmWorkerContract);
|
||||
List<WebFileDto> collect = fileMsg.stream().filter(data -> "合同".equals(data.getName())).collect(Collectors.toList());
|
||||
contractService.updateByPrimaryKey(bmWorkerContract,collect);
|
||||
record.setContractId(bmWorkerContract.getId());
|
||||
}
|
||||
}
|
||||
|
|
@ -121,7 +136,7 @@ public class PmWorkerServiceImpl implements PmWorkerService{
|
|||
*/
|
||||
@Transactional
|
||||
@Override
|
||||
public int updateByPrimaryKey(PmWorker record) {
|
||||
public int updateByPrimaryKey(PmWorker record,List<WebFileDto> fileMsg) {
|
||||
//更新基础数据
|
||||
record.setUpdateUser(SecurityUtils.getUsername());
|
||||
int update = mapper.updateByPrimaryKey(record);
|
||||
|
|
@ -129,9 +144,9 @@ public class PmWorkerServiceImpl implements PmWorkerService{
|
|||
mapper.updateEinRecordLast(record.getId());
|
||||
//已经入过场了
|
||||
if(record.getEinStatus() == 1){
|
||||
addWorkerWageCardDataAndContract(record);
|
||||
addWorkerWageCardDataAndContract(record,fileMsg);
|
||||
}else {
|
||||
addWorkerEinData(record);
|
||||
addWorkerEinData(record,fileMsg);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,10 +21,11 @@
|
|||
|
||||
<select id="selectWorkList" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
pw.id,
|
||||
pw.id as worker_id,
|
||||
pw.`name`,
|
||||
pw.id_number,
|
||||
pw.phone,
|
||||
bwepr.id,
|
||||
bwepr.pro_id,
|
||||
bwepr.pro_name,
|
||||
bwepr.sub_id,
|
||||
|
|
|
|||
Loading…
Reference in New Issue