Explorar el Código

耗材管理增加数量和总金额

wanxl hace 1 año
padre
commit
8649fe70e1

+ 16 - 2
src/main/java/com/repair/controller/RepairConsumablesController.java

@@ -2,6 +2,8 @@ package com.repair.controller;
 
 
 import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.repair.api.RepairConsumablesControllerAPI;
 import com.repair.common.utils.*;
 import com.repair.model.enumModel.eIsSuper;
@@ -20,6 +22,7 @@ import com.repair.services.*;
 import org.apache.poi.ss.usermodel.Workbook;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.transaction.annotation.Transactional;
+import org.springframework.util.StringUtils;
 import org.springframework.validation.BindingResult;
 import org.springframework.web.bind.annotation.RequestHeader;
 import org.springframework.web.bind.annotation.RestController;
@@ -159,8 +162,19 @@ public class RepairConsumablesController implements RepairConsumablesControllerA
             //当返回值大于0时,表示BigDecimal对象大于指定的数值。
             data.setStatu(data.getTotalPrice().compareTo(BigDecimal.ZERO) > 0 ? "有偿" : "无偿");
         }
-
-        return CommonResult.ok(result);
+        JSONObject jsonObject=(JSONObject) JSONObject.toJSON(result);
+        QueryWrapper<RepairConsumables> ew = new QueryWrapper<>();
+        if(StringUtils.hasText(endTime)&&StringUtils.hasText(startTime)){
+            ew.between("update_time",startTime,endTime);
+        }
+        if (StringUtils.hasText(keyWord)) {
+            String str ="record_id  in (select id from   repair_record rr where  rr.deleted = 0 and rr.record_no like '%" + keyWord + "%')";
+            ew.and(w -> w.like("consume_name", keyWord).or().apply(str));
+        }
+        ew.select("IFNULL(sum(number),0) tcont,IFNULL(sum(total_price),0) tprice");
+        Map<String,Object> map=repairConsumablesService.getMap(ew);
+        jsonObject.putAll(map);
+        return CommonResult.ok(jsonObject);
     }
 
     /**