|
|
|
|
@@ -3,15 +3,19 @@ package org.nl.wms.st.outbill.service.impl;
|
|
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
|
|
import cn.hutool.core.map.MapUtil;
|
|
|
|
|
import cn.hutool.core.util.IdUtil;
|
|
|
|
|
import cn.hutool.core.util.NumberUtil;
|
|
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
|
|
import com.alibaba.excel.EasyExcel;
|
|
|
|
|
import com.alibaba.excel.ExcelWriter;
|
|
|
|
|
import com.alibaba.excel.write.metadata.WriteSheet;
|
|
|
|
|
import com.alibaba.excel.write.metadata.fill.FillWrapper;
|
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.nl.modules.common.exception.BadRequestException;
|
|
|
|
|
import org.nl.modules.common.utils.SecurityUtils;
|
|
|
|
|
import org.nl.modules.system.domain.Param;
|
|
|
|
|
import org.nl.modules.system.service.impl.ParamServiceImpl;
|
|
|
|
|
import org.nl.modules.system.util.CodeUtil;
|
|
|
|
|
import org.nl.modules.wql.WQL;
|
|
|
|
|
@@ -22,19 +26,23 @@ import org.nl.wms.ext.mes.service.impl.LmsToMesServiceImpl;
|
|
|
|
|
import org.nl.wms.ext.sap.service.impl.LmsToSapServiceImpl;
|
|
|
|
|
import org.nl.wms.pda.mps.eum.RegionTypeEnum;
|
|
|
|
|
import org.nl.wms.sch.manage.TaskStatusEnum;
|
|
|
|
|
import org.nl.wms.sch.service.dto.TaskDto;
|
|
|
|
|
import org.nl.wms.sch.tasks.OutTask;
|
|
|
|
|
import org.nl.wms.st.inbill.service.CheckOutBillService;
|
|
|
|
|
import org.nl.wms.st.inbill.service.RawAssistIStorService;
|
|
|
|
|
import org.nl.wms.st.inbill.service.StorPublicService;
|
|
|
|
|
import org.nl.wms.st.instor.service.HandMoveStorService;
|
|
|
|
|
import org.nl.wms.st.instor.service.impl.HandMoveStorServiceImpl;
|
|
|
|
|
import org.nl.wms.st.instor.task.HandMoveStorAcsTask;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.data.domain.Pageable;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
|
|
import javax.servlet.ServletOutputStream;
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
import java.io.BufferedWriter;
|
|
|
|
|
import java.io.File;
|
|
|
|
|
import java.io.FileWriter;
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@@ -2113,12 +2121,94 @@ public class CheckOutBillServiceImpl implements CheckOutBillService {
|
|
|
|
|
@Override
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
|
public void moneySubmit(JSONObject whereJson) {
|
|
|
|
|
|
|
|
|
|
WQLObject mstTab = WQLObject.getWQLObject("ST_IVT_IOStorInv");
|
|
|
|
|
mstTab.update(whereJson);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
|
public void downloadExcel(HttpServletResponse response, Map whereJson) throws IOException {
|
|
|
|
|
|
|
|
|
|
WQLObject custTab = WQLObject.getWQLObject("MD_CS_CustomerBase"); // 客户基本信息表
|
|
|
|
|
WQLObject mstTab = WQLObject.getWQLObject("ST_IVT_IOStorInv"); // 出入库主表
|
|
|
|
|
|
|
|
|
|
JSONObject jsonMst = mstTab.query("iostorinv_id = '" + MapUtil.getStr(whereJson, "iostorinv_id") + "'").uniqueResult(0);
|
|
|
|
|
String cust_code = jsonMst.getString("cust_code");
|
|
|
|
|
|
|
|
|
|
JSONObject jsonCust = custTab.query("cust_code = '" + cust_code + "'").uniqueResult(0);
|
|
|
|
|
|
|
|
|
|
//1.根据出入库主表中 收货单位 查询客户表中的模板路径
|
|
|
|
|
String code_template = jsonCust.getString("shd_print_no");
|
|
|
|
|
// 2.获取输出流
|
|
|
|
|
ServletOutputStream outputStream = response.getOutputStream();
|
|
|
|
|
// 3.创建模板工作簿
|
|
|
|
|
ExcelWriter workBook = EasyExcel.write(outputStream, null).withTemplate(code_template).build();
|
|
|
|
|
// 4.获取第一个sheet
|
|
|
|
|
// WriteSheet sheet = EasyExcel.writerSheet().build();
|
|
|
|
|
// 5.多组填充
|
|
|
|
|
JSONArray dtlArr = WQL.getWO("ST_OUTIVT02").addParam("flag", "3").addParam("iostorinv_id", MapUtil.getStr(whereJson, "iostorinv_id")).process().getResultJSONArray(0);
|
|
|
|
|
|
|
|
|
|
int shd_dtl_num = jsonCust.getIntValue("shd_dtl_num"); // 送货单明细数
|
|
|
|
|
ArrayList<HashMap<String,Object>> flData = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
if (shd_dtl_num > dtlArr.size()) {
|
|
|
|
|
WriteSheet sheet = EasyExcel.writerSheet().build();
|
|
|
|
|
for (int i = 0; i < dtlArr.size(); i++) {
|
|
|
|
|
JSONObject json = dtlArr.getJSONObject(i);
|
|
|
|
|
HashMap<String, Object> mapFL = new HashMap<>();
|
|
|
|
|
|
|
|
|
|
mapFL.put("index", i + 1);
|
|
|
|
|
mapFL.put("source_bill_code", json.getString("source_bill_code"));
|
|
|
|
|
mapFL.put("material_name", json.getString("material_name"));
|
|
|
|
|
mapFL.put("material_spec", json.getString("material_spec"));
|
|
|
|
|
mapFL.put("qty", json.getString("real_qty"));
|
|
|
|
|
mapFL.put("remark", json.getString("remark"));
|
|
|
|
|
flData.add(mapFL);
|
|
|
|
|
}
|
|
|
|
|
workBook.fill(new FillWrapper("data", flData), sheet);
|
|
|
|
|
workBook.finish();
|
|
|
|
|
} else {
|
|
|
|
|
double div = NumberUtil.div(dtlArr.size(), shd_dtl_num);
|
|
|
|
|
double ceil = Math.ceil(div);
|
|
|
|
|
Integer integer = Integer.valueOf(String.valueOf(NumberUtil.round(ceil, 0)));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (int j = 0; j < integer; j++) {
|
|
|
|
|
HashMap<String, Object> mapFL = new HashMap<>();
|
|
|
|
|
|
|
|
|
|
for (int i = j*shd_dtl_num; i < (j+1)*shd_dtl_num; i++) {
|
|
|
|
|
if (i == dtlArr.size()) {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
JSONObject json = dtlArr.getJSONObject(i);
|
|
|
|
|
mapFL.put("index", i + 1);
|
|
|
|
|
mapFL.put("source_bill_code", json.getString("source_bill_code"));
|
|
|
|
|
mapFL.put("material_name", json.getString("material_name"));
|
|
|
|
|
mapFL.put("material_spec", json.getString("material_spec"));
|
|
|
|
|
mapFL.put("qty", json.getString("real_qty"));
|
|
|
|
|
mapFL.put("remark", json.getString("remark"));
|
|
|
|
|
flData.add(mapFL);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
WriteSheet sheet = EasyExcel.writerSheet(j+1).build();
|
|
|
|
|
workBook.fill(new FillWrapper("data", flData), sheet);
|
|
|
|
|
workBook.finish();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// workBook.fill(oneMap, sheet);
|
|
|
|
|
// workBook.fill(ylData, sheet);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void main(String[] args) {
|
|
|
|
|
double ceil = Math.ceil(2.2);
|
|
|
|
|
Integer integer = Integer.valueOf(String.valueOf(NumberUtil.round(ceil, 0)));
|
|
|
|
|
System.out.println(integer);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 更新主表状态
|
|
|
|
|
*
|
|
|
|
|
|