Просмотр исходного кода

[bug-3733]试剂耗材退货申请报错

szjbdgzl 1 год назад
Родитель
Сommit
5f00b1fd52

+ 1 - 1
ibps-provider-root/modules/provider-business/src/main/java/com/lc/ibps/components/reagent/api/IReagentConsumablesInventoryService.java

@@ -96,7 +96,7 @@ public interface IReagentConsumablesInventoryService {
 
 
 	@RequestMapping(value = "/takeStock", method = { RequestMethod.POST })
 	@RequestMapping(value = "/takeStock", method = { RequestMethod.POST })
 	public APIResult<List<Map<String,Object>>> takeStock(
 	public APIResult<List<Map<String,Object>>> takeStock(
-			@RequestParam(name = "ckId", required = false) String ckId,
+			@RequestParam(name = "ckId", required = false) String[] ckIds,
 			@RequestParam(name = "date", required = false) String date,
 			@RequestParam(name = "date", required = false) String date,
 			@RequestParam(name = "type", required = false) String type);
 			@RequestParam(name = "type", required = false) String type);
 
 

+ 2 - 2
ibps-provider-root/modules/provider-business/src/main/java/com/lc/ibps/components/reagent/provider/ReagentConsumablesInventoryProvider.java

@@ -225,14 +225,14 @@ public class ReagentConsumablesInventoryProvider extends GenericProvider impleme
 	@Override
 	@Override
 	public APIResult<List<Map<String,Object>>> takeStock(
 	public APIResult<List<Map<String,Object>>> takeStock(
 			@ApiParam(name = "ckId", value = "仓库id(多个用逗号隔开,为空查所有)", required = false)
 			@ApiParam(name = "ckId", value = "仓库id(多个用逗号隔开,为空查所有)", required = false)
-			@RequestParam(name = "ckId", required = false) String ckId,
+			@RequestParam(name = "ckId", required = false) String[] ckIds,
 			@ApiParam(name = "date", value = "盘点月份(默认当前月份)", required = false)
 			@ApiParam(name = "date", value = "盘点月份(默认当前月份)", required = false)
 			@RequestParam(name = "date", required = false) String date,
 			@RequestParam(name = "date", required = false) String date,
 			@ApiParam(name = "type", value = "备用(可忽略)", required = false)
 			@ApiParam(name = "type", value = "备用(可忽略)", required = false)
 			@RequestParam(name = "type", required = false) String type) {
 			@RequestParam(name = "type", required = false) String type) {
 		APIResult<List<Map<String,Object>>> result = new APIResult<>();
 		APIResult<List<Map<String,Object>>> result = new APIResult<>();
 		try {
 		try {
-			List<Map<String,Object>> list = takeStockService.takeStock( ckId , date , type );
+			List<Map<String,Object>> list = takeStockService.takeStock( ckIds , date , type );
 			result.setData(list);
 			result.setData(list);
 			result.setMessage("保存成功!");
 			result.setMessage("保存成功!");
 		} catch (Exception e) {
 		} catch (Exception e) {

+ 33 - 26
ibps-provider-root/modules/provider-business/src/main/java/com/lc/ibps/components/reagent/service/InventoryService.java

@@ -139,13 +139,13 @@ public class InventoryService extends GenericProvider {
         long currentQuantity = StrUtil.parseLongSafe(inventory.get("quantity"));
         long currentQuantity = StrUtil.parseLongSafe(inventory.get("quantity"));
         long currentWithhold = StrUtil.parseLongSafe(inventory.get("withhold"));
         long currentWithhold = StrUtil.parseLongSafe(inventory.get("withhold"));
         long available = currentQuantity - currentWithhold;
         long available = currentQuantity - currentWithhold;
+        String status = StrUtil.str(record.get("status"));
 
 
-        if (available < quantity) {
+        if (available < quantity && "start".equals(status)) {
             throw new Exception(record.get("ming_cheng_") + " 可用量不足!可用量:" + available + ",需要:" + quantity);
             throw new Exception(record.get("ming_cheng_") + " 可用量不足!可用量:" + available + ",需要:" + quantity);
         }
         }
 
 
         String inventoryId = StrUtil.str(inventory.get("id_"));
         String inventoryId = StrUtil.str(inventory.get("id_"));
-        String status = StrUtil.str(record.get("status"));
         if ("start".equals(status)) {
         if ("start".equals(status)) {
             linYongService.updateWithhold(inventoryId, currentWithhold + quantity);
             linYongService.updateWithhold(inventoryId, currentWithhold + quantity);
         } else if ("end".equals(status)) {
         } else if ("end".equals(status)) {
@@ -157,11 +157,12 @@ public class InventoryService extends GenericProvider {
         record.put("quantity", quantity);
         record.put("quantity", quantity);
         record.put("flow", status.isEmpty()?"not":status);
         record.put("flow", status.isEmpty()?"not":status);
         record.put("position", StrUtil.str(inventory.get("position")));
         record.put("position", StrUtil.str(inventory.get("position")));
-        addTrans(record);
+        updateTrans(record);
     }
     }
 
 
     private void handleMultipleInventories(List<Map<String, Object>> inventoryList, Map<String, Object> record) throws Exception {
     private void handleMultipleInventories(List<Map<String, Object>> inventoryList, Map<String, Object> record) throws Exception {
         long quantity = Long.parseLong(record.get("shu_liang_").toString());
         long quantity = Long.parseLong(record.get("shu_liang_").toString());
+        String status = StrUtil.str(record.get("status"));
         long totalAvailable = inventoryList.stream()
         long totalAvailable = inventoryList.stream()
                 .mapToLong(inv -> {
                 .mapToLong(inv -> {
                     long qty = StrUtil.parseLongSafe(inv.get("quantity"));
                     long qty = StrUtil.parseLongSafe(inv.get("quantity"));
@@ -170,12 +171,11 @@ public class InventoryService extends GenericProvider {
                 })
                 })
                 .sum();
                 .sum();
 
 
-        if (totalAvailable < quantity) {
+        if (totalAvailable < quantity && "start".equals(status)) {
             throw new Exception(record.get("ming_cheng_") + " 总可用量不足!总可用量:" + totalAvailable + ",需要:" + quantity);
             throw new Exception(record.get("ming_cheng_") + " 总可用量不足!总可用量:" + totalAvailable + ",需要:" + quantity);
         }
         }
 
 
         long remainingQuantity = quantity;
         long remainingQuantity = quantity;
-        String status = StrUtil.str(record.get("status"));
         for (Map<String, Object> inventory : inventoryList) {
         for (Map<String, Object> inventory : inventoryList) {
             if (remainingQuantity <= 0) break;
             if (remainingQuantity <= 0) break;
 
 
@@ -204,7 +204,7 @@ public class InventoryService extends GenericProvider {
             record.put("quantity", actualDeduction);
             record.put("quantity", actualDeduction);
             record.put("flow", status.isEmpty()?"not":status);
             record.put("flow", status.isEmpty()?"not":status);
             record.put("position", StrUtil.str(inventory.get("position")));
             record.put("position", StrUtil.str(inventory.get("position")));
-            addTrans(record);
+            updateTrans(record);
         }
         }
     }
     }
 
 
@@ -216,26 +216,33 @@ public class InventoryService extends GenericProvider {
         }
         }
     }
     }
 
 
-    public void addTrans(Map<String, Object> map) {
-        ReagentConsumablesTransactionPo tran = new ReagentConsumablesTransactionPo();
-        tran.setReagentCode(StrUtil.str(map.get("bian_ma_")));
-        tran.setQuantity(Long.parseLong(StrUtil.str(map.get("quantity"))));
-        String value1 = StrUtil.str(map.get("you_xiao_qi_"));
-        String value2 = StrUtil.str(map.get("you_xiao_qi_zhi_"));
-        String date = !value1.isEmpty() ? value1 : !value2.isEmpty() ? value2 : "";
-        tran.setExpDate(date);
-        tran.setPosition(StrUtil.str(map.get("position")));
-        tran.setStatus(StrUtil.str(map.get("type")));
-        tran.setType(Long.valueOf("-1"));
-        tran.setBoId(StrUtil.str(map.get("id_")));
-        tran.setDiDian(StrUtil.str(map.get("di_dian_")));
-        tran.setBatchNum(StrUtil.str(map.get("pi_hao_")));
-        tran.setInventoryId(StrUtil.str(map.get("inventory_id")));
-        tran.setFlow(StrUtil.str(map.get("flow")));
-
-        ReagentConsumablesTransaction transaction = reagentConsumablesTransactionRepository.newInstance();
-        transaction.setData(tran);
-        transaction.save();
+    public void updateTrans(Map<String, Object> map) {
+        String status = StrUtil.str(map.get("flow"));
+        String boId = StrUtil.str(map.get("id_"));
+        String kcId = StrUtil.str(map.get("inventory_id"));
+        if("end".equals(status)){
+            linYongService.updateTaiZhang(boId,kcId);
+        }else {
+            ReagentConsumablesTransactionPo tran = new ReagentConsumablesTransactionPo();
+            tran.setReagentCode(StrUtil.str(map.get("bian_ma_")));
+            tran.setQuantity(Long.parseLong(StrUtil.str(map.get("quantity"))));
+            String value1 = StrUtil.str(map.get("you_xiao_qi_"));
+            String value2 = StrUtil.str(map.get("you_xiao_qi_zhi_"));
+            String date = !value1.isEmpty() ? value1 : !value2.isEmpty() ? value2 : "";
+            tran.setExpDate(date);
+            tran.setPosition(StrUtil.str(map.get("position")));
+            tran.setStatus(StrUtil.str(map.get("type")));
+            tran.setType(Long.valueOf("-1"));
+            tran.setBoId(boId);
+            tran.setDiDian(StrUtil.str(map.get("di_dian_")));
+            tran.setBatchNum(StrUtil.str(map.get("pi_hao_")));
+            tran.setInventoryId(kcId);
+            tran.setFlow(status);
+
+            ReagentConsumablesTransaction transaction = reagentConsumablesTransactionRepository.newInstance();
+            transaction.setData(tran);
+            transaction.save();
+        }
     }
     }
 
 
     public void updateStock(StockDto stockDto) throws Exception {
     public void updateStock(StockDto stockDto) throws Exception {

+ 12 - 4
ibps-provider-root/modules/provider-business/src/main/java/com/lc/ibps/components/reagent/service/LinYongService.java

@@ -1,6 +1,7 @@
 package com.lc.ibps.components.reagent.service;
 package com.lc.ibps.components.reagent.service;
 
 
 import com.lc.ibps.base.framework.table.ICommonDao;
 import com.lc.ibps.base.framework.table.ICommonDao;
+import com.lc.ibps.base.web.context.ContextUtil;
 import com.lc.ibps.components.reagent.dto.InventoryDTO;
 import com.lc.ibps.components.reagent.dto.InventoryDTO;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
 
 
@@ -31,23 +32,30 @@ public class LinYongService implements OperationService{
     }
     }
 
 
     public void updateWithhold(String id, long withhold) {
     public void updateWithhold(String id, long withhold) {
-        String sql = "update t_reagent_inventory set withhold=%s where id_='%s'";
+        String sql = "update t_reagent_inventory set update_time_=now(),withhold=%s where id_='%s'";
         commonDao.execute(String.format(sql,Math.max(withhold,0),id));
         commonDao.execute(String.format(sql,Math.max(withhold,0),id));
     }
     }
 
 
     public void updateWithholdAndInventory(String id, long quantity,long withhold) {
     public void updateWithholdAndInventory(String id, long quantity,long withhold) {
-        String sql = "update t_reagent_inventory set quantity=%s, withhold=%s where id_='%s'";
+        String sql = "update t_reagent_inventory set update_time_=now(), quantity=%s, withhold=%s where id_='%s'";
         commonDao.execute(String.format(sql,Math.max(quantity,0),Math.max(withhold,0),id));
         commonDao.execute(String.format(sql,Math.max(quantity,0),Math.max(withhold,0),id));
     }
     }
 
 
     public void updateInventory(String id,long quantity){
     public void updateInventory(String id,long quantity){
-        String sql = "update t_reagent_inventory set quantity=%s where id_='%s'";
+        String sql = "update t_reagent_inventory set update_time_=now(),quantity=%s where id_='%s'";
         commonDao.execute(String.format(sql,Math.max(quantity,0),id));
         commonDao.execute(String.format(sql,Math.max(quantity,0),id));
     }
     }
 
 
     public void updateInventoryAndStatus(String id,long quantity){
     public void updateInventoryAndStatus(String id,long quantity){
-        String sql = "update t_reagent_inventory set enable_='是',quantity=%s where id_='%s'";
+        String sql = "update t_reagent_inventory set update_time_=now(),enable_='是',quantity=%s where id_='%s'";
         commonDao.execute(String.format(sql,Math.max(quantity,0),id));
         commonDao.execute(String.format(sql,Math.max(quantity,0),id));
     }
     }
 
 
+    public void updateTaiZhang(String boId,String kcId){
+        String userId = ContextUtil.getCurrentUserId();
+        String sql = "update t_reagent_trans set update_by_='%s',update_time_=now(),flow_='end' where bo_id='%s' and inventory_id='%s'";
+        sql = String.format(sql,userId,boId,kcId);
+        commonDao.execute(sql);
+    }
+
 }
 }

+ 2 - 0
ibps-provider-root/modules/provider-business/src/main/java/com/lc/ibps/components/reagent/service/ReturnService.java

@@ -5,6 +5,8 @@ import com.lc.ibps.base.framework.table.ICommonDao;
 import com.lc.ibps.components.reagent.dto.InventoryDTO;
 import com.lc.ibps.components.reagent.dto.InventoryDTO;
 import com.lc.ibps.untils.StrUtil;
 import com.lc.ibps.untils.StrUtil;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Propagation;
+import org.springframework.transaction.annotation.Transactional;
 
 
 import javax.annotation.Resource;
 import javax.annotation.Resource;
 import java.util.Collections;
 import java.util.Collections;

+ 5 - 4
ibps-provider-root/modules/provider-business/src/main/java/com/lc/ibps/components/reagent/service/TakeStockService.java

@@ -27,12 +27,13 @@ public class TakeStockService extends GenericProvider {
     private ICommonDao commonDao;
     private ICommonDao commonDao;
 
 
 
 
-    public List<Map<String,Object>> takeStock(String ckId, String date,String type) throws Exception {
-        logger.warn("com.lc.ibps.components.reagent.service.TakeStockService.takeStock()--->ckId={},date={},type={}", ckId, date, type);
+    public List<Map<String,Object>> takeStock(String[] ckIds, String date,String type) throws Exception {
+        logger.warn("com.lc.ibps.components.reagent.service.TakeStockService.takeStock()--->ckId={},date={},type={}", ckIds, date, type);
         String sql = "SELECT *from v_reagentinventory WHERE withhold=0 ORDER BY ming_cheng_";
         String sql = "SELECT *from v_reagentinventory WHERE withhold=0 ORDER BY ming_cheng_";
-        if(BeanUtils.isNotEmpty(ckId)){
+        if(BeanUtils.isNotEmpty(ckIds)){
+            String positions = String.join("','", ckIds);
             sql = "SELECT *from v_reagentinventory where withhold=0 and position in('%s') ORDER BY ming_cheng_";
             sql = "SELECT *from v_reagentinventory where withhold=0 and position in('%s') ORDER BY ming_cheng_";
-            sql = String.format(sql, ckId);
+            sql = String.format(sql, positions);
         }
         }
         List<Map<String,Object>> list = commonDao.query(sql);
         List<Map<String,Object>> list = commonDao.query(sql);
         if(Collections.isEmpty(list)){
         if(Collections.isEmpty(list)){

+ 1 - 1
ibps-provider-root/modules/provider-platform-default/src/main/java/com/lc/ibps/cloud/timer/utils/HttpUtil.java

@@ -54,7 +54,7 @@ public class HttpUtil {
         ContextUtil.setCurrentAccessToken(accessToken);
         ContextUtil.setCurrentAccessToken(accessToken);
         List<NameValuePair> params = ApacheHttpClient.NameValuePairBuilder.create()
         List<NameValuePair> params = ApacheHttpClient.NameValuePairBuilder.create()
                 .add(ParameterKey.PARAMETER_ACCESS_TOKEN, accessToken)
                 .add(ParameterKey.PARAMETER_ACCESS_TOKEN, accessToken)
-                .add("ckId", "")
+                .add("ckIds", "")
                 .add("date", "")
                 .add("date", "")
                 .add("type", type)
                 .add("type", type)
                 .build();
                 .build();