| | |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.java110.core.factory.GenerateCodeFactory; |
| | | import com.java110.dto.purchaseApply.PurchaseApplyDto; |
| | | import com.java110.dto.resourceStore.ResourceStoreDto; |
| | | import com.java110.dto.userStorehouse.UserStorehouseDto; |
| | | import com.java110.entity.audit.AuditUser; |
| | | import com.java110.dto.purchase.PurchaseApplyDto; |
| | | import com.java110.dto.resource.ResourceStoreDto; |
| | | import com.java110.dto.resource.ResourceStoreTimesDto; |
| | | import com.java110.dto.user.UserDto; |
| | | import com.java110.dto.user.UserStorehouseDto; |
| | | import com.java110.dto.audit.AuditUser; |
| | | import com.java110.intf.store.IResourceStoreInnerServiceSMO; |
| | | import com.java110.intf.store.IResourceStoreTimesV1InnerServiceSMO; |
| | | import com.java110.intf.store.IUserStorehouseInnerServiceSMO; |
| | | import com.java110.intf.user.IUserV1InnerServiceSMO; |
| | | import com.java110.po.purchase.PurchaseApplyDetailPo; |
| | | import com.java110.po.purchase.PurchaseApplyPo; |
| | | import com.java110.po.purchase.ResourceStorePo; |
| | | import com.java110.po.userStorehouse.UserStorehousePo; |
| | | import com.java110.po.resource.ResourceStoreTimesPo; |
| | | import com.java110.po.user.UserStorehousePo; |
| | | import com.java110.store.bmo.collection.IGetCollectionAuditOrderBMO; |
| | | import com.java110.store.bmo.collection.IGoodsCollectionBMO; |
| | | import com.java110.store.bmo.collection.IResourceOutBMO; |
| | | import com.java110.utils.exception.CmdException; |
| | | import com.java110.utils.util.Assert; |
| | | import com.java110.utils.util.BeanConvertUtil; |
| | | import com.java110.utils.util.DateUtil; |
| | |
| | | @Autowired |
| | | private IUserStorehouseInnerServiceSMO userStorehouseInnerServiceSMOImpl; |
| | | |
| | | @Autowired |
| | | private IUserV1InnerServiceSMO userV1InnerServiceSMOImpl; |
| | | |
| | | @Autowired |
| | | private IResourceStoreTimesV1InnerServiceSMO resourceStoreTimesV1InnerServiceSMOImpl; |
| | | |
| | | |
| | | /** |
| | | * 物品领用 接口类 |
| | | * |
| | | * @param reqJson |
| | | * @param userId |
| | | * @param userName |
| | | * @param storeId |
| | | * @return {"resourceStores":[{"resId":"852020070239060001","resName":"水性笔","resCode":"002","price":"2.00","stock":"2", |
| | | * "description":"黑色","quantity":"1"}],"description":"123123","endUserName":"1","endUserTel":"17797173942","file":"", |
| | |
| | | @RequestMapping(value = "/goodsCollection", method = RequestMethod.POST) |
| | | public ResponseEntity<String> goodsCollection(@RequestBody JSONObject reqJson, |
| | | @RequestHeader(value = "user-id") String userId, |
| | | @RequestHeader(value = "user-name") String userName, |
| | | @RequestHeader(value = "store-id") String storeId) { |
| | | |
| | | UserDto userDto = new UserDto(); |
| | | userDto.setUserId(userId); |
| | | List<UserDto> userDtos = userV1InnerServiceSMOImpl.queryUsers(userDto); |
| | | |
| | | Assert.listOnlyOne(userDtos,"未包含用户"); |
| | | |
| | | |
| | | String userName = userDtos.get(0).getName(); |
| | | |
| | | Assert.hasKeyAndValue(reqJson, "resourceStores", "必填,请填写物品领用的物资"); |
| | | Assert.hasKeyAndValue(reqJson, "description", "必填,请填写采购申请说明"); |
| | | PurchaseApplyPo purchaseApplyPo = new PurchaseApplyPo(); |
| | |
| | | } |
| | | |
| | | /** |
| | | * 物品直接出库 |
| | | * 物品领用-物品直接出库 |
| | | */ |
| | | @RequestMapping(value = "/goodsDelivery", method = RequestMethod.POST) |
| | | public ResponseEntity<String> goodsDelivery(@RequestBody JSONObject reqJson, |
| | | @RequestHeader(value = "user-id") String userId, |
| | | @RequestHeader(value = "user-name") String userName, |
| | | @RequestHeader(value = "store-id") String storeId) { |
| | | Assert.hasKeyAndValue(reqJson, "resourceStores", "必填,请填写物品领用的物资"); |
| | | Assert.hasKeyAndValue(reqJson, "description", "必填,请填写采购申请说明"); |
| | | |
| | | UserDto userDto = new UserDto(); |
| | | userDto.setUserId(userId); |
| | | List<UserDto> userDtos = userV1InnerServiceSMOImpl.queryUsers(userDto); |
| | | |
| | | Assert.listOnlyOne(userDtos,"未包含用户"); |
| | | |
| | | |
| | | String userName = userDtos.get(0).getName(); |
| | | |
| | | PurchaseApplyPo purchaseApplyPo = new PurchaseApplyPo(); |
| | | purchaseApplyPo.setApplyOrderId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.CODE_PREFIX_applyOrderId)); |
| | | purchaseApplyPo.setDescription(reqJson.getString("description")); |
| | |
| | | } |
| | | resourceStorePo.setMiniStock(String.valueOf(surplusMiniStock)); |
| | | resourceStoreInnerServiceSMOImpl.updateResourceStore(resourceStorePo); |
| | | |
| | | //加入 从库存中扣减 |
| | | subResourceStoreTimesStock(resourceStore.getString("resCode"), purchaseApplyDetailPo); |
| | | |
| | | //查询资源 |
| | | ResourceStoreDto resourceStoreDto = new ResourceStoreDto(); |
| | | resourceStoreDto.setResId(purchaseApplyDetailPo.getResId()); |
| | |
| | | userStorehousePo.setResName(resourceStoreDtos.get(0).getResName()); |
| | | userStorehousePo.setStoreId(resourceStoreDtos.get(0).getStoreId()); |
| | | userStorehousePo.setUserId(purchaseApplyPo.getUserId()); |
| | | userStorehousePo.setTimesId(purchaseApplyDetailPo.getTimesId()); |
| | | |
| | | //查询个人物品仓库中 是否已经存在商品 |
| | | UserStorehouseDto userStorehouseDto = new UserStorehouseDto(); |
| | |
| | | purchaseApplyPo.setPurchaseApplyDetailPos(purchaseApplyDetailPos); |
| | | return goodsCollectionBMOImpl.collection(purchaseApplyPo,reqJson); |
| | | } |
| | | |
| | | /** |
| | | * 从times中扣减 |
| | | * |
| | | * @param resCode |
| | | * @param purchaseApplyDetailPo |
| | | */ |
| | | private void subResourceStoreTimesStock(String resCode, PurchaseApplyDetailPo purchaseApplyDetailPo) { |
| | | String applyQuantity = purchaseApplyDetailPo.getPurchaseQuantity(); |
| | | ResourceStoreTimesDto resourceStoreTimesDto = new ResourceStoreTimesDto(); |
| | | resourceStoreTimesDto.setResCode(resCode); |
| | | resourceStoreTimesDto.setTimesId(purchaseApplyDetailPo.getTimesId()); |
| | | List<ResourceStoreTimesDto> resourceStoreTimesDtos = resourceStoreTimesV1InnerServiceSMOImpl.queryResourceStoreTimess(resourceStoreTimesDto); |
| | | |
| | | if (resourceStoreTimesDtos == null || resourceStoreTimesDtos.size() < 1) { |
| | | return; |
| | | } |
| | | int stock = 0; |
| | | int quantity = Integer.parseInt(applyQuantity); |
| | | ResourceStoreTimesPo resourceStoreTimesPo = null; |
| | | |
| | | stock = Integer.parseInt(resourceStoreTimesDtos.get(0).getStock()); |
| | | if (stock < quantity) { |
| | | throw new CmdException(resourceStoreTimesDtos.get(0).getResCode() + "价格为:" + resourceStoreTimesDtos.get(0).getPrice() + "的库存" + resourceStoreTimesDtos.get(0).getStock() + ",库存不足"); |
| | | } |
| | | |
| | | stock = stock - quantity; |
| | | resourceStoreTimesPo = new ResourceStoreTimesPo(); |
| | | resourceStoreTimesPo.setTimesId(resourceStoreTimesDtos.get(0).getTimesId()); |
| | | resourceStoreTimesPo.setStock(stock + ""); |
| | | resourceStoreTimesV1InnerServiceSMOImpl.updateResourceStoreTimes(resourceStoreTimesPo); |
| | | } |
| | | } |