员工工资设置

dev
siontion 4 months ago
parent a5b2b39ebe
commit 3712e33b19

@ -55,6 +55,8 @@ public interface ErrorCodeConstants {
ErrorCode PROCESS_DETAIL_NOT_EXISTS = new ErrorCode(1_001_018, "工艺路线明细不存在"); ErrorCode PROCESS_DETAIL_NOT_EXISTS = new ErrorCode(1_001_018, "工艺路线明细不存在");
ErrorCode PROCESS_SETTING_NOT_EXISTS = new ErrorCode(1_001_019, "工时工价不存在"); ErrorCode PROCESS_SETTING_NOT_EXISTS = new ErrorCode(1_001_019, "工时工价不存在");
ErrorCode SALARY_SETTING_NOT_EXISTS = new ErrorCode(1_001_020, "员工工资设置不存在"); ErrorCode SALARY_SETTING_NOT_EXISTS = new ErrorCode(1_001_020, "员工工资设置不存在");
ErrorCode SALARY_USER_NOT_EXISTS = new ErrorCode(1_001_021, "员工工资设置主表不存在");
/*********组织架构************/ /*********组织架构************/
ErrorCode WORKSHOP_NOT_EXISTS = new ErrorCode(1_002_001, "车间不存在"); ErrorCode WORKSHOP_NOT_EXISTS = new ErrorCode(1_002_001, "车间不存在");

@ -1,95 +1,129 @@
package com.chanko.yunxi.mes.module.biz.controller.admin.salarysetting; package com.chanko.yunxi.mes.module.biz.controller.admin.salarysetting;
import org.springframework.web.bind.annotation.*; import cn.hutool.core.collection.CollUtil;
import javax.annotation.Resource; import com.chanko.yunxi.mes.module.biz.controller.admin.salarysetting.vo.SalaryUserSaveReqVO;
import org.springframework.validation.annotation.Validated; import com.chanko.yunxi.mes.module.biz.dal.dataobject.salaryuser.SalaryUserDO;
import org.springframework.security.access.prepost.PreAuthorize; import com.chanko.yunxi.mes.module.biz.service.salaryuser.SalaryUserService;
import io.swagger.v3.oas.annotations.tags.Tag; import org.springframework.web.bind.annotation.*;
import io.swagger.v3.oas.annotations.Parameter; import javax.annotation.Resource;
import io.swagger.v3.oas.annotations.Operation; import org.springframework.validation.annotation.Validated;
import org.springframework.security.access.prepost.PreAuthorize;
import javax.validation.constraints.*; import io.swagger.v3.oas.annotations.tags.Tag;
import javax.validation.*; import io.swagger.v3.oas.annotations.Parameter;
import javax.servlet.http.*; import io.swagger.v3.oas.annotations.Operation;
import java.util.*;
import java.io.IOException; import javax.validation.*;
import javax.servlet.http.*;
import com.chanko.yunxi.mes.framework.common.pojo.PageParam; import java.util.*;
import com.chanko.yunxi.mes.framework.common.pojo.PageResult; import java.io.IOException;
import com.chanko.yunxi.mes.framework.common.pojo.CommonResult;
import com.chanko.yunxi.mes.framework.common.util.object.BeanUtils; import com.chanko.yunxi.mes.framework.common.pojo.PageParam;
import static com.chanko.yunxi.mes.framework.common.pojo.CommonResult.success; import com.chanko.yunxi.mes.framework.common.pojo.PageResult;
import com.chanko.yunxi.mes.framework.common.pojo.CommonResult;
import com.chanko.yunxi.mes.framework.excel.core.util.ExcelUtils; import com.chanko.yunxi.mes.framework.common.util.object.BeanUtils;
import static com.chanko.yunxi.mes.framework.common.pojo.CommonResult.success;
import com.chanko.yunxi.mes.framework.operatelog.core.annotations.OperateLog;
import static com.chanko.yunxi.mes.framework.operatelog.core.enums.OperateTypeEnum.*; import com.chanko.yunxi.mes.framework.excel.core.util.ExcelUtils;
import com.chanko.yunxi.mes.module.biz.controller.admin.salarysetting.vo.*; import com.chanko.yunxi.mes.framework.operatelog.core.annotations.OperateLog;
import com.chanko.yunxi.mes.module.biz.dal.dataobject.salarysetting.SalarySettingDO; import static com.chanko.yunxi.mes.framework.operatelog.core.enums.OperateTypeEnum.*;
import com.chanko.yunxi.mes.module.biz.service.salarysetting.SalarySettingService;
import com.chanko.yunxi.mes.module.biz.controller.admin.salarysetting.vo.*;
@Tag(name = "管理后台 - 员工工资设置") import com.chanko.yunxi.mes.module.biz.dal.dataobject.salarysetting.SalarySettingDO;
@RestController import com.chanko.yunxi.mes.module.biz.service.salarysetting.SalarySettingService;
@RequestMapping("/biz/salary-setting")
@Validated @Tag(name = "管理后台 - 员工工资设置")
public class SalarySettingController { @RestController
@RequestMapping("/biz/salary-setting")
@Resource @Validated
private SalarySettingService salarySettingService; public class SalarySettingController {
@PostMapping("/create") @Resource
@Operation(summary = "创建员工工资设置") private SalaryUserService salaryUserService;
@PreAuthorize("@ss.hasPermission('biz:salary-setting:create')")
public CommonResult<Long> createSalarySetting(@Valid @RequestBody SalarySettingSaveReqVO createReqVO) { @Resource
return success(salarySettingService.createSalarySetting(createReqVO)); private SalarySettingService salarySettingService;
}
@PostMapping("/create")
@PutMapping("/update") @Operation(summary = "创建员工工资设置主")
@Operation(summary = "更新员工工资设置") @PreAuthorize("@ss.hasPermission('biz:salary-user:create')")
@PreAuthorize("@ss.hasPermission('biz:salary-setting:update')") public CommonResult<Long> createSalaryUser(@Valid @RequestBody SalaryUserSaveReqVO createReqVO) {
public CommonResult<Boolean> updateSalarySetting(@Valid @RequestBody SalarySettingSaveReqVO updateReqVO) { return success(salaryUserService.createSalaryUser(createReqVO));
salarySettingService.updateSalarySetting(updateReqVO); }
return success(true);
} @PutMapping("/update")
@Operation(summary = "更新员工工资设置主")
@DeleteMapping("/delete") @PreAuthorize("@ss.hasPermission('biz:salary-user:update')")
@Operation(summary = "删除员工工资设置") public CommonResult<Boolean> updateSalaryUser(@Valid @RequestBody SalaryUserSaveReqVO updateReqVO) {
@Parameter(name = "id", description = "编号", required = true) salaryUserService.updateSalaryUser(updateReqVO);
@PreAuthorize("@ss.hasPermission('biz:salary-setting:delete')") return success(true);
public CommonResult<Boolean> deleteSalarySetting(@RequestParam("id") Long id) { }
salarySettingService.deleteSalarySetting(id);
return success(true); @DeleteMapping("/delete")
} @Operation(summary = "删除员工工资设置主")
@Parameter(name = "id", description = "编号", required = true)
@GetMapping("/get") @PreAuthorize("@ss.hasPermission('biz:salary-user:delete')")
@Operation(summary = "获得员工工资设置") public CommonResult<Boolean> deleteSalaryUser(@RequestParam("id") Long id) {
@Parameter(name = "id", description = "编号", required = true, example = "1024") salaryUserService.deleteSalaryUser(id);
@PreAuthorize("@ss.hasPermission('biz:salary-setting:query')") return success(true);
public CommonResult<SalarySettingRespVO> getSalarySetting(@RequestParam("id") Long id) { }
SalarySettingDO salarySetting = salarySettingService.getSalarySetting(id); @GetMapping("/get")
return success(BeanUtils.toBean(salarySetting, SalarySettingRespVO.class)); @Operation(summary = "获得员工工资设置")
} @Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('biz:salary-setting:query')")
@GetMapping("/page") public CommonResult<SalaryUserRespVO> getSalarySetting(@RequestParam("id") Long id) {
@Operation(summary = "获得员工工资设置分页")
@PreAuthorize("@ss.hasPermission('biz:salary-setting:query')") SalaryUserDO salaryUserDO = salaryUserService.getSalaryUser(id);
public CommonResult<PageResult<SalarySettingRespVO>> getSalarySettingPage(@Valid SalarySettingPageReqVO pageReqVO) {
PageResult<SalarySettingDO> pageResult = salarySettingService.getSalarySettingPage(pageReqVO); SalarySettingPageReqVO pageReqVO = new SalarySettingPageReqVO();
return success(BeanUtils.toBean(pageResult, SalarySettingRespVO.class)); pageReqVO.setUserId(salaryUserDO.getUserId());
} pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
PageResult<SalarySettingDO> salarySetting = salarySettingService.getSalarySettingByUserIdPage(pageReqVO);
@GetMapping("/export-excel") SalaryUserRespVO result = BeanUtils.toBean(salaryUserDO, SalaryUserRespVO.class);
@Operation(summary = "导出员工工资设置 Excel") result.setSetting(salarySetting.getList());
@PreAuthorize("@ss.hasPermission('biz:salary-setting:export')") return success(result);
@OperateLog(type = EXPORT) }
public void exportSalarySettingExcel(@Valid SalarySettingPageReqVO pageReqVO,
HttpServletResponse response) throws IOException { @GetMapping("/page-setting")
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); @Operation(summary = "获得员工工资设置分页")
List<SalarySettingDO> list = salarySettingService.getSalarySettingPage(pageReqVO).getList(); @PreAuthorize("@ss.hasPermission('biz:salary-setting:query')")
// 导出 Excel public CommonResult<PageResult<SalarySettingRespVO>> getSalarySettingPage(@Valid SalarySettingPageReqVO pageReqVO) {
ExcelUtils.write(response, "员工工资设置.xls", "数据", SalarySettingRespVO.class, PageResult<SalarySettingDO> pageResult = salarySettingService.getSalarySettingPage(pageReqVO);
BeanUtils.toBean(list, SalarySettingRespVO.class)); return success(BeanUtils.toBean(pageResult, SalarySettingRespVO.class));
} }
} @GetMapping("/export-setting-excel")
@Operation(summary = "导出员工工资设置 Excel")
@PreAuthorize("@ss.hasPermission('biz:salary-setting:export')")
@OperateLog(type = EXPORT)
public void exportSalarySettingExcel(@Valid SalarySettingPageReqVO pageReqVO,
HttpServletResponse response) throws IOException {
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
List<SalarySettingDO> list = salarySettingService.getSalarySettingPage(pageReqVO).getList();
// 导出 Excel
ExcelUtils.write(response, "员工工资设置.xls", "数据", SalarySettingRespVO.class,
BeanUtils.toBean(list, SalarySettingRespVO.class));
}
@GetMapping("/page")
@Operation(summary = "获得员工工资设置主分页")
@PreAuthorize("@ss.hasPermission('biz:salary-user:query')")
public CommonResult<PageResult<SalaryUserRespVO>> getSalaryUserPage(@Valid SalaryUserPageReqVO pageReqVO) {
PageResult<SalaryUserDO> pageResult = salaryUserService.getSalaryUserPage(pageReqVO);
return success(BeanUtils.toBean(pageResult, SalaryUserRespVO.class));
}
@GetMapping("/export-excel")
@Operation(summary = "导出员工工资设置主表 Excel")
@PreAuthorize("@ss.hasPermission('biz:salary-user:export')")
@OperateLog(type = EXPORT)
public void exportSalaryUserExcel(@Valid SalaryUserPageReqVO pageReqVO,
HttpServletResponse response) throws IOException {
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
List<SalaryUserDO> list = salaryUserService.getSalaryUserPage(pageReqVO).getList();
// 导出 Excel
ExcelUtils.write(response, "员工工资设置主表.xls", "数据", SalaryUserRespVO.class,
BeanUtils.toBean(list, SalaryUserRespVO.class));
}
}

