commit
6851cf0f4b
@ -0,0 +1,40 @@
|
|||||||
|
package com.dsic.gj_erp.bean.jhgk.excel;
|
||||||
|
|
||||||
|
import com.alibaba.excel.annotation.ExcelProperty;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
public class ZrcAndPlb {
|
||||||
|
|
||||||
|
@ExcelProperty(value = "批量号")
|
||||||
|
public String dcPl;
|
||||||
|
|
||||||
|
@ExcelProperty(value = "包含分段")
|
||||||
|
public String mfd;
|
||||||
|
|
||||||
|
@ExcelProperty(value = "吨位")
|
||||||
|
public String ton;
|
||||||
|
|
||||||
|
@ExcelProperty(value = "钢加结束")
|
||||||
|
public String gjjs;
|
||||||
|
|
||||||
|
@ExcelProperty(value = "钢加开始")
|
||||||
|
public String gjks;
|
||||||
|
|
||||||
|
@ExcelProperty(value = "套料图")
|
||||||
|
public String tlt;
|
||||||
|
|
||||||
|
@ExcelProperty(value = "板材领取表")
|
||||||
|
public String bclqb;
|
||||||
|
|
||||||
|
@ExcelProperty(value = "订货清单发放")
|
||||||
|
public String dhqd;
|
||||||
|
|
||||||
|
@ExcelProperty(value = "钢料到齐时间")
|
||||||
|
public String gldq;
|
||||||
|
|
||||||
|
@ExcelProperty(value = "备注")
|
||||||
|
public String bz;
|
||||||
|
}
|
@ -0,0 +1,263 @@
|
|||||||
|
package com.dsic.gj_erp.controller.jhgk;
|
||||||
|
|
||||||
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
|
import cn.hutool.core.date.DateUtil;
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import com.alibaba.excel.EasyExcel;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
import com.dsic.gj_erp.bean.ResultBean;
|
||||||
|
import com.dsic.gj_erp.bean.jcsj.DmCzplp;
|
||||||
|
import com.dsic.gj_erp.bean.jcsj.DmCzplpNew;
|
||||||
|
import com.dsic.gj_erp.bean.jhgk.DmTzjh;
|
||||||
|
import com.dsic.gj_erp.bean.jhgk.DmZrcjh;
|
||||||
|
import com.dsic.gj_erp.bean.jhgk.DmZrcjhOld;
|
||||||
|
import com.dsic.gj_erp.bean.jhgk.excel.ZrcAndPlb;
|
||||||
|
import com.dsic.gj_erp.listeners.ExcelZrcAndPlb;
|
||||||
|
import com.dsic.gj_erp.service.jcsj.DmCzplpNewService;
|
||||||
|
import com.dsic.gj_erp.service.jcsj.DmCzplpService;
|
||||||
|
import com.dsic.gj_erp.service.jhgk.DmTzjhService;
|
||||||
|
import com.dsic.gj_erp.service.jhgk.DmZrcjhOldService;
|
||||||
|
import com.dsic.gj_erp.service.jhgk.DmZrcjhService;
|
||||||
|
import com.dsic.gj_erp.service.sy.SYService;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
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.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("zrcAndPlb")
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class 中日程批量表合并导入控制器 {
|
||||||
|
|
||||||
|
private final DmZrcjhService zrcjhService;
|
||||||
|
private final DmCzplpNewService czplpNewService;
|
||||||
|
private final DmTzjhService dmTzjhService;
|
||||||
|
private final DmCzplpService dmCzplpService;
|
||||||
|
private final SYService syService;
|
||||||
|
private final DmZrcjhOldService oldService;
|
||||||
|
|
||||||
|
@PostMapping("upload")
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public ResultBean<?> upload(@RequestParam("file") MultipartFile file,String dcCh, HttpServletRequest req) throws IOException {
|
||||||
|
ExcelZrcAndPlb excelZrcAndPlb = new ExcelZrcAndPlb();
|
||||||
|
EasyExcel.read(file.getInputStream(), ZrcAndPlb.class, excelZrcAndPlb).sheet(0).headRowNumber(1).doRead();
|
||||||
|
List<ZrcAndPlb> objList = excelZrcAndPlb.getList();
|
||||||
|
|
||||||
|
List<DmZrcjh> zrcjhList=new ArrayList<>();
|
||||||
|
List<DmCzplpNew> plList=new ArrayList<>();
|
||||||
|
List<DmCzplp> dmCzplpList=new ArrayList<>();
|
||||||
|
|
||||||
|
String bzr = (String) req.getAttribute("yhms");
|
||||||
|
String day=DateUtil.date().toString("yyyy/MM/dd");
|
||||||
|
for(ZrcAndPlb item:objList){
|
||||||
|
String[] fds = item.getMfd().split("/");
|
||||||
|
List<DmCzplpNew> fdList = czplpNewService.list(new QueryWrapper<DmCzplpNew>().eq("dc_pl", item.getDcPl()).eq("dc_ch", dcCh));
|
||||||
|
boolean remove = czplpNewService.remove(new QueryWrapper<DmCzplpNew>().eq("dc_pl", item.getDcPl()).eq("dc_ch", dcCh));
|
||||||
|
|
||||||
|
for (String fd:fds){
|
||||||
|
if (StrUtil.isNotEmpty(fd)){
|
||||||
|
//中日程
|
||||||
|
DmZrcjh dmZrcjh = DmZrcjh.createByExcel(dcCh, fd, item);
|
||||||
|
QueryWrapper<DmZrcjh> queryWrapper = new QueryWrapper<>();
|
||||||
|
queryWrapper.eq("DC_CH", dmZrcjh.getDcCh());
|
||||||
|
queryWrapper.eq("DC_PL", dmZrcjh.getDcPl());
|
||||||
|
queryWrapper.eq("DC_FD", dmZrcjh.getDcFd());
|
||||||
|
DmZrcjh dmZrcjhOne = zrcjhService.getOne(queryWrapper);
|
||||||
|
if (ObjectUtil.isNotEmpty(dmZrcjhOne)) {
|
||||||
|
//存进备份表
|
||||||
|
DmZrcjhOld old= BeanUtil.copyProperties(dmZrcjhOne, DmZrcjhOld.class);
|
||||||
|
oldService.save(old);
|
||||||
|
String dmZrcjhOneBzr = dmZrcjhOne.getBzr();
|
||||||
|
String dmZrcjhOneBzrq = dmZrcjhOne.getBzrq();
|
||||||
|
if (!dmZrcjhOneBzr.contains(bzr)) {
|
||||||
|
dmZrcjh.setBzr(StrUtil.format("{}@{}",dmZrcjhOneBzr , bzr));
|
||||||
|
dmZrcjh.setBzrq(StrUtil.format("{}@{}",dmZrcjhOneBzrq , day));
|
||||||
|
dmZrcjh.setXh(dmZrcjhOne.getXh());
|
||||||
|
}
|
||||||
|
zrcjhService.updateById(dmZrcjh);
|
||||||
|
} else {
|
||||||
|
dmZrcjh.setBzr(bzr);
|
||||||
|
dmZrcjh.setBzrq(day);
|
||||||
|
zrcjhList.add(dmZrcjh);
|
||||||
|
}
|
||||||
|
|
||||||
|
//批量表
|
||||||
|
DmCzplpNew plb = DmCzplpNew.createByExcel(dcCh, fd, item);
|
||||||
|
String id = syService.f_getpjh("DM", "DM", "CZPL");
|
||||||
|
plb.setId(id);
|
||||||
|
if (remove){
|
||||||
|
try {
|
||||||
|
fdList.stream().filter(fst -> plb.getDcPl().equals(fst.getDcPl()))
|
||||||
|
.findFirst().ifPresent(it->updateCzPlp(plb,it));
|
||||||
|
}catch (Exception ignored){}
|
||||||
|
}
|
||||||
|
plList.add(plb);
|
||||||
|
|
||||||
|
//旧表数据,仅当首次导入时写入即可
|
||||||
|
if (!remove){
|
||||||
|
DmCzplp plp = DmCzplp.createByExcel(dcCh, item, (String) req.getAttribute("yhms"));
|
||||||
|
plp.setId(id);
|
||||||
|
dmCzplpList.add(plp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
zrcjhService.saveBatch(zrcjhList,500);
|
||||||
|
|
||||||
|
if (!plList.isEmpty()) {
|
||||||
|
czplpNewService.saveBatch(plList,500);
|
||||||
|
|
||||||
|
//生成图纸计划并保存到数据库中
|
||||||
|
List<DmTzjh>tzjhs=new ArrayList<>();
|
||||||
|
plList.forEach(e->{
|
||||||
|
List<DmTzjh> list1 = dmTzjhService.list(new QueryWrapper<DmTzjh>().eq("dc_ch", e.getDcCh()).eq("dc_pl", e.getDcPl()).eq("dc_fd",e.getDcFd()));
|
||||||
|
if(list1.isEmpty()){
|
||||||
|
DmTzjh tzjh=new DmTzjh();
|
||||||
|
tzjh.setDcPl(e.getDcPl());
|
||||||
|
tzjh.setDcFd(e.getDcFd());
|
||||||
|
tzjh.setDcCh(e.getDcCh());
|
||||||
|
tzjh.setXfqTlt(e.getXfqTlt());
|
||||||
|
tzjh.setXfqLqb(e.getXfqLqb());
|
||||||
|
tzjh.setXfqPtb(e.getXfqPtb());
|
||||||
|
tzjhs.add(tzjh);
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
dmTzjhService.saveBatch(tzjhs);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!dmCzplpList.isEmpty()) {
|
||||||
|
dmCzplpService.saveBatch(dmCzplpList);
|
||||||
|
}
|
||||||
|
|
||||||
|
return new ResultBean<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateCzPlp(DmCzplpNew czplpNew,DmCzplpNew czplp){
|
||||||
|
String rq ="";
|
||||||
|
String rqsm = "";
|
||||||
|
int xfqLqb = DateUtil.compare(DateUtil.parse(czplpNew.getXfqLqb()), DateUtil.parse(czplp.getXfqLqb()), "MM");
|
||||||
|
if (xfqLqb == 0) {
|
||||||
|
xfqLqb = DateUtil.compare(DateUtil.parse(czplpNew.getXfqLqb()), DateUtil.parse(czplp.getXfqLqb()));
|
||||||
|
if (xfqLqb != 0) {
|
||||||
|
rqsm = "变更";
|
||||||
|
rq = czplp.getXfqLqb() + " " + czplpNew.getXfqLqb();
|
||||||
|
}else{
|
||||||
|
rqsm = czplp.getXfqLqb1sm();
|
||||||
|
rq = czplp.getXfqLqb1() ;
|
||||||
|
}
|
||||||
|
} else if (xfqLqb < 0) {
|
||||||
|
rqsm = "托期";
|
||||||
|
rq = czplp.getXfqLqb() + " " + czplpNew.getXfqLqb();
|
||||||
|
} else if (xfqLqb > 0) {
|
||||||
|
rqsm = "延期";
|
||||||
|
rq = czplp.getXfqLqb() + " " + czplpNew.getXfqLqb();
|
||||||
|
}
|
||||||
|
czplpNew.setXfqLqb1sm(rqsm);
|
||||||
|
czplpNew.setXfqLqb1(rq);
|
||||||
|
int xzjsq = DateUtil.compare(DateUtil.parse(czplpNew.getXzjsq()), DateUtil.parse(czplp.getXzjsq()), "MM");
|
||||||
|
if (xzjsq == 0) {
|
||||||
|
xzjsq = DateUtil.compare(DateUtil.parse(czplpNew.getXzjsq()), DateUtil.parse(czplp.getXzjsq()));
|
||||||
|
if (xzjsq != 0) {
|
||||||
|
rqsm = "变更";
|
||||||
|
rq = czplp.getXzjsq() + " " + czplpNew.getXzjsq();
|
||||||
|
}else{
|
||||||
|
rqsm = czplp.getXzjsqsm();
|
||||||
|
rq = czplp.getXzjsq1() ;
|
||||||
|
}
|
||||||
|
} else if (xzjsq < 0) {
|
||||||
|
rqsm = "托期";
|
||||||
|
rq = czplp.getXzjsq() + " " + czplpNew.getXzjsq();
|
||||||
|
} else if (xzjsq > 0) {
|
||||||
|
rqsm = "延期";
|
||||||
|
rq = czplp.getXzjsq() + " " + czplpNew.getXzjsq();
|
||||||
|
}
|
||||||
|
czplpNew.setXzjsq1(rq);
|
||||||
|
czplpNew.setXzjsqsm(rqsm);
|
||||||
|
int xfqTlt = DateUtil.compare(DateUtil.parse(czplpNew.getXfqTlt()), DateUtil.parse(czplp.getXfqTlt()), "MM");
|
||||||
|
if (xfqTlt == 0) {
|
||||||
|
xfqTlt = DateUtil.compare(DateUtil.parse(czplpNew.getXfqTlt()), DateUtil.parse(czplp.getXfqTlt()));
|
||||||
|
if (xfqTlt != 0) {
|
||||||
|
rqsm = "变更";
|
||||||
|
rq = czplp.getXfqTlt() + " " + czplpNew.getXfqTlt();
|
||||||
|
}else{
|
||||||
|
rqsm = czplp.getXfqTltsm();
|
||||||
|
rq = czplp.getXfqTlt1() ;
|
||||||
|
}
|
||||||
|
} else if (xfqTlt < 0) {
|
||||||
|
rqsm = "托期";
|
||||||
|
rq = czplp.getXfqTlt() + " " + czplpNew.getXfqTlt();
|
||||||
|
} else if (xfqTlt > 0) {
|
||||||
|
rqsm = "延期";
|
||||||
|
rq = czplp.getXfqTlt() + " " + czplpNew.getXfqTlt();
|
||||||
|
}
|
||||||
|
czplpNew.setXfqTltsm(rqsm);
|
||||||
|
czplpNew.setXfqTlt1(rq);
|
||||||
|
int dzjsq = DateUtil.compare(DateUtil.parse(czplpNew.getDzjsq()), DateUtil.parse(czplp.getDzjsq()), "MM");
|
||||||
|
if (dzjsq == 0) {
|
||||||
|
dzjsq = DateUtil.compare(DateUtil.parse(czplpNew.getDzjsq()), DateUtil.parse(czplp.getDzjsq()));
|
||||||
|
if (dzjsq != 0) {
|
||||||
|
rqsm = "变更";
|
||||||
|
rq = czplp.getDzjsq() + " " + czplpNew.getDzjsq();
|
||||||
|
}else{
|
||||||
|
rqsm = czplp.getDzjsqsm();
|
||||||
|
rq = czplp.getDzjsq1() ;
|
||||||
|
}
|
||||||
|
} else if (dzjsq < 0) {
|
||||||
|
rqsm = "托期";
|
||||||
|
rq = czplp.getDzjsq() + " " + czplpNew.getDzjsq();
|
||||||
|
} else if (dzjsq > 0) {
|
||||||
|
rqsm = "延期";
|
||||||
|
rq = czplp.getDzjsq() + " " + czplpNew.getDzjsq();
|
||||||
|
}
|
||||||
|
czplpNew.setDzjsqsm(rqsm);
|
||||||
|
czplpNew.setDzjsq1(rq);
|
||||||
|
int gjks = DateUtil.compare(DateUtil.parse(czplpNew.getGjks()), DateUtil.parse(czplp.getGjks()), "MM");
|
||||||
|
if (gjks == 0) {
|
||||||
|
gjks = DateUtil.compare(DateUtil.parse(czplpNew.getGjks()), DateUtil.parse(czplp.getGjks()));
|
||||||
|
if (gjks != 0) {
|
||||||
|
rqsm = "变更";
|
||||||
|
rq = czplp.getGjks() + " " + czplpNew.getGjks();
|
||||||
|
}else{
|
||||||
|
rqsm = czplp.getGjkssm();
|
||||||
|
rq = czplp.getGjks1() ;
|
||||||
|
}
|
||||||
|
} else if (gjks < 0) {
|
||||||
|
rqsm = "托期";
|
||||||
|
rq = czplp.getGjks() + " " + czplpNew.getGjks();
|
||||||
|
} else if (gjks > 0) {
|
||||||
|
rqsm = "延期";
|
||||||
|
rq = czplp.getGjks() + " " + czplpNew.getGjks();
|
||||||
|
}
|
||||||
|
czplpNew.setGjks1(rq);
|
||||||
|
czplpNew.setGjkssm(rqsm);
|
||||||
|
int xfqDhqd = DateUtil.compare(DateUtil.parse(czplpNew.getXfqDhqd()), DateUtil.parse(czplp.getXfqDhqd()), "MM");
|
||||||
|
if (xfqDhqd == 0) {
|
||||||
|
xfqDhqd = DateUtil.compare(DateUtil.parse(czplpNew.getXfqDhqd()), DateUtil.parse(czplp.getXfqDhqd()));
|
||||||
|
if (xfqDhqd != 0) {
|
||||||
|
rqsm = "变更";
|
||||||
|
rq = czplp.getXfqDhqd() + " " + czplpNew.getXfqDhqd();
|
||||||
|
}else{
|
||||||
|
rqsm = czplp.getXfqDhqd1sm();
|
||||||
|
rq = czplp.getXfqDhqd1() ;
|
||||||
|
}
|
||||||
|
} else if (xfqDhqd < 0) {
|
||||||
|
rqsm = "托期";
|
||||||
|
rq = czplp.getXfqDhqd() + " " + czplpNew.getXfqDhqd();
|
||||||
|
} else if (xfqDhqd > 0) {
|
||||||
|
rqsm = "延期";
|
||||||
|
rq = czplp.getXfqDhqd() + " " + czplpNew.getXfqDhqd();
|
||||||
|
}
|
||||||
|
czplpNew.setXfqDhqd1(rq);
|
||||||
|
czplpNew.setXfqDhqd1sm(rqsm);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,31 @@
|
|||||||
|
package com.dsic.gj_erp.listeners;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import com.alibaba.excel.context.AnalysisContext;
|
||||||
|
import com.alibaba.excel.event.AnalysisEventListener;
|
||||||
|
import com.dsic.gj_erp.bean.jhgk.excel.ZrcAndPlb;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
public class ExcelZrcAndPlb extends AnalysisEventListener<ZrcAndPlb> {
|
||||||
|
|
||||||
|
private List<ZrcAndPlb> list;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void invoke(ZrcAndPlb zrcAndPlb, AnalysisContext analysisContext) {
|
||||||
|
zrcAndPlb.setDcPl(StrUtil.padPre(zrcAndPlb.getDcPl(),3,"0"));
|
||||||
|
list.add(zrcAndPlb);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void doAfterAllAnalysed(AnalysisContext analysisContext) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public ExcelZrcAndPlb(){
|
||||||
|
this.list=new ArrayList<>();
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in new issue