forked from I3-YF/i3plus-mes-pcn-yfai
工步调配原料功能
parent
afdae0a8d2
commit
3a1a45777c
@ -0,0 +1,12 @@
|
|||||||
|
package cn.estsh.i3plus.ext.mes.pcn.api.busi;
|
||||||
|
|
||||||
|
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProdRuleContext;
|
||||||
|
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProductionAssemblyContext;
|
||||||
|
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProductionAssemblyNosortContext;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface IMesRawSnWeightRecordService {
|
||||||
|
void insertRawRemainWeightRecord(MesProductionAssemblyContext context, String organizeCode, String username);
|
||||||
|
void insertOutPartNoWeightRecord(MesProdRuleContext prodRuleContext, List<MesProductionAssemblyNosortContext> productionAssemblyNosortContextList, String organizeCode, String username);
|
||||||
|
}
|
@ -0,0 +1,105 @@
|
|||||||
|
package cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.busi;
|
||||||
|
|
||||||
|
import cn.estsh.i3plus.ext.mes.pcn.api.base.IMesPartService;
|
||||||
|
import cn.estsh.i3plus.ext.mes.pcn.api.busi.IMesRawSnWeightRecordService;
|
||||||
|
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProdRuleContext;
|
||||||
|
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProductionAssemblyContext;
|
||||||
|
import cn.estsh.i3plus.ext.mes.pcn.pojo.context.MesProductionAssemblyNosortContext;
|
||||||
|
import cn.estsh.i3plus.platform.common.convert.ConvertBean;
|
||||||
|
import cn.estsh.i3plus.pojo.base.bean.DdlPackBean;
|
||||||
|
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
|
||||||
|
import cn.estsh.i3plus.pojo.base.tool.DdlPreparedPack;
|
||||||
|
import cn.estsh.i3plus.pojo.mes.bean.MesPart;
|
||||||
|
import cn.estsh.i3plus.pojo.mes.bean.MesRawMixCfgDetail;
|
||||||
|
import cn.estsh.i3plus.pojo.mes.bean.MesRawSnWeightRecord;
|
||||||
|
import cn.estsh.i3plus.pojo.mes.bean.MesRawWeightCfg;
|
||||||
|
import cn.estsh.i3plus.pojo.mes.repository.MesRawMixCfgDetailRepository;
|
||||||
|
import cn.estsh.i3plus.pojo.mes.repository.MesRawSnWeightRecordRepository;
|
||||||
|
import cn.estsh.i3plus.pojo.mes.repository.MesRawWeightCfgRepository;
|
||||||
|
import cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class MesRawSnWeightRecordServiceImpl implements IMesRawSnWeightRecordService {
|
||||||
|
@Autowired
|
||||||
|
private MesRawSnWeightRecordRepository rawSnWeightRecordRDao;
|
||||||
|
@Autowired
|
||||||
|
private MesRawWeightCfgRepository rawWeightCfgRDao;
|
||||||
|
@Autowired
|
||||||
|
private MesRawMixCfgDetailRepository rawMixCfgDetailRDao;
|
||||||
|
@Autowired
|
||||||
|
private IMesPartService partService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void insertRawRemainWeightRecord(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()});
|
||||||
|
if (detail == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
MesRawWeightCfg weightCfg = rawWeightCfgRDao.getByProperty(new String[]{"organizeCode", "isValid", "isDeleted", "partNo"},
|
||||||
|
new Object[]{organizeCode, CommonEnumUtil.IS_VAILD.VAILD.getValue(), CommonEnumUtil.IS_DEAL.NO.getValue(), context.getAssemblyPartNo()});
|
||||||
|
if (weightCfg == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
double remainQty = getRemainQty(organizeCode, context.getAssemblyPartNo());
|
||||||
|
|
||||||
|
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.setNetUnit(weightCfg.getNetUnit());
|
||||||
|
record.setRawType(detail.getRawType());
|
||||||
|
ConvertBean.serviceModelInitialize(record, username);
|
||||||
|
rawSnWeightRecordRDao.insert(record);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void insertOutPartNoWeightRecord(MesProdRuleContext prodRuleContext, List<MesProductionAssemblyNosortContext> productionAssemblyNosortContextList, String organizeCode, String username) {
|
||||||
|
MesPart mesPart = partService.getMesPartByPartNo(prodRuleContext.getOutPartNo(), organizeCode);
|
||||||
|
if (mesPart == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
double totalWeight = 0.0;
|
||||||
|
for (MesProductionAssemblyNosortContext context : productionAssemblyNosortContextList) {
|
||||||
|
if (Objects.equals(context.getMatchType(), MesExtEnumUtil.ASSEMBLY_MATCH_TYPE.MATCH_TYPE_90.getValue())) {
|
||||||
|
totalWeight += context.getQty();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
MesRawSnWeightRecord record = new MesRawSnWeightRecord();
|
||||||
|
record.setOrganizeCode(organizeCode);
|
||||||
|
record.setBarCode(prodRuleContext.getProductSn());
|
||||||
|
record.setPartNo(mesPart.getPartNo());
|
||||||
|
record.setPartName(mesPart.getPartName());
|
||||||
|
record.setNetWeight(totalWeight);
|
||||||
|
record.setRawType(MesExtEnumUtil.RAW_MIX_DETAIL_TYPE.RAW_MIX_DETAIL_TYPE_10.getValue());
|
||||||
|
ConvertBean.serviceModelInitialize(record, username);
|
||||||
|
rawSnWeightRecordRDao.insert(record);
|
||||||
|
}
|
||||||
|
|
||||||
|
private double getRemainQty(String organizeCode, String partNo) {
|
||||||
|
DdlPackBean ddlPackBean = DdlPackBean.getDdlPackBean(organizeCode);
|
||||||
|
DdlPreparedPack.getStringEqualPack(partNo, "partNo", ddlPackBean);
|
||||||
|
DdlPreparedPack.getOrderBy("createDatetime", CommonEnumUtil.ASC_OR_DESC.DESC.getValue(), ddlPackBean);
|
||||||
|
MesRawSnWeightRecord record = rawSnWeightRecordRDao.getByProperty(ddlPackBean);
|
||||||
|
if (record != null) {
|
||||||
|
return record.getNetWeight();
|
||||||
|
}
|
||||||
|
|
||||||
|
MesRawWeightCfg weightCfg = rawWeightCfgRDao.getByProperty(new String[]{"organizeCode", "isValid", "isDeleted", "partNo"},
|
||||||
|
new Object[]{organizeCode, CommonEnumUtil.IS_VAILD.VAILD.getValue(), CommonEnumUtil.IS_DEAL.NO.getValue(), partNo});
|
||||||
|
if (weightCfg == null) {
|
||||||
|
return 0.0;
|
||||||
|
}
|
||||||
|
return weightCfg.getNetWeight();
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue