物资领料逻辑修改 app人员管理接口

This commit is contained in:
lcj
2025-09-02 17:32:42 +08:00
parent de5c569f88
commit 9aef0d4b86
18 changed files with 287 additions and 103 deletions

View File

@ -50,6 +50,19 @@ public class SubConstructionUserAppController {
return R.ok(constructionUserService.getVo(constructionUser));
}
/**
* 根据用户id查询施工人员信息
*/
@GetMapping("/user/{userId}")
public R<SubConstructionUserVo> queryByUserId(@NotNull(message = "用户主键不能为空")
@PathVariable Long userId) {
SubConstructionUser constructionUser = constructionUserService.getBySysUserId(userId);
if (constructionUser == null) {
return R.fail("查询施工人员不存在");
}
return R.ok(constructionUserService.getVo(constructionUser));
}
/**
* 根据id查询施工人员信息
*/

View File

@ -0,0 +1,38 @@
package org.dromara.contractor.controller.app;
import jakarta.annotation.Resource;
import org.dromara.common.core.domain.R;
import org.dromara.common.web.core.BaseController;
import org.dromara.contractor.domain.dto.constructionuserfile.SubConstructionUserFileQueryReq;
import org.dromara.contractor.domain.vo.constructionuserfile.SubConstructionUserFileVo;
import org.dromara.contractor.service.ISubConstructionUserFileService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* 施工人员文件存储 app 接口
*
* @author lilemy
* @date 2025-09-02 17:20
*/
@Validated
@RestController
@RequestMapping("/app/contractor/constructionUserFile")
public class SubConstructionUserFileAppController extends BaseController {
@Resource
private ISubConstructionUserFileService constructionUserFileService;
/**
* 查询施工人员文件存储列表
*/
@GetMapping("/list")
public R<List<SubConstructionUserFileVo>> list(SubConstructionUserFileQueryReq req) {
return R.ok(constructionUserFileService.queryList(req));
}
}

View File

