Commit b5ac532b by shiwenbo

修改库存量接口增加参数,控制是否是自增或自减

parent 0ea74abd
...@@ -73,10 +73,15 @@ public class InventoryServiceImpl implements InventoryService { ...@@ -73,10 +73,15 @@ public class InventoryServiceImpl implements InventoryService {
return result; return result;
} }
/**
* body json格式数据
* isLog 是否记录修改日志
* autoCalculate 是否是自增或自减
*/
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Override @Override
@Transactional @Transactional
public ResponseObj<String> modifyInventory(String body, boolean isLog) { public ResponseObj<String> modifyInventory(String body, boolean isLog, boolean autoCalculate) {
JSONObject params = new JSONObject(body); JSONObject params = new JSONObject(body);
JSONArray datas = params.getJSONArray("datas"); JSONArray datas = params.getJSONArray("datas");
for(int j = 0; j < datas.length(); j++) { for(int j = 0; j < datas.length(); j++) {
...@@ -95,7 +100,13 @@ public class InventoryServiceImpl implements InventoryService { ...@@ -95,7 +100,13 @@ public class InventoryServiceImpl implements InventoryService {
double amount = item.getDouble("amount"); double amount = item.getDouble("amount");
KObject kobj = inventoryDao.getItemByStationIdAndDinasTypeId(UUID.fromString(stationId), UUID.fromString(dinasTypeId)); KObject kobj = inventoryDao.getItemByStationIdAndDinasTypeId(UUID.fromString(stationId), UUID.fromString(dinasTypeId));
double oldAmount = kobj.getDouble("amount"); double oldAmount = kobj.getDouble("amount");
kobj.set("amount", amount); if(autoCalculate) {
BigDecimal addParam2 = new BigDecimal(oldAmount);
BigDecimal addParam1 = new BigDecimal(amount);
kobj.set("amount", addParam2.add(addParam1).doubleValue());
} else {
kobj.set("amount", amount);
}
inventoryDao.update(kobj); inventoryDao.update(kobj);
if(isLog) { if(isLog) {
......
...@@ -10,7 +10,7 @@ import com.xyst.dinas.sales.entity.StationDinasTypeRelation; ...@@ -10,7 +10,7 @@ import com.xyst.dinas.sales.entity.StationDinasTypeRelation;
public interface InventoryService { public interface InventoryService {
public List<StationDinasTypeRelation> getInventoryByRegionalCompany(UUID regionalCompany); public List<StationDinasTypeRelation> getInventoryByRegionalCompany(UUID regionalCompany);
public ResponseObj<String> modifyInventory(String body, boolean isLog); public ResponseObj<String> modifyInventory(String body, boolean isLog, boolean autoCalculate);
public List<InventoryLog> queryLog(UUID regionalCompany); public List<InventoryLog> queryLog(UUID regionalCompany);
} }
...@@ -36,7 +36,7 @@ public class InventoryController { ...@@ -36,7 +36,7 @@ public class InventoryController {
@ResponseBody @ResponseBody
@RequestMapping(value = "/inventory/modify", method = RequestMethod.POST) @RequestMapping(value = "/inventory/modify", method = RequestMethod.POST)
public Object modify(@RequestBody String body) { public Object modify(@RequestBody String body) {
ResponseObj<String> result = inventoryService.modifyInventory(body, true); ResponseObj<String> result = inventoryService.modifyInventory(body, true, false);
return result; return result;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment