|
@@ -18,6 +18,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import java.math.BigDecimal;
|
|
|
+import java.math.RoundingMode;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
|
|
|
@@ -532,6 +533,114 @@ public class OyeResultServiceImpl implements IOyeResultService {
|
|
|
}
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
+ * 新厂钢材入库
|
|
|
+ * @param map
|
|
|
+ * @return
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public synchronized String putNewFactory(Map<String, Object> map) throws Exception{
|
|
|
+ map.put("inboundArea", "欧冶库");
|
|
|
+ System.out.println("+++++++++++" + new Date());
|
|
|
+ JSONObject jsonObject = new JSONObject(map);
|
|
|
+ System.out.println(jsonObject);
|
|
|
+ System.out.println("+++++++++++" + new Date());
|
|
|
+ // 新增新厂钢材入库数据
|
|
|
+ //客户ID
|
|
|
+ BigDecimal consigneeId = DataChange.dataToBigDecimal(map.get("consigneeId"));
|
|
|
+ //片区
|
|
|
+ String saleArea = map.get("saleArea") == null ? "" : map.get("saleArea").toString();
|
|
|
+ //仓库
|
|
|
+ String inboundWarehouse = map.get("inboundWarehouse") == null ? "" : map.get("inboundWarehouse").toString();
|
|
|
+ //物资信息
|
|
|
+ BigDecimal materialId = DataChange.dataToBigDecimal(map.get("materialId"));
|
|
|
+ String materialName = map.get("materialName") == null ? "" : map.get("materialName").toString();
|
|
|
+ BigDecimal meter = DataChange.dataToBigDecimal(map.get("meter"));
|
|
|
+ //入库件数
|
|
|
+ BigDecimal materialNumber = DataChange.dataToBigDecimal(map.get("materialNumber"));
|
|
|
+ //入库净重
|
|
|
+ BigDecimal netWeight = DataChange.dataToBigDecimal(map.get("netWeight"));
|
|
|
+ if(!(consigneeId.doubleValue() > 0)) {
|
|
|
+ throw new Exception("客户不能为空!");
|
|
|
+ }
|
|
|
+ if(saleArea.isEmpty()){
|
|
|
+ throw new Exception("片区不能为空!");
|
|
|
+ }
|
|
|
+ if(inboundWarehouse.isEmpty()){
|
|
|
+ throw new Exception("仓库不能为空!");
|
|
|
+ }
|
|
|
+ if(!(materialNumber.doubleValue() > 0)) {
|
|
|
+ throw new Exception("物资件数错误!");
|
|
|
+ }
|
|
|
+ //重量划拨,允许件数为0
|
|
|
+ if(!(materialId.doubleValue() > 0)) {
|
|
|
+ throw new Exception("物资不能为空!");
|
|
|
+ }
|
|
|
+ if(!(netWeight.doubleValue() > 0)) {
|
|
|
+ throw new Exception("物资净重不能为空!");
|
|
|
+ }
|
|
|
+ //入库理重
|
|
|
+ BigDecimal theoryWeight;
|
|
|
+ //单件理重
|
|
|
+ BigDecimal singleWeight;
|
|
|
+ if(materialName.contains("定尺")){
|
|
|
+ singleWeight = DataChange.dataToBigDecimal(map.get("singleWeight"));
|
|
|
+ if(!(singleWeight.doubleValue() > 0)){
|
|
|
+ throw new RuntimeException("定尺类必须输入单件理重!");
|
|
|
+ }
|
|
|
+ if(!(meter.doubleValue() > 0)){
|
|
|
+ throw new RuntimeException("定尺类必须输入米数!");
|
|
|
+ }
|
|
|
+ theoryWeight = singleWeight.multiply(materialNumber).setScale(3, RoundingMode.HALF_UP);
|
|
|
+ } else {
|
|
|
+ theoryWeight = DataChange.dataToBigDecimal(map.get("netWeight"));
|
|
|
+ singleWeight = theoryWeight.divide(materialNumber, 3, RoundingMode.HALF_UP);
|
|
|
+ }
|
|
|
+ // 创建入库需要的数据
|
|
|
+ OyeInboundResult oyeInboundResult = new OyeInboundResult();
|
|
|
+ oyeInboundResult.setResultId(oyeInboundResultMapper.getResultId());
|
|
|
+ oyeInboundResult.setInboundArea(map.get("inboundArea").toString());
|
|
|
+ oyeInboundResult.setConsigneeId(consigneeId);
|
|
|
+ oyeInboundResult.setSaleArea(saleArea);
|
|
|
+ oyeInboundResult.setInboundWarehouse(inboundWarehouse);
|
|
|
+ oyeInboundResult.setMeter(meter);
|
|
|
+ oyeInboundResult.setMaterialId(materialId);
|
|
|
+ oyeInboundResult.setSingleWeight(singleWeight);
|
|
|
+ oyeInboundResult.setTheoryWeight(theoryWeight);
|
|
|
+ oyeInboundResult.setNetWeight(netWeight);
|
|
|
+ oyeInboundResult.setMaterialNumber(materialNumber);
|
|
|
+ oyeInboundResult.setInsertUsername(map.get("userId") + "");
|
|
|
+ oyeInboundResult.setInsertTime(new Date());
|
|
|
+ oyeInboundResult.setAlternateFields2("新厂钢材入库");
|
|
|
+ oyeInboundResult.setCapacityNumbher("新厂钢材入库");
|
|
|
+ OyeRealtimeInventory oyeRealtimeInventoryInsert = null;
|
|
|
+ OyeRealtimeInventory oyeRealtimeInventoryUpdate = null;
|
|
|
+ //根据区域,客户,物资,单重,米数,仓库,库区查询实时库存在不在
|
|
|
+ BigDecimal inventoryId ;
|
|
|
+ inventoryId = oyeRealtimeInventoryMapper.getInventoryId(map);
|
|
|
+ if (inventoryId == null) {
|
|
|
+ //新增实时库存
|
|
|
+ map.put("flag",1);
|
|
|
+ oyeRealtimeInventoryInsert = insertRealTimeInventory(map);
|
|
|
+ oyeInboundResult.setInventoryId(oyeRealtimeInventoryInsert.getInventoryId());
|
|
|
+ }else{
|
|
|
+ map.put("inventoryId",inventoryId);
|
|
|
+ map.put("flag",1);
|
|
|
+ oyeRealtimeInventoryUpdate = updateRealTimeInventory(map);
|
|
|
+ oyeInboundResult.setInventoryId(oyeRealtimeInventoryUpdate.getInventoryId());
|
|
|
+ }
|
|
|
+ if (oyeRealtimeInventoryInsert != null) {
|
|
|
+ oyeRealtimeInventoryMapper.insertSelective(oyeRealtimeInventoryInsert);
|
|
|
+ }
|
|
|
+ if (oyeRealtimeInventoryUpdate != null) {
|
|
|
+ oyeRealtimeInventoryMapper.updateByPrimaryKeySelective(oyeRealtimeInventoryUpdate);
|
|
|
+ }
|
|
|
+ oyeInboundResultMapper.insertSelective(oyeInboundResult);
|
|
|
+ return "操作成功";
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public List<Map<String, Object>> receiveSendReport(Map<String, Object> map) {
|