Commit 969a5fe0 authored by 李驰骋's avatar 李驰骋

异常相关看板接口

parent 745a2fb6
......@@ -27,41 +27,7 @@ public class KanbanAbnormalController {
@ApiOperation("当月异常分布数据")
@PostMapping("/currentMonthStat")
public AjaxResult<AbnormalMonthStatDto> currentMonthStat() {
AbnormalMonthStatDto rst = new AbnormalMonthStatDto();
AbnormalMonthStatDto.AbnormalMonthStatDetail abnormal1 = new AbnormalMonthStatDto.AbnormalMonthStatDetail();
abnormal1.setTotalCt(10);
abnormal1.setExpireUnClose(2);
abnormal1.setUnCloseCt(6);
rst.setEquipAbnormal(abnormal1);
AbnormalMonthStatDto.AbnormalMonthStatDetail abnormal2 = new AbnormalMonthStatDto.AbnormalMonthStatDetail();
abnormal2.setTotalCt(6);
abnormal2.setExpireUnClose(1);
abnormal2.setUnCloseCt(4);
rst.setProductAbnormal(abnormal2);
rst.setEquipCt(52);
rst.setEquipErrorCt(3);
List<AbnormalMonthStatDto.AbnormalCauseStat> abnormalCauseStats = new ArrayList<>();
abnormalCauseStats.add(new AbnormalMonthStatDto.AbnormalCauseStat(){
{
setCause("停电");
setCt(2);
}
});
abnormalCauseStats.add(new AbnormalMonthStatDto.AbnormalCauseStat(){
{
setCause("设备损坏");
setCt(4);
}
});
abnormalCauseStats.add(new AbnormalMonthStatDto.AbnormalCauseStat(){
{
setCause("硬件故障");
setCt(0);
}
});
rst.setAbnormalCauseData(abnormalCauseStats);
rst.setEquipErrorArr(ListUtil.toList(new Integer[]{0,0,0,2,2,0,0}));
AbnormalMonthStatDto rst = kanbanAbnormalService.currentMonthStat();
return AjaxResult.success(rst);
}
......
......@@ -22,7 +22,7 @@ public class AbnormalMonthStatDto {
@ApiModelProperty("当前设备故障数")
Integer equipErrorCt;
@ApiModelProperty("设备七天故障数")
@ApiModelProperty("设备近七天故障数,顺序为:索引0当天、1昨天、2前天")
List<Integer> equipErrorArr=new ArrayList<>();
@ApiModelProperty("异常原因不合格分布")
......@@ -31,11 +31,11 @@ public class AbnormalMonthStatDto {
@Data
public static class AbnormalMonthStatDetail{
@ApiModelProperty("异常总数")
Integer totalCt;
Integer totalCt=0;
@ApiModelProperty("未关闭数")
Integer unCloseCt;
Integer unCloseCt=0;
@ApiModelProperty("超期未关闭数")
Integer expireUnClose;
Integer expireUnClose=0;
}
@Data
......@@ -45,7 +45,7 @@ public class AbnormalMonthStatDto {
String cause;
@ApiModelProperty("异常原因")
Integer ct;
Integer ct=0;
}
......
package com.ximai.mes.kanban.service;
import cn.hutool.core.collection.ListUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.map.MapUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ximai.mes.kanban.dto.abnormal.AbnormalMonthStatDto;
import com.ximai.mes.md.domain.MdWorkunit;
import com.ximai.mes.md.mapper.MdWorkunitMapper;
import com.ximai.mes.md.service.IMdWorkunitService;
import com.ximai.mes.qc.domain.QcAbnormalInformation;
import com.ximai.mes.qc.domain.QcAbnormalReport;
import com.ximai.mes.qc.dto.QcAbnormalReportDto;
import com.ximai.mes.qc.dto.QcAbnormalReportStatusEnum;
import com.ximai.mes.qc.dto.QcAbnormalTypeEnum;
import com.ximai.mes.qc.mapper.QcAbnormalReportMapper;
import com.ximai.mes.qc.service.IQcAbnormalInformationService;
import com.ximai.mes.qc.service.IQcAbnormalReportService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.checkerframework.checker.units.qual.C;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.util.*;
import java.util.stream.Collectors;
@Service
public class KanbanAbnormalService {
@Autowired
IQcAbnormalReportService abnormalReportService;
@Autowired
IQcAbnormalInformationService abnormalInformationService;
@Autowired
MdWorkunitMapper workunitMapper;
@Autowired
QcAbnormalReportMapper abnormalReportMapper;
@ApiOperation("当月异常分布数据")
@PostMapping("/currentMonthStat")
public AbnormalMonthStatDto currentMonthStat() {
return null;
//本月第一天
LocalDateTime monthFirstDay = LocalDateTime.now().withDayOfMonth(1).with(LocalTime.MIN);
AbnormalMonthStatDto rst = new AbnormalMonthStatDto();
QueryWrapper<QcAbnormalReport> query = new QueryWrapper<>();
query.ge("create_time", monthFirstDay);
List<QcAbnormalReportDto> abnormalList = abnormalReportService.selectQcAbnormalReportDtoList(query);
Map<String, List<QcAbnormalReportDto>> abnormalTypeMap = abnormalList.stream().collect(Collectors.groupingBy(s->s.getAbnormalType()));
List<QcAbnormalReportDto> equipAbnormal = abnormalTypeMap.getOrDefault(QcAbnormalTypeEnum.DEVI.getType(), new ArrayList<>());
List<QcAbnormalReportDto> productAbnormal = abnormalTypeMap.getOrDefault(QcAbnormalTypeEnum.PROD.getType(), new ArrayList<>());
AbnormalMonthStatDto.AbnormalMonthStatDetail abnormal1 = this.stat(equipAbnormal);
AbnormalMonthStatDto.AbnormalMonthStatDetail abnormal2 = this.stat(productAbnormal);
rst.setProductAbnormal(abnormal2);
rst.setEquipAbnormal(abnormal1);
//统计所有未关闭设备异常
QueryWrapper<QcAbnormalReport> abnormalReportQuery = new QueryWrapper<>();
abnormalReportQuery.in("abnormal_status", new String[]{QcAbnormalReportStatusEnum.NOT.getStatus(), QcAbnormalReportStatusEnum.SUBMIT.getStatus()});
Integer abnormalEquipCt = abnormalReportMapper.selectCount(abnormalReportQuery);
rst.setEquipErrorCt(abnormalEquipCt);
QueryWrapper<MdWorkunit> workunitQuery = new QueryWrapper<>();
workunitQuery.eq("enable_flag", "Y");
int workunitCt = workunitMapper.selectCount(workunitQuery);
rst.setEquipCt(workunitCt-abnormalEquipCt);
List<QcAbnormalReportDto> unqualifiedAbnormal = abnormalTypeMap.getOrDefault(QcAbnormalTypeEnum.UNQUALIFIED_REASON.getType(), new ArrayList<>());
//按不合格原因分组
Map<String, List<QcAbnormalReportDto>> unqualifiedAbnormalMap = unqualifiedAbnormal.stream().collect(Collectors.groupingBy(s->s.getAbnormalReason()));
//查询不合格原因
QcAbnormalInformation qcAbnormalInformationQuery = new QcAbnormalInformation();
qcAbnormalInformationQuery.setAbnormalType(QcAbnormalTypeEnum.UNQUALIFIED_REASON.getType());
List<QcAbnormalInformation> abnormalInfoList = abnormalInformationService.selectQcAbnormalInformationList(qcAbnormalInformationQuery);
LinkedHashMap<String, Integer> unqualifiedAbnormalRstMap = new LinkedHashMap<>();
List<AbnormalMonthStatDto.AbnormalCauseStat> abnormalCauseStats = new ArrayList<>();
abnormalInfoList.forEach(s->{
if(!unqualifiedAbnormalMap.containsKey(s.getAbnormalReason())){
unqualifiedAbnormalRstMap.put(s.getAbnormalReason(), 0);
}else {
unqualifiedAbnormalRstMap.put(s.getAbnormalReason(), unqualifiedAbnormalMap.get(s.getAbnormalReason()).size());
}
});
Map<String,Integer> queueUnqualifiedMap = MapUtil.sortByValue(unqualifiedAbnormalRstMap, true);
queueUnqualifiedMap.forEach((k,v)->{
abnormalCauseStats.add(new AbnormalMonthStatDto.AbnormalCauseStat(){
{
setCt(v);
setCause(k);
}
});
});
rst.setAbnormalCauseData(abnormalCauseStats);
//查询七天内设备异常,按天统计
Calendar last7Day = Calendar.getInstance();
last7Day.set(Calendar.DATE, -6);
Map<String,List<QcAbnormalReportDto>> newEquipAbnormalMap = equipAbnormal.stream()
.filter(s->s.getCreateTime().compareTo(last7Day.getTime())>0)
.collect(Collectors.groupingBy(s-> DateUtil.format(s.getCreateTime(),"MMdd")));
//按日期dd/MM分组
List<Integer> last7EquipAbnormalCt = new ArrayList<>();
Calendar tempCurr = Calendar.getInstance();
for(int i=0;i<7;i++){
String key = DateUtil.format(tempCurr.getTime(), "MMdd");
if(newEquipAbnormalMap.containsKey(key)){
last7EquipAbnormalCt.add(newEquipAbnormalMap.get(key).size());
}else {
last7EquipAbnormalCt.add(0);
}
tempCurr.add(Calendar.DATE, -1);
}
rst.setEquipErrorArr(last7EquipAbnormalCt);
return rst;
}
private AbnormalMonthStatDto.AbnormalMonthStatDetail stat(List<QcAbnormalReportDto> abnormalList){
AbnormalMonthStatDto.AbnormalMonthStatDetail abnormal1 = new AbnormalMonthStatDto.AbnormalMonthStatDetail();
if(abnormalList==null){
return abnormal1;
}
abnormal1.setTotalCt(abnormalList.size());
//报检时间超一天未关闭-超时未闭
Calendar curr = Calendar.getInstance();
curr.add(Calendar.DATE, 1);
int expireCt = abnormalList.stream().filter(s->{
if(s.getAbnormalStatus().equals(QcAbnormalReportStatusEnum.NOT.getStatus())
||s.getAbnormalStatus().equals(QcAbnormalReportStatusEnum.SUBMIT.getStatus())){
curr.setTime(s.getCreateTime());
curr.add(Calendar.DATE, 1);
if(curr.getTime().compareTo(curr.getTime())>0){
return true;
}
}
return false;
}).collect(Collectors.toList()).size();
abnormal1.setExpireUnClose(expireCt);
abnormal1.setUnCloseCt(abnormalList.stream().filter(s->s.getAbnormalStatus().equals(QcAbnormalReportStatusEnum.NOT.getStatus())
||s.getAbnormalStatus().equals(QcAbnormalReportStatusEnum.SUBMIT.getStatus())).collect(Collectors.toList()).size());
return abnormal1;
}
}
......@@ -2,12 +2,15 @@ package com.ximai.mes.kanban.service;
import com.ximai.mes.kanban.dto.task.TaskStatDto;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import org.checkerframework.checker.units.qual.A;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.List;
@Service
......@@ -15,8 +18,15 @@ public class KanbanTaskService {
@ApiOperation("工序当月统计")
@PostMapping("/currentMonthStat")
public List<TaskStatDto> currentMonthStat() {
return null;
public TaskStatDto currentMonthStat() {
TaskStatDto rst = new TaskStatDto();
List<TaskStatDto.ProcessOutput> outputList=new ArrayList<>();
List<TaskStatDto.ProcessQualifiedRate> qualifiedRateList=new ArrayList<>();
TaskStatDto.ProcessMonthlyIndexDto processMonthlyIndexDto=new TaskStatDto.ProcessMonthlyIndexDto();
rst.setOutputList(outputList);
rst.setQualifiedRateList(qualifiedRateList);
rst.setProcessMonthlyIndexDto(processMonthlyIndexDto);
return rst;
}
}
package com.ximai.mes.md.mapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ximai.mes.md.domain.MdVehicle;
import com.ximai.mes.md.domain.MdWorkunit;
import com.ximai.mes.md.vo.MdWorkunitVo;
import org.apache.ibatis.annotations.Delete;
......@@ -15,7 +17,7 @@ import java.util.List;
* @author yinjinlu
* @date 2024-01-18
*/
public interface MdWorkunitMapper {
public interface MdWorkunitMapper extends BaseMapper<MdWorkunit> {
/**
* 查询工作单元
......
package com.ximai.mes.qc.dto;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.ximai.common.annotation.Excel;
import com.ximai.common.core.domain.BaseEntity;
import lombok.Data;
import java.util.Date;
/**
* 车间异常单对象 qc_abnormal_report
*
* @author generator
* @date 2024-02-20
*/
@Data
public class QcAbnormalReportDto extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 车间异常单ID */
@TableId
private Long abnormalReportId;
/** 编批单号 */
@Excel(name = "编批单号")
private String batchNumber;
/** 编批单号 */
@Excel(name = "车间异常单单号 来源于编码规则:ABNORMAL_NUMBER")
private String abnormalNumber;
/** 工序ID */
@Excel(name = "工序ID")
private Long processId;
/** 工序编号 */
@Excel(name = "工序编号")
private String processCode;
/** 工序名称 */
@Excel(name = "工序名称")
private String processName;
/** 工作单元ID */
@Excel(name = "工作单元ID")
private Long workstationId;
/** 工作单元编号 */
@Excel(name = "工作单元编号")
private String workstationCode;
/** 工作单元名称 */
@Excel(name = "工作单元名称")
private String workstationName;
/** 异常类型 */
@Excel(name = "异常类型")
private String abnormalType;
/** 异常原因 */
@Excel(name = "异常原因")
private String abnormalReason;
/** 异常时间 */
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "异常时间", width = 30, dateFormat = "yyyy-MM-dd")
private Date abnormalTime;
/** 单据状态 */
@Excel(name = "单据状态")
private String abnormalStatus;
private Long taskId;
/** 任务派工ID */
@Excel(name = "任务派工ID")
private Long taskWorkunitId;
//开始时间
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "开始时间", width = 30, dateFormat = "yyyy-MM-dd")
private Date beginPurchaseDate;
//结束时间
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "结束时间", width = 30, dateFormat = "yyyy-MM-dd")
private Date endPurchaseDate;
/**
* 单据开始处理时间
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date startTime;
/**
* 异常处理开始人
*/
private String startBy;
/**
* 处理结束时间
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date endTime;
/**
* 处理结束人
*/
private String endBy;
/**
* 处理该异常的耗时
*/
private Long timeConsuming;
private String remarks;
}
package com.ximai.mes.qc.dto;
import com.ximai.mes.constant.TaskStatusEnum;
/**
* 车间异常单状态对象 QcAbnormalReportStatusEnum
*
* @author generator
* @date 2024-02-20
*/
public enum QcAbnormalReportStatusEnum {
/**
* 已提交
*/
SUBMIT("SUBMIT"),
/**
* 关闭
*/
CLOSE("CLOSE"),
/**
* 未提交
*/
NOT("NOT"),
/**
* 完成
*/
FINISH("FINISH");
/**
* Lock type
*/
private final String status;
QcAbnormalReportStatusEnum(String status) {
this.status = status;
}
public String getStatus() {
return status;
}
public static QcAbnormalReportStatusEnum get(String status) {
for (QcAbnormalReportStatusEnum temp : QcAbnormalReportStatusEnum.values()) {
if (temp.getStatus().equals(status)) {
return temp;
}
}
return null;
}
}
package com.ximai.mes.qc.dto;
import com.ximai.mes.constant.TaskStatusEnum;
/**
* 车间异常单类型
*
* @author generator
* @date 2024-11-6
*/
public enum QcAbnormalTypeEnum {
/**
* 设备异常
*/
DEVI("DEVI"),
/**
* 生产异常
*/
PROD("PROD"),
/**
* 不合格异常
*/
UNQUALIFIED_REASON("UNQUALIFIED_REASON");
private final String type;
QcAbnormalTypeEnum(String type) {
this.type = type;
}
public String getType() {
return type;
}
public static QcAbnormalTypeEnum get(String type) {
for (QcAbnormalTypeEnum temp : QcAbnormalTypeEnum.values()) {
if (temp.getType().equals(type)) {
return temp;
}
}
return null;
}
}
package com.ximai.mes.qc.mapper;
import java.util.List;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ximai.mes.qc.domain.QcAbnormalReport;
import com.ximai.mes.qc.dto.QcAbnormalReportDto;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
/**
* 车间异常单Mapper接口
......@@ -28,6 +33,17 @@ public interface QcAbnormalReportMapper extends BaseMapper<QcAbnormalReport>
*/
public List<QcAbnormalReport> selectQcAbnormalReportList(QcAbnormalReport qcAbnormalReport);
/**
* 查询车间异常单列表
*
* @param query 车间异常单
* @return 车间异常单集合
*/
@Select(value = "select t1.* from qc_abnormal_report t1\n" +
"${ew.customSqlSegment}")
public List<QcAbnormalReportDto> selectQcAbnormalReportDtoList(@Param("ew") QueryWrapper<QcAbnormalReport> query);
/**
* 新增车间异常单
*
......
package com.ximai.mes.qc.service;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ximai.mes.qc.domain.QcAbnormalReport;
import com.ximai.mes.qc.dto.QcAbnormalReportDto;
import org.apache.ibatis.annotations.Param;
import java.util.List;
......@@ -27,6 +30,14 @@ public interface IQcAbnormalReportService {
*/
List<QcAbnormalReport> selectQcAbnormalReportList(QcAbnormalReport qcAbnormalReport);
/**
* 查询车间异常单列表
*
* @param query 车间异常单
* @return 车间异常单集合
*/
public List<QcAbnormalReportDto> selectQcAbnormalReportDtoList(QueryWrapper<QcAbnormalReport> query);
/**
* 新增车间异常单
*
......
package com.ximai.mes.qc.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ximai.common.constant.UserConstants;
import com.ximai.common.exception.ServiceException;
import com.ximai.common.utils.MessageUtils;
......@@ -20,6 +21,7 @@ import com.ximai.mes.pro.service.IProPauseWorkService;
import com.ximai.mes.pro.service.IProStartWorkService;
import com.ximai.mes.pro.service.task.IProTaskWorkunitService;
import com.ximai.mes.qc.domain.QcAbnormalReport;
import com.ximai.mes.qc.dto.QcAbnormalReportDto;
import com.ximai.mes.qc.mapper.QcAbnormalReportMapper;
import com.ximai.mes.qc.service.IQcAbnormalReportService;
import com.ximai.system.strategy.AutoCodeUtil;
......@@ -85,6 +87,11 @@ public class QcAbnormalReportServiceImpl implements IQcAbnormalReportService {
return qcAbnormalReportMapper.selectQcAbnormalReportList(qcAbnormalReport);
}
@Override
public List<QcAbnormalReportDto> selectQcAbnormalReportDtoList(QueryWrapper<QcAbnormalReport> query) {
return qcAbnormalReportMapper.selectQcAbnormalReportDtoList(query);
}
/**
* 新增车间异常单
*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment