1.新导入月度计划

master
董哲奇 3 months ago
parent cff7f8f7c1
commit 44910e569b

@ -281,6 +281,7 @@ public class DmSygdMx implements Serializable {
}
}
public static DmSygdMx ofWithDmSygdMxlj(DmSygdMxLj lj){
DmSygdMx mx = new DmSygdMx();
BeanUtil.copyProperties(lj,mx);
@ -374,7 +375,4 @@ public class DmSygdMx implements Serializable {
this.ylbhgg=bom.getYlbhgg();
}
public boolean isAvailable(){
return !StrUtil.isAllBlank(this.slrq,this.xcpw,this.pw,this.qgrq,this.qgjs,this.mbjb,this.xcmb,this.fdxq,this.gdjs);
}
}

@ -0,0 +1,163 @@
package com.dsic.gj_erp.bean.jhgk;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.format.DateTimeFormat;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
@TableName("ydjh_import_new")
public class YdjhImportNew {
@TableId(type = IdType.AUTO)
private String id;
@ExcelProperty("序号")
private String xh;
@ExcelProperty("产品")
private String dcCh;
@ExcelProperty("批量")
private String dcPl;
@ExcelProperty("分段")
private String dcFd;
@ExcelProperty("板数")
private String ;
@ExcelProperty("上料\n完成")
@DateTimeFormat("yyyy/MM/dd")
private String ;
@ExcelProperty("型材抛丸")
@DateTimeFormat("yyyy/MM/dd")
private String ;
@ExcelProperty("抛丸\n完成")
@DateTimeFormat("yyyy/MM/dd")
private String ;
@ExcelProperty("一垮\n龙门\n板数")
private String ;
@ExcelProperty("一垮\n数控\n板数")
private String ;
@ExcelProperty(value = "切割完成",index = 10)
@DateTimeFormat("yyyy/MM/dd")
private String 1;
@ExcelProperty("二垮\n面板\n板数")
private String ;
@ExcelProperty(value = "切割完成",index = 12)
@DateTimeFormat("yyyy/MM/dd")
private String 2;
@ExcelProperty("二垮\n数控\n板数")
private String ;
@ExcelProperty(value = "切割完成",index = 14)
@DateTimeFormat("yyyy/MM/dd")
private String 3;
@ExcelProperty("三垮\n平铁\n板数")
private String ;
@ExcelProperty(value = "切割完成",index = 16)
@DateTimeFormat("yyyy/MM/dd")
private String 4;
@ExcelProperty("曲平铁曲完成")
@DateTimeFormat("yyyy/MM/dd")
private String ;
@ExcelProperty("三垮\n数控\n板数")
private String ;
@ExcelProperty(value = "切割完成",index = 19)
@DateTimeFormat("yyyy/MM/dd")
private String 5;
@ExcelProperty("曲外板曲完成")
@DateTimeFormat("yyyy/MM/dd")
private String ;
@ExcelProperty("四区\n腹板\n板数")
private String ;
@ExcelProperty(value = "切割完成",index = 22)
@DateTimeFormat("yyyy/MM/dd")
private String 6;
@ExcelProperty("四区\n数控\n板数")
private String ;
@ExcelProperty(value = "切割完成",index = 24)
@DateTimeFormat("yyyy/MM/dd")
private String 7;
@ExcelProperty("面板挤边完成")
@DateTimeFormat("yyyy/MM/dd")
private String ;
@ExcelProperty("面板切割完成")
@DateTimeFormat("yyyy/MM/dd")
private String ;
@ExcelProperty("七垮\n型材\n米数")
private String ;
@ExcelProperty("型材切割完成")
@DateTimeFormat("yyyy/MM/dd")
private String ;
@ExcelProperty("光电 完成")
@DateTimeFormat("yyyy/MM/dd")
private String ;
@ExcelProperty("小组\n配送\n完成")
@DateTimeFormat("yyyy/MM/dd")
private String ;
@ExcelProperty("备注")
private String ;
private String fdxq;
private String ;
private boolean nonBom=true;
private String mbcz;
private String qfxqrqxz;
private String qfxqrqdz;
private String zt="0";
private String bzr;
private String bzrq;
public void tj(){
this.zt=ZtEnum.TJ.ordinal()+"";
}
public void sh(){
this.zt=ZtEnum.SH.ordinal()+"";
}
public enum ZtEnum{
BZ,TJ,SH
}
}