@ -15,11 +15,6 @@ public class SubConstructionUserFileQueryReq implements Serializable {
@Serial
private static final long serialVersionUID = 552027602186820020L;
/**
* 主键id
*/
private Long id;
/**
* 用户id
*/
@ -30,9 +25,4 @@ public class SubConstructionUserFileQueryReq implements Serializable {
*/
private String fileType;
/**
* 备注
*/
private String remark;
}

View File

@ -58,6 +58,11 @@ public class SubConstructionUserVo implements Serializable {
@ExcelProperty(value = "项目id")
private Long projectId;
/**
* 项目名称
*/
private String projectName;
/**
* 分包公司id
*/

View File

@ -17,21 +17,20 @@ import org.dromara.common.core.utils.DateUtils;
import org.dromara.common.core.utils.ObjectUtils;
import org.dromara.common.core.utils.StringUtils;
import org.dromara.common.core.utils.file.FileUtils;
import org.dromara.common.satoken.utils.LoginHelper;
import org.dromara.contractor.domain.SubConstructionUserFile;
import org.dromara.contractor.constant.SubConstructionUserConstant;
import org.dromara.project.domain.BusConstructionBlacklist;
import org.dromara.contractor.domain.SubConstructionUser;
import org.dromara.project.domain.BusProject;
import org.dromara.contractor.domain.SubConstructionUserFile;
import org.dromara.contractor.domain.dto.constructionuserfile.SubConstructionUserFileQueryReq;
import org.dromara.contractor.domain.dto.constructionuserfile.SubConstructionUserFileReq;
import org.dromara.contractor.domain.dto.constructionuserfile.SubConstructionUserFileSaveReq;
import org.dromara.contractor.domain.dto.constructionuserfile.SubConstructionUserFileTemplateReq;
import org.dromara.contractor.domain.vo.constructionuserfile.SubConstructionUserFileVo;
import org.dromara.contractor.mapper.SubConstructionUserFileMapper;
import org.dromara.project.service.IBusConstructionBlacklistService;
import org.dromara.contractor.service.ISubConstructionUserFileService;
import org.dromara.contractor.service.ISubConstructionUserService;
import org.dromara.project.domain.BusConstructionBlacklist;
import org.dromara.project.domain.BusProject;
import org.dromara.project.service.IBusConstructionBlacklistService;
import org.dromara.project.service.IBusProjectService;
import org.dromara.system.domain.vo.SysDictDataVo;
import org.dromara.system.domain.vo.SysOssVo;
@ -132,7 +131,7 @@ public class SubConstructionUserFileServiceImpl extends ServiceImpl<SubConstruct
zipOut.closeEntry();
// 7. 对每个人,创建其文件夹,再在其中创建子文件夹(如“三级安全教育”、“体检报告”...)及文件
for (SubConstructionUser constructionUser : constructionUserList) {
String personFolder = rootFolder + constructionUser.getUserName() + "-" + constructionUser.getId() + "/";
String personFolder = rootFolder + constructionUser.getUserName() + "-" + constructionUser.getSysUserId() + "/";
// 7.1. 写入个人文件夹条目
zipOut.putNextEntry(new ZipEntry(personFolder));
zipOut.closeEntry();
@ -316,18 +315,16 @@ public class SubConstructionUserFileServiceImpl extends ServiceImpl<SubConstruct
throw new ServiceException("施工人员文件存储参数错误", HttpStatus.BAD_REQUEST);
}
// 校验修改用户是否存在
SubConstructionUser constructionUser = constructionUserService.getById(userId);
SubConstructionUser constructionUser = constructionUserService.getBySysUserId(userId);
if (constructionUser == null) {
throw new ServiceException("施工人员不存在", HttpStatus.NOT_FOUND);
}
// 判断登录用户是否有用户所在项目的操作权限
Long projectId = constructionUser.getProjectId();
Long loginUser = LoginHelper.getUserId();
projectService.validAuth(projectId, loginUser);
// 2. 查询当前用户的所有文件记录(一次性查询,避免多次访问数据库)
LambdaQueryWrapper<SubConstructionUserFile> lqw = Wrappers.lambdaQuery(SubConstructionUserFile.class)
.eq(SubConstructionUserFile::getUserId, userId);
List<SubConstructionUserFile> constructionUserFileList = this.list(lqw);
List<SubConstructionUserFile> constructionUserFileList = this.lambdaQuery()
.eq(SubConstructionUserFile::getUserId, userId)
.list();
// 3. 构建 Map<fileType, BusConstructionUserFile> 方便查找
Map<String, SubConstructionUserFile> existingFileMap = constructionUserFileList.stream()
.collect(Collectors.toMap(SubConstructionUserFile::getFileType, Function.identity()));
@ -392,14 +389,9 @@ public class SubConstructionUserFileServiceImpl extends ServiceImpl<SubConstruct
if (req == null) {
return lqw;
}
Long id = req.getId();
Long userId = req.getUserId();
String fileType = req.getFileType();
String remark = req.getRemark();
// 模糊查询
lqw.like(StringUtils.isNotBlank(remark), SubConstructionUserFile::getRemark, remark);
// 精确查询
lqw.eq(ObjectUtils.isNotEmpty(id), SubConstructionUserFile::getId, id);
lqw.eq(ObjectUtils.isNotEmpty(userId), SubConstructionUserFile::getUserId, userId);
lqw.eq(StringUtils.isNotBlank(fileType), SubConstructionUserFile::getFileType, fileType);
return lqw;
@ -440,7 +432,7 @@ public class SubConstructionUserFileServiceImpl extends ServiceImpl<SubConstruct
.eq(BusConstructionBlacklist::getProjectId, projectId)
.list().stream().map(BusConstructionBlacklist::getUserId).toList();
if (CollUtil.isNotEmpty(blacklistUserIdList)) {
lqw.notIn(SubConstructionUser::getId, blacklistUserIdList);
lqw.notIn(SubConstructionUser::getSysUserId, blacklistUserIdList);
}
return lqw;
}

View File

@ -646,6 +646,11 @@ public class SubConstructionUserServiceImpl extends ServiceImpl<SubConstructionU
return constructionUserVo;
}
BeanUtils.copyProperties(constructionUser, constructionUserVo);
// 关联项目名称
Long projectId = constructionUser.getProjectId();
if (projectId != null) {
constructionUserVo.setProjectName(projectService.getById(projectId).getProjectName());
}
// 关联查询分包公司信息信息
Long contractorId = constructionUser.getContractorId();
if (contractorId != null) {
@ -657,7 +662,6 @@ public class SubConstructionUserServiceImpl extends ServiceImpl<SubConstructionU
constructionUserVo.setFacePicUrl(ossService.getById(Long.parseLong(facePic)).getUrl());
}
// 关联查询薪水标准
Long projectId = constructionUser.getProjectId();
String typeOfWork = constructionUser.getTypeOfWork();
String wageMeasureUnit = constructionUser.getWageMeasureUnit();
if (projectId != null && StringUtils.isNotEmpty(typeOfWork) && StringUtils.isNotEmpty(wageMeasureUnit)) {
@ -739,7 +743,7 @@ public class SubConstructionUserServiceImpl extends ServiceImpl<SubConstructionU
List<Long> blackUserIdList = constructionBlacklistService.queryIdListByProjectId(projectId);
// 查询结果移除黑名单人员
if (CollUtil.isNotEmpty(blackUserIdList)) {
lqw.notIn(SubConstructionUser::getId, blackUserIdList);
lqw.notIn(SubConstructionUser::getSysUserId, blackUserIdList);
}
}
lqw.ne(StringUtils.isNotBlank(notUserRole), SubConstructionUser::getUserRole, notUserRole);
@ -887,7 +891,7 @@ public class SubConstructionUserServiceImpl extends ServiceImpl<SubConstructionU
List<Long> blackUserIdList = constructionBlacklistService.queryIdListByProjectId(projectId);
// 查询结果移除黑名单人员
if (CollUtil.isNotEmpty(blackUserIdList)) {
lqw.notIn(SubConstructionUser::getId, blackUserIdList);
lqw.notIn(SubConstructionUser::getSysUserId, blackUserIdList);
}
// 分页查询获取数据
Page<SubConstructionUser> constructionUserPage = this.page(pageQuery.build(), lqw);

