diff --git a/doc/设计文档/数据库设计/mes-pro.sql b/doc/设计文档/数据库设计/mes-pro.sql index 6d84db0..4775fec 100644 --- a/doc/设计文档/数据库设计/mes-pro.sql +++ b/doc/设计文档/数据库设计/mes-pro.sql @@ -24,6 +24,7 @@ create table pro_workorder ( request_date datetime not null comment '需求日期', parent_id bigint(20) default 0 not null comment '父工单', ancestors varchar(500) not null comment '所有父节点ID', + finish_date datetime comment '完成时间', status varchar(64) default 'PREPARE' comment '单据状态', remark varchar(500) default '' comment '备注', attr1 varchar(64) default null comment '预留字段1', @@ -537,3 +538,29 @@ create table pro_andon_record ( update_time datetime comment '更新时间', primary key (record_id) ) engine=innodb auto_increment=200 comment = '安灯呼叫记录'; + +-- ---------------------------- +-- 4、停机记录 +-- ---------------------------- +drop table if exists pro_shutdown_record; +create table pro_shutdown_record ( + record_id bigint(20) not null auto_increment comment '记录ID', + workstation_id bigint(20) not null comment '工作站ID', + workstation_code varchar(64) comment '工作站编号', + workstation_name varchar(125) comment '工作站名称', + machinery_id bigint(20) comment '设备ID', + machinery_code varchar(64) comment '设备编号', + machinery_name varchar(255) comment '设备名称', + shutdown_reason varchar(500) not null comment '停机原因', + operation_time datetime comment '操作时间', + remark varchar(500) default '' comment '备注', + attr1 varchar(64) default null comment '预留字段1', + attr2 varchar(255) default null comment '预留字段2', + attr3 int(11) default 0 comment '预留字段3', + attr4 int(11) default 0 comment '预留字段4', + create_by varchar(64) default '' comment '创建者', + create_time datetime comment '创建时间', + update_by varchar(64) default '' comment '更新者', + update_time datetime comment '更新时间', + primary key (record_id) +) engine=innodb auto_increment=200 comment = '停机记录记录'; diff --git a/doc/设计文档/数据库设计/数据库设计.xlsx b/doc/设计文档/数据库设计/数据库设计.xlsx index 195b067..07d21eb 100644 Binary files a/doc/设计文档/数据库设计/数据库设计.xlsx and b/doc/设计文档/数据库设计/数据库设计.xlsx differ diff --git a/ktg-mes/src/main/java/com/ktg/mes/pro/controller/ProFeedbackController.java b/ktg-mes/src/main/java/com/ktg/mes/pro/controller/ProFeedbackController.java index c79f131..59ebf94 100644 --- a/ktg-mes/src/main/java/com/ktg/mes/pro/controller/ProFeedbackController.java +++ b/ktg-mes/src/main/java/com/ktg/mes/pro/controller/ProFeedbackController.java @@ -230,8 +230,15 @@ public class ProFeedbackController extends BaseController } ProWorkorder workorder = proWorkorderService.selectProWorkorderByWorkorderId(feedback.getWorkorderId()); - //更新生产任务的生产数量 + ProTask task = proTaskService.selectProTaskByTaskId(feedback.getTaskId()); + + //判断当前生产任务的状态,如果已经完成则不能再报工 + if(UserConstants.ORDER_STATUS_FINISHED.equals(task.getStatus())){ + return AjaxResult.error("当前生产工单的状态为已完成,不能继续报工,请刷新生产任务列表!"); + } + + //更新生产任务的生产数量 BigDecimal quantityProduced,quantityQuanlify,quantityUnquanlify; quantityQuanlify = task.getQuantityQuanlify()==null? new BigDecimal(0):task.getQuantityQuanlify(); quantityUnquanlify = task.getQuantityUnquanlify() ==null? new BigDecimal(0):task.getQuantityUnquanlify(); @@ -239,6 +246,7 @@ public class ProFeedbackController extends BaseController task.setQuantityProduced(quantityProduced.add(feedback.getQuantityFeedback())); task.setQuantityQuanlify(quantityQuanlify.add(feedback.getQuantityQualified())); task.setQuantityUnquanlify(quantityUnquanlify.add(feedback.getQuantityUnquanlified())); + proTaskService.updateProTask(task); //如果是关键工序,则更新当前工单的已生产数量,进行产品产出动作 diff --git a/ktg-mes/src/main/java/com/ktg/mes/pro/controller/ProWorkorderController.java b/ktg-mes/src/main/java/com/ktg/mes/pro/controller/ProWorkorderController.java index 192dfa8..329fd6c 100644 --- a/ktg-mes/src/main/java/com/ktg/mes/pro/controller/ProWorkorderController.java +++ b/ktg-mes/src/main/java/com/ktg/mes/pro/controller/ProWorkorderController.java @@ -12,11 +12,17 @@ import com.ktg.common.utils.StringUtils; import com.ktg.mes.md.domain.MdItem; import com.ktg.mes.md.domain.MdProductBom; import com.ktg.mes.md.service.IMdProductBomService; +import com.ktg.mes.pro.domain.ProTask; import com.ktg.mes.pro.domain.ProWorkorderBom; +import com.ktg.mes.pro.service.IProTaskService; import com.ktg.mes.pro.service.IProWorkorderBomService; +import com.ktg.mes.wm.domain.WmRtIssue; +import com.ktg.mes.wm.domain.WmRtIssueLine; +import com.ktg.mes.wm.domain.tx.RtIssueTxBean; import io.minio.messages.Item; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.transaction.annotation.Transactional; import org.springframework.util.CollectionUtils; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; @@ -53,6 +59,9 @@ public class ProWorkorderController extends BaseController @Autowired private IMdProductBomService mdProductBomService; + @Autowired + private IProTaskService proTaskService; + /** * 查询生产工单列表 */ @@ -237,4 +246,34 @@ public class ProWorkorderController extends BaseController return results; } + + /** + * 完成工单 + * @param workorderId + * @return + */ + @PreAuthorize("@ss.hasPermi('mes:wm:rtissue:edit')") + @Log(title = "生产工单", businessType = BusinessType.UPDATE) + @Transactional + @PutMapping("/{workorderId}") + public AjaxResult dofinish(@PathVariable Long workorderId){ + ProWorkorder workorder = proWorkorderService.selectProWorkorderByWorkorderId(workorderId); + + //将此工单下所有的生产任务状态设置为已完成 + ProTask param = new ProTask(); + param.setWorkorderId(workorderId); + List tasks = proTaskService.selectProTaskList(param); + if(!CollectionUtils.isEmpty(tasks)){ + for (ProTask task:tasks + ) { + task.setStatus(UserConstants.ORDER_STATUS_FINISHED); + proTaskService.updateProTask(task); + } + } + + workorder.setStatus(UserConstants.ORDER_STATUS_FINISHED); //更新工单的状态 + proWorkorderService.updateProWorkorder(workorder); + return AjaxResult.success(); + } + } diff --git a/ktg-mes/src/main/java/com/ktg/mes/pro/domain/ProWorkorder.java b/ktg-mes/src/main/java/com/ktg/mes/pro/domain/ProWorkorder.java index 4d7be77..ac064af 100644 --- a/ktg-mes/src/main/java/com/ktg/mes/pro/domain/ProWorkorder.java +++ b/ktg-mes/src/main/java/com/ktg/mes/pro/domain/ProWorkorder.java @@ -94,6 +94,11 @@ public class ProWorkorder extends TreeEntity @Excel(name = "需求日期", width = 30, dateFormat = "yyyy-MM-dd") private Date requestDate; + /** 完成时间 */ + @JsonFormat(pattern = "yyyy-MM-dd hh:mi:ss") + @Excel(name = "完成时间", width = 30, dateFormat = "yyyy-MM-dd hh:mi:ss") + private Date finishDate; + /** 单据状态 */ @Excel(name = "单据状态") private String status; @@ -326,6 +331,13 @@ public class ProWorkorder extends TreeEntity return attr4; } + public Date getFinishDate() { + return finishDate; + } + + public void setFinishDate(Date finishDate) { + this.finishDate = finishDate; + } @Override public String toString() { @@ -349,6 +361,7 @@ public class ProWorkorder extends TreeEntity ", clientCode='" + clientCode + '\'' + ", clientName='" + clientName + '\'' + ", requestDate=" + requestDate + + ", finishDate=" + finishDate + ", status='" + status + '\'' + ", attr1='" + attr1 + '\'' + ", attr2='" + attr2 + '\'' + diff --git a/ktg-mes/src/main/resources/mapper/pro/ProWorkorderMapper.xml b/ktg-mes/src/main/resources/mapper/pro/ProWorkorderMapper.xml index 2cb41d1..5d8dcd1 100644 --- a/ktg-mes/src/main/resources/mapper/pro/ProWorkorderMapper.xml +++ b/ktg-mes/src/main/resources/mapper/pro/ProWorkorderMapper.xml @@ -26,6 +26,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + @@ -63,6 +64,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and client_code = #{clientCode} and client_name like concat('%', #{clientName}, '%') and request_date = #{requestDate} + and finish_date = #{finishDate} and parent_id = #{parentId} and ancestors = #{ancestors} and status = #{status} @@ -101,6 +103,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" client_code, client_name, request_date, + finish_date, parent_id, ancestors, status, @@ -133,6 +136,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{clientCode}, #{clientName}, #{requestDate}, + #{finishDate}, #{parentId}, #{ancestors}, #{status}, @@ -169,6 +173,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" client_code = #{clientCode}, client_name = #{clientName}, request_date = #{requestDate}, + finish_date = #{finishDate}, parent_id = #{parentId}, ancestors = #{ancestors}, status = #{status}, diff --git a/ktg-system/src/main/resources/mapper/system/UserTaskMapper.xml b/ktg-system/src/main/resources/mapper/system/UserTaskMapper.xml index b48f241..59fb405 100644 --- a/ktg-system/src/main/resources/mapper/system/UserTaskMapper.xml +++ b/ktg-system/src/main/resources/mapper/system/UserTaskMapper.xml @@ -71,7 +71,7 @@ ) t left join sys_user su on t.create_by = su.user_name - order by create_time, task_type desc + order by create_time desc, task_type desc