@ -1,5 +1,6 @@
package com.chanko.yunxi.mes.module.biz.controller.admin.salarysetting.vo; package com.chanko.yunxi.mes.module.biz.controller.admin.salarysetting.vo;
import com.chanko.yunxi.mes.module.biz.dal.dataobject.salarysetting.SalarySettingDO;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*; import lombok.*;
@ -34,6 +35,10 @@ public class SalarySettingRespVO {
@ExcelProperty("工序范围") @ExcelProperty("工序范围")
private String procedure; private String procedure;
@Schema(description = "工序ids范围")
@ExcelProperty("工序ids范围")
private String procedureIds;
@Schema(description = "状态,1表示正常2表示禁用", requiredMode = Schema.RequiredMode.REQUIRED) @Schema(description = "状态,1表示正常2表示禁用", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("状态,1表示正常2表示禁用") @ExcelProperty("状态,1表示正常2表示禁用")
private Boolean status; private Boolean status;
@ -46,4 +51,8 @@ public class SalarySettingRespVO {
@ExcelProperty("工价") @ExcelProperty("工价")
private BigDecimal price; private BigDecimal price;
@Schema(description = "工序列表")
@ExcelProperty("工序列表")
private List<SalarySettingDO> setting;
} }

@ -30,5 +30,7 @@ public class SalarySettingSaveReqVO {
@Schema(description = "工价") @Schema(description = "工价")
private BigDecimal price; private BigDecimal price;
@Schema(description = "工价")
private Long salaryUserId;
} }

