no message

main
HUOJIN\92525 2025-04-07 18:09:50 +08:00
parent cd5a52a4dc
commit d231bdb85d
43 changed files with 2050 additions and 21 deletions

View File

@ -0,0 +1,75 @@
package net.lab1024.sa.admin.module.business.inventory.controller;
import net.lab1024.sa.admin.module.business.inventory.domain.form.InventoryAddForm;
import net.lab1024.sa.admin.module.business.inventory.domain.form.InventoryQueryForm;
import net.lab1024.sa.admin.module.business.inventory.domain.form.InventoryUpdateForm;
import net.lab1024.sa.admin.module.business.inventory.domain.vo.InventoryVO;
import net.lab1024.sa.admin.module.business.inventory.service.InventoryQueryService;
import net.lab1024.sa.admin.module.business.inventory.service.InventoryService;
import net.lab1024.sa.base.common.domain.ValidateList;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import net.lab1024.sa.base.common.domain.ResponseDTO;
import net.lab1024.sa.base.common.domain.PageResult;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import cn.dev33.satoken.annotation.SaCheckPermission;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
/**
* Controller
*
* @Author
* @Date 2024-12-06 17:24:53
* @Copyright
*/
@RestController
@Tag(name = "库存信息")
public class InventoryController {
@Resource
private InventoryService inventoryService;
@Resource
private InventoryQueryService inventoryQueryService;
@Operation(summary = "分页查询 @author 霍锦")
@PostMapping("/inventory/queryPage")
@SaCheckPermission("inventory:query")
public ResponseDTO<PageResult<InventoryVO>> queryPage(@RequestBody @Valid InventoryQueryForm queryForm) {
return ResponseDTO.ok(inventoryQueryService.queryPage(queryForm));
}
@Operation(summary = "添加 @author 霍锦")
@PostMapping("/inventory/add")
@SaCheckPermission("inventory:add")
public ResponseDTO<String> add(@RequestBody @Valid InventoryAddForm addForm) {
return inventoryService.add(addForm);
}
@Operation(summary = "更新 @author 霍锦")
@PostMapping("/inventory/update")
@SaCheckPermission("inventory:update")
public ResponseDTO<String> update(@RequestBody @Valid InventoryUpdateForm updateForm) {
return inventoryService.update(updateForm);
}
@Operation(summary = "批量删除 @author 霍锦")
@PostMapping("/inventory/batchDelete")
@SaCheckPermission("inventory:delete")
public ResponseDTO<String> batchDelete(@RequestBody ValidateList<Long> idList) {
return inventoryService.batchDelete(idList);
}
@Operation(summary = "单个删除 @author 霍锦")
@GetMapping("/inventory/delete/{inventoryId}")
@SaCheckPermission("inventory:delete")
public ResponseDTO<String> batchDelete(@PathVariable Long inventoryId) {
return inventoryService.delete(inventoryId);
}
}

View File

@ -0,0 +1,33 @@
package net.lab1024.sa.admin.module.business.inventory.dao;
import java.util.List;
import net.lab1024.sa.admin.module.business.inventory.domain.entity.InventoryEntity;
import net.lab1024.sa.admin.module.business.inventory.domain.form.InventoryQueryForm;
import net.lab1024.sa.admin.module.business.inventory.domain.vo.InventoryVO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Component;
/**
* Dao
*
* @Author
* @Date 2024-12-06 17:24:53
* @Copyright
*/
@Mapper
public interface InventoryDao extends BaseMapper<InventoryEntity> {
/**
*
*
* @param page
* @param queryForm
* @return
*/
List<InventoryVO> queryPage(Page page, @Param("queryForm") InventoryQueryForm queryForm);
}

View File

@ -0,0 +1,84 @@
package net.lab1024.sa.admin.module.business.inventory.domain.entity;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
*
*
* @Author
* @Date 2024-12-06 17:24:53
* @Copyright
*/
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@TableName("t_inventory")
public class InventoryEntity {
/**
* id
*/
@TableId(type = IdType.AUTO)
private Long inventoryId;
/**
*
*/
private Long itemKeyId;
/**
*
*/
private Long locationId;
/**
*
*/
private Long stockId;
/**
*
*/
private BigDecimal quantity;
/**
*
*/
private BigDecimal queuedQuantity;
/**
*
*/
@TableField(fill = FieldFill.INSERT)
private LocalDateTime createTime;
/**
* ID
*/
private Long createUserId;
/**
*
*/
private String createUserName;
/**
*
*/
@TableField(fill = FieldFill.INSERT_UPDATE)
private LocalDateTime updateTime;
}

View File

@ -0,0 +1,40 @@
package net.lab1024.sa.admin.module.business.inventory.domain.form;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import java.time.LocalDateTime;
import lombok.Data;
/**
*
*
* @Author
* @Date 2024-12-06 17:24:53
* @Copyright
*/
@Data
public class InventoryAddForm {
@Schema(description = "库存id", requiredMode = Schema.RequiredMode.REQUIRED)
@NotNull(message = "库存id 不能为空")
private Long inventoryId;
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
@NotNull(message = "创建时间 不能为空")
private LocalDateTime createTime;
@Schema(description = "创建人ID", requiredMode = Schema.RequiredMode.REQUIRED)
@NotNull(message = "创建人ID 不能为空")
private Long createUserId;
@Schema(description = "创建人", requiredMode = Schema.RequiredMode.REQUIRED)
@NotBlank(message = "创建人 不能为空")
private String createUserName;
@Schema(description = "更新时间", requiredMode = Schema.RequiredMode.REQUIRED)
@NotNull(message = "更新时间 不能为空")
private LocalDateTime updateTime;
}

View File

@ -0,0 +1,19 @@
package net.lab1024.sa.admin.module.business.inventory.domain.form;
import net.lab1024.sa.base.common.domain.PageParam;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
*
*
* @Author
* @Date 2024-12-06 17:24:53
* @Copyright
*/
@Data
@EqualsAndHashCode(callSuper = false)
public class InventoryQueryForm extends PageParam {
}

View File

@ -0,0 +1,22 @@
package net.lab1024.sa.admin.module.business.inventory.domain.form;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
/**
*
*
* @Author
* @Date 2024-12-06 17:24:53
* @Copyright
*/
@Data
public class InventoryUpdateForm {
@Schema(description = "库存id", requiredMode = Schema.RequiredMode.REQUIRED)
@NotNull(message = "库存id 不能为空")
private Long inventoryId;
}

View File

@ -0,0 +1,41 @@
package net.lab1024.sa.admin.module.business.inventory.domain.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import lombok.Data;
/**
* VO
*
* @Author
* @Date 2024-12-06 17:24:53
* @Copyright
*/
@Data
public class InventoryVO {
@Schema(description = "库存id")
private Long inventoryId;
@Schema(description = "物料属性")
private Long itemKeyId;
@Schema(description = "库位")
private Long locationId;
@Schema(description = "容器")
private Long stockId;
@Schema(description = "数量")
private BigDecimal quantity;
@Schema(description = "占用数")
private BigDecimal queuedQuantity;
@Schema(description = "创建时间")
private LocalDateTime createTime;
}

View File

@ -0,0 +1,20 @@
package net.lab1024.sa.admin.module.business.inventory.manager;
import net.lab1024.sa.admin.module.business.inventory.dao.InventoryDao;
import net.lab1024.sa.admin.module.business.inventory.domain.entity.InventoryEntity;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
/**
* Manager
*
* @Author
* @Date 2024-12-06 17:24:53
* @Copyright
*/
@Service
public class InventoryManager extends ServiceImpl<InventoryDao, InventoryEntity> {
}

View File

@ -0,0 +1,40 @@
package net.lab1024.sa.admin.module.business.inventory.service;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import jakarta.annotation.Resource;
import net.lab1024.sa.admin.module.business.inventory.dao.InventoryDao;
import net.lab1024.sa.admin.module.business.inventory.domain.entity.InventoryEntity;
import net.lab1024.sa.admin.module.business.inventory.domain.form.InventoryQueryForm;
import net.lab1024.sa.admin.module.business.inventory.domain.vo.InventoryVO;
import net.lab1024.sa.base.common.domain.PageResult;
import net.lab1024.sa.base.common.util.SmartPageUtil;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class InventoryQueryService {
@Resource
private InventoryDao inventoryDao;
/**
*
*/
public PageResult<InventoryVO> queryPage(InventoryQueryForm queryForm) {
Page<?> page = SmartPageUtil.convert2PageQuery(queryForm);
List<InventoryVO> list = inventoryDao.queryPage(page, queryForm);
return SmartPageUtil.convert2PageResult(page, list);
}
/**
* @param ItemKeyId
* @return InventoryEntity
*/
public InventoryEntity queryInventory(Long ItemKeyId) {
LambdaQueryWrapper<InventoryEntity> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(InventoryEntity::getItemKeyId, ItemKeyId);
return inventoryDao.selectOne(queryWrapper);
}
}