View File

@ -84,6 +84,11 @@ public class MatMaterialsInventory extends BaseEntity {
*/
private String shipper;
/**
* 是否领用(0未领用 1已领用)
*/
private String isReceive;
/**
* 备注
*/

View File

@ -0,0 +1,23 @@
package org.dromara.materials.domain.enums;
import lombok.Getter;
/**
* @author lilemy
* @date 2025-09-02 15:47
*/
@Getter
public enum MatMaterialsInventoryReceiveStatusEnum {
NOT("未领用", "0"),
USED("已领用", "1");
private final String text;
private final String value;
MatMaterialsInventoryReceiveStatusEnum(String text, String value) {
this.text = text;
this.value = value;
}
}

View File

@ -1,10 +1,13 @@
package org.dromara.materials.domain.vo.materials;
import lombok.Data;
import org.dromara.materials.domain.vo.materialsinventory.MatMaterialsInventoryOutVo;
import java.io.Serial;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
/**
* @author lilemy
@ -40,4 +43,14 @@ public class MatMaterialsNumberVo implements Serializable {
* 库存数量
*/
private BigDecimal inventoryNumber;
/**
* 创建时间
*/
private Date createTime;
/**
* 出库列表
*/
private List<MatMaterialsInventoryOutVo> outList;
}

View File

