chenlu
12 小时以前 94c0a729da1b88ab4a0067f1e14a00264e0447cf
north-glass-erp/src/main/java/com/example/erp/service/sd/BomDataService.java
@@ -1,11 +1,11 @@
package com.example.erp.service.sd;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.example.erp.entity.sd.BasicData;
import com.example.erp.entity.sd.BasicOtherMoney;
import com.example.erp.entity.sd.BomBase;
import com.example.erp.entity.sd.Customer;
import com.example.erp.entity.pp.FlowCard;
import com.example.erp.entity.sd.*;
import com.example.erp.mapper.sd.BomDataMapper;
import com.example.erp.mapper.sd.BasicOtherMoneyMapper;
import com.example.erp.mapper.sd.CustomerMapper;
@@ -34,14 +34,21 @@
        Object consume =  object.get("consume");
        Object price =  object.get("price");
        Integer type = (Integer) object.get("type");
        String unit="";
        if (type.equals(1)){
            unit = "㎡";
        } else if (type.equals(2)) {
            unit = "m";
        } else if (type.equals(3)) {
            unit = "片";
        }
        if (id!=null){
            //查询物料编号是否已存在
            Integer countId =  bomDataMapper.getMaterialId(id);
            if (countId == 0){
                bomDataMapper.saveMaterialBomDataMp(id,name,consume,price,type);
                bomDataMapper.saveMaterialBomDataMp(id,name,consume,price,type,unit);
            }else {
                bomDataMapper.updateMaterialBomDataMp(id,name,consume,price,type);
                bomDataMapper.updateMaterialBomDataMp(id,name,consume,price,type,unit);
            }
            return true;
@@ -64,12 +71,44 @@
                    Object produceId = row.get("produceId");
                    Object tabId = row.get("tabId");
                    Object layer = row.get("layer");
                    if (tabId!=null){
                        bomDataMapper.saveProductBOMMp(produceId,tabId,layer);
                    }
                    bomDataMapper.saveProductBOMMp(produceId,tabId,layer);
                }
            }
        }
        return true;
    }
    public Map<String, Object> getOrderBomDataSv(String orderId) {
        Map<String, Object> map = new HashMap<>();
        map.put("data", bomDataMapper.getOrderBomDataMp(orderId));
        map.put("sumData", bomDataMapper.getOrderBomSumDataMp(orderId));
        map.put("sumDataDatils", bomDataMapper.getOrderBomsumDataDatilsMp(orderId));
        return map;
    }
    public Map<String, Object> getBomDataProductSv(Map<String, Object> object) {
        Map<String, Object> map = new HashMap<>();
        List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
        List<OrderDetail> orderDetailsList = JSONArray.parseArray(JSONObject.toJSONString(object.get("productName")), OrderDetail.class);
        if (!orderDetailsList.isEmpty()) {
            for (OrderDetail od : orderDetailsList) {
                Map<String, Object> itemmap = new HashMap<>();
                itemmap.put("data", bomDataMapper.getBOMDetails(od.getProductId(),od.getOrderId()));
                list.add(itemmap);
            }
        }
        map.put("data", list);
        return map;
    }
    public Map<String, Object> editProductBOMSv(String produceId) {
        Map<String, Object> map = new HashMap<>();
        map.put("data", bomDataMapper.getEditProductBOMSv(produceId));
        return map;
    }
}