Compare commits
2 Commits
1e26ada9ce
...
4248828933
| Author | SHA1 | Date |
|---|---|---|
|
|
4248828933 | 2 weeks ago |
|
|
43fb1c2242 | 2 weeks ago |
@ -0,0 +1,246 @@
|
|||||||
|
package cn.iocoder.yudao.module.mes.controller.admin.dashboard;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||||
|
import cn.iocoder.yudao.framework.common.util.collection.MapUtils;
|
||||||
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||||
|
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||||
|
import cn.iocoder.yudao.module.erp.controller.admin.product.vo.product.ErpProductRespVO;
|
||||||
|
import cn.iocoder.yudao.module.erp.service.product.ErpProductService;
|
||||||
|
import cn.iocoder.yudao.module.mes.controller.admin.dashboard.vo.DeviceRespVO;
|
||||||
|
import cn.iocoder.yudao.module.mes.controller.admin.dashboard.vo.TaskReqVO;
|
||||||
|
import cn.iocoder.yudao.module.mes.controller.admin.dashboard.vo.TaskRespVO;
|
||||||
|
import cn.iocoder.yudao.module.mes.controller.admin.plan.vo.PlanRespVO;
|
||||||
|
import cn.iocoder.yudao.module.mes.dal.dataobject.organization.OrganizationDO;
|
||||||
|
import cn.iocoder.yudao.module.mes.dal.dataobject.plan.PlanDO;
|
||||||
|
import cn.iocoder.yudao.module.mes.dal.dataobject.task.TaskDO;
|
||||||
|
import cn.iocoder.yudao.module.mes.dal.mysql.plan.PlanMapper;
|
||||||
|
import cn.iocoder.yudao.module.mes.dal.mysql.task.TaskMapper;
|
||||||
|
import cn.iocoder.yudao.module.mes.dal.mysql.ticketmanagement.TicketManagementMapper;
|
||||||
|
import cn.iocoder.yudao.module.mes.service.dvrepair.DvRepairService;
|
||||||
|
import cn.iocoder.yudao.module.mes.service.organization.OrganizationService;
|
||||||
|
import cn.iocoder.yudao.module.mes.service.plan.PlanService;
|
||||||
|
import cn.iocoder.yudao.module.mes.service.ticketmanagement.TicketManagementService;
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
import io.swagger.v3.oas.annotations.Parameter;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import javax.validation.Valid;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||||
|
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
|
||||||
|
|
||||||
|
@Tag(name = "管理后台 - 首页")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/mes/dashboard")
|
||||||
|
@Validated
|
||||||
|
public class DashboardController {
|
||||||
|
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private PlanService planService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private ErpProductService productService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private OrganizationService organizationService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private DvRepairService dvRepairService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private TicketManagementService ticketManagementService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private PlanMapper planMapper;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private TaskMapper taskMapper;
|
||||||
|
|
||||||
|
|
||||||
|
@GetMapping("/getProduction")
|
||||||
|
@Operation(summary = "获得整体生产概况")
|
||||||
|
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||||
|
@PreAuthorize("@ss.hasPermission('mes:bom:query')")
|
||||||
|
public CommonResult<TaskRespVO> getProduction(@Valid TaskReqVO taskReqVO) {
|
||||||
|
TaskRespVO taskRespVO = new TaskRespVO();
|
||||||
|
List<TaskRespVO.Item> taskItems = new ArrayList<>();
|
||||||
|
List<TaskRespVO.Item> planItems = new ArrayList<>();
|
||||||
|
// 生产任务总数
|
||||||
|
TaskRespVO.Item item = new TaskRespVO.Item();
|
||||||
|
item.setKey("1");
|
||||||
|
item.setLabel("生产任务总数");
|
||||||
|
item.setValue(taskMapper.selectCount(new LambdaQueryWrapperX<TaskDO>()
|
||||||
|
.betweenIfPresent(TaskDO::getCreateTime, taskReqVO.getStartTime()))); // 创建时间
|
||||||
|
taskItems.add(item);
|
||||||
|
// 未开工任务数
|
||||||
|
item = new TaskRespVO.Item();
|
||||||
|
item.setKey("2");
|
||||||
|
item.setLabel("未开工任务数");
|
||||||
|
Collection<Long> count1 = new ArrayList<>();
|
||||||
|
count1.add(1L);
|
||||||
|
count1.add(2L);
|
||||||
|
count1.add(3L);
|
||||||
|
item.setValue(taskMapper.selectCount(new LambdaQueryWrapperX<TaskDO>()
|
||||||
|
.in(TaskDO::getStatus, count1)
|
||||||
|
.betweenIfPresent(TaskDO::getOrderDate, taskReqVO.getStartTime()))); // 下达时间
|
||||||
|
taskItems.add(item);
|
||||||
|
// 生产中任务数
|
||||||
|
item = new TaskRespVO.Item();
|
||||||
|
item.setKey("3");
|
||||||
|
item.setLabel("生产中任务数");
|
||||||
|
Collection<Long> count2 = new ArrayList<>();
|
||||||
|
count2.add(4L);
|
||||||
|
item.setValue(taskMapper.selectCount(new LambdaQueryWrapperX<TaskDO>()
|
||||||
|
.in(TaskDO::getStatus, count2)
|
||||||
|
.betweenIfPresent(TaskDO::getOrderDate, taskReqVO.getStartTime())));
|
||||||
|
taskItems.add(item);
|
||||||
|
// 完工任务数
|
||||||
|
item = new TaskRespVO.Item();
|
||||||
|
item.setKey("4");
|
||||||
|
item.setLabel("完工任务数");
|
||||||
|
Collection<Long> count3 = new ArrayList<>();
|
||||||
|
count3.add(5L);
|
||||||
|
count3.add(6L);
|
||||||
|
item.setValue(taskMapper.selectCount(new LambdaQueryWrapperX<TaskDO>()
|
||||||
|
.in(TaskDO::getStatus, count3)
|
||||||
|
.betweenIfPresent(TaskDO::getOrderDate, taskReqVO.getStartTime())));
|
||||||
|
taskItems.add(item);
|
||||||
|
// 生产计划总数
|
||||||
|
item = new TaskRespVO.Item();
|
||||||
|
item.setKey("5");
|
||||||
|
item.setLabel("生产计划单数");
|
||||||
|
item.setValue(planMapper.selectCount());
|
||||||
|
planItems.add(item);
|
||||||
|
// 完成生产数量
|
||||||
|
item = new TaskRespVO.Item();
|
||||||
|
item.setKey("6");
|
||||||
|
item.setLabel("产品计划总数");
|
||||||
|
List<PlanDO> planDOList = planMapper.selectList();
|
||||||
|
long count = 0L;
|
||||||
|
for (PlanDO planDO : planDOList) {
|
||||||
|
if (planDO.getPlanNumber() != null) {
|
||||||
|
count = count + planDO.getPlanNumber();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
item.setValue(count);
|
||||||
|
planItems.add(item);
|
||||||
|
// 报工数量
|
||||||
|
item = new TaskRespVO.Item();
|
||||||
|
item.setKey("7");
|
||||||
|
item.setLabel("报工总数");
|
||||||
|
long baogong = 0L;
|
||||||
|
for (PlanDO planDO : planDOList) {
|
||||||
|
if (planDO.getWangongNumber() != null) {
|
||||||
|
baogong = baogong + planDO.getWangongNumber();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
item.setValue(baogong);
|
||||||
|
planItems.add(item);
|
||||||
|
// 未完成生产数量
|
||||||
|
item = new TaskRespVO.Item();
|
||||||
|
item.setKey("81");
|
||||||
|
item.setLabel("产品合格数");
|
||||||
|
long pass = 0L;
|
||||||
|
for (PlanDO planDO : planDOList) {
|
||||||
|
if (planDO.getPassNumber() != null) {
|
||||||
|
pass = pass + planDO.getPassNumber();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
item.setValue(pass);
|
||||||
|
planItems.add(item);
|
||||||
|
// 完工率
|
||||||
|
item = new TaskRespVO.Item();
|
||||||
|
item.setKey("8");
|
||||||
|
item.setLabel("产品不合格数");
|
||||||
|
long noPass = 0L;
|
||||||
|
for (PlanDO planDO : planDOList) {
|
||||||
|
if (planDO.getNoPassNumber() != null) {
|
||||||
|
noPass = noPass + planDO.getNoPassNumber();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
item.setValue(noPass);
|
||||||
|
planItems.add(item);
|
||||||
|
// 合格率
|
||||||
|
item = new TaskRespVO.Item();
|
||||||
|
item.setKey("9");
|
||||||
|
item.setLabel("合格率");
|
||||||
|
long passRate = 0;
|
||||||
|
if (baogong != 0) {
|
||||||
|
passRate = (long) (((double) pass / baogong) * 100);
|
||||||
|
|
||||||
|
}
|
||||||
|
item.setValue(passRate);
|
||||||
|
planItems.add(item);
|
||||||
|
|
||||||
|
taskRespVO.setTaskItems(taskItems);
|
||||||
|
taskRespVO.setPlanItems(planItems);
|
||||||
|
return success(taskRespVO);
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/getPlan")
|
||||||
|
@Operation(summary = "获得实时生产进度")
|
||||||
|
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||||
|
@PreAuthorize("@ss.hasPermission('mes:bom:query')")
|
||||||
|
public CommonResult<List<PlanRespVO>> getPlan() {
|
||||||
|
List<Integer> statusList = new ArrayList<>();
|
||||||
|
statusList.add(1);
|
||||||
|
statusList.add(2);
|
||||||
|
statusList.add(3);
|
||||||
|
statusList.add(4);
|
||||||
|
statusList.add(5);
|
||||||
|
statusList.add(6);
|
||||||
|
List<PlanDO> planDOList = planService.getPlanByStatus(statusList);
|
||||||
|
Map<Long, ErpProductRespVO> productMap = productService.getProductVOMap(
|
||||||
|
convertSet(planDOList, PlanDO::getProductId));
|
||||||
|
Map<Long, OrganizationDO> organizationMap = organizationService.getOrganizationVOMap(convertSet(planDOList, PlanDO::getFeedingPipeline));
|
||||||
|
return success(BeanUtils.toBean(planDOList, PlanRespVO.class, planRespVO ->{
|
||||||
|
MapUtils.findAndThen(productMap, planRespVO.getProductId(), product -> planRespVO.setProductName(product.getName()));
|
||||||
|
MapUtils.findAndThen(organizationMap, planRespVO.getFeedingPipeline(), organization -> planRespVO.setFeedingPipelineName(organization.getName()));
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@GetMapping("/getDevice")
|
||||||
|
@Operation(summary = "获得设备")
|
||||||
|
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||||
|
@PreAuthorize("@ss.hasPermission('mes:bom:query')")
|
||||||
|
public CommonResult<List<DeviceRespVO>> getDevice() {
|
||||||
|
List<DeviceRespVO> deviceRespVOList = new ArrayList<>();
|
||||||
|
DeviceRespVO deviceRespVO = new DeviceRespVO();
|
||||||
|
// 设备维修
|
||||||
|
deviceRespVO.setKey("1");
|
||||||
|
deviceRespVO.setLabel("维修");
|
||||||
|
deviceRespVO.setValue(dvRepairService.getRepairListCountByRepairStatus());
|
||||||
|
deviceRespVO.setLevel("mini-danger");
|
||||||
|
deviceRespVOList.add(deviceRespVO);
|
||||||
|
// 设备点检
|
||||||
|
deviceRespVO = new DeviceRespVO();
|
||||||
|
deviceRespVO.setKey("2");
|
||||||
|
deviceRespVO.setLabel("点检");
|
||||||
|
deviceRespVO.setValue(ticketManagementService.getDianjianListCountByJobStatus());
|
||||||
|
deviceRespVO.setLevel("mini-normal");
|
||||||
|
deviceRespVOList.add(deviceRespVO);
|
||||||
|
// 设备保养
|
||||||
|
deviceRespVO = new DeviceRespVO();
|
||||||
|
deviceRespVO.setKey("3");
|
||||||
|
deviceRespVO.setLabel("保养");
|
||||||
|
deviceRespVO.setValue(ticketManagementService.getBaoyangListCountByJobStatus());
|
||||||
|
deviceRespVO.setLevel("mini-total");
|
||||||
|
deviceRespVOList.add(deviceRespVO);
|
||||||
|
return success(deviceRespVOList);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,24 @@
|
|||||||
|
package cn.iocoder.yudao.module.mes.controller.admin.dashboard.vo;
|
||||||
|
|
||||||
|
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Schema(description = "管理后台 - 首页设备 Response VO")
|
||||||
|
@Data
|
||||||
|
@ExcelIgnoreUnannotated
|
||||||
|
public class DeviceRespVO {
|
||||||
|
@Schema(description = "key")
|
||||||
|
private String key;
|
||||||
|
|
||||||
|
@Schema(description = "label")
|
||||||
|
private String label;
|
||||||
|
|
||||||
|
@Schema(description = "value")
|
||||||
|
private Long value;
|
||||||
|
|
||||||
|
@Schema(description = "level")
|
||||||
|
private String level;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@ -0,0 +1,16 @@
|
|||||||
|
package cn.iocoder.yudao.module.mes.controller.admin.dashboard.vo;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
@Schema(description = "管理后台 - 首页整体生产概况 Request VO")
|
||||||
|
@Data
|
||||||
|
public class TaskReqVO {
|
||||||
|
|
||||||
|
@Schema(description = "开始时间")
|
||||||
|
private LocalDateTime[] startTime;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,35 @@
|
|||||||
|
package cn.iocoder.yudao.module.mes.controller.admin.dashboard.vo;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.out.ErpStockOutSaveReqVO;
|
||||||
|
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import javax.validation.Valid;
|
||||||
|
import javax.validation.constraints.NotEmpty;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Schema(description = "管理后台 - 产品BOM Response VO")
|
||||||
|
@Data
|
||||||
|
@ExcelIgnoreUnannotated
|
||||||
|
public class TaskRespVO {
|
||||||
|
@Schema(description = "任务")
|
||||||
|
private List<TaskRespVO.Item> taskItems;
|
||||||
|
|
||||||
|
@Schema(description = "计划")
|
||||||
|
private List<TaskRespVO.Item> planItems;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public static class Item {
|
||||||
|
@Schema(description = "key")
|
||||||
|
private String key;
|
||||||
|
|
||||||
|
@Schema(description = "label")
|
||||||
|
private String label;
|
||||||
|
|
||||||
|
@Schema(description = "value")
|
||||||
|
private Long value;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@ -0,0 +1,4 @@
|
|||||||
|
package cn.iocoder.yudao.module.mes.controller.admin.dashboard.vo;
|
||||||
|
|
||||||
|
public class TaskVO {
|
||||||
|
}
|
||||||
@ -0,0 +1,50 @@
|
|||||||
|
package cn.iocoder.yudao.module.mes.controller.admin.deviceledger.vo;
|
||||||
|
|
||||||
|
|
||||||
|
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||||
|
import com.alibaba.excel.annotation.ExcelProperty;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY;
|
||||||
|
|
||||||
|
@Schema(description = "管理后台 - 设备模具导出 Resp VO")
|
||||||
|
@Data
|
||||||
|
@ExcelIgnoreUnannotated
|
||||||
|
public class MoldVO {
|
||||||
|
@Schema(description = "ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "32278")
|
||||||
|
@ExcelProperty("ID")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@Schema(description = "模具编码", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
|
@ExcelProperty("模具编码")
|
||||||
|
private String code;
|
||||||
|
|
||||||
|
@Schema(description = "模具名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿")
|
||||||
|
@ExcelProperty("模具名称")
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Schema(description = "入库时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
|
@ExcelProperty("入库时间")
|
||||||
|
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY)
|
||||||
|
private LocalDateTime inTime;
|
||||||
|
|
||||||
|
|
||||||
|
@Schema(description = "备注", example = "你猜")
|
||||||
|
@ExcelProperty("备注")
|
||||||
|
private String remark;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
|
// @ExcelProperty("创建时间")
|
||||||
|
private LocalDateTime createTime;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue