为生产工单添加完成状态和完成时间,生产报工进行状态控制

This commit is contained in:
yinjinlu-pc\尹金路 2023-09-12 22:58:24 +08:00
parent e5bc8d5b76
commit 5c115d057b
7 changed files with 94 additions and 2 deletions

View File

@ -24,6 +24,7 @@ create table pro_workorder (
request_date datetime not null comment '需求日期', request_date datetime not null comment '需求日期',
parent_id bigint(20) default 0 not null comment '父工单', parent_id bigint(20) default 0 not null comment '父工单',
ancestors varchar(500) not null comment '所有父节点ID', ancestors varchar(500) not null comment '所有父节点ID',
finish_date datetime comment '完成时间',
status varchar(64) default 'PREPARE' comment '单据状态', status varchar(64) default 'PREPARE' comment '单据状态',
remark varchar(500) default '' comment '备注', remark varchar(500) default '' comment '备注',
attr1 varchar(64) default null comment '预留字段1', attr1 varchar(64) default null comment '预留字段1',
@ -537,3 +538,29 @@ create table pro_andon_record (
update_time datetime comment '更新时间', update_time datetime comment '更新时间',
primary key (record_id) primary key (record_id)
) engine=innodb auto_increment=200 comment = '安灯呼叫记录'; ) 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 = '停机记录记录';

View File

@ -230,8 +230,15 @@ public class ProFeedbackController extends BaseController
} }
ProWorkorder workorder = proWorkorderService.selectProWorkorderByWorkorderId(feedback.getWorkorderId()); ProWorkorder workorder = proWorkorderService.selectProWorkorderByWorkorderId(feedback.getWorkorderId());
//更新生产任务的生产数量
ProTask task = proTaskService.selectProTaskByTaskId(feedback.getTaskId()); ProTask task = proTaskService.selectProTaskByTaskId(feedback.getTaskId());
//判断当前生产任务的状态如果已经完成则不能再报工
if(UserConstants.ORDER_STATUS_FINISHED.equals(task.getStatus())){
return AjaxResult.error("当前生产工单的状态为已完成,不能继续报工,请刷新生产任务列表!");
}
//更新生产任务的生产数量
BigDecimal quantityProduced,quantityQuanlify,quantityUnquanlify; BigDecimal quantityProduced,quantityQuanlify,quantityUnquanlify;
quantityQuanlify = task.getQuantityQuanlify()==null? new BigDecimal(0):task.getQuantityQuanlify(); quantityQuanlify = task.getQuantityQuanlify()==null? new BigDecimal(0):task.getQuantityQuanlify();
quantityUnquanlify = task.getQuantityUnquanlify() ==null? new BigDecimal(0):task.getQuantityUnquanlify(); 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.setQuantityProduced(quantityProduced.add(feedback.getQuantityFeedback()));
task.setQuantityQuanlify(quantityQuanlify.add(feedback.getQuantityQualified())); task.setQuantityQuanlify(quantityQuanlify.add(feedback.getQuantityQualified()));
task.setQuantityUnquanlify(quantityUnquanlify.add(feedback.getQuantityUnquanlified())); task.setQuantityUnquanlify(quantityUnquanlify.add(feedback.getQuantityUnquanlified()));
proTaskService.updateProTask(task); proTaskService.updateProTask(task);
//如果是关键工序则更新当前工单的已生产数量进行产品产出动作 //如果是关键工序则更新当前工单的已生产数量进行产品产出动作

View File

@ -12,11 +12,17 @@ import com.ktg.common.utils.StringUtils;
import com.ktg.mes.md.domain.MdItem; import com.ktg.mes.md.domain.MdItem;
import com.ktg.mes.md.domain.MdProductBom; import com.ktg.mes.md.domain.MdProductBom;
import com.ktg.mes.md.service.IMdProductBomService; 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.domain.ProWorkorderBom;
import com.ktg.mes.pro.service.IProTaskService;
import com.ktg.mes.pro.service.IProWorkorderBomService; 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 io.minio.messages.Item;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
@ -53,6 +59,9 @@ public class ProWorkorderController extends BaseController
@Autowired @Autowired
private IMdProductBomService mdProductBomService; private IMdProductBomService mdProductBomService;
@Autowired
private IProTaskService proTaskService;
/** /**
* 查询生产工单列表 * 查询生产工单列表
*/ */
@ -237,4 +246,34 @@ public class ProWorkorderController extends BaseController
return results; 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<ProTask> 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();
}
} }

View File