View File

@ -0,0 +1,100 @@
package net.lab1024.sa.admin.module.business.inventory.service;
import java.math.BigDecimal;
import java.util.List;
import net.lab1024.sa.admin.module.business.inventory.dao.InventoryDao;
import net.lab1024.sa.admin.module.business.inventory.domain.entity.InventoryEntity;
import net.lab1024.sa.admin.module.business.inventory.domain.form.InventoryAddForm;
import net.lab1024.sa.admin.module.business.inventory.domain.form.InventoryQueryForm;
import net.lab1024.sa.admin.module.business.inventory.domain.form.InventoryUpdateForm;
import net.lab1024.sa.admin.module.business.inventory.domain.vo.InventoryVO;
import net.lab1024.sa.admin.module.business.inventory.manager.InventoryManager;
import net.lab1024.sa.base.common.code.UserErrorCode;
import net.lab1024.sa.base.common.util.SmartBeanUtil;
import net.lab1024.sa.base.common.util.SmartPageUtil;
import net.lab1024.sa.base.common.domain.ResponseDTO;
import net.lab1024.sa.base.common.domain.PageResult;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import net.lab1024.sa.base.common.util.SmartRequestUtil;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Service;
import jakarta.annotation.Resource;
import org.springframework.transaction.annotation.Transactional;
/**
* Service
*
* @Author
* @Date 2024-12-06 17:24:53
* @Copyright
*/
@Service
public class InventoryService {
@Resource
private InventoryDao inventoryDao;
@Resource
private InventoryManager inventoryManager;
/**
*
*/
@Transactional(rollbackFor = Exception.class)
public ResponseDTO<String> add(InventoryAddForm addForm) {
InventoryEntity inventoryEntity = SmartBeanUtil.copy(addForm, InventoryEntity.class);
inventoryDao.insert(inventoryEntity);
return ResponseDTO.ok();
}
/**
*
*
*/
@Transactional(rollbackFor = Exception.class)
public ResponseDTO<String> update(InventoryUpdateForm updateForm) {
InventoryEntity inventoryEntity = SmartBeanUtil.copy(updateForm, InventoryEntity.class);
inventoryDao.updateById(inventoryEntity);
return ResponseDTO.ok();
}
/**
*
*/
@Transactional(rollbackFor = Exception.class)
public ResponseDTO<String> batchDelete(List<Long> idList) {
if (CollectionUtils.isEmpty(idList)){
return ResponseDTO.userErrorParam(UserErrorCode.PARAM_ERROR.getMsg());
}
inventoryManager.removeBatchByIds(idList);
return ResponseDTO.ok();
}
/**
*
*/
@Transactional(rollbackFor = Exception.class)
public ResponseDTO<String> delete(Long inventoryId) {
if (null == inventoryId){
return ResponseDTO.userErrorParam(UserErrorCode.PARAM_ERROR.getMsg());
}
inventoryDao.deleteById(inventoryId);
return ResponseDTO.ok();
}
public InventoryEntity createInventory(Long itemKeyId, Long locationId, Long stockId, BigDecimal quantity) {
return InventoryEntity.builder()
.itemKeyId(itemKeyId)
.locationId(locationId)
.stockId(stockId)
.quantity(quantity)
.queuedQuantity(BigDecimal.ZERO)
.createUserId(SmartRequestUtil.getRequestUser().getUserId())
.createUserName(SmartRequestUtil.getRequestUser().getUserName())
.build();
}
}

View File

@ -0,0 +1,22 @@
# 默认是按前端工程文件的 /views/business 文件夹的路径作为前端组件路径,如果你没把生成的 .vue 前端代码放在 /views/business 下,
# 那就根据自己实际情况修改下面 SQL 的 path,component 字段值,避免执行 SQL 后菜单无法访问。
# 如果你一切都是按照默认,那么下面的 SQL 基本不用改
INSERT INTO t_menu ( menu_name, menu_type, parent_id, path, component, frame_flag, cache_flag, visible_flag, disabled_flag, perms_type, create_user_id )
VALUES ( '库存信息', 2, 0, '/inventory/list', '/business/inventory/inventory-list.vue', false, false, true, false, 1, 1 );
# 按菜单名称查询该菜单的 menu_id 作为按钮权限的 父菜单ID 与 功能点关联菜单ID
SET @parent_id = NULL;
SELECT t_menu.menu_id INTO @parent_id FROM t_menu WHERE t_menu.menu_name = '库存信息';
INSERT INTO t_menu ( menu_name, menu_type, parent_id, frame_flag, cache_flag, visible_flag, disabled_flag, perms_type, api_perms, web_perms, context_menu_id, create_user_id )
VALUES ( '查询', 3, @parent_id, false, false, true, false, 1, 'inventory:query', 'inventory:query', @parent_id, 1 );
INSERT INTO t_menu ( menu_name, menu_type, parent_id, frame_flag, cache_flag, visible_flag, disabled_flag, perms_type, api_perms, web_perms, context_menu_id, create_user_id )
VALUES ( '添加', 3, @parent_id, false, false, true, false, 1, 'inventory:add', 'inventory:add', @parent_id, 1 );
INSERT INTO t_menu ( menu_name, menu_type, parent_id, frame_flag, cache_flag, visible_flag, disabled_flag, perms_type, api_perms, web_perms, context_menu_id, create_user_id )
VALUES ( '更新', 3, @parent_id, false, false, true, false, 1, 'inventory:update', 'inventory:update', @parent_id, 1 );
INSERT INTO t_menu ( menu_name, menu_type, parent_id, frame_flag, cache_flag, visible_flag, disabled_flag, perms_type, api_perms, web_perms, context_menu_id, create_user_id )
VALUES ( '删除', 3, @parent_id, false, false, true, false, 1, 'inventory:delete', 'inventory:delete', @parent_id, 1 );

View File

@ -0,0 +1,75 @@
package net.lab1024.sa.admin.module.business.itemKey.controller;
import net.lab1024.sa.admin.module.business.itemKey.domain.form.ItemKeyAddForm;
import net.lab1024.sa.admin.module.business.itemKey.domain.form.ItemKeyQueryForm;
import net.lab1024.sa.admin.module.business.itemKey.domain.form.ItemKeyUpdateForm;
import net.lab1024.sa.admin.module.business.itemKey.domain.vo.ItemKeyVO;
import net.lab1024.sa.admin.module.business.itemKey.service.ItemKeyQueryService;
import net.lab1024.sa.admin.module.business.itemKey.service.ItemKeyService;
import net.lab1024.sa.base.common.domain.ValidateList;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import net.lab1024.sa.base.common.domain.ResponseDTO;
import net.lab1024.sa.base.common.domain.PageResult;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import cn.dev33.satoken.annotation.SaCheckPermission;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
/**
* Controller
*
* @Author
* @Date 2024-12-05 21:38:40
* @Copyright
*/
@RestController
@Tag(name = "物料属性")
public class ItemKeyController {
@Resource
private ItemKeyService itemKeyService;
@Resource
private ItemKeyQueryService itemKeyQueryService;
@Operation(summary = "分页查询 @author 霍锦")
@PostMapping("/itemKey/queryPage")
@SaCheckPermission("itemKey:query")
public ResponseDTO<PageResult<ItemKeyVO>> queryPage(@RequestBody @Valid ItemKeyQueryForm queryForm) {
return ResponseDTO.ok(itemKeyQueryService.queryPage(queryForm));
}
@Operation(summary = "添加 @author 霍锦")
@PostMapping("/itemKey/add")
@SaCheckPermission("itemKey:add")
public ResponseDTO<String> add(@RequestBody @Valid ItemKeyAddForm addForm) {
return itemKeyService.add(addForm);
}
@Operation(summary = "更新 @author 霍锦")
@PostMapping("/itemKey/update")
@SaCheckPermission("itemKey:update")
public ResponseDTO<String> update(@RequestBody @Valid ItemKeyUpdateForm updateForm) {
return itemKeyService.update(updateForm);
}
@Operation(summary = "批量删除 @author 霍锦")
@PostMapping("/itemKey/batchDelete")
@SaCheckPermission("itemKey:delete")
public ResponseDTO<String> batchDelete(@RequestBody ValidateList<Long> idList) {
return itemKeyService.batchDelete(idList);
}
@Operation(summary = "单个删除 @author 霍锦")
@GetMapping("/itemKey/delete/{itemKeyId}")
@SaCheckPermission("itemKey:delete")
public ResponseDTO<String> batchDelete(@PathVariable Long itemKeyId) {
return itemKeyService.delete(itemKeyId);
}
}

