| | |
| | | package com.java110.store.cmd.resourceStore; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.google.protobuf.Api; |
| | | import com.java110.core.annotation.Java110Cmd; |
| | | import com.java110.core.context.ICmdDataFlowContext; |
| | | import com.java110.core.event.cmd.Cmd; |
| | |
| | | import com.java110.dto.PageDto; |
| | | import com.java110.dto.basePrivilege.BasePrivilegeDto; |
| | | import com.java110.dto.resourceStore.ResourceStoreDto; |
| | | import com.java110.dto.resourceStoreTimes.ResourceStoreTimesDto; |
| | | import com.java110.dto.storehouse.StorehouseDto; |
| | | import com.java110.intf.community.IMenuInnerServiceSMO; |
| | | import com.java110.intf.store.IResourceStoreInnerServiceSMO; |
| | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 查询物品 |
| | | * add by wuxw 2023-01-19 |
| | | */ |
| | | @Java110Cmd(serviceCode = "resourceStore.listResourceStores") |
| | | public class ListResourceStoresCmd extends Cmd { |
| | | |
| | |
| | | basePrivilegeDto.setResource("/viewGroupResource"); |
| | | basePrivilegeDto.setUserId(userId); |
| | | List<Map> privileges = menuInnerServiceSMOImpl.checkUserHasResource(basePrivilegeDto); |
| | | if (reqJson.containsKey("operationType") && reqJson.getString("operationType").equals("1000") && privileges.size() > 0) { |
| | | if ("1000".equals(reqJson.getString("operationType")) && privileges.size() > 0) { |
| | | resourceStoreDto.setShType(""); |
| | | resourceStoreDto.setShObjIds(new String[]{reqJson.getString("communityId"), reqJson.getString("storeId")}); |
| | | } else if (StorehouseDto.SH_TYPE_COMMUNITY.equals(resourceStoreDto.getShType()) || privileges.size() == 0) { |
| | | //add by wuxw 这里 修改为 小区仓库也能采购 模式 所以这里不限制 |
| | | //resourceStoreDto.setShType(StorehouseDto.SH_TYPE_COMMUNITY); |
| | | resourceStoreDto.setShObjId(reqJson.getString("communityId")); |
| | | } |
| | | BasePrivilegeDto basePrivilegeDto1 = new BasePrivilegeDto(); |
| | | basePrivilegeDto1.setResource("/viewHiddenWarehouse"); |
| | | basePrivilegeDto1.setUserId(userId); |
| | | List<Map> viewHiddenWarehousePrivileges = menuInnerServiceSMOImpl.checkUserHasResource(basePrivilegeDto1); |
| | | if (viewHiddenWarehousePrivileges.size() == 0) { |
| | | resourceStoreDto.setIsShow("true"); |
| | | } |
| | | int count = resourceStoreInnerServiceSMOImpl.queryResourceStoresCount(resourceStoreDto); |
| | | List<ApiResourceStoreDataVo> resourceStores = new ArrayList<>(); |
| | |
| | | BigDecimal totalPrice = BigDecimal.ZERO; |
| | | if (count > 0) { |
| | | resourceStores = BeanConvertUtil.covertBeanList(resourceStoreInnerServiceSMOImpl.queryResourceStores(resourceStoreDto), ApiResourceStoreDataVo.class); |
| | | //查询总价 |
| | | //todo 计算物品 库存和 价格 |
| | | queryResourceStoreAndResourceTotalPrice(resourceStores); |
| | | resourceStoreDto.setPage(Integer.valueOf(reqJson.getString("page"))); |
| | | subTotalPrice = new BigDecimal(resourceStoreInnerServiceSMOImpl.queryResourceStoresTotalPrice(resourceStoreDto)); |
| | | resourceStoreDto.setPage(PageDto.DEFAULT_PAGE); |
| | |
| | | ResponseEntity<String> responseEntity = new ResponseEntity<String>(JSONObject.toJSONString(apiResourceStoreVo), HttpStatus.OK); |
| | | context.setResponseEntity(responseEntity); |
| | | } |
| | | |
| | | /** |
| | | * 计算物品的数量和金额 |
| | | * |
| | | * @param resourceStores |
| | | */ |
| | | private void queryResourceStoreAndResourceTotalPrice(List<ApiResourceStoreDataVo> resourceStores) { |
| | | |
| | | if (resourceStores == null || resourceStores.size() < 1) { |
| | | return; |
| | | } |
| | | |
| | | |
| | | BigDecimal stock = new BigDecimal(0.0); |
| | | BigDecimal totalPrice = new BigDecimal(0.0); |
| | | for (ApiResourceStoreDataVo resourceStore : resourceStores) { |
| | | List<ResourceStoreTimesDto> resourceStoreTimesDtos = resourceStore.getTimes(); |
| | | if (resourceStoreTimesDtos == null || resourceStoreTimesDtos.size() < 1) { |
| | | continue; |
| | | } |
| | | |
| | | for (ResourceStoreTimesDto resourceStoreTimesDto : resourceStoreTimesDtos) { |
| | | stock = stock.add(new BigDecimal(resourceStoreTimesDto.getStock())); |
| | | totalPrice = totalPrice.add(new BigDecimal(resourceStoreTimesDto.getTotalPrice())); |
| | | } |
| | | |
| | | resourceStore.setStock(stock.doubleValue() + ""); |
| | | resourceStore.setTotalPrice(totalPrice.doubleValue() + ""); |
| | | } |
| | | |
| | | } |
| | | } |