feat(smartfactory): 新增搬运组相关功能

- 添加搬运组列表、分页、新增、修改、删除等接口
- 实现搬运组相关数据结构和持久化
- 优化搬运组工资规格关联相关功能,支持批量操作和合计数计算
- 更新员工列表接口,增加工作类型筛选功能
This commit is contained in:
aikai 2025-05-16 11:59:11 +08:00
parent 1aeef763b6
commit 8aef773086
29 changed files with 791 additions and 159 deletions

View File

@ -0,0 +1,95 @@
package cn.iocoder.yudao.module.smartfactory.controller.admin.handlinggroup;
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.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.handlinggroup.vo.HandlingGroupPageReqVO;
import cn.iocoder.yudao.module.smartfactory.controller.admin.handlinggroup.vo.HandlingGroupRespVO;
import cn.iocoder.yudao.module.smartfactory.controller.admin.handlinggroup.vo.HandlingGroupSaveReqVO;
import cn.iocoder.yudao.module.smartfactory.dal.dataobject.handlinggroup.HandlingGroupDO;
import cn.iocoder.yudao.module.smartfactory.service.handlinggroup.HandlingGroupService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
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.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
@RequestMapping("/smartfactory/handling-group")
@Validated
public class HandlingGroupController {
@Resource
private HandlingGroupService handlingGroupService;
@PostMapping("/create")
@Operation(summary = "创建搬运组")
public CommonResult<Long> createHandlingGroup(@Valid @RequestBody HandlingGroupSaveReqVO createReqVO) {
return success(handlingGroupService.createHandlingGroup(createReqVO));
}
@PutMapping("/update")
@Operation(summary = "更新搬运组")
public CommonResult<Boolean> updateHandlingGroup(@Valid @RequestBody HandlingGroupSaveReqVO updateReqVO) {
handlingGroupService.updateHandlingGroup(updateReqVO);
return success(true);
}
@DeleteMapping("/delete")
@Operation(summary = "删除搬运组")
@Parameter(name = "id", description = "编号", required = true)
public CommonResult<Boolean> deleteHandlingGroup(@RequestParam("id") Long id) {
handlingGroupService.deleteHandlingGroup(id);
return success(true);
}
@GetMapping("/get")
@Operation(summary = "获得搬运组")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
public CommonResult<HandlingGroupRespVO> getHandlingGroup(@RequestParam("id") Long id) {
HandlingGroupDO handlingGroup = handlingGroupService.getHandlingGroup(id);
return success(BeanUtils.toBean(handlingGroup, HandlingGroupRespVO.class));
}
@GetMapping("/getAllByFactoryId")
@Operation(summary = "根据工程id获得搬运组列表")
public CommonResult<List<HandlingGroupRespVO>> getAllByFactoryId(@RequestParam("factoryId") Long factoryId) {
List<HandlingGroupDO> list = handlingGroupService.list(new LambdaQueryWrapper<HandlingGroupDO>().eq(HandlingGroupDO::getFactoryId, factoryId));
return success(BeanUtils.toBean(list, HandlingGroupRespVO.class));
}
@GetMapping("/page")
@Operation(summary = "获得搬运组分页")
public CommonResult<PageResult<HandlingGroupRespVO>> getHandlingGroupPage(@Valid HandlingGroupPageReqVO pageReqVO) {
PageResult<HandlingGroupDO> pageResult = handlingGroupService.getHandlingGroupPage(pageReqVO);
return success(BeanUtils.toBean(pageResult, HandlingGroupRespVO.class));
}
@GetMapping("/export-excel")
@Operation(summary = "导出搬运组 Excel")
@OperateLog(type = EXPORT)
public void exportHandlingGroupExcel(@Valid HandlingGroupPageReqVO pageReqVO,
HttpServletResponse response) throws IOException {
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
List<HandlingGroupDO> list = handlingGroupService.getHandlingGroupPage(pageReqVO).getList();
// 导出 Excel
ExcelUtils.write(response, "搬运组.xls", "数据", HandlingGroupRespVO.class,
BeanUtils.toBean(list, HandlingGroupRespVO.class));
}
}

View File

@ -0,0 +1,21 @@
package cn.iocoder.yudao.module.smartfactory.controller.admin.handlinggroup.vo;
import cn.iocoder.yudao.module.smartfactory.controller.admin.handlinggroupamountspecifications.vo.HandlingGroupAmountSpecificationsBatchCreateItemVO;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.util.List;
@Data
@ExcelIgnoreUnannotated
public class HandlingGroupListVO {
@Schema(description = "搬运组id", example = "27617")
private Long handlingGroupId;
@Schema(description = "叉车司机id", example = "27617")
private Long staffId;
@Schema(description = "规格/数量列表")
private List<HandlingGroupAmountSpecificationsBatchCreateItemVO> itemList;
}

View File

