feat(smartfactory): 新增搬运组工资记录按月查询功能- 新增 HandlingGroupUserAmountMonthVO 和 HandlingGroupUserAmountMonthItemVO 类用于按月查询结果- 在 HandlingGroupUserAmountService 中添加 getListByMonth 方法实现按月查询功能
- 在 HandlingGroupUserAmountMapper 中添加 getListByMonth 方法用于获取按月查询数据 - 优化了数据处理逻辑,通过 Map 结构组织按月查询结果
This commit is contained in:
parent
95120fe0f3
commit
346716c3ff
@ -65,6 +65,14 @@ public class DeptController {
|
||||
return success(list);
|
||||
}
|
||||
|
||||
@GetMapping("/getFactoryDeptListByLeaderUserId")
|
||||
@Operation(summary = "获取当前用户所负责的工厂部门列表")
|
||||
public CommonResult<List<DeptDO>> getFactoryDeptListByLeaderUserId() {
|
||||
Long id = getLoginUserId();
|
||||
List<DeptDO> list = deptService.getFactoryDeptByLeaderId(id);
|
||||
return success(list);
|
||||
}
|
||||
|
||||
@PutMapping("update")
|
||||
@Operation(summary = "更新部门")
|
||||
@PreAuthorize("@ss.hasPermission('system:dept:update')")
|
||||
|
@ -187,6 +187,7 @@ public interface DeptService {
|
||||
|
||||
/**
|
||||
* 获取指定类型的部门列表
|
||||
*
|
||||
* @param type 部门类型
|
||||
* @return 部门列表
|
||||
*/
|
||||
@ -194,7 +195,16 @@ public interface DeptService {
|
||||
|
||||
/**
|
||||
* 获取工厂部门
|
||||
*
|
||||
* @return 部门列表
|
||||
*/
|
||||
List<DeptDO> getFactoryDept();
|
||||
|
||||
/**
|
||||
* 获取当前登录用户负责的工厂部门
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
List<DeptDO> getFactoryDeptByLeaderId(Long id);
|
||||
}
|
||||
|
@ -404,6 +404,14 @@ public class DeptServiceImpl implements DeptService {
|
||||
.isNotNull(DeptDO::getFactoryId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DeptDO> getFactoryDeptByLeaderId(Long id) {
|
||||
return deptMapper.selectList(new LambdaQueryWrapperX<DeptDO>()
|
||||
.eq(DeptDO::getLeaderUserId, id)
|
||||
.eq(DeptDO::getStatus, CommonStatusEnum.ENABLE.getStatus())
|
||||
.isNotNull(DeptDO::getFactoryId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DeptDO> getDeptList(DeptApiDTO dto) {
|
||||
List<DeptDO> list = deptMapper.selectList(new LambdaQueryWrapperX<DeptDO>()
|
||||
|
@ -6,6 +6,7 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||
import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
|
||||
import cn.iocoder.yudao.module.smartfactory.controller.admin.handlinggroupamountspecifications.vo.HandlingGroupAmountSpecificationsBatchCreateVO;
|
||||
import cn.iocoder.yudao.module.smartfactory.controller.admin.handlinggroupamountspecifications.vo.HandlingGroupAmountSpecificationsPageReqVO;
|
||||
import cn.iocoder.yudao.module.smartfactory.controller.admin.handlinggroupamountspecifications.vo.HandlingGroupAmountSpecificationsRespVO;
|
||||
import cn.iocoder.yudao.module.smartfactory.controller.admin.handlinggroupamountspecifications.vo.HandlingGroupAmountSpecificationsSaveReqVO;
|
||||
@ -36,11 +37,20 @@ public class HandlingGroupAmountSpecificationsController {
|
||||
@Resource
|
||||
private HandlingGroupAmountSpecificationsService handlingGroupAmountSpecificationsService;
|
||||
|
||||
@PostMapping("/createOrEdit")
|
||||
@PostMapping("/batchCreate")
|
||||
@Operation(summary = "创建搬运组工资规格关联")
|
||||
@PreAuthorize("@ss.hasPermission('smartfactory:handling-group-amount-specifications:create')")
|
||||
public CommonResult<Boolean> createOrEdit(@Valid @RequestBody HandlingGroupAmountSpecificationsSaveReqVO createReqVO) {
|
||||
handlingGroupAmountSpecificationsService.createOrEdit(createReqVO);
|
||||
public CommonResult<Boolean> batchCreate(@Valid @RequestBody HandlingGroupAmountSpecificationsBatchCreateVO vo) {
|
||||
handlingGroupAmountSpecificationsService.batchCreate(vo);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/update")
|
||||
@Operation(summary = "更新搬运组工资规格关联")
|
||||
@PreAuthorize("@ss.hasPermission('smartfactory:handling-group-amount-specifications:update')")
|
||||
public CommonResult<Boolean> update(@Valid @RequestBody HandlingGroupAmountSpecificationsSaveReqVO createReqVO) {
|
||||
handlingGroupAmountSpecificationsService.updateHandlingGroupAmountSpecifications(createReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,20 @@
|
||||
package cn.iocoder.yudao.module.smartfactory.controller.admin.handlinggroupamountspecifications.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@Data
|
||||
public class HandlingGroupAmountSpecificationsBatchCreateItemVO {
|
||||
|
||||
@Schema(description = "搬运规格id", example = "23178")
|
||||
@NotNull(message = "搬运规格不能为空")
|
||||
private Long handlingSpecificationsId;
|
||||
|
||||
@Schema(description = "数量", example = "15611")
|
||||
@NotNull(message = "数量不能为空")
|
||||
private Integer totalCount;
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
package cn.iocoder.yudao.module.smartfactory.controller.admin.handlinggroupamountspecifications.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class HandlingGroupAmountSpecificationsBatchCreateVO {
|
||||
@Schema(description = "工厂id", example = "23178")
|
||||
private Long factoryId;
|
||||
|
||||
@Schema(description = "日期 格式 yyyy-MM-dd")
|
||||
@NotNull(message = "日期不能为空")
|
||||
private String dateStr;
|
||||
|
||||
@Schema(description = "子列表")
|
||||
private List<HandlingGroupAmountSpecificationsBatchCreateItemVO> itemVOS;
|
||||
}
|
@ -18,6 +18,9 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_
|
||||
@ToString(callSuper = true)
|
||||
public class HandlingGroupAmountSpecificationsPageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "工厂id", example = "23178")
|
||||
private Long factoryId;
|
||||
|
||||
@Schema(description = "搬运规格id", example = "23178")
|
||||
private Long handlingSpecificationsId;
|
||||
|
||||
|
@ -17,6 +17,9 @@ public class HandlingGroupAmountSpecificationsRespVO {
|
||||
@ExcelProperty("主键id")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "工厂id", example = "23178")
|
||||
private Long factoryId;
|
||||
|
||||
@Schema(description = "搬运规格id", example = "23178")
|
||||
@ExcelProperty("搬运规格id")
|
||||
private Long handlingSpecificationsId;
|
||||
|
@ -12,6 +12,9 @@ public class HandlingGroupAmountSpecificationsSaveReqVO {
|
||||
@Schema(description = "主键id", requiredMode = Schema.RequiredMode.REQUIRED, example = "9721")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "工厂id", example = "23178")
|
||||
private Long factoryId;
|
||||
|
||||
@Schema(description = "搬运规格id", example = "23178")
|
||||
@NotNull(message = "搬运规格不能为空")
|
||||
private Long handlingSpecificationsId;
|
||||
|
@ -1,34 +1,29 @@
|
||||
package cn.iocoder.yudao.module.smartfactory.controller.admin.handlinggroupuseramount;
|
||||
|
||||
import cn.iocoder.yudao.module.smartfactory.controller.admin.handlinggroupuseramount.dto.StaffWagesPageDTO;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.*;
|
||||
import javax.servlet.http.*;
|
||||
import java.util.*;
|
||||
import java.io.IOException;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
|
||||
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||
|
||||
import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
|
||||
import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*;
|
||||
|
||||
import cn.iocoder.yudao.module.smartfactory.controller.admin.handlinggroupuseramount.dto.StaffWagesPageDTO;
|
||||
import cn.iocoder.yudao.module.smartfactory.controller.admin.handlinggroupuseramount.vo.*;
|
||||
import cn.iocoder.yudao.module.smartfactory.dal.dataobject.handlinggroupuseramount.HandlingGroupUserAmountDO;
|
||||
import cn.iocoder.yudao.module.smartfactory.service.handlinggroupuseramount.HandlingGroupUserAmountService;
|
||||
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.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.Valid;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT;
|
||||
|
||||
@Tag(name = "管理后台 - 搬运组每日个人工资记录")
|
||||
@RestController
|
||||
@ -41,7 +36,6 @@ public class HandlingGroupUserAmountController {
|
||||
|
||||
@PostMapping("/createOrEdit")
|
||||
@Operation(summary = "创建搬运组每日个人工资记录")
|
||||
@PreAuthorize("@ss.hasPermission('smartfactory:handling-group-user-amount:create')")
|
||||
public CommonResult<Boolean> createOrEdit(@Valid @RequestBody HandlingGroupUserAmountSaveReqVO createReqVO) {
|
||||
handlingGroupUserAmountService.createOrEdit(createReqVO);
|
||||
return success(true);
|
||||
@ -49,7 +43,6 @@ public class HandlingGroupUserAmountController {
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新搬运组每日个人工资记录")
|
||||
@PreAuthorize("@ss.hasPermission('smartfactory:handling-group-user-amount:update')")
|
||||
public CommonResult<Boolean> updateHandlingGroupUserAmount(@Valid @RequestBody HandlingGroupUserAmountSaveReqVO updateReqVO) {
|
||||
handlingGroupUserAmountService.updateHandlingGroupUserAmount(updateReqVO);
|
||||
return success(true);
|
||||
@ -58,7 +51,6 @@ public class HandlingGroupUserAmountController {
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除搬运组每日个人工资记录")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('smartfactory:handling-group-user-amount:delete')")
|
||||
public CommonResult<Boolean> deleteHandlingGroupUserAmount(@RequestParam("id") Long id) {
|
||||
handlingGroupUserAmountService.deleteHandlingGroupUserAmount(id);
|
||||
return success(true);
|
||||
@ -67,15 +59,24 @@ public class HandlingGroupUserAmountController {
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得搬运组每日个人工资记录")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('smartfactory:handling-group-user-amount:query')")
|
||||
public CommonResult<HandlingGroupUserAmountRespVO> getHandlingGroupUserAmount(@RequestParam("id") Long id) {
|
||||
HandlingGroupUserAmountDO handlingGroupUserAmount = handlingGroupUserAmountService.getHandlingGroupUserAmount(id);
|
||||
return success(BeanUtils.toBean(handlingGroupUserAmount, HandlingGroupUserAmountRespVO.class));
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/getListByMonth")
|
||||
@Operation(summary = "获得搬运组工资记录 按月搜索")
|
||||
@Parameter(name = "time", description = "日期 格式(yyyy-MM) 默认当前月", required = true, example = "1024")
|
||||
public CommonResult<HandlingGroupUserAmountMonthVO> getListByMonth(@RequestParam(value = "name", required = false) String name,
|
||||
@RequestParam(value = "time", required = true) String time,
|
||||
@RequestParam(value = "factoryId", required = false) Long factoryId) {
|
||||
HandlingGroupUserAmountMonthVO vo = handlingGroupUserAmountService.getListByMonth(factoryId, time, name);
|
||||
return success(vo);
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得搬运组每日个人工资记录分页")
|
||||
@PreAuthorize("@ss.hasPermission('smartfactory:handling-group-user-amount:query')")
|
||||
public CommonResult<PageResult<HandlingGroupUserAmountRespVO>> getHandlingGroupUserAmountPage(@Valid HandlingGroupUserAmountPageReqVO pageReqVO) {
|
||||
PageResult<HandlingGroupUserAmountDO> pageResult = handlingGroupUserAmountService.getHandlingGroupUserAmountPage(pageReqVO);
|
||||
return success(BeanUtils.toBean(pageResult, HandlingGroupUserAmountRespVO.class));
|
||||
@ -90,7 +91,6 @@ public class HandlingGroupUserAmountController {
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@Operation(summary = "导出搬运组每日个人工资记录 Excel")
|
||||
@PreAuthorize("@ss.hasPermission('smartfactory:handling-group-user-amount:export')")
|
||||
@OperateLog(type = EXPORT)
|
||||
public void exportHandlingGroupUserAmountExcel(@Valid HandlingGroupUserAmountPageReqVO pageReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
|
@ -0,0 +1,17 @@
|
||||
package cn.iocoder.yudao.module.smartfactory.controller.admin.handlinggroupuseramount.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Data
|
||||
public class HandlingGroupUserAmountMonthItemVO {
|
||||
@Schema(description = "用户id", example = "15129")
|
||||
private Long userId;
|
||||
|
||||
@Schema(description = "列表", example = "22544")
|
||||
private List<Map<Integer,String>> contentList;
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
package cn.iocoder.yudao.module.smartfactory.controller.admin.handlinggroupuseramount.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Data
|
||||
public class HandlingGroupUserAmountMonthVO {
|
||||
@Schema(description = "表头")
|
||||
private Map<Integer,String> headers;
|
||||
|
||||
@Schema(description = "列表值")
|
||||
private List<HandlingGroupUserAmountMonthItemVO> list;
|
||||
}
|
@ -17,6 +17,9 @@ public class HandlingGroupUserAmountSaveReqVO {
|
||||
@Schema(description = "用户id", example = "12639")
|
||||
private Long userId;
|
||||
|
||||
@Schema(description = "工厂id", example = "12639")
|
||||
private Long factoryId;
|
||||
|
||||
@Schema(description = "搬运组工资规格关联id", example = "27617")
|
||||
private Long handlingGroupAmountSpecificationsId;
|
||||
|
||||
|
@ -31,6 +31,10 @@ public class HandlingGroupAmountSpecificationsDO extends BaseDO {
|
||||
*/
|
||||
@TableId
|
||||
private Long id;
|
||||
/**
|
||||
* 工厂id
|
||||
*/
|
||||
private Long factoryId;
|
||||
/**
|
||||
* 搬运规格id
|
||||
*/
|
||||
|
@ -44,6 +44,10 @@ public class HandlingGroupUserAmountDO extends BaseDO {
|
||||
* 搬运组工资规格关联id
|
||||
*/
|
||||
private Long handlingGroupAmountSpecificationsId;
|
||||
/**
|
||||
* 工厂id
|
||||
*/
|
||||
private Long factoryId;
|
||||
/**
|
||||
* 日期 格式 yyyy-MM-dd
|
||||
*/
|
||||
|
@ -12,6 +12,10 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
|
||||
/**
|
||||
* 搬运组每日个人工资记录 Mapper
|
||||
*
|
||||
@ -45,4 +49,13 @@ public interface HandlingGroupUserAmountMapper extends BaseMapperX<HandlingGroup
|
||||
* @return
|
||||
*/
|
||||
IPage<StaffWagesPageVO> staffWagesPage(@Param("page") Page page, @Param("dto") StaffWagesPageDTO dto);
|
||||
|
||||
/**
|
||||
* 获取月工资列表
|
||||
* @param factoryId
|
||||
* @param dateList
|
||||
* @param name
|
||||
* @return
|
||||
*/
|
||||
List<Map<String, Object>> getListByMonth(@Param("factoryId") Long factoryId, @Param("dateList") List<String> dateList, @Param("name") String name);
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package cn.iocoder.yudao.module.smartfactory.service.handlinggroupamountspecifications;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.smartfactory.controller.admin.handlinggroupamountspecifications.vo.HandlingGroupAmountSpecificationsBatchCreateVO;
|
||||
import cn.iocoder.yudao.module.smartfactory.controller.admin.handlinggroupamountspecifications.vo.HandlingGroupAmountSpecificationsPageReqVO;
|
||||
import cn.iocoder.yudao.module.smartfactory.controller.admin.handlinggroupamountspecifications.vo.HandlingGroupAmountSpecificationsSaveReqVO;
|
||||
import cn.iocoder.yudao.module.smartfactory.dal.dataobject.handlinggroupamountspecifications.HandlingGroupAmountSpecificationsDO;
|
||||
@ -58,4 +59,10 @@ public interface HandlingGroupAmountSpecificationsService {
|
||||
* @param createReqVO
|
||||
*/
|
||||
void createOrEdit(@Valid HandlingGroupAmountSpecificationsSaveReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 批量新增
|
||||
* @param vo
|
||||
*/
|
||||
void batchCreate(@Valid HandlingGroupAmountSpecificationsBatchCreateVO vo);
|
||||
}
|
||||
|
@ -3,12 +3,15 @@ package cn.iocoder.yudao.module.smartfactory.service.handlinggroupamountspecific
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.util.MyBatisUtils;
|
||||
import cn.iocoder.yudao.module.smartfactory.controller.admin.handlinggroupamountspecifications.vo.HandlingGroupAmountSpecificationsBatchCreateItemVO;
|
||||
import cn.iocoder.yudao.module.smartfactory.controller.admin.handlinggroupamountspecifications.vo.HandlingGroupAmountSpecificationsBatchCreateVO;
|
||||
import cn.iocoder.yudao.module.smartfactory.controller.admin.handlinggroupamountspecifications.vo.HandlingGroupAmountSpecificationsPageReqVO;
|
||||
import cn.iocoder.yudao.module.smartfactory.controller.admin.handlinggroupamountspecifications.vo.HandlingGroupAmountSpecificationsSaveReqVO;
|
||||
import cn.iocoder.yudao.module.smartfactory.dal.dataobject.handlinggroupamountspecifications.HandlingGroupAmountSpecificationsDO;
|
||||
import cn.iocoder.yudao.module.smartfactory.dal.dataobject.handlingspecifications.HandlingSpecificationsDO;
|
||||
import cn.iocoder.yudao.module.smartfactory.dal.mysql.handlinggroupamountspecifications.HandlingGroupAmountSpecificationsMapper;
|
||||
import cn.iocoder.yudao.module.smartfactory.service.handlingspecifications.HandlingSpecificationsService;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@ -16,6 +19,10 @@ import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.module.smartfactory.enums.ErrorCodeConstants.CANNOT_FIND_THE_CORRESPONDING_FACTORY_HANDLING_SPECIFICATION;
|
||||
@ -49,6 +56,20 @@ public class HandlingGroupAmountSpecificationsServiceImpl implements HandlingGro
|
||||
public void updateHandlingGroupAmountSpecifications(HandlingGroupAmountSpecificationsSaveReqVO updateReqVO) {
|
||||
// 更新
|
||||
HandlingGroupAmountSpecificationsDO updateObj = BeanUtils.toBean(updateReqVO, HandlingGroupAmountSpecificationsDO.class);
|
||||
HandlingSpecificationsDO handlingSpecificationsDO = handlingSpecificationsService.getById(updateObj.getHandlingSpecificationsId());
|
||||
if (handlingSpecificationsDO == null) {
|
||||
throw exception(CANNOT_FIND_THE_CORRESPONDING_FACTORY_HANDLING_SPECIFICATION);
|
||||
}
|
||||
BigDecimal totalAmount;
|
||||
if (handlingSpecificationsDO.getType() == 0) {
|
||||
totalAmount = new BigDecimal(updateReqVO.getTotalCount().toString()).multiply(handlingSpecificationsDO.getUnitPrice());
|
||||
} else {
|
||||
totalAmount = new BigDecimal(updateReqVO.getTotalCount().toString()).multiply(handlingSpecificationsDO.getWeight())
|
||||
.multiply(handlingSpecificationsDO.getUnitPrice().multiply(THOUSANDTH));
|
||||
}
|
||||
// 插入
|
||||
HandlingGroupAmountSpecificationsDO handlingGroupAmountSpecifications = BeanUtils.toBean(updateReqVO, HandlingGroupAmountSpecificationsDO.class);
|
||||
handlingGroupAmountSpecifications.setAmount(totalAmount);
|
||||
handlingGroupAmountSpecificationsMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
@ -90,4 +111,33 @@ public class HandlingGroupAmountSpecificationsServiceImpl implements HandlingGro
|
||||
handlingGroupAmountSpecificationsMapper.insertOrUpdate(handlingGroupAmountSpecifications);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void batchCreate(HandlingGroupAmountSpecificationsBatchCreateVO vo) {
|
||||
List<HandlingGroupAmountSpecificationsDO> list = new ArrayList<>();
|
||||
List<Long> handlingSpecificationsIds = vo.getItemVOS().stream().map(HandlingGroupAmountSpecificationsBatchCreateItemVO::getHandlingSpecificationsId).collect(Collectors.toList());
|
||||
List<HandlingSpecificationsDO> handlingSpecificationsDOS = handlingSpecificationsService.list(new LambdaQueryWrapper<HandlingSpecificationsDO>()
|
||||
.in(HandlingSpecificationsDO::getId, handlingSpecificationsIds));
|
||||
Map<Long, HandlingSpecificationsDO> map = handlingSpecificationsDOS.stream().collect(Collectors.toMap(HandlingSpecificationsDO::getId, item -> item));
|
||||
for (HandlingGroupAmountSpecificationsBatchCreateItemVO itemVO : vo.getItemVOS()) {
|
||||
HandlingGroupAmountSpecificationsDO handlingGroupAmountSpecificationsDO = new HandlingGroupAmountSpecificationsDO();
|
||||
BigDecimal totalAmount;
|
||||
HandlingSpecificationsDO handlingSpecificationsDO = map.get(itemVO.getHandlingSpecificationsId());
|
||||
if (handlingSpecificationsDO == null) {
|
||||
continue;
|
||||
}
|
||||
if (handlingSpecificationsDO.getType() == 0) {
|
||||
totalAmount = new BigDecimal(itemVO.getTotalCount().toString()).multiply(handlingSpecificationsDO.getUnitPrice());
|
||||
} else {
|
||||
totalAmount = new BigDecimal(itemVO.getTotalCount().toString()).multiply(handlingSpecificationsDO.getWeight())
|
||||
.multiply(handlingSpecificationsDO.getUnitPrice().multiply(THOUSANDTH));
|
||||
}
|
||||
handlingGroupAmountSpecificationsDO.setFactoryId(vo.getFactoryId());
|
||||
handlingGroupAmountSpecificationsDO.setDateStr(vo.getDateStr());
|
||||
handlingGroupAmountSpecificationsDO.setHandlingSpecificationsId(itemVO.getHandlingSpecificationsId());
|
||||
handlingGroupAmountSpecificationsDO.setAmount(totalAmount);
|
||||
handlingGroupAmountSpecificationsDO.setTotalCount(itemVO.getTotalCount());
|
||||
list.add(handlingGroupAmountSpecificationsDO);
|
||||
}
|
||||
handlingGroupAmountSpecificationsMapper.insertBatch(list);
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.smartfactory.service.handlinggroupuseramount;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.smartfactory.controller.admin.handlinggroupuseramount.dto.StaffWagesPageDTO;
|
||||
import cn.iocoder.yudao.module.smartfactory.controller.admin.handlinggroupuseramount.vo.HandlingGroupUserAmountMonthVO;
|
||||
import cn.iocoder.yudao.module.smartfactory.controller.admin.handlinggroupuseramount.vo.HandlingGroupUserAmountPageReqVO;
|
||||
import cn.iocoder.yudao.module.smartfactory.controller.admin.handlinggroupuseramount.vo.HandlingGroupUserAmountSaveReqVO;
|
||||
import cn.iocoder.yudao.module.smartfactory.controller.admin.handlinggroupuseramount.vo.StaffWagesPageVO;
|
||||
@ -68,4 +69,14 @@ public interface HandlingGroupUserAmountService {
|
||||
* @return
|
||||
*/
|
||||
PageResult<StaffWagesPageVO> staffWagesPage(@Valid StaffWagesPageDTO dto);
|
||||
|
||||
/**
|
||||
* 获得搬运组工资记录 按月搜索
|
||||
*
|
||||
* @param factoryId
|
||||
* @param time
|
||||
* @param name
|
||||
* @return
|
||||
*/
|
||||
HandlingGroupUserAmountMonthVO getListByMonth(Long factoryId, String time, String name);
|
||||
}
|
||||
|
@ -1,14 +1,14 @@
|
||||
package cn.iocoder.yudao.module.smartfactory.service.handlinggroupuseramount;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.date.DateUtils;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.util.MyBatisUtils;
|
||||
import cn.iocoder.yudao.module.smartfactory.controller.admin.handlinggroupuseramount.dto.StaffWagesPageDTO;
|
||||
import cn.iocoder.yudao.module.smartfactory.controller.admin.handlinggroupuseramount.vo.HandlingGroupUserAmountPageReqVO;
|
||||
import cn.iocoder.yudao.module.smartfactory.controller.admin.handlinggroupuseramount.vo.HandlingGroupUserAmountSaveReqVO;
|
||||
import cn.iocoder.yudao.module.smartfactory.controller.admin.handlinggroupuseramount.vo.StaffWagesPageVO;
|
||||
import cn.iocoder.yudao.module.smartfactory.controller.admin.handlinggroupuseramount.vo.*;
|
||||
import cn.iocoder.yudao.module.smartfactory.dal.dataobject.handlinggroupamountspecifications.HandlingGroupAmountSpecificationsDO;
|
||||
import cn.iocoder.yudao.module.smartfactory.dal.dataobject.handlinggroupuseramount.HandlingGroupUserAmountDO;
|
||||
import cn.iocoder.yudao.module.smartfactory.dal.dataobject.handlingspecifications.HandlingSpecificationsDO;
|
||||
import cn.iocoder.yudao.module.smartfactory.dal.mysql.handlinggroupamountspecifications.HandlingGroupAmountSpecificationsMapper;
|
||||
import cn.iocoder.yudao.module.smartfactory.dal.mysql.handlinggroupuseramount.HandlingGroupUserAmountMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import org.springframework.stereotype.Service;
|
||||
@ -16,6 +16,8 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 搬运组每日个人工资记录 Service 实现类
|
||||
@ -28,6 +30,10 @@ public class HandlingGroupUserAmountServiceImpl implements HandlingGroupUserAmou
|
||||
|
||||
@Resource
|
||||
private HandlingGroupUserAmountMapper handlingGroupUserAmountMapper;
|
||||
@Resource
|
||||
private HandlingGroupAmountSpecificationsMapper handlingGroupAmountSpecificationsMapper;
|
||||
private static final String NAME = "姓名";
|
||||
private static final String TOTAL_AMOUNT = "总金额";
|
||||
|
||||
@Override
|
||||
public Long createHandlingGroupUserAmount(HandlingGroupUserAmountSaveReqVO createReqVO) {
|
||||
@ -65,7 +71,9 @@ public class HandlingGroupUserAmountServiceImpl implements HandlingGroupUserAmou
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void createOrEdit(HandlingGroupUserAmountSaveReqVO createReqVO) {
|
||||
HandlingGroupAmountSpecificationsDO handlingGroupAmountSpecificationsDO = handlingGroupAmountSpecificationsMapper.selectById(createReqVO.getHandlingGroupAmountSpecificationsId());
|
||||
// 插入
|
||||
createReqVO.setFactoryId(handlingGroupAmountSpecificationsDO.getFactoryId());
|
||||
HandlingGroupUserAmountDO handlingGroupUserAmount = BeanUtils.toBean(createReqVO, HandlingGroupUserAmountDO.class);
|
||||
handlingGroupUserAmountMapper.insertOrUpdate(handlingGroupUserAmount);
|
||||
}
|
||||
@ -76,4 +84,46 @@ public class HandlingGroupUserAmountServiceImpl implements HandlingGroupUserAmou
|
||||
return new PageResult<>(page.getRecords(), page.getTotal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlingGroupUserAmountMonthVO getListByMonth(Long factoryId, String time, String name) {
|
||||
HandlingGroupUserAmountMonthVO vo = new HandlingGroupUserAmountMonthVO();
|
||||
Map<Integer, String> headers = new HashMap<>();
|
||||
// -- 根据yyyy-MM获取到该月第一天时间 - 再获取到最后一天 - 完了后组装表头
|
||||
String[] times = time.split("-");
|
||||
LocalDateTime startTime = LocalDateTime.of(Integer.parseInt(times[0]), Integer.parseInt(times[1]), 1, 0, 0, 0);
|
||||
LocalDateTime endTime = startTime.plusMonths(1).minusDays(1);
|
||||
List<String> dateList = DateUtils.betweenDayList(startTime, endTime);
|
||||
headers.put(1, NAME);
|
||||
int num = 1;
|
||||
for (String date : dateList) {
|
||||
num++;
|
||||
headers.put(num, date);
|
||||
}
|
||||
headers.put(num + 1, TOTAL_AMOUNT);
|
||||
// - 插入表头
|
||||
vo.setHeaders(headers);
|
||||
|
||||
List<Map<String, Object>> map = handlingGroupUserAmountMapper.getListByMonth(factoryId, dateList, name);
|
||||
List<HandlingGroupUserAmountMonthItemVO> list = new ArrayList<>();
|
||||
List<Map<Integer, String>> contentList = new ArrayList<>();
|
||||
for (Map<String, Object> item : map) {
|
||||
HandlingGroupUserAmountMonthItemVO itemVO = new HandlingGroupUserAmountMonthItemVO();
|
||||
itemVO.setUserId((Long) item.get("userId"));
|
||||
Map<Integer, String> itemMap = new HashMap<>();
|
||||
itemMap.put(1, item.get("nickName").toString());
|
||||
num = 1;
|
||||
for (String date : dateList) {
|
||||
num++;
|
||||
itemMap.put(num, item.get(date).toString());
|
||||
}
|
||||
itemMap.put(num + 1, item.get("totalAmount").toString());
|
||||
contentList.add(itemMap);
|
||||
itemVO.setContentList(contentList);
|
||||
list.add(itemVO);
|
||||
}
|
||||
vo.setList(list);
|
||||
return vo;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -71,4 +71,28 @@
|
||||
</where>
|
||||
group by a.id
|
||||
</select>
|
||||
<select id="getListByMonth" resultType="java.util.Map">
|
||||
SELECT
|
||||
a.user_id as userId,
|
||||
b.nick_name as nickName,
|
||||
<foreach collection="dateList" item="date" separator=",">
|
||||
SUM(CASE WHEN a.date_str = #{date} THEN a.amount ELSE 0 END) AS `${date}`
|
||||
</foreach>,
|
||||
-- 继续添加该月所有日期...
|
||||
SUM(a.amount) AS totalAmount
|
||||
FROM
|
||||
sf_handling_group_user_amount as a
|
||||
left join sf_staff as b on a.user_id = b.id
|
||||
<where>
|
||||
a.deleted = 0
|
||||
<if test="factoryId != null">
|
||||
and a.factory_id = #{factoryId}
|
||||
</if>
|
||||
<if test="name != null and name != ''">
|
||||
and b.nick_name like concat('%', #{name}, '%')
|
||||
</if>
|
||||
</where>
|
||||
GROUP BY
|
||||
a.user_id;
|
||||
</select>
|
||||
</mapper>
|
||||
|
Loading…
Reference in New Issue
Block a user