@ -0,0 +1,46 @@
package com.chanko.yunxi.mes.module.biz.controller.admin.salarysetting.vo;
import lombok.*;
import java.util.*;
import io.swagger.v3.oas.annotations.media.Schema;
import com.chanko.yunxi.mes.framework.common.pojo.PageParam;
import java.math.BigDecimal;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import static com.chanko.yunxi.mes.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 SalaryUserPageReqVO extends PageParam {
@Schema(description = "自增字段,唯一")
private Long id;
@Schema(description = "员工id")
private Long userId;
@Schema(description = "员工姓名")
private String userName;
@Schema(description = "员工编号")
private String userCode;
@Schema(description = "工资类型字典")
private String salaryType;
@Schema(description = "工价")
private BigDecimal price;
@Schema(description = "工序范围")
private String procedure;
@Schema(description = "状态,1表示正常2表示禁用")
private Integer status;
@Schema(description = "创建时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] createTime;
}

@ -0,0 +1,62 @@
package com.chanko.yunxi.mes.module.biz.controller.admin.salarysetting.vo;
import com.chanko.yunxi.mes.module.biz.dal.dataobject.salarysetting.SalarySettingDO;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
import java.util.*;
import java.math.BigDecimal;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import com.alibaba.excel.annotation.*;
import com.chanko.yunxi.mes.framework.excel.core.annotations.DictFormat;
import com.chanko.yunxi.mes.framework.excel.core.convert.DictConvert;
@Schema(description = "管理后台 - 员工工资设置主 Response VO")
@Data
@ExcelIgnoreUnannotated
public class SalaryUserRespVO {
@Schema(description = "自增字段,唯一", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("自增字段,唯一")
private Long id;
@Schema(description = "员工id")
@ExcelProperty("员工id")
private Long userId;
@Schema(description = "员工姓名")
@ExcelProperty("员工姓名")
private String userName;
@Schema(description = "员工工号")
@ExcelProperty("员工工号")
private String userCode;
@Schema(description = "工资类型字典")
@ExcelProperty(value = "工资类型字典", converter = DictConvert.class)
@DictFormat("biz_salary_type") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中
private String salaryType;
@Schema(description = "工价")
@ExcelProperty("工价")
private BigDecimal price;
@Schema(description = "工序范围")
@ExcelProperty(value = "工序范围", converter = DictConvert.class)
@DictFormat("biz_procedure_range") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中
private String procedure;
@Schema(description = "状态,1表示正常2表示禁用", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("状态,1表示正常2表示禁用")
private Integer status;
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("创建时间")
private LocalDateTime createTime;
@Schema(description = "工序列表")
@ExcelProperty("工序列表")
private List<SalarySettingDO> setting;
}

@ -0,0 +1,36 @@
package com.chanko.yunxi.mes.module.biz.controller.admin.salarysetting.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
import javax.validation.constraints.*;
import java.util.*;
import java.math.BigDecimal;
@Schema(description = "管理后台 - 员工工资设置主新增/修改 Request VO")
@Data
public class SalaryUserSaveReqVO {
@Schema(description = "自增字段,唯一", requiredMode = Schema.RequiredMode.REQUIRED)
private Long id;
@Schema(description = "员工id")
private Long userId;
@Schema(description = "工资类型字典")
private String salaryType;
@Schema(description = "工价")
private BigDecimal price;
@Schema(description = "工序范围")
private String procedure;
@Schema(description = "状态,1表示正常2表示禁用", requiredMode = Schema.RequiredMode.REQUIRED)
@NotNull(message = "状态,1表示正常2表示禁用不能为空")
private Integer status;
@Schema(description = "工序范围")
private List<SalarySettingSaveReqVO> setting;
}

@ -33,6 +33,10 @@ public class SalarySettingDO extends BaseDO {
* id * id
*/ */
private Long userId; private Long userId;
@TableField(exist = false)
private String userName;
@TableField(exist = false)
private String userCode;
/** /**
* *
* *
@ -43,13 +47,25 @@ public class SalarySettingDO extends BaseDO {
* *
*/ */
private String procedure; private String procedure;
@TableField(exist = false)
private String procedureIds;
/** /**
* ,12 * ,12
*/ */
private Boolean status; private Integer status;
private Long salaryUserId;
/** /**
* *
*/ */
private BigDecimal price; private BigDecimal price;
@TableField(exist = false)
private String procedureName;
@TableField(exist = false)
private String procedureCode;
@TableField(exist = false)
private String workShopName;
} }

@ -0,0 +1,61 @@
package com.chanko.yunxi.mes.module.biz.dal.dataobject.salaryuser;
import lombok.*;
import java.util.*;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.time.LocalDateTime;
import com.baomidou.mybatisplus.annotation.*;
import com.chanko.yunxi.mes.framework.mybatis.core.dataobject.BaseDO;
/**
* DO
*
* @author
*/
@TableName("base_salary_user")
@KeySequence("base_salary_user_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class SalaryUserDO extends BaseDO {
/**
*
*/
@TableId
private Long id;
/**
* id
*/
private Long userId;
/**
*
*
* {@link TODO biz_salary_type }
*/
private String salaryType;
/**
*
*/
private BigDecimal price;
/**
*
*
* {@link TODO biz_procedure_range }
*/
private String procedure;
/**
* ,12
*/
private Integer status;
@TableField(exist = false)
private String userName;
@TableField(exist = false)
private String userCode;
}

@ -2,12 +2,22 @@ package com.chanko.yunxi.mes.module.biz.dal.mysql.salarysetting;
import java.util.*; import java.util.*;
import cn.hutool.core.collection.CollUtil;
import com.chanko.yunxi.mes.framework.common.pojo.PageResult; import com.chanko.yunxi.mes.framework.common.pojo.PageResult;
import com.chanko.yunxi.mes.framework.mybatis.core.query.LambdaQueryWrapperX; import com.chanko.yunxi.mes.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.chanko.yunxi.mes.framework.mybatis.core.mapper.BaseMapperX; import com.chanko.yunxi.mes.framework.mybatis.core.mapper.BaseMapperX;
import com.chanko.yunxi.mes.module.biz.controller.admin.projectorder.vo.ProjectOrderPageReqVO;
import com.chanko.yunxi.mes.module.biz.dal.dataobject.customer.CustomerDO;
import com.chanko.yunxi.mes.module.biz.dal.dataobject.procedure.ProcedureDO;
import com.chanko.yunxi.mes.module.biz.dal.dataobject.projectorder.ProjectOrderDO;
import com.chanko.yunxi.mes.module.biz.dal.dataobject.salarysetting.SalarySettingDO; import com.chanko.yunxi.mes.module.biz.dal.dataobject.salarysetting.SalarySettingDO;
import com.chanko.yunxi.mes.module.biz.dal.dataobject.workshop.WorkshopDO;
import com.chanko.yunxi.mes.module.system.dal.dataobject.dept.DeptDO;
import com.chanko.yunxi.mes.module.system.dal.dataobject.user.AdminUserDO;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import com.chanko.yunxi.mes.module.biz.controller.admin.salarysetting.vo.*; import com.chanko.yunxi.mes.module.biz.controller.admin.salarysetting.vo.*;
import org.springframework.util.StringUtils;
/** /**
* Mapper * Mapper
@ -17,15 +27,47 @@ import com.chanko.yunxi.mes.module.biz.controller.admin.salarysetting.vo.*;
@Mapper @Mapper
public interface SalarySettingMapper extends BaseMapperX<SalarySettingDO> { public interface SalarySettingMapper extends BaseMapperX<SalarySettingDO> {
// default PageResult<SalarySettingDO> selectPage(SalarySettingPageReqVO reqVO) {
// return selectPage(reqVO, new LambdaQueryWrapperX<SalarySettingDO>()
// .eqIfPresent(SalarySettingDO::getId, reqVO.getId())
// .eqIfPresent(SalarySettingDO::getUserId, reqVO.getUserId())
// .eqIfPresent(SalarySettingDO::getSalaryType, reqVO.getSalaryType())
// .eqIfPresent(SalarySettingDO::getProcedure, reqVO.getProcedure())
// .eqIfPresent(SalarySettingDO::getStatus, reqVO.getStatus())
// .betweenIfPresent(SalarySettingDO::getCreateTime, reqVO.getCreateTime())
// .orderByDesc(SalarySettingDO::getId));
// }
default PageResult<SalarySettingDO> selectPage(SalarySettingPageReqVO reqVO) { default PageResult<SalarySettingDO> selectPage(SalarySettingPageReqVO reqVO) {
return selectPage(reqVO, new LambdaQueryWrapperX<SalarySettingDO>() MPJLambdaWrapper<SalarySettingDO> query = new MPJLambdaWrapper<>();
.eqIfPresent(SalarySettingDO::getId, reqVO.getId()) query.selectAll(SalarySettingDO.class)
.eqIfPresent(SalarySettingDO::getUserId, reqVO.getUserId()) .select("u.nickname as userName", "u.username as userCode")
.eqIfPresent(SalarySettingDO::getSalaryType, reqVO.getSalaryType()) .select("group_concat(t.procedure) as procedureIds")
.eqIfPresent(SalarySettingDO::getProcedure, reqVO.getProcedure()) .leftJoin(AdminUserDO.class, "u", AdminUserDO::getId, SalarySettingDO::getUserId)
.eqIfPresent(SalarySettingDO::getStatus, reqVO.getStatus()) .groupBy(SalarySettingDO::getUserId)
.betweenIfPresent(SalarySettingDO::getCreateTime, reqVO.getCreateTime()) .disableSubLogicDel()
.orderByDesc(SalarySettingDO::getId)); .orderByDesc(SalarySettingDO::getUserId);
query.like(!StringUtils.isEmpty(reqVO.getUserCode()), "u.username", reqVO.getUserCode())
.like(!StringUtils.isEmpty(reqVO.getUserName()), "u.nickname", reqVO.getUserName())
.eq(!StringUtils.isEmpty(reqVO.getUserId()), SalarySettingDO::getUserId, reqVO.getUserId())
;
return selectPage(reqVO, query);
}
default PageResult<SalarySettingDO> selectByUserIdPage(SalarySettingPageReqVO reqVO) {
MPJLambdaWrapper<SalarySettingDO> query = new MPJLambdaWrapper<>();
query.selectAll(SalarySettingDO.class)
.select("u.nickname as userName", "u.username as userCode")
.select("p.name as procedureName","p.code as procedureCode")
.select("w.name as workShopName")
.leftJoin(AdminUserDO.class, "u", AdminUserDO::getId, SalarySettingDO::getUserId)
.leftJoin(ProcedureDO.class,"p",ProcedureDO::getId,SalarySettingDO::getProcedure)
.leftJoin(WorkshopDO.class,"w",WorkshopDO::getId,ProcedureDO::getWid)
.disableSubLogicDel()
.orderByDesc(SalarySettingDO::getUserId);
query.eq(!StringUtils.isEmpty(reqVO.getUserId()), SalarySettingDO::getUserId, reqVO.getUserId())
;
return selectPage(reqVO, query);
} }
} }

@ -0,0 +1,49 @@
package com.chanko.yunxi.mes.module.biz.dal.mysql.salaryuser;
import com.chanko.yunxi.mes.framework.common.pojo.PageResult;
import com.chanko.yunxi.mes.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.chanko.yunxi.mes.framework.mybatis.core.mapper.BaseMapperX;
import com.chanko.yunxi.mes.module.biz.controller.admin.salarysetting.vo.SalarySettingPageReqVO;
import com.chanko.yunxi.mes.module.biz.controller.admin.salarysetting.vo.SalaryUserPageReqVO;
import com.chanko.yunxi.mes.module.biz.dal.dataobject.salarysetting.SalarySettingDO;
import com.chanko.yunxi.mes.module.biz.dal.dataobject.salaryuser.SalaryUserDO;
import com.chanko.yunxi.mes.module.system.dal.dataobject.user.AdminUserDO;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.util.StringUtils;
/**
* Mapper
*
* @author
*/
@Mapper
public interface SalaryUserMapper extends BaseMapperX<SalaryUserDO> {
// default PageResult<SalaryUserDO> selectPage(SalaryUserPageReqVO reqVO) {
// return selectPage(reqVO, new LambdaQueryWrapperX<SalaryUserDO>()
// .eqIfPresent(SalaryUserDO::getId, reqVO.getId())
// .eqIfPresent(SalaryUserDO::getUserId, reqVO.getUserId())
// .eqIfPresent(SalaryUserDO::getSalaryType, reqVO.getSalaryType())
// .eqIfPresent(SalaryUserDO::getPrice, reqVO.getPrice())
// .eqIfPresent(SalaryUserDO::getProcedure, reqVO.getProcedure())
// .eqIfPresent(SalaryUserDO::getStatus, reqVO.getStatus())
// .betweenIfPresent(SalaryUserDO::getCreateTime, reqVO.getCreateTime())
// .orderByDesc(SalaryUserDO::getId));
// }
default PageResult<SalaryUserDO> selectPage(SalaryUserPageReqVO reqVO) {
MPJLambdaWrapper<SalaryUserDO> query = new MPJLambdaWrapper<>();
query.selectAll(SalaryUserDO.class)
.select("u.nickname as userName", "u.username as userCode")
.leftJoin(AdminUserDO.class, "u", AdminUserDO::getId, SalaryUserDO::getUserId)
.disableSubLogicDel()
.orderByDesc(SalaryUserDO::getUserId);
query.like(!StringUtils.isEmpty(reqVO.getUserCode()), "u.username", reqVO.getUserCode())
.like(!StringUtils.isEmpty(reqVO.getUserName()), "u.nickname", reqVO.getUserName())
.eq(!StringUtils.isEmpty(reqVO.getUserId()), SalaryUserDO::getUserId, reqVO.getUserId())
;
return selectPage(reqVO, query);
}
}

@ -1,55 +1,63 @@
package com.chanko.yunxi.mes.module.biz.service.salarysetting; package com.chanko.yunxi.mes.module.biz.service.salarysetting;
import java.util.*; import java.util.*;
import javax.validation.*; import javax.validation.*;
import com.chanko.yunxi.mes.module.biz.controller.admin.salarysetting.vo.*; import com.chanko.yunxi.mes.module.biz.controller.admin.salarysetting.vo.*;
import com.chanko.yunxi.mes.module.biz.dal.dataobject.salarysetting.SalarySettingDO; import com.chanko.yunxi.mes.module.biz.dal.dataobject.salarysetting.SalarySettingDO;
import com.chanko.yunxi.mes.framework.common.pojo.PageResult; import com.chanko.yunxi.mes.framework.common.pojo.PageResult;
import com.chanko.yunxi.mes.framework.common.pojo.PageParam; import com.chanko.yunxi.mes.framework.common.pojo.PageParam;
/** /**
* Service * Service
* *
* @author * @author
*/ */
public interface SalarySettingService { public interface SalarySettingService {
/** /**
* *
* *
* @param createReqVO * @param createReqVO
* @return * @return
*/ */
Long createSalarySetting(@Valid SalarySettingSaveReqVO createReqVO); Long createSalarySetting(@Valid SalarySettingSaveReqVO createReqVO);
/** /**
* *
* *
* @param updateReqVO * @param updateReqVO
*/ */
void updateSalarySetting(@Valid SalarySettingSaveReqVO updateReqVO); void updateSalarySetting(@Valid SalarySettingSaveReqVO updateReqVO);
/** /**
* *
* *
* @param id * @param id
*/ */
void deleteSalarySetting(Long id); void deleteSalarySetting(Long id);
/** /**
* *
* *
* @param id * @param id
* @return * @return
*/ */
SalarySettingDO getSalarySetting(Long id); SalarySettingDO getSalarySetting(Long id);
/** /**
* *
* *
* @param pageReqVO * @param pageReqVO
* @return * @return
*/ */
PageResult<SalarySettingDO> getSalarySettingPage(SalarySettingPageReqVO pageReqVO); PageResult<SalarySettingDO> getSalarySettingPage(SalarySettingPageReqVO pageReqVO);
} /**
*
*
* @param pageReqVO
* @return
*/
PageResult<SalarySettingDO> getSalarySettingByUserIdPage(SalarySettingPageReqVO pageReqVO);
}

@ -1,74 +1,79 @@
package com.chanko.yunxi.mes.module.biz.service.salarysetting; package com.chanko.yunxi.mes.module.biz.service.salarysetting;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.util.*; import java.util.*;
import com.chanko.yunxi.mes.module.biz.controller.admin.salarysetting.vo.*; import com.chanko.yunxi.mes.module.biz.controller.admin.salarysetting.vo.*;
import com.chanko.yunxi.mes.module.biz.dal.dataobject.salarysetting.SalarySettingDO; import com.chanko.yunxi.mes.module.biz.dal.dataobject.salarysetting.SalarySettingDO;
import com.chanko.yunxi.mes.framework.common.pojo.PageResult; import com.chanko.yunxi.mes.framework.common.pojo.PageResult;
import com.chanko.yunxi.mes.framework.common.pojo.PageParam; import com.chanko.yunxi.mes.framework.common.pojo.PageParam;
import com.chanko.yunxi.mes.framework.common.util.object.BeanUtils; import com.chanko.yunxi.mes.framework.common.util.object.BeanUtils;
import com.chanko.yunxi.mes.module.biz.dal.mysql.salarysetting.SalarySettingMapper; import com.chanko.yunxi.mes.module.biz.dal.mysql.salarysetting.SalarySettingMapper;
import static com.chanko.yunxi.mes.framework.common.exception.util.ServiceExceptionUtil.exception; import static com.chanko.yunxi.mes.framework.common.exception.util.ServiceExceptionUtil.exception;
import static com.chanko.yunxi.mes.module.biz.enums.ErrorCodeConstants.*; import static com.chanko.yunxi.mes.module.biz.enums.ErrorCodeConstants.*;
/** /**
* Service * Service
* *
* @author * @author
*/ */
@Service @Service
@Validated @Validated
public class SalarySettingServiceImpl implements SalarySettingService { public class SalarySettingServiceImpl implements SalarySettingService {
@Resource @Resource
private SalarySettingMapper salarySettingMapper; private SalarySettingMapper salarySettingMapper;
@Override @Override
public Long createSalarySetting(SalarySettingSaveReqVO createReqVO) { public Long createSalarySetting(SalarySettingSaveReqVO createReqVO) {
// 插入 // 插入
SalarySettingDO salarySetting = BeanUtils.toBean(createReqVO, SalarySettingDO.class); SalarySettingDO salarySetting = BeanUtils.toBean(createReqVO, SalarySettingDO.class);
salarySettingMapper.insert(salarySetting); salarySettingMapper.insert(salarySetting);
// 返回 // 返回
return salarySetting.getId(); return salarySetting.getId();
} }
@Override @Override
public void updateSalarySetting(SalarySettingSaveReqVO updateReqVO) { public void updateSalarySetting(SalarySettingSaveReqVO updateReqVO) {
// 校验存在 // 校验存在
validateSalarySettingExists(updateReqVO.getId()); validateSalarySettingExists(updateReqVO.getId());
// 更新 // 更新
SalarySettingDO updateObj = BeanUtils.toBean(updateReqVO, SalarySettingDO.class); SalarySettingDO updateObj = BeanUtils.toBean(updateReqVO, SalarySettingDO.class);
salarySettingMapper.updateById(updateObj); salarySettingMapper.updateById(updateObj);
} }
@Override @Override
public void deleteSalarySetting(Long id) { public void deleteSalarySetting(Long id) {
// 校验存在 // 校验存在
validateSalarySettingExists(id); validateSalarySettingExists(id);
// 删除 // 删除
salarySettingMapper.deleteById(id); salarySettingMapper.deleteById(id);
} }
private void validateSalarySettingExists(Long id) { private void validateSalarySettingExists(Long id) {
if (salarySettingMapper.selectById(id) == null) { if (salarySettingMapper.selectById(id) == null) {
throw exception(SALARY_SETTING_NOT_EXISTS); throw exception(SALARY_SETTING_NOT_EXISTS);
} }
} }
@Override @Override
public SalarySettingDO getSalarySetting(Long id) { public SalarySettingDO getSalarySetting(Long id) {
return salarySettingMapper.selectById(id); return salarySettingMapper.selectById(id);
} }
@Override @Override
public PageResult<SalarySettingDO> getSalarySettingPage(SalarySettingPageReqVO pageReqVO) { public PageResult<SalarySettingDO> getSalarySettingPage(SalarySettingPageReqVO pageReqVO) {
return salarySettingMapper.selectPage(pageReqVO); return salarySettingMapper.selectPage(pageReqVO);
} }
} @Override
public PageResult<SalarySettingDO> getSalarySettingByUserIdPage(SalarySettingPageReqVO pageReqVO) {
return salarySettingMapper.selectByUserIdPage(pageReqVO);
}
}

@ -0,0 +1,55 @@
package com.chanko.yunxi.mes.module.biz.service.salaryuser;
import javax.validation.*;
import com.chanko.yunxi.mes.module.biz.controller.admin.salarysetting.vo.SalaryUserPageReqVO;
import com.chanko.yunxi.mes.module.biz.controller.admin.salarysetting.vo.SalaryUserSaveReqVO;
import com.chanko.yunxi.mes.module.biz.dal.dataobject.salaryuser.SalaryUserDO;
import com.chanko.yunxi.mes.framework.common.pojo.PageResult;
/**
* Service
*
* @author
*/
public interface SalaryUserService {
/**
*
*
* @param createReqVO
* @return
*/
Long createSalaryUser(@Valid SalaryUserSaveReqVO createReqVO);
/**
*
*
* @param updateReqVO
*/
void updateSalaryUser(@Valid SalaryUserSaveReqVO updateReqVO);
/**
*
*
* @param id
*/
void deleteSalaryUser(Long id);
/**
*
*
* @param id
* @return
*/
SalaryUserDO getSalaryUser(Long id);
/**
*
*
* @param pageReqVO
* @return
*/
PageResult<SalaryUserDO> getSalaryUserPage(SalaryUserPageReqVO pageReqVO);
}

@ -0,0 +1,113 @@
package com.chanko.yunxi.mes.module.biz.service.salaryuser;
import cn.hutool.core.collection.CollUtil;
import com.chanko.yunxi.mes.module.biz.controller.admin.salarysetting.vo.SalaryUserPageReqVO;
import com.chanko.yunxi.mes.module.biz.controller.admin.salarysetting.vo.SalaryUserSaveReqVO;
import com.chanko.yunxi.mes.module.biz.dal.dataobject.salarysetting.SalarySettingDO;
import com.chanko.yunxi.mes.module.biz.dal.dataobject.warehouse.WarehouseDO;
import com.chanko.yunxi.mes.module.biz.dal.mysql.salarysetting.SalarySettingMapper;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import com.chanko.yunxi.mes.module.biz.dal.dataobject.salaryuser.SalaryUserDO;
import com.chanko.yunxi.mes.framework.common.pojo.PageResult;
import com.chanko.yunxi.mes.framework.common.util.object.BeanUtils;
import com.chanko.yunxi.mes.module.biz.dal.mysql.salaryuser.SalaryUserMapper;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import static com.chanko.yunxi.mes.framework.common.exception.util.ServiceExceptionUtil.exception;
import static com.chanko.yunxi.mes.module.biz.enums.ErrorCodeConstants.*;
/**
* Service
*
* @author
*/
@Service
@Validated
public class SalaryUserServiceImpl implements SalaryUserService {
@Resource
private SalaryUserMapper salaryUserMapper;
@Resource
private SalarySettingMapper salarySettingMapper;
@Override
public Long createSalaryUser(SalaryUserSaveReqVO createReqVO) {
// 插入
SalaryUserDO salaryUser = BeanUtils.toBean(createReqVO, SalaryUserDO.class);
salaryUserMapper.insert(salaryUser);
// 返回
return salaryUser.getId();
}
@Override
public void updateSalaryUser(SalaryUserSaveReqVO updateReqVO) {
// 校验存在
validateSalaryUserExists(updateReqVO.getId());
// 更新
SalaryUserDO updateObj = BeanUtils.toBean(updateReqVO, SalaryUserDO.class);
salaryUserMapper.updateById(updateObj);
if(CollUtil.isNotEmpty(updateReqVO.getSetting())){
List<SalarySettingDO> insertList = new ArrayList<>(16);
List<SalarySettingDO> updateList = new ArrayList<>(16);
updateReqVO.getSetting().forEach(setting ->{
SalarySettingDO salarySettingDO =new SalarySettingDO();
if(setting.getId()==null || setting.getId()==0){
salarySettingDO.setSalaryUserId(updateObj.getId());
salarySettingDO.setUserId(updateObj.getUserId());
salarySettingDO.setSalaryType(updateObj.getSalaryType());
salarySettingDO.setSalaryUserId(updateObj.getId());
salarySettingDO.setPrice(updateObj.getPrice());
salarySettingDO.setStatus(updateObj.getStatus());
insertList.add(salarySettingDO);
}else{
salarySettingDO.setId(setting.getId());
salarySettingDO.setSalaryUserId(updateObj.getId());
salarySettingDO.setUserId(updateObj.getUserId());
salarySettingDO.setSalaryType(updateObj.getSalaryType());
salarySettingDO.setSalaryUserId(updateObj.getId());
salarySettingDO.setPrice(updateObj.getPrice());
salarySettingDO.setStatus(updateObj.getStatus());
updateList.add(salarySettingDO);
}
});
if(CollUtil.isNotEmpty(insertList)) salarySettingMapper.insertBatch(insertList);
if(CollUtil.isNotEmpty(updateList)) salarySettingMapper.updateBatch(updateList);
}
}
@Override
public void deleteSalaryUser(Long id) {
// 校验存在
validateSalaryUserExists(id);
// 删除
salaryUserMapper.deleteById(id);
}
private void validateSalaryUserExists(Long id) {
if (salaryUserMapper.selectById(id) == null) {
throw exception(SALARY_USER_NOT_EXISTS);
}
}
@Override
public SalaryUserDO getSalaryUser(Long id) {
return salaryUserMapper.selectById(id);
}
@Override
public PageResult<SalaryUserDO> getSalaryUserPage(SalaryUserPageReqVO pageReqVO) {
return salaryUserMapper.selectPage(pageReqVO);
}
}

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.chanko.yunxi.mes.module.biz.dal.mysql.salaryuser.SalaryUserMapper">
<!--
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
文档可见https://www.iocoder.cn/MyBatis/x-plugins/
-->
</mapper>

@ -1,9 +1,11 @@
package com.chanko.yunxi.mes.module.system.dal.mysql.user; package com.chanko.yunxi.mes.module.system.dal.mysql.user;
import cn.hutool.core.collection.CollUtil;
import com.chanko.yunxi.mes.framework.common.pojo.PageResult; import com.chanko.yunxi.mes.framework.common.pojo.PageResult;
import com.chanko.yunxi.mes.framework.mybatis.core.mapper.BaseMapperX; import com.chanko.yunxi.mes.framework.mybatis.core.mapper.BaseMapperX;
import com.chanko.yunxi.mes.framework.mybatis.core.query.LambdaQueryWrapperX; import com.chanko.yunxi.mes.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.chanko.yunxi.mes.module.system.controller.admin.user.vo.user.UserPageReqVO; import com.chanko.yunxi.mes.module.system.controller.admin.user.vo.user.UserPageReqVO;
import com.chanko.yunxi.mes.module.system.dal.dataobject.dept.DeptDO;
import com.chanko.yunxi.mes.module.system.dal.dataobject.user.AdminUserDO; import com.chanko.yunxi.mes.module.system.dal.dataobject.user.AdminUserDO;
import com.github.yulichang.wrapper.MPJLambdaWrapper; import com.github.yulichang.wrapper.MPJLambdaWrapper;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
@ -30,17 +32,27 @@ public interface AdminUserMapper extends BaseMapperX<AdminUserDO> {
} }
default PageResult<AdminUserDO> selectPage(UserPageReqVO reqVO, Collection<Long> deptIds) { default PageResult<AdminUserDO> selectPage(UserPageReqVO reqVO, Collection<Long> deptIds) {
LambdaQueryWrapperX<AdminUserDO> query = new LambdaQueryWrapperX<AdminUserDO>() // LambdaQueryWrapperX<AdminUserDO> query = new LambdaQueryWrapperX<AdminUserDO>()
.likeIfPresent(AdminUserDO::getUsername, reqVO.getUsername()) // .likeIfPresent(AdminUserDO::getUsername, reqVO.getUsername())
.likeIfPresent(AdminUserDO::getNickname, reqVO.getNickname()) // .likeIfPresent(AdminUserDO::getNickname, reqVO.getNickname())
.likeIfPresent(AdminUserDO::getMobile, reqVO.getMobile()) // .likeIfPresent(AdminUserDO::getMobile, reqVO.getMobile())
.eqIfPresent(AdminUserDO::getStatus, reqVO.getStatus()) // .eqIfPresent(AdminUserDO::getStatus, reqVO.getStatus())
.betweenIfPresent(AdminUserDO::getCreateTime, reqVO.getCreateTime()) // .betweenIfPresent(AdminUserDO::getCreateTime, reqVO.getCreateTime())
.inIfPresent(AdminUserDO::getDeptId, deptIds) // .inIfPresent(AdminUserDO::getDeptId, deptIds)
// .orderByDesc(AdminUserDO::getId);
// if(!StringUtils.isEmpty(reqVO.getUserNickName())){
// query.and(QueryWrapper -> QueryWrapper.like(AdminUserDO::getUsername, reqVO.getUserNickName()).or().like(AdminUserDO::getNickname, reqVO.getUserNickName()));
// }
// return selectPage(reqVO, query);
MPJLambdaWrapper<AdminUserDO> query = new MPJLambdaWrapper<>();
query.selectAll(AdminUserDO.class)
.select("d.name as deptName")
.leftJoin(DeptDO.class, "d", DeptDO::getId, AdminUserDO::getDeptId)
.disableSubLogicDel()
.orderByDesc(AdminUserDO::getId); .orderByDesc(AdminUserDO::getId);
if(!StringUtils.isEmpty(reqVO.getUserNickName())){ query.apply(!StringUtils.isEmpty(reqVO.getUserNickName()), "(t.nickname like {0} or t.username like {0})","%"+ reqVO.getUserNickName()+"%")
query.and(QueryWrapper -> QueryWrapper.like(AdminUserDO::getUsername, reqVO.getUserNickName()).or().like(AdminUserDO::getNickname, reqVO.getUserNickName())); .in(CollUtil.isNotEmpty(deptIds), AdminUserDO::getDeptId, deptIds)
} ;
return selectPage(reqVO, query); return selectPage(reqVO, query);
} }

Loading…
Cancel
Save