View File

@ -0,0 +1,32 @@
package net.lab1024.sa.admin.module.business.itemKey.dao;
import java.util.List;
import net.lab1024.sa.admin.module.business.itemKey.domain.entity.ItemKeyEntity;
import net.lab1024.sa.admin.module.business.itemKey.domain.form.ItemKeyQueryForm;
import net.lab1024.sa.admin.module.business.itemKey.domain.vo.ItemKeyVO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
/**
* Dao
*
* @Author
* @Date 2024-12-05 21:38:40
* @Copyright
*/
@Mapper
public interface ItemKeyDao extends BaseMapper<ItemKeyEntity> {
/**
*
*
* @param page
* @param queryForm
* @return
*/
List<ItemKeyVO> queryPage(Page page, @Param("queryForm") ItemKeyQueryForm queryForm);
}

View File

@ -0,0 +1,109 @@
package net.lab1024.sa.admin.module.business.itemKey.domain.entity;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.time.LocalDate;
import java.time.LocalDateTime;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
*
*
* @Author
* @Date 2024-12-05 21:38:40
* @Copyright
*/
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@TableName("t_item_key")
public class ItemKeyEntity {
/**
* id
*/
@TableId(type = IdType.AUTO)
private Long itemKeyId;
/**
*
*/
private String orderNumber;
/**
* ID
*/
private Long itemId;
/**
*
*/
private String propC1;
/**
*
*/
private String propC2;
/**
* 3
*/
private String propC3;
/**
* 4
*/
private String propC4;
/**
* 5
*/
private String propC5;
/**
* 6
*/
private String propC6;
/**
*
*/
private LocalDate propD1;
/**
*
*/
private LocalDate propD2;
/**
* ID
*/
private Long createUserId;
/**
*
*/
private String createUserName;
/**
*
*/
@TableField(fill = FieldFill.INSERT)
private LocalDateTime createTime;
/**
*
*/
@TableField(fill = FieldFill.INSERT_UPDATE)
private LocalDateTime updateTime;
}

View File

@ -0,0 +1,22 @@
package net.lab1024.sa.admin.module.business.itemKey.domain.form;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import java.time.LocalDateTime;
import lombok.Data;
/**
*
*
* @Author
* @Date 2024-12-05 21:38:40
* @Copyright
*/
@Data
public class ItemKeyAddForm {
}

View File

@ -0,0 +1,19 @@
package net.lab1024.sa.admin.module.business.itemKey.domain.form;
import net.lab1024.sa.base.common.domain.PageParam;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
*
*
* @Author
* @Date 2024-12-05 21:38:40
* @Copyright
*/
@Data
@EqualsAndHashCode(callSuper = false)
public class ItemKeyQueryForm extends PageParam {
}

View File

@ -0,0 +1,22 @@
package net.lab1024.sa.admin.module.business.itemKey.domain.form;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
/**
*
*
* @Author
* @Date 2024-12-05 21:38:40
* @Copyright
*/
@Data
public class ItemKeyUpdateForm {
@Schema(description = "id", requiredMode = Schema.RequiredMode.REQUIRED)
@NotNull(message = "id 不能为空")
private Long itemKeyId;
}

View File

@ -0,0 +1,65 @@
package net.lab1024.sa.admin.module.business.itemKey.domain.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import java.time.LocalDate;
import java.time.LocalDateTime;
import lombok.Data;
/**
* VO
*
* @Author
* @Date 2024-12-05 21:38:40
* @Copyright
*/
@Data
public class ItemKeyVO {
@Schema(description = "id")
private Long itemKeyId;
@Schema(description = "工单号")
private String orderNumber;
@Schema(description = "物料ID")
private Long itemId;
@Schema(description = "批次号")
private String propC1;
@Schema(description = "序列号")
private String propC2;
@Schema(description = "属性3")
private String propC3;
@Schema(description = "属性4")
private String propC4;
@Schema(description = "属性5")
private String propC5;
@Schema(description = "属性6")
private String propC6;
@Schema(description = "生产日期")
private LocalDate propD1;
@Schema(description = "到期日期")
private LocalDate propD2;
@Schema(description = "创建人ID")
private Long createUserId;
@Schema(description = "创建人")
private String createUserName;
@Schema(description = "创建时间")
private LocalDateTime createTime;
@Schema(description = "更新时间")
private LocalDateTime updateTime;
}

View File

@ -0,0 +1,20 @@
package net.lab1024.sa.admin.module.business.itemKey.manager;
import net.lab1024.sa.admin.module.business.itemKey.domain.entity.ItemKeyEntity;
import net.lab1024.sa.admin.module.business.itemKey.dao.ItemKeyDao;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
/**
* Manager
*
* @Author
* @Date 2024-12-05 21:38:40
* @Copyright
*/
@Service
public class ItemKeyManager extends ServiceImpl<ItemKeyDao, ItemKeyEntity> {
}

View File

@ -0,0 +1,43 @@
package net.lab1024.sa.admin.module.business.itemKey.service;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import jakarta.annotation.Resource;
import net.lab1024.sa.admin.module.business.itemKey.dao.ItemKeyDao;
import net.lab1024.sa.admin.module.business.itemKey.domain.entity.ItemKeyEntity;
import net.lab1024.sa.admin.module.business.itemKey.domain.form.ItemKeyQueryForm;
import net.lab1024.sa.admin.module.business.itemKey.domain.vo.ItemKeyVO;
import net.lab1024.sa.base.common.domain.PageResult;
import net.lab1024.sa.base.common.util.SmartPageUtil;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class ItemKeyQueryService {
@Resource
private ItemKeyDao itemKeyDao;
/**
*
*/
public PageResult<ItemKeyVO> queryPage(ItemKeyQueryForm queryForm) {
Page<?> page = SmartPageUtil.convert2PageQuery(queryForm);
List<ItemKeyVO> list = itemKeyDao.queryPage(page, queryForm);
return SmartPageUtil.convert2PageResult(page, list);
}
public ItemKeyEntity queryItemKey(String orderNumber, Long itemId, String propC1) {
LambdaQueryWrapper<ItemKeyEntity> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(ItemKeyEntity::getOrderNumber, orderNumber);
queryWrapper.eq(ItemKeyEntity::getItemId, itemId);
queryWrapper.eq(ItemKeyEntity::getPropC1, propC1);
List<ItemKeyEntity> itemKeys = itemKeyDao.selectList(queryWrapper);
if (CollectionUtils.isEmpty(itemKeys)) {
return null;
}
return itemKeys.get(0);
}
}

View File

