diff --git a/zn-module-smartfactory/zn-module-smartfactory-api/src/main/java/cn/iocoder/yudao/module/smartfactory/api/staffSalary/StaffSalaryApi.java b/zn-module-smartfactory/zn-module-smartfactory-api/src/main/java/cn/iocoder/yudao/module/smartfactory/api/staffSalary/StaffSalaryApi.java new file mode 100644 index 00000000..e683230f --- /dev/null +++ b/zn-module-smartfactory/zn-module-smartfactory-api/src/main/java/cn/iocoder/yudao/module/smartfactory/api/staffSalary/StaffSalaryApi.java @@ -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 updateIsGrant(@RequestParam("ids") Collection ids, + @RequestParam("isGrant") Integer isGrant); +} diff --git a/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/api/staffSalary/StaffSalaryApiImpl.java b/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/api/staffSalary/StaffSalaryApiImpl.java new file mode 100644 index 00000000..52df71c1 --- /dev/null +++ b/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/api/staffSalary/StaffSalaryApiImpl.java @@ -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 updateIsGrant(Collection ids, Integer isGrant) { + staffSalaryService.updateIsGrant(ids, isGrant); + return success(true); + } +} diff --git a/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/controller/admin/factoryinfo/FactoryInfoController.java b/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/controller/admin/factoryinfo/FactoryInfoController.java index 803bb386..3fff6d95 100644 --- a/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/controller/admin/factoryinfo/FactoryInfoController.java +++ b/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/controller/admin/factoryinfo/FactoryInfoController.java @@ -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> getFactoryListByLoginUser() { + + List factoryInfo = factoryInfoService.getFactoryListByLoginUser(); + return success(BeanUtils.toBean(factoryInfo, FactorySimpleRespVO.class)); + } + @GetMapping("/get-tree") @Operation(summary = "获得工厂树结构") @PreAuthorize("@ss.hasPermission('smartfactory:factory-info:query')") diff --git a/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/controller/admin/handlinggroupamountspecifications/HandlingGroupAmountSpecificationsController.java b/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/controller/admin/handlinggroupamountspecifications/HandlingGroupAmountSpecificationsController.java index 8dd8880e..8ee14f33 100644 --- a/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/controller/admin/handlinggroupamountspecifications/HandlingGroupAmountSpecificationsController.java +++ b/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/controller/admin/handlinggroupamountspecifications/HandlingGroupAmountSpecificationsController.java @@ -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 factoryIds = convertSet(result.getList(), HandlingGroupAmountSpecificationsRespVO::getFactoryId); - Map factoryMap = convertMap(deptApi.getDeptList(factoryIds).getCheckedData(), DeptRespDTO::getId); + Map 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); }); } diff --git a/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/controller/admin/staffsalary/vo/StaffSalaryPageReqVO.java b/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/controller/admin/staffsalary/vo/StaffSalaryPageReqVO.java index afed0a9c..c0f8584c 100644 --- a/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/controller/admin/staffsalary/vo/StaffSalaryPageReqVO.java +++ b/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/controller/admin/staffsalary/vo/StaffSalaryPageReqVO.java @@ -31,4 +31,7 @@ public class StaffSalaryPageReqVO extends PageParam { @Schema(description = "工厂编码集合") private List factoryIds; + + @Schema(description = "是否发放工资 | 0未发放 1已发放", example = "0") + private Integer isGrant; } \ No newline at end of file diff --git a/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/controller/admin/staffsalary/vo/StaffSalaryRespVO.java b/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/controller/admin/staffsalary/vo/StaffSalaryRespVO.java index 8d2c1083..f10f3259 100644 --- a/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/controller/admin/staffsalary/vo/StaffSalaryRespVO.java +++ b/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/controller/admin/staffsalary/vo/StaffSalaryRespVO.java @@ -77,4 +77,7 @@ public class StaffSalaryRespVO { @Schema(description = "借支金额") private BigDecimal loanAmount; + + @Schema(description = "是否发放工资 | 0未发放 1已发放") + private Integer isGrant; } \ No newline at end of file diff --git a/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/dal/dataobject/staffsalary/StaffSalaryDO.java b/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/dal/dataobject/staffsalary/StaffSalaryDO.java index 27ee2310..b701b745 100644 --- a/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/dal/dataobject/staffsalary/StaffSalaryDO.java +++ b/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/dal/dataobject/staffsalary/StaffSalaryDO.java @@ -80,4 +80,9 @@ public class StaffSalaryDO extends BaseDO { */ private Integer status; + /** + * 是否发放工资 | 0未发放 1已发放 + */ + private Integer isGrant; + } \ No newline at end of file diff --git a/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/dal/mysql/staffsalary/StaffSalaryMapper.java b/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/dal/mysql/staffsalary/StaffSalaryMapper.java index 52f8a4c7..d637bfa3 100644 --- a/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/dal/mysql/staffsalary/StaffSalaryMapper.java +++ b/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/dal/mysql/staffsalary/StaffSalaryMapper.java @@ -40,6 +40,7 @@ public interface StaffSalaryMapper extends BaseMapperX { 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); diff --git a/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/service/factoryinfo/FactoryInfoService.java b/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/service/factoryinfo/FactoryInfoService.java index e2993f4d..f2b154b9 100644 --- a/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/service/factoryinfo/FactoryInfoService.java +++ b/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/service/factoryinfo/FactoryInfoService.java @@ -152,4 +152,10 @@ public interface FactoryInfoService { * @return 工厂列表 */ List getCompanyFactoryList(); + + /** + * 获取登录用户工厂列表, 登陆用户无工厂则拉取所有工厂 + * @return 工厂列表 + */ + List getFactoryListByLoginUser(); } diff --git a/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/service/factoryinfo/FactoryInfoServiceImpl.java b/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/service/factoryinfo/FactoryInfoServiceImpl.java index a5dcf10e..47639c44 100644 --- a/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/service/factoryinfo/FactoryInfoServiceImpl.java +++ b/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/service/factoryinfo/FactoryInfoServiceImpl.java @@ -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 getFactoryListByLoginUser() { + + List 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 = deptApi.getDeptByLeaderId(getLoginUserId()).getCheckedData(); + + if (deptRespDTO != null) { + + factoryIds.addAll(convertList(deptRespDTO, DeptRespDTO::getFactoryId)); + } + + return factoryInfoMapper.selectListByType(factoryIds); + } } diff --git a/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/service/handlinggroupamountspecifications/HandlingGroupAmountSpecificationsServiceImpl.java b/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/service/handlinggroupamountspecifications/HandlingGroupAmountSpecificationsServiceImpl.java index a048cf76..493fb5da 100644 --- a/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/service/handlinggroupamountspecifications/HandlingGroupAmountSpecificationsServiceImpl.java +++ b/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/service/handlinggroupamountspecifications/HandlingGroupAmountSpecificationsServiceImpl.java @@ -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 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 pageResult = handlingGroupAmountSpecificationsMapper.getHandlingGroupAmountSpecificationsPage(MyBatisUtils.buildPage(pageReqVO), pageReqVO); return new PageResult<>(pageResult.getRecords(), pageResult.getTotal()); } diff --git a/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/service/staffsalary/StaffSalaryService.java b/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/service/staffsalary/StaffSalaryService.java index c8013edb..e17a9b01 100644 --- a/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/service/staffsalary/StaffSalaryService.java +++ b/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/service/staffsalary/StaffSalaryService.java @@ -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 vo); + /** + * 更新是否发工资 + * @param ids 工资编号集合 + * @param isGrant 是否发工资 + */ + void updateIsGrant(Collection ids, Integer isGrant); + /** * 获取工资统计 * @param pageReqVO 查询信息 diff --git a/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/service/staffsalary/StaffSalaryServiceImpl.java b/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/service/staffsalary/StaffSalaryServiceImpl.java index 33992adb..199d4861 100644 --- a/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/service/staffsalary/StaffSalaryServiceImpl.java +++ b/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/service/staffsalary/StaffSalaryServiceImpl.java @@ -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 ids, Integer isGrant) { + + List salaryDOS = ids.stream() + .map(id -> new StaffSalaryDO() + .setId(id) + .setIsGrant(isGrant)) + .collect(Collectors.toList()); + + // 更新 + staffSalaryMapper.updateBatch(salaryDOS); + } + @Override public SalaryTotalVO getStaffSalaryTotal(StaffSalaryPageReqVO pageReqVO) { diff --git a/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/resources/mapper/handlinggroupamountspecifications/HandlingGroupAmountSpecificationsMapper.xml b/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/resources/mapper/handlinggroupamountspecifications/HandlingGroupAmountSpecificationsMapper.xml index 2cc9cc9c..2a063af9 100644 --- a/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/resources/mapper/handlinggroupamountspecifications/HandlingGroupAmountSpecificationsMapper.xml +++ b/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/resources/mapper/handlinggroupamountspecifications/HandlingGroupAmountSpecificationsMapper.xml @@ -21,6 +21,9 @@ AND a.handling_specifications_id = #{vo.handlingSpecificationsId} + + AND a.factory_id = #{vo.factoryId} + and a.date_str like concat('%', #{vo.dateStr}, '%')