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 {
query.eq(StringUtils.isNotEmpty(proFeedbackCheckListDto.getTaskBatch()), "SUBSTRING_INDEX(ta.task_batch, '-', -1)", proFeedbackCheckListDto.getTaskBatch());
query.between(proFeedbackCheckListDto.getFeedbackTimeStart() != null && proFeedbackCheckListDto.getFeedbackTimeEnd() != null,
"f.feedback_time", proFeedbackCheckListDto.getFeedbackTimeStart(), proFeedbackCheckListDto.getFeedbackTimeEnd());
query.orderByAsc("f.feedback_time");
query.orderByDesc("f.create_time");
startPage();
List<ProFeedbackVo> list = proFeedbackService.queryProFeedbackListJoinTaskWorkUnit(query);
List<ProFeedbackVo> proFeedbackVoList = new ArrayList<>();
......@@ -166,7 +166,7 @@ public class ProFeedbackController extends BaseController {
query.eq(StringUtils.isNotEmpty(proFeedbackCheckListDto.getTaskBatch()), "SUBSTRING_INDEX(ta.task_batch, '-', -1)", proFeedbackCheckListDto.getTaskBatch());
query.between(proFeedbackCheckListDto.getFeedbackTimeStart() != null && proFeedbackCheckListDto.getFeedbackTimeEnd() != null,
"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> proFeedbackVoList = new ArrayList<>();
if (proFeedback.getUserId() != null) {
......@@ -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.like(StringUtils.isNotEmpty(proFeedback.getNickName()), "f.nick_name", proFeedback.getNickName());
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> proFeedbackVoList = new ArrayList<>();
if (proFeedback.getUserId() != null) {
......@@ -313,5 +313,24 @@ public class ProFeedbackController extends BaseController {
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 {
private String sapRequestParam;
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")
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 {
@Excel(name = "销售序号")
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 {
ProTask nextTask;
ProTaskWorkunit currTaskWorkunit;
ProTaskWorkunit nextTaskWorkunit;
/** 报工表 machine_time(分钟) */
String machineTime;
}
......@@ -130,6 +130,8 @@ public interface ProFeedbackMapper {
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> 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;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
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.ProTaskAssistProcess;
import com.ximai.mes.pro.domain.vo.ProFeedbackSplitInfo;
......@@ -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.feedbackTaskVo;
import com.ximai.mes.pro.domain.vo.task.FeedbackValidateSerialNoParams;
import com.ximai.mes.pro.dto.FeedbackSapPushResult;
import com.ximai.mes.pro.dto.ProFeedbackDto;
import java.math.BigDecimal;
import java.util.LinkedHashMap;
import java.util.List;
......@@ -105,6 +108,13 @@ public interface IProFeedbackService {
*/
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);
......@@ -112,6 +122,18 @@ public interface IProFeedbackService {
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);
List<feedbackTaskVo> selectProFeedbackreport(feedbackTaskVo feedbackTaskVo);
......
......@@ -3,6 +3,7 @@ package com.ximai.mes.pro.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ximai.common.constant.UserConstants;
import com.ximai.common.exception.ServiceException;
......@@ -12,6 +13,7 @@ import com.ximai.common.utils.data.DateUtils;
import com.ximai.common.utils.data.ExceptionUtil;
import com.ximai.common.utils.data.StringUtils;
import com.ximai.mes.cal.service.ICalPlanWorkunitService;
import com.ximai.mes.constant.FeedbackSapPushConst;
import com.ximai.mes.constant.ProStartWorkEnum;
import com.ximai.mes.constant.TaskWorkunitStatusEnum;
import com.ximai.mes.constant.WorkorderConst;
......@@ -22,19 +24,19 @@ import com.ximai.mes.md.mapper.MdWorkstationMapper;
import com.ximai.mes.md.service.IMdItemService;
import com.ximai.mes.md.service.IMdWorkstationService;
import com.ximai.mes.pro.domain.*;
import com.ximai.mes.pro.domain.proWorkOrder.ProWorkOrderProcess;
import com.ximai.mes.pro.domain.proWorkOrder.ProWorkOrderProcessItem;
import com.ximai.mes.pro.domain.proWorkOrder.ProWorkorder;
import com.ximai.mes.pro.domain.productionSolution.ProProductionSolution;
import com.ximai.mes.pro.domain.sap.SAPDtoFeedback;
import com.ximai.mes.pro.domain.task.ProTask;
import com.ximai.mes.pro.domain.task.ProTaskWorkunit;
import com.ximai.mes.pro.domain.vo.ProFeedbackSplitInfo;
import com.ximai.mes.pro.domain.vo.ProFeedbackVo;
import com.ximai.mes.pro.domain.vo.ProPackagePrintResult;
import com.ximai.mes.pro.domain.vo.feedbackTaskVo;
import com.ximai.mes.pro.domain.vo.*;
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.task.FeedbackDto;
import com.ximai.mes.remote.process.FinishStockInCreateProcess;
import com.ximai.mes.remote.process.ProcessReportCreateProcess;
import com.ximai.mes.pro.mapper.*;
import com.ximai.mes.pro.mapper.proWorkOrder.ProWorkOrderProcessItemMapper;
import com.ximai.mes.pro.mapper.proWorkOrder.ProWorkorderMapper;
......@@ -48,8 +50,11 @@ import com.ximai.mes.pro.service.proWorkOrder.IProWorkOrderProcessService;
import com.ximai.mes.pro.service.proWorkOrder.IProWorkorderService;
import com.ximai.mes.pro.service.task.IProTaskService;
import com.ximai.mes.pro.service.task.IProTaskWorkunitService;
import com.ximai.common.utils.SecurityUtils;
import com.ximai.system.strategy.AutoCodeUtil;
import com.ximai.system.service.ISysConfigService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
......@@ -117,9 +122,21 @@ public class ProFeedbackServiceImpl implements IProFeedbackService {
@Resource
private ProRecoilMaterialMapper proRecoilMaterialMapper;
@Resource
private ProFeedbackModifyRecordMapper proFeedbackModifyRecordMapper;
@Autowired
private AutoCodeUtil autoCodeUtil;
@Autowired
private ProcessReportCreateProcess processReportCreateProcess;
@Autowired
private FinishStockInCreateProcess finishStockInCreateProcess;
@Autowired
private ISysConfigService configService;
// 判断工单分割报工
private static Double splitFeedBack(Double execSize, Map<Long, List<ProFeedback>> feedbackGroupMap, ProWorkorder proWorkorder, BigDecimal reportSize, ProFeedback feedback, Long itemSecond, BigDecimal qualifySize, BigDecimal unQualifySize, List<ProFeedback> tempFeedback, LinkedHashMap<String, ProFeedbackSplitInfo> feedbackWorkorder) {
......@@ -346,6 +363,9 @@ public class ProFeedbackServiceImpl implements IProFeedbackService {
public int insertProFeedback(ProFeedback proFeedback) {
proFeedback.createAction();
proFeedback.setFeedbackCode(autoCodeUtil.genSerialCode(UserConstants.FEEDBACK_CODE, ""));
if (StringUtils.isEmpty(proFeedback.getSapPushStatus())) {
proFeedback.setSapPushStatus(FeedbackSapPushConst.NOT_PUSHED);
}
return proFeedbackMapper.insertProFeedback(proFeedback);
}
......@@ -555,6 +575,7 @@ public class ProFeedbackServiceImpl implements IProFeedbackService {
// 保存数据
proFeedback.setCreateTime(new Date());
this.insertProFeedback(proFeedback);
feedbackSplitInfo.getFeedbackList().add(proFeedback);
}
return feedbackWorkorderMap;
......@@ -669,16 +690,108 @@ public class ProFeedbackServiceImpl implements IProFeedbackService {
@Override
public int syncSap(Long recordId) {
QueryWrapper<ProFeedback> proFeedbackQueryWrapper = new QueryWrapper<>();
proFeedbackQueryWrapper.eq("record_id", recordId);
List<ProFeedback> proFeedbacks = proFeedbackMapper.selectListByQw(proFeedbackQueryWrapper);
ProFeedback proFeedback = proFeedbacks.get(0);
this.updateProFeedback(proFeedback);
FeedbackSapPushResult result = syncSapBatch(new Long[]{recordId});
if (result.getFailCount() > 0) {
throw new ServiceException(result.getMessages().get(0));
}
return 1;
}
@Override
public FeedbackSapPushResult syncSapBatch(Long[] recordIds) {
FeedbackSapPushResult result = new FeedbackSapPushResult();
if (recordIds == null || recordIds.length == 0) {
throw new ServiceException(MessageUtils.message("pro.feedback.error.not.data"));
}
for (Long recordId : recordIds) {
try {
String pushType = pushFeedbackToSap(recordId);
result.addSuccess(recordId, pushType);
} catch (Exception e) {
log.error("报工记录 {} 推送 SAP 失败", recordId, e);
result.addFail(recordId, e.getMessage());
}
}
return result;
}
@Override
public void markSapPushedAfterAuto(Long recordId, String erpSwitchKey, String pushType) {
if (recordId == null || StringUtils.isEmpty(erpSwitchKey)) {
return;
}
String val = configService.selectConfigByKey(erpSwitchKey);
if ("0".equals(val)) {
return;
}
proFeedbackMapper.markSapPushed(recordId, pushType, new Date());
}
private void assertNotSapPushed(ProFeedback feedback) {
ExceptionUtil.checkTrueThrowException(FeedbackSapPushConst.isPushed(feedback.getSapPushStatus()),
"该报工记录已推送SAP,不能重复推送");
}
private void markSapPushed(Long recordId, String pushType) {
int rows = proFeedbackMapper.markSapPushed(recordId, pushType, new Date());
ExceptionUtil.checkTrueThrowException(rows == 0, "该报工记录已推送SAP,不能重复推送");
}
/**
* 末道工序推生产入库,非末道工序推报工单
*/
private String pushFeedbackToSap(Long recordId) {
List<ProFeedback> proFeedbacks = proFeedbackMapper.selectListByQw(
new QueryWrapper<ProFeedback>().eq("record_id", recordId));
ExceptionUtil.checkTrueThrowException(CollectionUtil.isEmpty(proFeedbacks),
MessageUtils.message("pro.feedback.error.not.data"));
ProFeedback feedback = proFeedbacks.get(0);
assertNotSapPushed(feedback);
BigDecimal qualifyQuantity = DataUtil.getNormalData(feedback.getQuantityQualify());
ExceptionUtil.checkTrueThrowException(qualifyQuantity.compareTo(BigDecimal.ZERO) <= 0,
"合格数量为0,无法推送SAP");
ProTask currTask = proTaskService.selectProTaskByTaskId(feedback.getTaskId());
ExceptionUtil.checkTrueThrowException(currTask == null, "生产任务不存在");
ProWorkorder workorder = new ProWorkorder();
ProWorkorderVo workorderVo = proWorkorderService.selectProWorkorderByWorkorderId(feedback.getWorkorderId());
ExceptionUtil.checkTrueThrowException(workorderVo == null, "生产工单不存在");
BeanUtils.copyProperties(workorderVo, workorder);
ProTask nextTask = proTaskService.getNextTaskByTaskId(feedback.getTaskId());
String pushType;
if (nextTask == null) {
finishStockInCreateProcess.process(new Object[]{workorder, qualifyQuantity}, null);
pushType = FeedbackSapPushConst.TYPE_STOCK_IN;
markSapPushed(recordId, pushType);
return "生产入库";
}
ProTaskWorkunit currTaskWorkunit = proTaskWorkunitService.selectProTaskWorkunitByTaskWorkunitId(feedback.getTaskWorkunitId());
ProTaskWorkunit nextTaskWorkunit = null;
List<ProTaskWorkunit> nextWorkunits = proTaskWorkunitMapper.selectListByQw(
new QueryWrapper<ProTaskWorkunit>().eq("task_id", nextTask.getTaskId()));
if (CollectionUtil.isNotEmpty(nextWorkunits)) {
nextTaskWorkunit = nextWorkunits.get(0);
}
FeedbackDto feedbackDto = FeedbackDto.builder()
.workorder(workorder)
.currTask(currTask)
.nextTask(nextTask)
.currTaskWorkunit(currTaskWorkunit)
.nextTaskWorkunit(nextTaskWorkunit)
.machineTime(feedback.getMachineTime())
.build();
processReportCreateProcess.process(new Object[]{feedbackDto, qualifyQuantity}, null);
pushType = FeedbackSapPushConst.TYPE_REPORT;
markSapPushed(recordId, pushType);
return "报工单";
}
@Override
@Transactional(rollbackFor = Exception.class)
public int updateObj(ProFeedback proFeedback) {
MdWorkstation workstation = mdWorkstationService.selectMdWorkstationByWorkstationId(proFeedback.getWorkstationId());
ExceptionUtil.checkTrueThrowException(StringUtils.isNull(workstation), MessageUtils.message("md.workStation.error.not.exist"));
......@@ -686,22 +799,20 @@ public class ProFeedbackServiceImpl implements IProFeedbackService {
ExceptionUtil.checkTrueThrowException(!StringUtils.isNotNull(proFeedback.getQuantityQualify())
|| !StringUtils.isNotNull(proFeedback.getQuantityUnqualify()), MessageUtils.message("pro.feedback.error.error2"));
BigDecimal quantityFeedback = proFeedback.getQuantityFeedback();
List<ProFeedback> proFeedbacks = proFeedbackMapper.selectListByQw(new QueryWrapper<ProFeedback>().eq("record_id", proFeedback.getRecordId()));
ExceptionUtil.checkTrueThrowException(CollectionUtil.isEmpty(proFeedbacks), MessageUtils.message("pro.feedback.error.not.data"));
ProFeedback oldFeedback = proFeedbacks.get(0);
ExceptionUtil.checkTrueThrowException(FeedbackSapPushConst.isPushed(oldFeedback.getSapPushStatus()),
"该报工记录已推送ERP,不允许修改");
//条码报工时只允许修改最新的报工记录(因为一个条码可以多次报工)
ExceptionUtil.checkTrueThrowException(
StringUtils.isNotEmpty(oldFeedback.getQrcode()) && (oldFeedback.getLastFeedback() == null || !oldFeedback.getLastFeedback()),
MessageUtils.message("pro.feedback.error.notTheLatest"));
proFeedback.setFeedbackCode(oldFeedback.getFeedbackCode());
// BigDecimal feedbackQuantitySubtract = quantityFeedback.subtract(oldFeedback.getQuantityFeedback());
//
// if (feedbackQuantitySubtract.doubleValue() == 0) {
// return 1;
// }
proFeedback.setQuantityFeedback(proFeedback.getQuantityQualify().add(proFeedback.getQuantityUnqualify()));
BigDecimal updateUnQuality = proFeedback.getQuantityUnqualify();
BigDecimal updateQuality = proFeedback.getQuantityQualify();
......@@ -714,14 +825,15 @@ public class ProFeedbackServiceImpl implements IProFeedbackService {
double v2 = updateUnQuality.doubleValue() - oldUnQuality.doubleValue();
boolean b3 = Objects.equals(updateMachineTime, oldMachineTime);
if (v1 == 0 && b3 && v2 == 0) {
//有可能是修改异常信息
if(proFeedback.getAbnormalId() != null)
proFeedbackMapper.updateAbnormal(proFeedback.getAbnormalId(),proFeedback.getAbnormalReason(),proFeedback.getAbnormalRemark(),proFeedback.getAbnormalType(),proFeedback.getRecordId());
if (proFeedback.getAbnormalId() != null) {
proFeedbackMapper.updateAbnormal(proFeedback.getAbnormalId(), proFeedback.getAbnormalReason(), proFeedback.getAbnormalRemark(), proFeedback.getAbnormalType(), proFeedback.getRecordId());
}
return 1;
}
validateQualifyNotExceedPreviousProcess(oldFeedback.getTaskId(), oldFeedback.getWorkorderId(),
DataUtil.getNormalData(oldFeedback.getQuantityQualify()), updateQuality);
Long taskId = proFeedback.getTaskId();
ProTask thisProTask = proTaskService.selectBaseById(taskId);
......@@ -729,11 +841,9 @@ public class ProFeedbackServiceImpl implements IProFeedbackService {
BigDecimal thisTaskUnQualify = thisProTask.getQuantityUnqualify();
BigDecimal thisTaskWait = thisProTask.getQuantityWait();
BigDecimal thisTaskProduced = thisProTask.getQuantityProduced();
BigDecimal thisQuantity = thisProTask.getQuantity();
ProTask nextProTask = proTaskService.getNextTaskByTaskId(taskId);
BigDecimal nextTaskWait = nextProTask.getQuantityWait();
BigDecimal nextTaskWait = nextProTask != null ? nextProTask.getQuantityWait() : BigDecimal.ZERO;
ProTaskWorkunit proTaskWorkunit = proTaskWorkunitService.selectProTaskWorkunitByTaskWorkunitId(proFeedback.getTaskWorkunitId());
......@@ -744,14 +854,12 @@ public class ProFeedbackServiceImpl implements IProFeedbackService {
if (v2 != 0) {
if (v2 < 0) {
// 减少
thisTaskUnQualify = BigDecimal.valueOf(thisTaskUnQualify.doubleValue() - v2abs);
taskWorkunitUnQualify = proTaskWorkunit.getQuantityUnqualify().doubleValue() - v2abs;
taskWorkunitProduced = proTaskWorkunit.getQuantityProduced().doubleValue() - v2abs;
thisTaskProduced = BigDecimal.valueOf(thisTaskProduced.doubleValue() - v2abs);
thisTaskWait = BigDecimal.valueOf(thisTaskWait.doubleValue() + v2abs);
} else {
// 增加
thisTaskUnQualify = BigDecimal.valueOf(thisTaskUnQualify.doubleValue() + v2abs);
taskWorkunitUnQualify = proTaskWorkunit.getQuantityUnqualify().doubleValue() + v2abs;
taskWorkunitProduced = proTaskWorkunit.getQuantityProduced().doubleValue() + v2abs;
......@@ -760,46 +868,43 @@ public class ProFeedbackServiceImpl implements IProFeedbackService {
}
}
double v1abc = Math.abs(v1);
if (v1 != 0) {
if (v1 < 0) {
// 减少
taskWorkunitQualify = proTaskWorkunit.getQuantityQualify().doubleValue() - v1abc;
thisTaskQualify = BigDecimal.valueOf(thisTaskQualify.doubleValue() - v1abc);
taskWorkunitProduced = taskWorkunitProduced - v1abc;
thisTaskProduced = BigDecimal.valueOf(thisTaskProduced.doubleValue() - v1abc);
thisTaskWait = BigDecimal.valueOf(thisTaskWait.doubleValue() + v1abc);
nextTaskWait = BigDecimal.valueOf(nextTaskWait.doubleValue() - v1abc);
if (nextProTask != null) {
nextTaskWait = BigDecimal.valueOf(nextTaskWait.doubleValue() - v1abc);
}
} else {
// 增加
taskWorkunitQualify = proTaskWorkunit.getQuantityQualify().doubleValue() + v1abc;
thisTaskQualify = BigDecimal.valueOf(thisTaskQualify.doubleValue() + v1abc);
taskWorkunitProduced = taskWorkunitProduced + v1abc;
thisTaskProduced = BigDecimal.valueOf(thisTaskProduced.doubleValue() + v1abc);
thisTaskWait = BigDecimal.valueOf(thisTaskWait.doubleValue() - v1abc);
nextTaskWait = BigDecimal.valueOf(nextTaskWait.doubleValue() + v1abc);
if (nextProTask != null) {
nextTaskWait = BigDecimal.valueOf(nextTaskWait.doubleValue() + v1abc);
}
}
}
QueryWrapper<ProWorkorder> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("t1.workorder_code", proFeedback.getWorkorderCode());
queryWrapper.notIn("t1.status", Arrays.asList(WorkorderStatusEnum.CLOSE.getValue(), WorkorderStatusEnum.CANCEL.getValue(), WorkorderStatusEnum.CANCELED.getValue()));
List<ProWorkorder> proWorkorders = proWorkorderService.selectListByQw(queryWrapper);
if(thisTaskWait.compareTo(BigDecimal.ZERO) < 0){
if(thisProTask.getOrdinal() == 1){
if(proWorkorders.size() > 0 && proWorkorders.get(0).getProductionSolutionId() != null){
if (thisTaskWait.compareTo(BigDecimal.ZERO) < 0) {
if (thisProTask.getOrdinal() == 1) {
if (proWorkorders.size() > 0 && proWorkorders.get(0).getProductionSolutionId() != null) {
ProProductionSolution proProductionSolution
= proProductionSolutionMapper.selectProProductionSolutionByProductionSolutionId(proWorkorders.get(0).getProductionSolutionId());
if(proProductionSolution != null && proProductionSolution.getSurpassState() != null){
if(!proProductionSolution.getSurpassState()){
//不允许超报 可报工数目 - (合格数 + 不合格数)不能小于 0
ExceptionUtil.checkTrueThrowException(
true, "工单关联的生产版本不允许超报行为");
if (proProductionSolution != null && proProductionSolution.getSurpassState() != null) {
if (!proProductionSolution.getSurpassState()) {
ExceptionUtil.checkTrueThrowException(true, "工单关联的生产版本不允许超报行为");
}
}
}
}else{
ExceptionUtil.checkTrueThrowException(true, "非首工序不允许超过可报工数报工");
}
}
proTaskWorkunit.setQuantityQualify(BigDecimal.valueOf(taskWorkunitQualify));
......@@ -807,13 +912,17 @@ public class ProFeedbackServiceImpl implements IProFeedbackService {
proTaskWorkunit.setQuantityUnqualify(BigDecimal.valueOf(taskWorkunitUnQualify));
thisProTask.setQuantityQualify(thisTaskQualify);
thisProTask.setQuantityUnqualify( thisTaskUnQualify);
thisProTask.setQuantityWait( thisTaskWait);
thisProTask.setQuantityProduced( thisTaskProduced);
nextProTask.setQuantityWait(nextTaskWait);
thisProTask.setQuantityUnqualify(thisTaskUnQualify);
thisProTask.setQuantityWait(thisTaskWait);
thisProTask.setQuantityProduced(thisTaskProduced);
if (nextProTask != null) {
nextProTask.setQuantityWait(nextTaskWait);
}
proTaskService.updateProTask(thisProTask);
proTaskService.updateProTask(nextProTask);
if (nextProTask != null) {
proTaskService.updateProTask(nextProTask);
}
if (thisTaskWait.compareTo(BigDecimal.ZERO) > 0 && proTaskWorkunit.getStatus().equals(TaskWorkunitStatusEnum.FINISHED.getStatus())) {
proTaskWorkunit.setStatus(TaskWorkunitStatusEnum.BEGINNING.getStatus());
thisProTask.setTaskWorkunitId(proTaskWorkunit.getTaskWorkunitId());
......@@ -822,12 +931,80 @@ public class ProFeedbackServiceImpl implements IProFeedbackService {
}
proTaskWorkunitService.updateProTaskWorkunit(proTaskWorkunit);
//不允许修改报工时间
proFeedback.setMachineTime(oldFeedback.getMachineTime());
proFeedback.setFeedbackTime(oldFeedback.getFeedbackTime());
saveModifyRecord(oldFeedback, proFeedback);
this.updateProFeedback(proFeedback);
return 1;
}
@Override
public void validateQualifyNotExceedPreviousProcess(Long taskId, Long workorderId, BigDecimal excludeQualify, BigDecimal newQualify) {
ProTask task = proTaskService.selectBaseById(taskId);
if (task == null || task.getOrdinal() == null || task.getOrdinal() == 1) {
return;
}
ProTask prevTask = proTaskService.getPreviousTaskByTaskId(taskId);
if (prevTask == null) {
return;
}
BigDecimal prevQualifyTotal = sumFeedbackQualify(prevTask.getTaskId(), workorderId);
BigDecimal currentQualifyTotal = sumFeedbackQualify(taskId, workorderId);
if (excludeQualify != null) {
currentQualifyTotal = currentQualifyTotal.subtract(excludeQualify);
}
BigDecimal newTaskQualifyTotal = currentQualifyTotal.add(DataUtil.getNormalData(newQualify));
ExceptionUtil.checkTrueThrowException(newTaskQualifyTotal.compareTo(prevQualifyTotal) > 0,
"非首工序良品报工数不能超过上工序良品报工数(上工序合计:" + prevQualifyTotal.stripTrailingZeros().toPlainString() + ")");
}
private BigDecimal sumFeedbackQualify(Long taskId, Long workorderId) {
QueryWrapper<ProFeedback> qw = new QueryWrapper<>();
qw.eq("task_id", taskId);
qw.eq("workorder_id", workorderId);
return proFeedbackMapper.selectListByQw(qw).stream()
.map(f -> DataUtil.getNormalData(f.getQuantityQualify()))
.reduce(BigDecimal.ZERO, BigDecimal::add);
}
private void saveModifyRecord(ProFeedback before, ProFeedback after) {
JSONObject body = new JSONObject();
JSONObject beforeJson = new JSONObject();
beforeJson.put("quantityQualify", before.getQuantityQualify());
beforeJson.put("quantityUnqualify", before.getQuantityUnqualify());
beforeJson.put("quantityFeedback", before.getQuantityFeedback());
beforeJson.put("machineTime", before.getMachineTime());
beforeJson.put("remark", before.getRemark());
JSONObject afterJson = new JSONObject();
afterJson.put("quantityQualify", after.getQuantityQualify());
afterJson.put("quantityUnqualify", after.getQuantityUnqualify());
afterJson.put("quantityFeedback", after.getQuantityFeedback());
afterJson.put("machineTime", after.getMachineTime());
afterJson.put("remark", after.getRemark());
body.put("before", beforeJson);
body.put("after", afterJson);
ProFeedbackModifyRecord record = new ProFeedbackModifyRecord();
record.setRecordId(before.getRecordId());
record.setFeedbackCode(before.getFeedbackCode());
record.setWorkorderId(before.getWorkorderId());
record.setWorkorderCode(before.getWorkorderCode());
record.setTaskId(before.getTaskId());
record.setProcessName(before.getProcessName());
record.setRequestBody(body.toJSONString());
record.setRemark(after.getRemark());
record.setCreateBy(SecurityUtils.getUsername());
record.setCreateTime(new Date());
proFeedbackModifyRecordMapper.insertProFeedbackModifyRecord(record);
}
@Override
public List<ProFeedbackModifyRecord> listModifyRecord(Long recordId) {
if (recordId == null) {
return Collections.emptyList();
}
return proFeedbackModifyRecordMapper.selectByRecordId(recordId);
}
private void createStarkWorkRecord(ProTask proTask) {
QueryWrapper<ProStartWork> proStartWorkQueryWrapper = new QueryWrapper<>();
proStartWorkQueryWrapper.eq(StringUtils.isNotEmpty(proTask.getTaskId()), "task_id", proTask.getTaskId());
......
......@@ -343,10 +343,12 @@ public class ProTaskAssistProcessServiceImpl implements IProTaskAssistProcessSer
proTaskService.updateProTask(task);
proTaskWorkunitService.updateProTaskWorkunit(taskWorkunit);
// 末道工序:与普通报工 doFeedBack 一致,回写工单并触发 ERP 完工入库(reportUpdateProWorkorder)
// 末道工序:与普通报工 doFeedBack 一致,回写工单并触发 ERP 完工入库(reportUpdateProWorkorder,开关 erp.finish.stockin.create.enable
if (nextTask == null && quantityQualify.compareTo(BigDecimal.ZERO) > 0) {
if (workorder != null) {
proWorkorderService.reportUpdateProWorkorder(workorder, quantityQualify, quantityUnQualify);
proFeedbackService.markSapPushedAfterAuto(feedback.getRecordId(),
"erp.finish.stockin.create.enable", com.ximai.mes.constant.FeedbackSapPushConst.TYPE_STOCK_IN);
}
tryFinishWorkorderOnLastProcessComplete(task);
}
......
......@@ -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.IProTaskWorkunitService;
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.service.ITmToolMachinesService;
import com.ximai.mes.tm.service.ITmToolRequestService;
......@@ -866,22 +866,18 @@ public class ProTaskServiceImpl implements IProTaskService, ApplicationContextAw
queryWrapper.eq("t1.workorder_code", task.getArrangeCode());
queryWrapper.notIn("t1.status", Arrays.asList(WorkorderStatusEnum.CLOSE.getValue(), WorkorderStatusEnum.CANCEL.getValue(), WorkorderStatusEnum.CANCELED.getValue()));
List<ProWorkorder> proWorkorders = proWorkorderService.selectListByQw(queryWrapper);
//检查该工单绑定的生产版本是否允许超报,PS只有首工序允许
if(taskQuantityWaitConst.compareTo(feedbackQualifyConst.add(fuantityUnqualify)) < 0){
if(task.getOrdinal() == 1){
if(proWorkorders.size() > 0 && proWorkorders.get(0).getProductionSolutionId() != null){
ProProductionSolution proProductionSolution
= proProductionSolutionMapper.selectProProductionSolutionByProductionSolutionId(proWorkorders.get(0).getProductionSolutionId());
if(proProductionSolution != null && proProductionSolution.getSurpassState() != null){
if(!proProductionSolution.getSurpassState()){
//不允许超报 可报工数目 - (合格数 + 不合格数)不能小于 0
ExceptionUtil.checkTrueThrowException(
taskQuantityWaitConst.compareTo(feedbackQualifyConst.add(fuantityUnqualify)) < 0, "工单关联的生产版本不允许超报行为");
}
if (task.getOrdinal() != null && task.getOrdinal() != 1) {
proFeedbackService.validateQualifyNotExceedPreviousProcess(task.getTaskId(), feedback.getWorkorderId(), null, feedbackQualifyConst);
} else if (taskQuantityWaitConst.compareTo(feedbackQualifyConst.add(fuantityUnqualify)) < 0) {
if (proWorkorders.size() > 0 && proWorkorders.get(0).getProductionSolutionId() != null) {
ProProductionSolution proProductionSolution
= proProductionSolutionMapper.selectProProductionSolutionByProductionSolutionId(proWorkorders.get(0).getProductionSolutionId());
if (proProductionSolution != null && proProductionSolution.getSurpassState() != null) {
if (!proProductionSolution.getSurpassState()) {
ExceptionUtil.checkTrueThrowException(
taskQuantityWaitConst.compareTo(feedbackQualifyConst.add(fuantityUnqualify)) < 0, "工单关联的生产版本不允许超报行为");
}
}
}else{
ExceptionUtil.checkTrueThrowException(true, "非首工序不允许超过可报工数报工");
}
}
......@@ -945,20 +941,31 @@ public class ProTaskServiceImpl implements IProTaskService, ApplicationContextAw
if (StringUtils.isEmpty(nextTask)) {
feedbackWorkorder.forEach((k, v) -> {
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);
feedbackWorkorder.forEach((k, v) -> {
FeedbackDto feedbackDto = FeedbackDto.builder().workorder(v.getWorkorder()).currTask(task).currTaskWorkunit(taskWorkunit)
.nextTask(nextTask).nextTaskWorkunit(nextTaskWorkunit.get()).build();
applicationContext.getBean(ProTaskServiceImpl.class).feedbackToErp(feedbackDto, v.getQuantityQualify(), v.getQuantityUnqualify());
});
if (nextTask != null) {
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)
.nextTask(nextTask).nextTaskWorkunit(nextTaskWorkunit.get()).machineTime(machineTimeMinutes).build();
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;
}
@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)
})
@Override
......@@ -1394,6 +1401,23 @@ public class ProTaskServiceImpl implements IProTaskService, ApplicationContextAw
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
public List<ProTask> selectListByQw(QueryWrapper<ProTask> proTaskQueryWrapper) {
return proTaskMapper.selectListJoinByQw(proTaskQueryWrapper);
......
......@@ -188,6 +188,11 @@ public interface IProTaskService {
ProTask getNextTaskByTaskId(Long taskId);
/**
* 获取上一道工序任务(同排产批次)
*/
ProTask getPreviousTaskByTaskId(Long taskId);
ProTask selectBaseById(Long taskId);
List<ProTask> getTaskList(ProTaskQuery proTask);
......
......@@ -79,4 +79,9 @@ public interface ErpService {
@PostMapping(value = "/sfctb/processTransfer")
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
@JsonProperty("tg013")
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("批号")
@JsonProperty("tg017")
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 {
detail.setWorkorderCode(workorder.getWorkorderCode());
detail.setCheckQuantity(qualifyQuantity);
detail.setInQuantity(qualifyQuantity);
detail.setScrapQuantity(BigDecimal.ZERO);
detail.setReturnQuantity(BigDecimal.ZERO);
detail.setDestroyQuantity(BigDecimal.ZERO);
detail.setBatchNo(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMdd")));
details.add(detail);
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 @@
<result property="sapFeedbackItemCode" column="sap_feedback_item_code"/>
<result property="sapRequestParam" column="sap_request_param"/>
<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="workorderCode" column="workorder_code"/>
<result property="workorderName" column="workorder_name"/>
......@@ -68,6 +71,9 @@
f.workstation_name,
f.sap_request_param,
f.sap_response,
f.sap_push_status,
f.sap_push_type,
f.sap_push_time,
f.sap_feedback_code,
f.sap_feedback_item_code,
f.machine_time,
......@@ -1046,6 +1052,9 @@
<if test="sapFeedbackItemCode != null">sap_feedback_item_code,</if>
<if test="sapRequestParam != null">sap_request_param,</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="processCode != null">process_code,</if>
<if test="processName != null">process_name,</if>
......@@ -1105,6 +1114,9 @@
<if test="sapFeedbackItemCode != null">#{sapFeedbackItemCode},</if>
<if test="sapRequestParam != null">#{sapRequestParam},</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="processCode != null">#{processCode},</if>
<if test="processName != null">#{processName},</if>
......@@ -1168,6 +1180,9 @@
<if test="sapFeedbackItemCode != null">sap_feedback_item_code = #{sapFeedbackItemCode},</if>
<if test="sapRequestParam != null">sap_request_param = #{sapRequestParam},</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="processCode != null">process_code = #{processCode},</if>
<if test="processName != null">process_name = #{processName},</if>
......@@ -1223,6 +1238,15 @@
<update id="updateLastFeedback">
update pro_feedback set last_feedback = false where qrcode = #{qrcode} and task_id = #{taskId}
</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
......
<?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