@ -0,0 +1,116 @@
package net.lab1024.sa.admin.module.business.itemKey.service;
import java.time.LocalDateTime;
import java.util.List;
import net.lab1024.sa.admin.module.business.itemKey.dao.ItemKeyDao;
import net.lab1024.sa.admin.module.business.itemKey.domain.entity.ItemKeyEntity;
import net.lab1024.sa.admin.module.business.itemKey.domain.form.ItemKeyAddForm;
import net.lab1024.sa.admin.module.business.itemKey.domain.form.ItemKeyQueryForm;
import net.lab1024.sa.admin.module.business.itemKey.domain.form.ItemKeyUpdateForm;
import net.lab1024.sa.admin.module.business.itemKey.domain.vo.ItemKeyVO;
import net.lab1024.sa.admin.module.business.itemKey.manager.ItemKeyManager;
import net.lab1024.sa.base.common.code.UserErrorCode;
import net.lab1024.sa.base.common.util.SmartBeanUtil;
import net.lab1024.sa.base.common.util.SmartPageUtil;
import net.lab1024.sa.base.common.domain.ResponseDTO;
import net.lab1024.sa.base.common.domain.PageResult;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import net.lab1024.sa.base.common.util.SmartRequestUtil;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Service;
import jakarta.annotation.Resource;
import org.springframework.transaction.annotation.Transactional;
/**
* Service
*
* @Author
* @Date 2024-12-05 21:38:40
* @Copyright
*/
@Service
public class ItemKeyService {
@Resource
private ItemKeyDao itemKeyDao;
@Resource
private ItemKeyManager itemKeyManager;
@Resource
private ItemKeyQueryService itemKeyQueryService;
/**
*
*/
@Transactional(rollbackFor = Exception.class)
public ResponseDTO<String> add(ItemKeyAddForm addForm) {
ItemKeyEntity itemKeyEntity = SmartBeanUtil.copy(addForm, ItemKeyEntity.class);
itemKeyDao.insert(itemKeyEntity);
return ResponseDTO.ok();
}
/**
*
*/
@Transactional(rollbackFor = Exception.class)
public ResponseDTO<String> update(ItemKeyUpdateForm updateForm) {
ItemKeyEntity itemKeyEntity = SmartBeanUtil.copy(updateForm, ItemKeyEntity.class);
itemKeyDao.updateById(itemKeyEntity);
return ResponseDTO.ok();
}
/**
*
*/
@Transactional(rollbackFor = Exception.class)
public ResponseDTO<String> batchDelete(List<Long> idList) {
if (CollectionUtils.isEmpty(idList)) {
return ResponseDTO.userErrorParam(UserErrorCode.PARAM_ERROR.getMsg());
}
itemKeyManager.removeBatchByIds(idList);
return ResponseDTO.ok();
}
/**
*
*/
@Transactional(rollbackFor = Exception.class)
public ResponseDTO<String> delete(Long itemKeyId) {
if (null == itemKeyId) {
return ResponseDTO.userErrorParam(UserErrorCode.PARAM_ERROR.getMsg());
}
itemKeyDao.deleteById(itemKeyId);
return ResponseDTO.ok();
}
/**
* itemKey
*
* @param orderNumber
* @param itemId
* @param propC1
* @return ItemKeyEntity
*/
@Transactional(rollbackFor = Exception.class)
public ItemKeyEntity createItemKey(String orderNumber, Long itemId, String propC1) {
ItemKeyEntity itemKey = itemKeyQueryService.queryItemKey(orderNumber, itemId, propC1);
if (itemKey != null) {
return itemKey;
}
itemKey = ItemKeyEntity.builder()
.orderNumber(orderNumber)
.itemId(itemId)
.propC1(propC1)
.createUserId(SmartRequestUtil.getRequestUser().getUserId())
.createUserName(SmartRequestUtil.getRequestUser().getUserName())
.build();
itemKeyDao.insert(itemKey);
return itemKey;
}
}

View File

@ -0,0 +1,22 @@
# 默认是按前端工程文件的 /views/business 文件夹的路径作为前端组件路径,如果你没把生成的 .vue 前端代码放在 /views/business 下,
# 那就根据自己实际情况修改下面 SQL 的 path,component 字段值,避免执行 SQL 后菜单无法访问。
# 如果你一切都是按照默认,那么下面的 SQL 基本不用改
INSERT INTO t_menu ( menu_name, menu_type, parent_id, path, component, frame_flag, cache_flag, visible_flag, disabled_flag, perms_type, create_user_id )
VALUES ( '物料属性', 2, 0, '/item-key/list', '/business/item-key/item-key-list.vue', false, false, true, false, 1, 1 );
# 按菜单名称查询该菜单的 menu_id 作为按钮权限的 父菜单ID 与 功能点关联菜单ID
SET @parent_id = NULL;
SELECT t_menu.menu_id INTO @parent_id FROM t_menu WHERE t_menu.menu_name = '物料属性';
INSERT INTO t_menu ( menu_name, menu_type, parent_id, frame_flag, cache_flag, visible_flag, disabled_flag, perms_type, api_perms, web_perms, context_menu_id, create_user_id )
VALUES ( '查询', 3, @parent_id, false, false, true, false, 1, 'itemKey:query', 'itemKey:query', @parent_id, 1 );
INSERT INTO t_menu ( menu_name, menu_type, parent_id, frame_flag, cache_flag, visible_flag, disabled_flag, perms_type, api_perms, web_perms, context_menu_id, create_user_id )
VALUES ( '添加', 3, @parent_id, false, false, true, false, 1, 'itemKey:add', 'itemKey:add', @parent_id, 1 );
INSERT INTO t_menu ( menu_name, menu_type, parent_id, frame_flag, cache_flag, visible_flag, disabled_flag, perms_type, api_perms, web_perms, context_menu_id, create_user_id )
VALUES ( '更新', 3, @parent_id, false, false, true, false, 1, 'itemKey:update', 'itemKey:update', @parent_id, 1 );
INSERT INTO t_menu ( menu_name, menu_type, parent_id, frame_flag, cache_flag, visible_flag, disabled_flag, perms_type, api_perms, web_perms, context_menu_id, create_user_id )
VALUES ( '删除', 3, @parent_id, false, false, true, false, 1, 'itemKey:delete', 'itemKey:delete', @parent_id, 1 );

View File

