diff --git a/src/main/java/com/dsic/gj_erp/bean/jhgk/DmSygdMx.java b/src/main/java/com/dsic/gj_erp/bean/jhgk/DmSygdMx.java
index 8e8e8f1..d051e32 100644
--- a/src/main/java/com/dsic/gj_erp/bean/jhgk/DmSygdMx.java
+++ b/src/main/java/com/dsic/gj_erp/bean/jhgk/DmSygdMx.java
@@ -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);
- }
}
diff --git a/src/main/java/com/dsic/gj_erp/bean/jhgk/YdjhImportNew.java b/src/main/java/com/dsic/gj_erp/bean/jhgk/YdjhImportNew.java
new file mode 100644
index 0000000..7022714
--- /dev/null
+++ b/src/main/java/com/dsic/gj_erp/bean/jhgk/YdjhImportNew.java
@@ -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
+ }
+
+}
diff --git a/src/main/java/com/dsic/gj_erp/bean/pgd/PgdTzjh.java b/src/main/java/com/dsic/gj_erp/bean/pgd/PgdTzjh.java
index 3a0d357..89e9f33 100644
--- a/src/main/java/com/dsic/gj_erp/bean/pgd/PgdTzjh.java
+++ b/src/main/java/com/dsic/gj_erp/bean/pgd/PgdTzjh.java
@@ -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;
@@ -80,15 +81,23 @@ public class PgdTzjh implements Serializable {
private String fkry;
- public static PgdTzjh of(YdjhImport jh,String pl){
+ public static PgdTzjh of(YdjhImport 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;
+ }
+
+ 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.setFd(fd);
tzjh.setZt("01");
-// tzjh.setTzzt("0");
return tzjh;
}
}
diff --git a/src/main/java/com/dsic/gj_erp/controller/jhgk/YdjhImportNewController.java b/src/main/java/com/dsic/gj_erp/controller/jhgk/YdjhImportNewController.java
new file mode 100644
index 0000000..ae6f61e
--- /dev/null
+++ b/src/main/java/com/dsic/gj_erp/controller/jhgk/YdjhImportNewController.java
@@ -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<>();
+ }
+}
diff --git a/src/main/java/com/dsic/gj_erp/listeners/ExcelYdjhImportNewListener.java b/src/main/java/com/dsic/gj_erp/listeners/ExcelYdjhImportNewListener.java
new file mode 100644
index 0000000..fdc02e8
--- /dev/null
+++ b/src/main/java/com/dsic/gj_erp/listeners/ExcelYdjhImportNewListener.java
@@ -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) {
+
+ }
+
+}
diff --git a/src/main/java/com/dsic/gj_erp/mapper/jhgk/YdjhImportNewMapper.java b/src/main/java/com/dsic/gj_erp/mapper/jhgk/YdjhImportNewMapper.java
new file mode 100644
index 0000000..b169def
--- /dev/null
+++ b/src/main/java/com/dsic/gj_erp/mapper/jhgk/YdjhImportNewMapper.java
@@ -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();
+}
diff --git a/src/main/java/com/dsic/gj_erp/service/jhgk/impl/YdjhImportNewService.java b/src/main/java/com/dsic/gj_erp/service/jhgk/impl/YdjhImportNewService.java
new file mode 100644
index 0000000..f931a79
--- /dev/null
+++ b/src/main/java/com/dsic/gj_erp/service/jhgk/impl/YdjhImportNewService.java
@@ -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.get切割完成1() != 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.get切割完成2() != null) {
+ Optional.ofNullable(collect.get("5")).ifPresent(bom -> {
+ item.set二跨面板板数(bom.size()+"");
+ });
+ }
+
+ if (item.get切割完成3() != 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.get切割完成4() != 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.get切割完成5() != null) {
+ Optional.ofNullable(collect.get("13")).ifPresent(bom -> {
+ item.set三跨数控板数(bom.size()+"");
+ });
+ }
+
+ if (item.get切割完成6() != null) {
+ Optional.ofNullable(collect.get("11")).ifPresent(bom -> {
+ item.set四区腹板板数(bom.size()+"");
+ });
+ }
+
+ if (item.get切割完成7() != 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.get切割完成1() != null) {
+ Optional.ofNullable(collect.get("7")).ifPresent(ydjhs -> {
+ ydjhs.forEach(ydjh->{
+ DmYdjh dmYdjh = this.updateYdjh(item.get上料完成(),item.get抛丸完成(),item.get切割完成1());
+ 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.get切割完成1());
+ dmYdjh.setId(ydjh.getId());
+ updateList.add(dmYdjh);
+ });
+ });
+ }
+
+ if (item.get切割完成2() != null) {
+ Optional.ofNullable(collect.get("5")).ifPresent(ydjhs -> {
+ ydjhs.forEach(ydjh->{
+ DmYdjh dmYdjh = this.updateYdjh(item.get上料完成(),item.get抛丸完成(),item.get切割完成2());
+ dmYdjh.setId(ydjh.getId());
+ updateList.add(dmYdjh);
+ });
+ });
+ }
+
+ if (item.get切割完成3() != null) {
+ Optional.ofNullable(collect.get("9")).ifPresent(ydjhs -> {
+ ydjhs.forEach(ydjh->{
+ DmYdjh dmYdjh = this.updateYdjh(item.get上料完成(),item.get抛丸完成(),item.get切割完成3());
+ 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.get切割完成3());
+ 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.get切割完成3());
+ dmYdjh.setId(ydjh.getId());
+ updateList.add(dmYdjh);
+ });
+ });
+ }
+
+ if (item.get切割完成4() != null) {
+ Optional.ofNullable(collect.get("6")).ifPresent(ydjhs -> {
+ ydjhs.forEach(ydjh->{
+ DmYdjh dmYdjh = this.updateYdjh(item.get上料完成(),item.get抛丸完成(),item.get切割完成4());
+ 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.get切割完成4());
+ dmYdjh.setId(ydjh.getId());
+ updateList.add(dmYdjh);
+ });
+ });
+ }
+
+ if (item.get切割完成5() != null) {
+ Optional.ofNullable(collect.get("13")).ifPresent(ydjhs -> {
+ ydjhs.forEach(ydjh->{
+ DmYdjh dmYdjh = this.updateYdjh(item.get上料完成(),item.get抛丸完成(),item.get切割完成5());
+ dmYdjh.setId(ydjh.getId());
+ updateList.add(dmYdjh);
+ });
+ });
+ }
+
+ if (item.get切割完成6() != null) {
+ Optional.ofNullable(collect.get("11")).ifPresent(ydjhs -> {
+ ydjhs.forEach(ydjh->{
+ DmYdjh dmYdjh = this.updateYdjh(item.get上料完成(),item.get抛丸完成(),item.get切割完成6());
+ dmYdjh.setId(ydjh.getId());
+ updateList.add(dmYdjh);
+ });
+ });
+ }
+
+ if (item.get切割完成7() != null) {
+ Optional.ofNullable(collect.get("15")).ifPresent(ydjhs -> {
+ ydjhs.forEach(ydjh->{
+ DmYdjh dmYdjh = this.updateYdjh(item.get上料完成(),item.get抛丸完成(),item.get切割完成7());
+ 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.get切割完成7());
+ 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.get切割完成1() != 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.get切割完成1());
+ 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.get切割完成1());
+ dmSygdMx.setJssj(item.getQfxqrqxz());
+ dmSygdMx.setGjjsDz(item.getQfxqrqdz());
+ dmSygdMx.setBomData(bom);
+ addList.add(dmSygdMx);
+ });
+ });
+ }
+
+ if (item.get切割完成2() != 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.get切割完成2());
+ dmSygdMx.setJssj(item.getQfxqrqxz());
+ dmSygdMx.setGjjsDz(item.getQfxqrqdz());
+ dmSygdMx.setBomData(bom);
+ addList.add(dmSygdMx);
+ });
+ });
+ }
+
+ if (item.get切割完成3() != 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.get切割完成3());
+ 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.get切割完成3());
+ 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.get切割完成3());
+ dmSygdMx.setJssj(item.getQfxqrqxz());
+ dmSygdMx.setGjjsDz(item.getQfxqrqdz());
+ dmSygdMx.setBomData(bom);
+ addList.add(dmSygdMx);
+ });
+ });
+ }
+
+ if (item.get切割完成4() != 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.get切割完成4());
+ 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.get切割完成4());
+ dmSygdMx.setQbs("1");
+ dmSygdMx.setQjgrq(item.get曲平铁曲完成());
+ dmSygdMx.setJssj(item.getQfxqrqxz());
+ dmSygdMx.setGjjsDz(item.getQfxqrqdz());
+ dmSygdMx.setBomData(bom);
+ addList.add(dmSygdMx);
+ });
+ });
+
+ }
+
+ if (item.get切割完成5() != 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.get切割完成5());
+ dmSygdMx.setQbs("1");
+ dmSygdMx.setQjgrq(item.get曲外板曲完成());
+ dmSygdMx.setJssj(item.getQfxqrqxz());
+ dmSygdMx.setGjjsDz(item.getQfxqrqdz());
+ dmSygdMx.setBomData(bom);
+ addList.add(dmSygdMx);
+ });
+ });
+ }
+
+ if (item.get切割完成6() != 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.get切割完成6());
+ dmSygdMx.setJssj(item.getQfxqrqxz());
+ dmSygdMx.setGjjsDz(item.getQfxqrqdz());
+ dmSygdMx.setBomData(bom);
+ addList.add(dmSygdMx);
+ });
+ });
+ }
+
+ if (item.get切割完成7() != 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.get切割完成7());
+ 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.get切割完成7());
+ 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);
+ });
+ }
+}
diff --git a/src/main/resources/mappers/jhgk/YdjhImportNewMapper.xml b/src/main/resources/mappers/jhgk/YdjhImportNewMapper.xml
new file mode 100644
index 0000000..c1bb47f
--- /dev/null
+++ b/src/main/resources/mappers/jhgk/YdjhImportNewMapper.xml
@@ -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>