Sfoglia il codice sorgente

新厂钢材入厂边库

xiaosonghong 3 mesi fa
parent
commit
756c604906

+ 13 - 0
src/main/java/com/steerinfo/dil/controller/OyeResultController.java

@@ -226,6 +226,19 @@ public class OyeResultController extends BaseRESTfulController {
         }
     }
 
+    @ApiOperation("新厂钢材入库")
+    @PostMapping("putNewFactory")
+    public RESTfulResult putNewFactory(@RequestBody Map<String,Object> map) {
+        String result;
+        try {
+            result = oyeResultService.putNewFactory(map);
+            return success(result);
+        } catch (Exception e) {
+            e.printStackTrace();
+            return failed(e.getMessage());
+        }
+    }
+
     @ApiOperation("定制报表数据,收发存")
     @PostMapping("receiveSendReport")
     public RESTfulResult receiveSendReport(@RequestBody Map<String,Object> map) {

+ 109 - 0
src/main/java/com/steerinfo/dil/service/impl/OyeResultServiceImpl.java

@@ -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) {

+ 1 - 1
src/main/resources/com/steerinfo/dil/mapper/OyeRealtimeInventoryMapper.xml

@@ -738,10 +738,10 @@
     </where>
     ORDER BY RC.CONSIGNEE_COMPANY_NAME desc,ORI.SALE_AREA desc
   </select>
+  <!--以下条件删除 AND ORI.SINGLE_WEIGHT = #{singleWeight,jdbcType=DECIMAL}-->
   <select id="getInventoryId" resultType="java.math.BigDecimal" parameterType="java.util.Map">
     SELECT ORI.INVENTORY_ID FROM OYE_REALTIME_INVENTORY ORI
     WHERE ORI.CONSIGNEE_ID = #{consigneeId,jdbcType=DECIMAL}
-    AND ORI.SINGLE_WEIGHT = #{singleWeight,jdbcType=DECIMAL}
     AND ORI.SALE_AREA = #{saleArea,jdbcType=VARCHAR}
     AND ORI.material_Id = #{materialId,jdbcType=DECIMAL}
     AND ORI.INBOUND_WAREHOUSE = #{inboundWarehouse,jdbcType=VARCHAR}