chengf
2026-03-25 1e0e62187e2b7ff3e1fef23b182a710dc8cd76f8
service-store/src/main/java/com/java110/store/cmd/resourceStore/ListResourceStoresCmd.java
@@ -2,6 +2,7 @@
import com.alibaba.fastjson.JSONObject;
import com.java110.core.annotation.Java110Cmd;
import com.java110.core.context.CmdContextUtils;
import com.java110.core.context.ICmdDataFlowContext;
import com.java110.core.event.cmd.Cmd;
import com.java110.core.event.cmd.CmdEvent;
@@ -10,9 +11,9 @@
import com.java110.dto.privilege.BasePrivilegeDto;
import com.java110.dto.resource.ResourceStoreDto;
import com.java110.dto.resource.ResourceStoreTimesDto;
import com.java110.dto.store.StorehouseDto;
import com.java110.intf.community.IMenuInnerServiceSMO;
import com.java110.intf.store.IResourceStoreInnerServiceSMO;
import com.java110.intf.store.IResourceStoreTimesV1InnerServiceSMO;
import com.java110.utils.exception.CmdException;
import com.java110.utils.util.Assert;
import com.java110.utils.util.BeanConvertUtil;
@@ -44,8 +45,8 @@
)
@Java110ParamsDoc(params = {
        @Java110ParamDoc(name = "page", length = 11,type = "int",remark = "页数"),
        @Java110ParamDoc(name = "row", length = 11,type = "int", remark = "行业数"),
        @Java110ParamDoc(name = "page", length = 11, type = "int", remark = "页数"),
        @Java110ParamDoc(name = "row", length = 11, type = "int", remark = "行业数"),
})
@Java110ResponseDoc(
@@ -53,14 +54,14 @@
                @Java110ParamDoc(name = "code", type = "int", length = 11, defaultValue = "0", remark = "返回编号,0 成功 其他失败"),
                @Java110ParamDoc(name = "msg", type = "String", length = 250, defaultValue = "成功", remark = "描述"),
                @Java110ParamDoc(name = "data", type = "Object", remark = "有效数据"),
                @Java110ParamDoc(parentNodeName = "data",name = "resCode", type = "String", remark = "物品编号"),
                @Java110ParamDoc(parentNodeName = "data",name = "resName", type = "String", remark = "物品名称"),
                @Java110ParamDoc(parentNodeName = "data", name = "resCode", type = "String", remark = "物品编号"),
                @Java110ParamDoc(parentNodeName = "data", name = "resName", type = "String", remark = "物品名称"),
        }
)
@Java110ExampleDoc(
        reqBody="http://localhost:3000/app/resourceStore.listResourceStores?resId=&resName=&resCode=&shId=&parentRstId=&rstId=&rssId=&isFixed=&page=1&row=10",
        resBody="{\n" +
        reqBody = "http://localhost:3000/app/resourceStore.listResourceStores?resId=&resName=&resCode=&shId=&parentRstId=&rstId=&rssId=&isFixed=&page=1&row=10",
        resBody = "{\n" +
                "    \"page\": 0,\n" +
                "    \"records\": 1,\n" +
                "    \"resourceStores\": [\n" +
@@ -150,22 +151,28 @@
    private IResourceStoreInnerServiceSMO resourceStoreInnerServiceSMOImpl;
    @Autowired
    private IResourceStoreTimesV1InnerServiceSMO resourceStoreTimesV1InnerServiceSMOImpl;
    @Autowired
    private IMenuInnerServiceSMO menuInnerServiceSMOImpl;
    @Override
    public void validate(CmdEvent event, ICmdDataFlowContext context, JSONObject reqJson) throws CmdException {
        super.validatePageInfo(reqJson);
        Assert.hasKeyAndValue(reqJson, "communityId", "请求报文中未包含小区ID");
        Assert.hasKeyAndValue(reqJson, "storeId", "请求报文中未包含商户ID");
        /*if (!reqJson.containsKey("shId") || StringUtil.isEmpty(reqJson.getString("shId"))) {
            Assert.hasKeyAndValue(reqJson, "communityId", "请求报文中未包含小区ID");
        }*/
    }
    @Override
    public void doCmd(CmdEvent event, ICmdDataFlowContext context, JSONObject reqJson) throws CmdException, ParseException {
        String storeId = CmdContextUtils.getStoreId(context);
        ResourceStoreDto resourceStoreDto = BeanConvertUtil.covertBean(reqJson, ResourceStoreDto.class);
        resourceStoreDto.setStoreId(storeId);
        //采购2806集团仓库 物品领用2807小区仓库  默认查询当前小区所有商品
        //是否具有查看集团仓库物品权限
        String userId = reqJson.getString("userId");
        BasePrivilegeDto basePrivilegeDto1 = new BasePrivilegeDto();
        basePrivilegeDto1.setResource("/viewHiddenWarehouse");
        basePrivilegeDto1.setUserId(userId);
@@ -180,13 +187,28 @@
        //计算总价(大计)
        BigDecimal totalPrice = BigDecimal.ZERO;
        if (count > 0) {
            resourceStores = BeanConvertUtil.covertBeanList(resourceStoreInnerServiceSMOImpl.queryResourceStores(resourceStoreDto), ApiResourceStoreDataVo.class);
            List<ResourceStoreDto> resourceStoreDtos = resourceStoreInnerServiceSMOImpl.queryResourceStores(resourceStoreDto);
            resourceStores = BeanConvertUtil.covertBeanList(resourceStoreDtos, ApiResourceStoreDataVo.class);
            //todo 计算物品 库存和 价格
            queryResourceStoreAndResourceTotalPrice(resourceStores);
            resourceStoreDto.setPage(Integer.valueOf(reqJson.getString("page")));
            subTotalPrice = new BigDecimal(resourceStoreInnerServiceSMOImpl.queryResourceStoresTotalPrice(resourceStoreDto));
            BigDecimal number = BigDecimal.ZERO;
            for (ResourceStoreDto resourceStore : resourceStoreDtos) {
                ResourceStoreTimesDto resourceStoreTimesDto = new ResourceStoreTimesDto();
                resourceStoreTimesDto.setResCode(resourceStore.getResCode());
                resourceStoreTimesDto.setShId(resourceStore.getShId());
                //查询批次表
//                List<ResourceStoreTimesDto> resourceStoreTimesDtos = resourceStoreTimesV1InnerServiceSMOImpl.queryResourceStoreTimess(resourceStoreTimesDto);
//                for (ResourceStoreTimesDto resourceStoreTimes : resourceStoreTimesDtos) {
//                    BigDecimal stock = new BigDecimal(resourceStoreTimes.getStock());
//                    BigDecimal price = new BigDecimal(resourceStoreTimes.getPrice());
//                    BigDecimal multiply = stock.multiply(price).setScale(2, BigDecimal.ROUND_HALF_UP);
//                    number = number.add(multiply);
//                }
            }
            subTotalPrice = number;
            resourceStoreDto.setPage(PageDto.DEFAULT_PAGE);
            totalPrice = new BigDecimal(resourceStoreInnerServiceSMOImpl.queryResourceStoresTotalPrice(resourceStoreDto));
            String price = resourceStoreInnerServiceSMOImpl.queryResourceStoresTotalPrice(resourceStoreDto);
            totalPrice = new BigDecimal(price);
        } else {
            resourceStores = new ArrayList<>();
        }
@@ -206,12 +228,9 @@
     * @param resourceStores
     */
    private void queryResourceStoreAndResourceTotalPrice(List<ApiResourceStoreDataVo> resourceStores) {
        if (resourceStores == null || resourceStores.size() < 1) {
            return;
        }
        BigDecimal stock = null;
        BigDecimal totalPrice = null;
        for (ApiResourceStoreDataVo resourceStore : resourceStores) {
@@ -221,15 +240,12 @@
            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() + "");
//            for (ResourceStoreTimesDto resourceStoreTimesDto : resourceStoreTimesDtos) {
//                stock = stock.add(new BigDecimal(resourceStoreTimesDto.getStock())).setScale(2, BigDecimal.ROUND_HALF_EVEN);
//                totalPrice = totalPrice.add(new BigDecimal(resourceStoreTimesDto.getTotalPrice())).setScale(2, BigDecimal.ROUND_HALF_EVEN);
//            }
//            resourceStore.setStock(stock.doubleValue() + "");
//            resourceStore.setTotalPrice(totalPrice.doubleValue() + "");
        }
    }
}