hanqingsong 5 роки тому
батько
коміт
e6f5693604

+ 16 - 0
src/main/java/com/chinaitop/depot/business/controller/BusinessDrugStandingBookController.java

@@ -1,5 +1,6 @@
1 1
 package com.chinaitop.depot.business.controller;
2 2
 
3
+import com.alibaba.fastjson.JSON;
3 4
 import com.chinaitop.depot.business.model.BusinessDrugStandingBook;
4 5
 import com.chinaitop.depot.business.model.BusinessDrugStandingBookExample;
5 6
 import com.chinaitop.depot.business.service.BusinessDrugStandingBookService;
@@ -120,6 +121,21 @@ public class BusinessDrugStandingBookController {
120 121
         return pageInfo;
121 122
     }
122 123
 
124
+    /**
125
+     * 获取台账剩余存数量.
126
+     *
127
+     * @param drugStandingBookJson
128
+     * @return
129
+     */
130
+    @RequestMapping(value = "/getRemainingQuantity", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
131
+    @ApiOperation(value = "台账剩余存数量", notes = "台账剩余存数量")
132
+    @ApiImplicitParams({
133
+            @ApiImplicitParam(name = "drugStandingBook", value = "台账对象json", paramType = "query")
134
+    })
135
+    public Integer getRemainingQuantity(String drugStandingBookJson) {
136
+        BusinessDrugStandingBook drugStandingBook = JSON.parseObject(drugStandingBookJson, BusinessDrugStandingBook.class);
137
+        return drugStandingBookService.getRemainingQuantity(drugStandingBook);
138
+    }
123 139
 
124 140
     /**
125 141
      * 生产装备汇总统计

+ 10 - 0
src/main/java/com/chinaitop/depot/business/service/BusinessDrugStandingBookService.java

@@ -84,4 +84,14 @@ public interface BusinessDrugStandingBookService {
84 84
      * @param drugDestroy
85 85
      */
86 86
     void countByDrugDestroy(BusinessDrugDestroy drugDestroy);
87
+
88
+    /**
89
+     * 获取台账剩余存数量.
90
+     *
91
+     * @param drugStandingBook
92
+     * @return
93
+     * @throws Exception
94
+     */
95
+    Integer getRemainingQuantity(BusinessDrugStandingBook drugStandingBook);
96
+
87 97
 }

+ 43 - 0
src/main/java/com/chinaitop/depot/business/service/impl/BusinessDrugStandingBookServiceImpl.java

@@ -4,10 +4,12 @@ import com.chinaitop.depot.business.mapper.BusinessDrugStandingBookMapper;
4 4
 import com.chinaitop.depot.business.model.*;
5 5
 import com.chinaitop.depot.business.service.BusinessDrugStandingBookService;
6 6
 import com.github.pagehelper.PageHelper;
7
+import org.apache.commons.lang.StringUtils;
7 8
 import org.springframework.beans.factory.annotation.Autowired;
8 9
 import org.springframework.stereotype.Service;
9 10
 
10 11
 import javax.servlet.http.HttpServletRequest;
12
+import java.lang.reflect.Field;
11 13
 import java.util.Date;
12 14
 import java.util.List;
13 15
 import java.util.Map;
@@ -447,5 +449,46 @@ public class BusinessDrugStandingBookServiceImpl implements BusinessDrugStanding
447 449
 
448 450
     }
449 451
 
452
+    /**
453
+     * 获取台账剩余存数量.
454
+     *
455
+     * @param drugStandingBook
456
+     * @return
457
+     */
458
+    @Override
459
+    public Integer getRemainingQuantity(BusinessDrugStandingBook drugStandingBook) {
460
+        BusinessDrugStandingBookExample example = getExapleObject(drugStandingBook);
461
+        List<BusinessDrugStandingBook> businessDrugStandingBooks = drugStandingBookMapper.selectByExample(example);
462
+        if (businessDrugStandingBooks.size() > 0)
463
+            return businessDrugStandingBooks.get(0).getAmount(); // 台账剩余存数量
464
+        return 0;
465
+    }
466
+
467
+    // 查询条件
468
+    private synchronized BusinessDrugStandingBookExample getExapleObject(BusinessDrugStandingBook drugStandingBook) {
469
+        BusinessDrugStandingBookExample example = new BusinessDrugStandingBookExample();
470
+        if (drugStandingBook != null) {
471
+            BusinessDrugStandingBookExample.Criteria createCriteria = example.createCriteria();
472
+            // 查询条件
473
+            createCriteria.andIsLastShelfDataEqualTo(1); // 是否是最后的货架号盘点数据
474
+            Integer orgId = drugStandingBook.getOrgId();
475
+            if (null != orgId)
476
+                createCriteria.andOrgIdEqualTo(orgId); // 组织编码
477
+            Integer drugName = drugStandingBook.getDrugName();
478
+            if (null != drugName)
479
+                createCriteria.andDrugNameEqualTo(drugName); // 药剂名称 drug_name
480
+            Integer drugType = drugStandingBook.getDrugType();
481
+            if (null != drugType)
482
+                createCriteria.andDrugTypeEqualTo(drugType); // 药剂形态 drug_type
483
+            Integer drugKind = drugStandingBook.getDrugKind();
484
+            if (null != drugKind)
485
+                createCriteria.andDrugKindEqualTo(drugKind); // 药剂类型 drug_kind
486
+            String manufacturer = drugStandingBook.getManufacturer();
487
+            if (StringUtils.isNotBlank(manufacturer))
488
+                createCriteria.andManufacturerEqualTo(manufacturer); // 生产厂家 manufacturer
489
+        }
490
+        return example;
491
+    }
492
+
450 493
 
451 494
 }