@ -3,6 +3,7 @@ package com.dsic.gj_erp.bean.pgd;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.dsic.gj_erp.bean.jhgk.YdjhImport;
import com.dsic.gj_erp.bean.jhgk.YdjhImportNew;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@ -86,9 +87,17 @@ public class PgdTzjh implements Serializable {
tzjh.setPl(pl);
tzjh.setQfxqrqxz(jh.getQfxqrqxz());
tzjh.setQfxqrqdz(jh.getQfxqrqdz());
// tzjh.setFd(fd);
tzjh.setZt("01");
// tzjh.setTzzt("0");
return tzjh;
}
public static PgdTzjh of(YdjhImportNew jh, String pl){
PgdTzjh tzjh = new PgdTzjh();
tzjh.setCzbh(jh.getDcCh());
tzjh.setPl(pl);
tzjh.setQfxqrqxz(jh.getQfxqrqxz());
tzjh.setQfxqrqdz(jh.getQfxqrqdz());
tzjh.setZt("01");
return tzjh;
}
}

@ -0,0 +1,65 @@
package com.dsic.gj_erp.controller.jhgk;
import cn.hutool.core.util.StrUtil;
import com.alibaba.excel.EasyExcel;
import com.dsic.gj_erp.annotation.AuthFunction;
import com.dsic.gj_erp.bean.ResultBean;
import com.dsic.gj_erp.bean.jhgk.YdjhImportNew;
import com.dsic.gj_erp.listeners.ExcelYdjhImportNewListener;
import com.dsic.gj_erp.service.jhgk.impl.YdjhImportNewService;
import lombok.AllArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.util.List;
@RestController
@RequestMapping("ydjhImportNew")
@AllArgsConstructor
public class YdjhImportNewController {
private final YdjhImportNewService ydjhImportNewService;
@GetMapping("listByFileName")
public ResultBean<?> listByFileName(String fileName) {
return new ResultBean<>(ydjhImportNewService.listByFileName(fileName));
}
@RequestMapping("/getFileNameList")
public ResultBean<?> getFileNameList(){
return new ResultBean<>(ydjhImportNewService.getFileNameList());
}
@RequestMapping("/ydjhImportNew")
@AuthFunction
public ResultBean ydjhImportNew(@RequestParam("file") MultipartFile file, HttpServletRequest req) throws IOException {
ExcelYdjhImportNewListener objectListener = new ExcelYdjhImportNewListener();
EasyExcel.read(file.getInputStream(), YdjhImportNew.class, objectListener).sheet(0).headRowNumber(1).doRead();
List<YdjhImportNew> objList = objectListener.getObjectList();
String fileName = file.getOriginalFilename();
fileName= StrUtil.removeSuffix(fileName, ".xls");
fileName=StrUtil.removeSuffix(fileName, ".xlsx");
ydjhImportNewService.handler(objList, fileName, req);
return new ResultBean(fileName);
}
@GetMapping("/tj")
public ResultBean<?> tj(String fileName) {
ydjhImportNewService.tj(fileName);
return new ResultBean<>();
}
@GetMapping("/sh")
public ResultBean<?> sh(String fileName) {
ydjhImportNewService.sh(fileName);
return new ResultBean<>();
}
}

@ -0,0 +1,31 @@
package com.dsic.gj_erp.listeners;
import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import com.dsic.gj_erp.bean.jhgk.YdjhImportNew;
import com.dsic.gj_erp.bean.jhgk.excel.JhxfExcel;
import lombok.Getter;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* Excel
*/
public class ExcelYdjhImportNewListener extends AnalysisEventListener<YdjhImportNew> {
@Getter
List<YdjhImportNew> objectList = new ArrayList<>();
@Override
public void invoke(YdjhImportNew excelDemo, AnalysisContext analysisContext) {
objectList.add(excelDemo);
}
@Override
public void doAfterAllAnalysed(AnalysisContext analysisContext) {
}
}

