|
|
|
@ -2,6 +2,7 @@ package com.dsic.gj_erp.service.zyjh;
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.date.DateTime;
|
|
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
|
|
import cn.hutool.core.io.FileUtil;
|
|
|
|
|
import cn.hutool.core.util.ObjUtil;
|
|
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
@ -17,19 +18,21 @@ import com.dsic.gj_erp.bean.zyjh.DmYppyz;
|
|
|
|
|
import com.dsic.gj_erp.controller.zyjh.dto.PgWithPcDto;
|
|
|
|
|
import com.dsic.gj_erp.controller.zyjh.dto.ShangLiao;
|
|
|
|
|
import com.dsic.gj_erp.controller.zyjh.dto.SljhSearch;
|
|
|
|
|
import com.dsic.gj_erp.dao.zyjh.PPBGongDto;
|
|
|
|
|
import com.dsic.gj_erp.mapper.jhgk.DmYdjhMapper;
|
|
|
|
|
import com.dsic.gj_erp.service.jcsj.DmBzryService;
|
|
|
|
|
import com.dsic.gj_erp.service.jcsj.DmCbxxpService;
|
|
|
|
|
import com.dsic.gj_erp.service.jhgk.DmYdjhLjService;
|
|
|
|
|
import com.dsic.gj_erp.util.ExcelUtil;
|
|
|
|
|
import com.google.common.collect.ImmutableMap;
|
|
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
|
|
import org.springframework.data.redis.core.RedisTemplate;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
|
|
import java.io.File;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
import java.util.regex.Pattern;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
@Service
|
|
|
|
@ -114,13 +117,80 @@ public class ZyjhService extends ServiceImpl<DmYdjhMapper,DmYdjh> {
|
|
|
|
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
|
public List<DmYdjhLj> createLj(String dcCh, String dcPl, String tzbh){
|
|
|
|
|
|
|
|
|
|
List<DmYdjhLj> ljInfo = baseMapper.getLjInfo(dcCh, dcPl, tzbh);
|
|
|
|
|
//给零件设置流向
|
|
|
|
|
Map<String, List<DmYdjhLj>> _ljMap = ljInfo.stream()
|
|
|
|
|
.collect(Collectors
|
|
|
|
|
.groupingBy(item ->
|
|
|
|
|
item.getCzbh() + "_" + item.getPl() + "_" + item.getFd()
|
|
|
|
|
));
|
|
|
|
|
_ljMap.forEach((key,values)->{
|
|
|
|
|
try {
|
|
|
|
|
String[] keys=key.split("_");
|
|
|
|
|
String ch=keys[0];
|
|
|
|
|
String pl=keys[1];
|
|
|
|
|
String fd=keys[2];
|
|
|
|
|
File dir = new File("static/upload/" + ch + "/" + pl + "/其他");
|
|
|
|
|
String patternStr = pl + "_" + fd + "_分段配套表";
|
|
|
|
|
List<File> fileList = FileUtil.loopFiles(dir);
|
|
|
|
|
fileList.stream()
|
|
|
|
|
.filter(file -> file.getName().contains(patternStr))
|
|
|
|
|
.forEach(file -> {
|
|
|
|
|
if (file.exists()){
|
|
|
|
|
List<String> strings = ExcelUtil.ReadExcelByLine(file);
|
|
|
|
|
System.out.println(strings);
|
|
|
|
|
for (DmYdjhLj _lj : values){
|
|
|
|
|
for (String _str:strings){
|
|
|
|
|
if (_str.contains(_lj.getTlth())&&_str.contains(_lj.getLjbh())){
|
|
|
|
|
String[] _strArr=_str.split(" ");
|
|
|
|
|
if (_strArr.length>8){
|
|
|
|
|
_lj.setLx(_strArr[8]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
ljService.remove(Wrappers.<DmYdjhLj>lambdaQuery()
|
|
|
|
|
.eq(DmYdjhLj::getCzbh,dcCh)
|
|
|
|
|
.eq(DmYdjhLj::getPl,dcPl)
|
|
|
|
|
.eq(DmYdjhLj::getTlth,tzbh)
|
|
|
|
|
);
|
|
|
|
|
List<DmYdjhLj> ljInfo = baseMapper.getLjInfo(dcCh, dcPl, tzbh);
|
|
|
|
|
ljService.saveBatch(ljInfo);
|
|
|
|
|
|
|
|
|
|
//自动生成无摆放位置的预配盘原则
|
|
|
|
|
Map<String, List<DmYdjhLj>> collect = ljInfo.stream()
|
|
|
|
|
.collect(Collectors
|
|
|
|
|
.groupingBy(item ->
|
|
|
|
|
item.getCzbh() + " "
|
|
|
|
|
+ item.getPl() + " "
|
|
|
|
|
+ item.getFd() + " "
|
|
|
|
|
+ item.getZl() + " "
|
|
|
|
|
+ (StrUtil.isNotEmpty(item.getLx())?item.getLx():"")
|
|
|
|
|
));
|
|
|
|
|
|
|
|
|
|
collect.keySet().forEach(item -> {
|
|
|
|
|
DmYppyz dmYppyz = DmYppyz.of(item);
|
|
|
|
|
if (dmYppyz!=null){
|
|
|
|
|
int count = yppyzService.count(Wrappers.<DmYppyz>lambdaQuery()
|
|
|
|
|
.eq(DmYppyz::getDcCh, dmYppyz.getDcCh())
|
|
|
|
|
.eq(DmYppyz::getDcPl, dmYppyz.getDcPl())
|
|
|
|
|
.eq(DmYppyz::getDcFd, dmYppyz.getDcFd())
|
|
|
|
|
.eq(DmYppyz::getZl, dmYppyz.getZl())
|
|
|
|
|
.eq(StrUtil.isNotEmpty(dmYppyz.getLx()),DmYppyz::getLx, dmYppyz.getLx())
|
|
|
|
|
);
|
|
|
|
|
if (count==0){
|
|
|
|
|
yppyzService.save(dmYppyz);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return ljInfo;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|