|
|
|
@ -19,6 +19,9 @@ import cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
|
import java.math.MathContext;
|
|
|
|
|
import java.math.RoundingMode;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Objects;
|
|
|
|
|
|
|
|
|
@ -36,7 +39,7 @@ public class MesRawSnWeightRecordServiceImpl implements IMesRawSnWeightRecordSer
|
|
|
|
|
private MesRawSnWeightRecordLogRepository rawSnWeightRecordLogRDao;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void insertRawRemainWeightRecord(String productSn, MesProductionAssemblyContext context, String organizeCode, String username) {
|
|
|
|
|
public void insertRawRemainWeightRecord(MesProductionPsOutContext productionPsOutContext, MesProductionAssemblyContext context, String organizeCode, String username) {
|
|
|
|
|
MesRawMixCfgDetail detail = rawMixCfgDetailRDao.getByProperty(
|
|
|
|
|
new String[]{"organizeCode", "isValid", "isDeleted", "outPartNo", "partNo"},
|
|
|
|
|
new Object[]{organizeCode, CommonEnumUtil.IS_VAILD.VAILD.getValue(), CommonEnumUtil.IS_DEAL.NO.getValue(), context.getPartNo(), context.getAssemblyPartNo()});
|
|
|
|
@ -50,13 +53,19 @@ public class MesRawSnWeightRecordServiceImpl implements IMesRawSnWeightRecordSer
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
double remainQty = getRemainQty(organizeCode, context.getAssemblyPartNo(), context.getAssemblySn());
|
|
|
|
|
double weightQty = context.getQty() != null ? context.getQty() : 0;
|
|
|
|
|
// 保留两位小数,四舍五入
|
|
|
|
|
MathContext mc = new MathContext(8, RoundingMode.HALF_UP);
|
|
|
|
|
BigDecimal decimalRemainQty = new BigDecimal(remainQty, mc);
|
|
|
|
|
BigDecimal decimalWeight = new BigDecimal(weightQty, mc);
|
|
|
|
|
|
|
|
|
|
MesRawSnWeightRecord record = new MesRawSnWeightRecord();
|
|
|
|
|
record.setOrganizeCode(organizeCode);
|
|
|
|
|
record.setBarCode(context.getAssemblySn());
|
|
|
|
|
record.setPartNo(context.getAssemblyPartNo());
|
|
|
|
|
record.setPartName(context.getAssemblyPartName());
|
|
|
|
|
record.setNetWeight(remainQty - context.getQty());
|
|
|
|
|
// record.setNetWeight(remainQty - context.getQty());
|
|
|
|
|
record.setNetWeight(decimalRemainQty.subtract(decimalWeight).doubleValue());
|
|
|
|
|
record.setNetUnit(weightCfg.getNetUnit());
|
|
|
|
|
record.setRawType(detail.getRawType());
|
|
|
|
|
ConvertBean.serviceModelInitialize(record, username);
|
|
|
|
@ -64,8 +73,12 @@ public class MesRawSnWeightRecordServiceImpl implements IMesRawSnWeightRecordSer
|
|
|
|
|
|
|
|
|
|
MesRawSnWeightRecordLog recordLog = new MesRawSnWeightRecordLog();
|
|
|
|
|
recordLog.setOrganizeCode(organizeCode);
|
|
|
|
|
recordLog.setProductSn(productSn);
|
|
|
|
|
recordLog.setProductSn(productionPsOutContext.getProductSn());
|
|
|
|
|
recordLog.setPartNo(productionPsOutContext.getPartNo());
|
|
|
|
|
recordLog.setPartName(productionPsOutContext.getPartName());
|
|
|
|
|
recordLog.setAssemblySn(context.getAssemblySn());
|
|
|
|
|
recordLog.setAssemblyPartNo(context.getAssemblyPartNo());
|
|
|
|
|
recordLog.setAssemblyPartName(context.getAssemblyPartName());
|
|
|
|
|
recordLog.setOriginWeight(remainQty);
|
|
|
|
|
recordLog.setDeductionWeight(context.getQty());
|
|
|
|
|
recordLog.setRemainWeight(record.getNetWeight());
|
|
|
|
|