wangxinhui
2025-03-31 638a684258fb4bc6adf76a1964bdf0d7f99e404f
Merge branch 'master' of http://115.159.85.185:8098/r/MeiRuiAn/HuaiAn

# Conflicts:
# 代码管理/WMS/WIDESEA_WMSServer/WIDESEA_SystemService/Sys_DictionaryService.cs
# 代码管理/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/appsettings.json
已修改6个文件
已添加6个文件
995 ■■■■ 文件已修改
代码管理/WMS/WIDESEA_WMSClient/src/extension/basic/materielInfo.js 116 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
代码管理/WMS/WIDESEA_WMSClient/src/extension/stock/materielnfoStatistics.js 59 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
代码管理/WMS/WIDESEA_WMSClient/src/router/viewGird.js 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
代码管理/WMS/WIDESEA_WMSClient/src/views/basic/materielInfo.vue 155 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
代码管理/WMS/WIDESEA_WMSClient/src/views/stock/materielnfoStatistics.vue 189 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
代码管理/WMS/WIDESEA_WMSServer/WIDESEA_Common/MaterielEnum/MaterielSourceTypeEnum.cs 10 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
代码管理/WMS/WIDESEA_WMSServer/WIDESEA_Common/MaterielEnum/MaterielTypeEnum.cs 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
代码管理/WMS/WIDESEA_WMSServer/WIDESEA_DTO/Stock/MaterielnfoStatisticsDTO.cs 66 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
代码管理/WMS/WIDESEA_WMSServer/WIDESEA_IStockService/IMaterielnfoStatisticsService.cs 17 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
代码管理/WMS/WIDESEA_WMSServer/WIDESEA_Model/Models/Basic/Dt_MaterielInfo.cs 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
代码管理/WMS/WIDESEA_WMSServer/WIDESEA_StockService/MaterielnfoStatisticsService.cs 308 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
代码管理/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/Stock/MaterielnfoStatisticsController.cs 55 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
´úÂë¹ÜÀí/WMS/WIDESEA_WMSClient/src/extension/basic/materielInfo.js
@@ -2,57 +2,71 @@
//此js文件是用来自定义扩展业务代码,可以扩展一些自定义页面或者重新配置生成的代码
let extension = {
    components: {
      //查询界面扩展组件
      gridHeader: '',
      gridBody: '',
      gridFooter: '',
      //新建、编辑弹出框扩展组件
      modelHeader: '',
      modelBody: '',
      modelFooter: ''
  components: {
    //查询界面扩展组件
    gridHeader: '',
    gridBody: '',
    gridFooter: '',
    //新建、编辑弹出框扩展组件
    modelHeader: '',
    modelBody: '',
    modelFooter: ''
  },
  tableAction: '', //指定某张表的权限(这里填写表名,默认不用填写)
  buttons: { view: [], box: [], detail: [] }, //扩展的按钮
  methods: {
    //下面这些方法可以保留也可以删除
    onInit() {
    },
    tableAction: '', //指定某张表的权限(这里填写表名,默认不用填写)
    buttons: { view: [], box: [], detail: [] }, //扩展的按钮
    methods: {
       //下面这些方法可以保留也可以删除
      onInit() {
      },
      onInited() {
        //框架初始化配置后
        //如果要配置明细表,在此方法操作
        //this.detailOptions.columns.forEach(column=>{ });
      },
      searchBefore(param) {
        //界面查询前,可以给param.wheres添加查询参数
        //返回false,则不会执行查询
        return true;
      },
      searchAfter(result) {
        //查询后,result返回的查询数据,可以在显示到表格前处理表格的值
        return true;
      },
      addBefore(formData) {
        //新建保存前formData为对象,包括明细表,可以给给表单设置值,自己输出看formData的值
        return true;
      },
      updateBefore(formData) {
        //编辑保存前formData为对象,包括明细表、删除行的Id
        return true;
      },
      rowClick({ row, column, event }) {
        //查询界面点击行事件
        this.$refs.table.$refs.table.toggleRowSelection(row); //单击行时选中当前行;
      },
      modelOpenAfter(row) {
        //点击编辑、新建按钮弹出框后,可以在此处写逻辑,如,从后台获取数据
        //(1)判断是编辑还是新建操作: this.currentAction=='Add';
        //(2)给弹出框设置默认值
        //(3)this.editFormFields.字段='xxx';
        //如果需要给下拉框设置默认值,请遍历this.editFormOptions找到字段配置对应data属性的key值
        //看不懂就把输出看:console.log(this.editFormOptions)
    onInited() {
      //框架初始化配置后
      //如果要配置明细表,在此方法操作
      //this.detailOptions.columns.forEach(column=>{ });
    },
    searchBefore(param) {
      //界面查询前,可以给param.wheres添加查询参数
      //返回false,则不会执行查询
      return true;
    },
    searchAfter(result) {
      //查询后,result返回的查询数据,可以在显示到表格前处理表格的值
      // if (Array.isArray(result)) {
      //   result.forEach(item => {
      //     if (item.hasOwnProperty('isCheck')) {
      //       item.isCheck = item.isCheck === 'True' ? '是' : '否';
      //     }
      //     if (item.hasOwnProperty('materielState')) {
      //       item.materielState = item.materielState === 'Enable' ? '启用' : '禁用'
      //     }
      //   });
      // }
      return result;
    },
    addBefore(formData) {
      //新建保存前formData为对象,包括明细表,可以给给表单设置值,自己输出看formData的值
      return true;
    },
    updateBefore(formData) {
      //编辑保存前formData为对象,包括明细表、删除行的Id
      return true;
    },
    rowClick({ row, column, event }) {
      //查询界面点击行事件
      this.$refs.table.$refs.table.toggleRowSelection(row); //单击行时选中当前行;
    },
    modelOpenAfter(row) {
      //点击编辑、新建按钮弹出框后,可以在此处写逻辑,如,从后台获取数据
      //(1)判断是编辑还是新建操作: this.currentAction=='Add';
      //(2)给弹出框设置默认值
      //(3)this.editFormFields.字段='xxx';
      //如果需要给下拉框设置默认值,请遍历this.editFormOptions找到字段配置对应data属性的key值
      //看不懂就把输出看:console.log(this.editFormOptions)
      let isAdd = this.currentAction == 'Add'
      if (isAdd) {
        this.editFormFields.materielInvOrgId = '淮安特创二厂'
      }
    }
  };
  export default extension;
  }
};
export default extension;
´úÂë¹ÜÀí/WMS/WIDESEA_WMSClient/src/extension/stock/materielnfoStatistics.js
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,59 @@
//此js文件是用来自定义扩展业务代码,可以扩展一些自定义页面或者重新配置生成的代码
let extension = {
    components: {
      //查询界面扩展组件
      gridHeader: '',
      gridBody: '',
      gridFooter: '',
      //新建、编辑弹出框扩展组件
      modelHeader: '',
      modelBody: '',
      modelFooter: ''
    },
    tableAction: '', //指定某张表的权限(这里填写表名,默认不用填写)
    buttons: { view: [], box: [], detail: [] }, //扩展的按钮
    methods: {
       //下面这些方法可以保留也可以删除
      onInit() {
      },
      onInited() {
        //框架初始化配置后
        //如果要配置明细表,在此方法操作
        //this.detailOptions.columns.forEach(column=>{ });
      },
      searchBefore(param) {
        //界面查询前,可以给param.wheres添加查询参数
        //返回false,则不会执行查询
        return true;
      },
      searchAfter(result) {
        //查询后,result返回的查询数据,可以在显示到表格前处理表格的值
        return true;
      },
      addBefore(formData) {
        //新建保存前formData为对象,包括明细表,可以给给表单设置值,自己输出看formData的值
        return true;
      },
      updateBefore(formData) {
        //编辑保存前formData为对象,包括明细表、删除行的Id
        return true;
      },
      rowClick({ row, column, event }) {
        //查询界面点击行事件
        this.$refs.table.$refs.table.toggleRowSelection(row); //单击行时选中当前行;
      },
      modelOpenAfter(row) {
        //点击编辑、新建按钮弹出框后,可以在此处写逻辑,如,从后台获取数据
        //(1)判断是编辑还是新建操作: this.currentAction=='Add';
        //(2)给弹出框设置默认值
        //(3)this.editFormFields.字段='xxx';
        //如果需要给下拉框设置默认值,请遍历this.editFormOptions找到字段配置对应data属性的key值
        //看不懂就把输出看:console.log(this.editFormOptions)
      }
    }
  };
  export default extension;
´úÂë¹ÜÀí/WMS/WIDESEA_WMSClient/src/router/viewGird.js
@@ -78,6 +78,11 @@
    path: '/outStockLockInfo',
    name: 'outStockLockInfo',
    component: () => import('@/views/outbound/outStockLockInfo.vue')
  },
  {
    path: '/materielnfoStatistics',
    name: 'materielnfoStatistics',
    component: () => import('@/views/stock/materielnfoStatistics.vue')
  },{
    path: '/stockInfo',
    name: 'stockInfo',
´úÂë¹ÜÀí/WMS/WIDESEA_WMSClient/src/views/basic/materielInfo.vue
@@ -38,9 +38,11 @@
      [
        {
          title: "仓库",
          required: true,
          field: "warehouseId",
          type: "string",
          type: "select",
          dataKey: "warehouses",
          data: [],
          required: true,
        },
        {
          title: "物料编号",
@@ -48,27 +50,74 @@
          field: "materielCode",
          type: "string",
        },
        {
      ],
      [
         {
          title: "物料名称",
          required: true,
          field: "materielName",
          type: "string",
        },
        {
          title: "计量单位",
          title: "物料规格",
          required: true,
          field: "unit",
          field: "materielSpec",
          type: "string",
        },
      ],
      [
        {
          title: "物料描述",
          field: "materielDes",
          type: "textarea",
       {
          title: "物料基本分类",
          required: true,
          field: "materielType",
          type: "select",
          dataKey:"materielTypeEnum",
          data:[]
        },
        {
        field: "materielSourceType",
        title: "物料属性分类",
        required: true,
        type: "select",
        dataKey:"materielSourceTypeEnum",
        data:[]
      },
      ],
      [
        {
          title: "基本单位",
          required: true,
          field: "materielUnit",
          type: "string",
        },
        {
          title: "物料状态",
          required: true,
          field: "materielState",
          type: "select",
          dataKey:"enableEnum",
          data:[]
        },
      ],
      [
        {
          title: "库存组织",
          required: true,
          field: "materielInvOrgId",
          type: "string",
        },
        {
          title: "是否需要质检",
          required: true,
          field: "isCheck",
          type: "select",
          dataKey:"yesno",
          data:[]
        },
      ]
    ]);
    const searchFormFields = ref({
      materielCode: "",
@@ -78,6 +127,7 @@
      [
        { title: "物料编号", field: "materielCode", type: "like" },
        { title: "物料名称", field: "materielName", type: "like" },
        {title: "所属仓库", field:"warehouseId",type:"select",dataKey:"warehouses",data:[]}
      ],
    ]);
    const columns = ref([
@@ -114,57 +164,78 @@
        align: "left",
      },
      {
        field: "materielDes",
        title: "物料描述",
        type: "decimal",
        width: 90,
        align: "left",
      },
      {
        field: "cotainerType",
        title: "容器类型",
        field: "materielSpec",
        title: "物料规格",
        type: "string",
        width: 90,
        width: 240,
        align: "left",
        hidden:true
      },
      {
        field: "packspes",
        title: "包装规格",
        type: "int",
        field: "materielSourceType",
        title: "物料属性分类",
        type: "string",
        width: 120,
        align: "left",
        hidden:true
        bind: { key: "materielSourceTypeEnum", data: [] },
      },
      {
        field: "attribute",
        title: "物料属性",
        field: "materielType",
        title: "物料基本分类",
        type: "string",
        width: 200,
        width: 120,
        align: "left",
        hidden:true
      },
      {
        field: "unit",
        title: "计量单位",
        field: "materielUnit",
        title: "基本单位",
        type: "string",
        width: 120,
        align: "left",
      },
      {
        field: "materielSize",
        title: "物料尺寸",
        type: "float",
        width: 180,
        align: "left",
      },
      {
        field: "validity",
        title: "有效期",
        type: "string",
        field: "materielLength",
        title: "物料长度",
        type: "float",
        width: 120,
        align: "left",
      },
      {
        field: "safetyStock",
        title: "安全库存",
        type: "string",
        field: "materielThickness",
        title: "物料厚度",
        type: "float",
        width: 120,
        align: "left",
        hidden:true
      },
      {
        field: "materielState",
        title: "物料状态",
        type: "select",
        width: 100,
        bind:{key:"",data: [{key:'Enable',value:'启用'},{key:'Disable',value:'禁用'}] },
        align: "left",
      },
      {
        field: "materielInvOrgId",
        title: "库存组织",
        type: "string",
        width: 100,
        align: "left",
      },
      {
        field: "isCheck",
        title: "是否需要质检",
        type: "int",
        bind:{key:"",data: [{key:'False',value:'否'},{key:'True',value:'是'}] },
        width: 100,
        align: "left",
      },
      {
        field: "creater",
@@ -196,13 +267,7 @@
        align: "left",
        hidden:true
      },
      {
        field: "remark",
        title: "备注",
        type: "string",
        width: 100,
        align: "left",
      },
    ]);
    const detail = ref({
      cnName: "#detailCnName",
´úÂë¹ÜÀí/WMS/WIDESEA_WMSClient/src/views/stock/materielnfoStatistics.vue
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,189 @@
<template>
  <view-grid ref="grid" :columns="columns" :detail="detail" :editFormFields="editFormFields"
    :editFormOptions="editFormOptions" :searchFormFields="searchFormFields" :searchFormOptions="searchFormOptions"
    :table="table" :extend="extend">
  </view-grid>
</template>
<script>
import extend from "@/extension/stock/materielnfoStatistics.js";
import { ref, defineComponent } from "vue";
export default defineComponent({
  setup() {
    const table = ref({
      key: "stockId",
      footer: "Foots",
      cnName: "物料分类统计",
      name: "materielnfoStatistics",
      url: "/materielnfoStatistics/",
      sortName: "stockId",
    });
    const editFormFields = ref({
      deviceCode: "",
      deviceName: "",
      deviceType: "",
      deviceStatus: "",
      deviceIp: "",
      devicePort: "",
      devicePlcType: "",
      deviceRemark: "",
    });
    const editFormOptions = ref([
      [
        {
          title: "物料编号",
          required: true,
          field: "materielCode",
          type: "string",
        },
        {
          title: "单据编号",
          required: true,
          field: "materielName",
          type: "string",
        },
        {
          title: "批次号",
          required: true,
          field: "orderNo",
          type: "string",
        },
        {
          title: "序列号",
          required: true,
          field: "serialNumber",
          type: "string",
        },
      ],
    ]);
    const searchFormFields = ref({
      materielCode: "",
      materielName: "",
      orderNo: "",
    });
    const searchFormOptions = ref([
      [
        { title: "物料编号", field: "materielCode", type:"like"},
        { title: "物料名称", field: "materielName" ,type:"like"},
        { title: "所属仓库", field: "warehouseId",type: "select",dataKey: "warehouses",data: []},
        {title: "库存状态",field: "stockStatus",type: "select",dataKey:"stockStatusEmun", data: []}
      ],
    ]);
    const columns = ref([
      {
        field: "stockId",
        title: "Id",
        type: "int",
        width: 90,
        hidden: true,
        readonly: true,
        require: true,
        align: "left",
      },
      {
       field: "warehouseId",
          title: "仓库",
          type: "select",
          width: 100,
          align: "left",
          bind: { key: "warehouses", data: [] },
      },
      {
        field: "materielCode",
        title: "物料编号",
        type: "string",
        width: 150,
        align: "left",
      },
      {
        field: "materielName",
        title: "物料名称",
        type: "string",
        width: 150,
        align: "left",
      },
      {
        field: "stockQuantity",
        title: "库存数量",
        type: "string",
        width: 120,
        align: "left",
      },
      {
        field: "outboundQuantity",
        title: "出库数量",
        type: "string",
        width: 120,
        align: "left",
      },
      {
        field:"unit",
        title:"单位",
        type:"string",
        width:60,
        align:"left"
      },
      {
        field: "stockStatus",
        title: "库存状态",
        type: "string",
        width: 120,
        align: "left",
        bind: { key: "stockStatusEmun", data: [] },
      },
      {
        field: "remark",
        title: "备注",
        type: "string",
        width: 100,
        align: "left",
      },
      {
        field: "creater",
        title: "创建人",
        type: "string",
        width: 90,
        align: "left",
      },
      {
        field: "createDate",
        title: "创建时间",
        type: "datetime",
        width: 160,
        align: "left",
      },
      {
        field: "modifier",
        title: "修改人",
        type: "string",
        width: 100,
        align: "left",
      },
      {
        field: "modifyDate",
        title: "修改时间",
        type: "datetime",
        width: 160,
        align: "left",
      },
    ]);
    const detail = ref({
      cnName: "#detailCnName",
      table: "",
      columns: [],
      sortName: "",
    });
    return {
      table,
      extend,
      editFormFields,
      editFormOptions,
      searchFormFields,
      searchFormOptions,
      columns,
      detail,
    };
  },
});
</script>
´úÂë¹ÜÀí/WMS/WIDESEA_WMSServer/WIDESEA_Common/MaterielEnum/MaterielSourceTypeEnum.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@@ -11,16 +12,19 @@
        /// <summary>
        /// é‡‡è´­ä»¶
        /// </summary>
        PurchasePart = 1,
        [Description("采购件")]
        é‡‡è´­ä»¶ = 1,
        /// <summary>
        /// è‡ªåˆ¶ä»¶
        /// </summary>
        SelfMadePart = 2,
        [Description("自制件")]
        è‡ªåˆ¶ä»¶ = 2,
        /// <summary>
        /// é‡‡è´­&自制件
        /// </summary>
        PurchaseAndSelf = 3
        [Description("采购和自制件")]
        é‡‡è´­å’Œè‡ªåˆ¶ä»¶ = 3
    }
}
´úÂë¹ÜÀí/WMS/WIDESEA_WMSServer/WIDESEA_Common/MaterielEnum/MaterielTypeEnum.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@@ -14,21 +15,25 @@
        /// <summary>
        /// æˆå“
        /// </summary>
        FinishProduct = 1,
        [Description("成品")]
        æˆå“ = 1,
        /// <summary>
        /// åŠæˆå“
        /// </summary>
        HalfProduct = 2,
        [Description("半成品")]
        åŠæˆå“ = 2,
        /// <summary>
        /// åŽŸææ–™
        /// </summary>
        RawMateriel = 3,
        [Description("原材料")]
        åŽŸææ–™ = 3,
        /// <summary>
        /// å¤‡ä»¶
        /// </summary>
        SpareParts = 4
        [Description("备件")]
        å¤‡ä»¶ = 4
    }
}
´úÂë¹ÜÀí/WMS/WIDESEA_WMSServer/WIDESEA_DTO/Stock/MaterielnfoStatisticsDTO.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,66 @@
using Magicodes.ExporterAndImporter.Core;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WIDESEA_Model.Models;
namespace WIDESEA_DTO.Stock
{
   public class MaterielnfoStatisticsDTO
   {
        /// <summary>
        /// ä»“库ID
        /// </summary>
        [ExporterHeader(DisplayName = "仓库ID")]
        public int WarehouseId { get; set; }
        /// <summary>
        /// ç‰©æ–™ç¼–号
        /// </summary>
        [ExporterHeader(DisplayName = "物料编号")]
        public string MaterielCode { get; set; }
        /// <summary>
        /// ç‰©æ–™åç§°
        /// </summary>
        [ExporterHeader(DisplayName = "物料名称")]
        public string MaterielName { get; set; }
        /// <summary>
        /// åº“存数量
        /// </summary>
        [ExporterHeader(DisplayName = "库存数量")]
        public float StockQuantity { get; set; }
        /// <summary>
        /// å‡ºåº“数量
        /// </summary>
        [ExporterHeader(DisplayName = "出库数量")]
        public float OutboundQuantity { get; set; }
        /// <summary>
        /// åº“存状态
        /// </summary>
        [ExporterHeader(IsIgnore = true)]
        public int StockStatus { get; set; }
        /// <summary>
        /// å•位
        /// </summary>
        [ExporterHeader(DisplayName = "单位")]
        public string Unit { get; set; }
        /// <summary>
        /// å¤‡æ³¨
        /// </summary>
        [ExporterHeader(DisplayName = "备注")]
        public string Remark { get; set; }
    }
}
´úÂë¹ÜÀí/WMS/WIDESEA_WMSServer/WIDESEA_IStockService/IMaterielnfoStatisticsService.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WIDESEA_Core;
using WIDESEA_DTO.Stock;
namespace WIDESEA_IStockService
{
    public interface  IMaterielnfoStatisticsService : IDependency
    {
        PageGridData<MaterielnfoStatisticsDTO> GetPageGridData(PageDataOptions options);
        WebResponseContent Export(PageDataOptions options);
    }
}
´úÂë¹ÜÀí/WMS/WIDESEA_WMSServer/WIDESEA_Model/Models/Basic/Dt_MaterielInfo.cs
@@ -68,7 +68,7 @@
        /// <summary>
        /// ç‰ˆæœ¬åç§°
        /// </summary>
        [SugarColumn(IsNullable = false, Length = 50, ColumnDescription = "版本名称")]
        [SugarColumn(IsNullable = true, Length = 50, ColumnDescription = "版本名称")]
        public string MaterielVersion { get; set; }
        /// <summary>
