|
|
@ -1,32 +1,59 @@ |
|
|
|
package org.nl.wms.st.outbill.service.impl; |
|
|
|
|
|
|
|
import cn.hutool.core.collection.CollectionUtil; |
|
|
|
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 cn.hutool.poi.excel.ExcelReader; |
|
|
|
import cn.hutool.poi.excel.ExcelUtil; |
|
|
|
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.JSON; |
|
|
|
import com.alibaba.fastjson.JSONArray; |
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.nl.b_lms.pdm.subpackagerelation.dao.PdmBiSubpackagerelation; |
|
|
|
import org.nl.b_lms.pdm.subpackagerelation.dao.PdmBiSubpackagerelationrecord; |
|
|
|
import org.nl.b_lms.pdm.subpackagerelation.service.IPdmBiSubpackagerelationrecordService; |
|
|
|
import org.nl.b_lms.pdm.subpackagerelation.service.IpdmBiSubpackagerelationService; |
|
|
|
import org.nl.b_lms.sch.task.dao.SchBaseTask; |
|
|
|
import org.nl.b_lms.sch.task.service.IschBaseTaskService; |
|
|
|
import org.nl.b_lms.sch.tasks.TwoOutTask; |
|
|
|
import org.nl.b_lms.storage_manage.ios.enums.IOSEnum; |
|
|
|
import org.nl.b_lms.storage_manage.ios.service.iostorInv.IStIvtIostorinvService; |
|
|
|
import org.nl.b_lms.storage_manage.ios.service.iostorInv.IStIvtIostorinvdisService; |
|
|
|
import org.nl.b_lms.storage_manage.ios.service.iostorInv.IStIvtIostorinvdtlService; |
|
|
|
import org.nl.b_lms.storage_manage.ios.service.iostorInv.dao.StIvtIostorinv; |
|
|
|
import org.nl.b_lms.storage_manage.ios.service.iostorInv.dao.StIvtIostorinvdis; |
|
|
|
import org.nl.b_lms.storage_manage.ios.service.iostorInv.dao.StIvtIostorinvdtl; |
|
|
|
import org.nl.b_lms.storage_manage.ios.service.iostorInv.dao.mapper.StIvtIostorinvMapper; |
|
|
|
import org.nl.b_lms.storage_manage.md.dao.MdCsCustomerBase; |
|
|
|
import org.nl.b_lms.storage_manage.md.dao.MdCsTransportationBase; |
|
|
|
import org.nl.b_lms.storage_manage.md.service.IMdCsCustomerBaseService; |
|
|
|
import org.nl.b_lms.storage_manage.md.service.IMdCsTransportationBaseService; |
|
|
|
import org.nl.b_lms.storage_manage.st.dao.StIvtBsrealstorattr; |
|
|
|
import org.nl.b_lms.storage_manage.st.dao.StIvtSectattr; |
|
|
|
import org.nl.b_lms.storage_manage.st.dao.mapper.StIvtStructivtMapper; |
|
|
|
import org.nl.b_lms.storage_manage.st.service.StIvtBsrealstorattrService; |
|
|
|
import org.nl.b_lms.storage_manage.st.service.StIvtSectattrService; |
|
|
|
import org.nl.common.domain.query.PageQuery; |
|
|
|
import org.nl.common.utils.CodeUtil; |
|
|
|
import org.nl.common.utils.SecurityUtils; |
|
|
|
import org.nl.common.utils.StringDealUtils; |
|
|
|
import org.nl.modules.common.exception.BadRequestException; |
|
|
|
import org.nl.modules.common.utils.FileUtil; |
|
|
|
import org.nl.system.service.param.ISysParamService; |
|
|
|
import org.nl.wms.sch.manage.TaskStatusEnum; |
|
|
|
import org.nl.wms.st.inbill.service.StorPublicService; |
|
|
|
import org.nl.wms.st.outbill.service.CheckOutBillService; |
|
|
|
import org.nl.wms.st.outbill.service.dto.*; |
|
|
|
import org.nl.wms.st.outbill.service.vo.OutBillDtlVo; |
|
|
@ -39,12 +66,15 @@ import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
import org.springframework.web.multipart.MultipartFile; |
|
|
|
|
|
|
|
import javax.servlet.ServletOutputStream; |
|
|
|
import javax.servlet.http.HttpServletRequest; |
|
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
|
import java.io.IOException; |
|
|
|
import java.io.InputStream; |
|
|
|
import java.math.BigDecimal; |
|
|
|
import java.util.*; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
import java.util.stream.Stream; |
|
|
|
|
|
|
|
/** |
|
|
|
* @Author: lyd |
|
|
@ -67,6 +97,20 @@ public class CheckOutBillServiceImpl implements CheckOutBillService { |
|
|
|
private StIvtStructivtMapper stIvtStructivtMapper; |
|
|
|
@Autowired |
|
|
|
private IMdCsTransportationBaseService mdCsTransportationBaseService; |
|
|
|
@Autowired |
|
|
|
private IMdCsCustomerBaseService csCustomerBaseService; |
|
|
|
@Autowired |
|
|
|
private ISysParamService sysParamService; |
|
|
|
@Autowired |
|
|
|
private IpdmBiSubpackagerelationService subpackagerelationService; |
|
|
|
@Autowired |
|
|
|
private IPdmBiSubpackagerelationrecordService subpackagerelationrecordService; |
|
|
|
@Autowired |
|
|
|
private StorPublicService storPublicService; |
|
|
|
@Autowired |
|
|
|
private StIvtSectattrService stIvtSectattrService; |
|
|
|
@Autowired |
|
|
|
private IschBaseTaskService ischBaseTaskService; |
|
|
|
|
|
|
|
@Override |
|
|
|
public List<OutBillDtlVo> getOutBillDtl(OutBillDtlQueryParam param) { |
|
|
@ -151,12 +195,12 @@ public class CheckOutBillServiceImpl implements CheckOutBillService { |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public JSONArray getOutBillTask(Map whereJson) { |
|
|
|
public List<OutBillTaskVo> getOutBillTask(Map whereJson) { |
|
|
|
HashMap<String, String> map = new HashMap<>(whereJson); |
|
|
|
if ("true".equals(map.get("checked"))) { |
|
|
|
map.put("task_status", "99"); |
|
|
|
} |
|
|
|
JSONArray jo = new JSONArray(); |
|
|
|
List<OutBillTaskVo> jo = new ArrayList<>(); |
|
|
|
if (map.containsKey("iostorinvdtl_id")) { |
|
|
|
jo = stIvtStructivtMapper.getOutBillTask(map); |
|
|
|
} |
|
|
@ -302,7 +346,7 @@ public class CheckOutBillServiceImpl implements CheckOutBillService { |
|
|
|
String estimated_freight = list.get(5).toString(); |
|
|
|
|
|
|
|
// 更新主表
|
|
|
|
jsonMst.setTrans_code( ObjectUtil.isNotEmpty(trans) ? trans.getCust_code() : "" ); |
|
|
|
jsonMst.setTrans_code(ObjectUtil.isNotEmpty(trans) ? trans.getCust_code() : ""); |
|
|
|
jsonMst.setOrder_number(order_number); |
|
|
|
jsonMst.setCar_type(car_type); |
|
|
|
jsonMst.setOther_freight(new BigDecimal(other_freight)); |
|
|
@ -311,8 +355,848 @@ public class CheckOutBillServiceImpl implements CheckOutBillService { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void moneySubmit(JSONObject whereJson) { |
|
|
|
stIvtIostorinvService.updateById(whereJson.toJavaObject(StIvtIostorinv.class)); |
|
|
|
// todo: 回传SAP
|
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public JSONObject getDisNum(Map whereJson) { |
|
|
|
List<AllBoxInfoDto> dtlArr = iostorinvdisService.getBoxInfoByInvId(MapUtil.getStr(whereJson, "iostorinv_id")); |
|
|
|
JSONObject json = new JSONObject(); |
|
|
|
json.put("num", dtlArr.size()); |
|
|
|
return json; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void downloadExcel(HttpServletResponse response, Map whereJson) throws IOException { |
|
|
|
StIvtIostorinv jsonMst = stIvtIostorinvService.getById(MapUtil.getStr(whereJson, "iostorinv_id")); |
|
|
|
String cust_code = jsonMst.getCust_code(); |
|
|
|
MdCsCustomerBase jsonCust = csCustomerBaseService.getByCode(cust_code); |
|
|
|
String bill_type = jsonMst.getBill_type(); |
|
|
|
|
|
|
|
int j = Integer.parseInt((String) whereJson.get("j")); |
|
|
|
|
|
|
|
HashMap<String, Object> oneMap = new HashMap<>(); |
|
|
|
// 2.获取输出流
|
|
|
|
ServletOutputStream outputStream = response.getOutputStream(); |
|
|
|
String code_template = ""; |
|
|
|
int shd_dtl_num = 0; // 送货单明细数
|
|
|
|
|
|
|
|
// 调拨发货单
|
|
|
|
if (StrUtil.equals(bill_type, OutBillTypeEnum.TRANSFER_OUT.getCode()) || StrUtil.equals(bill_type, OutBillTypeEnum.MANUAL_OUT.getCode())) { |
|
|
|
shd_dtl_num = 44; |
|
|
|
//1.获取系统参数模板地址
|
|
|
|
code_template = sysParamService.findByCode("allot_order").getValue(); |
|
|
|
|
|
|
|
// 5.单组填充
|
|
|
|
StIvtIostorinvdtl jsonDtl = iostorinvdtlService.getOne(new LambdaQueryWrapper<StIvtIostorinvdtl>() |
|
|
|
.eq(StIvtIostorinvdtl::getIostorinv_id, jsonMst.getIostorinv_id()), false); |
|
|
|
if (ObjectUtil.isNotEmpty(jsonDtl) && StrUtil.equals(bill_type, OutBillTypeEnum.TRANSFER_OUT.getCode())) { |
|
|
|
// 调拨单号
|
|
|
|
oneMap.put("vbeln", jsonMst.getBill_code()); |
|
|
|
// 调出仓库
|
|
|
|
oneMap.put("out_stor", jsonMst.getStor_code()); |
|
|
|
// 调入仓库
|
|
|
|
StIvtBsrealstorattr jsonStor = bsrealstorattrService.getById(jsonMst.getOut_stor_id()); |
|
|
|
oneMap.put("in_stor", jsonStor.getStor_code()); |
|
|
|
|
|
|
|
} |
|
|
|
String pageNow = String.valueOf(j + 1); // 页码
|
|
|
|
oneMap.put("page", pageNow + "/" + MapUtil.getStr(whereJson, "pageNum")); |
|
|
|
oneMap.put("consignee", jsonMst.getConsignee()); // 收货单位
|
|
|
|
oneMap.put("receiver", jsonMst.getReceiver()); // 收货人
|
|
|
|
String receiptaddress = jsonMst.getReceiptaddress(); |
|
|
|
oneMap.put("receiptaddress", receiptaddress); // 收货地址
|
|
|
|
oneMap.put("receiptphone", jsonMst.getReceiptphone()); // 收货人联系电话
|
|
|
|
// 物流公司
|
|
|
|
MdCsTransportationBase jsonTran = mdCsTransportationBaseService.getByCode(jsonMst.getTrans_code()); |
|
|
|
if (ObjectUtil.isNotEmpty(jsonTran)) { |
|
|
|
oneMap.put("logisticscompany", jsonTran.getCust_name()); |
|
|
|
} |
|
|
|
oneMap.put("drivername", jsonMst.getDrivername()); // 司机
|
|
|
|
oneMap.put("carno", jsonMst.getCarno()); // 车牌号
|
|
|
|
oneMap.put("driverphone", jsonMst.getDriverphone()); // 司机联系电话
|
|
|
|
// 总箱数
|
|
|
|
List<AllBoxInfoDto> jsonAllBox = iostorinvdisService.getAllBoxInfoByInvId(MapUtil.getStr(whereJson, "iostorinv_id")); |
|
|
|
oneMap.put("all_box", jsonAllBox.size()); |
|
|
|
// 总毛重
|
|
|
|
double all_box_qty = 0; |
|
|
|
for (AllBoxInfoDto allBox : jsonAllBox) { |
|
|
|
all_box_qty = NumberUtil.add(all_box_qty, Double.parseDouble(allBox.getQty())); |
|
|
|
} |
|
|
|
oneMap.put("all_box_qty", NumberUtil.round(all_box_qty, 2).toString()); |
|
|
|
oneMap.put("deliveryaddress", jsonMst.getDeliveryaddress()); // 送货方地址
|
|
|
|
oneMap.put("deliveryname", jsonMst.getDeliveryname()); // 送货方联系人
|
|
|
|
oneMap.put("deliveryphone", jsonMst.getDeliveryphone()); // 送货方联系电话
|
|
|
|
oneMap.put("contractno", jsonMst.getContractno()); // 合同号
|
|
|
|
} else { |
|
|
|
|
|
|
|
if (ObjectUtil.isEmpty(jsonCust)) { |
|
|
|
shd_dtl_num = 44; |
|
|
|
//1.根据出入库主表中 收货单位 查询客户表中的模板路径
|
|
|
|
code_template = sysParamService.findByCode("PRINT_TEMPLE").getValue(); |
|
|
|
} else { |
|
|
|
shd_dtl_num = jsonCust.getShd_dtl_num(); |
|
|
|
|
|
|
|
if (ObjectUtil.isEmpty(shd_dtl_num)) { |
|
|
|
throw new BadRequestException("客户编码:" + cust_code + ",送货单明细数未配置,请先去配置!"); |
|
|
|
} |
|
|
|
//1.根据出入库主表中 收货单位 查询客户表中的模板路径
|
|
|
|
code_template = jsonCust.getShd_print_no(); |
|
|
|
|
|
|
|
if (StrUtil.isEmpty(code_template)) { |
|
|
|
throw new BadRequestException("客户编码:" + cust_code + ",送货单打印模板号未配置,请先去配置!"); |
|
|
|
} |
|
|
|
} |
|
|
|
StIvtIostorinvdtl jsonDtl = iostorinvdtlService.getOne(new LambdaQueryWrapper<StIvtIostorinvdtl>() |
|
|
|
.eq(StIvtIostorinvdtl::getIostorinv_id, jsonMst.getIostorinv_id()), false); |
|
|
|
if (ObjectUtil.isNotEmpty(jsonDtl)) { |
|
|
|
// 送货单号
|
|
|
|
oneMap.put("vbeln", jsonDtl.getVbeln()); |
|
|
|
// 订单号
|
|
|
|
String source_bill_code = jsonDtl.getSource_bill_code(); |
|
|
|
if (ObjectUtil.isNotEmpty(source_bill_code)) { |
|
|
|
try { |
|
|
|
oneMap.put("order_no", source_bill_code.substring(0, source_bill_code.indexOf("-"))); |
|
|
|
} catch (Exception e) { |
|
|
|
oneMap.put("order_no", source_bill_code); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
String pageNow = String.valueOf(j + 1); // 页码
|
|
|
|
oneMap.put("page", pageNow + "/" + MapUtil.getStr(whereJson, "pageNum")); |
|
|
|
oneMap.put("consignee", jsonMst.getConsignee()); // 收货单位
|
|
|
|
oneMap.put("receiver", jsonMst.getReceiver()); // 收货人
|
|
|
|
String receiptaddress = jsonMst.getReceiptaddress(); |
|
|
|
/* StrBuilder strBuilder = new StrBuilder(receiptaddress); |
|
|
|
|
|
|
|
if (receiptaddress.length() > 10) { |
|
|
|
strBuilder.insert(11,"\n"); |
|
|
|
}*/ |
|
|
|
oneMap.put("receiptaddress", receiptaddress); // 收货地址
|
|
|
|
oneMap.put("receiptphone", jsonMst.getReceiptphone()); // 收货人联系电话
|
|
|
|
// 物流公司
|
|
|
|
MdCsTransportationBase jsonTran = mdCsTransportationBaseService.getByCode(jsonMst.getTrans_code()); |
|
|
|
if (ObjectUtil.isNotEmpty(jsonTran)) { |
|
|
|
oneMap.put("logisticscompany", jsonTran.getCust_name()); |
|
|
|
} |
|
|
|
oneMap.put("drivername", jsonMst.getDrivername()); // 司机
|
|
|
|
oneMap.put("carno", jsonMst.getCarno()); // 车牌号
|
|
|
|
oneMap.put("driverphone", jsonMst.getDriverphone()); // 司机联系电话
|
|
|
|
// 总箱数
|
|
|
|
List<AllBoxInfoDto> jsonAllBox = iostorinvdisService.getAllBoxInfoByInvId(MapUtil.getStr(whereJson, "iostorinv_id")); |
|
|
|
oneMap.put("all_box", jsonAllBox.size()); |
|
|
|
// 总毛重
|
|
|
|
double all_box_qty = 0; |
|
|
|
for (AllBoxInfoDto allBox : jsonAllBox) { |
|
|
|
all_box_qty = NumberUtil.add(all_box_qty, Double.parseDouble(allBox.getQty())); |
|
|
|
} |
|
|
|
oneMap.put("all_box_qty", NumberUtil.round(all_box_qty, 2).toString()); |
|
|
|
oneMap.put("deliveryaddress", jsonMst.getDeliveryaddress()); // 送货方地址
|
|
|
|
oneMap.put("deliveryname", jsonMst.getDeliveryname()); // 送货方联系人
|
|
|
|
oneMap.put("deliveryphone", jsonMst.getDeliveryphone()); // 送货方联系电话
|
|
|
|
oneMap.put("contractno", jsonMst.getContractno()); // 合同号
|
|
|
|
} |
|
|
|
|
|
|
|
// 6.多组填充
|
|
|
|
List<AllBoxInfoDto> dtlArr = iostorinvdisService.getBoxInfoByInvId(MapUtil.getStr(whereJson, "iostorinv_id")); |
|
|
|
|
|
|
|
if (shd_dtl_num > dtlArr.size()) { |
|
|
|
double all_qty = 0; |
|
|
|
String order_no = ""; |
|
|
|
ArrayList<HashMap<String, Object>> flData = new ArrayList<>(); |
|
|
|
WriteSheet sheet = EasyExcel.writerSheet().build(); |
|
|
|
double all_real = 0; // 总毛总
|
|
|
|
for (int i = 0; i < dtlArr.size(); i++) { |
|
|
|
AllBoxInfoDto json = dtlArr.get(i); |
|
|
|
PdmBiSubpackagerelation jsonSub = subpackagerelationService.getOne(new LambdaQueryWrapper<PdmBiSubpackagerelation>() |
|
|
|
.eq(PdmBiSubpackagerelation::getPackage_box_sn, json.getBox_no()), false); |
|
|
|
if (ObjectUtil.isEmpty(jsonSub)) { |
|
|
|
throw new BadRequestException("没有查询到子卷包装"); |
|
|
|
} |
|
|
|
order_no = jsonSub.getSale_order_name(); |
|
|
|
|
|
|
|
// 规格: 厚度*幅宽
|
|
|
|
String material_spec = jsonSub.getThickness_request() + "*" + jsonSub.getWidth_standard(); |
|
|
|
// 箱号
|
|
|
|
String box_no = json.getBox_no(); |
|
|
|
String sub_box_no = ""; |
|
|
|
if (ObjectUtil.isNotEmpty(box_no)) { |
|
|
|
try { |
|
|
|
sub_box_no = box_no.substring(box_no.lastIndexOf("@") + 1, box_no.length()); |
|
|
|
} catch (Exception e) { |
|
|
|
sub_box_no = box_no; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
HashMap<String, Object> mapFL = new HashMap<>(); |
|
|
|
// 明细
|
|
|
|
// String date_of_production = jsonSub.getString("date_of_production").replaceAll("[[\\s-:punct:]]", "");
|
|
|
|
// mapFL.put("date_of_production", date_of_production); // 批号 : 子卷包装生产日期
|
|
|
|
mapFL.put("material_name", json.getMaterial_name()); |
|
|
|
mapFL.put("material_spec", material_spec); |
|
|
|
// mapFL.put("qty_unit_name", "KG");
|
|
|
|
mapFL.put("box_no", sub_box_no); |
|
|
|
mapFL.put("qty", NumberUtil.round(json.getQty(), 1).doubleValue()); // 净重
|
|
|
|
if (ObjectUtil.isNotEmpty(jsonSub.getReal_weight())) { |
|
|
|
mapFL.put("real_weight", NumberUtil.round(jsonSub.getBox_weight(), 1).doubleValue()); // 毛重
|
|
|
|
all_real = NumberUtil.add(String.valueOf(all_real), jsonSub.getBox_weight().toString()).doubleValue(); |
|
|
|
} else { |
|
|
|
mapFL.put("real_weight", NumberUtil.round(jsonSub.getBox_weight(), 1).doubleValue()); // 毛重
|
|
|
|
all_real = NumberUtil.add(String.valueOf(all_real), jsonSub.getBox_weight().toString()).doubleValue(); |
|
|
|
} |
|
|
|
|
|
|
|
flData.add(mapFL); |
|
|
|
all_qty = NumberUtil.add(String.valueOf(all_qty), json.getQty()).doubleValue(); |
|
|
|
} |
|
|
|
// 订单号
|
|
|
|
/* if (ObjectUtil.isNotEmpty(order_no)) { |
|
|
|
oneMap.put("order_no",order_no.substring(0,order_no.indexOf("-"))); |
|
|
|
}*/ |
|
|
|
ExcelWriter workBook = EasyExcel.write(outputStream, null).withTemplate(code_template).build(); |
|
|
|
|
|
|
|
oneMap.put("all_qty", NumberUtil.round(all_qty, 1)); // 合计
|
|
|
|
oneMap.put("all_real", NumberUtil.round(all_real, 1)); // 总毛重
|
|
|
|
workBook.fill(oneMap, sheet); |
|
|
|
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))); |
|
|
|
|
|
|
|
double all_qty = 0; |
|
|
|
double all_real = 0; |
|
|
|
String order_no = ""; |
|
|
|
ArrayList<HashMap<String, Object>> flData = new ArrayList<>(); |
|
|
|
for (int i = j * shd_dtl_num; i < (j + 1) * shd_dtl_num; i++) { |
|
|
|
if (i == dtlArr.size()) { |
|
|
|
break; |
|
|
|
} |
|
|
|
|
|
|
|
AllBoxInfoDto json = dtlArr.get(i); |
|
|
|
PdmBiSubpackagerelation jsonSub = subpackagerelationService.getOne(new LambdaQueryWrapper<PdmBiSubpackagerelation>() |
|
|
|
.eq(PdmBiSubpackagerelation::getPackage_box_sn, json.getBox_no()), false); |
|
|
|
if (ObjectUtil.isEmpty(jsonSub)) { |
|
|
|
throw new BadRequestException("没有查询到子卷包装"); |
|
|
|
} |
|
|
|
order_no = jsonSub.getSale_order_name(); |
|
|
|
|
|
|
|
// 规格: 厚度*幅宽
|
|
|
|
String material_spec = jsonSub.getThickness_request() + "*" + jsonSub.getWidth_standard(); |
|
|
|
// 箱号
|
|
|
|
String box_no = json.getBox_no(); |
|
|
|
String sub_box_no = ""; |
|
|
|
if (ObjectUtil.isNotEmpty(box_no)) { |
|
|
|
try { |
|
|
|
sub_box_no = box_no.substring(box_no.lastIndexOf("@") + 1, box_no.length()); |
|
|
|
} catch (Exception e) { |
|
|
|
sub_box_no = box_no; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
HashMap<String, Object> mapFL = new HashMap<>(); |
|
|
|
// 明细
|
|
|
|
// String date_of_production = jsonSub.getString("date_of_production").replaceAll("[[\\s-:punct:]]", "");
|
|
|
|
// mapFL.put("date_of_production", date_of_production); // 批号 : 子卷包装生产日期
|
|
|
|
mapFL.put("material_name", json.getMaterial_name()); |
|
|
|
mapFL.put("material_spec", material_spec); |
|
|
|
// mapFL.put("qty_unit_name", "KG");
|
|
|
|
mapFL.put("box_no", sub_box_no); |
|
|
|
mapFL.put("qty", NumberUtil.round(json.getQty(), 1).doubleValue()); |
|
|
|
if (ObjectUtil.isNotEmpty(jsonSub.getReal_weight())) { |
|
|
|
mapFL.put("real_weight", NumberUtil.round(jsonSub.getBox_weight(), 1).doubleValue()); // 毛重
|
|
|
|
all_real = NumberUtil.add(String.valueOf(all_real), jsonSub.getBox_weight().toString()).doubleValue(); |
|
|
|
} else { |
|
|
|
mapFL.put("real_weight", NumberUtil.round(jsonSub.getBox_weight(), 1).doubleValue()); // 毛重
|
|
|
|
all_real = NumberUtil.add(String.valueOf(all_real), jsonSub.getBox_weight().toString()).doubleValue(); |
|
|
|
} |
|
|
|
flData.add(mapFL); |
|
|
|
|
|
|
|
// 计算合计重量
|
|
|
|
all_qty = NumberUtil.add(String.valueOf(all_qty), json.getQty()).doubleValue(); |
|
|
|
|
|
|
|
} |
|
|
|
// 订单号
|
|
|
|
ExcelWriter workBook = EasyExcel.write(outputStream, null).withTemplate(code_template).build(); |
|
|
|
oneMap.put("all_qty", NumberUtil.round(all_qty, 1)); // 合计
|
|
|
|
oneMap.put("all_real", NumberUtil.round(all_real, 1)); // 总毛重
|
|
|
|
WriteSheet sheet = EasyExcel.writerSheet(0).build(); |
|
|
|
workBook.fill(oneMap, sheet); |
|
|
|
workBook.fill(new FillWrapper("data", flData), sheet); |
|
|
|
workBook.finish(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void finishTask(OutBillTaskVo whereJson) { |
|
|
|
// hint: 根据明细去完成
|
|
|
|
// 查询任务对应的分配明细 (任务可能为空)
|
|
|
|
JSONArray disJsonArr = iostorinvdisService.getBillInfosByConditions(OutTaskQueryDisDto.builder() |
|
|
|
.task_id(whereJson.getTask_id()) |
|
|
|
.build()); |
|
|
|
// 获取一个数据
|
|
|
|
JSONObject demoDis = disJsonArr.getJSONObject(0); |
|
|
|
// 获取出库单据
|
|
|
|
StIvtIostorinv jo_mst = stIvtIostorinvService.getById(demoDis.getString("iostorinv_id")); |
|
|
|
String iostorinv_id = jo_mst.getIostorinv_id(); |
|
|
|
for (int i = 0; i < disJsonArr.size(); i++) { |
|
|
|
JSONObject dis = disJsonArr.getJSONObject(i); |
|
|
|
|
|
|
|
double plan_qty = dis.getDoubleValue("plan_qty"); |
|
|
|
double real_qty = dis.getDoubleValue("real_qty"); |
|
|
|
//未出部分,按取消分配处理
|
|
|
|
if (Double.compare(real_qty, plan_qty) != 0) { |
|
|
|
dis.put("change_qty", plan_qty - real_qty); |
|
|
|
dis.put("bill_type_scode", jo_mst.getBill_type()); |
|
|
|
dis.put("inv_id", iostorinv_id); |
|
|
|
dis.put("bill_code", jo_mst.getBill_code()); |
|
|
|
dis.put("bill_table", "ST_IVT_IOStorInv"); |
|
|
|
storPublicService.IOStor(dis, "12"); |
|
|
|
} |
|
|
|
//更新已出库重量
|
|
|
|
if (real_qty != 0) { |
|
|
|
dis.put("change_qty", real_qty); |
|
|
|
dis.put("bill_type_scode", jo_mst.getBill_type()); |
|
|
|
dis.put("inv_id", iostorinv_id); |
|
|
|
dis.put("bill_code", jo_mst.getBill_code()); |
|
|
|
dis.put("bill_table", "ST_IVT_IOStorInv"); |
|
|
|
|
|
|
|
if (jo_mst.getIs_overdue().equals("1")) { |
|
|
|
if (dis.getString("is_overdue").equals("1")) { |
|
|
|
storPublicService.IOStor(dis, "12"); |
|
|
|
} else { |
|
|
|
storPublicService.IOStor(dis, "21"); |
|
|
|
} |
|
|
|
} else { |
|
|
|
storPublicService.IOStor(dis, "21"); |
|
|
|
} |
|
|
|
} |
|
|
|
// 更新分配明细执行状态为 - 99
|
|
|
|
iostorinvdisService.update(new LambdaUpdateWrapper<StIvtIostorinvdis>() |
|
|
|
.set(StIvtIostorinvdis::getWork_status, "99") |
|
|
|
.eq(StIvtIostorinvdis::getIostorinvdis_id, dis.getString("iostorinvdis_id"))); |
|
|
|
if (jo_mst.getIs_overdue().equals("1") && dis.getString("is_overdue").equals("1")) { |
|
|
|
continue; |
|
|
|
} |
|
|
|
// 更新子卷包装关系表 状态 - 3
|
|
|
|
JSONObject jsonSub = subpackagerelationService.getObj(new LambdaQueryWrapper<PdmBiSubpackagerelation>() |
|
|
|
.eq(PdmBiSubpackagerelation::getContainer_name, dis.getString("pcsn")) |
|
|
|
.eq(PdmBiSubpackagerelation::getPackage_box_sn, dis.getString("box_no")) |
|
|
|
.eq(PdmBiSubpackagerelation::getStatus, "2"), p -> (JSONObject) JSON.toJSON(p)); |
|
|
|
//查询对应的包装关系出入库记录表
|
|
|
|
if (ObjectUtil.isEmpty(jsonSub)) { |
|
|
|
jsonSub = subpackagerelationrecordService.getObj(new LambdaQueryWrapper<PdmBiSubpackagerelationrecord>() |
|
|
|
.eq(PdmBiSubpackagerelationrecord::getContainer_name, dis.getString("pcsn")) |
|
|
|
.eq(PdmBiSubpackagerelationrecord::getPackage_box_sn, dis.getString("box_no")) |
|
|
|
.eq(PdmBiSubpackagerelationrecord::getStatus, "2") |
|
|
|
.eq(PdmBiSubpackagerelationrecord::getBill_code, jo_mst.getBill_code()), p -> (JSONObject) JSON.toJSON(p)); |
|
|
|
} |
|
|
|
if (ObjectUtil.isEmpty(jsonSub)) { |
|
|
|
throw new BadRequestException("此子卷不存在或不为入库状态:" + dis.getString("pcsn")); |
|
|
|
|
|
|
|
} |
|
|
|
// 如果是拆分入库则将包装关系改为生成状态
|
|
|
|
if (IOSEnum.OUT_TYPE.code("拆箱出库").equals(jo_mst.getBill_type()) || (IOSEnum.OUT_TYPE.code("手工出库").equals(jo_mst.getBill_type()))) { |
|
|
|
jsonSub.put("status", "0"); |
|
|
|
} else { |
|
|
|
jsonSub.put("status", "3"); |
|
|
|
} |
|
|
|
// 分拣出库
|
|
|
|
if (jo_mst.getBill_type().equals("1011")) { |
|
|
|
// 更新子卷包装净重
|
|
|
|
double net_weight = NumberUtil.sub(jsonSub.getDoubleValue("net_weight"), plan_qty); |
|
|
|
jsonSub.put("net_weight", net_weight); |
|
|
|
|
|
|
|
if (net_weight <= 0) { |
|
|
|
jsonSub.put("status", "3"); |
|
|
|
} else { |
|
|
|
jsonSub.put("status", "2"); |
|
|
|
} |
|
|
|
} |
|
|
|
subpackagerelationService.updateById(jsonSub.toJavaObject(PdmBiSubpackagerelation.class)); |
|
|
|
|
|
|
|
// 改切出库、返检出库
|
|
|
|
// 如果为返检出库或者改切出库删除对应的包装关系
|
|
|
|
if ("1003".equals(jo_mst.getBill_type()) || "1006".equals(jo_mst.getBill_type())) { |
|
|
|
List<StIvtIostorinvdis> disRows = iostorinvdisService.list(new LambdaQueryWrapper<StIvtIostorinvdis>() |
|
|
|
.eq(StIvtIostorinvdis::getIostorinv_id, iostorinv_id) |
|
|
|
.eq(StIvtIostorinvdis::getBox_no, jsonSub.getString("package_box_sn")) |
|
|
|
.eq(jo_mst.getIs_overdue().equals("1"), StIvtIostorinvdis::getIs_overdue, "0")); |
|
|
|
|
|
|
|
for (StIvtIostorinvdis disRow : disRows) { |
|
|
|
StIvtSectattr sect_jo = stIvtSectattrService.getByCode(disRow.getSect_code()); |
|
|
|
if (ObjectUtil.isEmpty(sect_jo)) { |
|
|
|
throw new BadRequestException("未查询到对应的库区!"); |
|
|
|
} |
|
|
|
//如果是虚拟区的出库,直接把包装关系删除;如果为立库的包装关系,将解绑删除标识置为1。当发货区解绑时,删除包装关系
|
|
|
|
String pcsn = disRow.getPcsn(); |
|
|
|
if ("09".equals(sect_jo.getSect_type_attr())) { |
|
|
|
subpackagerelationService.remove(new LambdaQueryWrapper<PdmBiSubpackagerelation>() |
|
|
|
.eq(PdmBiSubpackagerelation::getContainer_name, pcsn)); |
|
|
|
} else { |
|
|
|
LambdaUpdateWrapper<PdmBiSubpackagerelation> subUpLam = new LambdaUpdateWrapper<>(); |
|
|
|
subUpLam.set(PdmBiSubpackagerelation::getNeed_delete, "1") |
|
|
|
.eq(PdmBiSubpackagerelation::getContainer_name, pcsn); |
|
|
|
subpackagerelationService.update(subUpLam); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// 解锁起点
|
|
|
|
JSONObject from_start = new JSONObject(); |
|
|
|
from_start.put("struct_id", dis.getString("struct_id")); |
|
|
|
from_start.put("lock_type", "1"); |
|
|
|
from_start.put("is_overdue", dis.getString("is_overdue")); |
|
|
|
|
|
|
|
if (jo_mst.getIs_overdue().equals("1")) { |
|
|
|
if (dis.getString("is_overdue").equals("1")) { |
|
|
|
from_start.put("storagevehicle_code", dis.getString("box_no")); |
|
|
|
} else { |
|
|
|
from_start.put("storagevehicle_code", ""); |
|
|
|
} |
|
|
|
} else { |
|
|
|
from_start.put("storagevehicle_code", ""); |
|
|
|
} |
|
|
|
if (jo_mst.getBill_type().equals("1011")) { |
|
|
|
// 判断此木箱下的所有子卷净重是否为0,如果为0则清空载具
|
|
|
|
List<JSONObject> packageList = subpackagerelationService.getSubInfoByBoxNosToObject( |
|
|
|
Stream.of(jsonSub.getString("package_box_sn")).collect(Collectors.toList()) |
|
|
|
); |
|
|
|
|
|
|
|
boolean is_zero = packageList.stream() |
|
|
|
.allMatch(row -> row.getDoubleValue("net_weight") <= 0); |
|
|
|
|
|
|
|
if (is_zero) { |
|
|
|
from_start.put("storagevehicle_code", ""); |
|
|
|
} else { |
|
|
|
from_start.put("bill_type", "1011"); |
|
|
|
from_start.put("storagevehicle_code", jsonSub.getString("package_box_sn")); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
storPublicService.updateStructAndPoint(from_start); |
|
|
|
//插入包装关系出入库记录表
|
|
|
|
jsonSub.put("bill_code", jo_mst.getBill_code()); |
|
|
|
jsonSub.put("bill_id", jo_mst.getIostorinv_id()); |
|
|
|
jsonSub.put("bill_type", jo_mst.getBill_type()); |
|
|
|
jsonSub.put("io_type", "1"); |
|
|
|
jsonSub.put("insert_time", DateUtil.now()); |
|
|
|
jsonSub.put("record_id", IdUtil.getSnowflake(1, 1).nextId()); |
|
|
|
subpackagerelationrecordService.save(jsonSub.toJavaObject(PdmBiSubpackagerelationrecord.class)); |
|
|
|
} |
|
|
|
|
|
|
|
LambdaUpdateWrapper<SchBaseTask> taskLam = new LambdaUpdateWrapper<>(); |
|
|
|
taskLam.set(SchBaseTask::getTask_status, TaskStatusEnum.FINISHED.getCode()) |
|
|
|
.set(SchBaseTask::getFinished_type, "01") |
|
|
|
.set(SchBaseTask::getUpdate_optid, SecurityUtils.getCurrentUserId() + "") |
|
|
|
.set(SchBaseTask::getUpdate_optname, SecurityUtils.getCurrentNickName()) |
|
|
|
.set(SchBaseTask::getUpdate_time, DateUtil.now()) |
|
|
|
.eq(SchBaseTask::getTask_id, whereJson.getTask_id()); |
|
|
|
//更新任务为完成
|
|
|
|
ischBaseTaskService.update(taskLam); |
|
|
|
|
|
|
|
// 查询此任务下所有的分配明细
|
|
|
|
List<StIvtIostorinvdis> disArr = iostorinvdisService.list(new LambdaQueryWrapper<StIvtIostorinvdis>() |
|
|
|
.eq(StIvtIostorinvdis::getTask_id, whereJson.getTask_id())); |
|
|
|
for (int i = 0; i < disArr.size(); i++) { |
|
|
|
StIvtIostorinvdis json = disArr.get(i); |
|
|
|
// 更新分配明细为完成
|
|
|
|
json.setWork_status("99"); |
|
|
|
iostorinvdisService.updateById(json); |
|
|
|
|
|
|
|
// 判断此明细下是否还有未完成的分配明细
|
|
|
|
StIvtIostorinvdtl jsonDtl = iostorinvdtlService.getById(json.getIostorinvdtl_id()); |
|
|
|
List<StIvtIostorinvdis> disArr2 = iostorinvdisService.list(new LambdaQueryWrapper<StIvtIostorinvdis>() |
|
|
|
.eq(StIvtIostorinvdis::getIostorinvdtl_id, jsonDtl.getIostorinvdtl_id()) |
|
|
|
.ne(StIvtIostorinvdis::getWork_status, "99")); |
|
|
|
if (ObjectUtil.isEmpty(disArr2)) { |
|
|
|
// 更新明细为完成
|
|
|
|
jsonDtl.setBill_status("99"); |
|
|
|
iostorinvdtlService.updateById(jsonDtl); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
//判断是否还有未完成的明细
|
|
|
|
List<StIvtIostorinvdtl> ja = iostorinvdtlService.list(new LambdaQueryWrapper<StIvtIostorinvdtl>() |
|
|
|
.ne(StIvtIostorinvdtl::getBill_status, "99") |
|
|
|
.eq(StIvtIostorinvdtl::getIostorinv_id, disArr.get(0).getIostorinv_id())); |
|
|
|
if (ja.size() == 0) { |
|
|
|
this.confirmOrder((JSONObject) JSONObject.toJSON(jo_mst)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void confirmOrder(JSONObject form) { |
|
|
|
String iostorinv_id = form.getString("iostorinv_id"); |
|
|
|
String currentUserId = SecurityUtils.getCurrentUserId(); |
|
|
|
String nickName = SecurityUtils.getCurrentNickName(); |
|
|
|
String now = DateUtil.now(); |
|
|
|
|
|
|
|
//查询主表信息
|
|
|
|
StIvtIostorinv jo_mst = stIvtIostorinvService.getById(iostorinv_id); |
|
|
|
if (ObjectUtil.isEmpty(jo_mst)) { |
|
|
|
throw new BadRequestException("未查到相关出库单"); |
|
|
|
} |
|
|
|
|
|
|
|
//判断分配明细中是否有未生成状态的分配明细
|
|
|
|
List<StIvtIostorinvdis> disArr = iostorinvdisService.list(new LambdaQueryWrapper<StIvtIostorinvdis>() |
|
|
|
.eq(StIvtIostorinvdis::getIostorinv_id, iostorinv_id) |
|
|
|
.eq(StIvtIostorinvdis::getWork_status, "00")); |
|
|
|
if (ObjectUtil.isNotEmpty(disArr)) { |
|
|
|
throw new BadRequestException("有未生成状态的分配明细,不允许强制确认"); |
|
|
|
} |
|
|
|
|
|
|
|
// 查询是否有未完成的任务
|
|
|
|
List<JSONObject> isTaskEmp = iostorinvdisService.getTasking(iostorinv_id); |
|
|
|
|
|
|
|
if (ObjectUtil.isNotEmpty(isTaskEmp)) { |
|
|
|
// 拼接字符串
|
|
|
|
String box_no = isTaskEmp.stream() |
|
|
|
.map(row -> row.getString("box_no")) |
|
|
|
.distinct() |
|
|
|
.collect(Collectors.joining(",")); |
|
|
|
|
|
|
|
throw new BadRequestException("请先完成载具对应的出库任务:" + box_no); |
|
|
|
} |
|
|
|
|
|
|
|
//查询生成和未分配完的明细
|
|
|
|
List<JSONObject> dtls = iostorinvdtlService.getGeneratedAndUnallocatedDtls(GenOrUnDtlDto.builder() |
|
|
|
.bill_status("50") |
|
|
|
.iostorinv_id(iostorinv_id) |
|
|
|
.build()); |
|
|
|
|
|
|
|
if (dtls.size() != 0) { |
|
|
|
for (int i = 0; i < dtls.size(); i++) { |
|
|
|
JSONObject dtl = dtls.get(i); |
|
|
|
//更新明细状态
|
|
|
|
LambdaUpdateWrapper<StIvtIostorinvdtl> dtlUpLam = new LambdaUpdateWrapper<>(); |
|
|
|
dtlUpLam.set(StIvtIostorinvdtl::getBill_status, "99") |
|
|
|
.eq(StIvtIostorinvdtl::getIostorinvdtl_id, dtl.getString("iostorinvdtl_id")); |
|
|
|
iostorinvdtlService.update(dtlUpLam); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
LambdaUpdateWrapper<StIvtIostorinv> invUpLam = new LambdaUpdateWrapper<>(); |
|
|
|
invUpLam.set(StIvtIostorinv::getBill_code, "99") |
|
|
|
.set(StIvtIostorinv::getConfirm_optid, currentUserId) |
|
|
|
.set(StIvtIostorinv::getConfirm_optname, nickName) |
|
|
|
.set(StIvtIostorinv::getConfirm_time, now) |
|
|
|
.eq(StIvtIostorinv::getIostorinv_id, iostorinv_id); |
|
|
|
stIvtIostorinvService.update(invUpLam); |
|
|
|
|
|
|
|
|
|
|
|
//查询需要更新库存的分配记录
|
|
|
|
JSONArray diss = iostorinvdisService.getBillInfosByConditions(OutTaskQueryDisDto.builder() |
|
|
|
.iostorinv_id(iostorinv_id) |
|
|
|
.build()); |
|
|
|
for (int i = 0; i < diss.size(); i++) { |
|
|
|
JSONObject dis = diss.getJSONObject(i); |
|
|
|
// 判断是否是主存区的仓位, 是否发超期 todo: 编码固定
|
|
|
|
if ("ZC01,ZZ01".contains(dis.getString("sect_code"))) { |
|
|
|
|
|
|
|
if (jo_mst.getIs_overdue().equals("1")) { |
|
|
|
// 不发超期
|
|
|
|
if (!dis.getString("is_overdue").equals("1")) { |
|
|
|
continue; |
|
|
|
} |
|
|
|
} else { |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
double plan_qty = dis.getDoubleValue("plan_qty"); |
|
|
|
double real_qty = dis.getDoubleValue("real_qty"); |
|
|
|
//未出部分,按取消分配处理
|
|
|
|
if (Double.compare(real_qty, plan_qty) != 0) { |
|
|
|
dis.put("change_qty", plan_qty - real_qty); |
|
|
|
dis.put("bill_type_scode", jo_mst.getBill_type()); |
|
|
|
dis.put("inv_id", iostorinv_id); |
|
|
|
dis.put("bill_code", jo_mst.getBill_code()); |
|
|
|
dis.put("bill_table", "ST_IVT_IOStorInv"); |
|
|
|
storPublicService.IOStor(dis, "12"); |
|
|
|
} |
|
|
|
//更新已出库重量
|
|
|
|
if (real_qty != 0) { |
|
|
|
dis.put("change_qty", real_qty); |
|
|
|
dis.put("bill_type_scode", jo_mst.getBill_type()); |
|
|
|
dis.put("inv_id", iostorinv_id); |
|
|
|
dis.put("bill_code", jo_mst.getBill_code()); |
|
|
|
dis.put("bill_table", "ST_IVT_IOStorInv"); |
|
|
|
|
|
|
|
if (jo_mst.getIs_overdue().equals("1")) { |
|
|
|
if (dis.getString("is_overdue").equals("1")) { |
|
|
|
storPublicService.IOStor(dis, "12"); |
|
|
|
} else { |
|
|
|
storPublicService.IOStor(dis, "21"); |
|
|
|
} |
|
|
|
} else { |
|
|
|
storPublicService.IOStor(dis, "21"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 更新分配明细执行状态为 - 99
|
|
|
|
StIvtIostorinvdis jsonDis = iostorinvdisService.getOne(new LambdaQueryWrapper<StIvtIostorinvdis>() |
|
|
|
.eq(StIvtIostorinvdis::getIostorinvdis_id, dis.getString("iostorinvdis_id"))); |
|
|
|
jsonDis.setWork_status("99"); |
|
|
|
iostorinvdisService.updateById(jsonDis); |
|
|
|
|
|
|
|
if (jo_mst.getIs_overdue().equals("1")) { |
|
|
|
if (dis.getString("is_overdue").equals("1")) { |
|
|
|
// 解锁起点
|
|
|
|
JSONObject from_start = new JSONObject(); |
|
|
|
from_start.put("struct_id", dis.getString("struct_id")); |
|
|
|
from_start.put("lock_type", "1"); |
|
|
|
from_start.put("is_overdue", dis.getString("is_overdue")); |
|
|
|
from_start.put("storagevehicle_code", dis.getString("box_no")); |
|
|
|
storPublicService.updateStructAndPoint(from_start); |
|
|
|
|
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
// 更新子卷包装关系表 状态 - 3
|
|
|
|
JSONObject jsonSub = subpackagerelationService.getObj(new LambdaQueryWrapper<PdmBiSubpackagerelation>() |
|
|
|
.eq(PdmBiSubpackagerelation::getContainer_name, dis.getString("pcsn")) |
|
|
|
.eq(PdmBiSubpackagerelation::getPackage_box_sn, dis.getString("box_no")) |
|
|
|
.eq(PdmBiSubpackagerelation::getStatus, "2"), p -> (JSONObject) JSON.toJSON(p)); |
|
|
|
//查询对应的包装关系出入库记录表
|
|
|
|
if (ObjectUtil.isEmpty(jsonSub)) { |
|
|
|
jsonSub = subpackagerelationrecordService.getObj(new LambdaQueryWrapper<PdmBiSubpackagerelationrecord>() |
|
|
|
.eq(PdmBiSubpackagerelationrecord::getContainer_name, dis.getString("pcsn")) |
|
|
|
.eq(PdmBiSubpackagerelationrecord::getPackage_box_sn, dis.getString("box_no")) |
|
|
|
.eq(PdmBiSubpackagerelationrecord::getStatus, "2") |
|
|
|
.eq(PdmBiSubpackagerelationrecord::getBill_code, jo_mst.getBill_code()), p -> (JSONObject) JSON.toJSON(p)); |
|
|
|
} |
|
|
|
|
|
|
|
if (ObjectUtil.isEmpty(jsonSub)) { |
|
|
|
throw new BadRequestException("此子卷不存在或不为入库状态:" + dis.getString("pcsn")); |
|
|
|
|
|
|
|
} |
|
|
|
// 如果是拆分入库则将包装关系改为生成状态
|
|
|
|
if ("1005".equals(jo_mst.getBill_type()) || ("1009".equals(jo_mst.getBill_type()))) { |
|
|
|
jsonSub.put("status", "0"); |
|
|
|
} else { |
|
|
|
jsonSub.put("status", "3"); |
|
|
|
} |
|
|
|
|
|
|
|
if (jo_mst.getBill_type().equals("1011")) { |
|
|
|
// 更新子卷包装净重
|
|
|
|
double net_weight = NumberUtil.sub(jsonSub.getDoubleValue("net_weight"), plan_qty); |
|
|
|
jsonSub.put("net_weight",net_weight); |
|
|
|
|
|
|
|
if (net_weight <= 0) { |
|
|
|
jsonSub.put("status","3"); |
|
|
|
} else { |
|
|
|
jsonSub.put("status","2"); |
|
|
|
} |
|
|
|
} |
|
|
|
subpackagerelationService.updateById(jsonSub.toJavaObject(PdmBiSubpackagerelation.class)); |
|
|
|
|
|
|
|
// 解锁起点
|
|
|
|
JSONObject from_start = new JSONObject(); |
|
|
|
from_start.put("struct_id", dis.getString("struct_id")); |
|
|
|
from_start.put("lock_type", "1"); |
|
|
|
from_start.put("is_overdue", dis.getString("is_overdue")); |
|
|
|
|
|
|
|
if (jo_mst.getIs_overdue().equals("1")) { |
|
|
|
if (dis.getString("is_overdue").equals("1")) { |
|
|
|
from_start.put("storagevehicle_code", dis.getString("box_no")); |
|
|
|
} else { |
|
|
|
from_start.put("storagevehicle_code", ""); |
|
|
|
} |
|
|
|
} else { |
|
|
|
from_start.put("storagevehicle_code", ""); |
|
|
|
} |
|
|
|
|
|
|
|
if (jo_mst.getBill_type().equals("1011")) { |
|
|
|
// 判断此木箱下的所有子卷净重是否为0,如果为0则清空载具
|
|
|
|
List<JSONObject> packageList = subpackagerelationService.getSubInfoByBoxNosToObject( |
|
|
|
Stream.of(jsonSub.getString("package_box_sn")).collect(Collectors.toList()) |
|
|
|
); |
|
|
|
boolean is_zero = packageList.stream() |
|
|
|
.allMatch(row -> row.getDoubleValue("net_weight") <= 0); |
|
|
|
|
|
|
|
if (is_zero) { |
|
|
|
from_start.put("storagevehicle_code", ""); |
|
|
|
} else { |
|
|
|
from_start.put("bill_type","1011"); |
|
|
|
from_start.put("storagevehicle_code", jsonSub.getString("package_box_sn")); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
storPublicService.updateStructAndPoint(from_start); |
|
|
|
|
|
|
|
//插入包装关系出入库记录表
|
|
|
|
jsonSub.put("bill_code", jo_mst.getBill_code()); |
|
|
|
jsonSub.put("bill_id", jo_mst.getIostorinv_id()); |
|
|
|
jsonSub.put("bill_type", jo_mst.getBill_type()); |
|
|
|
jsonSub.put("io_type", "1"); |
|
|
|
jsonSub.put("insert_time", DateUtil.now()); |
|
|
|
jsonSub.put("record_id", IdUtil.getSnowflake(1, 1).nextId()); |
|
|
|
subpackagerelationrecordService.save(jsonSub.toJavaObject(PdmBiSubpackagerelationrecord.class)); |
|
|
|
|
|
|
|
// 更新对应任务为完成
|
|
|
|
SchBaseTask jsonTask = ischBaseTaskService.getOne(new LambdaQueryWrapper<SchBaseTask>() |
|
|
|
.eq(SchBaseTask::getTask_id, jsonDis.getTask_id()) |
|
|
|
.lt(SchBaseTask::getTask_status, "07"), false); |
|
|
|
if (ObjectUtil.isNotEmpty(jsonTask)) { |
|
|
|
jsonTask.setTask_status(TaskStatusEnum.FINISHED.getCode()); |
|
|
|
ischBaseTaskService.updateById(jsonTask); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
StIvtIostorinv out_jo = stIvtIostorinvService.getById(iostorinv_id); |
|
|
|
if ("1004".equals(out_jo.getBill_type())) { |
|
|
|
//调拨出库自动生成调拨入库单
|
|
|
|
|
|
|
|
//校验主表状态为生成
|
|
|
|
if (!"99".equals(out_jo.getBill_status())) { |
|
|
|
throw new BadRequestException("主表状态必须为完成!"); |
|
|
|
} |
|
|
|
|
|
|
|
List<JSONObject> dis_rows = iostorinvdisService.listObjs(new LambdaQueryWrapper<StIvtIostorinvdis>() |
|
|
|
.eq(StIvtIostorinvdis::getIostorinv_id, iostorinv_id) |
|
|
|
.eq(jo_mst.getIs_overdue().equals("1"), StIvtIostorinvdis::getIs_overdue, "0"), p -> (JSONObject) JSON.toJSON(p)); |
|
|
|
|
|
|
|
//生成手工入库单
|
|
|
|
String new_iostorinv_id = IdUtil.getSnowflake(1, 1).nextId() + ""; |
|
|
|
String bill_code = CodeUtil.getNewCode("IO_CODE"); |
|
|
|
jo_mst.setIostorinv_id(new_iostorinv_id); |
|
|
|
jo_mst.setBill_code(bill_code); |
|
|
|
jo_mst.setIo_type("0"); |
|
|
|
jo_mst.setBill_type("0004"); |
|
|
|
jo_mst.setBuss_type(jo_mst.getBill_type().substring(0, 4)); |
|
|
|
//查询移入仓库的信息
|
|
|
|
StIvtBsrealstorattr in_stor = bsrealstorattrService.getById(out_jo.getOut_stor_id()); |
|
|
|
if (ObjectUtil.isEmpty(in_stor)) { |
|
|
|
throw new BadRequestException("未查询到对应的移入仓库信息!"); |
|
|
|
} |
|
|
|
jo_mst.setStor_id(in_stor.getStor_id()); |
|
|
|
jo_mst.setStor_code(in_stor.getStor_code()); |
|
|
|
jo_mst.setStor_name(in_stor.getStor_name()); |
|
|
|
jo_mst.setBill_status("30"); |
|
|
|
jo_mst.setInput_optid(currentUserId); |
|
|
|
jo_mst.setInput_optname(nickName); |
|
|
|
jo_mst.setInput_time(now); |
|
|
|
jo_mst.setUpdate_optid(currentUserId); |
|
|
|
jo_mst.setUpdate_optname(nickName); |
|
|
|
jo_mst.setUpdate_time(now); |
|
|
|
jo_mst.setOut_stor_id(in_stor.getStor_id()); |
|
|
|
|
|
|
|
double total_qty = 0.00; |
|
|
|
for (int i = 0; i < dis_rows.size(); i++) { |
|
|
|
//插入明细表
|
|
|
|
String iostorinvdtl_id = IdUtil.getSnowflake(1, 1).nextId() + ""; |
|
|
|
JSONObject dis_row = dis_rows.get(i); |
|
|
|
//查询对应的出库单明细
|
|
|
|
StIvtIostorinvdtl dtl_row = iostorinvdtlService.getById(dis_row.getString("iostorinvdtl_id")); |
|
|
|
dis_row.put("iostorinvdtl_id", iostorinvdtl_id); |
|
|
|
dis_row.put("iostorinv_id", new_iostorinv_id); |
|
|
|
dis_row.put("seq_no", i + 1); |
|
|
|
dis_row.put("bill_status", "30"); |
|
|
|
dis_row.put("real_qty", "0"); |
|
|
|
dis_row.put("vbeln", dtl_row.getVbeln()); |
|
|
|
dis_row.put("source_billdtl_id", dtl_row.getIostorinvdtl_id()); |
|
|
|
// dis_row.put("source_bill_type", mst_row.getString("bill_type"));
|
|
|
|
dis_row.put("source_bill_type", out_jo.getBill_type()); |
|
|
|
dis_row.put("source_bill_code", dtl_row.getSource_bill_code()); |
|
|
|
dis_row.put("source_bill_table", "ST_IVT_IOStorInvDtl"); |
|
|
|
dis_row.put("assign_qty", dis_row.getString("plan_qty")); |
|
|
|
dis_row.put("unassign_qty", "0"); |
|
|
|
//插入调拨明细表
|
|
|
|
iostorinvdisService.save(dis_row.toJavaObject(StIvtIostorinvdis.class)); |
|
|
|
dis_row.put("iostorinvdis_id", IdUtil.getSnowflake(1, 1).nextId()); |
|
|
|
dis_row.put("seq_no", 1); |
|
|
|
dis_row.put("sect_id", ""); |
|
|
|
dis_row.put("sect_code", ""); |
|
|
|
dis_row.put("sect_name", ""); |
|
|
|
dis_row.put("struct_id", ""); |
|
|
|
dis_row.put("struct_code", ""); |
|
|
|
dis_row.put("struct_name", ""); |
|
|
|
dis_row.put("work_status", "00"); |
|
|
|
dis_row.put("real_qty", "0"); |
|
|
|
dis_row.put("point_id", ""); |
|
|
|
dis_row.put("task_id", ""); |
|
|
|
//插入分配表
|
|
|
|
iostorinvdtlService.save(dis_row.toJavaObject(StIvtIostorinvdtl.class)); |
|
|
|
total_qty = NumberUtil.add(total_qty,dis_row.getDoubleValue("plan_qty")); |
|
|
|
|
|
|
|
//将包装关系中对应的记录状态改为包装
|
|
|
|
LambdaUpdateWrapper<PdmBiSubpackagerelation> subUpLam = new LambdaUpdateWrapper<>(); |
|
|
|
subUpLam.set(PdmBiSubpackagerelation::getStatus, "1") |
|
|
|
.eq(PdmBiSubpackagerelation::getPackage_box_sn, dis_row.getString("box_no")) |
|
|
|
.eq(PdmBiSubpackagerelation::getStatus, "3"); |
|
|
|
subpackagerelationService.update(subUpLam); |
|
|
|
} |
|
|
|
|
|
|
|
// 查询所有明细并计算实际重量
|
|
|
|
List<StIvtIostorinvdtl> dtlList = iostorinvdtlService.getBillDtlByInvId(iostorinv_id); |
|
|
|
|
|
|
|
double assign_qty = dtlList.stream() |
|
|
|
.map(row -> row.getAssign_qty().doubleValue()) |
|
|
|
.reduce(Double::sum).orElse(0.00); |
|
|
|
|
|
|
|
jo_mst.setDetail_count(BigDecimal.valueOf(dis_rows.size())); |
|
|
|
// jo_mst.put("total_qty", total_qty);
|
|
|
|
jo_mst.setTotal_qty(BigDecimal.valueOf(assign_qty)); |
|
|
|
stIvtIostorinvService.save(jo_mst); |
|
|
|
} |
|
|
|
|
|
|
|
if ("1003".equals(out_jo.getBill_type()) || "1006".equals(out_jo.getBill_type())) { |
|
|
|
//如果为返检出库或者改切出库删除对应的包装关系
|
|
|
|
List<JSONObject> dis_rows = iostorinvdisService.listObjs(new LambdaQueryWrapper<StIvtIostorinvdis>() |
|
|
|
.eq(StIvtIostorinvdis::getIostorinv_id, iostorinv_id) |
|
|
|
.eq(jo_mst.getIs_overdue().equals("1"), StIvtIostorinvdis::getIs_overdue, "0"), p -> (JSONObject) JSON.toJSON(p)); |
|
|
|
|
|
|
|
for (int i = 0; i < dis_rows.size(); i++) { |
|
|
|
JSONObject dis_row = dis_rows.get(i); |
|
|
|
String sect_code = dis_row.getString("sect_code"); |
|
|
|
StIvtSectattr sect_jo = stIvtSectattrService.getByCode(sect_code); |
|
|
|
if (ObjectUtil.isEmpty(sect_jo)) { |
|
|
|
throw new BadRequestException("未查询到对应的库区!"); |
|
|
|
} |
|
|
|
//如果是虚拟区的出库,直接把包装关系删除;如果为立库的包装关系,将解绑删除标识置为1。当发货区解绑时,删除包装关系
|
|
|
|
String pcsn = dis_row.getString("pcsn"); |
|
|
|
if ("09".equals(sect_jo.getSect_type_attr())) { |
|
|
|
subpackagerelationService.remove(new LambdaQueryWrapper<PdmBiSubpackagerelation>() |
|
|
|
.eq(PdmBiSubpackagerelation::getContainer_name, pcsn)); |
|
|
|
} else { |
|
|
|
LambdaUpdateWrapper<PdmBiSubpackagerelation> subUpLam = new LambdaUpdateWrapper<>(); |
|
|
|
subUpLam.set(PdmBiSubpackagerelation::getNeed_delete, "1") |
|
|
|
.eq(PdmBiSubpackagerelation::getContainer_name, pcsn); |
|
|
|
subpackagerelationService.update(subUpLam); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void issueTask(JSONObject whereJson) { |
|
|
|
|
|
|
|
String currentUserId = SecurityUtils.getCurrentUserId(); |
|
|
|
String nickName = SecurityUtils.getCurrentNickName(); |
|
|
|
String now = DateUtil.now(); |
|
|
|
SchBaseTask jsonTask = ischBaseTaskService.getById(whereJson.getString("task_id")); |
|
|
|
|
|
|
|
// 调用出库任务类下发任务
|
|
|
|
new TwoOutTask().immediateNotifyAcs(jsonTask.getTask_id()); |
|
|
|
|
|
|
|
// 更新任务状态为下发
|
|
|
|
jsonTask.setTask_status(TaskStatusEnum.ISSUE.getCode()); |
|
|
|
jsonTask.setUpdate_optid(currentUserId); |
|
|
|
jsonTask.setUpdate_optname(nickName); |
|
|
|
jsonTask.setUpdate_time(now); |
|
|
|
ischBaseTaskService.updateById(jsonTask); |
|
|
|
} |
|
|
|
|
|
|
|
private void doLikeOrInParam(OutManageParam paramMap) { |
|
|
|
if (StrUtil.isNotEmpty(paramMap.getVbeln())){ |
|
|
|
if (StrUtil.isNotEmpty(paramMap.getVbeln())) { |
|
|
|
// 判断是否有空格
|
|
|
|
boolean matches = paramMap.getVbeln().matches(".*\\s.*"); |
|
|
|
List<String> vbelnList = new ArrayList<>(); |
|
|
@ -323,7 +1207,7 @@ public class CheckOutBillServiceImpl implements CheckOutBillService { |
|
|
|
paramMap.setVbeln(""); |
|
|
|
} |
|
|
|
} |
|
|
|
if (StrUtil.isNotEmpty(paramMap.getBox_no())){ |
|
|
|
if (StrUtil.isNotEmpty(paramMap.getBox_no())) { |
|
|
|
// 判断是否有空格
|
|
|
|
boolean matches = paramMap.getBox_no().matches(".*\\s.*"); |
|
|
|
List<String> boxList = new ArrayList<>(); |
|
|
@ -334,7 +1218,7 @@ public class CheckOutBillServiceImpl implements CheckOutBillService { |
|
|
|
paramMap.setBox_no(""); |
|
|
|
} |
|
|
|
} |
|
|
|
if (StrUtil.isNotEmpty(paramMap.getPcsn())){ |
|
|
|
if (StrUtil.isNotEmpty(paramMap.getPcsn())) { |
|
|
|
// 判断是否有空格
|
|
|
|
boolean matches = paramMap.getPcsn().matches(".*\\s.*"); |
|
|
|
List<String> pcsnList = new ArrayList<>(); |
|
|
@ -345,7 +1229,7 @@ public class CheckOutBillServiceImpl implements CheckOutBillService { |
|
|
|
paramMap.setPcsn(""); |
|
|
|
} |
|
|
|
} |
|
|
|
if (StrUtil.isNotEmpty(paramMap.getSap_pcsn())){ |
|
|
|
if (StrUtil.isNotEmpty(paramMap.getSap_pcsn())) { |
|
|
|
// 判断是否有空格
|
|
|
|
boolean matches = paramMap.getSap_pcsn().matches(".*\\s.*"); |
|
|
|
List<String> pcsnList = new ArrayList<>(); |
|
|
|