Commit b5ac532b by shiwenbo

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

parent 0ea74abd
......@@ -73,10 +73,15 @@ public class InventoryServiceImpl implements InventoryService {
return result;
}
/**
* body json格式数据
* isLog 是否记录修改日志
* autoCalculate 是否是自增或自减
*/
@SuppressWarnings("unchecked")
@Override
@Transactional
public ResponseObj<String> modifyInventory(String body, boolean isLog) {
public ResponseObj<String> modifyInventory(String body, boolean isLog, boolean autoCalculate) {
JSONObject params = new JSONObject(body);
JSONArray datas = params.getJSONArray("datas");
for(int j = 0; j < datas.length(); j++) {
......@@ -95,7 +100,13 @@ public class InventoryServiceImpl implements InventoryService {
double amount = item.getDouble("amount");
KObject kobj = inventoryDao.getItemByStationIdAndDinasTypeId(UUID.fromString(stationId), UUID.fromString(dinasTypeId));
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);
if(isLog) {
......
......@@ -10,7 +10,7 @@ import com.xyst.dinas.sales.entity.StationDinasTypeRelation;
public interface InventoryService {
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);
}
......@@ -36,7 +36,7 @@ public class InventoryController {
@ResponseBody
@RequestMapping(value = "/inventory/modify", method = RequestMethod.POST)
public Object modify(@RequestBody String body) {
ResponseObj<String> result = inventoryService.modifyInventory(body, true);
ResponseObj<String> result = inventoryService.modifyInventory(body, true, false);
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