@ -4,16 +4,40 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import net.lab1024.sa.admin.module.business.base.item.domain.entity.ItemEntity; import net.lab1024.sa.admin.module.business.base.item.domain.entity.ItemEntity;
import net.lab1024.sa.admin.module.business.base.item.service.ItemQueryService; import net.lab1024.sa.admin.module.business.base.item.service.ItemQueryService;
import net.lab1024.sa.admin.module.business.base.location.dao.LocationDao;
import net.lab1024.sa.admin.module.business.base.location.domain.entity.LocationEntity;
import net.lab1024.sa.admin.module.business.base.location.service.LocationQueryService;
import net.lab1024.sa.admin.module.business.base.stock.dao.StockDao;
import net.lab1024.sa.admin.module.business.base.stock.domain.entity.StockEntity;
import net.lab1024.sa.admin.module.business.base.stock.service.StockQueryService;
import net.lab1024.sa.admin.module.business.inventory.domain.entity.InventoryEntity;
import net.lab1024.sa.admin.module.business.inventory.manager.InventoryManager;
import net.lab1024.sa.admin.module.business.inventory.service.InventoryQueryService;
import net.lab1024.sa.admin.module.business.inventory.service.InventoryService;
import net.lab1024.sa.admin.module.business.itemKey.domain.entity.ItemKeyEntity;
import net.lab1024.sa.admin.module.business.itemKey.manager.ItemKeyManager;
import net.lab1024.sa.admin.module.business.itemKey.service.ItemKeyQueryService;
import net.lab1024.sa.admin.module.business.itemKey.service.ItemKeyService;
import net.lab1024.sa.admin.module.business.receive.asn.domain.entity.AsnEntity;
import net.lab1024.sa.admin.module.business.receive.asn.service.AsnQueryService;
import net.lab1024.sa.admin.module.business.receive.asnDetail.domain.entity.AsnDetailEntity; import net.lab1024.sa.admin.module.business.receive.asnDetail.domain.entity.AsnDetailEntity;
import net.lab1024.sa.admin.module.business.receive.asnDetail.domain.vo.AsnDetailVO; import net.lab1024.sa.admin.module.business.receive.asnDetail.domain.vo.AsnDetailVO;
import net.lab1024.sa.admin.module.business.receive.asnDetail.manager.AsnDetailManager; import net.lab1024.sa.admin.module.business.receive.asnDetail.manager.AsnDetailManager;
import net.lab1024.sa.admin.module.business.receive.asnDetail.service.AsnDetailQueryService; import net.lab1024.sa.admin.module.business.receive.asnDetail.service.AsnDetailQueryService;
import net.lab1024.sa.admin.module.business.receive.asnDetail.service.AsnDetailService; import net.lab1024.sa.admin.module.business.receive.asnDetail.service.AsnDetailService;
import net.lab1024.sa.admin.module.business.task.constant.TaskStatusEnum;
import net.lab1024.sa.admin.module.business.task.constant.TaskTypeEnum;
import net.lab1024.sa.admin.module.business.task.domain.entity.TaskEntity;
import net.lab1024.sa.admin.module.business.task.manager.TaskManager;
import net.lab1024.sa.admin.module.business.task.service.TaskService;
import net.lab1024.sa.admin.util.JoinerResult; import net.lab1024.sa.admin.util.JoinerResult;
import net.lab1024.sa.admin.util.ResponseDTOUtils; import net.lab1024.sa.admin.util.ResponseDTOUtils;
import net.lab1024.sa.base.common.code.UserErrorCode; import net.lab1024.sa.base.common.code.UserErrorCode;
import net.lab1024.sa.base.common.domain.ResponseDTO; import net.lab1024.sa.base.common.domain.ResponseDTO;
import net.lab1024.sa.base.common.util.SmartBigDecimalUtil; import net.lab1024.sa.base.common.util.SmartBigDecimalUtil;
import net.lab1024.sa.base.common.util.SmartRequestUtil;
import net.lab1024.sa.base.module.support.serialnumber.constant.SerialNumberIdEnum;
import net.lab1024.sa.base.module.support.serialnumber.service.SerialNumberService;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@ -27,15 +51,45 @@ public class ReceiveService {
@Resource @Resource
private AsnDetailManager asnDetailManager; private AsnDetailManager asnDetailManager;
@Resource
private TaskManager taskManager;
@Resource
private InventoryManager inventoryManager;
@Resource
private LocationQueryService locationQueryService;
@Resource
private StockQueryService stockQueryService;
@Resource @Resource
private ItemQueryService itemQueryService; private ItemQueryService itemQueryService;
@Resource
private AsnQueryService asnQueryService;
@Resource
private AsnDetailQueryService asnDetailQueryService;
@Resource
private InventoryQueryService inventoryQueryService;
@Resource @Resource
private AsnDetailService asnDetailService; private AsnDetailService asnDetailService;
@Resource
private ItemKeyService itemKeyService;
@Resource @Resource
private AsnDetailQueryService asnDetailQueryService; private TaskService taskService;
@Resource
private InventoryService inventoryService;
@Resource
private SerialNumberService serialNumberService;
/** /**
* *
@ -53,57 +107,115 @@ public class ReceiveService {
return ResponseDTO.userErrorParam(UserErrorCode.PARAM_ERROR.getMsg()); return ResponseDTO.userErrorParam(UserErrorCode.PARAM_ERROR.getMsg());
} }
return batchReceive(asnDetails, null); return batchReceive(asnDetails, null, null);
} }
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public ResponseDTO<String> batchReceive(List<AsnDetailEntity> asnDetails, Long locationId) { public synchronized ResponseDTO<String> batchReceive(List<AsnDetailEntity> asnDetails, String stockCode, String locationCode) {
//消息提示 //消息提示
JoinerResult joiner = JoinerResult.createJoiner(); JoinerResult joiner = JoinerResult.createJoiner();
//查询物料 //查询物料
List<Long> itemIds = asnDetails.stream().map(AsnDetailEntity::getItemId).distinct().toList(); List<Long> itemIds = asnDetails.stream().map(AsnDetailEntity::getItemId).distinct().toList();
Map<Long, ItemEntity> itemMap = itemQueryService.queryItemList(itemIds); Map<Long, ItemEntity> itemMap = itemQueryService.queryItemList(itemIds);
//查询入库单
List<Long> asnIds = asnDetails.stream().map(AsnDetailEntity::getAsnId).distinct().toList();
Map<Long, AsnEntity> asnMap = asnQueryService.queryAsnListToMap(asnIds);
List<AsnDetailEntity> updateToAsnDetail = new ArrayList<>(); List<AsnDetailEntity> updateToAsnDetail = new ArrayList<>();
Set<Long> asnIds = new HashSet<>(); List<TaskEntity> insertToTask = new ArrayList<>();
List<InventoryEntity> insertToInventory = new ArrayList<>();
List<InventoryEntity> updateToInventory = new ArrayList<>();
//库位
LocationEntity dstLocation = locationQueryService.queryByLocationCode(locationCode);
//容器
StockEntity dstStock = stockQueryService.queryByStockCode(stockCode);
for (AsnDetailEntity asnDetail : asnDetails) { for (AsnDetailEntity asnDetail : asnDetails) {
//物料
ItemEntity item = itemMap.get(asnDetail.getItemId()); ItemEntity item = itemMap.get(asnDetail.getItemId());
//入库单
AsnEntity asn = asnMap.get(asnDetail.getAsnId());
if (SmartBigDecimalUtil.subtract(asnDetail.getOrderQuantity(), asnDetail.getReceivedQuantity(), 2).compareTo(BigDecimal.ZERO) == 0) { if (SmartBigDecimalUtil.subtract(asnDetail.getOrderQuantity(), asnDetail.getReceivedQuantity(), 2).compareTo(BigDecimal.ZERO) == 0) {
joiner.getErrorMsg().add(item.getItemCode() + "明细已收货"); joiner.getErrorMsg().add(item.getItemCode() + "明细已收货");
continue; continue;
} }
if (asnDetail.getReceivedQuantity().compareTo(asnDetail.getOrderQuantity()) > 0) { if (asnDetail.getReceivedQuantity().compareTo(asnDetail.getOrderQuantity()) > 0) {
joiner.getErrorMsg().add(item.getItemCode() + "收货数量不能大于订单数量"); joiner.getErrorMsg().add(item.getItemCode() + "收货数量不能大于订单数量");
continue; continue;
} }
if (locationId == null || locationId <= 0) {
//默认库位
locationId = 1L;
}
//更新入库明细 //更新入库明细
asnDetail.setReceivedQuantity(SmartBigDecimalUtil.subtract(asnDetail.getOrderQuantity(), asnDetail.getReceivedQuantity(), 2)); asnDetail.setReceivedQuantity(SmartBigDecimalUtil.subtract(asnDetail.getOrderQuantity(), asnDetail.getReceivedQuantity(), 2));
updateToAsnDetail.add(asnDetail); updateToAsnDetail.add(asnDetail);
//获取itemKey
ItemKeyEntity itemKey = itemKeyService.createItemKey(asn.getAsnNumber(), asnDetail.getItemId(), asnDetail.getPropC1());
//生成入库记录
TaskEntity task = taskService.createTask(serialNumberService.generate(SerialNumberIdEnum.TASK), TaskStatusEnum.CREATED.getValue(), TaskTypeEnum.ASN.getValue(), asnDetail.getOrderQuantity(), itemKey.getItemKeyId(), asnDetail.getAsnDetailId(), null, null, dstStock, null, dstLocation, null, null);
insertToTask.add(task);
//生成库存
InventoryEntity inventory = inventoryQueryService.queryInventory(itemKey.getItemKeyId());
if (inventory == null) {
inventory = inventoryService.createInventory(itemKey.getItemKeyId(), dstLocation == null ? null : dstLocation.getLocationId(), dstStock == null ? null : dstStock.getStockId(), asnDetail.getOrderQuantity());
insertToInventory.add(inventory);
} else {
//库存数量累加
inventory.setQuantity(SmartBigDecimalUtil.add(inventory.getQuantity(), asnDetail.getOrderQuantity(), 2));
updateToInventory.add(inventory);
}
joiner.getSussMsg().add(item.getItemCode() + "收货成功"); joiner.getSussMsg().add(item.getItemCode() + "收货成功");
asnIds.add(asnDetail.getAsnId());
} }
//生成itemKey //批量操作
batchUpdateOrInsert(updateToAsnDetail, insertToTask, insertToInventory, updateToInventory);
//生成入库记录 //刷新入库单
//生成库存
//批量更新入库明细
if (CollectionUtils.isNotEmpty(updateToAsnDetail)) {
asnDetailManager.updateBatchById(updateToAsnDetail);
}
//更新入库单
asnIds.forEach(asnDetailService::refreshAsn); asnIds.forEach(asnDetailService::refreshAsn);
return ResponseDTOUtils.buildResponseDTO(joiner); return ResponseDTOUtils.buildResponseDTO(joiner);
} }
/**
*
*
* @param updateToAsnDetail
* @param insertToTask task
* @param insertToInventory
* @param updateToInventory
*/
private void batchUpdateOrInsert(List<AsnDetailEntity> updateToAsnDetail, List<TaskEntity> insertToTask, List<InventoryEntity> insertToInventory, List<InventoryEntity> updateToInventory) {
//批量更新入库明细
if (CollectionUtils.isNotEmpty(updateToAsnDetail)) {
asnDetailManager.updateBatchById(updateToAsnDetail);
}
//批量新增入库记录
if (CollectionUtils.isNotEmpty(insertToTask)) {
taskManager.saveBatch(insertToTask);
}
//批量新增库存
if (CollectionUtils.isNotEmpty(insertToInventory)) {
inventoryManager.saveBatch(insertToInventory);
}
//批量更新库存
if (CollectionUtils.isNotEmpty(updateToInventory)) {
inventoryManager.updateBatchById(updateToInventory);
}
}
} }

