package com.jcdm.main.da.tileMatchRules.service.impl;
|
|
import java.util.ArrayList;
|
import java.util.List;
|
import java.util.stream.Collectors;
|
|
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.ListUtil;
|
import cn.hutool.core.util.StrUtil;
|
import com.jcdm.common.utils.DateUtils;
|
import com.jcdm.main.da.passingStationCollection.domain.ProductNewPassStation;
|
import com.jcdm.main.da.passingStationCollection.service.ProductNewPassStationService;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Service;
|
import com.jcdm.main.da.tileMatchRules.mapper.DaTileMatchRulesMapper;
|
import com.jcdm.main.da.tileMatchRules.domain.DaTileMatchRules;
|
import com.jcdm.main.da.tileMatchRules.service.IDaTileMatchRulesService;
|
|
import javax.annotation.Resource;
|
|
/**
|
* 配瓦规则Service业务层处理
|
*
|
* @author jiang
|
* @date 2024-01-24
|
*/
|
@Service
|
public class DaTileMatchRulesServiceImpl implements IDaTileMatchRulesService
|
{
|
@Autowired
|
private DaTileMatchRulesMapper daTileMatchRulesMapper;
|
|
@Resource
|
private ProductNewPassStationService productNewPassStationService;
|
|
/**
|
* 查询配瓦规则
|
*
|
* @param id 配瓦规则主键
|
* @return 配瓦规则
|
*/
|
@Override
|
public DaTileMatchRules selectDaTileMatchRulesById(Long id)
|
{
|
return daTileMatchRulesMapper.selectDaTileMatchRulesById(id);
|
}
|
|
/**
|
* 查询配瓦规则列表
|
*
|
* @param daTileMatchRules 配瓦规则
|
* @return 配瓦规则
|
*/
|
@Override
|
public List<DaTileMatchRules> selectDaTileMatchRulesList(DaTileMatchRules daTileMatchRules)
|
{
|
return daTileMatchRulesMapper.selectDaTileMatchRulesList(daTileMatchRules);
|
}
|
|
/**
|
* 新增配瓦规则
|
*
|
* @param daTileMatchRules 配瓦规则
|
* @return 结果
|
*/
|
@Override
|
public int insertDaTileMatchRules(DaTileMatchRules daTileMatchRules)
|
{
|
daTileMatchRules.setCreateTime(DateUtils.getNowDate());
|
return daTileMatchRulesMapper.insertDaTileMatchRules(daTileMatchRules);
|
}
|
|
/**
|
* 修改配瓦规则
|
*
|
* @param daTileMatchRules 配瓦规则
|
* @return 结果
|
*/
|
@Override
|
public int updateDaTileMatchRules(DaTileMatchRules daTileMatchRules)
|
{
|
daTileMatchRules.setUpdateTime(DateUtils.getNowDate());
|
return daTileMatchRulesMapper.updateDaTileMatchRules(daTileMatchRules);
|
}
|
|
/**
|
* 批量删除配瓦规则
|
*
|
* @param ids 需要删除的配瓦规则主键
|
* @return 结果
|
*/
|
@Override
|
public int deleteDaTileMatchRulesByIds(Long[] ids)
|
{
|
return daTileMatchRulesMapper.deleteDaTileMatchRulesByIds(ids);
|
}
|
|
/**
|
* 删除配瓦规则信息
|
*
|
* @param id 配瓦规则主键
|
* @return 结果
|
*/
|
@Override
|
public int deleteDaTileMatchRulesById(Long id)
|
{
|
return daTileMatchRulesMapper.deleteDaTileMatchRulesById(id);
|
}
|
|
@Override
|
public List<DaTileMatchRules> checkData(String SNCode, String XT, String CZ) {
|
List<DaTileMatchRules> resultList =new ArrayList<>();
|
ProductNewPassStation productNewPassStation = new ProductNewPassStation();
|
productNewPassStation.setSfcCode(SNCode);
|
List<ProductNewPassStation> passStationList = productNewPassStationService.getProductPassStationList(productNewPassStation);
|
if (CollUtil.isNotEmpty(passStationList)){
|
ProductNewPassStation passStation = passStationList.get(0);
|
String productType = passStation.getProductType();
|
DaTileMatchRules daTileMatchRules = new DaTileMatchRules();
|
daTileMatchRules.setProductSeries(productType);
|
daTileMatchRules.setScanObject1("箱体");
|
daTileMatchRules.setScanObject2("曲轴");
|
List<DaTileMatchRules> daTileMatchRulesList = this.selectDaTileMatchRulesList(daTileMatchRules);
|
if (StrUtil.isNotBlank(XT) && StrUtil.isNotBlank(CZ)){
|
ArrayList<String> xtList = ListUtil.toList(XT.split(";"));
|
ArrayList<String> czList = new ArrayList<>();
|
String s2 = "";
|
if (CZ.contains(";")){
|
czList = ListUtil.toList(CZ.split(";"));
|
if (CollUtil.isNotEmpty(czList) && czList.size()>2){
|
s2 = czList.get(2);
|
}
|
} else if (CZ.contains(",")){
|
czList = ListUtil.toList(CZ.split(","));
|
if (CollUtil.isNotEmpty(czList) && czList.size()>1){
|
s2 = czList.get(1);
|
}
|
}
|
if (CollUtil.isNotEmpty(xtList) && xtList.size()>1 &&
|
StrUtil.isNotBlank(s2)){
|
String s1 = xtList.get(1);
|
if ("380".equals(productType)){
|
for (int i = 1; i < 5; i++){
|
char[] charArray1 = s1.toCharArray();
|
String axisValue;
|
String neckValue;
|
if (charArray1.length >= 7){
|
axisValue = String.valueOf(charArray1[i]);
|
} else {
|
axisValue = "";
|
}
|
char[] charArray2 = s2.toCharArray();
|
if (charArray2.length >= 8){
|
neckValue = String.valueOf(charArray2[i]);
|
} else {
|
neckValue = "";
|
}
|
Integer position = i+1;
|
List<DaTileMatchRules> collect = daTileMatchRulesList.stream().filter(x -> position.equals(x.getAxisParameterNoPosition())
|
&& position.equals(x.getNeckParameterPosition())
|
&& x.getAxisValue().equals(axisValue)
|
&& x.getNeckValue().equals(neckValue)).collect(Collectors.toList());
|
if (CollUtil.isNotEmpty(collect)){
|
DaTileMatchRules daTileMatchRules1 = collect.get(0);
|
resultList.add(daTileMatchRules1);
|
}
|
}
|
|
}
|
}
|
|
}
|
}
|
return resultList;
|
}
|
}
|