@ -94,6 +94,11 @@ public class ProWorkorder extends TreeEntity
@Excel(name = "需求日期", width = 30, dateFormat = "yyyy-MM-dd") @Excel(name = "需求日期", width = 30, dateFormat = "yyyy-MM-dd")
private Date requestDate; 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 = "单据状态") @Excel(name = "单据状态")
private String status; private String status;
@ -326,6 +331,13 @@ public class ProWorkorder extends TreeEntity
return attr4; return attr4;
} }
public Date getFinishDate() {
return finishDate;
}
public void setFinishDate(Date finishDate) {
this.finishDate = finishDate;
}
@Override @Override
public String toString() { public String toString() {
@ -349,6 +361,7 @@ public class ProWorkorder extends TreeEntity
", clientCode='" + clientCode + '\'' + ", clientCode='" + clientCode + '\'' +
", clientName='" + clientName + '\'' + ", clientName='" + clientName + '\'' +
", requestDate=" + requestDate + ", requestDate=" + requestDate +
", finishDate=" + finishDate +
", status='" + status + '\'' + ", status='" + status + '\'' +
", attr1='" + attr1 + '\'' + ", attr1='" + attr1 + '\'' +
", attr2='" + attr2 + '\'' + ", attr2='" + attr2 + '\'' +

View File

@ -26,6 +26,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="requestDate" column="request_date" /> <result property="requestDate" column="request_date" />
<result property="parentId" column="parent_id" /> <result property="parentId" column="parent_id" />
<result property="ancestors" column="ancestors" /> <result property="ancestors" column="ancestors" />
<result property="finishDate" column="finish_date" />
<result property="status" column="status" /> <result property="status" column="status" />
<result property="remark" column="remark" /> <result property="remark" column="remark" />
<result property="attr1" column="attr1" /> <result property="attr1" column="attr1" />
@ -63,6 +64,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="clientCode != null and clientCode != ''"> and client_code = #{clientCode}</if> <if test="clientCode != null and clientCode != ''"> and client_code = #{clientCode}</if>
<if test="clientName != null and clientName != ''"> and client_name like concat('%', #{clientName}, '%')</if> <if test="clientName != null and clientName != ''"> and client_name like concat('%', #{clientName}, '%')</if>
<if test="requestDate != null "> and request_date = #{requestDate}</if> <if test="requestDate != null "> and request_date = #{requestDate}</if>
<if test="finishDate != null "> and finish_date = #{finishDate}</if>
<if test="parentId != null "> and parent_id = #{parentId}</if> <if test="parentId != null "> and parent_id = #{parentId}</if>
<if test="ancestors != null and ancestors != ''"> and ancestors = #{ancestors}</if> <if test="ancestors != null and ancestors != ''"> and ancestors = #{ancestors}</if>
<if test="status != null and status != ''"> and status = #{status}</if> <if test="status != null and status != ''"> and status = #{status}</if>
@ -101,6 +103,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="clientCode != null">client_code,</if> <if test="clientCode != null">client_code,</if>
<if test="clientName != null">client_name,</if> <if test="clientName != null">client_name,</if>
<if test="requestDate != null">request_date,</if> <if test="requestDate != null">request_date,</if>
<if test="finishDate != null">finish_date,</if>
<if test="parentId != null">parent_id,</if> <if test="parentId != null">parent_id,</if>
<if test="ancestors != null and ancestors != ''">ancestors,</if> <if test="ancestors != null and ancestors != ''">ancestors,</if>
<if test="status != null">status,</if> <if test="status != null">status,</if>
@ -133,6 +136,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="clientCode != null">#{clientCode},</if> <if test="clientCode != null">#{clientCode},</if>
<if test="clientName != null">#{clientName},</if> <if test="clientName != null">#{clientName},</if>
<if test="requestDate != null">#{requestDate},</if> <if test="requestDate != null">#{requestDate},</if>
<if test="finishDate != null">#{finishDate},</if>
<if test="parentId != null">#{parentId},</if> <if test="parentId != null">#{parentId},</if>
<if test="ancestors != null and ancestors != ''">#{ancestors},</if> <if test="ancestors != null and ancestors != ''">#{ancestors},</if>
<if test="status != null">#{status},</if> <if test="status != null">#{status},</if>
@ -169,6 +173,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="clientCode != null">client_code = #{clientCode},</if> <if test="clientCode != null">client_code = #{clientCode},</if>
<if test="clientName != null">client_name = #{clientName},</if> <if test="clientName != null">client_name = #{clientName},</if>
<if test="requestDate != null">request_date = #{requestDate},</if> <if test="requestDate != null">request_date = #{requestDate},</if>
<if test="finishDate != null">finish_date = #{finishDate},</if>
<if test="parentId != null">parent_id = #{parentId},</if> <if test="parentId != null">parent_id = #{parentId},</if>
<if test="ancestors != null and ancestors != ''">ancestors = #{ancestors},</if> <if test="ancestors != null and ancestors != ''">ancestors = #{ancestors},</if>
<if test="status != null">status = #{status},</if> <if test="status != null">status = #{status},</if>

View File

@ -71,7 +71,7 @@
) t ) t
left join sys_user su left join sys_user su
on t.create_by = su.user_name on t.create_by = su.user_name
order by create_time, task_type desc order by create_time desc, task_type desc
</select> </select>