diff --git a/zn-module-smartfactory/zn-module-smartfactory-api/src/main/java/cn/iocoder/yudao/module/smartfactory/api/staff/StaffApi.java b/zn-module-smartfactory/zn-module-smartfactory-api/src/main/java/cn/iocoder/yudao/module/smartfactory/api/staff/StaffApi.java index b42a669b..99a6895a 100644 --- a/zn-module-smartfactory/zn-module-smartfactory-api/src/main/java/cn/iocoder/yudao/module/smartfactory/api/staff/StaffApi.java +++ b/zn-module-smartfactory/zn-module-smartfactory-api/src/main/java/cn/iocoder/yudao/module/smartfactory/api/staff/StaffApi.java @@ -28,4 +28,9 @@ public interface StaffApi { @Operation(summary = "获得员工信息") @Parameter(name = "staffIds", description = "员工编号数组", required = true, example = "1,2,3") CommonResult> getStaffList(@RequestParam("staffIds") Collection staffId); + + @GetMapping(PREFIX + "/getByUserId") + @Operation(summary = "根据系统用户编号获得员工信息") + @Parameter(name = "userId", description = "系统用户编号", required = true, example = "1") + CommonResult getStaffByUserId(@RequestParam("userId") Long userId); } diff --git a/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/api/staff/StaffApiImpl.java b/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/api/staff/StaffApiImpl.java index 988058c0..84653075 100644 --- a/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/api/staff/StaffApiImpl.java +++ b/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/api/staff/StaffApiImpl.java @@ -4,6 +4,7 @@ import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.common.util.object.BeanUtils; import cn.iocoder.yudao.module.smartfactory.api.staff.dto.StaffDTO; import cn.iocoder.yudao.module.smartfactory.service.staff.StaffService; +import org.springframework.context.annotation.Bean; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.RestController; @@ -30,4 +31,9 @@ public class StaffApiImpl implements StaffApi { public CommonResult> getStaffList(Collection staffId) { return success(BeanUtils.toBean(staffService.getList(staffId), StaffDTO.class)); } + + @Override + public CommonResult getStaffByUserId(Long userId) { + return success(BeanUtils.toBean(staffService.getStaffByUserId(userId), StaffDTO.class)); + } } diff --git a/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/controller/admin/attendance/StaffAttendanceRecordController.java b/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/controller/admin/attendance/StaffAttendanceRecordController.java index ae725323..18c80bc7 100644 --- a/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/controller/admin/attendance/StaffAttendanceRecordController.java +++ b/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/controller/admin/attendance/StaffAttendanceRecordController.java @@ -128,6 +128,18 @@ public class StaffAttendanceRecordController { return success(staffAttendanceRecordService.getType(factoryId, month)); } + @GetMapping("/isReview") + @Operation(summary = "获得厂区员工考勤记录审核状态") + @Parameter(name = "factoryId", description = "工厂编号", required = true, example = "1024") + @Parameter(name = "month", description = "考勤月份", required = true, example = "2025-11") + @PreAuthorize("@ss.hasPermission('smartfactory:staff-attendance-record:query')") + public CommonResult getIsReview(@RequestParam("factoryId") Long factoryId, + @RequestParam("month") String month) { + + // 获取考勤审核状态 + return success(staffAttendanceRecordService.getIsReview(factoryId, month)); + } + @GetMapping("/list") @Operation(summary = "获得厂区员工考勤记录列表") @PreAuthorize("@ss.hasPermission('smartfactory:staff-attendance-record:query')") @@ -137,8 +149,37 @@ public class StaffAttendanceRecordController { // 查询该厂区员工在 其他厂区得考勤记录 List otherRecordDOS = staffAttendanceRecordService.getOtherRecord(reqVO); + // 获取工厂员工列表 + List staffDOS = staffService.getListByFactory(reqVO.getFactoryId(), true); + Map staffMap = convertMap(staffDOS, StaffDO::getId); + if (CollUtil.isNotEmpty(recordDOS)) { - return success(convertRecord(reqVO, recordDOS, otherRecordDOS)); + List recordRespVO = convertRecord(reqVO, recordDOS, otherRecordDOS); + + // 筛选掉已经存在的员工 + List staffIds = staffDOS.stream() + .map(StaffDO::getId) + .filter(id -> !convertList(recordDOS, StaffAttendanceRecordDO::getStaffId).contains(id)) + .collect(Collectors.toList()); + + // 获取其他员工的考勤记录, 打卡状态设置为null + List otherRecords = recordRespVO.get(0).getRecords().stream() + .map(record -> BeanUtils.toBean(record, AttendanceRecordVO.class) + .setStatus(null)) + .collect(Collectors.toList()); + List otherRespVO = staffIds.stream() + .map(id -> new StaffAttendanceRecordRespVO() + .setStaffId(id) + .setFactoryId(reqVO.getFactoryId()) + .setMonth(reqVO.getMonth()) + .setType(reqVO.getType()) + .setStaffName(staffMap.get(id).getNickName()) + .setWorkTypeId(staffMap.get(id).getWorkTypeId()) + .setRecords(otherRecords)) + .collect(Collectors.toList()); + + recordRespVO.addAll(otherRespVO); + return success(recordRespVO); }else { // 判断是否 新增考勤情况 if (reqVO.getFactoryId() != null && reqVO.getMonth() != null && reqVO.getType() != null) { @@ -156,8 +197,6 @@ public class StaffAttendanceRecordController { .setWorkTypeId(staffDO.getWorkTypeId()); return success(Collections.singletonList(respVO)); }else { - // 获取工厂员工列表 - List staffDOS = staffService.getListByFactory(reqVO.getFactoryId(), true); List respVO = staffDOS.stream() .map(staffDO -> new StaffAttendanceRecordRespVO() .setStaffId(staffDO.getId()) @@ -310,4 +349,16 @@ public class StaffAttendanceRecordController { ExcelUtils.write(response, "厂区员工考勤记录.xls", "数据", StaffAttendanceRecordRespVO.class, convertRecord(reqVO, recordDOS, null)); } + + @PutMapping("/review") + @Operation(summary = "考勤记录审核") + @Parameter(name = "factoryId", description = "工厂编号", required = true, example = "1024") + @Parameter(name = "month", description = "考勤月份", required = true, example = "2025-11") + @PreAuthorize("@ss.hasPermission('smartfactory:staff-attendance-record:review')") + public CommonResult reviewAttendanceRecord(@RequestParam("factoryId") Long factoryId, + @RequestParam("month") String month) { + + staffAttendanceRecordService.updateReview(factoryId, month); + return success(true); + } } \ 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/attendance/vo/StaffAttendanceRecordRespVO.java b/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/controller/admin/attendance/vo/StaffAttendanceRecordRespVO.java index d74bddb1..ae159d78 100644 --- a/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/controller/admin/attendance/vo/StaffAttendanceRecordRespVO.java +++ b/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/controller/admin/attendance/vo/StaffAttendanceRecordRespVO.java @@ -38,6 +38,9 @@ public class StaffAttendanceRecordRespVO { @Schema(description = "其他打卡记录") private List childRecords; + @Schema(description = "是否已审核") + private Integer isReview; + public StaffAttendanceRecordRespVO(Long staffId, Long factoryId, Integer type, String month) { this.staffId = staffId; this.factoryId = factoryId; diff --git a/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/controller/admin/industrialinjury/IndustrialInjuryController.java b/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/controller/admin/industrialinjury/IndustrialInjuryController.java index 36b48d7c..49823b44 100644 --- a/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/controller/admin/industrialinjury/IndustrialInjuryController.java +++ b/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/controller/admin/industrialinjury/IndustrialInjuryController.java @@ -96,6 +96,8 @@ public class IndustrialInjuryController { result.getList().forEach(vo -> { vo.setStaffName(userMap.get(vo.getStaffId()) != null ? userMap.get(vo.getStaffId()).getNickName() : null); vo.setFactoryName(factoryMap.get(vo.getFactoryId()) != null ? factoryMap.get(vo.getFactoryId()).getName() : null); + // 设置理赔总金额 + vo.setClaimTotalAmount(vo.getClaimAmount().add(vo.getAgreementClaimAmount())); }); } diff --git a/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/controller/admin/industrialinjury/vo/AdvancePaymentItem.java b/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/controller/admin/industrialinjury/vo/AdvancePaymentItem.java index a2416ee5..8dcafd58 100644 --- a/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/controller/admin/industrialinjury/vo/AdvancePaymentItem.java +++ b/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/controller/admin/industrialinjury/vo/AdvancePaymentItem.java @@ -12,10 +12,16 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_ @Data public class AdvancePaymentItem { + @Schema(description = "垫资方 | 1公司 2工厂") + private Integer payer; + @Schema(description = "金额") private BigDecimal amount; @Schema(description = "时间") @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) private String time; + + @Schema(description = "备注") + private String notes; } diff --git a/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/controller/admin/industrialinjury/vo/ClaimAmountItem.java b/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/controller/admin/industrialinjury/vo/ClaimAmountItem.java index a30fe7ba..2f9f9ab3 100644 --- a/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/controller/admin/industrialinjury/vo/ClaimAmountItem.java +++ b/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/controller/admin/industrialinjury/vo/ClaimAmountItem.java @@ -12,8 +12,8 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_ @Data public class ClaimAmountItem { - @Schema(description = "理赔方") - private String payee; + @Schema(description = "理赔类型") + private Integer payee; @Schema(description = "金额") private BigDecimal amount; @@ -21,4 +21,7 @@ public class ClaimAmountItem { @Schema(description = "理赔时间") @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) private String time; + + @Schema(description = "备注") + private String notes; } diff --git a/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/controller/admin/industrialinjury/vo/IndustrialInjuryRespVO.java b/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/controller/admin/industrialinjury/vo/IndustrialInjuryRespVO.java index e330ec97..7d86a639 100644 --- a/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/controller/admin/industrialinjury/vo/IndustrialInjuryRespVO.java +++ b/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/controller/admin/industrialinjury/vo/IndustrialInjuryRespVO.java @@ -48,10 +48,6 @@ public class IndustrialInjuryRespVO { @Schema(description = "医药垫资明细") private List advancePaymentItems; - @Schema(description = "垫资方 | 1公司 2工厂") - @ExcelProperty("垫资方 | 1公司 2工厂") - private Integer payer; - @Schema(description = "理赔金额") @ExcelProperty("理赔金额") private BigDecimal claimAmount; @@ -59,10 +55,33 @@ public class IndustrialInjuryRespVO { @Schema(description = "理赔明细") private List claimAmountItems; - @Schema(description = "状态 | 1处理中 2已完成", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @ExcelProperty("状态 | 1处理中 2已完成") + @Schema(description = "协议理赔金额") + private BigDecimal agreementClaimAmount; + + @Schema(description = "协议理赔明细") + private List agreementClaimItems; + + @Schema(description = "理赔总金额") + private BigDecimal claimTotalAmount; + + @Schema(description = "备注") + private String notes; + + @Schema(description = "状态 | 1处理中 2已完成") private Integer status; + @Schema(description = "是否上传发票 |0否 1是") + private Integer isUploadInvoice; + + @Schema(description = "是否保险理赔|0否 1是") + private Integer isInsuranceClaims; + + @Schema(description = "是否协议理赔|0否 1是") + private Integer isAgreementClaims; + + @Schema(description = "发票文件信息") + private List invoiceFileItems; + @Schema(description = "附件信息") @ExcelProperty("附件信息") private List fileItems; @@ -70,5 +89,4 @@ public class IndustrialInjuryRespVO { @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) @ExcelProperty("创建时间") private LocalDateTime createTime; - } \ 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/industrialinjury/vo/IndustrialInjurySaveReqVO.java b/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/controller/admin/industrialinjury/vo/IndustrialInjurySaveReqVO.java index 9522f7b6..c1cb0bb8 100644 --- a/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/controller/admin/industrialinjury/vo/IndustrialInjurySaveReqVO.java +++ b/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/controller/admin/industrialinjury/vo/IndustrialInjurySaveReqVO.java @@ -34,18 +34,36 @@ public class IndustrialInjurySaveReqVO { @Schema(description = "医药垫资明细") private List advancePaymentItems; - @Schema(description = "垫资方 | 1公司 2工厂") - private Integer payer; - @Schema(description = "理赔金额") private BigDecimal claimAmount; @Schema(description = "理赔明细") private List claimAmountItems; + @Schema(description = "协议理赔金额") + private BigDecimal agreementClaimAmount; + + @Schema(description = "协议理赔明细") + private List agreementClaimItems; + + @Schema(description = "备注") + private String notes; + @Schema(description = "状态 | 1处理中 2已完成") private Integer status; + @Schema(description = "是否上传发票 |0否 1是") + private Integer isUploadInvoice; + + @Schema(description = "是否保险理赔|0否 1是") + private Integer isInsuranceClaims; + + @Schema(description = "是否协议理赔|0否 1是") + private Integer isAgreementClaims; + + @Schema(description = "发票文件信息") + private List invoiceFileItems; + @Schema(description = "附件信息") private List fileItems; diff --git a/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/controller/admin/staffsalary/StaffSalaryController.java b/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/controller/admin/staffsalary/StaffSalaryController.java index 5f524825..c2c680af 100644 --- a/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/controller/admin/staffsalary/StaffSalaryController.java +++ b/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/controller/admin/staffsalary/StaffSalaryController.java @@ -41,12 +41,6 @@ public class StaffSalaryController { @Resource private StaffSalaryService staffSalaryService; - @Resource - private StaffService staffService; - - @Resource - private FactoryInfoService factoryInfoService; - @PostMapping("/create") @Operation(summary = "创建员工工资") @PreAuthorize("@ss.hasPermission('smartfactory:staff-salary:create')") @@ -89,29 +83,6 @@ public class StaffSalaryController { return success(BeanUtils.toBean(staffSalary, StaffSalaryRespVO.class)); } - @GetMapping("/get-list") - @Operation(summary = "获得指定员工工资列表") - @Parameter(name = "staffId", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('smartfactory:staff-salary:query')") - public CommonResult> getListByStaffId(@RequestParam("staffId") Long staffId) { - List staffSalary = staffSalaryService.getListByStaffId(staffId); - List respVOS = BeanUtils.toBean(staffSalary, StaffSalaryRespVO.class); - - // 获取员工信息 - StaffDO staffDO = staffService.getStaff(staffId); - // 获取工厂信息 - FactoryInfoDO factoryInfoDO = factoryInfoService.getFactoryInfo(staffDO.getFactoryId()); - - // 移除归还金额为0的记录 - respVOS.removeIf(vo -> vo.getRealAmount().compareTo(BigDecimal.ZERO) == 0); - respVOS.forEach(vo -> { - vo.setStaffName(staffDO.getNickName()); - vo.setFactoryName(factoryInfoDO.getName()); - }); - - return success(respVOS); - } - @GetMapping("/page") @Operation(summary = "获得厂区员工工资分页") @PreAuthorize("@ss.hasPermission('smartfactory:staff-salary:query')") diff --git a/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/dal/dataobject/attendance/SfAttendanceReviewDO.java b/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/dal/dataobject/attendance/SfAttendanceReviewDO.java new file mode 100644 index 00000000..7f39e395 --- /dev/null +++ b/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/dal/dataobject/attendance/SfAttendanceReviewDO.java @@ -0,0 +1,39 @@ +package cn.iocoder.yudao.module.smartfactory.dal.dataobject.attendance; + +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.*; + +/** + * 厂区员工考勤审核表 DO + * + * @author 符溶馨 + */ +@TableName("sf_attendance_review") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class SfAttendanceReviewDO extends BaseDO { + + /** + * 主键id + */ + @TableId + private Long id; + /** + * 工厂id + */ + private Long factoryId; + /** + * 考勤月份 + */ + private String month; + /** + * 审核状态 | 0未审核 1已审核 + */ + private Integer status; +} diff --git a/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/dal/dataobject/industrialinjury/IndustrialInjuryDO.java b/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/dal/dataobject/industrialinjury/IndustrialInjuryDO.java index 625b08a8..1639da69 100644 --- a/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/dal/dataobject/industrialinjury/IndustrialInjuryDO.java +++ b/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/dal/dataobject/industrialinjury/IndustrialInjuryDO.java @@ -60,10 +60,6 @@ public class IndustrialInjuryDO extends BaseDO { */ @TableField(typeHandler = JacksonTypeHandler.class) private List advancePaymentItems; - /** - * 垫资方 | 1公司 2工厂 - */ - private Integer payer; /** * 理赔金额 */ @@ -73,10 +69,40 @@ public class IndustrialInjuryDO extends BaseDO { */ @TableField(typeHandler = JacksonTypeHandler.class) private List claimAmountItems; + /** + * 协议理赔金额 + */ + private BigDecimal agreementClaimAmount; + /** + * 协议理赔明细 + */ + @TableField(typeHandler = JacksonTypeHandler.class) + private List agreementClaimItems; /** * 状态 | 1处理中 2已完成 */ private Integer status; + /** + * 是否上传发票 | 0否 1是 + */ + private Integer isUploadInvoice; + /** + * 是否保险理赔 | 0否 1是 + */ + private Integer isInsuranceClaims; + /** + * 是否协议理赔 | 0否 1是 + */ + private Integer isAgreementClaims; + /** + * 备注 + */ + private String notes; + /** + * 发票附件信息 + */ + @TableField(typeHandler = JacksonTypeHandler.class) + private List invoiceFileItems; /** * 附件信息 */ diff --git a/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/dal/mysql/attendance/SfAttendanceReviewMapper.java b/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/dal/mysql/attendance/SfAttendanceReviewMapper.java new file mode 100644 index 00000000..7ea05e92 --- /dev/null +++ b/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/dal/mysql/attendance/SfAttendanceReviewMapper.java @@ -0,0 +1,14 @@ +package cn.iocoder.yudao.module.smartfactory.dal.mysql.attendance; + +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; +import cn.iocoder.yudao.module.smartfactory.dal.dataobject.attendance.SfAttendanceReviewDO; +import org.apache.ibatis.annotations.Mapper; + +/** + * 厂区员工考勤审核 Mapper + * + * @author 符溶馨 + */ +@Mapper +public interface SfAttendanceReviewMapper extends BaseMapperX { +} diff --git a/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/dal/mysql/industrialinjury/IndustrialInjuryMapper.java b/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/dal/mysql/industrialinjury/IndustrialInjuryMapper.java index 34e7dc66..4ef4dd5c 100644 --- a/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/dal/mysql/industrialinjury/IndustrialInjuryMapper.java +++ b/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/dal/mysql/industrialinjury/IndustrialInjuryMapper.java @@ -20,7 +20,6 @@ public interface IndustrialInjuryMapper extends BaseMapperX .eqIfPresent(IndustrialInjuryDO::getStaffId, reqVO.getStaffId()) .eqIfPresent(IndustrialInjuryDO::getFactoryId, reqVO.getFactoryId()) .betweenIfPresent(IndustrialInjuryDO::getHappenTime, reqVO.getHappenTime()) - .eqIfPresent(IndustrialInjuryDO::getPayer, reqVO.getPayer()) .eqIfPresent(IndustrialInjuryDO::getStatus, reqVO.getStatus()) .orderByDesc(IndustrialInjuryDO::getId)); } diff --git a/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/dal/mysql/staff/StaffMapper.java b/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/dal/mysql/staff/StaffMapper.java index 9c80bbce..2457757c 100644 --- a/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/dal/mysql/staff/StaffMapper.java +++ b/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/dal/mysql/staff/StaffMapper.java @@ -78,4 +78,6 @@ public interface StaffMapper extends BaseMapperX { return selectJoinPage(pageReqVO, StaffSalaryRespVO.class, query); } + + StaffDO selectStaffByUserId(@Param("userId") Long userId); } diff --git a/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/service/attendance/StaffAttendanceRecordService.java b/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/service/attendance/StaffAttendanceRecordService.java index 4eba902d..b9dfb6d1 100644 --- a/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/service/attendance/StaffAttendanceRecordService.java +++ b/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/service/attendance/StaffAttendanceRecordService.java @@ -73,4 +73,19 @@ public interface StaffAttendanceRecordService { * @return 勤记录列表 */ List getRecordListGroupByStaffId(String month); + + /** + * 考勤记录审核 + * @param factoryId 工厂编号 + * @param month 考勤月份 + */ + void updateReview(Long factoryId, String month); + + /** + * 获取考勤记录是否已审核 + * @param factoryId 工厂编号 + * @param month 考勤月份 + * @return 是否已审核 + */ + Integer getIsReview(Long factoryId, String month); } \ No newline at end of file diff --git a/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/service/attendance/StaffAttendanceRecordServiceImpl.java b/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/service/attendance/StaffAttendanceRecordServiceImpl.java index 5ef9fb85..3d3837e3 100644 --- a/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/service/attendance/StaffAttendanceRecordServiceImpl.java +++ b/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/service/attendance/StaffAttendanceRecordServiceImpl.java @@ -5,8 +5,13 @@ import cn.iocoder.yudao.framework.common.util.object.BeanUtils; import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; import cn.iocoder.yudao.module.smartfactory.controller.admin.attendance.vo.StaffAttendanceRecordReqVO; import cn.iocoder.yudao.module.smartfactory.controller.admin.attendance.vo.StaffAttendanceRecordSaveReqVO; +import cn.iocoder.yudao.module.smartfactory.dal.dataobject.attendance.SfAttendanceReviewDO; import cn.iocoder.yudao.module.smartfactory.dal.dataobject.attendance.StaffAttendanceRecordDO; +import cn.iocoder.yudao.module.smartfactory.dal.mysql.attendance.SfAttendanceReviewMapper; import cn.iocoder.yudao.module.smartfactory.dal.mysql.attendance.StaffAttendanceRecordMapper; +import cn.iocoder.yudao.module.smartfactory.framework.job.staffSalary.StaffSalaryJob; +import cn.iocoder.yudao.module.smartfactory.service.staffsalary.StaffSalaryService; +import org.springframework.data.redis.connection.stream.ObjectRecord; import org.springframework.stereotype.Service; import org.springframework.validation.annotation.Validated; @@ -32,6 +37,12 @@ public class StaffAttendanceRecordServiceImpl implements StaffAttendanceRecordSe @Resource private StaffAttendanceRecordMapper staffAttendanceRecordMapper; + @Resource + private StaffSalaryService staffSalaryService; + + @Resource + private SfAttendanceReviewMapper attendanceReviewMapper; + @Override public void createStaffAttendanceRecord(List createReqVO) { @@ -164,4 +175,27 @@ public class StaffAttendanceRecordServiceImpl implements StaffAttendanceRecordSe .eq(StaffAttendanceRecordDO::getStatus, 1) .eq(StaffAttendanceRecordDO::getMonth, month)); } + + @Override + public void updateReview(Long factoryId, String month) { + + attendanceReviewMapper.insert(new SfAttendanceReviewDO() + .setFactoryId(factoryId) + .setMonth(month) + .setStatus(1)); + + List createDo = staffAttendanceRecordMapper.selectList(new LambdaQueryWrapperX() + .eq(StaffAttendanceRecordDO::getFactoryId, factoryId) + .eq(StaffAttendanceRecordDO::getMonth, month)); + // 审核考勤记录后, 自动计算员工薪资 + staffSalaryService.calculateSalary(createDo); + } + + @Override + public Integer getIsReview(Long factoryId, String month) { + SfAttendanceReviewDO attendanceReviewDO = attendanceReviewMapper.selectOne(new LambdaQueryWrapperX() + .eq(SfAttendanceReviewDO::getFactoryId, factoryId) + .eq(SfAttendanceReviewDO::getMonth, month)); + return attendanceReviewDO != null ? attendanceReviewDO.getStatus() : 0; + } } \ No newline at end of file diff --git a/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/service/staff/StaffService.java b/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/service/staff/StaffService.java index ea62825c..2f994148 100644 --- a/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/service/staff/StaffService.java +++ b/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/service/staff/StaffService.java @@ -67,14 +67,12 @@ public interface StaffService { /** * 获取人员数量 - * * @return */ Integer getCount(); /** * 查询工厂员工信息 - * * @param factoryId 工厂编号 * @return */ @@ -82,8 +80,7 @@ public interface StaffService { /** * 导入员工 - * - * @param list 导入数据集合 + * @param list 导入数据集合 * @param updateSupport 是否可更新 * @return 导入结果 */ @@ -93,7 +90,7 @@ public interface StaffService { * 获取指定厂区得员工列表 * * @param factoryId 工厂编号 - * @param isIn 是否获取该厂区员工 + * @param isIn 是否获取该厂区员工 * @return 员工列表 */ List getListByFactory(Long factoryId, Boolean isIn); @@ -108,7 +105,6 @@ public interface StaffService { /** * 获取员工信息列表 - * * @param staffIds 员工编号集合 * @return 员工信息列表 */ @@ -125,8 +121,15 @@ public interface StaffService { /** * - * @param userId + * * @return */ Long getTheFactoryOfTheCurrentlyLoggedInUser(); + + /** + * 根据系统用户编号获取员工信息 + * @param userId 系统用户编号 + * @return 员工信息 + */ + StaffDO getStaffByUserId(Long userId); } diff --git a/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/service/staff/StaffServiceImpl.java b/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/service/staff/StaffServiceImpl.java index 3c67a442..660f4091 100644 --- a/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/service/staff/StaffServiceImpl.java +++ b/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/service/staff/StaffServiceImpl.java @@ -58,6 +58,10 @@ public class StaffServiceImpl implements StaffService { @Override public Long createStaff(StaffSaveReqVO createReqVO) { + + // 身份证号是否已经存在 + validateUserForCreate(null, null, null, createReqVO.getIdCard()); + // 插入 StaffDO staff = BeanUtils.toBean(createReqVO, StaffDO.class); staffMapper.insert(staff); @@ -70,6 +74,10 @@ public class StaffServiceImpl implements StaffService { if (staffMapper.selectById(updateReqVO.getId()) == null) { throw exception(STAFF_NOT_EXISTS); } + + // 身份证号是否已经存在 + validateUserForCreate(null, null, null, updateReqVO.getIdCard()); + // 更新 StaffDO updateObj = BeanUtils.toBean(updateReqVO, StaffDO.class); staffMapper.updateById(updateObj); @@ -274,4 +282,10 @@ public class StaffServiceImpl implements StaffService { } return dto.getFactoryId(); } + + @Override + public StaffDO getStaffByUserId(Long userId) { + + return staffMapper.selectStaffByUserId(userId); + } } 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 fa0666d2..5f1e1d7f 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 @@ -4,6 +4,7 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.module.smartfactory.controller.admin.staffsalary.vo.StaffSalaryPageReqVO; import cn.iocoder.yudao.module.smartfactory.controller.admin.staffsalary.vo.StaffSalaryRespVO; import cn.iocoder.yudao.module.smartfactory.controller.admin.staffsalary.vo.StaffSalarySaveReqVO; +import cn.iocoder.yudao.module.smartfactory.dal.dataobject.attendance.StaffAttendanceRecordDO; import cn.iocoder.yudao.module.smartfactory.dal.dataobject.staffsalary.StaffSalaryDO; import javax.validation.Valid; @@ -60,9 +61,8 @@ public interface StaffSalaryService { void updateStatus(StaffSalarySaveReqVO updateReqVO); /** - * 获取指定员工工资列表 - * @param staffId 员工id - * @return 工资列表 + * 工资计算 + * @param vo 考勤信息 */ - List getListByStaffId(Long staffId); + void calculateSalary(List vo); } \ No newline at end of file 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 f2704092..dcf588fa 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 @@ -1,14 +1,21 @@ package cn.iocoder.yudao.module.smartfactory.service.staffsalary; +import cn.hutool.core.collection.CollUtil; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.util.object.BeanUtils; +import cn.iocoder.yudao.framework.jackson.core.databind.LocalDateTimeDeserializer; import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; +import cn.iocoder.yudao.module.bpm.api.oa.BpmOALoanApi; +import cn.iocoder.yudao.module.bpm.api.oa.vo.loan.BpmOALoanSumDTO; import cn.iocoder.yudao.module.smartfactory.controller.admin.staffsalary.vo.StaffSalaryPageReqVO; import cn.iocoder.yudao.module.smartfactory.controller.admin.staffsalary.vo.StaffSalaryRespVO; import cn.iocoder.yudao.module.smartfactory.controller.admin.staffsalary.vo.StaffSalarySaveReqVO; +import cn.iocoder.yudao.module.smartfactory.dal.dataobject.attendance.StaffAttendanceRecordDO; +import cn.iocoder.yudao.module.smartfactory.dal.dataobject.staff.StaffDO; import cn.iocoder.yudao.module.smartfactory.dal.dataobject.staffsalary.StaffSalaryDO; import cn.iocoder.yudao.module.smartfactory.dal.mysql.staff.StaffMapper; import cn.iocoder.yudao.module.smartfactory.dal.mysql.staffsalary.StaffSalaryMapper; +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 org.springframework.stereotype.Service; @@ -17,9 +24,16 @@ import org.springframework.validation.annotation.Validated; import javax.annotation.Resource; import java.math.BigDecimal; -import java.util.List; +import java.math.RoundingMode; +import java.time.LocalDate; +import java.time.format.DateTimeFormatter; +import java.time.temporal.ChronoUnit; +import java.util.*; +import java.util.stream.Collectors; import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; import static cn.iocoder.yudao.module.smartfactory.enums.ErrorCodeConstants.STAFF_SALARY_EXISTS; import static cn.iocoder.yudao.module.smartfactory.enums.ErrorCodeConstants.STAFF_SALARY_NOT_EXISTS; @@ -41,6 +55,12 @@ public class StaffSalaryServiceImpl implements StaffSalaryService { @Resource private LoanApi loanApi; + @Resource + private BpmOALoanApi bpmOALoanApi; + + @Resource + private StaffService staffService; + @Override public Long createStaffSalary(StaffSalarySaveReqVO createReqVO) { @@ -113,6 +133,7 @@ public class StaffSalaryServiceImpl implements StaffSalaryService { // 更新借支管理中 人员的归还金额 LoanDTO updateDO = new LoanDTO() .setUserId(staffSalaryDO.getStaffId()) + .setLoanType(1) .setAmount(BigDecimal.ZERO) .setReturnAmount(staffSalaryDO.getReturnAmount()); loanApi.createLoan(updateDO); @@ -120,10 +141,99 @@ public class StaffSalaryServiceImpl implements StaffSalaryService { } @Override - public List getListByStaffId(Long staffId) { + public void calculateSalary(List vo) { - return staffSalaryMapper.selectList(new LambdaQueryWrapperX() - .eq(StaffSalaryDO::getStaffId, staffId) - .eq(StaffSalaryDO::getStatus, 1)); + // 获取厂区考勤类型 + Integer type = vo.get(0).getType(); + // 获取厂区考勤月份 + String month = vo.get(0).getMonth(); + + // 获取当前考勤月份得第一天 + LocalDate firstDayOfMonth = LocalDate.parse(month + "-01", DateTimeFormatter.ISO_LOCAL_DATE); + + LocalDate[] date = new LocalDate[2]; + if (type == 1) { + + date = new LocalDate[]{ + firstDayOfMonth.minusMonths(1).withDayOfMonth(26), + firstDayOfMonth.withDayOfMonth(25) + }; + }else if (type == 2) { + + date = new LocalDate[]{ + firstDayOfMonth, + firstDayOfMonth.withDayOfMonth(firstDayOfMonth.lengthOfMonth()) + }; + } + + Map> recordMap = vo.stream() + .collect(Collectors.groupingBy(StaffAttendanceRecordDO::getStaffId)); + + // 获取厂区得员工信息 + List staffDOS = staffService.getList(convertSet(vo, StaffAttendanceRecordDO::getStaffId)); + Map staffMap = convertMap(staffDOS, StaffDO::getId); + + // 获取员工借支记录 + List loanDOS = bpmOALoanApi.getListByStaffId(recordMap.keySet(), month).getCheckedData(); + Map loanMap = loanDOS.stream() + .collect(Collectors.toMap( + BpmOALoanSumDTO::getSfUserId, + BpmOALoanSumDTO::getTotalAmount, + BigDecimal::add + )); + + // 获取员工剩余的 工资借支金额 + List sysLoanDOS = loanApi.getListByMonth(recordMap.keySet(), month).getCheckedData(); + Map sysLoanMap = new HashMap<>(); + if (CollUtil.isNotEmpty(sysLoanDOS)) { + sysLoanMap = sysLoanDOS.stream() + .collect(Collectors.toMap(LoanDTO::getUserId, LoanDTO::getRemainingAmount)); + } + + List salaryDOS = new ArrayList<>(); + for (Map.Entry> entry : recordMap.entrySet()) { + Long staffId = entry.getKey(); + // 获取该员工的上班考勤记录 + List items = entry.getValue().stream() + .filter(item -> item.getStatus() == 1) + .collect(Collectors.toList()); + + // 创建薪资DO + StaffSalaryDO salaryDO = new StaffSalaryDO() + .setStaffId(staffId) + .setMonth(month) + .setAttendanceDays(items.size()) + .setFactoryId(entry.getValue().get(0).getFactoryId()) + .setReturnAmount(loanMap.getOrDefault(staffId, BigDecimal.ZERO) + .add(sysLoanMap.getOrDefault(staffId, BigDecimal.ZERO))); + + // 计算当月的工作天数 + long days = ChronoUnit.DAYS.between(date[0], date[1]); + int workDays = (int) days + 1; + + // 计算应发工资 + if (staffMap.get(staffId).getSalary() != null) { // 没有录入基本薪资时,不做计算 + + if (salaryDO.getAttendanceDays() == workDays) { + // 设置应发工资 + salaryDO.setPayableAmount(staffMap.get(staffId).getSalary()); + // 设置实发工资 + salaryDO.setRealAmount(staffMap.get(staffId).getSalary()); + } else { + BigDecimal payableAmount = staffMap.get(staffId).getSalary().divide(BigDecimal.valueOf(workDays), RoundingMode.HALF_UP) + .multiply(BigDecimal.valueOf(salaryDO.getAttendanceDays())); + // 设置应发工资 + salaryDO.setPayableAmount(payableAmount); + // 设置实发工资 + salaryDO.setRealAmount(payableAmount); + } + } + + // 插入集合 + salaryDOS.add(salaryDO); + } + + // 插入工资记录 + staffSalaryMapper.insertBatch(salaryDOS); } } \ No newline at end of file diff --git a/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/resources/mapper/staff/StaffMapper.xml b/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/resources/mapper/staff/StaffMapper.xml index c3bc4930..dc2916ca 100644 --- a/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/resources/mapper/staff/StaffMapper.xml +++ b/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/resources/mapper/staff/StaffMapper.xml @@ -51,4 +51,21 @@ + +