feat(smartfactory): 新增员工薪资发放功能并优化相关查询- 新增 StaffSalaryApi 接口和 StaffSalaryApiImpl 实现类,提供员工薪资发放的 RPC 服务
- 在 StaffSalaryService 中添加 updateIsGrant 方法,用于更新工资发放状态 - 在 StaffSalaryMapper 中增加对 isGrant 字段的查询支持 - 优化 FactoryInfoController,添加获取登录用户工厂列表的接口 - 更新 HandlingGroupAmountSpecifications 相关服务和 Mapper,支持按工厂 ID 查询- 在 StaffSalaryDO 中添加 isGrant 字段,表示是否发放工资 - 更新相关请求和响应 VO 类,支持 isGrant 字段
This commit is contained in:
parent
fa4b663a23
commit
967e02b067
@ -0,0 +1,28 @@
|
||||
package cn.iocoder.yudao.module.smartfactory.api.staffSalary;
|
||||
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.module.smartfactory.api.staff.dto.StaffDTO;
|
||||
import cn.iocoder.yudao.module.smartfactory.enums.ApiConstants;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
@FeignClient(name = ApiConstants.NAME) // TODO 芋艿:fallbackFactory =
|
||||
@Tag(name = "RPC 服务 - 厂区员工薪资")
|
||||
public interface StaffSalaryApi {
|
||||
|
||||
String PREFIX = ApiConstants.PREFIX + "/staffSalary";
|
||||
|
||||
@PutMapping(PREFIX + "/updateIsGrant")
|
||||
@Operation(summary = "更新是否已发放薪资")
|
||||
CommonResult<Boolean> updateIsGrant(@RequestParam("ids") Collection<Long> ids,
|
||||
@RequestParam("isGrant") Integer isGrant);
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
package cn.iocoder.yudao.module.smartfactory.api.staffSalary;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.module.smartfactory.service.staffsalary.StaffSalaryService;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Collection;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
|
||||
@RestController // 提供 RESTful API 接口,给 Feign 调用
|
||||
@Validated
|
||||
public class StaffSalaryApiImpl implements StaffSalaryApi {
|
||||
|
||||
@Resource
|
||||
private StaffSalaryService staffSalaryService;
|
||||
|
||||
@Override
|
||||
public CommonResult<Boolean> updateIsGrant(Collection<Long> ids, Integer isGrant) {
|
||||
staffSalaryService.updateIsGrant(ids, isGrant);
|
||||
return success(true);
|
||||
}
|
||||
}
|
@ -124,6 +124,15 @@ public class FactoryInfoController {
|
||||
return success(BeanUtils.toBean(factoryInfo, FactorySimpleRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/factory-list")
|
||||
@Operation(summary = "取登录用户工厂列表, 登陆用户无工厂则拉取所有工厂 | 用于前端下拉框")
|
||||
@PreAuthorize("@ss.hasPermission('smartfactory:factory-info:query')")
|
||||
public CommonResult<List<FactorySimpleRespVO>> getFactoryListByLoginUser() {
|
||||
|
||||
List<FactoryInfoDO> factoryInfo = factoryInfoService.getFactoryListByLoginUser();
|
||||
return success(BeanUtils.toBean(factoryInfo, FactorySimpleRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/get-tree")
|
||||
@Operation(summary = "获得工厂树结构")
|
||||
@PreAuthorize("@ss.hasPermission('smartfactory:factory-info:query')")
|
||||
|
@ -11,7 +11,9 @@ import cn.iocoder.yudao.module.smartfactory.controller.admin.handlinggroupamount
|
||||
import cn.iocoder.yudao.module.smartfactory.controller.admin.handlinggroupamountspecifications.vo.HandlingGroupAmountSpecificationsPageReqVO;
|
||||
import cn.iocoder.yudao.module.smartfactory.controller.admin.handlinggroupamountspecifications.vo.HandlingGroupAmountSpecificationsRespVO;
|
||||
import cn.iocoder.yudao.module.smartfactory.controller.admin.handlinggroupamountspecifications.vo.HandlingGroupAmountSpecificationsSaveReqVO;
|
||||
import cn.iocoder.yudao.module.smartfactory.dal.dataobject.factoryinfo.FactoryInfoDO;
|
||||
import cn.iocoder.yudao.module.smartfactory.dal.dataobject.handlinggroupamountspecifications.HandlingGroupAmountSpecificationsDO;
|
||||
import cn.iocoder.yudao.module.smartfactory.service.factoryinfo.FactoryInfoService;
|
||||
import cn.iocoder.yudao.module.smartfactory.service.handlinggroupamountspecifications.HandlingGroupAmountSpecificationsService;
|
||||
import cn.iocoder.yudao.module.system.api.dept.DeptApi;
|
||||
import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO;
|
||||
@ -45,7 +47,7 @@ public class HandlingGroupAmountSpecificationsController {
|
||||
private HandlingGroupAmountSpecificationsService handlingGroupAmountSpecificationsService;
|
||||
|
||||
@Resource
|
||||
private DeptApi deptApi;
|
||||
private FactoryInfoService factoryInfoService;
|
||||
|
||||
@PostMapping("/batchCreate")
|
||||
@Operation(summary = "创建搬运组工资规格关联")
|
||||
@ -92,11 +94,11 @@ public class HandlingGroupAmountSpecificationsController {
|
||||
|
||||
// 获取工厂信息
|
||||
Set<Long> factoryIds = convertSet(result.getList(), HandlingGroupAmountSpecificationsRespVO::getFactoryId);
|
||||
Map<Long, DeptRespDTO> factoryMap = convertMap(deptApi.getDeptList(factoryIds).getCheckedData(), DeptRespDTO::getId);
|
||||
Map<Long, FactoryInfoDO> factoryMap = convertMap(factoryInfoService.getFactoryList(factoryIds), FactoryInfoDO::getId);
|
||||
|
||||
result.getList().forEach(data -> {
|
||||
// 设置工厂名称
|
||||
data.setFactoryName(factoryMap.get(data.getFactoryId()) != null ? factoryMap.get(data.getFactoryId()).getName() : null);
|
||||
data.setFactoryName(factoryMap.get(data.getFactoryId()) != null ? factoryMap.get(data.getFactoryId()).getShortName() : null);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -31,4 +31,7 @@ public class StaffSalaryPageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "工厂编码集合")
|
||||
private List<Long> factoryIds;
|
||||
|
||||
@Schema(description = "是否发放工资 | 0未发放 1已发放", example = "0")
|
||||
private Integer isGrant;
|
||||
}
|
@ -77,4 +77,7 @@ public class StaffSalaryRespVO {
|
||||
|
||||
@Schema(description = "借支金额")
|
||||
private BigDecimal loanAmount;
|
||||
|
||||
@Schema(description = "是否发放工资 | 0未发放 1已发放")
|
||||
private Integer isGrant;
|
||||
}
|
@ -80,4 +80,9 @@ public class StaffSalaryDO extends BaseDO {
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 是否发放工资 | 0未发放 1已发放
|
||||
*/
|
||||
private Integer isGrant;
|
||||
|
||||
}
|
@ -40,6 +40,7 @@ public interface StaffSalaryMapper extends BaseMapperX<StaffSalaryDO> {
|
||||
query.eqIfPresent(StaffSalaryDO::getFactoryId, reqVO.getFactoryId());
|
||||
query.inIfPresent(StaffSalaryDO::getFactoryId, reqVO.getFactoryIds());
|
||||
query.eqIfPresent(StaffSalaryDO::getStatus, reqVO.getStatus());
|
||||
query.eqIfPresent(StaffSalaryDO::getIsGrant, reqVO.getIsGrant());
|
||||
query.apply(Objects.nonNull(reqVO.getWorkTypeId()), "staff.work_type_id = {0} ", reqVO.getWorkTypeId());
|
||||
|
||||
return selectJoinPage(reqVO, StaffSalaryRespVO.class, query);
|
||||
|
@ -152,4 +152,10 @@ public interface FactoryInfoService {
|
||||
* @return 工厂列表
|
||||
*/
|
||||
List<FactoryInfoDO> getCompanyFactoryList();
|
||||
|
||||
/**
|
||||
* 获取登录用户工厂列表, 登陆用户无工厂则拉取所有工厂
|
||||
* @return 工厂列表
|
||||
*/
|
||||
List<FactoryInfoDO> getFactoryListByLoginUser();
|
||||
}
|
||||
|
@ -317,4 +317,25 @@ public class FactoryInfoServiceImpl implements FactoryInfoService {
|
||||
.eq(FactoryInfoDO::getStatus, CommonStatusEnum.ENABLE.getStatus())
|
||||
.in(FactoryInfoDO::getType, Arrays.asList(0,1)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<FactoryInfoDO> getFactoryListByLoginUser() {
|
||||
|
||||
List<Long> factoryIds = new ArrayList<>();
|
||||
// 获取自己所在工厂
|
||||
DeptRespDTO respDTO = deptApi.getDept(userApi.getUser(getLoginUserId()).getCheckedData().getDeptId()).getCheckedData();
|
||||
if (respDTO != null && respDTO.getFactoryId() != null) {
|
||||
factoryIds.add(respDTO.getFactoryId());
|
||||
}
|
||||
|
||||
// 查找担任负责人的工厂信息
|
||||
List<DeptRespDTO> deptRespDTO = deptApi.getDeptByLeaderId(getLoginUserId()).getCheckedData();
|
||||
|
||||
if (deptRespDTO != null) {
|
||||
|
||||
factoryIds.addAll(convertList(deptRespDTO, DeptRespDTO::getFactoryId));
|
||||
}
|
||||
|
||||
return factoryInfoMapper.selectListByType(factoryIds);
|
||||
}
|
||||
}
|
||||
|
@ -11,6 +11,10 @@ import cn.iocoder.yudao.module.smartfactory.dal.dataobject.handlinggroupamountsp
|
||||
import cn.iocoder.yudao.module.smartfactory.dal.dataobject.handlingspecifications.HandlingSpecificationsDO;
|
||||
import cn.iocoder.yudao.module.smartfactory.dal.mysql.handlinggroupamountspecifications.HandlingGroupAmountSpecificationsMapper;
|
||||
import cn.iocoder.yudao.module.smartfactory.service.handlingspecifications.HandlingSpecificationsService;
|
||||
import cn.iocoder.yudao.module.system.api.dept.DeptApi;
|
||||
import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO;
|
||||
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
|
||||
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import org.springframework.stereotype.Service;
|
||||
@ -25,6 +29,7 @@ import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
|
||||
import static cn.iocoder.yudao.module.smartfactory.enums.ErrorCodeConstants.CANNOT_FIND_THE_CORRESPONDING_FACTORY_HANDLING_SPECIFICATION;
|
||||
|
||||
/**
|
||||
@ -40,6 +45,13 @@ public class HandlingGroupAmountSpecificationsServiceImpl implements HandlingGro
|
||||
private HandlingGroupAmountSpecificationsMapper handlingGroupAmountSpecificationsMapper;
|
||||
@Resource
|
||||
private HandlingSpecificationsService handlingSpecificationsService;
|
||||
|
||||
@Resource
|
||||
private AdminUserApi userApi;
|
||||
|
||||
@Resource
|
||||
private DeptApi deptApi;
|
||||
|
||||
private static final BigDecimal THOUSANDTH = new BigDecimal("0.001");
|
||||
|
||||
@Override
|
||||
@ -87,6 +99,13 @@ public class HandlingGroupAmountSpecificationsServiceImpl implements HandlingGro
|
||||
|
||||
@Override
|
||||
public PageResult<HandlingGroupAmountSpecificationsDO> getHandlingGroupAmountSpecificationsPage(HandlingGroupAmountSpecificationsPageReqVO pageReqVO) {
|
||||
// 判断当前登录人是否属于工厂主管
|
||||
AdminUserRespDTO userRespDTO = userApi.getUser(getLoginUserId()).getCheckedData();
|
||||
DeptRespDTO deptRespDTO = deptApi.getDept(userRespDTO.getDeptId()).getCheckedData();
|
||||
if (deptRespDTO.getFactoryId() != null) {
|
||||
pageReqVO.setFactoryId(deptRespDTO.getFactoryId());
|
||||
}
|
||||
|
||||
IPage<HandlingGroupAmountSpecificationsDO> pageResult = handlingGroupAmountSpecificationsMapper.getHandlingGroupAmountSpecificationsPage(MyBatisUtils.buildPage(pageReqVO), pageReqVO);
|
||||
return new PageResult<>(pageResult.getRecords(), pageResult.getTotal());
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ import cn.iocoder.yudao.module.smartfactory.dal.dataobject.attendance.StaffAtten
|
||||
import cn.iocoder.yudao.module.smartfactory.dal.dataobject.staffsalary.StaffSalaryDO;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@ -67,6 +68,13 @@ public interface StaffSalaryService {
|
||||
*/
|
||||
void calculateSalary(List<StaffAttendanceRecordDO> vo);
|
||||
|
||||
/**
|
||||
* 更新是否发工资
|
||||
* @param ids 工资编号集合
|
||||
* @param isGrant 是否发工资
|
||||
*/
|
||||
void updateIsGrant(Collection<Long> ids, Integer isGrant);
|
||||
|
||||
/**
|
||||
* 获取工资统计
|
||||
* @param pageReqVO 查询信息
|
||||
|
@ -16,6 +16,7 @@ import cn.iocoder.yudao.module.smartfactory.dal.mysql.staffsalary.StaffSalaryMap
|
||||
import cn.iocoder.yudao.module.smartfactory.service.staff.StaffService;
|
||||
import cn.iocoder.yudao.module.system.api.loan.LoanApi;
|
||||
import cn.iocoder.yudao.module.system.api.loan.dto.LoanDTO;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
@ -254,6 +255,19 @@ public class StaffSalaryServiceImpl implements StaffSalaryService {
|
||||
staffSalaryMapper.insertBatch(salaryDOS);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateIsGrant(Collection<Long> ids, Integer isGrant) {
|
||||
|
||||
List<StaffSalaryDO> salaryDOS = ids.stream()
|
||||
.map(id -> new StaffSalaryDO()
|
||||
.setId(id)
|
||||
.setIsGrant(isGrant))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// 更新
|
||||
staffSalaryMapper.updateBatch(salaryDOS);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SalaryTotalVO getStaffSalaryTotal(StaffSalaryPageReqVO pageReqVO) {
|
||||
|
||||
|
@ -21,6 +21,9 @@
|
||||
<if test="vo.handlingSpecificationsId != null">
|
||||
AND a.handling_specifications_id = #{vo.handlingSpecificationsId}
|
||||
</if>
|
||||
<if test="vo.factoryId != null">
|
||||
AND a.factory_id = #{vo.factoryId}
|
||||
</if>
|
||||
<if test="vo.dateStr != null and vo.dateStr != ''">
|
||||
and a.date_str like concat('%', #{vo.dateStr}, '%')
|
||||
</if>
|
||||
|
Loading…
Reference in New Issue
Block a user