Browse Source

成本报表 添加更新查询

liuchaohui 2 years ago
parent
commit
67b383c82f

+ 14 - 6
jeecg-boot-module-system/src/main/java/org/jeecg/modules/cost/controller/SyCostAllocationController.java

@@ -1,5 +1,6 @@
 package org.jeecg.modules.cost.controller;
 
+import com.alibaba.fastjson.JSON;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
@@ -18,6 +19,7 @@ import org.jeecg.common.util.oConvertUtils;
 import org.jeecg.modules.cost.entity.*;
 import org.jeecg.modules.cost.service.*;
 import org.jeecg.modules.cost.vo.SyCostAllocationPage;
+import org.jeecg.modules.report.entity.FabricLoss;
 import org.jeecgframework.poi.excel.ExcelImportUtil;
 import org.jeecgframework.poi.excel.def.NormalExcelConstants;
 import org.jeecgframework.poi.excel.entity.ExportParams;
@@ -35,10 +37,7 @@ import springfox.documentation.spring.web.json.Json;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 
 /**
  * @Description: 成本分配
@@ -102,12 +101,21 @@ public class SyCostAllocationController {
             throw new JeecgBootException("计划号不能为空!");
         }
         if(type.equals("query")){
+            List<SyCostJson> list = syCostAllocationService.queryByCostJson(plannum,0,1);
+            if(list.size()>0){
+                syCostAllocation = JSON.parseObject(JSON.toJSONString(list.get(0).getCostInfo()), SyCostAllocation.class);
+                Result.OK(syCostAllocation);
+            }else {
+                syCostAllocation=syCostAllocationService.queryByPlanNum(plannum,type);
+                if(syCostAllocation==null){
+                    return result.error500("找不到对应计划单号!!!");
+                }
+            }
+        }else if(type.equals("queryNew")){
             syCostAllocation=syCostAllocationService.queryByPlanNum(plannum,type);
             if(syCostAllocation==null){
                 return result.error500("找不到对应计划单号!!!");
             }
-        }else if(type.equals("add")){
-
         }
         return Result.OK(syCostAllocation);
     }