feat(smartfactory): 添加厂区工伤管理功能

- 新增工业伤害相关实体类和控制器
- 实现工业伤害的创建、更新、删除和查询功能
- 添加员工导入模板和导入功能
-优化员工信息查询接口
This commit is contained in:
furongxin 2025-01-24 17:35:33 +08:00
parent e9de45bc7b
commit ca586f4173
13 changed files with 583 additions and 1 deletions

View File

@ -0,0 +1,17 @@
package cn.iocoder.yudao.module.smartfactory.controller.admin.attendance.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.time.LocalDate;
@Schema(description = "管理后台 - 厂区员工考勤记录 Response VO")
@Data
public class AttendanceRecordVO {
@Schema(description = "打卡日期")
private LocalDate punchTime;
@Schema(description = "打卡状态 | 1上班 2休息 3病假 4事假 5工伤")
private Integer status;
}

View File

@ -0,0 +1,104 @@
package cn.iocoder.yudao.module.smartfactory.controller.admin.industrialinjury;
import cn.hutool.core.collection.CollUtil;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.smartfactory.controller.admin.industrialinjury.vo.IndustrialInjuryPageReqVO;
import cn.iocoder.yudao.module.smartfactory.controller.admin.industrialinjury.vo.IndustrialInjuryRespVO;
import cn.iocoder.yudao.module.smartfactory.controller.admin.industrialinjury.vo.IndustrialInjurySaveReqVO;
import cn.iocoder.yudao.module.smartfactory.dal.dataobject.factoryinfo.FactoryInfoDO;
import cn.iocoder.yudao.module.smartfactory.dal.dataobject.industrialinjury.IndustrialInjuryDO;
import cn.iocoder.yudao.module.smartfactory.dal.dataobject.staff.StaffDO;
import cn.iocoder.yudao.module.smartfactory.service.factoryinfo.FactoryInfoService;
import cn.iocoder.yudao.module.smartfactory.service.industrialinjury.IndustrialInjuryService;
import cn.iocoder.yudao.module.smartfactory.service.staff.StaffService;
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.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.Map;
import java.util.Set;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap;
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
@Tag(name = "管理后台 - 厂区工伤")
@RestController
@RequestMapping("/smartfactory/industrial-injury")
@Validated
public class IndustrialInjuryController {
@Resource
private IndustrialInjuryService industrialInjuryService;
@Resource
private StaffService staffService;
@Resource
private FactoryInfoService factoryInfoService;
@PostMapping("/create")
@Operation(summary = "创建厂区工伤")
@PreAuthorize("@ss.hasPermission('smartfactory:industrial-injury:create')")
public CommonResult<Long> createIndustrialInjury(@Valid @RequestBody IndustrialInjurySaveReqVO createReqVO) {
return success(industrialInjuryService.createIndustrialInjury(createReqVO));
}
@PutMapping("/update")
@Operation(summary = "更新厂区工伤")
@PreAuthorize("@ss.hasPermission('smartfactory:industrial-injury:update')")
public CommonResult<Boolean> updateIndustrialInjury(@Valid @RequestBody IndustrialInjurySaveReqVO updateReqVO) {
industrialInjuryService.updateIndustrialInjury(updateReqVO);
return success(true);
}
@DeleteMapping("/delete")
@Operation(summary = "删除厂区工伤")
@Parameter(name = "id", description = "编号", required = true)
@PreAuthorize("@ss.hasPermission('smartfactory:industrial-injury:delete')")
public CommonResult<Boolean> deleteIndustrialInjury(@RequestParam("id") Long id) {
industrialInjuryService.deleteIndustrialInjury(id);
return success(true);
}
@GetMapping("/get")
@Operation(summary = "获得厂区工伤")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('smartfactory:industrial-injury:query')")
public CommonResult<IndustrialInjuryRespVO> getIndustrialInjury(@RequestParam("id") Long id) {
IndustrialInjuryDO industrialInjury = industrialInjuryService.getIndustrialInjury(id);
return success(BeanUtils.toBean(industrialInjury, IndustrialInjuryRespVO.class));
}
@GetMapping("/page")
@Operation(summary = "获得厂区工伤分页")
@PreAuthorize("@ss.hasPermission('smartfactory:industrial-injury:query')")
public CommonResult<PageResult<IndustrialInjuryRespVO>> getIndustrialInjuryPage(@Valid IndustrialInjuryPageReqVO pageReqVO) {
PageResult<IndustrialInjuryDO> pageResult = industrialInjuryService.getIndustrialInjuryPage(pageReqVO);
PageResult<IndustrialInjuryRespVO> result = BeanUtils.toBean(pageResult, IndustrialInjuryRespVO.class);
if (CollUtil.isNotEmpty(result.getList())) {
// 获取员工信息
Set<Long> userIds = convertSet(result.getList(), IndustrialInjuryRespVO::getStaffId);
Map<Long, StaffDO> userMap = convertMap(staffService.getList(userIds), StaffDO::getId);
// 获取工厂信息
Set<Long> factoryIds = convertSet(result.getList(), IndustrialInjuryRespVO::getFactoryId);
Map<Long, FactoryInfoDO> factoryMap = convertMap(factoryInfoService.getFactoryList(factoryIds), FactoryInfoDO::getId);
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);
});
}
return success(result);
}
}

