| | |
| | | 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; |
| | |
| | | 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; |
| | |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | public Object saveProductBOMSv(Map<String, Object> object) { |
| | | // 遍历每个产品 |
| | | for (Map.Entry<String, Object> entry : object.entrySet()) { |
| | | String productName = entry.getKey(); |
| | | Object value = entry.getValue(); |
| | | |
| | | if (value instanceof List) { |
| | | List<Map<String, Object>> rows = (List<Map<String, Object>>) value; |
| | | |
| | | for (Map<String, Object> row : rows) { |
| | | // 取每条数据 |
| | | Object produceId = row.get("produceId"); |
| | | Object tabId = row.get("tabId"); |
| | | Object layer = row.get("layer"); |
| | | if (tabId!=null){ |
| | | 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; |
| | | } |
| | | } |