getSfcListByResrce(@Param("site") String site, @Param("resrce") String resrce,@Param("locale") String locale);
- Integer resourceCheck(@Param("resrceBO")String resrceBO, @Param("dateTime")LocalDateTime dateTime);
-
SfcDto getInfoBySfc(@Param("sfc")Sfc sfc);
+
+ Integer resourceCheck(@Param("site")String site,@Param("resrce")String resrce, @Param("dateTime")LocalDateTime dateTime);
}
diff --git a/production/src/main/java/com/foreverwin/mesnac/production/mapper/SplitSfcMapper.java b/production/src/main/java/com/foreverwin/mesnac/production/mapper/SplitSfcMapper.java
new file mode 100644
index 00000000..3ac0c6a3
--- /dev/null
+++ b/production/src/main/java/com/foreverwin/mesnac/production/mapper/SplitSfcMapper.java
@@ -0,0 +1,24 @@
+package com.foreverwin.mesnac.production.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.foreverwin.mesnac.meapi.dto.SfcDto;
+import com.foreverwin.mesnac.production.dto.SplitSfcDto;
+import com.foreverwin.mesnac.production.model.SplitSfc;
+import org.apache.ibatis.annotations.Param;
+import org.springframework.stereotype.Repository;
+
+/**
+ *
+ * 产品条码拆分表 Mapper 接口
+ *
+ *
+ * @author Philip
+ * @since 2021-07-20
+ */
+@Repository
+public interface SplitSfcMapper extends BaseMapper {
+
+ SfcDto getSfcData(@Param("handle") String handle);
+
+ SplitSfcDto getAbnormalQty(@Param("site")String site, @Param("sfc")String sfc, @Param("operation") String operation);
+}
\ No newline at end of file
diff --git a/production/src/main/java/com/foreverwin/mesnac/production/model/SplitSfc.java b/production/src/main/java/com/foreverwin/mesnac/production/model/SplitSfc.java
new file mode 100644
index 00000000..c02c7e03
--- /dev/null
+++ b/production/src/main/java/com/foreverwin/mesnac/production/model/SplitSfc.java
@@ -0,0 +1,169 @@
+package com.foreverwin.mesnac.production.model;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.baomidou.mybatisplus.extension.activerecord.Model;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.time.LocalDateTime;
+
+/**
+ *
+ * 产品条码拆分表
+ *
+ *
+ * @author Philip
+ * @since 2021-07-20
+ */
+
+@TableName("Z_SPLIT_SFC")
+
+public class SplitSfc extends Model {
+
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * 主键
+ */
+ @TableId(value = "HANDLE", type = IdType.INPUT)
+ private String handle;
+ /**
+ * 站点
+ */
+ @TableField("SITE")
+ private String site;
+ /**
+ * 产品条码
+ */
+ @TableField("SFC")
+ private String sfc;
+ /**
+ * 拆出的产品条码
+ */
+ @TableField("SPLIT_SFC")
+ private String splitSfc;
+ /**
+ * 拆分数量
+ */
+ @TableField("SPLIT_QTY")
+ private BigDecimal splitQty;
+ /**
+ * 处置工艺路线
+ */
+ @TableField("ROUTER")
+ private String router;
+ /**
+ * 创建人
+ */
+ @TableField("CREATE_USER")
+ private String createUser;
+ /**
+ * 创建时间
+ */
+ @TableField("CREATED_DATE_TIME")
+ private LocalDateTime createdDateTime;
+
+
+ public String getHandle() {
+ return handle;
+ }
+
+ public void setHandle(String handle) {
+ this.handle = handle;
+ }
+
+ public String getSite() {
+ return site;
+ }
+
+ public void setSite(String site) {
+ this.site = site;
+ }
+
+ public String getSfc() {
+ return sfc;
+ }
+
+ public void setSfc(String sfc) {
+ this.sfc = sfc;
+ }
+
+ public String getSplitSfc() {
+ return splitSfc;
+ }
+
+ public void setSplitSfc(String splitSfc) {
+ this.splitSfc = splitSfc;
+ }
+
+ public BigDecimal getSplitQty() {
+ return splitQty;
+ }
+
+ public void setSplitQty(BigDecimal splitQty) {
+ this.splitQty = splitQty;
+ }
+
+ public String getRouter() {
+ return router;
+ }
+
+ public void setRouter(String router) {
+ this.router = router;
+ }
+
+ public String getCreateUser() {
+ return createUser;
+ }
+
+ public void setCreateUser(String createUser) {
+ this.createUser = createUser;
+ }
+
+ public LocalDateTime getCreatedDateTime() {
+ return createdDateTime;
+ }
+
+ public void setCreatedDateTime(LocalDateTime createdDateTime) {
+ this.createdDateTime = createdDateTime;
+ }
+
+public static final String HANDLE = "HANDLE";
+
+public static final String SITE = "SITE";
+
+public static final String SFC = "SFC";
+
+public static final String SPLIT_SFC = "SPLIT_SFC";
+
+public static final String SPLIT_QTY = "SPLIT_QTY";
+
+public static final String ROUTER = "ROUTER";
+
+public static final String CREATE_USER = "CREATE_USER";
+
+public static final String CREATED_DATE_TIME = "CREATED_DATE_TIME";
+
+
+ @Override
+ protected Serializable pkVal() {
+ return this.handle;
+ }
+
+ @Override
+ public String toString() {
+ return "SplitSfc{" +
+ "handle = " + handle +
+ ", site = " + site +
+ ", sfc = " + sfc +
+ ", splitSfc = " + splitSfc +
+ ", splitQty = " + splitQty +
+ ", router = " + router +
+ ", createUser = " + createUser +
+ ", createdDateTime = " + createdDateTime +
+ "}";
+ }
+}
\ No newline at end of file
diff --git a/production/src/main/java/com/foreverwin/mesnac/production/service/SplitSfcService.java b/production/src/main/java/com/foreverwin/mesnac/production/service/SplitSfcService.java
new file mode 100644
index 00000000..4e8e4c27
--- /dev/null
+++ b/production/src/main/java/com/foreverwin/mesnac/production/service/SplitSfcService.java
@@ -0,0 +1,33 @@
+package com.foreverwin.mesnac.production.service;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.foreverwin.mesnac.meapi.dto.SfcDto;
+import com.foreverwin.mesnac.production.model.SplitSfc;
+import com.foreverwin.modular.core.util.FrontPage;
+
+import java.util.List;
+
+/**
+ *
+ * 产品条码拆分表 服务类
+ *
+ *
+ * @author Philip
+ * @since 2021-07-20
+ */
+public interface SplitSfcService extends IService {
+
+ /**
+ * 分页查询
+ * @param frontPage
+ * @return
+ */
+ IPage selectPage(FrontPage frontPage, SplitSfc splitSfc);
+
+ List selectList(SplitSfc splitSfc);
+
+ SfcDto getSfcData(String sfc);
+
+ SplitSfc splitSfc(SfcDto sfcDto);
+}
\ No newline at end of file
diff --git a/production/src/main/java/com/foreverwin/mesnac/production/service/impl/PodTemplateServiceImpl.java b/production/src/main/java/com/foreverwin/mesnac/production/service/impl/PodTemplateServiceImpl.java
index 74cd6428..ba2b07e1 100644
--- a/production/src/main/java/com/foreverwin/mesnac/production/service/impl/PodTemplateServiceImpl.java
+++ b/production/src/main/java/com/foreverwin/mesnac/production/service/impl/PodTemplateServiceImpl.java
@@ -173,7 +173,7 @@ public class PodTemplateServiceImpl implements PodTemplateService {
throw new BaseException("资源不能为空");
}
//是否设备点检
- sfcCrossService.resourceCheck(HandleEnum.RESOURCE.getHandle(site,resrce));
+ sfcCrossService.resourceCheck(resrce);
sfcDtoList.forEach(sfcDto -> {
String operation = sfcDto.getOperation();
Operation currentRevisionRef = operationService.getCurrentRevisionRef(site, operation);
diff --git a/production/src/main/java/com/foreverwin/mesnac/production/service/impl/SfcCrossServiceImpl.java b/production/src/main/java/com/foreverwin/mesnac/production/service/impl/SfcCrossServiceImpl.java
index 96443454..97e4c234 100644
--- a/production/src/main/java/com/foreverwin/mesnac/production/service/impl/SfcCrossServiceImpl.java
+++ b/production/src/main/java/com/foreverwin/mesnac/production/service/impl/SfcCrossServiceImpl.java
@@ -77,10 +77,11 @@ public class SfcCrossServiceImpl implements SfcCrossService {
}
@Override
- public void resourceCheck(String resrceBO) {
+ public void resourceCheck(String resrce) {
LocalDateTime now = LocalDateTime.now();
+ String site = CommonMethods.getSite();
LocalDateTime dateTime = LocalDateTime.of(now.getYear(), now.getMonth(), now.getDayOfMonth(), 0, 0, 0);
- Integer integer = sfcCrossMapper.resourceCheck(resrceBO, dateTime);
+ Integer integer = sfcCrossMapper.resourceCheck(site,resrce, dateTime);
if (integer<1){
throw new BaseException("当前设备点检未完成");
}
diff --git a/production/src/main/java/com/foreverwin/mesnac/production/service/impl/SplitSfcServiceImpl.java b/production/src/main/java/com/foreverwin/mesnac/production/service/impl/SplitSfcServiceImpl.java
new file mode 100644
index 00000000..ea8dd3e8
--- /dev/null
+++ b/production/src/main/java/com/foreverwin/mesnac/production/service/impl/SplitSfcServiceImpl.java
@@ -0,0 +1,166 @@
+package com.foreverwin.mesnac.production.service.impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.foreverwin.mesnac.common.enums.HandleEnum;
+import com.foreverwin.mesnac.common.util.ExceptionUtil;
+import com.foreverwin.mesnac.common.util.StringUtil;
+import com.foreverwin.mesnac.meapi.dto.SfcDto;
+import com.foreverwin.mesnac.production.dto.SplitSfcDto;
+import com.foreverwin.mesnac.production.mapper.SplitSfcMapper;
+import com.foreverwin.mesnac.production.model.SplitSfc;
+import com.foreverwin.mesnac.production.service.SplitSfcService;
+import com.foreverwin.modular.core.exception.BaseException;
+import com.foreverwin.modular.core.meext.MEServices;
+import com.foreverwin.modular.core.util.CommonMethods;
+import com.foreverwin.modular.core.util.FrontPage;
+import com.sap.me.nonconformance.*;
+import com.sap.me.production.SplitSerializeServiceInterface;
+import com.sap.me.production.SplitSfcDetail;
+import com.sap.me.production.SplitSfcRequest;
+import com.sap.me.production.SplitSfcResponse;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.math.BigDecimal;
+import java.time.LocalDateTime;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+/**
+ *
+ * 产品条码拆分表 服务实现类
+ *
+ *
+ * @author Philip
+ * @since 2021-07-20
+ */
+@Service
+@Transactional(rollbackFor = Exception.class)
+public class SplitSfcServiceImpl extends ServiceImpl implements SplitSfcService {
+
+
+ @Autowired
+ private SplitSfcMapper splitSfcMapper;
+
+ @Override
+ public IPage selectPage(FrontPage frontPage, SplitSfc splitSfc) {
+ QueryWrapper queryWrapper = new QueryWrapper<>();
+ queryWrapper.setEntity(splitSfc);
+ return super.page(frontPage.getPagePlus(), queryWrapper);
+ }
+
+ @Override
+ public List selectList(SplitSfc splitSfc) {
+ QueryWrapper queryWrapper = new QueryWrapper<>();
+ queryWrapper.setEntity(splitSfc);
+ return super.list(queryWrapper);
+ }
+
+ @Override
+ public SfcDto getSfcData(String sfc) {
+ String site = CommonMethods.getSite();
+ String handle = HandleEnum.SFC.getHandle(site, sfc);
+ //根据sfc找工单等信息
+ SfcDto sfcData = splitSfcMapper.getSfcData(handle);
+ if (sfcData==null){
+ throw new BaseException("未找到产品条码信息");
+ }
+ String operation = sfcData.getOperation();
+ //查询质量异常记录数量
+ SplitSfcDto sfcDto=splitSfcMapper.getAbnormalQty(site,sfc,operation);
+ if (sfcDto==null){
+ throw new BaseException("未找到方案确认的质量异常");
+ }
+ sfcData.setQty(Double.valueOf(sfcDto.getNcQty()));
+ return sfcData;
+ }
+ @Override
+ public SplitSfc splitSfc(SfcDto sfcDto){
+ String site = CommonMethods.getSite();
+ String sfc = sfcDto.getSfc();
+ String handle = HandleEnum.SFC.getHandle(site, sfc);
+ BigDecimal splitQty = new BigDecimal(sfcDto.getQty());
+
+ //根据sfc找工单等信息
+ SfcDto sfcData = splitSfcMapper.getSfcData(handle);
+ String operation = sfcData.getOperation();
+ if (sfcData==null){
+ throw new BaseException("未找到产品条码信息");
+ }
+ //查询质量异常记录数量 处置工艺路线及不良代码
+ SplitSfcDto splitSfcDto=splitSfcMapper.getAbnormalQty(site,sfc,operation);
+ String routerBo = splitSfcDto.getRouterBo();
+ String ncCode = splitSfcDto.getNcCode();
+ if (StringUtil.isBlank(routerBo)){
+ throw new BaseException("异常处置未选择处置工艺路线");
+ }
+ if (StringUtil.isBlank(ncCode)){
+ throw new BaseException("异常处置未选择不良代码");
+ }
+ BigDecimal sfcQty = new BigDecimal(sfcData.getQty());
+ if (new BigDecimal(splitSfcDto.getNcQty()).compareTo(sfcQty)>=0){
+ throw new BaseException("质量异常数量不小于于产品条码的数量,不能拆分");
+ }
+ if (splitQty.compareTo(new BigDecimal(splitSfcDto.getNcQty()))>0){
+ throw new BaseException("拆分数量大于质量异常数量的数量,不能拆分");
+ }
+ String[] splitNcCode = ncCode.split(",");
+
+ SplitSfcRequest splitSfcRequest=new SplitSfcRequest();
+ try {
+ SplitSerializeServiceInterface splitService = MEServices.create("com.sap.me.production", "SplitSerializeService",site);
+ NCProductionServiceInterface ncProductionService = MEServices.create("com.sap.me.nonconformance", "NCProductionService",site);
+ //拆sfc
+ List newList=new ArrayList<>();
+ SplitSfcDetail splitDetail=new SplitSfcDetail();
+ splitDetail.setQuantity(splitQty);
+ newList.add(splitDetail);
+ splitSfcRequest.setNewSfcList(newList);
+ splitSfcRequest.setSfcRef(HandleEnum.SFC.getHandle(site,sfc));
+ Collection splitSfcResponses = splitService.splitSfc(splitSfcRequest);
+ SplitSfcResponse splitSfcResponse = splitSfcResponses.iterator().next();
+ String newSfcRef = splitSfcResponse.getNewSfcRef();
+ //记录不合格
+ CreateNCRequest createNCRequest=new CreateNCRequest();
+ createNCRequest.setQty(splitQty);
+ createNCRequest.setSfcRef(newSfcRef);
+ ProductionContext productionContext=new ProductionContext();
+ StepIdentifier stepIdentifier=new StepIdentifier();
+ stepIdentifier.setStepId(sfcData.getStepId());
+ stepIdentifier.setOperationId(sfcData.getOperation());
+ productionContext.setStepIdentifier(stepIdentifier);
+ createNCRequest.setProdCtx(productionContext);
+ createNCRequest.setNcCodeRef(HandleEnum.NC_CODE.getHandle(site,splitNcCode[0]));
+ ncProductionService.createNC(createNCRequest);
+ //不合格处置特殊工艺路线
+ DispositionMultipleSfcsRequest dispositionSfcsRequest=new DispositionMultipleSfcsRequest();
+ List sfcs=new ArrayList<>();
+ sfcs.add(newSfcRef);
+ dispositionSfcsRequest.setSfcs(sfcs);
+ dispositionSfcsRequest.setBypassStepValidation(true);
+ DispositionSelection dispositionSelection=new DispositionSelection();
+ dispositionSelection.setRouterRef(routerBo);
+ dispositionSfcsRequest.setDispositionSelection(dispositionSelection);
+ ncProductionService.dispositionMultipleSfcs(dispositionSfcsRequest);
+ SplitSfc splitSfc=new SplitSfc();
+ String newSfc = StringUtil.trimHandle(newSfcRef);
+ splitSfc.setHandle(HandleEnum.SPLIT_SFC.getHandle(site,newSfc));
+ splitSfc.setSite(site);
+ splitSfc.setSfc(sfc);
+ splitSfc.setSplitSfc(newSfc);
+ splitSfc.setSplitQty(splitQty);
+ splitSfc.setRouter(StringUtil.trimHandle(routerBo));
+ splitSfc.setCreateUser(CommonMethods.getUser());
+ splitSfc.setCreatedDateTime(LocalDateTime.now());
+ save(splitSfc);
+ return splitSfc;
+ } catch (Exception e) {
+ ExceptionUtil.throwException(e);
+ }
+ return null;
+ }
+
+}
\ No newline at end of file
diff --git a/production/src/main/resources/mapper/SfcCrossMapper.xml b/production/src/main/resources/mapper/SfcCrossMapper.xml
index 17fd4678..787b3224 100644
--- a/production/src/main/resources/mapper/SfcCrossMapper.xml
+++ b/production/src/main/resources/mapper/SfcCrossMapper.xml
@@ -160,7 +160,7 @@ WHERE sfc.site = #{site} and