View File

@ -0,0 +1,21 @@
package cn.iocoder.yudao.module.smartfactory.controller.admin.industrialinjury.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.math.BigDecimal;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@Schema(description = "管理后台 - 垫资明细")
@Data
public class AdvancePaymentItem {
@Schema(description = "金额")
private BigDecimal amount;
@Schema(description = "时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private String time;
}

View File

@ -0,0 +1,24 @@
package cn.iocoder.yudao.module.smartfactory.controller.admin.industrialinjury.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.math.BigDecimal;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@Schema(description = "管理后台 - 理赔明细")
@Data
public class ClaimAmountItem {
@Schema(description = "理赔方")
private String payee;
@Schema(description = "金额")
private BigDecimal amount;
@Schema(description = "理赔时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private String time;
}

View File

@ -0,0 +1,36 @@
package cn.iocoder.yudao.module.smartfactory.controller.admin.industrialinjury.vo;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDate;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@Schema(description = "管理后台 - 厂区工伤分页 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class IndustrialInjuryPageReqVO extends PageParam {
@Schema(description = "用户编号", example = "146")
private Long staffId;
@Schema(description = "所属工厂编号", example = "10000008")
private Long factoryId;
@Schema(description = "发生时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDate[] happenTime;
@Schema(description = "垫资方 | 1公司 2工厂")
private Integer payer;
@Schema(description = "状态 | 1处理中 2已完成", example = "1")
private Integer status;
}

View File

@ -0,0 +1,74 @@
package cn.iocoder.yudao.module.smartfactory.controller.admin.industrialinjury.vo;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;
@Schema(description = "管理后台 - 厂区工伤 Response VO")
@Data
@ExcelIgnoreUnannotated
public class IndustrialInjuryRespVO {
@Schema(description = "主键id", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
@ExcelProperty("主键id")
private Long id;
@Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "146")
@ExcelProperty("用户编号")
private Long staffId;
@Schema(description = "用户名称")
private String staffName;
@Schema(description = "所属工厂编号", example = "10000008")
@ExcelProperty("所属工厂编号")
private Long factoryId;
@Schema(description = "所属工厂名称")
private String factoryName;
@Schema(description = "发生时间")
@ExcelProperty("发生时间")
private LocalDate happenTime;
@Schema(description = "受伤原因")
@ExcelProperty("受伤原因")
private String reason;
@Schema(description = "医药垫资金额")
@ExcelProperty("医药垫资金额")
private BigDecimal advancePayment;
@Schema(description = "医药垫资明细")
private List<AdvancePaymentItem> advancePaymentItems;
@Schema(description = "垫资方 | 1公司 2工厂")
@ExcelProperty("垫资方 | 1公司 2工厂")
private Integer payer;
@Schema(description = "理赔金额")
@ExcelProperty("理赔金额")
private BigDecimal claimAmount;
@Schema(description = "理赔明细")
private List<ClaimAmountItem> claimAmountItems;
@Schema(description = "状态 | 1处理中 2已完成", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
@ExcelProperty("状态 | 1处理中 2已完成")
private Integer status;
@Schema(description = "附件信息")
@ExcelProperty("附件信息")
private List<UploadFilesVO> fileItems;
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("创建时间")
private LocalDateTime createTime;
}

View File

@ -0,0 +1,52 @@
package cn.iocoder.yudao.module.smartfactory.controller.admin.industrialinjury.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.util.List;
@Schema(description = "管理后台 - 厂区工伤新增/修改 Request VO")
@Data
public class IndustrialInjurySaveReqVO {
@Schema(description = "主键id", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
private Long id;
@Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "146")
@NotNull(message = "用户编号不能为空")
private Long staffId;
@Schema(description = "所属工厂编号", example = "10000008")
private Long factoryId;
@Schema(description = "发生时间")
private LocalDate happenTime;
@Schema(description = "受伤原因")
private String reason;
@Schema(description = "医药垫资金额")
private BigDecimal advancePayment;
@Schema(description = "医药垫资明细")
private List<AdvancePaymentItem> advancePaymentItems;
@Schema(description = "垫资方 | 1公司 2工厂")
private Integer payer;
@Schema(description = "理赔金额")
private BigDecimal claimAmount;
@Schema(description = "理赔明细")
private List<ClaimAmountItem> claimAmountItems;
@Schema(description = "状态 | 1处理中 2已完成")
private Integer status;
@Schema(description = "附件信息")
private List<UploadFilesVO> fileItems;
}

View File

@ -0,0 +1,13 @@
package cn.iocoder.yudao.module.smartfactory.controller.admin.staffsalary.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@Schema(description = "管理后台 - 扣款明细 Response VO")
@Data
public class DeductionItemsVO {
private String key;
private String value;
}

View File

@ -0,0 +1,86 @@
package cn.iocoder.yudao.module.smartfactory.dal.dataobject.industrialinjury;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
import cn.iocoder.yudao.module.smartfactory.controller.admin.industrialinjury.vo.AdvancePaymentItem;
import cn.iocoder.yudao.module.smartfactory.controller.admin.industrialinjury.vo.ClaimAmountItem;
import cn.iocoder.yudao.module.smartfactory.controller.admin.industrialinjury.vo.UploadFilesVO;
import com.baomidou.mybatisplus.annotation.KeySequence;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
import lombok.*;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.util.List;
/**
* 厂区工伤 DO
*
* @author 符溶馨
*/
@TableName(value = "sf_industrial_injury", autoResultMap = true)
@KeySequence("sf_industrial_injury_seq") // 用于 OraclePostgreSQLKingbaseDB2H2 数据库的主键自增如果是 MySQL 等数据库可不写
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class IndustrialInjuryDO extends BaseDO {
/**
* 主键id
*/
@TableId
private Long id;
/**
* 用户编号
*/
private Long staffId;
/**
* 所属工厂编号
*/
private Long factoryId;
/**
* 发生时间
*/
private LocalDate happenTime;
/**
* 受伤原因
*/
private String reason;
/**
* 医药垫资金额
*/
private BigDecimal advancePayment;
/**
* 垫资明细
*/
@TableField(typeHandler = JacksonTypeHandler.class)
private List<AdvancePaymentItem> advancePaymentItems;
/**
* 垫资方 | 1公司 2工厂
*/
private Integer payer;
/**
* 理赔金额
*/
private BigDecimal claimAmount;
/**
* 理赔明细
*/
@TableField(typeHandler = JacksonTypeHandler.class)
private List<ClaimAmountItem> claimAmountItems;
/**
* 状态 | 1处理中 2已完成
*/
private Integer status;
/**
* 附件信息
*/
@TableField(typeHandler = JacksonTypeHandler.class)
private List<UploadFilesVO> fileItems;
}

View File

@ -0,0 +1,28 @@
package cn.iocoder.yudao.module.smartfactory.dal.mysql.industrialinjury;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.smartfactory.controller.admin.industrialinjury.vo.IndustrialInjuryPageReqVO;
import cn.iocoder.yudao.module.smartfactory.dal.dataobject.industrialinjury.IndustrialInjuryDO;
import org.apache.ibatis.annotations.Mapper;
/**
* 厂区工伤 Mapper
*
* @author 符溶馨
*/
@Mapper
public interface IndustrialInjuryMapper extends BaseMapperX<IndustrialInjuryDO> {
default PageResult<IndustrialInjuryDO> selectPage(IndustrialInjuryPageReqVO reqVO) {
return selectPage(reqVO, new LambdaQueryWrapperX<IndustrialInjuryDO>()
.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));
}
}

View File

@ -6,6 +6,7 @@ import cn.iocoder.yudao.module.system.api.assets.AssetsTypeApi;
import cn.iocoder.yudao.module.system.api.dept.DeptApi; import cn.iocoder.yudao.module.system.api.dept.DeptApi;
import cn.iocoder.yudao.module.system.api.dept.PostApi; import cn.iocoder.yudao.module.system.api.dept.PostApi;
import cn.iocoder.yudao.module.system.api.dict.DictDataApi; import cn.iocoder.yudao.module.system.api.dict.DictDataApi;
import cn.iocoder.yudao.module.system.api.loan.LoanApi;
import cn.iocoder.yudao.module.system.api.notify.NotifyMessageSendApi; import cn.iocoder.yudao.module.system.api.notify.NotifyMessageSendApi;
import cn.iocoder.yudao.module.system.api.permission.PermissionApi; import cn.iocoder.yudao.module.system.api.permission.PermissionApi;
import cn.iocoder.yudao.module.system.api.permission.RoleApi; import cn.iocoder.yudao.module.system.api.permission.RoleApi;
@ -17,7 +18,7 @@ import org.springframework.context.annotation.Configuration;
@Configuration(proxyBeanMethods = false) @Configuration(proxyBeanMethods = false)
@EnableFeignClients(clients = {FileApi.class, RoleApi.class, DeptApi.class, PostApi.class, AdminUserApi.class, SmsSendApi.class, DictDataApi.class, NotifyMessageSendApi.class, @EnableFeignClients(clients = {FileApi.class, RoleApi.class, DeptApi.class, PostApi.class, AdminUserApi.class, SmsSendApi.class, DictDataApi.class, NotifyMessageSendApi.class,
SubscribeMessageSendApi.class, ConfigApi.class, PermissionApi.class, AssetsTypeApi.class SubscribeMessageSendApi.class, ConfigApi.class, PermissionApi.class, AssetsTypeApi.class, LoanApi.class
}) })
public class RpcConfiguration { public class RpcConfiguration {
} }

View File

@ -0,0 +1,55 @@
package cn.iocoder.yudao.module.smartfactory.service.industrialinjury;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.smartfactory.controller.admin.industrialinjury.vo.IndustrialInjuryPageReqVO;
import cn.iocoder.yudao.module.smartfactory.controller.admin.industrialinjury.vo.IndustrialInjurySaveReqVO;
import cn.iocoder.yudao.module.smartfactory.dal.dataobject.industrialinjury.IndustrialInjuryDO;
import javax.validation.Valid;
/**
* 厂区工伤 Service 接口
*
* @author 符溶馨
*/
public interface IndustrialInjuryService {
/**
* 创建厂区工伤
*
* @param createReqVO 创建信息
* @return 编号
*/
Long createIndustrialInjury(@Valid IndustrialInjurySaveReqVO createReqVO);
/**
* 更新厂区工伤
*
* @param updateReqVO 更新信息
*/
void updateIndustrialInjury(@Valid IndustrialInjurySaveReqVO updateReqVO);
/**
* 删除厂区工伤
*
* @param id 编号
*/
void deleteIndustrialInjury(Long id);
/**
* 获得厂区工伤
*
* @param id 编号
* @return 厂区工伤
*/
IndustrialInjuryDO getIndustrialInjury(Long id);
/**
* 获得厂区工伤分页
*
* @param pageReqVO 分页查询
* @return 厂区工伤分页
*/
PageResult<IndustrialInjuryDO> getIndustrialInjuryPage(IndustrialInjuryPageReqVO pageReqVO);
}

View File

@ -0,0 +1,71 @@
package cn.iocoder.yudao.module.smartfactory.service.industrialinjury;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.smartfactory.controller.admin.industrialinjury.vo.IndustrialInjuryPageReqVO;
import cn.iocoder.yudao.module.smartfactory.controller.admin.industrialinjury.vo.IndustrialInjurySaveReqVO;
import cn.iocoder.yudao.module.smartfactory.dal.dataobject.industrialinjury.IndustrialInjuryDO;
import cn.iocoder.yudao.module.smartfactory.dal.mysql.industrialinjury.IndustrialInjuryMapper;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.module.smartfactory.enums.ErrorCodeConstants.INDUSTRIAL_INJURY_NOT_EXISTS;
/**
* 厂区工伤 Service 实现类
*
* @author 符溶馨
*/
@Service
@Validated
public class IndustrialInjuryServiceImpl implements IndustrialInjuryService {
@Resource
private IndustrialInjuryMapper industrialInjuryMapper;
@Override
public Long createIndustrialInjury(IndustrialInjurySaveReqVO createReqVO) {
// 插入
IndustrialInjuryDO industrialInjury = BeanUtils.toBean(createReqVO, IndustrialInjuryDO.class);
industrialInjuryMapper.insert(industrialInjury);
// 返回
return industrialInjury.getId();
}
@Override
public void updateIndustrialInjury(IndustrialInjurySaveReqVO updateReqVO) {
// 校验存在
validateIndustrialInjuryExists(updateReqVO.getId());
// 更新
IndustrialInjuryDO updateObj = BeanUtils.toBean(updateReqVO, IndustrialInjuryDO.class);
industrialInjuryMapper.updateById(updateObj);
}
@Override
public void deleteIndustrialInjury(Long id) {
// 校验存在
validateIndustrialInjuryExists(id);
// 删除
industrialInjuryMapper.deleteById(id);
}
private void validateIndustrialInjuryExists(Long id) {
if (industrialInjuryMapper.selectById(id) == null) {
throw exception(INDUSTRIAL_INJURY_NOT_EXISTS);
}
}
@Override
public IndustrialInjuryDO getIndustrialInjury(Long id) {
return industrialInjuryMapper.selectById(id);
}
@Override
public PageResult<IndustrialInjuryDO> getIndustrialInjuryPage(IndustrialInjuryPageReqVO pageReqVO) {
return industrialInjuryMapper.selectPage(pageReqVO);
}
}