|
|
@@ -3,6 +3,7 @@ package com.ruoyi.warehouseBusiness.service.impl;
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
+import cn.hutool.json.JSONUtil;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
@@ -31,6 +32,7 @@ import com.ruoyi.common.utils.*;
|
|
|
import com.ruoyi.common.utils.ip.AddressUtils;
|
|
|
import com.ruoyi.common.utils.poi.DrawExcel;
|
|
|
import com.ruoyi.common.utils.poi.ExcelUtils;
|
|
|
+import com.ruoyi.common.utils.sign.Md5Utils;
|
|
|
import com.ruoyi.finance.domain.TFeeDo;
|
|
|
import com.ruoyi.finance.mapper.TFeeDoMapper;
|
|
|
import com.ruoyi.quotation.domain.TSeaprice;
|
|
|
@@ -60,10 +62,7 @@ import com.ruoyi.warehouseBusiness.domain.dto.WarehousebillsDTO;
|
|
|
import com.ruoyi.warehouseBusiness.domain.enums.FeesTypeEnum;
|
|
|
import com.ruoyi.warehouseBusiness.domain.enums.WarehouseActIdEnum;
|
|
|
import com.ruoyi.warehouseBusiness.domain.enums.WarehouseTypeEnum;
|
|
|
-import com.ruoyi.warehouseBusiness.domain.vo.AppWarehouseInfoVO;
|
|
|
-import com.ruoyi.warehouseBusiness.domain.vo.CalculateStorageFeesInfoVO;
|
|
|
-import com.ruoyi.warehouseBusiness.domain.vo.StorageFeeCalculationResultVO;
|
|
|
-import com.ruoyi.warehouseBusiness.domain.vo.WarehouseBillsVO;
|
|
|
+import com.ruoyi.warehouseBusiness.domain.vo.*;
|
|
|
import com.ruoyi.warehouseBusiness.excel.*;
|
|
|
import com.ruoyi.warehouseBusiness.mapper.*;
|
|
|
import com.ruoyi.warehouseBusiness.service.ITWarehouseBillsService;
|
|
|
@@ -84,6 +83,7 @@ import org.springframework.http.*;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
|
|
+import org.springframework.util.DigestUtils;
|
|
|
import org.springframework.util.LinkedMultiValueMap;
|
|
|
import org.springframework.util.MultiValueMap;
|
|
|
import org.springframework.web.client.RestTemplate;
|
|
|
@@ -94,9 +94,11 @@ import java.math.BigDecimal;
|
|
|
import java.math.BigInteger;
|
|
|
import java.math.RoundingMode;
|
|
|
import java.net.URLEncoder;
|
|
|
+import java.nio.charset.StandardCharsets;
|
|
|
import java.security.KeyFactory;
|
|
|
import java.security.PrivateKey;
|
|
|
import java.security.spec.PKCS8EncodedKeySpec;
|
|
|
+import java.text.DateFormat;
|
|
|
import java.text.ParseException;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
|
@@ -10332,6 +10334,313 @@ public class TWarehouseBillsServiceImpl implements ITWarehouseBillsService {
|
|
|
return "操作成功";
|
|
|
}
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private TWarehouseBillsMapper warehouseBillsMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private SkuItemMapper skuItemMapper;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<TWarehouseBills> mortgageList(TWarehouseBills warehouseBills) {
|
|
|
+
|
|
|
+ return warehouseBillsMapper.mortgageList(warehouseBills);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public TWarehouseBills mortgageDetail(Long id) {
|
|
|
+ TWarehouseBills tWarehouseBills = warehouseBillsMapper.mortgageDetail(id);
|
|
|
+ List<SkuItem> skuItemList = skuItemMapper.getByPid(tWarehouseBills.getfId());
|
|
|
+ tWarehouseBills.setSkuItemList(skuItemList);
|
|
|
+ return tWarehouseBills;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public AjaxResult getDistributionlList(WarehouseVO warehouseVO) {
|
|
|
+
|
|
|
+ TWhgenleg tWhgenleg = new TWhgenleg();
|
|
|
+ // 提单号
|
|
|
+ tWhgenleg.setfMblno(warehouseVO.getBillOfLading());
|
|
|
+ // 仓库编号
|
|
|
+// tWhgenleg.setWarehouseNo(warehouseVO.getPositionCode());
|
|
|
+ // 客户编号
|
|
|
+ tWhgenleg.setCustomerId(warehouseVO.getOwnerId().toString());
|
|
|
+ tWhgenleg.setSku(warehouseVO.getSkuId());
|
|
|
+ tWhgenleg.setSpu(warehouseVO.getSpuId());
|
|
|
+ List<Map<String, Object>> mapList = tWhgenlegMapper.selectInventoryMapListV2(tWhgenleg);
|
|
|
+
|
|
|
+ for (Map<String, Object> map : mapList) {
|
|
|
+ String fGrossweightD = map.get("fGrossweightD").toString();
|
|
|
+ BigDecimal big = new BigDecimal(fGrossweightD);
|
|
|
+ double v = big.divide(new BigDecimal("1000"), 2, RoundingMode.HALF_UP).doubleValue();
|
|
|
+ map.put("fGrossweightD", v);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ return AjaxResult.success(mapList);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Transactional
|
|
|
+ public AjaxResult mortgage(WarehouseVO warehouseVO) {
|
|
|
+ TWarehouseBills a = mortgageDetail(Long.valueOf(warehouseVO.getFId()));
|
|
|
+// a.setOperationType(Integer.valueOf(warehouseVO.getOperationType()));
|
|
|
+ a.setOperationType(10);
|
|
|
+
|
|
|
+ Map<String, Object> reqBody = new HashMap<>();
|
|
|
+
|
|
|
+ // 仓库
|
|
|
+ TWarehouse warehouseMaser = new TWarehouse();
|
|
|
+ warehouseMaser.setfId(Long.valueOf(a.getfWarehouseid()));
|
|
|
+ warehouseMaser = tWarehouseMapper.getOne(warehouseMaser);
|
|
|
+
|
|
|
+ // 仓储公司
|
|
|
+// TWarehouse warehouseFirm = new TWarehouse();
|
|
|
+// warehouseFirm.setfId(warehouseMaser.getParentId());
|
|
|
+// warehouseFirm = tWarehouseMapper.getOne(warehouseFirm);
|
|
|
+
|
|
|
+ // 客户信息
|
|
|
+ TCorps tCorps = new TCorps();
|
|
|
+ tCorps.setfId(Long.valueOf(a.getfCorpid()));
|
|
|
+ tCorps = tCorpsMapper.getOne(tCorps);
|
|
|
+
|
|
|
+ reqBody.put("businessCode", a.getBusinessCode());
|
|
|
+ reqBody.put("serialNumber", a.getSerialNumber());
|
|
|
+// reqBody.put("positionCode", warehouseMaser.getfNo());
|
|
|
+ reqBody.put("positionCode", warehouseMaser.getfId());
|
|
|
+// reqBody.put("operationType", a.getOperationType());
|
|
|
+ reqBody.put("receiptId", a.getfId());
|
|
|
+// reqBody.put("ownerCode", tCorps.getfNo());
|
|
|
+ reqBody.put("ownerName", tCorps.getfName());
|
|
|
+ reqBody.put("ownerIdentifier", tCorps.getUscc());
|
|
|
+
|
|
|
+ // 客户地址
|
|
|
+ reqBody.put("ownerAddress", tCorps.getfAddr());
|
|
|
+
|
|
|
+ reqBody.put("remark", a.getRemark());
|
|
|
+ reqBody.put("storageName", a.getStorageName());
|
|
|
+ reqBody.put("storageContractCode", a.getStorageContractCode());
|
|
|
+ reqBody.put("storageContractStart", a.getStorageContractStart());
|
|
|
+ reqBody.put("storageContractEnd", a.getStorageContractEnd());
|
|
|
+// reqBody.put("warehouseCode", warehouseMaser.getfNo());
|
|
|
+ reqBody.put("warehouseCode", warehouseMaser.getfId());
|
|
|
+ reqBody.put("warehouseName", warehouseMaser.getfName());
|
|
|
+ reqBody.put("storageRate", a.getStorageRate());
|
|
|
+ reqBody.put("storagePayTime", a.getStoragePayTime());
|
|
|
+ reqBody.put("insuranceCode", a.getInsuranceCode());
|
|
|
+ reqBody.put("insuranceAmount", a.getInsuranceAmount());
|
|
|
+ reqBody.put("insuranceStartTime", a.getInsuranceStartTime());
|
|
|
+ reqBody.put("insuranceEndTime", a.getInsuranceEndTime());
|
|
|
+ reqBody.put("insurer", a.getInsurer());
|
|
|
+ reqBody.put("inventory", a.getInventory());
|
|
|
+ reqBody.put("operator", a.getOperator());
|
|
|
+ reqBody.put("auditor", a.getAuditor());
|
|
|
+
|
|
|
+ reqBody.put("operationType", "10");
|
|
|
+
|
|
|
+ List<SkuItem> skuItemList = a.getSkuItemList();
|
|
|
+
|
|
|
+
|
|
|
+ List<Map<String, Object>> goodsMap = new ArrayList<>();
|
|
|
+ for (SkuItem skuItem : skuItemList) {
|
|
|
+ List<CollateralGoodsVO> collateralGoodsList = collateralMapper.selectByPid(skuItem.getId().toString());
|
|
|
+ for (CollateralGoodsVO vo : collateralGoodsList) {
|
|
|
+
|
|
|
+
|
|
|
+ // 锁定货物
|
|
|
+ TWhgenleg tWhgenleg = new TWhgenleg();
|
|
|
+ tWhgenleg.setfCorpid(a.getfCorpid());
|
|
|
+ tWhgenleg.setfWarehouseid(a.getfWarehouseid());
|
|
|
+ tWhgenleg.setfTrademodeid(1L);
|
|
|
+ tWhgenleg.setWarehouseInformation(vo.getFWarehouseInformation());
|
|
|
+ tWhgenleg.setfMblno(skuItem.getBillOfLading());
|
|
|
+ List<Map<String, Object>> maps = tWhgenlegMapper.selectInventoryList(tWhgenleg);
|
|
|
+ for (Map<String, Object> map : maps) {
|
|
|
+ tWhgenlegMapper.lockTheGoods(map.get("fId").toString());
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ Map<String, Object> goodsMaps = new HashMap<>();
|
|
|
+
|
|
|
+ // 库区
|
|
|
+ TWarehouse warehouse2 = new TWarehouse();
|
|
|
+ warehouse2.setfId(Long.valueOf(vo.getParentId()));
|
|
|
+ warehouse2 = tWarehouseMapper.getOne(warehouse2);
|
|
|
+ // 库位
|
|
|
+ TWarehouse warehouse3 = new TWarehouse();
|
|
|
+ warehouse3.setfId(Long.valueOf(vo.getFWarehouseLocationid()));
|
|
|
+ warehouse3 = tWarehouseMapper.getOne(warehouse3);
|
|
|
+
|
|
|
+ // 仓库
|
|
|
+ TWarehouse warehouse = new TWarehouse();
|
|
|
+ warehouse.setfId(warehouse2.getParentId());
|
|
|
+ warehouse = tWarehouseMapper.getOne(warehouse);
|
|
|
+ DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+ Date date = null;
|
|
|
+ try {
|
|
|
+ date = df.parse(vo.getFOriginalbilldate());
|
|
|
+ } catch (ParseException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+
|
|
|
+ TGoods goods = tGoodsMapper.getById(vo.getGoodsId());
|
|
|
+ Map<String, String> map = new HashMap<>();
|
|
|
+ map.put("name", goods.getfName());
|
|
|
+ map.put("spec", goods.getfPackagespecs());
|
|
|
+ map.put("producer", "无");
|
|
|
+ map.put("brand", "无");
|
|
|
+ map.put("level", "无");
|
|
|
+
|
|
|
+ SysDictData sysDictData = new SysDictData();
|
|
|
+ sysDictData.setDictType("data_goods_category");
|
|
|
+ sysDictData.setDictValue(vo.getSpu());
|
|
|
+
|
|
|
+ goodsMaps.put("spuId", vo.getSpu());
|
|
|
+ goodsMaps.put("skuId", vo.getSku());
|
|
|
+ goodsMaps.put("skuName", goods.getfName());
|
|
|
+ goodsMaps.put("billOfLading", vo.getFMblno());
|
|
|
+ goodsMaps.put("goodsWeight", Double.parseDouble(vo.getFGrossweightD()));
|
|
|
+ goodsMaps.put("goodsQuantity", Integer.parseInt(vo.getFQtyD()));
|
|
|
+ goodsMaps.put("quantityUnit", "个");
|
|
|
+ goodsMaps.put("weightUnit", "吨");
|
|
|
+ goodsMaps.put("warehouseCode", warehouse.getfId());
|
|
|
+ goodsMaps.put("warehouseName", warehouse.getfName());
|
|
|
+ // 仓库地址
|
|
|
+ goodsMaps.put("warehouseAddress", warehouse.getfAddr());
|
|
|
+ goodsMaps.put("areaName", warehouse2.getfName());
|
|
|
+ goodsMaps.put("areaCode", warehouse2.getfNo());
|
|
|
+ goodsMaps.put("slotName", warehouse3.getfName());
|
|
|
+ goodsMaps.put("slotCode", warehouse3.getfNo());
|
|
|
+ goodsMaps.put("preInOutReceiptId", vo.getFOriginalbillno());
|
|
|
+ goodsMaps.put("spuProperties", map);
|
|
|
+ goodsMaps.put("productDate", vo.getFOriginalbilldate());
|
|
|
+ goodsMaps.put("arrivalTime", vo.getFOriginalbilldate());
|
|
|
+ goodsMaps.put("remark", vo.getRemark());
|
|
|
+
|
|
|
+ // 入库单号
|
|
|
+ goodsMaps.put("enterCode", vo.getFBillno());
|
|
|
+
|
|
|
+ goodsMap.add(goodsMaps);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+// List<Map<String, Object>> goodsMapTwo = new ArrayList<>();
|
|
|
+// for (int i = 0; i < goodsMap.size(); i++) {
|
|
|
+// if (i == 0) {
|
|
|
+// goodsMapTwo.add(goodsMap.get(i));
|
|
|
+// continue;
|
|
|
+// }
|
|
|
+//
|
|
|
+// boolean isRepeat = false;
|
|
|
+// for (Map<String, Object> z : goodsMapTwo) {
|
|
|
+// Map<String, Object> x = goodsMap.get(i);
|
|
|
+// if (x.get("spuId").toString().equals(z.get("spuId").toString()) &&
|
|
|
+// x.get("skuId").toString().equals(z.get("skuId").toString()) &&
|
|
|
+// x.get("billOfLading").toString().equals(z.get("billOfLading").toString())) {
|
|
|
+// isRepeat = true;
|
|
|
+//
|
|
|
+// // 数量
|
|
|
+// BigDecimal bigDecimal = new BigDecimal(x.get("goodsQuantity").toString());
|
|
|
+// BigDecimal bigDecimal2 = new BigDecimal(z.get("goodsQuantity").toString());
|
|
|
+// z.put("goodsQuantity", bigDecimal.add(bigDecimal2).intValue());
|
|
|
+//
|
|
|
+// // 重量
|
|
|
+// BigDecimal goodsWeight = new BigDecimal(x.get("goodsWeight").toString());
|
|
|
+// BigDecimal goodsWeight2 = new BigDecimal(z.get("goodsWeight").toString());
|
|
|
+// z.put("goodsQuantity", goodsWeight.add(goodsWeight2).doubleValue());
|
|
|
+//
|
|
|
+// // 入库单号
|
|
|
+// String enterCode = z.get("enterCode").toString();
|
|
|
+// String enterCode1 = x.get("enterCode").toString();
|
|
|
+// z.put("enterCode", enterCode + "," + enterCode1);
|
|
|
+// }
|
|
|
+// }
|
|
|
+//
|
|
|
+// if (isRepeat) {
|
|
|
+// goodsMapTwo.add(goodsMap.get(i));
|
|
|
+// }
|
|
|
+// }
|
|
|
+
|
|
|
+ reqBody.put("skuItems", goodsMap);
|
|
|
+// reqBody.put("skuItems", goodsMapTwo);
|
|
|
+
|
|
|
+ // 公钥
|
|
|
+ String appKey = "D0fJZ22Gn4BTE7qd";
|
|
|
+ // 请求地址
|
|
|
+ String url = "https://sdpftz-console-test.pub.jdtiot.com/open/wms/receiptDistributeGoodsResult";
|
|
|
+
|
|
|
+ String appSecret = "Qrgx3tn2tGqdIkvwIK0rcdckdYDG3caF";
|
|
|
+
|
|
|
+ String timestamp = String.valueOf(new Date().getTime());
|
|
|
+ String signPlainText = "appKey=" + appKey + "×tamp=" + timestamp + "&uri=/open/wms/receiptDistributeGoodsResult&appSecret=" + appSecret;
|
|
|
+ Map<String, String> map = new HashMap<>();
|
|
|
+ map.put("appKey", appKey);
|
|
|
+ map.put("timestamp", timestamp);
|
|
|
+ map.put("uri", "/open/wms/receiptDistributeGoodsResult");
|
|
|
+ // 加密
|
|
|
+ String md5Upper = DigestUtils.md5DigestAsHex(signPlainText.getBytes(StandardCharsets.UTF_8));
|
|
|
+ md5Upper = md5Upper.toUpperCase();
|
|
|
+ map.put("sign", md5Upper);
|
|
|
+
|
|
|
+ String str = JsonUtil.toJson(reqBody);
|
|
|
+ JSONObject jsonObject = null;
|
|
|
+ // 发送请求
|
|
|
+ try {
|
|
|
+ System.out.println("=====================发送请求=======================");
|
|
|
+ System.out.println("发送时间:" + new Date());
|
|
|
+ System.out.println("请求url:" + url);
|
|
|
+ System.out.println("sign明文:" + signPlainText);
|
|
|
+ System.out.println("请求头:" + map);
|
|
|
+ System.out.println("请求体:" + str);
|
|
|
+ jsonObject = HttpClientUtils.doPost(url, map, JSONObject.parseObject(str));
|
|
|
+ System.out.println("=====================发送完成=======================");
|
|
|
+ } catch (IOException e) {
|
|
|
+ System.out.println("发送请求失败");
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ }
|
|
|
+ if (jsonObject == null) {
|
|
|
+ return new AjaxResult(400, "没有收到返回值");
|
|
|
+ }
|
|
|
+ System.out.println("msg:" + jsonObject.get("msg"));
|
|
|
+ if (!"OK".equals(jsonObject.get("msg"))) {
|
|
|
+ return new AjaxResult(400, "请求失败");
|
|
|
+ }
|
|
|
+
|
|
|
+ warehouseVO.setFBillstatus("5");
|
|
|
+ warehouseBillsMapper.updateOperationTypeByFid(warehouseVO);
|
|
|
+
|
|
|
+
|
|
|
+ return new AjaxResult(200, "完成");
|
|
|
+ }
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private CollateralMapper collateralMapper;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Transactional
|
|
|
+ public AjaxResult collateralCargoInformation(AddCollateralGoodsVO vo) {
|
|
|
+ collateralMapper.deleteByPid(vo.getPid());
|
|
|
+ List<CollateralGoodsVO> voList = vo.getList();
|
|
|
+ for (CollateralGoodsVO collateralGoodsVO : voList) {
|
|
|
+ collateralMapper.insetInto(collateralGoodsVO);
|
|
|
+ }
|
|
|
+
|
|
|
+ return new AjaxResult(200, "保存成功");
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public AjaxResult getCollateralGoodsBypid(String pid) {
|
|
|
+ List<CollateralGoodsVO> collateralGoodsList = collateralMapper.selectByPid(pid);
|
|
|
+// new ArrayList<>()
|
|
|
+
|
|
|
+ return new AjaxResult(200, "查询成功", collateralGoodsList);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public AjaxResult masterSuppressThePreservationOfGoods(TWarehouseBills warehouseBills) {
|
|
|
+ warehouseBillsMapper.foreclosurePreservation(warehouseBills);
|
|
|
+ return new AjaxResult(200, "保存成功");
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* RSA 签名
|
|
|
*
|