|
|
@ -2,6 +2,8 @@ package com.dsic.gj_erp.service.jhgk.impl;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
|
|
|
|
|
import cn.hutool.core.util.ObjUtil;
|
|
|
|
|
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
|
import cn.hutool.poi.excel.ExcelReader;
|
|
|
|
import cn.hutool.poi.excel.ExcelReader;
|
|
|
|
import cn.hutool.poi.excel.ExcelUtil;
|
|
|
|
import cn.hutool.poi.excel.ExcelUtil;
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
@ -12,18 +14,23 @@ import com.dsic.gj_erp.mapper.jhgk.DmDhqdpMapper;
|
|
|
|
import com.dsic.gj_erp.service.jhgk.DmDhqdpService;
|
|
|
|
import com.dsic.gj_erp.service.jhgk.DmDhqdpService;
|
|
|
|
import com.google.common.collect.Maps;
|
|
|
|
import com.google.common.collect.Maps;
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
|
|
|
import org.apache.poi.ss.usermodel.*;
|
|
|
|
|
|
|
|
import org.apache.poi.ss.util.CellRangeAddress;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.io.IOException;
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.Map;
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* <p>
|
|
|
|
* <p>
|
|
|
|
* 服务实现类
|
|
|
|
* 服务实现类
|
|
|
|
* </p>
|
|
|
|
* </p>
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @author xn
|
|
|
|
* @author xn
|
|
|
@ -36,26 +43,124 @@ public class DmDhqdpServiceImpl extends ServiceImpl<DmDhqdpMapper, DmDhqdp> impl
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public List<DmDhqdp> getList(JSONObject json) {
|
|
|
|
public List<DmDhqdp> getList(JSONObject json) {
|
|
|
|
QueryWrapper<DmDhqdp> queryWrapper=new QueryWrapper<>();
|
|
|
|
QueryWrapper<DmDhqdp> queryWrapper = new QueryWrapper<>();
|
|
|
|
if(StringUtils.isNotEmpty(json.getString("dcCh"))){
|
|
|
|
if (StringUtils.isNotEmpty(json.getString("dcCh"))) {
|
|
|
|
queryWrapper.eq("DC_CH",json.getString("dcCh"));
|
|
|
|
queryWrapper.eq("DC_CH", json.getString("dcCh"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(StringUtils.isNotEmpty(json.getString("Zt"))){
|
|
|
|
if (StringUtils.isNotEmpty(json.getString("Zt"))) {
|
|
|
|
queryWrapper.eq("ZT",json.getString("Zt"));
|
|
|
|
queryWrapper.eq("ZT", json.getString("Zt"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
List<DmDhqdp> dmDhqdps=dmDhqdpMapper.selectList(queryWrapper);
|
|
|
|
queryWrapper.orderByAsc("wpxh");
|
|
|
|
return dmDhqdps;
|
|
|
|
return dmDhqdpMapper.selectList(queryWrapper);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
|
|
|
|
@Transactional
|
|
|
|
public List<DmDhqdp> save(List<DmDhqdp> dmDhqdps) {
|
|
|
|
public List<DmDhqdp> save(List<DmDhqdp> dmDhqdps) {
|
|
|
|
saveBatch(dmDhqdps);
|
|
|
|
saveBatch(dmDhqdps);
|
|
|
|
return dmDhqdps;
|
|
|
|
return dmDhqdps;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
|
|
|
|
@Transactional
|
|
|
|
public List<DmDhqdp> upload(MultipartFile file, HttpServletRequest req) throws IOException {
|
|
|
|
public List<DmDhqdp> upload(MultipartFile file, HttpServletRequest req) throws IOException {
|
|
|
|
ExcelReader reader= ExcelUtil.getReader(file.getInputStream());
|
|
|
|
Workbook workbook = WorkbookFactory.create(file.getInputStream());
|
|
|
|
|
|
|
|
Sheet sheet = workbook.getSheetAt(0);
|
|
|
|
|
|
|
|
List<CellRangeAddress> mergedRegions = sheet.getMergedRegions();
|
|
|
|
|
|
|
|
if (mergedRegions.size() > 74) {
|
|
|
|
|
|
|
|
String ddh = null;
|
|
|
|
|
|
|
|
String dcch = null;
|
|
|
|
|
|
|
|
String qc = null;
|
|
|
|
|
|
|
|
CellRangeAddress ddhAddr = mergedRegions.get(68);
|
|
|
|
|
|
|
|
if (ddhAddr != null) {
|
|
|
|
|
|
|
|
ddh = this.getMergedData(sheet, ddhAddr);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
CellRangeAddress chAddr = mergedRegions.get(74);
|
|
|
|
|
|
|
|
if (chAddr != null) {
|
|
|
|
|
|
|
|
dcch = this.getMergedData(sheet, chAddr);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CellRangeAddress qcAddr = mergedRegions.get(75);
|
|
|
|
|
|
|
|
if (qcAddr != null) {
|
|
|
|
|
|
|
|
qc = this.getMergedData(sheet, qcAddr);
|
|
|
|
|
|
|
|
qc=StrUtil.subBetween(qc, "(", ")");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (StrUtil.isAllNotEmpty(dcch, ddh)) {
|
|
|
|
|
|
|
|
List<DmDhqdp> list = new ArrayList<>();
|
|
|
|
|
|
|
|
List<DmDhqdp> dmDhqdps = this.readExcel(file, dcch, ddh, qc, 1, req);
|
|
|
|
|
|
|
|
List<DmDhqdp> dmDhqdps1 = this.readExcel(file, dcch, ddh, qc, 2, req);
|
|
|
|
|
|
|
|
if (ObjUtil.isNotEmpty(dmDhqdps)) {
|
|
|
|
|
|
|
|
list.addAll(dmDhqdps);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ObjUtil.isNotEmpty(dmDhqdps1)) {
|
|
|
|
|
|
|
|
list.addAll(dmDhqdps1);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
this.saveBatch(list.stream().filter(item->StrUtil.isNotEmpty(item.getDcCh())).collect(Collectors.toList()));
|
|
|
|
|
|
|
|
return list;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private String getMergedData(Sheet sheet, CellRangeAddress addr) {
|
|
|
|
|
|
|
|
int firstRow = addr.getFirstRow();
|
|
|
|
|
|
|
|
int firstCol = addr.getFirstColumn();
|
|
|
|
|
|
|
|
Row row = sheet.getRow(firstRow);
|
|
|
|
|
|
|
|
Cell cell = row.getCell(firstCol);
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
return cell.getStringCellValue();
|
|
|
|
|
|
|
|
} catch (Exception ignored) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Transactional
|
|
|
|
|
|
|
|
public List<DmDhqdp> readExcel(MultipartFile file, String dcch, String ddh, String qc, int sheet, HttpServletRequest req) throws IOException {
|
|
|
|
|
|
|
|
ExcelReader reader = ExcelUtil.getReader(file.getInputStream());
|
|
|
|
|
|
|
|
Map<String, String> alias = Maps.newLinkedHashMap();
|
|
|
|
|
|
|
|
alias.put("序号\nNo.", "xh");
|
|
|
|
|
|
|
|
alias.put("材质\nMATERIAL", "wpxh");
|
|
|
|
|
|
|
|
alias.put("厚度\r\nTHICK.\nmm", "thickness");
|
|
|
|
|
|
|
|
alias.put("宽度\r\nWIDTH\nmm", "width");
|
|
|
|
|
|
|
|
alias.put("长度\r\nLENGTH\nmm", "length");
|
|
|
|
|
|
|
|
alias.put("重量\r\n吨/张\nWEIGHT\nTON/PIECE\r", "weight");
|
|
|
|
|
|
|
|
alias.put("设计数量\n张\nDESIGN\nPIECE", "sjsl");
|
|
|
|
|
|
|
|
alias.put("裕量\n张\nMARGIN\nPIECE", "yl");
|
|
|
|
|
|
|
|
alias.put("总数量\n张\nTOTAL\nPIECE", "zsl");
|
|
|
|
|
|
|
|
alias.put("总重量\n吨\nTOTAL\nTON ", "zzl");
|
|
|
|
|
|
|
|
alias.put("利库数量\n张\nSTORE\nPIECE", "lksl");
|
|
|
|
|
|
|
|
alias.put("利库重量\n吨\nSTORE\nTON", "lkzl");
|
|
|
|
|
|
|
|
alias.put("实订数量\n张\nORDER\nPIECE", "sdzs");
|
|
|
|
|
|
|
|
alias.put("实订重量\n吨\nORDER\nTON", "sdzl");
|
|
|
|
|
|
|
|
alias.put("备注\nNOTE", "bz");
|
|
|
|
|
|
|
|
alias.put("批量组立数量", "plzlsl");
|
|
|
|
|
|
|
|
alias.put("跨道组立数量", "kdzlsl");
|
|
|
|
|
|
|
|
alias.put("平铁用板数量", "ptybsl");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
reader.setHeaderAlias(alias);
|
|
|
|
|
|
|
|
reader.setSheet(sheet);
|
|
|
|
|
|
|
|
List<DmDhqdp> dmDhqdps = reader.read(1, 2, DmDhqdp.class);
|
|
|
|
|
|
|
|
String day = DateUtil.format(DateUtil.date(), "yyyy/MM/dd");
|
|
|
|
|
|
|
|
String user = (String) req.getAttribute("yhms");
|
|
|
|
|
|
|
|
this.remove(new QueryWrapper<DmDhqdp>().eq("Dc_ch", dcch)
|
|
|
|
|
|
|
|
.eq("qdh", ddh)
|
|
|
|
|
|
|
|
.eq("qc", qc));
|
|
|
|
|
|
|
|
dmDhqdps.stream().filter(item->StrUtil.isNotEmpty(item.getXh())&&!item.getXh().contains("合计"))
|
|
|
|
|
|
|
|
.forEach(l -> {
|
|
|
|
|
|
|
|
l.setDcCh(dcch);
|
|
|
|
|
|
|
|
l.setQdh(ddh);
|
|
|
|
|
|
|
|
l.setQc(qc);
|
|
|
|
|
|
|
|
l.setDrr(user);
|
|
|
|
|
|
|
|
l.setDrrq(day);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
return dmDhqdps;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Transactional
|
|
|
|
|
|
|
|
public List<DmDhqdp> upload1(MultipartFile file, HttpServletRequest req) throws IOException {
|
|
|
|
|
|
|
|
ExcelReader reader = ExcelUtil.getReader(file.getInputStream());
|
|
|
|
Map<String, String> alias = Maps.newLinkedHashMap();
|
|
|
|
Map<String, String> alias = Maps.newLinkedHashMap();
|
|
|
|
alias.put("船号", "dcCh");
|
|
|
|
alias.put("船号", "dcCh");
|
|
|
|
alias.put("订货清单号", "qdh");
|
|
|
|
alias.put("订货清单号", "qdh");
|
|
|
@ -111,15 +216,15 @@ public class DmDhqdpServiceImpl extends ServiceImpl<DmDhqdpMapper, DmDhqdp> impl
|
|
|
|
"TON", "sdzl");
|
|
|
|
"TON", "sdzl");
|
|
|
|
alias.put("备注\n" +
|
|
|
|
alias.put("备注\n" +
|
|
|
|
"NOTE", "bz");
|
|
|
|
"NOTE", "bz");
|
|
|
|
// alias.put("状态", "zt");
|
|
|
|
// alias.put("状态", "zt");
|
|
|
|
reader.setHeaderAlias(alias);
|
|
|
|
reader.setHeaderAlias(alias);
|
|
|
|
List<DmDhqdp> dmDhqdps= reader.readAll(DmDhqdp.class);
|
|
|
|
List<DmDhqdp> dmDhqdps = reader.readAll(DmDhqdp.class);
|
|
|
|
String day = DateUtil.format(DateUtil.date(), "yyyy/MM/dd");
|
|
|
|
String day = DateUtil.format(DateUtil.date(), "yyyy/MM/dd");
|
|
|
|
String user = (String) req.getAttribute("yhms");
|
|
|
|
String user = (String) req.getAttribute("yhms");
|
|
|
|
dmDhqdps.forEach(l->{
|
|
|
|
dmDhqdps.forEach(l -> {
|
|
|
|
this.remove(new QueryWrapper<DmDhqdp>().eq("Dc_ch",l.getDcCh())
|
|
|
|
this.remove(new QueryWrapper<DmDhqdp>().eq("Dc_ch", l.getDcCh())
|
|
|
|
.eq("qdh",l.getQdh())
|
|
|
|
.eq("qdh", l.getQdh())
|
|
|
|
.eq("qc",l.getQc()));
|
|
|
|
.eq("qc", l.getQc()));
|
|
|
|
l.setDrr(user);
|
|
|
|
l.setDrr(user);
|
|
|
|
l.setDrrq(day);
|
|
|
|
l.setDrrq(day);
|
|
|
|
});
|
|
|
|
});
|
|
|
@ -127,6 +232,7 @@ public class DmDhqdpServiceImpl extends ServiceImpl<DmDhqdpMapper, DmDhqdp> impl
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
|
|
|
|
@Transactional
|
|
|
|
public void sh(List<DmDhqdp> dmDhqdps) {
|
|
|
|
public void sh(List<DmDhqdp> dmDhqdps) {
|
|
|
|
dmDhqdps.forEach(dmZrcjh -> {
|
|
|
|
dmDhqdps.forEach(dmZrcjh -> {
|
|
|
|
dmZrcjh.setZt("2");
|
|
|
|
dmZrcjh.setZt("2");
|
|
|
@ -135,10 +241,11 @@ public class DmDhqdpServiceImpl extends ServiceImpl<DmDhqdpMapper, DmDhqdp> impl
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
|
|
|
|
@Transactional
|
|
|
|
public void tj(List<DmDhqdp> dmXbjhs) {
|
|
|
|
public void tj(List<DmDhqdp> dmXbjhs) {
|
|
|
|
dmXbjhs.forEach(dmZrcjh -> {
|
|
|
|
dmXbjhs.forEach(dmZrcjh -> {
|
|
|
|
String zt=dmZrcjh.getZt();
|
|
|
|
String zt = dmZrcjh.getZt();
|
|
|
|
String setZt=zt.equals("1")?"0":"1";
|
|
|
|
String setZt = zt.equals("1") ? "0" : "1";
|
|
|
|
dmZrcjh.setZt(setZt);
|
|
|
|
dmZrcjh.setZt(setZt);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
updateBatchById(dmXbjhs);
|
|
|
|
updateBatchById(dmXbjhs);
|
|
|
|