View File

@ -8,6 +8,7 @@ import net.lab1024.sa.admin.module.business.base.address.service.AddressQuerySer
import net.lab1024.sa.admin.module.business.base.area.domain.entity.AreaEntity; import net.lab1024.sa.admin.module.business.base.area.domain.entity.AreaEntity;
import net.lab1024.sa.admin.module.business.base.customer.domain.entity.CustomerEntity; import net.lab1024.sa.admin.module.business.base.customer.domain.entity.CustomerEntity;
import net.lab1024.sa.admin.module.business.base.customer.service.CustomerQueryService; import net.lab1024.sa.admin.module.business.base.customer.service.CustomerQueryService;
import net.lab1024.sa.admin.module.business.base.location.domain.entity.LocationEntity;
import net.lab1024.sa.admin.module.business.base.location.domain.vo.LocationVO; import net.lab1024.sa.admin.module.business.base.location.domain.vo.LocationVO;
import net.lab1024.sa.admin.module.business.receive.asn.dao.AsnDao; import net.lab1024.sa.admin.module.business.receive.asn.dao.AsnDao;
import net.lab1024.sa.admin.module.business.receive.asn.domain.entity.AsnEntity; import net.lab1024.sa.admin.module.business.receive.asn.domain.entity.AsnEntity;
@ -20,6 +21,7 @@ import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -97,5 +99,21 @@ public class AsnQueryService {
return asnDao.selectList(queryWrapper); return asnDao.selectList(queryWrapper);
} }
/**
*
*
* @param idList
* @return Map<String, AsnEntity>
*/
public Map<Long, AsnEntity> queryAsnListToMap(List<Long> idList) {
if (CollectionUtils.isEmpty(idList)) {
return Collections.emptyMap();
}
List<AsnEntity> asnList = queryAsnList(idList);
return asnList.stream()
.collect(Collectors.toMap(AsnEntity::getAsnId, asn -> asn, (existing, replacement) -> existing));
}
} }

View File