@ -0,0 +1,34 @@
package org.dromara.materials.domain.vo.materialsinventory;
import lombok.Data;
import java.io.Serial;
import java.io.Serializable;
import java.util.Date;
/**
* @author lilemy
* @date 2025-09-02 15:29
*/
@Data
public class MatMaterialsInventoryOutVo implements Serializable {
@Serial
private static final long serialVersionUID = -5887469045010555290L;
/**
* 出/入库的数量
*/
private Long number;
/**
* 剩余库存数量(记录最后一次操作留下的库存数)
*/
private Long residue;
/**
* 创建时间
*/
private Date createTime;
}

View File

@ -36,7 +36,6 @@ import org.dromara.materials.domain.dto.materialissue.MatMaterialIssueUpdateReq;
import org.dromara.materials.domain.dto.materialissue.MatMaterialIssueWordDto;
import org.dromara.materials.domain.dto.materialissueitem.MatMaterialIssueItemDto;
import org.dromara.materials.domain.dto.materialissueitem.MatMaterialIssueItemWordDto;
import org.dromara.materials.domain.enums.MatMaterialsInventoryOutPutEnum;
import org.dromara.materials.domain.vo.materialissue.MatMaterialIssueVo;
import org.dromara.materials.domain.vo.materialsinventory.MatMaterialsInventoryListVo;
import org.dromara.materials.mapper.MatMaterialIssueMapper;
@ -260,13 +259,15 @@ public class MatMaterialIssueServiceImpl extends ServiceImpl<MatMaterialIssueMap
BeanUtils.copyProperties(item, materialIssueItem);
materialIssueItem.setIssueId(materialIssue.getId());
materialIssueItem.setProjectId(materialIssue.getProjectId());
// 截取名称
materialIssueItem.setName(item.getName().split("_")[0]);
return materialIssueItem;
}).toList();
boolean result = materialIssueItemService.saveBatch(materialIssueItemList);
if (!result) {
throw new ServiceException("物料领料单明细项新增失败", HttpStatus.ERROR);
}
// 创建设备材料出库记录
/* // 创建设备材料出库记录
List<MatMaterialsInventory> inventoryList = itemList.stream().map(item -> {
MatMaterialsInventory inventory = new MatMaterialsInventory();
inventory.setNumber(item.getIssuedQuantity().longValue());
@ -284,7 +285,7 @@ public class MatMaterialIssueServiceImpl extends ServiceImpl<MatMaterialIssueMap
boolean saved = materialsInventoryService.saveBatch(inventoryList);
if (!saved) {
throw new ServiceException("物料出库记录新增失败", HttpStatus.ERROR);
}
}*/
}
return true;
}

View File