@ -0,0 +1,14 @@
package com.dsic.gj_erp.mapper.jhgk;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.dsic.gj_erp.bean.jhgk.YdjhImport;
import com.dsic.gj_erp.bean.jhgk.YdjhImportNew;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
@Mapper
public interface YdjhImportNewMapper extends BaseMapper<YdjhImportNew> {
List<String> getFileNameList();
}

@ -0,0 +1,616 @@
package com.dsic.gj_erp.service.jhgk.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.core.toolkit.support.SFunction;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.dsic.gj_erp.bean.jcsj.DmBom;
import com.dsic.gj_erp.bean.jcsj.DmCbxxp;
import com.dsic.gj_erp.bean.jhgk.*;
import com.dsic.gj_erp.bean.jhgk.excel.JhxfExcel;
import com.dsic.gj_erp.bean.pgd.PgdTzjh;
import com.dsic.gj_erp.mapper.jhgk.DmSygdxqMapper;
import com.dsic.gj_erp.mapper.jhgk.YdjhImportMapper;
import com.dsic.gj_erp.mapper.jhgk.YdjhImportNewMapper;
import com.dsic.gj_erp.service.jcsj.DmBomService;
import com.dsic.gj_erp.service.jcsj.DmCbxxpService;
import com.dsic.gj_erp.service.jhgk.DmSygdMxService;
import com.dsic.gj_erp.service.jhgk.DmYdjhService;
import com.dsic.gj_erp.service.pgd.PgdTzjhService;
import lombok.AllArgsConstructor;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.support.TransactionTemplate;
import javax.servlet.http.HttpServletRequest;
import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Consumer;
import java.util.stream.Collectors;
@Service
@AllArgsConstructor
public class YdjhImportNewService extends ServiceImpl<YdjhImportNewMapper, YdjhImportNew> {
private final DmSygdxqMapper sygdxqMapper;
private final DmBomService bomService;
private final DmCbxxpService dmCbxxpService;
private final PgdTzjhService tzjhService;
private final DmYdjhService dmYdjhService;
private final TransactionTemplate transactionTemplate;
private final DmSygdMxService sygdMxService;
private final RedisTemplate<String, Object> redisTemplate;
private static final String GJSCGK_SYGDMX_KEY = "GJSCGK::SYGDMX::";
private static final String GJSCGK_TZJH_KEY = "GJSCGK::TZJH::";
public List<String> getFileNameList() {
return baseMapper.getFileNameList();
}
public List<YdjhImportNew> listByFileName(String fileName) {
List<YdjhImportNew> list = this.list(Wrappers.<YdjhImportNew>lambdaQuery()
.eq(StrUtil.isNotEmpty(fileName), YdjhImportNew::get, fileName)
.orderByAsc(YdjhImportNew::getId)
);
list.stream().filter(item->StrUtil.isNotEmpty(item.getDcPl()))
.forEach(item->{
List<DmBom> bomList = bomService.getBomUni(item.getDcCh(),item.getDcPl());
if (ObjUtil.isNotEmpty(bomList)){
item.set(bomList.size()+"");
Map<String, List<DmBom>> collect = bomList.stream().collect(Collectors.groupingBy(DmBom::getKw));
//一垮龙门和一垮数控
if (item.get1() != null) {
Optional.ofNullable(collect.get("7")).ifPresent(bom -> {
item.set(bom.size()+"");
});
Optional.ofNullable(collect.get("8")).ifPresent(bom -> {
item.set(bom.size()+"");
});
}
if (item.get2() != null) {
Optional.ofNullable(collect.get("5")).ifPresent(bom -> {
item.set(bom.size()+"");
});
}
if (item.get3() != null) {
AtomicInteger atomicInteger = new AtomicInteger(0);
Optional.ofNullable(collect.get("9")).ifPresent(bom -> {
atomicInteger.addAndGet(bom.size());
});
Optional.ofNullable(collect.get("10")).ifPresent(bom -> {
atomicInteger.addAndGet(bom.size());
});
Optional.ofNullable(collect.get("12")).ifPresent(bom -> {
atomicInteger.addAndGet(bom.size());
});
item.set(atomicInteger.toString());
}
if (item.get4() != null) {
AtomicInteger atomicInteger = new AtomicInteger(0);
Optional.ofNullable(collect.get("6")).ifPresent(bom -> {
atomicInteger.addAndGet(bom.size());
});
Optional.ofNullable(collect.get("14")).ifPresent(bom -> {
atomicInteger.addAndGet(bom.size());
});
item.set(atomicInteger.toString());
}
if (item.get5() != null) {
Optional.ofNullable(collect.get("13")).ifPresent(bom -> {
item.set(bom.size()+"");
});
}
if (item.get6() != null) {
Optional.ofNullable(collect.get("11")).ifPresent(bom -> {
item.set(bom.size()+"");
});
}
if (item.get7() != null) {
AtomicInteger atomicInteger = new AtomicInteger(0);
Optional.ofNullable(collect.get("15")).ifPresent(bom -> {
atomicInteger.addAndGet(bom.size());
});
Optional.ofNullable(collect.get("16")).ifPresent(bom -> {
atomicInteger.addAndGet(bom.size());
});
item.set(atomicInteger.toString());
}
}
});
return list;
}
public void sh(String fileName) {
LambdaQueryWrapper<YdjhImportNew> wrapper = Wrappers.<YdjhImportNew>lambdaQuery()
.eq(YdjhImportNew::get, fileName)
.eq(YdjhImportNew::getZt, YdjhImportNew.ZtEnum.TJ.ordinal());
List<YdjhImportNew> list = this.updateData(wrapper, YdjhImportNew::sh);
if (ObjUtil.isEmpty(list)){
return;
}
List<DmYdjh> updateList=new ArrayList<>();
list.stream().filter(item->StrUtil.isAllNotEmpty(item.getDcCh(),item.getDcPl()))
.forEach(item->{
String dcPl = item.getDcPl();
try {
dcPl = String.format("%03d", Integer.parseInt(dcPl));
} catch (Exception ignored) {
}
List<DmYdjh> ydjhList = dmYdjhService.list(Wrappers.<DmYdjh>lambdaQuery().eq(DmYdjh::getDcCh, dcPl));
if (ObjUtil.isNotEmpty(ydjhList)){
Map<String, List<DmYdjh>> collect = ydjhList.stream().collect(Collectors.groupingBy(DmYdjh::getKw));
//一垮龙门和一垮数控
if (item.get1() != null) {
Optional.ofNullable(collect.get("7")).ifPresent(ydjhs -> {
ydjhs.forEach(ydjh->{
DmYdjh dmYdjh = this.updateYdjh(item.get(),item.get(),item.get1());
dmYdjh.setId(ydjh.getId());
updateList.add(dmYdjh);
});
});
Optional.ofNullable(collect.get("8")).ifPresent(ydjhs -> {
ydjhs.forEach(ydjh->{
DmYdjh dmYdjh = this.updateYdjh(item.get(),item.get(),item.get1());
dmYdjh.setId(ydjh.getId());
updateList.add(dmYdjh);
});
});
}
if (item.get2() != null) {
Optional.ofNullable(collect.get("5")).ifPresent(ydjhs -> {
ydjhs.forEach(ydjh->{
DmYdjh dmYdjh = this.updateYdjh(item.get(),item.get(),item.get2());
dmYdjh.setId(ydjh.getId());
updateList.add(dmYdjh);
});
});
}
if (item.get3() != null) {
Optional.ofNullable(collect.get("9")).ifPresent(ydjhs -> {
ydjhs.forEach(ydjh->{
DmYdjh dmYdjh = this.updateYdjh(item.get(),item.get(),item.get3());
dmYdjh.setId(ydjh.getId());
updateList.add(dmYdjh);
});
});
Optional.ofNullable(collect.get("10")).ifPresent(ydjhs -> {
ydjhs.forEach(ydjh->{
DmYdjh dmYdjh = this.updateYdjh(item.get(),item.get(),item.get3());
dmYdjh.setId(ydjh.getId());
updateList.add(dmYdjh);
});
});
Optional.ofNullable(collect.get("12")).ifPresent(ydjhs -> {
ydjhs.forEach(ydjh->{
DmYdjh dmYdjh = this.updateYdjh(item.get(),item.get(),item.get3());
dmYdjh.setId(ydjh.getId());
updateList.add(dmYdjh);
});
});
}
if (item.get4() != null) {
Optional.ofNullable(collect.get("6")).ifPresent(ydjhs -> {
ydjhs.forEach(ydjh->{
DmYdjh dmYdjh = this.updateYdjh(item.get(),item.get(),item.get4());
dmYdjh.setId(ydjh.getId());
updateList.add(dmYdjh);
});
});
Optional.ofNullable(collect.get("14")).ifPresent(ydjhs -> {
ydjhs.forEach(ydjh->{
DmYdjh dmYdjh = this.updateYdjh(item.get(),item.get(),item.get4());
dmYdjh.setId(ydjh.getId());
updateList.add(dmYdjh);
});
});
}
if (item.get5() != null) {
Optional.ofNullable(collect.get("13")).ifPresent(ydjhs -> {
ydjhs.forEach(ydjh->{
DmYdjh dmYdjh = this.updateYdjh(item.get(),item.get(),item.get5());
dmYdjh.setId(ydjh.getId());
updateList.add(dmYdjh);
});
});
}
if (item.get6() != null) {
Optional.ofNullable(collect.get("11")).ifPresent(ydjhs -> {
ydjhs.forEach(ydjh->{
DmYdjh dmYdjh = this.updateYdjh(item.get(),item.get(),item.get6());
dmYdjh.setId(ydjh.getId());
updateList.add(dmYdjh);
});
});
}
if (item.get7() != null) {
Optional.ofNullable(collect.get("15")).ifPresent(ydjhs -> {
ydjhs.forEach(ydjh->{
DmYdjh dmYdjh = this.updateYdjh(item.get(),item.get(),item.get7());
dmYdjh.setId(ydjh.getId());
updateList.add(dmYdjh);
});
});
Optional.ofNullable(collect.get("16")).ifPresent(ydjhs -> {
ydjhs.forEach(ydjh->{
DmYdjh dmYdjh = this.updateYdjh(item.get(),item.get(),item.get7());
dmYdjh.setId(ydjh.getId());
updateList.add(dmYdjh);
});
});
}
}
});
dmYdjhService.updateBatchById(updateList);
}
private DmYdjh updateYdjh(String slrq,String pwrq,String qgrq){
DmYdjh dmYdjh = new DmYdjh();
dmYdjh.setSljhrq(slrq);
dmYdjh.setPwjhrq(pwrq);
dmYdjh.setHxjhrq(qgrq);
dmYdjh.setQgjhrq(qgrq);
return dmYdjh;
}
public void tj(String fileName) {
LambdaQueryWrapper<YdjhImportNew> wrapper = Wrappers.<YdjhImportNew>lambdaQuery()
.eq(YdjhImportNew::get, fileName)
.eq(YdjhImportNew::getZt, YdjhImportNew.ZtEnum.BZ.ordinal());
List<YdjhImportNew> list = this.updateData(wrapper, YdjhImportNew::tj);
List<DmSygdMx> sygdMxList = new ArrayList<>();
List<PgdTzjh> tzjhList = new ArrayList<>();
if (ObjUtil.isEmpty(list)){
return;
}
list.forEach(item -> {
String dcPl = item.getDcPl();
try {
dcPl = String.format("%03d", Integer.parseInt(dcPl));
} catch (Exception ignored) {
}
item.setDcPl(dcPl);
List<DmSygdMx> sygdmx = (List<DmSygdMx>) redisTemplate.opsForHash().get(GJSCGK_SYGDMX_KEY + fileName, item.getDcCh() + "_" + dcPl);
if (ObjUtil.isNotEmpty(sygdmx)) {
sygdMxList.addAll(sygdmx);
}
PgdTzjh tzjh = (PgdTzjh) redisTemplate.opsForHash().get(GJSCGK_TZJH_KEY + fileName, item.getDcCh() + "_" + dcPl);
if (ObjUtil.isNotEmpty(tzjh)){
tzjhList.add(tzjh);
}
});
if (ObjUtil.isAllEmpty(sygdMxList,tzjhList)){
return;
}
transactionTemplate.execute((status)->{
list.stream().filter(item -> StrUtil.isAllNotEmpty(item.getDcCh(),item.getDcPl()))
.forEach(item->{
sygdMxService.remove(new QueryWrapper<DmSygdMx>()
.eq("dc_ch", item.getDcCh())
.eq("dc_pl", item.getDcPl())
);
//清理未处理的图纸计划
tzjhService.remove(Wrappers.<PgdTzjh>lambdaQuery()
.eq(PgdTzjh::getCzbh,item.getDcCh())
.eq(PgdTzjh::getPl,item.getDcPl())
.and(it->it.isNull(PgdTzjh::getFkrq).or().eq(PgdTzjh::getFkrq,""))
);
});
sygdMxService.saveBatch(sygdMxList);
//图纸计划入库
tzjhService.saveBatch(tzjhList);
return true;
});
// redisTemplate.opsForHash().delete(GJSCGK_SYGDMX_KEY+fileName);
// redisTemplate.opsForHash().delete(GJSCGK_TZJH_KEY+fileName);
}
private List<YdjhImportNew> updateData(LambdaQueryWrapper<YdjhImportNew> wrapper, Consumer<YdjhImportNew> handler) {
List<YdjhImportNew> list = this.list(wrapper);
list.forEach(item -> {
YdjhImportNew ydjhImportNew = new YdjhImportNew();
ydjhImportNew.setId(item.getId());
ydjhImportNew.setNonBom(item.isNonBom());
handler.accept(ydjhImportNew);
this.updateById(ydjhImportNew);
});
return list;
}
public void handler(List<YdjhImportNew> list, String fileName, HttpServletRequest request) {
//三月滚动明细
this.createSygdmx(list, fileName);
//没有基础数据的计划生成图纸计划
this.createTzjh(list, fileName, request);
transactionTemplate.execute((status) -> {
list.stream().filter(item -> StrUtil.isAllNotEmpty(item.getDcCh(), item.getDcPl()))
.forEach(item -> {
item.set(fileName);
this.remove(new QueryWrapper<YdjhImportNew>()
.eq("dc_ch", item.getDcCh())
.eq("dc_pl", item.getDcPl())
.eq("文件名", fileName)//根据同名文件进行删除
);
});
list.forEach(this::save);
return true;
});
}
private void createTzjh(List<YdjhImportNew> list, String fileName, HttpServletRequest request) {
String yhms = (String) request.getAttribute("yhms");
String date = DateUtil.date().toString("yyyy/MM/dd");
list.stream()
.filter(YdjhImportNew::isNonBom)
.forEach(item -> {
String dcPl = item.getDcPl();
try {
dcPl = String.format("%03d", Integer.parseInt(dcPl));
} catch (Exception ignored) {
}
PgdTzjh dmTzjh = PgdTzjh.of(item, dcPl);
dmTzjh.setBzry(yhms);
dmTzjh.setBzrq(date);
redisTemplate.opsForHash().put(GJSCGK_TZJH_KEY + fileName, item.getDcCh() + "_" + dcPl, dmTzjh);
});
}
/**
* ,使使
*/
private void createSygdmx(List<YdjhImportNew> objList, String fileName) {
objList.stream()
.filter(item -> !item.getDcPl().contains("-"))//批次范围的数据暂不处理
.forEach(item -> {
List<DmSygdMx> addList = new ArrayList<>();
String dcPl = item.getDcPl();
try {
dcPl = String.format("%03d", Integer.parseInt(dcPl));
} catch (Exception ignored) {
}
List<DmBom> bomList = bomService.getBomUni(item.getDcCh(), dcPl);
if (ObjUtil.isEmpty(bomList)) {
//无bom,明细数据使用目标船只替代,切在作业计划中生成一条(按照kw进行区分)数据
return;
}
if (ObjUtil.isNotEmpty(bomList)) {
item.setNonBom(false);
}
//修正前方需求数据
List<DmSygdxq> dmSygdxqs = sygdxqMapper.selectList(Wrappers.<DmSygdxq>lambdaQuery()
.eq(DmSygdxq::getDcCh, item.getDcCh()).eq(DmSygdxq::getDcPl, dcPl));
if (ObjUtil.isNotEmpty(dmSygdxqs)) {
DmSygdxq dmSygdxq = dmSygdxqs.get(0);
item.setQfxqrqxz(dmSygdxq.getXzglxq());
item.setQfxqrqdz(dmSygdxq.getDzglxq());
}
Map<String, List<DmBom>> collect = bomList.stream().collect(Collectors.groupingBy(DmBom::getKw));
//一垮龙门和一垮数控
if (item.get1() != null) {
Optional.ofNullable(collect.get("7")).ifPresent(boms -> {
boms.forEach(bom -> {
DmSygdMx dmSygdMx = new DmSygdMx();
dmSygdMx.setDcCh(item.getDcCh());
dmSygdMx.setDcPl(item.getDcPl());
dmSygdMx.setQgrq(item.get1());
dmSygdMx.setJssj(item.getQfxqrqxz());
dmSygdMx.setGjjsDz(item.getQfxqrqdz());
dmSygdMx.setBomData(bom);
addList.add(dmSygdMx);
});
});
Optional.ofNullable(collect.get("8")).ifPresent(boms -> {
boms.forEach(bom -> {
DmSygdMx dmSygdMx = new DmSygdMx();
dmSygdMx.setDcCh(item.getDcCh());
dmSygdMx.setDcPl(item.getDcPl());
dmSygdMx.setQgrq(item.get1());
dmSygdMx.setJssj(item.getQfxqrqxz());
dmSygdMx.setGjjsDz(item.getQfxqrqdz());
dmSygdMx.setBomData(bom);
addList.add(dmSygdMx);
});
});
}
if (item.get2() != null) {
Optional.ofNullable(collect.get("5")).ifPresent(boms -> {
boms.forEach(bom -> {
DmSygdMx dmSygdMx = new DmSygdMx();
dmSygdMx.setDcCh(item.getDcCh());
dmSygdMx.setDcPl(item.getDcPl());
dmSygdMx.setQgrq(item.get2());
dmSygdMx.setJssj(item.getQfxqrqxz());
dmSygdMx.setGjjsDz(item.getQfxqrqdz());
dmSygdMx.setBomData(bom);
addList.add(dmSygdMx);
});
});
}
if (item.get3() != null) {
Optional.ofNullable(collect.get("9")).ifPresent(boms -> {
boms.forEach(bom -> {
DmSygdMx dmSygdMx = new DmSygdMx();
dmSygdMx.setDcCh(item.getDcCh());
dmSygdMx.setDcPl(item.getDcPl());
dmSygdMx.setQgrq(item.get3());
dmSygdMx.setJssj(item.getQfxqrqxz());
dmSygdMx.setGjjsDz(item.getQfxqrqdz());
dmSygdMx.setBomData(bom);
addList.add(dmSygdMx);
});
});
Optional.ofNullable(collect.get("10")).ifPresent(boms -> {
boms.forEach(bom -> {
DmSygdMx dmSygdMx = new DmSygdMx();
dmSygdMx.setDcCh(item.getDcCh());
dmSygdMx.setDcPl(item.getDcPl());
dmSygdMx.setQgrq(item.get3());
dmSygdMx.setJssj(item.getQfxqrqxz());
dmSygdMx.setGjjsDz(item.getQfxqrqdz());
dmSygdMx.setBomData(bom);
addList.add(dmSygdMx);
});
});
Optional.ofNullable(collect.get("12")).ifPresent(boms -> {
boms.forEach(bom -> {
DmSygdMx dmSygdMx = new DmSygdMx();
dmSygdMx.setDcCh(item.getDcCh());
dmSygdMx.setDcPl(item.getDcPl());
dmSygdMx.setQgrq(item.get3());
dmSygdMx.setJssj(item.getQfxqrqxz());
dmSygdMx.setGjjsDz(item.getQfxqrqdz());
dmSygdMx.setBomData(bom);
addList.add(dmSygdMx);
});
});
}
if (item.get4() != null) {
Optional.ofNullable(collect.get("6")).ifPresent(boms -> {
boms.forEach(bom -> {
DmSygdMx dmSygdMx = new DmSygdMx();
dmSygdMx.setDcCh(item.getDcCh());
dmSygdMx.setDcPl(item.getDcPl());
dmSygdMx.setQgrq(item.get4());
dmSygdMx.setQbs("1");
dmSygdMx.setQjgrq(item.get());
dmSygdMx.setJssj(item.getQfxqrqxz());
dmSygdMx.setGjjsDz(item.getQfxqrqdz());
dmSygdMx.setBomData(bom);
addList.add(dmSygdMx);
});
});
Optional.ofNullable(collect.get("14")).ifPresent(boms -> {
boms.forEach(bom -> {
DmSygdMx dmSygdMx = new DmSygdMx();
dmSygdMx.setDcCh(item.getDcCh());
dmSygdMx.setDcPl(item.getDcPl());
dmSygdMx.setQgrq(item.get4());
dmSygdMx.setQbs("1");
dmSygdMx.setQjgrq(item.get());
dmSygdMx.setJssj(item.getQfxqrqxz());
dmSygdMx.setGjjsDz(item.getQfxqrqdz());
dmSygdMx.setBomData(bom);
addList.add(dmSygdMx);
});
});
}
if (item.get5() != null) {
Optional.ofNullable(collect.get("13")).ifPresent(boms -> {
boms.forEach(bom -> {
DmSygdMx dmSygdMx = new DmSygdMx();
dmSygdMx.setDcCh(item.getDcCh());
dmSygdMx.setDcPl(item.getDcPl());
dmSygdMx.setQgrq(item.get5());
dmSygdMx.setQbs("1");
dmSygdMx.setQjgrq(item.get());
dmSygdMx.setJssj(item.getQfxqrqxz());
dmSygdMx.setGjjsDz(item.getQfxqrqdz());
dmSygdMx.setBomData(bom);
addList.add(dmSygdMx);
});
});
}
if (item.get6() != null) {
Optional.ofNullable(collect.get("11")).ifPresent(boms -> {
boms.forEach(bom -> {
DmSygdMx dmSygdMx = new DmSygdMx();
dmSygdMx.setDcCh(item.getDcCh());
dmSygdMx.setDcPl(item.getDcPl());
dmSygdMx.setQgrq(item.get6());
dmSygdMx.setJssj(item.getQfxqrqxz());
dmSygdMx.setGjjsDz(item.getQfxqrqdz());
dmSygdMx.setBomData(bom);
addList.add(dmSygdMx);
});
});
}
if (item.get7() != null) {
Optional.ofNullable(collect.get("15")).ifPresent(boms -> {
boms.forEach(bom -> {
DmSygdMx dmSygdMx = new DmSygdMx();
dmSygdMx.setDcCh(item.getDcCh());
dmSygdMx.setDcPl(item.getDcPl());
dmSygdMx.setQgrq(item.get7());
dmSygdMx.setJssj(item.getQfxqrqxz());
dmSygdMx.setGjjsDz(item.getQfxqrqdz());
dmSygdMx.setBomData(bom);
addList.add(dmSygdMx);
});
});
Optional.ofNullable(collect.get("16")).ifPresent(boms -> {
boms.forEach(bom -> {
DmSygdMx dmSygdMx = new DmSygdMx();
dmSygdMx.setDcCh(item.getDcCh());
dmSygdMx.setDcPl(item.getDcPl());
dmSygdMx.setQgrq(item.get7());
dmSygdMx.setJssj(item.getQfxqrqxz());
dmSygdMx.setGjjsDz(item.getQfxqrqdz());
dmSygdMx.setBomData(bom);
addList.add(dmSygdMx);
});
});
}
redisTemplate.opsForHash().put(GJSCGK_SYGDMX_KEY + fileName, item.getDcCh() + "_" + dcPl, addList);
});
}
}

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.dsic.gj_erp.mapper.jhgk.YdjhImportNewMapper">
<select id="getFileNameList" resultType="java.lang.String">
SELECT distinct 文件名 from ydjh_import_new WHERE isnull(文件名,'')!=''
</select>
</mapper>
Loading…
Cancel
Save