diff --git a/sql/mysql/mesdata.sql b/sql/mysql/mesdata.sql index a5045dd74..069aecea1 100644 --- a/sql/mysql/mesdata.sql +++ b/sql/mysql/mesdata.sql @@ -83,4 +83,74 @@ CREATE TABLE `mes_produce_report_detail` PRIMARY KEY (`id`) USING BTREE ) ENGINE=InnoDB AUTO_INCREMENT=91 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC COMMENT='生产报工明细'; +CREATE TABLE `iot_iot_organization` +( + `id` bigint NOT NULL AUTO_INCREMENT COMMENT '组织id', + `name` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '组织名称', + `parent_id` bigint NOT NULL DEFAULT '0' COMMENT '父组织id', + `sort` int NOT NULL DEFAULT '0' COMMENT '显示顺序', + `worker_user_id` bigint DEFAULT NULL COMMENT '负责人/工人', + `org_id` bigint DEFAULT NULL COMMENT '绑定工位id', + + `status` tinyint NOT NULL COMMENT '组织状态', + `org_class` tinyint NOT NULL COMMENT '组织等级', + `machine_type` tinyint NOT NULL COMMENT '机台类型', + `device_type` tinyint NOT NULL COMMENT '设备类型', + + `creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT '' COMMENT '创建者', + `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + `updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT '' COMMENT '更新者', + `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', + `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除', + `tenant_id` bigint NOT NULL DEFAULT '0' COMMENT '租户编号', + PRIMARY KEY (`id`) USING BTREE +) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC COMMENT='IOT组织表'; + + +CREATE TABLE `iot_device` +( + `id` bigint NOT NULL AUTO_INCREMENT COMMENT 'ID', + `process_instance_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '流程实例的编号', + `work_team_id` bigint NOT NULL COMMENT '组别ID', + `group_id` bigint NOT NULL COMMENT '班组ID', + `report_date` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '报工日期', + `status` tinyint NOT NULL COMMENT '状态', + `group_type` tinyint NOT NULL COMMENT '白班/夜班', + + `remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT '' COMMENT '备注', + `is_enable` bit(1) NOT NULL DEFAULT b'1' COMMENT '是否启用', + `creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT '' COMMENT '创建者', + `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + `updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT '' COMMENT '更新者', + `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', + `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除', + `tenant_id` bigint DEFAULT NULL COMMENT '租户id', + PRIMARY KEY (`id`) USING BTREE +) ENGINE=InnoDB AUTO_INCREMENT=91 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC COMMENT='物联设备表'; +CREATE TABLE `iot_device_attribute` +( + `id` bigint NOT NULL AUTO_INCREMENT COMMENT 'ID', + `report_id` bigint DEFAULT NULL COMMENT '报工单id', + `plan_id` bigint NOT NULL COMMENT '生产计划ID', + `product_id` bigint NOT NULL COMMENT '产品ID', + `user_id` bigint NOT NULL COMMENT '用户ID', + `org_id` bigint NOT NULL COMMENT '组织ID', + `quality_number` decimal(24, 6) DEFAULT NULL COMMENT '成品数量', + `waste_number` decimal(24, 6) DEFAULT NULL COMMENT '废品数量', + `total_number` decimal(24, 6) DEFAULT NULL COMMENT '废品数量', + `quality_rate` decimal(24, 6) DEFAULT NULL COMMENT '成品率', + `waste_reason` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT '' COMMENT '备注', + `report_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '计件时间', + `total_time` decimal(24, 6) DEFAULT NULL COMMENT '总时长', + `package_number` decimal(24, 6) DEFAULT NULL COMMENT '打包数量', + `remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT '' COMMENT '备注', + `is_enable` bit(1) NOT NULL DEFAULT b'1' COMMENT '是否启用', + `creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT '' COMMENT '创建者', + `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + `updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT '' COMMENT '更新者', + `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', + `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除', + `tenant_id` bigint DEFAULT NULL COMMENT '租户id', + PRIMARY KEY (`id`) USING BTREE +) ENGINE=InnoDB AUTO_INCREMENT=91 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC COMMENT='设备属性表'; \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/product/ErpProductController.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/product/ErpProductController.java index aba64d8d8..876755eaf 100644 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/product/ErpProductController.java +++ b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/product/ErpProductController.java @@ -11,6 +11,7 @@ import cn.iocoder.yudao.module.erp.controller.admin.product.vo.product.ErpProduc import cn.iocoder.yudao.module.erp.controller.admin.product.vo.product.ErpProductRespVO; import cn.iocoder.yudao.module.erp.controller.admin.product.vo.product.ProductSaveReqVO; import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductDO; +import cn.iocoder.yudao.module.erp.framework.bean.ProductTypeEnum; import cn.iocoder.yudao.module.erp.service.product.ErpProductService; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; @@ -78,10 +79,20 @@ public class ErpProductController { return success(productService.getProductVOPage(pageReqVO)); } - @GetMapping("/simple-list") + @GetMapping("/simple-list-product") @Operation(summary = "获得产品精简列表", description = "只包含被开启的产品,主要用于前端的下拉选项") public CommonResult> getProductSimpleList() { - List list = productService.getProductVOListByStatus(CommonStatusEnum.ENABLE.getStatus()); + List list = productService.getProductVOListByCategory(ProductTypeEnum.PRODUCT.getTypeId()); + return success(convertList(list, product -> new ErpProductRespVO().setId(product.getId()) + .setName(product.getName()).setBarCode(product.getBarCode()) + .setCategoryId(product.getCategoryId()).setCategoryName(product.getCategoryName()) + .setUnitId(product.getUnitId()).setUnitName(product.getUnitName()) + .setPurchasePrice(product.getPurchasePrice()).setSalePrice(product.getSalePrice()).setMinPrice(product.getMinPrice()))); + } + @GetMapping("/simple-list-item") + @Operation(summary = "获得原料精简列表", description = "只包含被开启的原料,主要用于前端的下拉选项") + public CommonResult> getItemSimpleList() { + List list = productService.getProductVOListByCategory(ProductTypeEnum.ITEM.getTypeId()); return success(convertList(list, product -> new ErpProductRespVO().setId(product.getId()) .setName(product.getName()).setBarCode(product.getBarCode()) .setCategoryId(product.getCategoryId()).setCategoryName(product.getCategoryName()) diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/product/ErpProductMapper.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/product/ErpProductMapper.java index ff491fe22..1e0eb261e 100644 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/product/ErpProductMapper.java +++ b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/dal/mysql/product/ErpProductMapper.java @@ -1,5 +1,6 @@ package cn.iocoder.yudao.module.erp.dal.mysql.product; +import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; 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; @@ -36,5 +37,9 @@ public interface ErpProductMapper extends BaseMapperX { default List selectListByStatus(Integer status) { return selectList(ErpProductDO::getStatus, status); } + default List selectListByCategoryId(Integer categoryId) { + return selectList(ErpProductDO::getStatus, CommonStatusEnum.ENABLE.getStatus(), + ErpProductDO::getCategoryId, categoryId); + } } \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/framework/bean/ProductTypeEnum.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/framework/bean/ProductTypeEnum.java new file mode 100644 index 000000000..5817c4260 --- /dev/null +++ b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/framework/bean/ProductTypeEnum.java @@ -0,0 +1,34 @@ +package cn.iocoder.yudao.module.erp.framework.bean; + +import cn.hutool.core.util.ObjUtil; +import cn.iocoder.yudao.framework.common.core.IntArrayValuable; +import lombok.AllArgsConstructor; +import lombok.Getter; + +import java.util.Arrays; + +@Getter +@AllArgsConstructor +public enum ProductTypeEnum implements IntArrayValuable { + + ITEM(1, "原料"), + PRODUCT(2, "产品"); + + public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(ProductTypeEnum::getTypeId).toArray(); + + /** + * 值 + */ + private final Integer typeId; + /** + * 名 + */ + private final String name; + + @Override + public int[] array() { + return ARRAYS; + } + + +} \ No newline at end of file diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/product/ErpProductService.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/product/ErpProductService.java index 6add0ed5f..0869629f0 100644 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/product/ErpProductService.java +++ b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/product/ErpProductService.java @@ -66,7 +66,7 @@ public interface ErpProductService { * @return 产品 VO 列表 */ List getProductVOListByStatus(Integer status); - + List getProductVOListByCategory(Integer categoryId); /** * 获得产品 VO 列表 * diff --git a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/product/ErpProductServiceImpl.java b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/product/ErpProductServiceImpl.java index f3c3ac83c..1fd99d110 100644 --- a/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/product/ErpProductServiceImpl.java +++ b/yudao-module-erp/yudao-module-erp-biz/src/main/java/cn/iocoder/yudao/module/erp/service/product/ErpProductServiceImpl.java @@ -107,6 +107,11 @@ public class ErpProductServiceImpl implements ErpProductService { List list = productMapper.selectListByStatus(status); return buildProductVOList(list); } + @Override + public List getProductVOListByCategory(Integer categoryId) { + List list = productMapper.selectListByCategoryId(categoryId); + return buildProductVOList(list); + } @Override public List getProductVOList(Collection ids) { diff --git a/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/bom/vo/BomDetailRespVO.java b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/bom/vo/BomDetailRespVO.java index 7168b49bc..6200558a7 100644 --- a/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/bom/vo/BomDetailRespVO.java +++ b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/bom/vo/BomDetailRespVO.java @@ -39,7 +39,7 @@ public class BomDetailRespVO { @Schema(description = "用量", requiredMode = Schema.RequiredMode.REQUIRED) @ExcelProperty("用量") - private BigDecimal usage; + private BigDecimal usageNumber; @Schema(description = "损耗率%") @ExcelProperty("损耗率%") diff --git a/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/task/TaskController.java b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/task/TaskController.java index e6defd1b6..f1f97e94c 100644 --- a/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/task/TaskController.java +++ b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/task/TaskController.java @@ -108,7 +108,7 @@ public class TaskController { @Operation(summary = "获得生产任务单明细分页") @Parameter(name = "taskId", description = "task ID") @PreAuthorize("@ss.hasPermission('mes:task:query')") - public CommonResult> getTaskDetailPage(PageParam pageReqVO, + public CommonResult> getTaskDetailPage(PageParam pageReqVO, @RequestParam("taskId") Long taskId) { return success(taskService.getTaskDetailPage(pageReqVO, taskId)); } diff --git a/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/task/vo/TaskDetailRespVO.java b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/task/vo/TaskDetailRespVO.java new file mode 100644 index 000000000..32d9fe034 --- /dev/null +++ b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/task/vo/TaskDetailRespVO.java @@ -0,0 +1,62 @@ +package cn.iocoder.yudao.module.mes.controller.admin.task.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.util.*; +import java.util.*; +import org.springframework.format.annotation.DateTimeFormat; +import java.time.LocalDateTime; +import com.alibaba.excel.annotation.*; + +@Schema(description = "管理后台 - 生产任务单明细 Response VO") +@Data +@ExcelIgnoreUnannotated +public class TaskDetailRespVO { + + @Schema(description = "ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "2696") + @ExcelProperty("ID") + private Long id; + + @Schema(description = "产品ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "4041") + @ExcelProperty("产品ID") + private Long productId; + @Schema(description = "产品", requiredMode = Schema.RequiredMode.REQUIRED, example = "4041") + @ExcelProperty("产品") + private String productName; + + @Schema(description = "单位ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "13695") + @ExcelProperty("单位ID") + private Long unitId; + @Schema(description = "单位", requiredMode = Schema.RequiredMode.REQUIRED, example = "13695") + @ExcelProperty("单位") + private String unitName; + + @Schema(description = "task ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "12825") + @ExcelProperty("task ID") + private Long taskId; + + @Schema(description = "数量", requiredMode = Schema.RequiredMode.REQUIRED) + @ExcelProperty("数量") + private Long number; + + @Schema(description = "打包要求(每包/个)", requiredMode = Schema.RequiredMode.REQUIRED) + @ExcelProperty("打包要求(每包/个)") + private Long packageSize; + + @Schema(description = "项目名称", example = "赵六") + @ExcelProperty("项目名称") + private String projectName; + + @Schema(description = "技术要求") + @ExcelProperty("技术要求") + private String techRequirements; + + @Schema(description = "备注", example = "你猜") + @ExcelProperty("备注") + private String remark; + + @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) + @ExcelProperty("创建时间") + private LocalDateTime createTime; + +} \ No newline at end of file diff --git a/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/service/task/TaskService.java b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/service/task/TaskService.java index 8ec2a69cc..393eb7e89 100644 --- a/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/service/task/TaskService.java +++ b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/service/task/TaskService.java @@ -71,7 +71,7 @@ public interface TaskService { * @param taskId task ID * @return 生产任务单明细分页 */ - PageResult getTaskDetailPage(PageParam pageReqVO, Long taskId); + PageResult getTaskDetailPage(PageParam pageReqVO, Long taskId); /** * 创建生产任务单明细 diff --git a/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/service/task/TaskServiceImpl.java b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/service/task/TaskServiceImpl.java index e84639c87..1f23803af 100644 --- a/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/service/task/TaskServiceImpl.java +++ b/yudao-module-mes/yudao-module-mes-biz/src/main/java/cn/iocoder/yudao/module/mes/service/task/TaskServiceImpl.java @@ -1,5 +1,13 @@ package cn.iocoder.yudao.module.mes.service.task; +import cn.hutool.core.collection.CollUtil; +import cn.iocoder.yudao.framework.common.util.collection.MapUtils; +import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductDO; +import cn.iocoder.yudao.module.erp.dal.dataobject.product.ErpProductUnitDO; +import cn.iocoder.yudao.module.erp.service.product.ErpProductService; +import cn.iocoder.yudao.module.erp.service.product.ErpProductUnitService; +import cn.iocoder.yudao.module.mes.controller.admin.bom.vo.BomDetailRespVO; +import cn.iocoder.yudao.module.mes.dal.dataobject.bom.BomDetailDO; import org.springframework.stereotype.Service; import org.springframework.validation.annotation.Validated; import org.springframework.transaction.annotation.Transactional; @@ -18,6 +26,7 @@ import cn.iocoder.yudao.module.mes.dal.mysql.task.TaskDetailMapper; import javax.annotation.Resource; import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; import static cn.iocoder.yudao.module.mes.enums.ErrorCodeConstants.*; /** @@ -111,12 +120,31 @@ public class TaskServiceImpl implements TaskService { } // ==================== 子表(生产任务单明细) ==================== - + @Resource + private ErpProductService productService; + @Resource + private ErpProductUnitService productUnitService; @Override - public PageResult getTaskDetailPage(PageParam pageReqVO, Long taskId) { - return taskDetailMapper.selectPage(pageReqVO, taskId); + public PageResult getTaskDetailPage(PageParam pageReqVO, Long taskId) { + PageResult pageResult = taskDetailMapper.selectPage(pageReqVO, taskId); + return new PageResult<>(buildDetailVOList(pageResult.getList()), pageResult.getTotal()); + } + private List buildDetailVOList(List list) { + if (CollUtil.isEmpty(list)) { + return Collections.emptyList(); + } + Map map = productService.getProductMap( + convertSet(list, TaskDetailDO::getProductId)); + Map unitMap = productUnitService.getProductUnitMap( + convertSet(list, TaskDetailDO::getUnitId)); + + return BeanUtils.toBean(list, TaskDetailRespVO.class, item -> { + MapUtils.findAndThen(map, item.getProductId(), + product -> item.setProductName(product.getName())); + MapUtils.findAndThen(unitMap, item.getUnitId(), + unit -> item.setUnitName(unit.getName())); + }); } - @Override public Long createTaskDetail(TaskDetailDO taskDetail) { taskDetailMapper.insert(taskDetail);