|
@@ -1,6 +1,7 @@
|
|
|
package com.steerinfo.dil.service.impl;
|
|
|
|
|
|
|
|
|
+import com.alibaba.excel.EasyExcel;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.steerinfo.dil.feign.BmsTruckFeign;
|
|
|
import com.steerinfo.dil.mapper.OyeInboundResultMapper;
|
|
@@ -13,13 +14,17 @@ import com.steerinfo.dil.model.OyeRealtimeInventory;
|
|
|
import com.steerinfo.dil.model.TmstruckWeightBatch;
|
|
|
import com.steerinfo.dil.service.IOyeResultService;
|
|
|
import com.steerinfo.dil.util.DataChange;
|
|
|
+import com.steerinfo.dil.util.EasyExcelUtils;
|
|
|
import com.sun.org.apache.bcel.internal.generic.RETURN;
|
|
|
+import org.omg.PortableInterceptor.SUCCESSFUL;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import javax.xml.crypto.Data;
|
|
|
import java.math.BigDecimal;
|
|
|
+import java.net.URLEncoder;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
|
|
|
|
@Service
|
|
@@ -171,6 +176,10 @@ public class OyeResultServiceImpl implements IOyeResultService {
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public synchronized String insertOutboundResult(Map<String,Object> mapValue) throws Exception {
|
|
|
+ if (DataChange.dataToBigDecimal(mapValue.get("reUpdateOutBound")).intValue() == 1) {
|
|
|
+ reUpdateOutBound(mapValue);
|
|
|
+ return "操作成功";
|
|
|
+ }
|
|
|
List<OyeOutboundResult> oyeOutboundResults = new ArrayList<>();
|
|
|
List<TmstruckWeightBatch> tmstruckWeightBatches = new ArrayList<>();
|
|
|
List<OyeRealtimeInventory> oyeRealtimeInventories = new ArrayList<>();
|
|
@@ -218,7 +227,6 @@ public class OyeResultServiceImpl implements IOyeResultService {
|
|
|
oyeOutboundResult.setInboundArea(map.get("inboundArea").toString());
|
|
|
oyeOutboundResult.setInboundWarehouse(map.get("inboundWarehouse").toString());
|
|
|
oyeOutboundResult.setSaleMaterialId(DataChange.dataToBigDecimal(map.get("saleMaterialId")));
|
|
|
-
|
|
|
//更新制单日期
|
|
|
oyeOutboundResult.setMeter(meter);
|
|
|
oyeOutboundResult.setMaterialId(materialId);
|
|
@@ -325,6 +333,10 @@ public class OyeResultServiceImpl implements IOyeResultService {
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public synchronized String updateInsertRealTime(Map<String, Object> map) throws Exception{
|
|
|
+ System.out.println("===========" + new Date());
|
|
|
+ JSONObject jsonObject = new JSONObject(map);
|
|
|
+ System.out.println(jsonObject);
|
|
|
+ System.out.println("===========" + new Date());
|
|
|
// 划分实时库存数据
|
|
|
// 针对原先的库存,需要进行出库;针对划分后的库存需要进行入库;先出后入;
|
|
|
// 创建出库需要的数据;
|
|
@@ -416,6 +428,8 @@ public class OyeResultServiceImpl implements IOyeResultService {
|
|
|
return "操作成功";
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public List<Map<String, Object>> receiveSendReport(Map<String, Object> map) {
|
|
|
return oyeRealtimeInventoryMapper.receiveSendReport(map);
|
|
@@ -465,4 +479,94 @@ public class OyeResultServiceImpl implements IOyeResultService {
|
|
|
}
|
|
|
return 1;
|
|
|
}
|
|
|
+
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public int reUpdateOutBound(Map<String, Object> mapValue) throws Exception {
|
|
|
+ List<OyeOutboundResult> oyeOutboundResults = new ArrayList<>();
|
|
|
+ List<TmstruckWeightBatch> tmstruckWeightBatches = new ArrayList<>();
|
|
|
+ List<OyeRealtimeInventory> oyeRealtimeInventories = new ArrayList<>();
|
|
|
+ List<Map<String,Object>> mapList = (List<Map<String,Object>>) mapValue.get("mapList");
|
|
|
+ System.out.println("===========" + new Date());
|
|
|
+ JSONObject jsonObject = new JSONObject(mapValue);
|
|
|
+ System.out.println(jsonObject);
|
|
|
+ System.out.println("===========" + new Date());
|
|
|
+ for (Map<String,Object> map : mapList) {
|
|
|
+ BigDecimal resultId = DataChange.dataToBigDecimal(map.get("resultId"));
|
|
|
+ BigDecimal weightBatchId = DataChange.dataToBigDecimal(map.get("weightBatchId"));
|
|
|
+ //判断有没有实绩ID
|
|
|
+ if(resultId == null || resultId.intValue() == 0) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ //获取前端传输过来的件数、理重、净重
|
|
|
+ BigDecimal materialNumber = DataChange.dataToBigDecimal(map.get("materialNumber"));
|
|
|
+ BigDecimal theoryWeight = DataChange.dataToBigDecimal(map.get("theoryWeight"));
|
|
|
+ BigDecimal netWeight = DataChange.dataToBigDecimal(map.get("netWeight"));
|
|
|
+ if(materialNumber == null || materialNumber.intValue() == 0) {
|
|
|
+ throw new Exception("物资件数错误");
|
|
|
+ }
|
|
|
+ if(theoryWeight == null || theoryWeight.intValue() == 0) {
|
|
|
+ throw new Exception("理重信息错误");
|
|
|
+ }
|
|
|
+ if(netWeight == null || netWeight.intValue() == 0) {
|
|
|
+ throw new Exception("净重信息错误");
|
|
|
+ }
|
|
|
+ //根据实绩id获取件数、理重、净重
|
|
|
+ Map<String,Object> oldMes = oyeOutboundResultMapper.getOldMes(resultId);
|
|
|
+ BigDecimal netWeightSub = netWeight.subtract(DataChange.dataToBigDecimal(oldMes.get("netWeight")));
|
|
|
+ BigDecimal theoryWeightSub = theoryWeight.subtract(DataChange.dataToBigDecimal(oldMes.get("theoryWeight")));
|
|
|
+ if (netWeightSub.compareTo(new BigDecimal(0)) == 0 && theoryWeightSub.compareTo(new BigDecimal(0)) == 0) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ OyeOutboundResult oyeOutboundResult = oyeOutboundResultMapper.selectByPrimaryKey(resultId);
|
|
|
+ oyeOutboundResult.setTheoryWeight(theoryWeight);
|
|
|
+ oyeOutboundResult.setNetWeight(netWeight);
|
|
|
+ oyeOutboundResult.setMaterialNumber(materialNumber);
|
|
|
+ oyeOutboundResult.setUpdateTime(new Date());
|
|
|
+ map.put("flag",2);
|
|
|
+ Map<String, Object> updateRealMap = new HashMap<>();
|
|
|
+ updateRealMap.put("inventoryId",oldMes.get("inventoryId"));
|
|
|
+ updateRealMap.put("materialNumber",materialNumber.subtract(DataChange.dataToBigDecimal(oldMes.get("materialNumber"))));
|
|
|
+ updateRealMap.put("netWeight",netWeightSub);
|
|
|
+ updateRealMap.put("theoryWeight",theoryWeightSub);
|
|
|
+ OyeRealtimeInventory oyeRealtimeInventory = updateRealTimeInventory(updateRealMap);
|
|
|
+ oyeRealtimeInventories.add(oyeRealtimeInventory);
|
|
|
+ TmstruckWeightBatch tmstruckWeightBatch = tmstruckWeightBatchMapper.selectByPrimaryKey(weightBatchId);
|
|
|
+ tmstruckWeightBatch.setBatchNetWeight(netWeight);
|
|
|
+ tmstruckWeightBatches.add(tmstruckWeightBatch);
|
|
|
+ Map<String, Object> updateMap = new HashMap<>();
|
|
|
+ updateMap.put("weightBatchId",tmstruckWeightBatch.getWeightBatchId());
|
|
|
+ updateMap.put("materialNumber",materialNumber);
|
|
|
+ updateMap.put("saleMaterialId",DataChange.dataToBigDecimal(map.get("saleMaterialId")));
|
|
|
+ updateMap.put("materialWeight",theoryWeight);
|
|
|
+ oyeOutboundResultMapper.updateSaleMakeDate1(updateMap);
|
|
|
+ oyeOutboundResultMapper.updateOrderStatus(DataChange.dataToBigDecimal(map.get("orderId")));
|
|
|
+ oyeOutboundResults.add(oyeOutboundResult);
|
|
|
+ }
|
|
|
+ oyeOutboundResultMapper.batchUpdate(oyeOutboundResults);
|
|
|
+ oyeRealtimeInventoryMapper.batchUpdate(oyeRealtimeInventories);
|
|
|
+ tmstruckWeightBatchMapper.batchUpdate(tmstruckWeightBatches);
|
|
|
+ return 1;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ //public int exportExcel() {
|
|
|
+ // Calendar calendar = Calendar.getInstance();
|
|
|
+ // int year = calendar.get(Calendar.YEAR);
|
|
|
+ // int month = calendar.get(Calendar.MONTH) + 1;
|
|
|
+ // int day = calendar.get(Calendar.DAY_OF_MONTH);
|
|
|
+ // SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+ // String dateStr = simpleDateFormat.format(calendar.getTime());
|
|
|
+ // response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
|
|
+ // response.setCharacterEncoding("utf-8");
|
|
|
+ // String fileName = URLEncoder.encode(year + "" + month + "" + day + "运输单价", "UTF-8").replaceAll("\\+", "%20");
|
|
|
+ // response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx");
|
|
|
+ // EasyExcel.write(response.getOutputStream(), AmsTransPrice.class).sheet(dateStr + "运输单价").
|
|
|
+ // registerWriteHandler(new CustomCellWriteWidthConfig()).registerWriteHandler(new CustomCellWriteHeightConfig()).
|
|
|
+ // registerWriteHandler(EasyExcelUtils.getStyleStrategy()).
|
|
|
+ // doWrite(list);
|
|
|
+ // return success();
|
|
|
+ //}
|
|
|
}
|