plp
chenshuichuan 2 years ago
parent cf9f50266f
commit c45a0f8df6

@ -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='设备属性表';

@ -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<List<ErpProductRespVO>> getProductSimpleList() {
List<ErpProductRespVO> list = productService.getProductVOListByStatus(CommonStatusEnum.ENABLE.getStatus());
List<ErpProductRespVO> 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<List<ErpProductRespVO>> getItemSimpleList() {
List<ErpProductRespVO> 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())

@ -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<ErpProductDO> {
default List<ErpProductDO> selectListByStatus(Integer status) {
return selectList(ErpProductDO::getStatus, status);
}
default List<ErpProductDO> selectListByCategoryId(Integer categoryId) {
return selectList(ErpProductDO::getStatus, CommonStatusEnum.ENABLE.getStatus(),
ErpProductDO::getCategoryId, categoryId);
}
}

@ -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;
}
}

@ -66,7 +66,7 @@ public interface ErpProductService {
* @return VO
*/
List<ErpProductRespVO> getProductVOListByStatus(Integer status);
List<ErpProductRespVO> getProductVOListByCategory(Integer categoryId);
/**
* VO
*

@ -107,6 +107,11 @@ public class ErpProductServiceImpl implements ErpProductService {
List<ErpProductDO> list = productMapper.selectListByStatus(status);
return buildProductVOList(list);
}
@Override
public List<ErpProductRespVO> getProductVOListByCategory(Integer categoryId) {
List<ErpProductDO> list = productMapper.selectListByCategoryId(categoryId);
return buildProductVOList(list);
}
@Override
public List<ErpProductRespVO> getProductVOList(Collection<Long> ids) {

@ -39,7 +39,7 @@ public class BomDetailRespVO {
@Schema(description = "用量", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("用量")
private BigDecimal usage;
private BigDecimal usageNumber;
@Schema(description = "损耗率%")
@ExcelProperty("损耗率%")

@ -108,7 +108,7 @@ public class TaskController {
@Operation(summary = "获得生产任务单明细分页")
@Parameter(name = "taskId", description = "task ID")
@PreAuthorize("@ss.hasPermission('mes:task:query')")
public CommonResult<PageResult<TaskDetailDO>> getTaskDetailPage(PageParam pageReqVO,
public CommonResult<PageResult<TaskDetailRespVO>> getTaskDetailPage(PageParam pageReqVO,
@RequestParam("taskId") Long taskId) {
return success(taskService.getTaskDetailPage(pageReqVO, taskId));
}

@ -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;
}

@ -71,7 +71,7 @@ public interface TaskService {
* @param taskId task ID
* @return
*/
PageResult<TaskDetailDO> getTaskDetailPage(PageParam pageReqVO, Long taskId);
PageResult<TaskDetailRespVO> getTaskDetailPage(PageParam pageReqVO, Long taskId);
/**
*

@ -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<TaskDetailDO> getTaskDetailPage(PageParam pageReqVO, Long taskId) {
return taskDetailMapper.selectPage(pageReqVO, taskId);
public PageResult<TaskDetailRespVO> getTaskDetailPage(PageParam pageReqVO, Long taskId) {
PageResult<TaskDetailDO> pageResult = taskDetailMapper.selectPage(pageReqVO, taskId);
return new PageResult<>(buildDetailVOList(pageResult.getList()), pageResult.getTotal());
}
private List<TaskDetailRespVO> buildDetailVOList(List<TaskDetailDO> list) {
if (CollUtil.isEmpty(list)) {
return Collections.emptyList();
}
Map<Long, ErpProductDO> map = productService.getProductMap(
convertSet(list, TaskDetailDO::getProductId));
Map<Long, ErpProductUnitDO> 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);

Loading…
Cancel
Save