@ -0,0 +1,28 @@
package cn.iocoder.yudao.module.smartfactory.controller.admin.handlinggroup.vo;
import lombok.*;
import java.util.*;
import io.swagger.v3.oas.annotations.media.Schema;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
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 HandlingGroupPageReqVO extends PageParam {
@Schema(description = "工厂id", example = "5268")
private Long factoryId;
@Schema(description = "搬运组名称", example = "芋艿")
private String handlingGroupName;
@Schema(description = "创建时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] createTime;
}

View File

@ -0,0 +1,35 @@
package cn.iocoder.yudao.module.smartfactory.controller.admin.handlinggroup.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.time.LocalDateTime;
@Schema(description = "管理后台 - 搬运组 Response VO")
@Data
@ExcelIgnoreUnannotated
public class HandlingGroupRespVO {
@Schema(description = "主键id", requiredMode = Schema.RequiredMode.REQUIRED, example = "9657")
@ExcelProperty("主键id")
private Long id;
@Schema(description = "工厂id", requiredMode = Schema.RequiredMode.REQUIRED, example = "5268")
@ExcelProperty("工厂id")
private Long factoryId;
@Schema(description = "工厂名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "5268")
@ExcelProperty("工厂名称")
private String factoryName;
@Schema(description = "搬运组名称", example = "芋艿")
@ExcelProperty("搬运组名称")
private String handlingGroupName;
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("创建时间")
private LocalDateTime createTime;
}

View File

@ -0,0 +1,23 @@
package cn.iocoder.yudao.module.smartfactory.controller.admin.handlinggroup.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
import javax.validation.constraints.*;
import java.util.*;
@Schema(description = "管理后台 - 搬运组新增/修改 Request VO")
@Data
public class HandlingGroupSaveReqVO {
@Schema(description = "主键id", requiredMode = Schema.RequiredMode.REQUIRED, example = "9657")
private Long id;
@Schema(description = "工厂id", requiredMode = Schema.RequiredMode.REQUIRED, example = "5268")
@NotNull(message = "工厂id不能为空")
private Long factoryId;
@Schema(description = "搬运组名称", example = "芋艿")
private String handlingGroupName;
}

View File

@ -1,24 +1,18 @@
package cn.iocoder.yudao.module.smartfactory.controller.admin.handlinggroupamountspecifications;
import cn.hutool.core.collection.CollUtil;
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.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;
import cn.iocoder.yudao.module.smartfactory.dal.dataobject.factoryinfo.FactoryInfoDO;
import cn.iocoder.yudao.module.smartfactory.controller.admin.handlinggroupamountspecifications.vo.*;
import cn.iocoder.yudao.module.smartfactory.dal.dataobject.handlinggroupamountspecifications.HandlingGroupAmountSpecificationsDO;
import cn.iocoder.yudao.module.smartfactory.service.factoryinfo.FactoryInfoService;
import cn.iocoder.yudao.module.smartfactory.service.handlinggroupamountspecifications.HandlingGroupAmountSpecificationsService;
import 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.*;
@ -26,13 +20,13 @@ import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.io.IOException;
import java.math.BigDecimal;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
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;
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.getSumValue;
import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT;
@Tag(name = "管理后台 - 搬运组工资规格关联")
@ -48,64 +42,62 @@ public class HandlingGroupAmountSpecificationsController {
private FactoryInfoService factoryInfoService;
@PostMapping("/batchCreate")
@Operation(summary = "创建搬运组工资规格关联")
@PreAuthorize("@ss.hasPermission('smartfactory:handling-group-amount-specifications:create')")
@Operation(summary = "批量创建搬运组工资规格关联")
public CommonResult<Boolean> batchCreate(@Valid @RequestBody HandlingGroupAmountSpecificationsBatchCreateVO vo) {
handlingGroupAmountSpecificationsService.batchCreate(vo);
return success(true);
}
@GetMapping("/getTotalNum")
@Operation(summary = "获取合计数")
public CommonResult<HandlingGroupAmountSpecificationsTotalNumVO> getTotalNum(@RequestParam(required = false) Long factoryId) {
HandlingGroupAmountSpecificationsTotalNumVO vo = handlingGroupAmountSpecificationsService.getTotalNum(factoryId);
return success(vo);
}
@PostMapping("/update")
@Operation(summary = "更新搬运组工资规格关联")
@PreAuthorize("@ss.hasPermission('smartfactory:handling-group-amount-specifications:update')")
public CommonResult<Boolean> update(@Valid @RequestBody HandlingGroupAmountSpecificationsSaveReqVO createReqVO) {
handlingGroupAmountSpecificationsService.updateHandlingGroupAmountSpecifications(createReqVO);
@PostMapping("/batchUpdate")
@Operation(summary = "批量更新搬运组工资规格关联")
public CommonResult<Boolean> batchUpdate(@Valid @RequestBody HandlingGroupAmountSpecificationsBatchUpdateVO vo) {
handlingGroupAmountSpecificationsService.batchUpdate(vo);
return success(true);
}
@DeleteMapping("/delete")
@Operation(summary = "删除搬运组工资规格关联")
@Parameter(name = "id", description = "编号", required = true)
@PreAuthorize("@ss.hasPermission('smartfactory:handling-group-amount-specifications:delete')")
public CommonResult<Boolean> deleteHandlingGroupAmountSpecifications(@RequestParam("id") Long id) {
handlingGroupAmountSpecificationsService.deleteHandlingGroupAmountSpecifications(id);
@PostMapping("/batchDelete")
@Operation(summary = "批量删除搬运组工资规格关联")
public CommonResult<Boolean> batchDelete(@RequestBody HandlingGroupAmountSpecificationsBatchDelVO vo) {
handlingGroupAmountSpecificationsService.batchDelete(vo);
return success(true);
}
@GetMapping("/get")
@Operation(summary = "获得搬运组工资规格关联")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('smartfactory:handling-group-amount-specifications:query')")
public CommonResult<HandlingGroupAmountSpecificationsRespVO> getHandlingGroupAmountSpecifications(@RequestParam("id") Long id) {
HandlingGroupAmountSpecificationsDO handlingGroupAmountSpecifications = handlingGroupAmountSpecificationsService.getHandlingGroupAmountSpecifications(id);
@Parameter(name = "factoryId", description = "工厂id", required = true, example = "1024")
@Parameter(name = "dateStr", description = "日期", required = true, example = "1024")
@Parameter(name = "handlingGroupId", description = "搬运组id", required = true, example = "1024")
public CommonResult<List<HandlingGroupAmountSpecificationsRespVO>> getHandlingGroupAmountSpecifications(@RequestParam Long factoryId,
@RequestParam String dateStr,
@RequestParam Long handlingGroupId) {
List<HandlingGroupAmountSpecificationsDO> handlingGroupAmountSpecifications = handlingGroupAmountSpecificationsService.getHandlingGroupAmountSpecificationsList(factoryId, dateStr, handlingGroupId);
return success(BeanUtils.toBean(handlingGroupAmountSpecifications, HandlingGroupAmountSpecificationsRespVO.class));
}
@GetMapping("/page")
@Operation(summary = "获得搬运组工资规格关联分页")
@PreAuthorize("@ss.hasPermission('smartfactory:handling-group-amount-specifications:query')")
public CommonResult<PageResult<HandlingGroupAmountSpecificationsRespVO>> getHandlingGroupAmountSpecificationsPage(@Valid HandlingGroupAmountSpecificationsPageReqVO pageReqVO) {
PageResult<HandlingGroupAmountSpecificationsDO> pageResult = handlingGroupAmountSpecificationsService.getHandlingGroupAmountSpecificationsPage(pageReqVO);
PageResult<HandlingGroupAmountSpecificationsRespVO> result = BeanUtils.toBean(pageResult, HandlingGroupAmountSpecificationsRespVO.class);
if (CollUtil.isNotEmpty(result.getList())) {
// 获取工厂信息
Set<Long> factoryIds = convertSet(result.getList(), HandlingGroupAmountSpecificationsRespVO::getFactoryId);
Map<Long, FactoryInfoDO> factoryMap = convertMap(factoryInfoService.getFactoryList(factoryIds), FactoryInfoDO::getId);
result.getList().forEach(data -> {
// 设置工厂名称
data.setFactoryName(factoryMap.get(data.getFactoryId()) != null ? factoryMap.get(data.getFactoryId()).getShortName() : null);
});
// 计算合计 - 先根据工厂+搬运组+日期进行分组
Map<String, List<HandlingGroupAmountSpecificationsRespVO>> map = result.getList().stream().collect(Collectors.groupingBy(a -> a.getFactoryId() + "_" + a.getHandlingGroupId() + "_" + a.getDateStr()));
for (HandlingGroupAmountSpecificationsRespVO handlingGroupAmountSpecificationsDO : result.getList()) {
String key = handlingGroupAmountSpecificationsDO.getFactoryId() + "_" + handlingGroupAmountSpecificationsDO.getHandlingGroupId() + "_" + handlingGroupAmountSpecificationsDO.getDateStr();
handlingGroupAmountSpecificationsDO.setTotalAmount(getSumValue(map.get(key), HandlingGroupAmountSpecificationsRespVO::getAmount, BigDecimal::add));
handlingGroupAmountSpecificationsDO.setTotalNum(getSumValue(map.get(key), HandlingGroupAmountSpecificationsRespVO::getTotalCount, Integer::sum));
}
return success(result);
}
@GetMapping("/export-excel")
@Operation(summary = "导出搬运组工资规格关联 Excel")
@PreAuthorize("@ss.hasPermission('smartfactory:handling-group-amount-specifications:export')")
@OperateLog(type = EXPORT)
public void exportHandlingGroupAmountSpecificationsExcel(@Valid HandlingGroupAmountSpecificationsPageReqVO pageReqVO,
HttpServletResponse response) throws IOException {
@ -113,7 +105,7 @@ public class HandlingGroupAmountSpecificationsController {
List<HandlingGroupAmountSpecificationsDO> list = handlingGroupAmountSpecificationsService.getHandlingGroupAmountSpecificationsPage(pageReqVO).getList();
// 导出 Excel
ExcelUtils.write(response, "搬运组工资规格关联.xls", "数据", HandlingGroupAmountSpecificationsRespVO.class,
BeanUtils.toBean(list, HandlingGroupAmountSpecificationsRespVO.class));
BeanUtils.toBean(list, HandlingGroupAmountSpecificationsRespVO.class));
}
}

View File

@ -8,6 +8,10 @@ import javax.validation.constraints.NotNull;
@Data
public class HandlingGroupAmountSpecificationsBatchCreateItemVO {
@Schema(description = "id", example = "23178")
@NotNull(message = "id")
private Long id;
@Schema(description = "搬运规格id", example = "23178")
@NotNull(message = "搬运规格不能为空")
private Long handlingSpecificationsId;

View File

@ -1,5 +1,6 @@
package cn.iocoder.yudao.module.smartfactory.controller.admin.handlinggroupamountspecifications.vo;
import cn.iocoder.yudao.module.smartfactory.controller.admin.handlinggroup.vo.HandlingGroupListVO;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@ -15,6 +16,6 @@ public class HandlingGroupAmountSpecificationsBatchCreateVO {
@NotNull(message = "日期不能为空")
private String dateStr;
@Schema(description = "列表")
private List<HandlingGroupAmountSpecificationsBatchCreateItemVO> itemVOS;
@Schema(description = "搬运组列表")
private List<HandlingGroupListVO> handlingGroupList;
}

View File

@ -0,0 +1,21 @@
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 HandlingGroupAmountSpecificationsBatchDelVO {
@Schema(description = "工厂id", example = "23178")
private Long factoryId;
@Schema(description = "日期 格式 yyyy-MM-dd")
@NotNull(message = "日期不能为空")
private String dateStr;
@Schema(description = "搬运组id", example = "27617")
private Long handlingGroupId;
}

View File

@ -0,0 +1,27 @@
package cn.iocoder.yudao.module.smartfactory.controller.admin.handlinggroupamountspecifications.vo;
import cn.iocoder.yudao.module.smartfactory.controller.admin.handlinggroup.vo.HandlingGroupListVO;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import javax.validation.constraints.NotNull;
import java.util.List;
@Data
public class HandlingGroupAmountSpecificationsBatchUpdateVO {
@Schema(description = "工厂id", example = "23178")
private Long factoryId;
@Schema(description = "日期 格式 yyyy-MM-dd")
@NotNull(message = "日期不能为空")
private String dateStr;
@Schema(description = "搬运组id", example = "27617")
private Long handlingGroupId;
@Schema(description = "叉车司机id", example = "27617")
private Long staffId;
@Schema(description = "规格/数量列表")
private List<HandlingGroupAmountSpecificationsBatchCreateItemVO> itemList;
}

View File

@ -1,6 +1,7 @@
package cn.iocoder.yudao.module.smartfactory.controller.admin.handlinggroupamountspecifications.vo;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import com.alibaba.excel.annotation.ExcelProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
@ -21,6 +22,12 @@ public class HandlingGroupAmountSpecificationsPageReqVO extends PageParam {
@Schema(description = "工厂id", example = "23178")
private Long factoryId;
@Schema(description = "搬运组id", example = "23178")
private Long handlingGroupId;
@Schema(description = "叉车司机名称", example = "23178")
private String staffName;
@Schema(description = "搬运规格id", example = "23178")
private Long handlingSpecificationsId;

View File

@ -23,6 +23,22 @@ public class HandlingGroupAmountSpecificationsRespVO {
@Schema(description = "工厂名称", example = "23178")
private String factoryName;
@Schema(description = "搬运组id", example = "23178")
@ExcelProperty("搬运组id")
private Long handlingGroupId;
@Schema(description = "搬运组名称", example = "23178")
@ExcelProperty("搬运组名称")
private String handlingGroupName;
@Schema(description = "叉车司机名称", example = "23178")
@ExcelProperty("叉车司机名称")
private String staffName;
@Schema(description = "叉车司机id", example = "23178")
@ExcelProperty("叉车司机id")
private Long staffId;
@Schema(description = "搬运规格id", example = "23178")
@ExcelProperty("搬运规格id")
private Long handlingSpecificationsId;
@ -47,4 +63,12 @@ public class HandlingGroupAmountSpecificationsRespVO {
@ExcelProperty("创建时间")
private LocalDateTime createTime;
@Schema(description = "金额小计")
@ExcelProperty("金额小计")
private BigDecimal totalAmount;
@Schema(description = "数量小计")
@ExcelProperty("数量小计")
private Integer totalNum;
}

View File

@ -0,0 +1,17 @@
package cn.iocoder.yudao.module.smartfactory.controller.admin.handlinggroupamountspecifications.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.ToString;
import java.math.BigDecimal;
@Data
@ToString(callSuper = true)
public class HandlingGroupAmountSpecificationsTotalNumVO {
@Schema(description = "数量")
private Long num;
@Schema(description = "总金额")
private BigDecimal amount;
}

View File

@ -22,6 +22,9 @@ public class HandlingGroupUserAmountPageReqVO extends PageParam {
@Schema(description = "搬运组工资规格关联id", example = "27617")
private Long handlingGroupAmountSpecificationsId;
@Schema(description = "搬运组id", example = "27617")
private Long handlingGroupId;
@Schema(description = "日期 格式 yyyy-MM-dd")
private String dateStr;

View File

@ -115,8 +115,9 @@ public class StaffController {
@GetMapping("/getListByFactoryId")
@Operation(summary = "获得指定厂员工")
public CommonResult<List<StaffRespVO>> getListByFactoryId(@RequestParam("factoryId") Long factoryId,
@RequestParam(value = "nickName", required = false) String nickName) {
List<StaffDO> staffs = staffService.getListByFactoryId(factoryId, nickName);
@RequestParam(value = "nickName", required = false) String nickName,
@RequestParam(value = "workTypeId", required = false) Long workTypeId) {
List<StaffDO> staffs = staffService.getListByFactoryId(factoryId, nickName, workTypeId);
return success(BeanUtils.toBean(staffs, StaffRespVO.class));
}

View File

@ -0,0 +1,42 @@
package cn.iocoder.yudao.module.smartfactory.dal.dataobject.handlinggroup;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
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 lombok.*;
/**
* 搬运组 DO
*
* @author 艾楷
*/
@TableName("sf_handling_group")
@KeySequence("sf_handling_group_seq") // 用于 OraclePostgreSQLKingbaseDB2H2 数据库的主键自增如果是 MySQL 等数据库可不写
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class HandlingGroupDO extends BaseDO {
/**
* 主键id
*/
@TableId
private Long id;
/**
* 工厂id
*/
private Long factoryId;
/**
* 搬运组名称
*/
private String handlingGroupName;
@TableField(exist = false)
private String factoryName;
}

View File

@ -39,9 +39,16 @@ public class HandlingGroupAmountSpecificationsDO extends BaseDO {
* 搬运规格id
*/
private Long handlingSpecificationsId;
/**
* 搬运组id
*/
private Long handlingGroupId;
/**
* 叉车司机id
*/
private Long staffId;
@TableField(exist = false)
private String handlingSpecificationsName;
/**
* 数量
*/
@ -55,4 +62,25 @@ public class HandlingGroupAmountSpecificationsDO extends BaseDO {
*/
private BigDecimal amount;
/**
* 工厂名称
*/
@TableField(exist = false)
private String factoryName;
/**
* 搬运组名称
*/
@TableField(exist = false)
private String handlingGroupName;
/**
* 叉车司机名称
*/
@TableField(exist = false)
private String staffName;
/**
* 搬运规格名称
*/
@TableField(exist = false)
private String handlingSpecificationsName;
}

View File

@ -5,6 +5,7 @@ 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 io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.math.BigDecimal;
@ -44,6 +45,12 @@ public class HandlingGroupUserAmountDO extends BaseDO {
* 搬运组工资规格关联id
*/
private Long handlingGroupAmountSpecificationsId;
/**
* 搬运组id
*/
private Long handlingGroupId;
/**
* 工厂id
*/

View File

@ -0,0 +1,39 @@
package cn.iocoder.yudao.module.smartfactory.dal.mysql.handlinggroup;
import java.util.*;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.smartfactory.dal.dataobject.handlinggroup.HandlingGroupDO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.smartfactory.controller.admin.handlinggroup.vo.*;
import org.apache.ibatis.annotations.Param;
/**
* 搬运组 Mapper
*
* @author 艾楷
*/
@Mapper
public interface HandlingGroupMapper extends BaseMapperX<HandlingGroupDO> {
default PageResult<HandlingGroupDO> selectPage(HandlingGroupPageReqVO reqVO) {
return selectPage(reqVO, new LambdaQueryWrapperX<HandlingGroupDO>()
.eqIfPresent(HandlingGroupDO::getFactoryId, reqVO.getFactoryId())
.likeIfPresent(HandlingGroupDO::getHandlingGroupName, reqVO.getHandlingGroupName())
.betweenIfPresent(HandlingGroupDO::getCreateTime, reqVO.getCreateTime())
.orderByDesc(HandlingGroupDO::getId));
}
/**
*
* @param page
* @param vo
* @return
*/
IPage<HandlingGroupDO> selectPageList(@Param("page") Page<Object> page, @Param("vo") HandlingGroupPageReqVO vo);
}

View File

@ -10,6 +10,8 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 搬运组工资规格关联 Mapper
*
@ -44,4 +46,14 @@ public interface HandlingGroupAmountSpecificationsMapper extends BaseMapperX<Han
* @return
*/
HandlingGroupAmountSpecificationsDO getHandlingGroupAmountSpecifications(@Param("id") Long id);
/**
* 获取详情 多条
*
* @param factoryId
* @param dateStr
* @param handlingGroupId
* @return
*/
List<HandlingGroupAmountSpecificationsDO> getHandlingGroupAmountSpecificationsList(@Param("factoryId") Long factoryId, @Param("dateStr") String dateStr, @Param("handlingGroupId") Long handlingGroupId);
}

View File

@ -0,0 +1,56 @@
package cn.iocoder.yudao.module.smartfactory.service.handlinggroup;
import java.util.*;
import javax.validation.*;
import cn.iocoder.yudao.module.smartfactory.controller.admin.handlinggroup.vo.*;
import cn.iocoder.yudao.module.smartfactory.dal.dataobject.handlinggroup.HandlingGroupDO;
import com.baomidou.mybatisplus.extension.service.IService;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
/**
* 搬运组 Service 接口
*
* @author 艾楷
*/
public interface HandlingGroupService extends IService<HandlingGroupDO> {
/**
* 创建搬运组
*
* @param createReqVO 创建信息
* @return 编号
*/
Long createHandlingGroup(@Valid HandlingGroupSaveReqVO createReqVO);
/**
* 更新搬运组
*
* @param updateReqVO 更新信息
*/
void updateHandlingGroup(@Valid HandlingGroupSaveReqVO updateReqVO);
/**
* 删除搬运组
*
* @param id 编号
*/
void deleteHandlingGroup(Long id);
/**
* 获得搬运组
*
* @param id 编号
* @return 搬运组
*/
HandlingGroupDO getHandlingGroup(Long id);
/**
* 获得搬运组分页
*
* @param pageReqVO 分页查询
* @return 搬运组分页
*/
PageResult<HandlingGroupDO> getHandlingGroupPage(HandlingGroupPageReqVO pageReqVO);
}

View File

@ -0,0 +1,63 @@
package cn.iocoder.yudao.module.smartfactory.service.handlinggroup;
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.handlinggroup.vo.HandlingGroupPageReqVO;
import cn.iocoder.yudao.module.smartfactory.controller.admin.handlinggroup.vo.HandlingGroupSaveReqVO;
import cn.iocoder.yudao.module.smartfactory.dal.dataobject.handlinggroup.HandlingGroupDO;
import cn.iocoder.yudao.module.smartfactory.dal.mysql.handlinggroup.HandlingGroupMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource;
/**
* 搬运组 Service 实现类
*
* @author 艾楷
*/
@Service
@Validated
public class HandlingGroupServiceImpl extends ServiceImpl<HandlingGroupMapper, HandlingGroupDO> implements HandlingGroupService {
@Resource
private HandlingGroupMapper handlingGroupMapper;
@Override
public Long createHandlingGroup(HandlingGroupSaveReqVO createReqVO) {
// 插入
HandlingGroupDO handlingGroup = BeanUtils.toBean(createReqVO, HandlingGroupDO.class);
handlingGroupMapper.insert(handlingGroup);
// 返回
return handlingGroup.getId();
}
@Override
public void updateHandlingGroup(HandlingGroupSaveReqVO updateReqVO) {
// 更新
HandlingGroupDO updateObj = BeanUtils.toBean(updateReqVO, HandlingGroupDO.class);
handlingGroupMapper.updateById(updateObj);
}
@Override
public void deleteHandlingGroup(Long id) {
// 删除
handlingGroupMapper.deleteById(id);
}
@Override
public HandlingGroupDO getHandlingGroup(Long id) {
return handlingGroupMapper.selectById(id);
}
@Override
public PageResult<HandlingGroupDO> getHandlingGroupPage(HandlingGroupPageReqVO pageReqVO) {
IPage<HandlingGroupDO> pageResult = handlingGroupMapper.selectPageList(MyBatisUtils.buildPage(pageReqVO), pageReqVO);
return new PageResult<>(pageResult.getRecords(), pageResult.getTotal());
}
}

View File

@ -1,12 +1,11 @@
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.controller.admin.handlinggroupamountspecifications.vo.*;
import cn.iocoder.yudao.module.smartfactory.dal.dataobject.handlinggroupamountspecifications.HandlingGroupAmountSpecificationsDO;
import javax.validation.Valid;
import java.util.List;
/**
* 搬运组工资规格关联 Service 接口
@ -15,28 +14,6 @@ import javax.validation.Valid;
*/
public interface HandlingGroupAmountSpecificationsService {
/**
* 创建搬运组工资规格关联
*
* @param createReqVO 创建信息
* @return 编号
*/
Long createHandlingGroupAmountSpecifications(@Valid HandlingGroupAmountSpecificationsSaveReqVO createReqVO);
/**
* 更新搬运组工资规格关联
*
* @param updateReqVO 更新信息
*/
void updateHandlingGroupAmountSpecifications(@Valid HandlingGroupAmountSpecificationsSaveReqVO updateReqVO);
/**
* 删除搬运组工资规格关联
*
* @param id 编号
*/
void deleteHandlingGroupAmountSpecifications(Long id);
/**
* 获得搬运组工资规格关联
*
@ -45,6 +22,16 @@ public interface HandlingGroupAmountSpecificationsService {
*/
HandlingGroupAmountSpecificationsDO getHandlingGroupAmountSpecifications(Long id);
/**
* 获取详情 - 多条
*
* @param factoryId
* @param dateStr
* @param handlingGroupId
* @return
*/
List<HandlingGroupAmountSpecificationsDO> getHandlingGroupAmountSpecificationsList(Long factoryId, String dateStr, Long handlingGroupId);
/**
* 获得搬运组工资规格关联分页
*
@ -53,16 +40,32 @@ public interface HandlingGroupAmountSpecificationsService {
*/
PageResult<HandlingGroupAmountSpecificationsDO> getHandlingGroupAmountSpecificationsPage(HandlingGroupAmountSpecificationsPageReqVO pageReqVO);
/**
* 新增编辑
*
* @param createReqVO
*/
void createOrEdit(@Valid HandlingGroupAmountSpecificationsSaveReqVO createReqVO);
/**
* 批量新增
*
* @param vo
*/
void batchCreate(@Valid HandlingGroupAmountSpecificationsBatchCreateVO vo);
/**
* 批量更新
*
* @param vo
*/
void batchUpdate(@Valid HandlingGroupAmountSpecificationsBatchUpdateVO vo);
/**
* 批量删除
*
* @param vo
*/
void batchDelete(HandlingGroupAmountSpecificationsBatchDelVO vo);
/**
* 获取合计
*
* @param factoryId
* @return
*/
HandlingGroupAmountSpecificationsTotalNumVO getTotalNum(Long factoryId);
}

View File

@ -1,12 +1,9 @@
package cn.iocoder.yudao.module.smartfactory.service.handlinggroupamountspecifications;
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.controller.admin.handlinggroup.vo.HandlingGroupListVO;
import cn.iocoder.yudao.module.smartfactory.controller.admin.handlinggroupamountspecifications.vo.*;
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;
@ -18,19 +15,18 @@ import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Collections;
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.framework.common.util.collection.CollectionUtils.getSumValue;
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
import static cn.iocoder.yudao.module.smartfactory.enums.ErrorCodeConstants.CANNOT_FIND_THE_CORRESPONDING_FACTORY_HANDLING_SPECIFICATION;
/**
* 搬运组工资规格关联 Service 实现类
@ -54,49 +50,17 @@ public class HandlingGroupAmountSpecificationsServiceImpl implements HandlingGro
private static final BigDecimal THOUSANDTH = new BigDecimal("0.001");
@Override
public Long createHandlingGroupAmountSpecifications(HandlingGroupAmountSpecificationsSaveReqVO createReqVO) {
// 插入
HandlingGroupAmountSpecificationsDO handlingGroupAmountSpecifications = BeanUtils.toBean(createReqVO, HandlingGroupAmountSpecificationsDO.class);
handlingGroupAmountSpecificationsMapper.insert(handlingGroupAmountSpecifications);
// 返回
return handlingGroupAmountSpecifications.getId();
}
@Override
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);
}
@Override
public void deleteHandlingGroupAmountSpecifications(Long id) {
// 删除
handlingGroupAmountSpecificationsMapper.deleteById(id);
}
@Override
public HandlingGroupAmountSpecificationsDO getHandlingGroupAmountSpecifications(Long id) {
return handlingGroupAmountSpecificationsMapper.getHandlingGroupAmountSpecifications(id);
}
@Override
public List<HandlingGroupAmountSpecificationsDO> getHandlingGroupAmountSpecificationsList(Long factoryId, String dateStr, Long handlingGroupId) {
return handlingGroupAmountSpecificationsMapper.getHandlingGroupAmountSpecificationsList(factoryId,dateStr,handlingGroupId);
}
@Override
public PageResult<HandlingGroupAmountSpecificationsDO> getHandlingGroupAmountSpecificationsPage(HandlingGroupAmountSpecificationsPageReqVO pageReqVO) {
// 判断当前登录人是否属于工厂主管
@ -110,53 +74,101 @@ public class HandlingGroupAmountSpecificationsServiceImpl implements HandlingGro
return new PageResult<>(pageResult.getRecords(), pageResult.getTotal());
}
@Override
@Transactional(rollbackFor = Exception.class)
public void createOrEdit(HandlingGroupAmountSpecificationsSaveReqVO createReqVO) {
HandlingSpecificationsDO handlingSpecificationsDO = handlingSpecificationsService.getById(createReqVO.getHandlingSpecificationsId());
if (handlingSpecificationsDO == null) {
throw exception(CANNOT_FIND_THE_CORRESPONDING_FACTORY_HANDLING_SPECIFICATION);
}
BigDecimal totalAmount;
if (handlingSpecificationsDO.getType() == 0) {
totalAmount = new BigDecimal(createReqVO.getTotalCount().toString()).multiply(handlingSpecificationsDO.getUnitPrice());
} else {
totalAmount = new BigDecimal(createReqVO.getTotalCount().toString()).multiply(handlingSpecificationsDO.getWeight())
.multiply(handlingSpecificationsDO.getUnitPrice().multiply(THOUSANDTH));
}
// 插入
HandlingGroupAmountSpecificationsDO handlingGroupAmountSpecifications = BeanUtils.toBean(createReqVO, HandlingGroupAmountSpecificationsDO.class);
handlingGroupAmountSpecifications.setAmount(totalAmount);
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<Long> handlingSpecificationsIds = vo.getHandlingGroupList().stream()
.flatMap(group -> group.getItemList().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();
for (HandlingGroupListVO handlingGroupListVO : vo.getHandlingGroupList()) {
for (HandlingGroupAmountSpecificationsBatchCreateItemVO itemVO : handlingGroupListVO.getItemList()) {
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());
handlingGroupAmountSpecificationsDO.setHandlingGroupId(handlingGroupListVO.getHandlingGroupId());
handlingGroupAmountSpecificationsDO.setStaffId(handlingGroupListVO.getStaffId());
list.add(handlingGroupAmountSpecificationsDO);
}
}
handlingGroupAmountSpecificationsMapper.insertBatch(list);
}
@Override
public void batchUpdate(HandlingGroupAmountSpecificationsBatchUpdateVO vo) {
// 先通过 工厂 + 日期 + 组id 获取到当前编辑的搬运组
List<HandlingGroupAmountSpecificationsDO> list = handlingGroupAmountSpecificationsMapper.selectList(new LambdaQueryWrapper<HandlingGroupAmountSpecificationsDO>()
.eq(HandlingGroupAmountSpecificationsDO::getFactoryId, vo.getFactoryId())
.eq(HandlingGroupAmountSpecificationsDO::getHandlingGroupId, vo.getHandlingGroupId())
.eq(HandlingGroupAmountSpecificationsDO::getDateStr, vo.getDateStr()));
List<Long> handlingSpecificationsIds = vo.getItemList().stream().map(HandlingGroupAmountSpecificationsBatchCreateItemVO::getHandlingSpecificationsId).distinct().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));
Map<Long, HandlingGroupAmountSpecificationsBatchCreateItemVO> handlingGroupAmountSpecificationsMap = vo.getItemList().stream()
.collect(Collectors.toMap(HandlingGroupAmountSpecificationsBatchCreateItemVO::getId, item -> item));
for (HandlingGroupAmountSpecificationsDO item : list) {
BigDecimal totalAmount;
HandlingSpecificationsDO handlingSpecificationsDO = map.get(itemVO.getHandlingSpecificationsId());
HandlingGroupAmountSpecificationsBatchCreateItemVO handlingGroupAmountSpecificationsBatchCreateItemVO
= handlingGroupAmountSpecificationsMap.get(item.getId());
item.setHandlingSpecificationsId(handlingGroupAmountSpecificationsBatchCreateItemVO.getHandlingSpecificationsId());
HandlingSpecificationsDO handlingSpecificationsDO = map.get(item.getHandlingSpecificationsId());
if (handlingSpecificationsDO == null) {
continue;
}
if (handlingSpecificationsDO.getType() == 0) {
totalAmount = new BigDecimal(itemVO.getTotalCount().toString()).multiply(handlingSpecificationsDO.getUnitPrice());
totalAmount = new BigDecimal(item.getTotalCount().toString()).multiply(handlingSpecificationsDO.getUnitPrice());
} else {
totalAmount = new BigDecimal(itemVO.getTotalCount().toString()).multiply(handlingSpecificationsDO.getWeight())
totalAmount = new BigDecimal(item.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);
item.setAmount(totalAmount);
item.setTotalCount(item.getTotalCount());
item.setStaffId(vo.getStaffId());
item.setHandlingGroupId(vo.getHandlingGroupId());
}
handlingGroupAmountSpecificationsMapper.insertBatch(list);
handlingGroupAmountSpecificationsMapper.updateBatch(list);
}
@Override
public void batchDelete(HandlingGroupAmountSpecificationsBatchDelVO vo) {
handlingGroupAmountSpecificationsMapper.delete(new LambdaQueryWrapper<HandlingGroupAmountSpecificationsDO>()
.eq(HandlingGroupAmountSpecificationsDO::getFactoryId, vo.getFactoryId())
.eq(HandlingGroupAmountSpecificationsDO::getHandlingGroupId, vo.getHandlingGroupId())
.eq(HandlingGroupAmountSpecificationsDO::getDateStr, vo.getDateStr()));
}
@Override
public HandlingGroupAmountSpecificationsTotalNumVO getTotalNum(Long factoryId) {
HandlingGroupAmountSpecificationsTotalNumVO vo = new HandlingGroupAmountSpecificationsTotalNumVO();
List<HandlingGroupAmountSpecificationsDO> list = handlingGroupAmountSpecificationsMapper.selectList(new LambdaQueryWrapper<HandlingGroupAmountSpecificationsDO>()
.eq(factoryId != null, HandlingGroupAmountSpecificationsDO::getFactoryId, factoryId));
BigDecimal amount = getSumValue(list, HandlingGroupAmountSpecificationsDO::getAmount, BigDecimal::add);
Integer num = getSumValue(list, HandlingGroupAmountSpecificationsDO::getTotalCount, Integer::sum);
vo.setNum(num.longValue());
vo.setAmount(amount);
return vo;
}
}

View File

@ -112,9 +112,10 @@ public interface StaffService {
*
* @param factoryId
* @param nickName
* @param workTypeId
* @return
*/
List<StaffDO> getListByFactoryId(Long factoryId, String nickName);
List<StaffDO> getListByFactoryId(Long factoryId, String nickName, Long workTypeId);
/**
*

View File

@ -254,9 +254,10 @@ public class StaffServiceImpl implements StaffService {
}
@Override
public List<StaffDO> getListByFactoryId(Long factoryId, String nickName) {
public List<StaffDO> getListByFactoryId(Long factoryId, String nickName, Long workTypeId) {
return staffMapper.selectList(new LambdaQueryWrapperX<StaffDO>()
.eq(factoryId != null, StaffDO::getFactoryId, factoryId)
.eq(workTypeId != null, StaffDO::getWorkTypeId, workTypeId)
.like(StrUtil.isNotEmpty(nickName), StaffDO::getNickName, nickName));
}

View File

@ -0,0 +1,28 @@
<?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="cn.iocoder.yudao.module.smartfactory.dal.mysql.handlinggroup.HandlingGroupMapper">
<!--
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
文档可见https://www.iocoder.cn/MyBatis/x-plugins/
-->
<select id="selectPageList"
resultType="cn.iocoder.yudao.module.smartfactory.dal.dataobject.handlinggroup.HandlingGroupDO">
select
a.*,
b.short_name as factoryName
from sf_handling_group a
left join sf_factory_info as b on a.factory_id = b.id
<where>
<if test="vo.factoryId != null">
and a.factory_id = #{vo.factoryId}
</if>
<if test="vo.handlingGroupName != null and vo.handlingGroupName != ''">
and a.handling_group_name like concat('%', #{vo.handlingGroupName}, '%')
</if>
</where>
</select>
</mapper>

View File

@ -12,15 +12,27 @@
<select id="getHandlingGroupAmountSpecificationsPage"
resultType="cn.iocoder.yudao.module.smartfactory.dal.dataobject.handlinggroupamountspecifications.HandlingGroupAmountSpecificationsDO">
SELECT a.*,
b.specifications_name as handlingSpecificationsName
b.specifications_name as handlingSpecificationsName,
c.nick_name as staffName,
f.short_name as factoryName,
d.handling_group_name as handlingGroupName
FROM sf_handling_group_amount_specifications AS a
left join sf_factory_info as f on a.factory_id = f.id
LEFT JOIN sf_handling_specifications AS b ON a.handling_specifications_id = b.id
LEFT JOIN sf_staff AS c ON c.id = a.staff_id
left join sf_handling_group as d on a.handling_group_id = d.id
<where>
a.deleted = 0
and b.deleted = 0
<if test="vo.handlingSpecificationsId != null">
AND a.handling_specifications_id = #{vo.handlingSpecificationsId}
</if>
<if test="vo.handlingGroupId != null">
and a.handling_group_id = #{vo.handlingGroupId}
</if>
<if test="vo.staffName != null and vo.staffName != ''">
and c.nick_name like concat('%', #{vo.staffName}, '%')
</if>
<if test="vo.factoryId != null">
AND a.factory_id = #{vo.factoryId}
</if>
@ -41,4 +53,30 @@
and a.id = #{id}
</where>
</select>
<select id="getHandlingGroupAmountSpecificationsList"
resultType="cn.iocoder.yudao.module.smartfactory.dal.dataobject.handlinggroupamountspecifications.HandlingGroupAmountSpecificationsDO">
SELECT a.*,
b.specifications_name as handlingSpecificationsName,
c.nick_name as staffName,
f.short_name as factoryName,
d.handling_group_name as handlingGroupName
FROM sf_handling_group_amount_specifications AS a
left join sf_factory_info as f on a.factory_id = f.id
LEFT JOIN sf_handling_specifications AS b ON a.handling_specifications_id = b.id
LEFT JOIN sf_staff AS c ON c.id = a.staff_id
left join sf_handling_group as d on a.handling_group_id = d.id
<where>
a.deleted = 0
and b.deleted = 0
<if test="handlingGroupId != null">
and a.handling_group_id = #{handlingGroupId}
</if>
<if test="factoryId != null">
AND a.factory_id = #{factoryId}
</if>
<if test="dateStr != null and dateStr != ''">
and a.date_str like concat('%', #{dateStr}, '%')
</if>
</where>
</select>
</mapper>

View File

@ -21,6 +21,9 @@
<if test="vo.userId != null">
AND a.user_id = #{vo.userId}
</if>
<if test="vo.handlingGroupId != null">
AND a.handling_group_id = #{vo.handlingGroupId}
</if>
<if test="vo.handlingGroupAmountSpecificationsId != null">
AND a.handling_group_amount_specifications_id= #{vo.handlingGroupAmountSpecificationsId}
</if>