返工修改

tags/yfai-pcn-ext-v1.0
微笑着面对明天 11 months ago
parent bd6e57c44d
commit 8cef863bae

@ -33,6 +33,8 @@ public interface IMesReworkTaskService {
List<MesProductionAssembly> assemblyQuery(MesReworkTaskRequestModel requestModel);
boolean validateSn(MesReworkTaskRequestModel requestModel);
void assemblySnRepeat(MesReworkTaskRequestModel requestModel);
void reworkSuccess(MesReworkTaskRequestModel requestModel);

@ -103,10 +103,11 @@ public class MesReworkTaskController {
try {
// 数据校验
ValidatorBean.checkNotNull(requestModel.getCustSn(), "客户条码不能为空");
/*ValidatorBean.checkNotNull(requestModel.getPartNo(), "零件号不能为空");*/
ValidatorBean.checkNotNull(requestModel.getAssemblyIds(), "替换装配件id不能为空");
ValidatorBean.checkNotNull(requestModel.getSn(), "替换条码不能为空");
ValidatorBean.checkNotNull(requestModel.getDetailIds(), "缺陷位置id不能为空");
//mesReworkTaskService.validateSn(requestModel);
mesReworkTaskService.assemblySnRepeat(requestModel);
return ResultBean.success("返工成功");
} catch (ImppBusiException imppException) {

@ -32,9 +32,10 @@ import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import java.util.List;
import java.util.Objects;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
/**
@ -153,6 +154,8 @@ public class MesReworkTaskServiceImpl implements IMesReworkTaskService {
public List<MesProductionAssembly> assemblyQuery(MesReworkTaskRequestModel requestModel) {
DdlPackBean packBean = DdlPackBean.getDdlPackBean(requestModel.getOrganizeCode());
DdlPreparedPack.getStringEqualPack(requestModel.getCustSn(), "custSn", packBean);
DdlPreparedPack.getNumEqualPack(requestModel.getIsOrigSn(), "isOrigSn", packBean);
//DdlPreparedPack.getStringEqualPack(requestModel.getPartNo(), "partNo", packBean);
if (!StringUtils.isEmpty(requestModel.getAssemblyPartNo())) {
DdlPreparedPack.getStringEqualPack(requestModel.getAssemblyPartNo(), "assemblyPartNo", packBean);
@ -161,8 +164,6 @@ public class MesReworkTaskServiceImpl implements IMesReworkTaskService {
DdlPreparedPack.getNumEqualPack(requestModel.getAssemblyPartStatus(), "assemblyStatus", packBean);
}
DdlPreparedPack.getOrderByPack(new Object[]{CommonEnumUtil.ASC_OR_DESC.ASC.getValue()}, new String[]{"assemblyStatus"}, packBean);
List<MesProductionAssembly> mesProductionAssemblies = mesProductionAssemblyRepository.findByHqlWhere(packBean);
if (CollectionUtils.isEmpty(mesProductionAssemblies)) {
MesPcnException.throwFlowException("装配件信息不存在");
@ -186,37 +187,114 @@ public class MesReworkTaskServiceImpl implements IMesReworkTaskService {
}
@Override
public boolean validateSn(MesReworkTaskRequestModel requestModel) {
//
List<String> snList = Arrays.asList(requestModel.getSn().split(","));
List<String> idList = Arrays.asList(requestModel.getAssemblyIds().split(","));
// 判断数量是否一致
if (snList.size() != idList.size()) MesPcnException.throwFlowException("选中的装配件个数和输入的个数不一致");
// 判断顺序是否一致
Map<String, String> map = IntStream.range(0, snList.size()).boxed().collect(Collectors.toMap(idList::get, snList::get, (a, b) -> b));
List<Long> idLonglist = idList.stream().map(str -> Long.parseLong(str)).collect(Collectors.toList());
DdlPackBean ddlPackBean = DdlPackBean.getDdlPackBean();
DdlPreparedPack.getInPackList(idLonglist, "id", ddlPackBean);
List<MesProductionAssembly> mesProductionAssemblies = mesProductionAssemblyRepository.findByHqlWhere(ddlPackBean);
if (CollectionUtils.isEmpty(mesProductionAssemblies)) {
MesPcnException.throwFlowException("装配件记录不存在");
}
Map<Long, String> mapProduction = mesProductionAssemblies.stream().collect(Collectors.toMap(mesProductionAssembly -> mesProductionAssembly.getId(), mesProductionAssembly -> mesProductionAssembly.getPartNo()));
map.forEach((k, v) -> {
MesProductionAssembly mesProductionAssembly = mesProductionAssemblyRepository.getById(Long.parseLong(k));
if (!Objects.equals(mapProduction.get(k), mesProductionAssembly.getPartNo())) {
MesPcnException.throwFlowException(String.format("装配件记录不匹配id=【%s】,sn=【%s】", k, v));
}
});
return false;
}
/**
* map idsn
* mapProductionAssemble id
* mapProduceSn
*
* mapProductionAssemble idmapsn
* mapProductionAssemble mmapProduceSnsn
*
*
* @param requestModel
*/
@Override
public void assemblySnRepeat(MesReworkTaskRequestModel requestModel) {
try {
//
List<String> snList = Arrays.asList(requestModel.getSn().split(","));
List<String> idList = Arrays.asList(requestModel.getAssemblyIds().split(","));
// 判断数量是否一致
if (snList.size() != idList.size()) MesPcnException.throwFlowException("选中的装配件个数和输入的个数不一致");
// 判断顺序是否一致 key = id, value = sn
Map<String, String> map = IntStream.range(0, snList.size()).boxed().collect(Collectors.toMap(idList::get, snList::get, (a, b) -> b));
List<Long> idLonglist = idList.stream().map(str -> Long.parseLong(str)).collect(Collectors.toList());
// 获取装配件记录列表
DdlPackBean ddlPackBean = DdlPackBean.getDdlPackBean();
DdlPreparedPack.getInPackList(idLonglist, "id", ddlPackBean);
List<MesProductionAssembly> mesProductionAssemblies = mesProductionAssemblyRepository.findByHqlWhere(ddlPackBean);
if (CollectionUtils.isEmpty(mesProductionAssemblies)) {
MesPcnException.throwFlowException("装配件记录不存在");
}
Map<Long, String> mapProductionAssemble = mesProductionAssemblies.stream().collect(Collectors.toMap(mesProductionAssembly -> mesProductionAssembly.getId(), mesProductionAssembly -> mesProductionAssembly.getAssemblyPartNo()));
// 获取替换条码信息列表
DdlPackBean snDdlPackBean = DdlPackBean.getDdlPackBean();
DdlPreparedPack.getInPackList(snList, "productSn", snDdlPackBean);
List<MesProduceSn> mesProduceSns = mesProduceSnRepository.findByHqlWhere(snDdlPackBean);
if (CollectionUtils.isEmpty(mesProductionAssemblies)) {
MesPcnException.throwFlowException("零件条码不存在");
}
Map<String, String> mapProduceSn = mesProduceSns.stream().collect(Collectors.toMap(mesProduceSn -> mesProduceSn.getPartNo(), mesProduceSn -> mesProduceSn.getProductSn()));
mapProductionAssemble.forEach((k, v) -> {
String sn = map.get(k + "");
String newSn = mapProduceSn.get(v);
if (!Objects.equals(sn, newSn)) {
MesPcnException.throwFlowException(String.format("装配件记录不匹配id=【%s】,sn=【%s】", k, sn));
}
});
for (String sn : snList) {
DdlPackBean packBean = DdlPackBean.getDdlPackBean(requestModel.getOrganizeCode());
DdlPreparedPack.getStringEqualPack(requestModel.getSn(), "productSn", packBean);
DdlPreparedPack.getStringEqualPack(sn, "productSn", packBean);
MesProduceSn mesProduceSn = mesProduceSnRepository.getByProperty(packBean);
if (mesProduceSn == null) {
MesPcnException.throwFlowException("条码信息不存在");
}
requestModel.setAssemblyPartNo(mesProduceSn.getPartNo());
requestModel.setAssemblyPartStatus(MesExtEnumUtil.ASSEMBLY_STATUS.ASSEMBLY_STATUS_10.getValue());
List<MesProductionAssembly> mesProductionAssemblies = assemblyQuery(requestModel);
if (CollectionUtils.isEmpty(mesProductionAssemblies)) {
List<MesProductionAssembly> mesProductionAssemblieList = assemblyQuery(requestModel);
if (CollectionUtils.isEmpty(mesProductionAssemblieList)) {
MesPcnException.throwFlowException("未匹配到该条码的零件号");
}
// 需要变更之前的记录
MesProductionAssembly mesProductionAssembly = mesProductionAssemblies.get(0);
MesProductionAssembly mesProductionAssembly = mesProductionAssemblieList.get(0);
mesProductionAssembly.setAssemblyStatus(MesExtEnumUtil.ASSEMBLY_STATUS.ASSEMBLY_STATUS_20.getValue());
// 需要新增一条替换条码的记录
MesProductionAssembly mesProductionRepeatAssembly = new MesProductionAssembly();
BeanUtils.copyProperties(mesProductionAssembly, mesProductionRepeatAssembly);
mesProductionRepeatAssembly.setAssemblySn(requestModel.getSn());
mesProductionRepeatAssembly.setAssemblySn(sn);
mesProductionRepeatAssembly.setAssemblyStatus(MesExtEnumUtil.ASSEMBLY_STATUS.ASSEMBLY_STATUS_10.getValue());
mesProductionRepeatAssembly.setId(null);
mesProductionAssembly.setIsOrigSn(CommonEnumUtil.TRUE_OR_FALSE.FALSE.getValue());
mesProductionAssembly.setRepeatAssemblySn(requestModel.getSn());
mesProductionAssembly.setRepeatAssemblySn(sn);
mesProductionAssemblyRepository.update(mesProductionAssembly);
mesProductionAssemblyRepository.save(mesProductionRepeatAssembly);
}
/**
* NC
*/
@ -225,6 +303,7 @@ public class MesReworkTaskServiceImpl implements IMesReworkTaskService {
}
} catch (Exception e) {
log.error("替换条码异常", e);
throw e;
}
}

@ -12,6 +12,10 @@ import java.util.List;
public class MesReworkTaskRequestModel {
/**
* id
*/
private String assemblyIds;
/**
*
*/
private String sn;
@ -41,4 +45,6 @@ public class MesReworkTaskRequestModel {
private String detailIds;
private Integer isOrigSn;
}

Loading…
Cancel
Save