´úÂë¹ÜÀí/WMS/WIDESEA_WMSServer/WIDESEA_StockService/MaterielnfoStatisticsService.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,308 @@
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using WIDESEA_Core;
using WIDESEA_Core.BaseRepository;
using WIDESEA_Core.DB.Models;
using WIDESEA_Core.Helper;
using WIDESEA_Core.HostedService;
using WIDESEA_DTO.Stock;
using WIDESEA_IStockService;
using WIDESEA_Model.Models;
using System.Linq;
using WIDESEA_Common.WareHouseEnum;
using Magicodes.ExporterAndImporter.Core;
using Magicodes.ExporterAndImporter.Excel;
using WIDESEA_Common.LocationEnum;
using WIDESEA_Core.Utilities;
namespace WIDESEA_StockService
{
    public partial class MaterielnfoStatisticsService : IMaterielnfoStatisticsService
    {
        public readonly IUnitOfWorkManage _unitOfWorkManage;
        public readonly SqlSugarClient _dbBase;
        public MaterielnfoStatisticsService(IUnitOfWorkManage unitOfWorkManage) {
            _unitOfWorkManage = unitOfWorkManage;
            _dbBase = unitOfWorkManage.GetDbClient();
        }
        public virtual PageGridData<MaterielnfoStatisticsDTO> GetPageGridData(PageDataOptions options)
        {
            try
            {
                List<MaterielnfoStatisticsDTO> materielnfoStatistics = new List<MaterielnfoStatisticsDTO>();
                ISugarQueryable<Dt_StockInfoDetail> sugarQueryable1 = _dbBase.Queryable<Dt_StockInfoDetail>();
                string whereStoDe = GetDataRole(typeof(Dt_StockInfoDetail));
                sugarQueryable1 = sugarQueryable1.Where(whereStoDe);
                string whereSto = GetDataRole(typeof(Dt_StockInfo));
                ISugarQueryable<Dt_StockInfo> sugarQueryable = _dbBase.Queryable<Dt_StockInfo>().Where(whereSto);
                if (!string.IsNullOrEmpty(options.Wheres))
                {
                    try
                    {
                        List<SearchParameters> searchParametersList = options.Wheres.DeserializeObject<List<SearchParameters>>();
                        if (searchParametersList.Count > 0)
                        {
                            {
                                SearchParameters? searchParameters = searchParametersList.FirstOrDefault(x => x.Name == nameof(Dt_StockInfoDetail.MaterielCode).FirstLetterToLower());
                                if (searchParameters != null)
                                {
                                    sugarQueryable1 = sugarQueryable1.Where(x => x.MaterielCode.Contains(searchParameters.Value));
                                }
                            }
                            {
                                SearchParameters? searchParameters = searchParametersList.FirstOrDefault(x => x.Name == nameof(Dt_StockInfo.WarehouseId).FirstLetterToLower());
                                if (searchParameters != null) {
                                    sugarQueryable = sugarQueryable.Where(x => x.WarehouseId.Equals(searchParameters.Value));
                                }
                            }
                            {
                                SearchParameters? searchParameters = searchParametersList.FirstOrDefault(x => x.Name == nameof(Dt_StockInfo.StockStatus).FirstLetterToLower());
                                if(searchParameters!= null)
                                {
                                    sugarQueryable = sugarQueryable.Where(x => x.StockStatus.Equals(searchParameters.Value));
                                }
                            }
                            {
                                SearchParameters? searchParameters = searchParametersList.FirstOrDefault(x => x.Name == nameof(Dt_StockInfoDetail.MaterielName).FirstLetterToLower());
                                if (searchParameters != null)
                                {
                                    sugarQueryable1 = sugarQueryable1.Where(x => x.MaterielName.Contains(searchParameters.Value));
                                }
                            }
                        }
                    }
                    catch(Exception ex)
                    {
                    }
                }
                ISugarQueryable<MaterielnfoStatisticsDTO> sugarQueryable2 = sugarQueryable1.InnerJoin(sugarQueryable, (b, a) => b.StockId == a.Id).Where((b,a)=>a.LocationCode!="" && a.LocationCode!=null).Select((b, a)
                    => new MaterielnfoStatisticsDTO
                    {
                        WarehouseId = a.WarehouseId,
                        MaterielCode = b.MaterielCode,
                        MaterielName = b.MaterielName,
                        StockQuantity = b.StockQuantity,
                        OutboundQuantity = b.OutboundQuantity,
                        StockStatus = a.StockStatus,
                        Unit = b.Unit,
                        Remark = a.Remark,
                    });
                // èŽ·å–æ‰€æœ‰æ•°æ®
                var allData = sugarQueryable2.ToList();
                // ä½¿ç”¨å­—典进行分组汇总
                var groupedData = new Dictionary<string, MaterielnfoStatisticsDTO>();
                foreach (var item in allData)
                {
                    if (groupedData.ContainsKey(item.MaterielCode))
                    {
                        groupedData[item.MaterielCode].StockQuantity += item.StockQuantity;
                        groupedData[item.MaterielCode].OutboundQuantity += item.OutboundQuantity;
                    }
                    else
                    {
                        groupedData[item.MaterielCode] = new MaterielnfoStatisticsDTO
                        {
                            WarehouseId = item.WarehouseId,
                            MaterielCode = item.MaterielCode,
                            MaterielName = item.MaterielName,
                            StockQuantity = item.StockQuantity,
                            OutboundQuantity = item.OutboundQuantity,
                            StockStatus = item.StockStatus,
                            Unit = item.Unit,
                            Remark = item.Remark
                        };
                    }
                }
                // è½¬æ¢ä¸ºåˆ—表
                materielnfoStatistics = groupedData.Values.ToList();
                // åˆ†é¡µå¤„理
                int startIndex = (options.Page - 1) * options.Rows;
                int endIndex = Math.Min(startIndex + options.Rows, materielnfoStatistics.Count);
                materielnfoStatistics = materielnfoStatistics.GetRange(startIndex, endIndex - startIndex);
                int count = groupedData.Count;
                return new PageGridData<MaterielnfoStatisticsDTO>(count, materielnfoStatistics);
            }
            catch(Exception ex)
            {
            }
            return new PageGridData<MaterielnfoStatisticsDTO>();
        }
        public virtual WebResponseContent Export(PageDataOptions options)
        {
            WebResponseContent content = new WebResponseContent();
            try
            {
                Type t = typeof(MaterielnfoStatisticsDTO);
                string savePath = AppDomain.CurrentDomain.BaseDirectory + $"ExcelExport";
                IExporter exporter = new ExcelExporter();
                options.Page = 1;
                options.Rows = 30;
                options.Order = "desc";
                options.Sort = "MaterielCode";
                List<MaterielnfoStatisticsDTO> materielnfoStatistics = new List<MaterielnfoStatisticsDTO>();
                ISugarQueryable<Dt_StockInfoDetail> sugarQueryable1 = _dbBase.Queryable<Dt_StockInfoDetail>();
                string whereStoDe = GetDataRole(typeof(Dt_StockInfoDetail));
                sugarQueryable1 = sugarQueryable1.Where(whereStoDe);
                string whereSto = GetDataRole(typeof(Dt_StockInfo));
                ISugarQueryable<Dt_StockInfo> sugarQueryable = _dbBase.Queryable<Dt_StockInfo>().Where(whereSto);
                if (!string.IsNullOrEmpty(options.Wheres))
                {
                    try
                    {
                        List<SearchParameters> searchParametersList = options.Wheres.DeserializeObject<List<SearchParameters>>();
                        if (searchParametersList.Count > 0)
                        {
                            {
                                SearchParameters? searchParameters = searchParametersList.FirstOrDefault(x => x.Name == nameof(Dt_StockInfoDetail.MaterielCode).FirstLetterToLower());
                                if (searchParameters != null)
                                {
                                    sugarQueryable1 = sugarQueryable1.Where(x => x.MaterielCode.Contains(searchParameters.Value));
                                }
                            }
                            {
                                SearchParameters? searchParameters = searchParametersList.FirstOrDefault(x => x.Name == nameof(Dt_StockInfo.WarehouseId).FirstLetterToLower());
                                if (searchParameters != null)
                                {
                                    sugarQueryable = sugarQueryable.Where(x => x.WarehouseId.Equals(searchParameters.Value));
                                }
                            }
                            {
                                SearchParameters? searchParameters = searchParametersList.FirstOrDefault(x => x.Name == nameof(Dt_StockInfo.StockStatus).FirstLetterToLower());
                                if (searchParameters != null)
                                {
                                    sugarQueryable = sugarQueryable.Where(x => x.StockStatus.Equals(searchParameters.Value));
                                }
                            }
                            {
                                SearchParameters? searchParameters = searchParametersList.FirstOrDefault(x => x.Name == nameof(Dt_StockInfoDetail.MaterielName).FirstLetterToLower());
                                if (searchParameters != null)
                                {
                                    sugarQueryable1 = sugarQueryable1.Where(x => x.MaterielName.Contains(searchParameters.Value));
                                }
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                    }
                }
                ISugarQueryable<MaterielnfoStatisticsDTO> sugarQueryable2 = sugarQueryable1.InnerJoin(sugarQueryable, (b, a) => b.StockId == a.Id).Where((b, a) => a.LocationCode != "" && a.LocationCode != null).Select((b, a)
                    => new MaterielnfoStatisticsDTO
                    {
                        WarehouseId = a.WarehouseId,
                        MaterielCode = b.MaterielCode,
                        MaterielName = b.MaterielName,
                        StockQuantity = b.StockQuantity,
                        OutboundQuantity = b.OutboundQuantity,
                        StockStatus = a.StockStatus,
                        Unit = b.Unit,
                        Remark = a.Remark,
                    });
                // èŽ·å–æ‰€æœ‰æ•°æ®
                var allData = sugarQueryable2.ToList();
                // ä½¿ç”¨å­—典进行分组汇总
                var groupedData = new Dictionary<string, MaterielnfoStatisticsDTO>();
                foreach (var item in allData)
                {
                    if (groupedData.ContainsKey(item.MaterielCode))
                    {
                        groupedData[item.MaterielCode].StockQuantity += item.StockQuantity;
                        groupedData[item.MaterielCode].OutboundQuantity += item.OutboundQuantity;
                    }
                    else
                    {
                        groupedData[item.MaterielCode] = new MaterielnfoStatisticsDTO
                        {
                            WarehouseId = item.WarehouseId,
                            MaterielCode = item.MaterielCode,
                            MaterielName = item.MaterielName,
                            StockQuantity = item.StockQuantity,
                            OutboundQuantity = item.OutboundQuantity,
                            StockStatus = item.StockStatus,
                            Unit = item.Unit,
                            Remark = item.Remark
                        };
                    }
                }
                // è½¬æ¢ä¸ºåˆ—表
                materielnfoStatistics = groupedData.Values.ToList();
                byte[] data = exporter.ExportAsByteArray(materielnfoStatistics).Result;
                string fileName = "物料分类统计.xlsx";
                FileHelper.WriteFile(savePath, fileName, data);
                content = WebResponseContent.Instance.OK(data: savePath + "\\" + fileName);
            }
            catch (Exception ex)
            {
                content = WebResponseContent.Instance.Error(ex.Message);
            }
            return content;
        }
        private string GetDataRole(Type type)
        {
            try
            {
                UserRole? userRole = PermissionDataHostService.UserRoles.FirstOrDefault(x => x.UserId == App.User.UserId);
                if (userRole == null)
                    throw new Exception($"无权限");
                if (type.IsAssignableFrom(typeof(BaseWarehouseEntity)) || type.GetProperty(nameof(BaseWarehouseEntity.WarehouseId)) != null)
                {
                    if (userRole.WarehouseIds.Count > 0)
                    {
                        return $"{nameof(BaseWarehouseEntity.WarehouseId)} in ({userRole.WarehouseIds.Serialize().Replace("[", "").Replace("]", "")})";
                    }
                    else
                        return $"1 != 1";
                }
                else
                {
                    return "1 = 1";
                }
            }
            catch (Exception ex)
            {
                throw new Exception($"无权限,{ex.Message}");
            }
        }
    }
}
´úÂë¹ÜÀí/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/Stock/MaterielnfoStatisticsController.cs
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,55 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using System.Reflection;
using WIDESEA_Core;
using WIDESEA_IStockService;
using WIDESEA_StockService;
namespace WIDESEA_WMSServer.Controllers.Stock
{
    [Route("api/MaterielnfoStatistics")]
    [Authorize,ApiController]
    public class MaterielnfoStatisticsController : Controller
    {
        private readonly IMaterielnfoStatisticsService _materielnfoStatisticsService;
        public MaterielnfoStatisticsController (IMaterielnfoStatisticsService materielnfoStatisticsService)
        {
            _materielnfoStatisticsService = materielnfoStatisticsService;
        }
        [HttpPost,Route("GetPageData")]
        public object GetPageData([FromBody] PageDataOptions options)
        {
            return _materielnfoStatisticsService.GetPageGridData(options);
        }
        /// <summary>
        /// å¯¼å‡ºæ•°æ®
        /// </summary>
        /// <param name="loadData"></param>
        /// <returns></returns>
        [HttpPost, Route("Export")]
        public virtual ActionResult Export([FromBody] PageDataOptions loadData)
        {
            WebResponseContent result = InvokeService("Export", new object[] { loadData }) as WebResponseContent;
            if (result.Status)
                return File(
                       System.IO.File.ReadAllBytes(result.Data.ToString()),
                       System.Net.Mime.MediaTypeNames.Application.Octet,
                       Path.GetFileName(result.Data.ToString())
                   );
            return Json(result);
        }
        private object InvokeService(string methodName, object[] parameters)
        {
            Type t = _materielnfoStatisticsService.GetType();
            List<Type> types = new List<Type>();
            foreach (var param in parameters)
            {
                types.Add(param.GetType());
            }
            MethodInfo method = t.GetMethod(methodName, types.ToArray());
            return method.Invoke(_materielnfoStatisticsService, parameters);
        }
    }
}