@ -44,6 +44,16 @@ public class AsnDetailEntity {
*/ */
private Long itemId; private Long itemId;
/**
*
*/
private String propC1;
/**
*
*/
private String propC2;
/** /**
* *
*/ */

View File

@ -40,6 +40,12 @@ public class AsnDetailVO {
@Schema(description = "物料名称") @Schema(description = "物料名称")
private String itemName; private String itemName;
@Schema(description = "批次号")
private String propC1;
@Schema(description = "序列号")
private String propC2;
@Schema(description = "订单数量") @Schema(description = "订单数量")
private BigDecimal orderQuantity; private BigDecimal orderQuantity;

View File

@ -0,0 +1,60 @@
package net.lab1024.sa.admin.module.business.task.constant;
import lombok.AllArgsConstructor;
import lombok.Getter;
import net.lab1024.sa.base.common.enumeration.BaseEnum;
@AllArgsConstructor
@Getter
public enum TaskStatusEnum implements BaseEnum {
/**
* 1
*/
CREATED("CREATED", "已创建"),
/**
* 2
*/
APPROVING("APPROVING", "已提交"),
/**
* 3
*/
APPROVED("APPROVED", "已审核"),
/**
* 4
*/
IN_PROGRESS("IN_PROGRESS", "入库中"),
/**
* 5
*/
COMPLETED("COMPLETED", "已完成"),
/**
* 6
*/
CANCELLED("CANCELLED", "已取消"),
;
private final String value;
private final String desc;
/**
* value desc
* @param value
* @return null
*/
public static String getDescByValue(String value) {
for (TaskStatusEnum status : TaskStatusEnum.values()) {
if (status.getValue().equals(value)) {
return status.getDesc();
}
}
return null;
}
}

View File

@ -0,0 +1,42 @@
package net.lab1024.sa.admin.module.business.task.constant;
import lombok.AllArgsConstructor;
import lombok.Getter;
import net.lab1024.sa.base.common.enumeration.BaseEnum;
/**
*
*
* @Author 1024:
* @Date 2021-10-25 20:26:54
* @Wechat zhuoda1024
* @Email lab1024@163.com
* @Copyright <a href="https://1024lab.net">1024</a>
*/
@AllArgsConstructor
@Getter
public enum TaskTypeEnum implements BaseEnum {
/**
* 1
*/
ASN("ASN", "入库"),
/**
* 2
*/
PICK("RETURN", "PICK"),
/**
* 3
*/
STOCK("STOCK", "盘点"),
;
private final String value;
private final String desc;
}

View File

@ -0,0 +1,71 @@
package net.lab1024.sa.admin.module.business.task.controller;
import net.lab1024.sa.admin.module.business.task.domain.form.TaskAddForm;
import net.lab1024.sa.admin.module.business.task.domain.form.TaskQueryForm;
import net.lab1024.sa.admin.module.business.task.domain.form.TaskUpdateForm;
import net.lab1024.sa.admin.module.business.task.domain.vo.TaskVO;
import net.lab1024.sa.admin.module.business.task.service.TaskQueryService;
import net.lab1024.sa.admin.module.business.task.service.TaskService;
import net.lab1024.sa.base.common.domain.ValidateList;
import org.springframework.web.bind.annotation.*;
import net.lab1024.sa.base.common.domain.ResponseDTO;
import net.lab1024.sa.base.common.domain.PageResult;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import cn.dev33.satoken.annotation.SaCheckPermission;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
/**
* Task Controller
*
* @Author
* @Date 2024-12-03 17:08:30
* @Copyright
*/
@RestController
@Tag(name = "Task任务")
public class TaskController {
@Resource
private TaskService taskService;
@Resource
private TaskQueryService taskQueryService;
@Operation(summary = "分页查询 @author 霍锦")
@PostMapping("/task/queryPage")
@SaCheckPermission("task:query")
public ResponseDTO<PageResult<TaskVO>> queryPage(@RequestBody @Valid TaskQueryForm queryForm) {
return ResponseDTO.ok(taskQueryService.queryPage(queryForm));
}
@Operation(summary = "添加 @author 霍锦")
@PostMapping("/task/add")
@SaCheckPermission("task:add")
public ResponseDTO<String> add(@RequestBody @Valid TaskAddForm addForm) {
return taskService.add(addForm);
}
@Operation(summary = "更新 @author 霍锦")
@PostMapping("/task/update")
@SaCheckPermission("task:update")
public ResponseDTO<String> update(@RequestBody @Valid TaskUpdateForm updateForm) {
return taskService.update(updateForm);
}
@Operation(summary = "批量删除 @author 霍锦")
@PostMapping("/task/batchDelete")
@SaCheckPermission("task:batchDelete")
public ResponseDTO<String> batchDelete(@RequestBody ValidateList<Long> idList) {
return taskService.batchDelete(idList);
}
@Operation(summary = "单个删除 @author 霍锦")
@GetMapping("/task/delete")
@SaCheckPermission("task:delete")
public ResponseDTO<String> delete(@RequestParam Long taskId) {
return taskService.delete(taskId);
}
}

View File

@ -0,0 +1,33 @@
package net.lab1024.sa.admin.module.business.task.dao;
import java.util.List;
import net.lab1024.sa.admin.module.business.task.domain.entity.TaskEntity;
import net.lab1024.sa.admin.module.business.task.domain.form.TaskQueryForm;
import net.lab1024.sa.admin.module.business.task.domain.vo.TaskVO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Component;
/**
* Task Dao
*
* @Author
* @Date 2024-12-03 17:08:30
* @Copyright
*/
@Mapper
public interface TaskDao extends BaseMapper<TaskEntity> {
/**
*
*
* @param page
* @param queryForm
* @return
*/
List<TaskVO> queryPage(Page page, @Param("queryForm") TaskQueryForm queryForm);
}

View File

@ -0,0 +1,160 @@
package net.lab1024.sa.admin.module.business.task.domain.entity;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* Task
*
* @Author
* @Date 2024-12-03 17:08:30
* @Copyright
*/
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@TableName("t_task")
public class TaskEntity {
/**
* id
*/
@TableId(type = IdType.AUTO)
private Long taskId;
/**
*
*/
private String billCode;
/**
*
*/
private String status;
/**
*
*/
private String taskType;
/**
*
*/
private BigDecimal planQty;
/**
*
*/
private BigDecimal moveQty;
/**
*
*/
private Long itemKeyId;
/**
*
*/
private Long asnDetailId;
/**
*
*/
private Long pickDetailId;
/**
*
*/
private Long srcStockId;
/**
*
*/
private String srcStockCode;
/**
*
*/
private Long dstStockId;
/**
*
*/
private String dstStockCode;
/**
*
*/
private Long srcLocationId;
/**
*
*/
private String srcLocationCode;
/**
*
*/
private Long dstLocationId;
/**
*
*/
private String dstLocationCode;
/**
* ID
*/
private Long inventoryId;
/**
* agvID
*/
private Long agvTaskId;
/**
*
*/
private Long beSkip;
/**
*
*/
@TableField(fill = FieldFill.INSERT)
private LocalDateTime createTime;
/**
*
*/
private LocalDateTime endTime;
/**
* ID
*/
private Long createUserId;
/**
*
*/
private String createUserName;
/**
*
*/
@TableField(fill = FieldFill.INSERT_UPDATE)
private LocalDateTime updateTime;
}

View File

@ -0,0 +1,21 @@
package net.lab1024.sa.admin.module.business.task.domain.form;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import java.time.LocalDateTime;
import lombok.Data;
/**
* Task
*
* @Author
* @Date 2024-12-03 17:08:30
* @Copyright
*/
@Data
public class TaskAddForm {
}

View File

@ -0,0 +1,23 @@
package net.lab1024.sa.admin.module.business.task.domain.form;
import net.lab1024.sa.base.common.domain.PageParam;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* Task
*
* @Author
* @Date 2024-12-03 17:08:30
* @Copyright
*/
@Data
@EqualsAndHashCode(callSuper = false)
public class TaskQueryForm extends PageParam {
@Schema(description = "入库单")
private Long asnId;
}

View File

@ -0,0 +1,22 @@
package net.lab1024.sa.admin.module.business.task.domain.form;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
/**
* Task
*
* @Author
* @Date 2024-12-03 17:08:30
* @Copyright
*/
@Data
public class TaskUpdateForm {
@Schema(description = "任务id", requiredMode = Schema.RequiredMode.REQUIRED)
@NotNull(message = "任务id 不能为空")
private Long taskId;
}

View File

@ -0,0 +1,95 @@
package net.lab1024.sa.admin.module.business.task.domain.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import lombok.Data;
/**
* Task VO
*
* @Author
* @Date 2024-12-03 17:08:30
* @Copyright
*/
@Data
public class TaskVO {
@Schema(description = "任务id")
private Long taskId;
@Schema(description = "任务号")
private String billCode;
@Schema(description = "任务状态")
private String status;
@Schema(description = "任务类型")
private String taskType;
@Schema(description = "待拣货数量")
private BigDecimal planQty;
@Schema(description = "已拣货数量")
private BigDecimal moveQty;
@Schema(description = "物料序号")
private Long itemKeyId;
@Schema(description = "收货明细序号")
private Long asnDetailId;
@Schema(description = "发货明细序号")
private Long pickDetailId;
@Schema(description = "原容器")
private Long srcStockId;
@Schema(description = "原容器编码")
private String srcStockCode;
@Schema(description = "目标容器")
private Long dstStockId;
@Schema(description = "原点位")
private Long srcLocationId;
@Schema(description = "目标点位")
private Long dstLocationId;
@Schema(description = "目标库位编码")
private String dstLocationCode;
@Schema(description = "原库位编码")
private String srcLocationCode;
@Schema(description = "目标容器编码")
private String dstStockCode;
@Schema(description = "库存ID")
private Long inventoryId;
@Schema(description = "agvID")
private Long agvTaskId;
@Schema(description = "跳过")
private Long beSkip;
@Schema(description = "创建时间")
private LocalDateTime createTime;
@Schema(description = "完成时间")
private LocalDateTime endTime;
@Schema(description = "创建人ID")
private Long createUserId;
@Schema(description = "创建人")
private String createUserName;
@Schema(description = "更新时间")
private LocalDateTime updateTime;
}

View File

@ -0,0 +1,20 @@
package net.lab1024.sa.admin.module.business.task.manager;
import net.lab1024.sa.admin.module.business.task.domain.entity.TaskEntity;
import net.lab1024.sa.admin.module.business.task.dao.TaskDao;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
/**
* Task Manager
*
* @Author
* @Date 2024-12-03 17:08:30
* @Copyright
*/
@Service
public class TaskManager extends ServiceImpl<TaskDao, TaskEntity> {
}

View File

@ -0,0 +1,30 @@
package net.lab1024.sa.admin.module.business.task.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import jakarta.annotation.Resource;
import net.lab1024.sa.admin.module.business.task.dao.TaskDao;
import net.lab1024.sa.admin.module.business.task.domain.form.TaskQueryForm;
import net.lab1024.sa.admin.module.business.task.domain.vo.TaskVO;
import net.lab1024.sa.base.common.domain.PageResult;
import net.lab1024.sa.base.common.util.SmartPageUtil;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class TaskQueryService {
@Resource
private TaskDao taskDao;
/**
*
*/
public PageResult<TaskVO> queryPage(TaskQueryForm queryForm) {
Page<?> page = SmartPageUtil.convert2PageQuery(queryForm);
List<TaskVO> list = taskDao.queryPage(page, queryForm);
return SmartPageUtil.convert2PageResult(page, list);
}
}

View File

@ -0,0 +1,134 @@
package net.lab1024.sa.admin.module.business.task.service;
import java.math.BigDecimal;
import java.util.List;
import net.lab1024.sa.admin.module.business.base.location.domain.entity.LocationEntity;
import net.lab1024.sa.admin.module.business.base.stock.domain.entity.StockEntity;
import net.lab1024.sa.admin.module.business.task.dao.TaskDao;
import net.lab1024.sa.admin.module.business.task.domain.entity.TaskEntity;
import net.lab1024.sa.admin.module.business.task.domain.form.TaskAddForm;
import net.lab1024.sa.admin.module.business.task.domain.form.TaskQueryForm;
import net.lab1024.sa.admin.module.business.task.domain.form.TaskUpdateForm;
import net.lab1024.sa.admin.module.business.task.domain.vo.TaskVO;
import net.lab1024.sa.admin.module.business.task.manager.TaskManager;
import net.lab1024.sa.base.common.code.UserErrorCode;
import net.lab1024.sa.base.common.util.SmartBeanUtil;
import net.lab1024.sa.base.common.util.SmartPageUtil;
import net.lab1024.sa.base.common.domain.ResponseDTO;
import net.lab1024.sa.base.common.domain.PageResult;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import net.lab1024.sa.base.common.util.SmartRequestUtil;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Service;
import jakarta.annotation.Resource;
import org.springframework.transaction.annotation.Transactional;
/**
* Task Service
*
* @Author
* @Date 2024-12-03 17:08:30
* @Copyright
*/
@Service
public class TaskService {
@Resource
private TaskDao taskDao;
@Resource
private TaskManager taskManager;
/**
*
*/
@Transactional(rollbackFor = Exception.class)
public ResponseDTO<String> add(TaskAddForm addForm) {
TaskEntity taskEntity = SmartBeanUtil.copy(addForm, TaskEntity.class);
taskDao.insert(taskEntity);
return ResponseDTO.ok();
}
/**
*
*/
@Transactional(rollbackFor = Exception.class)
public ResponseDTO<String> update(TaskUpdateForm updateForm) {
TaskEntity taskEntity = SmartBeanUtil.copy(updateForm, TaskEntity.class);
taskDao.updateById(taskEntity);
return ResponseDTO.ok();
}
/**
*
*/
@Transactional(rollbackFor = Exception.class)
public ResponseDTO<String> batchDelete(List<Long> idList) {
if (CollectionUtils.isEmpty(idList)) {
return ResponseDTO.userErrorParam(UserErrorCode.PARAM_ERROR.getMsg());
}
taskManager.removeBatchByIds(idList);
return ResponseDTO.ok();
}
/**
*
*/
@Transactional(rollbackFor = Exception.class)
public ResponseDTO<String> delete(Long taskId) {
if (null == taskId) {
return ResponseDTO.userErrorParam(UserErrorCode.PARAM_ERROR.getMsg());
}
taskDao.deleteById(taskId);
return ResponseDTO.ok();
}
/**
* Task
*
* @param orderNumber
* @param status
* @param taskType
* @param planQty
* @param itemKeyId
* @param asnDetailId
* @param pickDetailId
* @param srcStock
* @param dstStock
* @param srcLocation
* @param dstLocation
* @param inventoryId ID
* @param agvTaskId AGVID
* @return TaskEntity
*/
public TaskEntity createTask(String orderNumber, String status, String taskType, BigDecimal planQty, Long itemKeyId, Long asnDetailId, Long pickDetailId, StockEntity srcStock, StockEntity dstStock, LocationEntity srcLocation, LocationEntity dstLocation, Long inventoryId, Long agvTaskId) {
return TaskEntity.builder()
.billCode(orderNumber)
.status(status)
.taskType(taskType)
.planQty(planQty)
.moveQty(BigDecimal.ZERO)
.itemKeyId(itemKeyId)
.asnDetailId(asnDetailId)
.pickDetailId(pickDetailId)
.srcStockId(srcStock == null ? null : srcStock.getStockId())
.srcStockCode(srcStock == null ? null : srcStock.getStockCode())
.dstStockId(dstStock == null ? null : dstStock.getStockId())
.dstStockCode(dstStock == null ? null : dstStock.getStockCode())
.srcLocationId(srcLocation == null ? null : srcLocation.getLocationId())
.srcLocationCode(srcLocation == null ? null : srcLocation.getLocationCode())
.dstLocationId(dstLocation == null ? null : dstLocation.getLocationId())
.dstLocationCode(dstLocation == null ? null : dstLocation.getLocationCode())
.inventoryId(inventoryId)
.agvTaskId(agvTaskId)
.beSkip(0L)
.createUserId(SmartRequestUtil.getRequestUser().getUserId())
.createUserName(SmartRequestUtil.getRequestUser().getUserName())
.build();
}
}

View File

@ -0,0 +1,22 @@
# 默认是按前端工程文件的 /views/business 文件夹的路径作为前端组件路径,如果你没把生成的 .vue 前端代码放在 /views/business 下,
# 那就根据自己实际情况修改下面 SQL 的 path,component 字段值,避免执行 SQL 后菜单无法访问。
# 如果你一切都是按照默认,那么下面的 SQL 基本不用改
INSERT INTO t_menu ( menu_name, menu_type, parent_id, path, component, frame_flag, cache_flag, visible_flag, disabled_flag, perms_type, create_user_id )
VALUES ( 'Task任务', 2, 0, '/task/list', '/business/task/task-list.vue', false, false, true, false, 1, 1 );
# 按菜单名称查询该菜单的 menu_id 作为按钮权限的 父菜单ID 与 功能点关联菜单ID
SET @parent_id = NULL;
SELECT t_menu.menu_id INTO @parent_id FROM t_menu WHERE t_menu.menu_name = 'Task任务';
INSERT INTO t_menu ( menu_name, menu_type, parent_id, frame_flag, cache_flag, visible_flag, disabled_flag, perms_type, api_perms, web_perms, context_menu_id, create_user_id )
VALUES ( '查询', 3, @parent_id, false, false, true, false, 1, 'task:query', 'task:query', @parent_id, 1 );
INSERT INTO t_menu ( menu_name, menu_type, parent_id, frame_flag, cache_flag, visible_flag, disabled_flag, perms_type, api_perms, web_perms, context_menu_id, create_user_id )
VALUES ( '添加', 3, @parent_id, false, false, true, false, 1, 'task:add', 'task:add', @parent_id, 1 );
INSERT INTO t_menu ( menu_name, menu_type, parent_id, frame_flag, cache_flag, visible_flag, disabled_flag, perms_type, api_perms, web_perms, context_menu_id, create_user_id )
VALUES ( '更新', 3, @parent_id, false, false, true, false, 1, 'task:update', 'task:update', @parent_id, 1 );
INSERT INTO t_menu ( menu_name, menu_type, parent_id, frame_flag, cache_flag, visible_flag, disabled_flag, perms_type, api_perms, web_perms, context_menu_id, create_user_id )
VALUES ( '删除', 3, @parent_id, false, false, true, false, 1, 'task:delete', 'task:delete', @parent_id, 1 );

View File

@ -0,0 +1,27 @@
<?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="net.lab1024.sa.admin.module.business.inventory.dao.InventoryDao">
<!-- 查询结果列 -->
<sql id="base_columns">
t_inventory.inventory_id,
t_inventory.item_key_id,
t_inventory.location_id,
t_inventory.stock_id,
t_inventory.quantity,
t_inventory.queued_quantity,
t_inventory.create_time,
t_inventory.create_user_id,
t_inventory.create_user_name,
t_inventory.update_time
</sql>
<!-- 分页查询 -->
<select id="queryPage" resultType="net.lab1024.sa.admin.module.business.inventory.domain.vo.InventoryVO">
SELECT
<include refid="base_columns"/>
FROM t_inventory
</select>
</mapper>

View File

@ -0,0 +1,32 @@
<?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="net.lab1024.sa.admin.module.business.itemKey.dao.ItemKeyDao">
<!-- 查询结果列 -->
<sql id="base_columns">
t_item_key.item_key_id,
t_item_key.order_number,
t_item_key.item_id,
t_item_key.prop_c1,
t_item_key.prop_c2,
t_item_key.prop_c3,
t_item_key.prop_c4,
t_item_key.prop_c5,
t_item_key.prop_c6,
t_item_key.prop_d1,
t_item_key.prop_d2,
t_item_key.create_user_id,
t_item_key.create_user_name,
t_item_key.create_time,
t_item_key.update_time
</sql>
<!-- 分页查询 -->
<select id="queryPage" resultType="net.lab1024.sa.admin.module.business.itemKey.domain.vo.ItemKeyVO">
SELECT
<include refid="base_columns"/>
FROM t_item_key
</select>
</mapper>

View File

@ -0,0 +1,48 @@
<?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="net.lab1024.sa.admin.module.business.task.dao.TaskDao">
<!-- 查询结果列 -->
<sql id="base_columns">
t_task.task_id,
t_task.bill_code,
t_task.status,
t_task.task_type,
t_task.plan_qty,
t_task.move_qty,
t_task.item_key_id,
t_task.asn_detail_id,
t_task.pick_detail_id,
t_task.src_stock_id,
t_task.src_stock_code,
t_task.dst_stock_id,
t_task.src_location_id,
t_task.dst_location_id,
t_task.dst_location_code,
t_task.src_location_code,
t_task.dst_stock_code,
t_task.inventory_id,
t_task.agv_task_id,
t_task.be_skip,
t_task.create_time,
t_task.end_time,
t_task.create_user_id,
t_task.create_user_name,
t_task.update_time
</sql>
<!-- 分页查询 -->
<select id="queryPage" resultType="net.lab1024.sa.admin.module.business.task.domain.vo.TaskVO">
SELECT
<include refid="base_columns"/>
FROM t_task
<where>
<!--入库单-->
<if test="queryForm.asnId != null ">
AND t_task.asn_detail_id=#{queryForm.asnId}
</if>
</where>
</select>
</mapper>

View File

@ -25,6 +25,8 @@ public enum SerialNumberIdEnum implements BaseEnum {
ASN(4, "入库单编号"), ASN(4, "入库单编号"),
TASK(5, "任务编号"),
; ;
private final Integer serialNumberId; private final Integer serialNumberId;