Commit 3614a628 authored by chicheng's avatar chicheng

工序报工支持修改、手动推送

工序报工接口添加(切换原来的工序转移单接口)
parent acea36a3
package com.ximai.mes.constant;
/**
* 报工 SAP 推送状态
*/
public final class FeedbackSapPushConst {
/** 未推送 */
public static final String NOT_PUSHED = "0";
/** 已推送 */
public static final String PUSHED = "1";
/** 生产转移单(已废弃,保留兼容) */
public static final String TYPE_TRANSFER = "TRANSFER";
/** 工序报工单 */
public static final String TYPE_REPORT = "REPORT";
/** 生产入库 */
public static final String TYPE_STOCK_IN = "STOCK_IN";
private FeedbackSapPushConst() {
}
public static boolean isPushed(String sapPushStatus) {
return PUSHED.equals(sapPushStatus);
}
}
...@@ -103,7 +103,7 @@ public class ProFeedbackController extends BaseController { ...@@ -103,7 +103,7 @@ public class ProFeedbackController extends BaseController {
query.eq(StringUtils.isNotEmpty(proFeedbackCheckListDto.getTaskBatch()), "SUBSTRING_INDEX(ta.task_batch, '-', -1)", proFeedbackCheckListDto.getTaskBatch()); query.eq(StringUtils.isNotEmpty(proFeedbackCheckListDto.getTaskBatch()), "SUBSTRING_INDEX(ta.task_batch, '-', -1)", proFeedbackCheckListDto.getTaskBatch());
query.between(proFeedbackCheckListDto.getFeedbackTimeStart() != null && proFeedbackCheckListDto.getFeedbackTimeEnd() != null, query.between(proFeedbackCheckListDto.getFeedbackTimeStart() != null && proFeedbackCheckListDto.getFeedbackTimeEnd() != null,
"f.feedback_time", proFeedbackCheckListDto.getFeedbackTimeStart(), proFeedbackCheckListDto.getFeedbackTimeEnd()); "f.feedback_time", proFeedbackCheckListDto.getFeedbackTimeStart(), proFeedbackCheckListDto.getFeedbackTimeEnd());
query.orderByAsc("f.feedback_time"); query.orderByDesc("f.create_time");
startPage(); startPage();
List<ProFeedbackVo> list = proFeedbackService.queryProFeedbackListJoinTaskWorkUnit(query); List<ProFeedbackVo> list = proFeedbackService.queryProFeedbackListJoinTaskWorkUnit(query);
List<ProFeedbackVo> proFeedbackVoList = new ArrayList<>(); List<ProFeedbackVo> proFeedbackVoList = new ArrayList<>();
...@@ -166,7 +166,7 @@ public class ProFeedbackController extends BaseController { ...@@ -166,7 +166,7 @@ public class ProFeedbackController extends BaseController {
query.eq(StringUtils.isNotEmpty(proFeedbackCheckListDto.getTaskBatch()), "SUBSTRING_INDEX(ta.task_batch, '-', -1)", proFeedbackCheckListDto.getTaskBatch()); query.eq(StringUtils.isNotEmpty(proFeedbackCheckListDto.getTaskBatch()), "SUBSTRING_INDEX(ta.task_batch, '-', -1)", proFeedbackCheckListDto.getTaskBatch());
query.between(proFeedbackCheckListDto.getFeedbackTimeStart() != null && proFeedbackCheckListDto.getFeedbackTimeEnd() != null, query.between(proFeedbackCheckListDto.getFeedbackTimeStart() != null && proFeedbackCheckListDto.getFeedbackTimeEnd() != null,
"f.feedback_time", proFeedbackCheckListDto.getFeedbackTimeStart(), proFeedbackCheckListDto.getFeedbackTimeEnd()); "f.feedback_time", proFeedbackCheckListDto.getFeedbackTimeStart(), proFeedbackCheckListDto.getFeedbackTimeEnd());
query.orderByAsc("f.feedback_time"); query.orderByDesc("f.create_time");
List<ProFeedbackVo> list = proFeedbackService.queryProFeedbackListJoinTaskWorkUnit(query); List<ProFeedbackVo> list = proFeedbackService.queryProFeedbackListJoinTaskWorkUnit(query);
List<ProFeedbackVo> proFeedbackVoList = new ArrayList<>(); List<ProFeedbackVo> proFeedbackVoList = new ArrayList<>();
if (proFeedback.getUserId() != null) { if (proFeedback.getUserId() != null) {
...@@ -216,7 +216,7 @@ public class ProFeedbackController extends BaseController { ...@@ -216,7 +216,7 @@ public class ProFeedbackController extends BaseController {
query.between(StringUtils.isNotEmpty(proFeedback.getCreateStartTime()) && StringUtils.isNotEmpty(proFeedback.getCreateEndTime()), "f.update_time", proFeedback.getCreateStartTime(), proFeedback.getCreateEndTime()); query.between(StringUtils.isNotEmpty(proFeedback.getCreateStartTime()) && StringUtils.isNotEmpty(proFeedback.getCreateEndTime()), "f.update_time", proFeedback.getCreateStartTime(), proFeedback.getCreateEndTime());
query.like(StringUtils.isNotEmpty(proFeedback.getNickName()), "f.nick_name", proFeedback.getNickName()); query.like(StringUtils.isNotEmpty(proFeedback.getNickName()), "f.nick_name", proFeedback.getNickName());
query.notIn("tw.status", TaskWorkunitStatusEnum.CLOSE.getStatus()); query.notIn("tw.status", TaskWorkunitStatusEnum.CLOSE.getStatus());
query.orderByAsc("f.feedback_time"); query.orderByDesc("f.create_time");
List<ProFeedbackVo> list = proFeedbackService.queryProFeedbackListJoinTaskWorkUnit(query); List<ProFeedbackVo> list = proFeedbackService.queryProFeedbackListJoinTaskWorkUnit(query);
List<ProFeedbackVo> proFeedbackVoList = new ArrayList<>(); List<ProFeedbackVo> proFeedbackVoList = new ArrayList<>();
if (proFeedback.getUserId() != null) { if (proFeedback.getUserId() != null) {
...@@ -313,5 +313,24 @@ public class ProFeedbackController extends BaseController { ...@@ -313,5 +313,24 @@ public class ProFeedbackController extends BaseController {
return toAjax(proFeedbackService.syncSap(recordId)); return toAjax(proFeedbackService.syncSap(recordId));
} }
/**
* 批量推送 SAP:末道工序推生产入库,非末道工序推生产转移单
*/
@PreAuthorize("@ss.hasPermi('mes:pro:feedback:edit')")
@Log(title = "生产报工推送SAP", businessType = BusinessType.UPDATE)
@PostMapping("/syncSap")
public AjaxResult syncSapBatch(@RequestBody Long[] recordIds) {
return AjaxResult.success(proFeedbackService.syncSapBatch(recordIds));
}
/**
* 报工修改记录
*/
@PreAuthorize("@ss.hasPermi('mes:pro:feedback:query')")
@GetMapping("/modifyRecord/{recordId}")
public AjaxResult listModifyRecord(@PathVariable Long recordId) {
return AjaxResult.success(proFeedbackService.listModifyRecord(recordId));
}
} }
...@@ -336,6 +336,16 @@ public class ProFeedback extends BaseEntity { ...@@ -336,6 +336,16 @@ public class ProFeedback extends BaseEntity {
private String sapRequestParam; private String sapRequestParam;
private String sapResponse; private String sapResponse;
@ApiModelProperty("SAP推送状态:0未推送 1已推送")
private String sapPushStatus;
@ApiModelProperty("SAP推送类型:TRANSFER转移单 STOCK_IN入库")
private String sapPushType;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@ApiModelProperty("SAP推送时间")
private Date sapPushTime;
@ApiModelProperty( "异常原因ID") @ApiModelProperty( "异常原因ID")
private Long abnormalId; private Long abnormalId;
......
package com.ximai.mes.pro.domain;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.ximai.common.core.domain.BaseEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
/**
* 报工修改记录 pro_feedback_modify_record
*/
@Data
public class ProFeedbackModifyRecord extends BaseEntity {
@TableId
private Long id;
@ApiModelProperty("报工记录ID")
private Long recordId;
@ApiModelProperty("报工单编号")
private String feedbackCode;
@ApiModelProperty("工单ID")
private Long workorderId;
@ApiModelProperty("工单编号")
private String workorderCode;
@ApiModelProperty("任务ID")
private Long taskId;
@ApiModelProperty("工序名称")
private String processName;
@ApiModelProperty("修改前后JSON")
private String requestBody;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date createTime;
}
...@@ -315,4 +315,14 @@ public class ProFeedbackVo { ...@@ -315,4 +315,14 @@ public class ProFeedbackVo {
@Excel(name = "销售序号") @Excel(name = "销售序号")
private String orderSerial; private String orderSerial;
@ApiModelProperty("SAP推送状态:0未推送 1已推送")
private String sapPushStatus;
@ApiModelProperty("SAP推送类型")
private String sapPushType;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@ApiModelProperty("SAP推送时间")
private Date sapPushTime;
} }
package com.ximai.mes.pro.dto;
import lombok.Data;
import java.util.ArrayList;
import java.util.List;
/**
* 报工记录批量推送 SAP 结果
*/
@Data
public class FeedbackSapPushResult {
private int successCount;
private int failCount;
private List<String> messages = new ArrayList<>();
public void addSuccess(Long recordId, String pushType) {
successCount++;
messages.add(String.format("报工记录 %d 推送成功(%s)", recordId, pushType));
}
public void addFail(Long recordId, String reason) {
failCount++;
messages.add(String.format("报工记录 %d 推送失败:%s", recordId, reason));
}
}
...@@ -14,4 +14,6 @@ public class FeedbackDto { ...@@ -14,4 +14,6 @@ public class FeedbackDto {
ProTask nextTask; ProTask nextTask;
ProTaskWorkunit currTaskWorkunit; ProTaskWorkunit currTaskWorkunit;
ProTaskWorkunit nextTaskWorkunit; ProTaskWorkunit nextTaskWorkunit;
/** 报工表 machine_time(分钟) */
String machineTime;
} }
...@@ -130,6 +130,8 @@ public interface ProFeedbackMapper { ...@@ -130,6 +130,8 @@ public interface ProFeedbackMapper {
void updateLastFeedback(@Param("qrcode")String qrcode, @Param("taskId")Long taskId); void updateLastFeedback(@Param("qrcode")String qrcode, @Param("taskId")Long taskId);
int markSapPushed(@Param("recordId") Long recordId, @Param("pushType") String pushType, @Param("pushTime") java.util.Date pushTime);
List<FeedbackResponse> getList(FeedbackRequest feedbackRequest); List<FeedbackResponse> getList(FeedbackRequest feedbackRequest);
List<FeedbackResponse> getListByWorkOrder(FeedbackRequest feedbackRequest); List<FeedbackResponse> getListByWorkOrder(FeedbackRequest feedbackRequest);
......
package com.ximai.mes.pro.mapper;
import com.ximai.mes.pro.domain.ProFeedbackModifyRecord;
import java.util.List;
/**
* 报工修改记录 Mapper
*/
public interface ProFeedbackModifyRecordMapper {
int insertProFeedbackModifyRecord(ProFeedbackModifyRecord record);
List<ProFeedbackModifyRecord> selectByRecordId(Long recordId);
}
...@@ -2,6 +2,7 @@ package com.ximai.mes.pro.service; ...@@ -2,6 +2,7 @@ package com.ximai.mes.pro.service;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ximai.mes.pro.domain.ProFeedback; import com.ximai.mes.pro.domain.ProFeedback;
import com.ximai.mes.pro.domain.ProFeedbackModifyRecord;
import com.ximai.mes.pro.domain.task.ProTask; import com.ximai.mes.pro.domain.task.ProTask;
import com.ximai.mes.pro.domain.task.ProTaskAssistProcess; import com.ximai.mes.pro.domain.task.ProTaskAssistProcess;
import com.ximai.mes.pro.domain.vo.ProFeedbackSplitInfo; import com.ximai.mes.pro.domain.vo.ProFeedbackSplitInfo;
...@@ -9,8 +10,10 @@ import com.ximai.mes.pro.domain.vo.ProFeedbackVo; ...@@ -9,8 +10,10 @@ import com.ximai.mes.pro.domain.vo.ProFeedbackVo;
import com.ximai.mes.pro.domain.vo.ProPackagePrintResult; import com.ximai.mes.pro.domain.vo.ProPackagePrintResult;
import com.ximai.mes.pro.domain.vo.feedbackTaskVo; import com.ximai.mes.pro.domain.vo.feedbackTaskVo;
import com.ximai.mes.pro.domain.vo.task.FeedbackValidateSerialNoParams; import com.ximai.mes.pro.domain.vo.task.FeedbackValidateSerialNoParams;
import com.ximai.mes.pro.dto.FeedbackSapPushResult;
import com.ximai.mes.pro.dto.ProFeedbackDto; import com.ximai.mes.pro.dto.ProFeedbackDto;
import java.math.BigDecimal;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
...@@ -105,6 +108,13 @@ public interface IProFeedbackService { ...@@ -105,6 +108,13 @@ public interface IProFeedbackService {
*/ */
Double selectQuantityQualifySum(ProFeedback proFeedback); Double selectQuantityQualifySum(ProFeedback proFeedback);
/**
* 非首工序:本工序良品报工合计(含本次变更)不得超过上工序良品报工合计
*
* @param excludeQualify 修改场景排除原记录良品数,新增传 null
*/
void validateQualifyNotExceedPreviousProcess(Long taskId, Long workorderId, BigDecimal excludeQualify, BigDecimal newQualify);
LinkedHashMap<String, ProFeedbackSplitInfo> taskFeedback(ProTask proTask, ProFeedback mainFeedBack); LinkedHashMap<String, ProFeedbackSplitInfo> taskFeedback(ProTask proTask, ProFeedback mainFeedBack);
...@@ -112,6 +122,18 @@ public interface IProFeedbackService { ...@@ -112,6 +122,18 @@ public interface IProFeedbackService {
int syncSap(Long recordId); int syncSap(Long recordId);
FeedbackSapPushResult syncSapBatch(Long[] recordIds);
/**
* 自动推送成功后标记 SAP 已推送(受 ERP 开关控制)
*/
void markSapPushedAfterAuto(Long recordId, String erpSwitchKey, String pushType);
/**
* 查询报工修改记录
*/
List<ProFeedbackModifyRecord> listModifyRecord(Long recordId);
int insertObj(ProFeedback proFeedback); int insertObj(ProFeedback proFeedback);
List<feedbackTaskVo> selectProFeedbackreport(feedbackTaskVo feedbackTaskVo); List<feedbackTaskVo> selectProFeedbackreport(feedbackTaskVo feedbackTaskVo);
......
...@@ -343,10 +343,12 @@ public class ProTaskAssistProcessServiceImpl implements IProTaskAssistProcessSer ...@@ -343,10 +343,12 @@ public class ProTaskAssistProcessServiceImpl implements IProTaskAssistProcessSer
proTaskService.updateProTask(task); proTaskService.updateProTask(task);
proTaskWorkunitService.updateProTaskWorkunit(taskWorkunit); proTaskWorkunitService.updateProTaskWorkunit(taskWorkunit);
// 末道工序:与普通报工 doFeedBack 一致,回写工单并触发 ERP 完工入库(reportUpdateProWorkorder) // 末道工序:与普通报工 doFeedBack 一致,回写工单并触发 ERP 完工入库(reportUpdateProWorkorder,开关 erp.finish.stockin.create.enable
if (nextTask == null && quantityQualify.compareTo(BigDecimal.ZERO) > 0) { if (nextTask == null && quantityQualify.compareTo(BigDecimal.ZERO) > 0) {
if (workorder != null) { if (workorder != null) {
proWorkorderService.reportUpdateProWorkorder(workorder, quantityQualify, quantityUnQualify); proWorkorderService.reportUpdateProWorkorder(workorder, quantityQualify, quantityUnQualify);
proFeedbackService.markSapPushedAfterAuto(feedback.getRecordId(),
"erp.finish.stockin.create.enable", com.ximai.mes.constant.FeedbackSapPushConst.TYPE_STOCK_IN);
} }
tryFinishWorkorderOnLastProcessComplete(task); tryFinishWorkorderOnLastProcessComplete(task);
} }
......
...@@ -56,7 +56,7 @@ import com.ximai.mes.pro.service.proWorkOrder.IProWorkorderService; ...@@ -56,7 +56,7 @@ import com.ximai.mes.pro.service.proWorkOrder.IProWorkorderService;
import com.ximai.mes.pro.service.task.IProTaskService; import com.ximai.mes.pro.service.task.IProTaskService;
import com.ximai.mes.pro.service.task.IProTaskWorkunitService; import com.ximai.mes.pro.service.task.IProTaskWorkunitService;
import com.ximai.mes.qc.service.IQcIpqcService; import com.ximai.mes.qc.service.IQcIpqcService;
import com.ximai.mes.remote.process.ProcessTransferCreateProcess; import com.ximai.mes.remote.process.ProcessReportCreateProcess;
import com.ximai.mes.tm.domain.vo.TmToolRequestItemVo; import com.ximai.mes.tm.domain.vo.TmToolRequestItemVo;
import com.ximai.mes.tm.service.ITmToolMachinesService; import com.ximai.mes.tm.service.ITmToolMachinesService;
import com.ximai.mes.tm.service.ITmToolRequestService; import com.ximai.mes.tm.service.ITmToolRequestService;
...@@ -866,23 +866,19 @@ public class ProTaskServiceImpl implements IProTaskService, ApplicationContextAw ...@@ -866,23 +866,19 @@ public class ProTaskServiceImpl implements IProTaskService, ApplicationContextAw
queryWrapper.eq("t1.workorder_code", task.getArrangeCode()); queryWrapper.eq("t1.workorder_code", task.getArrangeCode());
queryWrapper.notIn("t1.status", Arrays.asList(WorkorderStatusEnum.CLOSE.getValue(), WorkorderStatusEnum.CANCEL.getValue(), WorkorderStatusEnum.CANCELED.getValue())); queryWrapper.notIn("t1.status", Arrays.asList(WorkorderStatusEnum.CLOSE.getValue(), WorkorderStatusEnum.CANCEL.getValue(), WorkorderStatusEnum.CANCELED.getValue()));
List<ProWorkorder> proWorkorders = proWorkorderService.selectListByQw(queryWrapper); List<ProWorkorder> proWorkorders = proWorkorderService.selectListByQw(queryWrapper);
//检查该工单绑定的生产版本是否允许超报,PS只有首工序允许 if (task.getOrdinal() != null && task.getOrdinal() != 1) {
if(taskQuantityWaitConst.compareTo(feedbackQualifyConst.add(fuantityUnqualify)) < 0){ proFeedbackService.validateQualifyNotExceedPreviousProcess(task.getTaskId(), feedback.getWorkorderId(), null, feedbackQualifyConst);
if(task.getOrdinal() == 1){ } else if (taskQuantityWaitConst.compareTo(feedbackQualifyConst.add(fuantityUnqualify)) < 0) {
if(proWorkorders.size() > 0 && proWorkorders.get(0).getProductionSolutionId() != null){ if (proWorkorders.size() > 0 && proWorkorders.get(0).getProductionSolutionId() != null) {
ProProductionSolution proProductionSolution ProProductionSolution proProductionSolution
= proProductionSolutionMapper.selectProProductionSolutionByProductionSolutionId(proWorkorders.get(0).getProductionSolutionId()); = proProductionSolutionMapper.selectProProductionSolutionByProductionSolutionId(proWorkorders.get(0).getProductionSolutionId());
if(proProductionSolution != null && proProductionSolution.getSurpassState() != null){ if (proProductionSolution != null && proProductionSolution.getSurpassState() != null) {
if(!proProductionSolution.getSurpassState()){ if (!proProductionSolution.getSurpassState()) {
//不允许超报 可报工数目 - (合格数 + 不合格数)不能小于 0
ExceptionUtil.checkTrueThrowException( ExceptionUtil.checkTrueThrowException(
taskQuantityWaitConst.compareTo(feedbackQualifyConst.add(fuantityUnqualify)) < 0, "工单关联的生产版本不允许超报行为"); taskQuantityWaitConst.compareTo(feedbackQualifyConst.add(fuantityUnqualify)) < 0, "工单关联的生产版本不允许超报行为");
} }
} }
} }
}else{
ExceptionUtil.checkTrueThrowException(true, "非首工序不允许超过可报工数报工");
}
} }
//本次合格数和不合格数总和大于可报工数目 与 已报工数目已经超过了排产数量 //本次合格数和不合格数总和大于可报工数目 与 已报工数目已经超过了排产数量
...@@ -945,20 +941,31 @@ public class ProTaskServiceImpl implements IProTaskService, ApplicationContextAw ...@@ -945,20 +941,31 @@ public class ProTaskServiceImpl implements IProTaskService, ApplicationContextAw
if (StringUtils.isEmpty(nextTask)) { if (StringUtils.isEmpty(nextTask)) {
feedbackWorkorder.forEach((k, v) -> { feedbackWorkorder.forEach((k, v) -> {
proWorkorderService.reportUpdateProWorkorder(v.getWorkorder(), v.getQuantityQualify(), v.getQuantityUnqualify()); proWorkorderService.reportUpdateProWorkorder(v.getWorkorder(), v.getQuantityQualify(), v.getQuantityUnqualify());
v.getFeedbackList().forEach(f -> proFeedbackService.markSapPushedAfterAuto(
f.getRecordId(), "erp.finish.stockin.create.enable", com.ximai.mes.constant.FeedbackSapPushConst.TYPE_STOCK_IN));
}); });
} }
} }
proTaskWorkunitService.updateProTaskWorkunit(taskWorkunit); proTaskWorkunitService.updateProTaskWorkunit(taskWorkunit);
if (nextTask != null) {
feedbackWorkorder.forEach((k, v) -> { feedbackWorkorder.forEach((k, v) -> {
String machineTimeMinutes = v.getFeedbackList().stream()
.map(f -> DataUtil.getNormalData(f.getMachineTime(), BigDecimal.class))
.reduce(BigDecimal.ZERO, BigDecimal::add)
.stripTrailingZeros()
.toPlainString();
FeedbackDto feedbackDto = FeedbackDto.builder().workorder(v.getWorkorder()).currTask(task).currTaskWorkunit(taskWorkunit) FeedbackDto feedbackDto = FeedbackDto.builder().workorder(v.getWorkorder()).currTask(task).currTaskWorkunit(taskWorkunit)
.nextTask(nextTask).nextTaskWorkunit(nextTaskWorkunit.get()).build(); .nextTask(nextTask).nextTaskWorkunit(nextTaskWorkunit.get()).machineTime(machineTimeMinutes).build();
applicationContext.getBean(ProTaskServiceImpl.class).feedbackToErp(feedbackDto, v.getQuantityQualify(), v.getQuantityUnqualify()); applicationContext.getBean(ProTaskServiceImpl.class).feedbackToErp(feedbackDto, v.getQuantityQualify(), v.getQuantityUnqualify());
v.getFeedbackList().forEach(f -> proFeedbackService.markSapPushedAfterAuto(
f.getRecordId(), "erp.process.report.create.enable", com.ximai.mes.constant.FeedbackSapPushConst.TYPE_REPORT));
}); });
}
return response; return response;
} }
@MethodExtendedProcesses(config ={ @MethodExtendedProcesses(config ={
@MethodExtendedProcess(sysSwitchParam = "erp.process.finish.create.enable", processClz = ProcessTransferCreateProcess.class, @MethodExtendedProcess(sysSwitchParam = "erp.process.report.create.enable", processClz = ProcessReportCreateProcess.class,
newThread = true, errorCatch = true) newThread = true, errorCatch = true)
}) })
@Override @Override
...@@ -1394,6 +1401,23 @@ public class ProTaskServiceImpl implements IProTaskService, ApplicationContextAw ...@@ -1394,6 +1401,23 @@ public class ProTaskServiceImpl implements IProTaskService, ApplicationContextAw
return tasks.get(0); return tasks.get(0);
} }
@Override
public ProTask getPreviousTaskByTaskId(Long taskId) {
ProTask thisProTask = this.selectProTaskByTaskId(taskId);
if (thisProTask == null || thisProTask.getOrdinal() == null || thisProTask.getOrdinal() <= 1) {
return null;
}
QueryWrapper<ProTask> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("task_batch", thisProTask.getTaskBatch());
queryWrapper.lt("ordinal", thisProTask.getOrdinal());
queryWrapper.orderByDesc("ordinal");
List<ProTask> tasks = proTaskMapper.selectListByQw(queryWrapper);
if (tasks.isEmpty()) {
return null;
}
return tasks.get(0);
}
@Override @Override
public List<ProTask> selectListByQw(QueryWrapper<ProTask> proTaskQueryWrapper) { public List<ProTask> selectListByQw(QueryWrapper<ProTask> proTaskQueryWrapper) {
return proTaskMapper.selectListJoinByQw(proTaskQueryWrapper); return proTaskMapper.selectListJoinByQw(proTaskQueryWrapper);
......
...@@ -188,6 +188,11 @@ public interface IProTaskService { ...@@ -188,6 +188,11 @@ public interface IProTaskService {
ProTask getNextTaskByTaskId(Long taskId); ProTask getNextTaskByTaskId(Long taskId);
/**
* 获取上一道工序任务(同排产批次)
*/
ProTask getPreviousTaskByTaskId(Long taskId);
ProTask selectBaseById(Long taskId); ProTask selectBaseById(Long taskId);
List<ProTask> getTaskList(ProTaskQuery proTask); List<ProTask> getTaskList(ProTaskQuery proTask);
......
...@@ -79,4 +79,9 @@ public interface ErpService { ...@@ -79,4 +79,9 @@ public interface ErpService {
@PostMapping(value = "/sfctb/processTransfer") @PostMapping(value = "/sfctb/processTransfer")
ErpResponseResult<Object> processTransfer(ProcessTransferCreate create); ErpResponseResult<Object> processTransfer(ProcessTransferCreate create);
@ApiLog(businessType = BusinessType.UPDATE, inOutType = InOutType.OUT)
@ApiOperation(value = "ERP工序报工")
@PostMapping(value = "/sfctd/processReport")
ErpResponseResult<Object> processReportCreate(ProcessReportCreate create);
} }
...@@ -34,6 +34,18 @@ public class FinishStockInCreateDetail ...@@ -34,6 +34,18 @@ public class FinishStockInCreateDetail
@JsonProperty("tg013") @JsonProperty("tg013")
private BigDecimal checkQuantity; private BigDecimal checkQuantity;
@ApiModelProperty("报废数量")
@JsonProperty("tg012")
private BigDecimal scrapQuantity = BigDecimal.ZERO;
@ApiModelProperty("验退数量")
@JsonProperty("tg023")
private BigDecimal returnQuantity = BigDecimal.ZERO;
@ApiModelProperty("破坏数量")
@JsonProperty("tg032")
private BigDecimal destroyQuantity = BigDecimal.ZERO;
@ApiModelProperty("批号") @ApiModelProperty("批号")
@JsonProperty("tg017") @JsonProperty("tg017")
private String batchNo; private String batchNo;
......
package com.ximai.mes.remote.dto;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
/**
* 工序报工单创建
*/
@Data
public class ProcessReportCreate {
@ApiModelProperty("报工单单别")
@JsonProperty("td001")
private String reportType = "D30";
@ApiModelProperty("工单单别")
@JsonProperty("te006")
private String workOrderType;
@ApiModelProperty("工单单号")
@JsonProperty("te007")
private String workOrderNo;
@ApiModelProperty("工序(加工顺序)")
@JsonProperty("te008")
private String processSeq;
@ApiModelProperty("工序号")
@JsonProperty("te009")
private String processRef;
@ApiModelProperty("类型(1:正常完成 2:返工完成 3:报废)")
@JsonProperty("te010")
private String type = "1";
@ApiModelProperty("报工数量(合格)")
@JsonProperty("te011")
private BigDecimal reportQty;
@ApiModelProperty("不合格数量(固定0,不推送MES不合格数)")
@JsonProperty("unQualifyQty")
private BigDecimal unQualifyQty = BigDecimal.ZERO;
@ApiModelProperty("使用机时(秒)")
@JsonProperty("te013")
private Integer machineHours;
@ApiModelProperty("员工编号")
@JsonProperty("te004")
private String employeeNo;
@ApiModelProperty("机器编号")
@JsonProperty("te005")
private String machineNo;
@ApiModelProperty("工序名称/备注")
@JsonProperty("te015")
private String processName;
}
...@@ -44,6 +44,9 @@ public class FinishStockInCreateProcess implements IExtendedProcess { ...@@ -44,6 +44,9 @@ public class FinishStockInCreateProcess implements IExtendedProcess {
detail.setWorkorderCode(workorder.getWorkorderCode()); detail.setWorkorderCode(workorder.getWorkorderCode());
detail.setCheckQuantity(qualifyQuantity); detail.setCheckQuantity(qualifyQuantity);
detail.setInQuantity(qualifyQuantity); detail.setInQuantity(qualifyQuantity);
detail.setScrapQuantity(BigDecimal.ZERO);
detail.setReturnQuantity(BigDecimal.ZERO);
detail.setDestroyQuantity(BigDecimal.ZERO);
detail.setBatchNo(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMdd"))); detail.setBatchNo(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMdd")));
details.add(detail); details.add(detail);
create.setDetails(details); create.setDetails(details);
......
package com.ximai.mes.remote.process;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ximai.mes.aspect.IExtendedProcess;
import com.ximai.mes.pro.domain.proWorkOrder.ProWorkOrderProcess;
import com.ximai.mes.pro.domain.task.ProTask;
import com.ximai.mes.pro.dto.task.FeedbackDto;
import com.ximai.mes.pro.service.proWorkOrder.IProWorkOrderProcessService;
import com.ximai.mes.remote.ErpService;
import com.ximai.mes.remote.dto.ProcessReportCreate;
import com.ximai.mes.remote.util.ErpMachineTimeConverter;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.math.BigDecimal;
import java.util.List;
@ApiOperation("工序报工")
@Component
public class ProcessReportCreateProcess implements IExtendedProcess {
@Autowired
ErpService erpService;
@Autowired
IProWorkOrderProcessService workOrderProcessService;
@Override
public void process(Object[] args, Object returnResult) {
FeedbackDto feedbackDto = (FeedbackDto) args[0];
BigDecimal qualifyQuantity = (BigDecimal) args[1];
ProTask currTask = feedbackDto.getCurrTask();
ProcessReportCreate create = new ProcessReportCreate();
create.setWorkOrderType(feedbackDto.getWorkorder().getWorkorderType());
create.setWorkOrderNo(feedbackDto.getWorkorder().getWorkorderCode());
create.setProcessSeq(currTask.getIdx());
create.setProcessName(currTask.getProcessName());
create.setReportQty(qualifyQuantity);
create.setUnQualifyQty(BigDecimal.ZERO);
create.setType("1");
create.setMachineHours(ErpMachineTimeConverter.toMachineSeconds(feedbackDto.getMachineTime()));
List<ProWorkOrderProcess> workorderProcessList = workOrderProcessService.selectListByQw(
new QueryWrapper<ProWorkOrderProcess>()
.eq("t1.workorder_id", feedbackDto.getWorkorder().getWorkorderId())
.eq("t1.process_id", currTask.getProcessId()));
String processNo = currTask.getProcessCode();
if (!workorderProcessList.isEmpty()) {
ProWorkOrderProcess workOrderProcess = workorderProcessList.get(0);
if (StringUtils.isBlank(processNo)) {
processNo = workOrderProcess.getProcessRef();
}
}
if (StringUtils.isBlank(processNo)) {
processNo = currTask.getIdx();
}
create.setProcessRef(StringUtils.left(processNo, 4));
erpService.processReportCreate(create);
}
}
package com.ximai.mes.remote.util;
import org.apache.commons.lang3.StringUtils;
import java.math.BigDecimal;
import java.math.RoundingMode;
/**
* 报工 machine_time 转 ERP 机时(秒)
* <p>
* pro_feedback.machine_time 在自动报工时由开工记录秒数 / 60 写入,单位为<strong>分钟</strong>;
* SFCTE.TE013 单位为秒。
*/
public final class ErpMachineTimeConverter {
private ErpMachineTimeConverter() {
}
public static int toMachineSeconds(String machineTimeMinutes) {
if (StringUtils.isBlank(machineTimeMinutes)) {
return 0;
}
try {
return new BigDecimal(machineTimeMinutes.trim())
.multiply(BigDecimal.valueOf(60))
.setScale(0, RoundingMode.HALF_UP)
.intValue();
} catch (NumberFormatException e) {
return 0;
}
}
}
...@@ -16,6 +16,9 @@ ...@@ -16,6 +16,9 @@
<result property="sapFeedbackItemCode" column="sap_feedback_item_code"/> <result property="sapFeedbackItemCode" column="sap_feedback_item_code"/>
<result property="sapRequestParam" column="sap_request_param"/> <result property="sapRequestParam" column="sap_request_param"/>
<result property="sapResponse" column="sap_response"/> <result property="sapResponse" column="sap_response"/>
<result property="sapPushStatus" column="sap_push_status"/>
<result property="sapPushType" column="sap_push_type"/>
<result property="sapPushTime" column="sap_push_time"/>
<result property="workorderId" column="workorder_id"/> <result property="workorderId" column="workorder_id"/>
<result property="workorderCode" column="workorder_code"/> <result property="workorderCode" column="workorder_code"/>
<result property="workorderName" column="workorder_name"/> <result property="workorderName" column="workorder_name"/>
...@@ -68,6 +71,9 @@ ...@@ -68,6 +71,9 @@
f.workstation_name, f.workstation_name,
f.sap_request_param, f.sap_request_param,
f.sap_response, f.sap_response,
f.sap_push_status,
f.sap_push_type,
f.sap_push_time,
f.sap_feedback_code, f.sap_feedback_code,
f.sap_feedback_item_code, f.sap_feedback_item_code,
f.machine_time, f.machine_time,
...@@ -1046,6 +1052,9 @@ ...@@ -1046,6 +1052,9 @@
<if test="sapFeedbackItemCode != null">sap_feedback_item_code,</if> <if test="sapFeedbackItemCode != null">sap_feedback_item_code,</if>
<if test="sapRequestParam != null">sap_request_param,</if> <if test="sapRequestParam != null">sap_request_param,</if>
<if test="sapResponse != null">sap_response,</if> <if test="sapResponse != null">sap_response,</if>
<if test="sapPushStatus != null">sap_push_status,</if>
<if test="sapPushType != null">sap_push_type,</if>
<if test="sapPushTime != null">sap_push_time,</if>
<if test="processId != null">process_id,</if> <if test="processId != null">process_id,</if>
<if test="processCode != null">process_code,</if> <if test="processCode != null">process_code,</if>
<if test="processName != null">process_name,</if> <if test="processName != null">process_name,</if>
...@@ -1105,6 +1114,9 @@ ...@@ -1105,6 +1114,9 @@
<if test="sapFeedbackItemCode != null">#{sapFeedbackItemCode},</if> <if test="sapFeedbackItemCode != null">#{sapFeedbackItemCode},</if>
<if test="sapRequestParam != null">#{sapRequestParam},</if> <if test="sapRequestParam != null">#{sapRequestParam},</if>
<if test="sapResponse != null">#{sapResponse},</if> <if test="sapResponse != null">#{sapResponse},</if>
<if test="sapPushStatus != null">#{sapPushStatus},</if>
<if test="sapPushType != null">#{sapPushType},</if>
<if test="sapPushTime != null">#{sapPushTime},</if>
<if test="processId != null">#{processId},</if> <if test="processId != null">#{processId},</if>
<if test="processCode != null">#{processCode},</if> <if test="processCode != null">#{processCode},</if>
<if test="processName != null">#{processName},</if> <if test="processName != null">#{processName},</if>
...@@ -1168,6 +1180,9 @@ ...@@ -1168,6 +1180,9 @@
<if test="sapFeedbackItemCode != null">sap_feedback_item_code = #{sapFeedbackItemCode},</if> <if test="sapFeedbackItemCode != null">sap_feedback_item_code = #{sapFeedbackItemCode},</if>
<if test="sapRequestParam != null">sap_request_param = #{sapRequestParam},</if> <if test="sapRequestParam != null">sap_request_param = #{sapRequestParam},</if>
<if test="sapResponse != null">sap_response = #{sapResponse},</if> <if test="sapResponse != null">sap_response = #{sapResponse},</if>
<if test="sapPushStatus != null">sap_push_status = #{sapPushStatus},</if>
<if test="sapPushType != null">sap_push_type = #{sapPushType},</if>
<if test="sapPushTime != null">sap_push_time = #{sapPushTime},</if>
<if test="processId != null">process_id = #{processId},</if> <if test="processId != null">process_id = #{processId},</if>
<if test="processCode != null">process_code = #{processCode},</if> <if test="processCode != null">process_code = #{processCode},</if>
<if test="processName != null">process_name = #{processName},</if> <if test="processName != null">process_name = #{processName},</if>
...@@ -1223,6 +1238,15 @@ ...@@ -1223,6 +1238,15 @@
<update id="updateLastFeedback"> <update id="updateLastFeedback">
update pro_feedback set last_feedback = false where qrcode = #{qrcode} and task_id = #{taskId} update pro_feedback set last_feedback = false where qrcode = #{qrcode} and task_id = #{taskId}
</update> </update>
<update id="markSapPushed">
update pro_feedback
set sap_push_status = '1',
sap_push_type = #{pushType},
sap_push_time = #{pushTime},
update_time = #{pushTime}
where record_id = #{recordId}
and (sap_push_status is null or sap_push_status = '0')
</update>
<delete id="deleteProFeedbackByRecordId" parameterType="Long"> <delete id="deleteProFeedbackByRecordId" parameterType="Long">
delete delete
......
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ximai.mes.pro.mapper.ProFeedbackModifyRecordMapper">
<resultMap type="com.ximai.mes.pro.domain.ProFeedbackModifyRecord" id="ProFeedbackModifyRecordResult">
<result property="id" column="id"/>
<result property="recordId" column="record_id"/>
<result property="feedbackCode" column="feedback_code"/>
<result property="workorderId" column="workorder_id"/>
<result property="workorderCode" column="workorder_code"/>
<result property="taskId" column="task_id"/>
<result property="processName" column="process_name"/>
<result property="requestBody" column="request_body"/>
<result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/>
<result property="remark" column="remark"/>
</resultMap>
<insert id="insertProFeedbackModifyRecord" parameterType="com.ximai.mes.pro.domain.ProFeedbackModifyRecord"
useGeneratedKeys="true" keyProperty="id">
insert into pro_feedback_modify_record
(record_id, feedback_code, workorder_id, workorder_code, task_id, process_name, request_body, create_by, create_time, remark)
values
(#{recordId}, #{feedbackCode}, #{workorderId}, #{workorderCode}, #{taskId}, #{processName}, #{requestBody},
#{createBy}, #{createTime}, #{remark})
</insert>
<select id="selectByRecordId" resultMap="ProFeedbackModifyRecordResult">
select id, record_id, feedback_code, workorder_id, workorder_code, task_id, process_name,
request_body, create_by, create_time, remark
from pro_feedback_modify_record
where record_id = #{recordId}
order by create_time desc
</select>
</mapper>
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