@ -26,10 +26,12 @@ import org.dromara.materials.domain.dto.materials.MatMaterialsQueryReq;
import org.dromara.materials.domain.dto.materials.MatMaterialsUpdateReq;
import org.dromara.materials.domain.dto.materialsinventory.MatMaterialsInventoryCreateReq;
import org.dromara.materials.domain.enums.MatMaterialsInventoryOutPutEnum;
import org.dromara.materials.domain.enums.MatMaterialsInventoryReceiveStatusEnum;
import org.dromara.materials.domain.vo.materials.MatMaterialsByFormCodeVo;
import org.dromara.materials.domain.vo.materials.MatMaterialsGisVo;
import org.dromara.materials.domain.vo.materials.MatMaterialsNumberVo;
import org.dromara.materials.domain.vo.materials.MatMaterialsVo;
import org.dromara.materials.domain.vo.materialsinventory.MatMaterialsInventoryOutVo;
import org.dromara.materials.mapper.MatMaterialsMapper;
import org.dromara.materials.service.IMatCompanyService;
import org.dromara.materials.service.IMatMaterialReceiveService;
@ -419,55 +421,74 @@ public class MatMaterialsServiceImpl extends ServiceImpl<MatMaterialsMapper, Mat
.eq(MatMaterials::getStatus, "0")
.list();
if (CollUtil.isEmpty(materials)) {
return null;
return Collections.emptyList();
}
// 过滤出有 formCode 的材料
List<Long> materialIds = materials.stream()
.filter(material -> StringUtils.isNotBlank(material.getFormCode()))
.filter(m -> StringUtils.isNotBlank(m.getFormCode()))
.map(MatMaterials::getId)
.toList();
List<MatMaterialsInventory> materialsInventories = materialsInventoryService.selectLatestByMaterialIds(materialIds);
Map<Long, MatMaterialsInventory> inventoryMap = materialsInventories.stream().collect(Collectors.toMap(
MatMaterialsInventory::getMaterialsId,
Function.identity(),
(a, b) -> a));
// 查询最新库存
Map<Long, MatMaterialsInventory> inventoryMap = materialsInventoryService
.selectLatestByMaterialIds(materialIds)
.stream()
.collect(Collectors.toMap(MatMaterialsInventory::getMaterialsId, Function.identity(), (a, b) -> a));
// 查询出库记录
List<MatMaterialsInventory> outList = materialsInventoryService.lambdaQuery()
.in(MatMaterialsInventory::getMaterialsId, materialIds)
.eq(MatMaterialsInventory::getOutPut, MatMaterialsInventoryOutPutEnum.OUT.getValue())
.eq(MatMaterialsInventory::getIsReceive, MatMaterialsInventoryReceiveStatusEnum.NOT.getValue())
.list();
Map<Long, List<MatMaterialsInventory>> outMap = new HashMap<>();
if (CollUtil.isNotEmpty(outList)) {
outMap = outList.stream()
.collect(Collectors.groupingBy(MatMaterialsInventory::getMaterialsId));
}
Map<Long, List<MatMaterialsInventory>> finalOutMap = outMap;
// 按 formCode 分组
Map<String, List<MatMaterials>> formCodeMap = materials.stream()
.collect(Collectors.groupingBy(MatMaterials::getFormCode));
Set<String> formCodeList = materials.stream().map(MatMaterials::getFormCode).collect(Collectors.toSet());
List<MatMaterialReceive> receiveList = materialReceiveService.lambdaQuery()
// 查询入库单
Set<String> formCodeList = formCodeMap.keySet();
Map<String, MatMaterialReceive> receiveMap = materialReceiveService.lambdaQuery()
.in(MatMaterialReceive::getFormCode, formCodeList)
.list();
Map<String, MatMaterialReceive> receiveMap = receiveList.stream().collect(Collectors.toMap(
MatMaterialReceive::getFormCode,
Function.identity(),
(a, b) -> a));
.list()
.stream()
.collect(Collectors.toMap(MatMaterialReceive::getFormCode, Function.identity(), (a, b) -> a));
List<MatMaterialsByFormCodeVo> resultList = new ArrayList<>();
for (Map.Entry<String, List<MatMaterials>> entry : formCodeMap.entrySet()) {
String key = entry.getKey();
List<MatMaterials> value = entry.getValue();
List<MatMaterials> list = value.stream().filter(material -> {
Long materialId = material.getId();
if (inventoryMap.containsKey(materialId)) {
MatMaterialsInventory inventory = inventoryMap.get(materialId);
Long residue = inventory.getResidue();
return residue > 0;
}
return false;
}).toList();
if (CollUtil.isEmpty(list)) {
String formCode = entry.getKey();
// 过滤库存为 0 的材料
List<MatMaterials> validMaterials = entry.getValue().stream()
.filter(m -> {
MatMaterialsInventory inv = inventoryMap.get(m.getId());
return inv != null && inv.getResidue() > 0;
})
.toList();
if (CollUtil.isEmpty(validMaterials)) {
continue;
}
// 组装结果
MatMaterialsByFormCodeVo vo = new MatMaterialsByFormCodeVo();
vo.setFormCode(key);
if (receiveMap.containsKey(key)) {
MatMaterialReceive receive = receiveMap.get(key);
vo.setFormCode(formCode);
MatMaterialReceive receive = receiveMap.get(formCode);
if (receive != null) {
BeanUtils.copyProperties(receive, vo);
}
List<MatMaterialsNumberVo> numberVos = value.stream().map(material -> {
List<MatMaterialsNumberVo> numberVos = validMaterials.stream().map(m -> {
MatMaterialsNumberVo numberVo = new MatMaterialsNumberVo();
BeanUtils.copyProperties(material, numberVo);
Long materialId = material.getId();
if (inventoryMap.containsKey(materialId)) {
numberVo.setInventoryNumber(BigDecimal.valueOf(inventoryMap.get(materialId).getNumber()));
BeanUtils.copyProperties(m, numberVo);
MatMaterialsInventory inv = inventoryMap.get(m.getId());
if (inv != null) {
numberVo.setInventoryNumber(BigDecimal.valueOf(inv.getNumber()));
}
if (CollUtil.isNotEmpty(finalOutMap) && finalOutMap.containsKey(m.getId())) {
List<MatMaterialsInventory> outs = finalOutMap.get(m.getId());
numberVo.setOutList(outs.stream().map(out -> {
MatMaterialsInventoryOutVo outVo = new MatMaterialsInventoryOutVo();
BeanUtils.copyProperties(out, outVo);
return outVo;
}).toList());
}
return numberVo;
}).toList();

View File

@ -15,11 +15,6 @@ public class BusConstructionBlacklistQueryReq implements Serializable {
@Serial
private static final long serialVersionUID = 5638694783769399209L;
/**
* 主键id
*/
private Long id;
/**
* 项目id
*/

View File

@ -1,5 +1,6 @@
package org.dromara.project.domain.dto.constructionuserexit;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
import java.io.Serial;
@ -16,8 +17,9 @@ public class BusConstructionUserExitCreateReq implements Serializable {
private static final long serialVersionUID = -722474400854585360L;
/**
* 主键id
* 用户id
*/
@NotNull(message = "用户id不能为空")
private Long userId;
/**

View File

@ -4,50 +4,41 @@ import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import jakarta.annotation.Resource;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.dromara.common.core.domain.R;
import org.dromara.common.core.enums.FormatsType;
import org.dromara.common.core.constant.HttpStatus;
import org.dromara.common.core.exception.ServiceException;
import org.dromara.common.core.utils.DateUtils;
import org.dromara.common.core.utils.MapstructUtils;
import org.dromara.common.core.utils.StringUtils;
import org.dromara.common.domain.GeoPoint;
import org.dromara.common.mybatis.core.page.TableDataInfo;
import org.dromara.common.mybatis.core.page.PageQuery;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import lombok.RequiredArgsConstructor;
import org.dromara.common.mybatis.core.page.TableDataInfo;
import org.dromara.common.satoken.utils.LoginHelper;
import org.dromara.common.utils.JSTUtil;
import org.dromara.contractor.domain.SubConstructionUser;
import org.dromara.contractor.service.ISubConstructionUserService;
import org.dromara.project.domain.*;
import org.dromara.project.domain.bo.BusProjectPunchrangeBo;
import org.dromara.project.domain.bo.BusAttendanceBo;
import org.dromara.project.domain.dto.attendance.BusAttendancePunchCardByFaceReq;
import org.dromara.project.domain.enums.BusAttendanceClockStatusEnum;
import org.dromara.project.domain.enums.BusAttendanceCommuterEnum;
import org.dromara.project.domain.vo.BusAttendanceRuleVo;
import org.dromara.project.domain.vo.BusAttendanceVo;
import org.dromara.project.domain.vo.BusMonthAttendanceVo;
import org.dromara.project.domain.vo.BusProjectPunchrangeVo;
import org.dromara.project.mapper.BusAttendanceMapper;
import org.dromara.project.service.*;
import org.dromara.system.domain.vo.SysOssVo;
import org.dromara.system.service.ISysOssService;
import org.springframework.stereotype.Service;
import org.dromara.project.domain.bo.BusAttendanceBo;
import org.dromara.project.domain.vo.BusAttendanceVo;
import org.dromara.project.mapper.BusAttendanceMapper;
import org.springframework.web.multipart.MultipartFile;
import org.dromara.common.core.constant.HttpStatus;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit;
import java.util.*;
import java.util.stream.Collectors;
@ -231,7 +222,7 @@ public class BusAttendanceServiceImpl extends ServiceImpl<BusAttendanceMapper, B
throw new ServiceException("当前用户已被禁止打卡", HttpStatus.BAD_REQUEST);
}
// 判断用户是否已经被拉黑
constructionBlacklistService.validUserInBlacklist(constructionUser.getId(), req.getProjectId());
constructionBlacklistService.validUserInBlacklist(constructionUser.getSysUserId(), req.getProjectId());
// 进行人脸比对
Boolean result = constructionUserService.faceComparison(file);

View File

@ -157,7 +157,7 @@ public class BusConstructionBlacklistServiceImpl extends ServiceImpl<BusConstruc
if (userId == null) {
throw new ServiceException("用户 id 不能为空", HttpStatus.BAD_REQUEST);
}
SubConstructionUser constructionUser = constructionUserService.getById(userId);
SubConstructionUser constructionUser = constructionUserService.getBySysUserId(userId);
if (constructionUser == null) {
throw new ServiceException("对应用户不存在", HttpStatus.NOT_FOUND);
}
@ -241,7 +241,6 @@ public class BusConstructionBlacklistServiceImpl extends ServiceImpl<BusConstruc
@Override
public LambdaQueryWrapper<BusConstructionBlacklist> buildQueryWrapper(BusConstructionBlacklistQueryReq req) {
LambdaQueryWrapper<BusConstructionBlacklist> lqw = new LambdaQueryWrapper<>();
Long id = req.getId();
Long userId = req.getUserId();
Long projectId = req.getProjectId();
String userName = req.getUserName();
@ -250,7 +249,6 @@ public class BusConstructionBlacklistServiceImpl extends ServiceImpl<BusConstruc
lqw.like(StringUtils.isNotBlank(userName), BusConstructionBlacklist::getUserName, userName);
lqw.like(StringUtils.isNotBlank(sfzNumber), BusConstructionBlacklist::getSfzNumber, sfzNumber);
// 精确查询
lqw.eq(ObjectUtils.isNotEmpty(id), BusConstructionBlacklist::getId, id);
lqw.eq(ObjectUtils.isNotEmpty(userId), BusConstructionBlacklist::getUserId, userId);
lqw.eq(ObjectUtils.isNotEmpty(projectId), BusConstructionBlacklist::getProjectId, projectId);
return lqw;

View File

@ -2,26 +2,36 @@ package org.dromara.project.service.impl;
import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import jakarta.annotation.Resource;
import org.dromara.common.core.constant.HttpStatus;
import org.dromara.common.core.exception.ServiceException;
import org.dromara.common.core.utils.ObjectUtils;
import org.dromara.common.core.utils.StringUtils;
import org.dromara.common.mybatis.core.page.PageQuery;
import org.dromara.common.mybatis.core.page.TableDataInfo;
import org.dromara.contractor.domain.SubConstructionUser;
import org.dromara.contractor.service.ISubConstructionUserService;
import org.dromara.project.domain.BusConstructionUserExit;
import org.dromara.project.domain.BusProjectTeamMember;
import org.dromara.project.domain.dto.constructionuserexit.BusConstructionUserExitCreateReq;
import org.dromara.project.domain.dto.constructionuserexit.BusConstructionUserExitQueryReq;
import org.dromara.project.domain.vo.constructionuserexit.BusConstructionUserExitVo;
import org.dromara.project.mapper.BusConstructionUserExitMapper;
import org.dromara.project.service.IBusConstructionUserExitService;
import org.dromara.project.service.IBusProjectTeamMemberService;
import org.dromara.system.domain.vo.SysOssVo;
import org.dromara.system.service.ISysOssService;
import org.springframework.beans.BeanUtils;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
/**
@ -37,6 +47,13 @@ public class BusConstructionUserExitServiceImpl extends ServiceImpl<BusConstruct
@Resource
private ISysOssService ossService;
@Lazy
@Resource
private IBusProjectTeamMemberService projectTeamMemberService;
@Resource
private ISubConstructionUserService constructionUserService;
/**
* 查询施工人员入场退场记录信息
*
@ -163,8 +180,50 @@ public class BusConstructionUserExitServiceImpl extends ServiceImpl<BusConstruct
* @return 新增结果
*/
@Override
@Transactional(rollbackFor = Exception.class)
public Boolean addRecord(BusConstructionUserExitCreateReq req) {
return null;
String salaryVoucherFile = req.getSalaryVoucherFile();
String salaryConfirmationFile = req.getSalaryConfirmationFile();
if (StringUtils.isAnyBlank(salaryVoucherFile, salaryConfirmationFile)) {
throw new ServiceException("请上传退场文件", HttpStatus.BAD_REQUEST);
}
Long userId = req.getUserId();
BusProjectTeamMember projectTeamMember = projectTeamMemberService.lambdaQuery()
.eq(BusProjectTeamMember::getMemberId, userId)
.one();
if (projectTeamMember == null) {
throw new ServiceException("对应项目班组下的成员不存在", HttpStatus.NOT_FOUND);
}
boolean result = projectTeamMemberService.removeById(projectTeamMember.getId());
if (!result) {
throw new ServiceException("施工人员退场失败,数据库异常", HttpStatus.ERROR);
}
// 将文件信息保存到数据库
SubConstructionUser constructionUser = constructionUserService.getBySysUserId(userId);
BusConstructionUserExit constructionUserExit = new BusConstructionUserExit();
constructionUserExit.setProjectId(constructionUser.getProjectId());
constructionUserExit.setUserId(constructionUser.getId());
constructionUserExit.setSalaryVoucherFile(salaryVoucherFile);
constructionUserExit.setSalaryConfirmationFile(salaryConfirmationFile);
constructionUserExit.setTeamId(constructionUser.getTeamId());
constructionUserExit.setSfzNumber(constructionUser.getSfzNumber());
constructionUserExit.setEntryDate(constructionUser.getEntryDate());
constructionUserExit.setLeaveDate(new Date());
constructionUserExit.setRemark(req.getRemark());
boolean save = this.save(constructionUserExit);
if (!save) {
throw new ServiceException("施工人员退场失败,数据库异常", HttpStatus.ERROR);
}
// 同步修改用户表的team_id字段
LambdaUpdateWrapper<SubConstructionUser> constructionUserLuw = Wrappers.lambdaUpdate(SubConstructionUser.class)
.eq(SubConstructionUser::getId, constructionUser.getId())
.set(SubConstructionUser::getTeamId, null)
.set(SubConstructionUser::getLeaveDate, new Date());
boolean update = constructionUserService.update(constructionUserLuw);
if (!update) {
throw new ServiceException("施工人员退场失败,数据库异常", HttpStatus.ERROR);
}
return true;
}
}

View File

@ -133,7 +133,7 @@ public class BusProjectTeamMemberServiceImpl extends ServiceImpl<BusProjectTeamM
Long memberId = projectTeamMember.getMemberId();
SubConstructionUser constructionUser = constructionUserService.getBySysUserId(memberId);
// 判断用户是否已经被拉黑
constructionBlacklistService.validUserInBlacklist(constructionUser.getId(), projectTeamMember.getProjectId());
constructionBlacklistService.validUserInBlacklist(constructionUser.getSysUserId(), projectTeamMember.getProjectId());
// 判断对应的用户与项目关联是否存在
BusProjectTeamMember teamMember = this.getOne(new LambdaQueryWrapper<BusProjectTeamMember>()
.eq(BusProjectTeamMember::getMemberId, memberId)