| | |
| | | import com.java110.core.annotation.Java110Cmd; |
| | | import com.java110.core.annotation.Java110Transactional; |
| | | import com.java110.core.context.ICmdDataFlowContext; |
| | | import com.java110.core.event.cmd.AbstractServiceCmdListener; |
| | | import com.java110.core.event.cmd.Cmd; |
| | | import com.java110.core.event.cmd.CmdEvent; |
| | | import com.java110.core.factory.GenerateCodeFactory; |
| | | import com.java110.dto.allocationStorehouse.AllocationStorehouseDto; |
| | | import com.java110.dto.allocationStorehouseApply.AllocationStorehouseApplyDto; |
| | | import com.java110.dto.resourceStore.ResourceStoreDto; |
| | | import com.java110.dto.user.UserDto; |
| | | import com.java110.dto.userStorehouse.UserStorehouseDto; |
| | | import com.java110.intf.common.IAllocationStorehouseUserInnerServiceSMO; |
| | | import com.java110.intf.store.*; |
| | | import com.java110.intf.user.IUserV1InnerServiceSMO; |
| | | import com.java110.po.allocationStorehouse.AllocationStorehousePo; |
| | | import com.java110.po.allocationStorehouseApply.AllocationStorehouseApplyPo; |
| | | import com.java110.po.purchase.ResourceStorePo; |
| | |
| | | * |
| | | */ |
| | | @Java110Cmd(serviceCode = "resourceStore.saveAllocationStorehouse") |
| | | public class SaveAllocationStorehouseCmd extends AbstractServiceCmdListener { |
| | | public class SaveAllocationStorehouseCmd extends Cmd { |
| | | |
| | | @Autowired |
| | | private IResourceStoreInnerServiceSMO resourceStoreInnerServiceSMOImpl; |
| | |
| | | |
| | | @Autowired |
| | | private IUserStorehouseV1InnerServiceSMO userStorehouseV1InnerServiceSMOImpl; |
| | | |
| | | @Autowired |
| | | private IUserV1InnerServiceSMO userV1InnerServiceSMOImpl; |
| | | |
| | | @Override |
| | | public void validate(CmdEvent event, ICmdDataFlowContext cmdDataFlowContext, JSONObject reqJson) throws CmdException { |
| | |
| | | int flag = 0; |
| | | //获取调拨返还状态标识 |
| | | String applyType = reqJson.getString("apply_type"); |
| | | |
| | | // 查询用户名称 |
| | | UserDto userDto = new UserDto(); |
| | | userDto.setUserId(reqJson.getString("userId")); |
| | | List<UserDto> userDtos = userV1InnerServiceSMOImpl.queryUsers(userDto); |
| | | |
| | | Assert.listOnlyOne(userDtos, "用户不存在"); |
| | | reqJson.put("userName", userDtos.get(0).getName()); |
| | | |
| | | |
| | | //封装调拨对象 |
| | | AllocationStorehouseApplyPo allocationStorehouseApplyPo = covertAllocationStorehouseApply(reqJson); |
| | | JSONArray resourceStores = reqJson.getJSONArray("resourceStores"); |
| | |
| | | if (AllocationStorehouseApplyDto.STORE_TYPE_ALLOCATION.equals(applyType)) { |
| | | AllocationStorehouseApplyDto allocationStorehouseDto = BeanConvertUtil.covertBean(allocationStorehouseApplyPo, AllocationStorehouseApplyDto.class); |
| | | allocationStorehouseDto.setCurrentUserId(reqJson.getString("userId")); |
| | | allocationStorehouseDto.setNextUserId(reqJson.getString("staffId")); |
| | | allocationStorehouseUserInnerServiceSMOImpl.startProcess(allocationStorehouseDto); |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | private void doDealResourceStore(JSONObject reqJson, String applyType, AllocationStorehouseApplyPo allocationStorehouseApplyPo, JSONArray resourceStores, JSONObject resObj) { |
| | | int flag; |
| | | //保存调拨申请的物品调拨记录 |
| | | saveAllocationStorehouse(reqJson, applyType, allocationStorehouseApplyPo, resObj); |
| | | if (AllocationStorehouseApplyDto.STORE_TYPE_ALLOCATION.equals(applyType)) { //调拨减去库存 |
| | |
| | | resourceStorePo.setShId(resObj.getString("shId")); |
| | | BigDecimal stockA = new BigDecimal(resObj.getString("stock"));//现有库存 |
| | | BigDecimal stockB = new BigDecimal(resObj.getString("curStock"));//调拨数量 |
| | | if (stockA.compareTo(stockB) == -1) { |
| | | if (stockA.compareTo(stockB) < 0) { |
| | | throw new IllegalArgumentException("库存不足!"); |
| | | } |
| | | resourceStorePo.setStock((stockA.subtract(stockB)).toString()); |