华港PDA调整 及条件出库

sdgslk
ZR20090193-陈敬勇 2 years ago
parent d29b25d08b
commit 8732919308

@ -353,6 +353,7 @@ let extension = {
this.$refs.modelBody.$refs.table1.reset();
this.$refs.modelBody.$refs.table2.reset();
this.$refs.modelBody.$refs.tab_truck.reset();
this.$refs.modelBody.$refs.tab_condition.reset();
this.$refs.modelBody.$refs.tab_infofiles.$refs.tab_infofiles.reset();
} else {
@ -360,6 +361,7 @@ let extension = {
this.$refs.modelBody.$refs.table1.load();
this.$refs.modelBody.$refs.table2.reset();
this.$refs.modelBody.$refs.tab_truck.load();
this.$refs.modelBody.$refs.tab_condition.load();
this.$refs.modelBody.$refs.tab_infofiles.$refs.tab_infofiles.load();
@ -379,12 +381,14 @@ let extension = {
return true;
},
setFormData(formData) {
console.log('条件数据',this.$refs.modelBody.$refs.tab_condition.rowData)
//新建或编辑时将从表1、2的数据提交到后台
//后台从对象里直接取extra的值
let extra = {
table1List: this.$refs.modelBody.$refs.table1.rowData,
table3List: this.$refs.modelBody.$refs.tab_truck.rowData,
table4List: this.$refs.modelBody.$refs.tab_infofiles.$refs.tab_infofiles.rowData
table4List: this.$refs.modelBody.$refs.tab_infofiles.$refs.tab_infofiles.rowData,
table6List: this.$refs.modelBody.$refs.tab_condition.rowData,
}
formData.extra = JSON.stringify(extra);
@ -425,6 +429,7 @@ let extension = {
this.$refs.modelBody.$refs.table1.load();
//this.$refs.modelBody.$refs.table2.load();
this.$refs.modelBody.$refs.tab_truck.load();
this.$refs.modelBody.$refs.tab_condition.load();
this.$refs.modelBody.$refs.tab_infofiles.$refs.tab_infofiles.load();
formData.mainData.MBLNO = this._mblno;
@ -435,6 +440,7 @@ let extension = {
this.$refs.modelBody.$refs.table1.load();
//this.$refs.modelBody.$refs.table2.load();
this.$refs.modelBody.$refs.tab_truck.load();
this.$refs.modelBody.$refs.tab_condition.load();
this.$refs.modelBody.$refs.tab_infofiles.$refs.tab_infofiles.load();
return true;
},
@ -575,6 +581,7 @@ let extension = {
this.$refs.modelBody.$refs.table1.load();
this.$refs.modelBody.$refs.tab_chfee.$refs.tab_chfee.load();
this.$refs.modelBody.$refs.tab_truckinfo.$refs.tab_truckinfo.load();
this.$refs.modelBody.$refs.tab_condition.$refs.tab_condition.load();
this.$refs.modelBody.$refs.tab_infofiles.$refs.tab_infofiles.load();
return true;

@ -58,7 +58,7 @@
@loadAfter="loadTableAfter1"
></vol-table>
<div class="tabs1-header" v-show="!isFEST">
<div class="tabs1-header" v-show="!isFEST&&!isBatchStock">
<div class="btn-group">
<Button type="info" size="small" icon="md-arrow-round-up" ghost @click="makedo">{{this.$t('labeltitle.AddToPlan')}}</Button>
<Label>{{this.$t('labeltitle.searchwms')}}</Label>
@ -153,7 +153,7 @@
</div>
<vol-table
ref="table2" v-show="!isFEST"
ref="table2" v-show="!isFEST&&!isBatchStock"
:loadKey="true"
:columns="tableColumns2"
:pagination-hide="false"
@ -192,6 +192,31 @@
@loadAfter="loadTableAfter_tab_truck"
></vol-table>
</TabPane>
<TabPane label="出库条件" icon="ios-aperture" v-if="isBatchStock">
<!-- 从表3配置 ,双击可以开启编辑-->
<div class="tabs1-header">
<!-- 显示操作按钮 -->
<!--<div class="message">tableColumns2配置,双击可以开启编辑</div>-->
<div class="btn-group">
<Button ref="btn_addcondition" type="info" size="small" ghost icon="md-add-circle" @click="addcondition">{{this.$t('ADDDETAIL')}}</Button>
<Button ref="btn_delcondition" type="info" size="small" ghost icon="md-remove-circle" @click="delcondition">{{this.$t('DELDETAIL')}}</Button>
<Button ref="btn_refresh" type="info" size="small" icon="md-refresh" ghost @click="()=>{$refs.tab_condition.load()}">{{this.$t('refrash')}}</Button>
</div>
</div>
<vol-table
ref="tab_condition"
:loadKey="true"
:columns="tableColumns4"
:pagination-hide="false"
:max-height="600"
:url="tab_conditionUrl"
:index="true"
@loadBefore="loadTableBefore_tab_condition"
@loadAfter="loadTableAfter_tab_condition"
></vol-table>
</TabPane>
<TabPane :label="this.$t('labeltitle.table_fee')" icon="ios-aperture">
@ -554,7 +579,19 @@ export default {
{field:'IMGPATH',title:this.$t('Img')+this.$t('Path'),type:'img',width:220,align:'left'}
]
,loadKey: true
//
,tab_conditionUrl: "api/Op_Wms_Logic/GetPageData", //GetPageData
//
tableColumns4: [
{field:'WMSLOGICID',title:'GID',type:'guid',width:90,hidden:true,readonly:true,require:true,align:'left'},
// {field:'WMSPLANID',title:'WMSPLANID',type:'guid',width:90,hidden:true,align:'left'},
{ field: "VALUE", title: '条件', type: "text", width: 120,bind:{ key:'ConditionStock',data:[]}, edit: { type: "select", keep: true }, hidden: false,sort:true //keep:truefalse
},
{ field: "VALUE2", title: '值', type: "text", width: 120, edit: { type: "text", keep: true }, hidden: false,sort:true//keep:truefalse
},
// {field:'truckteam',title:'',type: "text", edit: { type: "text", keep: true },width:90,align:'left',sortable:true},
],loadKey: true
,isFEST:false
,CNTRNOList:[]
,PRINTINFOList: [], //
@ -571,12 +608,14 @@ export default {
},
GoodsModelShow:{},
options:[],
conditionList:[],
// isBatchStock:false
};
},
created() {
this.getCustName();
// this.getConditionList();
//this.searchField_planlist.PLANTIME
window.Bodyhead = this;
window.Listhead = this.$store.getters.data().outplan_parent_head;
@ -617,6 +656,9 @@ export default {
if(x.label=="费用"){
x.disabled=true;
}
// if(x.label=="" && !isBatchStock){
// x.disabled=true;
// }
}
});
@ -734,7 +776,27 @@ export default {
param.wheres.push({ Name:"WMSPLANID",Value:headid,displayType:'='});
},
loadTableBefore_tab_condition(param, callBack) {
let _this=this.$store.getters.data().outplan_parent_head;
if (_this.currentAction == "Add") {
return callBack(false);
}
param.wheres=[];
let headid =this.getheadid()
param.wheres.push({ Name:"PID",Value:headid,displayType:'='});
},
loadTableAfter_tab_condition(data, callBack) {
// if(this.isFEST){
// let trucklist=[];
// data.forEach((x)=>{
// trucklist.push({key:x.TRUCKNO,value:x.TRUCKNO});
// })
// this.$refs.tab_infofiles.setTruckinfo(trucklist);
// }
return true;
},
//
loadTableAfter1(data, callBack) {
this.getphysics(data);
@ -785,7 +847,7 @@ export default {
setFormData(formData){
let extra = {
table1List: this.$refs.table1.rowData,
tab_truckList: this.$refs.tab_truck.rowData
tab_truckList: this.$refs.tab_truck.rowData,
}
formData.extra = JSON.stringify(extra);
return formData;
@ -1096,6 +1158,70 @@ export default {
this.CustomerList=selectCustName.data;
}
},
getConditionList() {
if(this.conditionList.length==0){
let selectCondition= this.getOption("ConditionStock");
this.conditionList=selectCondition.data;
}
},
addcondition(){
// let _headform=this.$store.getters.data().inplan_head;
// let editFormFields = _headform.geteditformfield();
this.$refs.tab_condition.addRow({WMSLOGICID:'00000000-0000-0000-0000-000000000000',WMSID:'00000000-0000-0000-0000-000000000000',NAME:'批量出库条件',VALUE:'',PID:this.getheadid()
,VALUE2:''
,VALUE3:''
});
},
delcondition() {
let _this=this;
if(!this.check())
return;
let rows = this.$refs.tab_condition.getSelected();
if (rows.length == 0) {
return this.$Message.error(this.$t('MSG.PleaseSelectRow'));
}
let delKeys = rows.map(x => {
return x['WMSLOGICID'];
});
let headid = this.getheadid();
let formData = {
mainData: {PID:headid},
detailData: null,
delKeys: delKeys,
workKeys: null,
extra:null
};
let tigger = false;
let delmsg = this.$t('MSG.DeleteAlertConfirm');
this.$Modal.confirm({
title: this.$t('MSG.DeleteAlert'),
content:
'<p style="color: red;font-weight: bold;letter-spacing: 3px;">'+delmsg+'?</p>',
onOk: () => {
if (tigger) return;
tigger = true;
//
if (_this.currentAction == "Add") {
// this.$refs.table1.reset();
_this.$refs.tab_condition.delRow(rows);
}else{
let url = "api/Op_Wms_Logic/DelDetail";
this.http.post(url, formData, this.$t('MSG.DeleteingData')).then(x => {
if (!x.status) return this.$Message.error(x.message);
tigger = false;
_this.$refs.tab_condition.delRow(rows);
//this.refresh();
});
}
} //, onCancel: () => {}
});
},
getphysics(datalist){
// let rows= this.$refs.table1.rowData;
// let workKeys = rows.map(x => {

@ -84,7 +84,7 @@
,{"title":"BILLTYPE","field":"BILLTYPE","type":"text","hidden":true}
]
,[{"title":"是否批次出库","field":"ISBATCHSTOCK","type":"switch"}]
,[{"title":"是否条件出库","field":"ISBATCHSTOCK","type":"switch"}]
],
searchFormFields: {"PLANTIME":"","CUSTOMERNAME":"","CORPID":"","CUSTOMNO":""},
searchFormOptions: [

@ -95,7 +95,7 @@ public virtual ActionResult GetPageData([FromBody] PageDataOptions loadData)
{
return Json(InvokeService("Upload", new object[] { files }));
}
[HttpPost, Route("CommonUpload"), AllowAnonymous]
public virtual IActionResult CommonUpload(IEnumerable<IFormFile> file)

@ -257,6 +257,26 @@ namespace VOL.Entity.DomainModels
[Column(TypeName="varchar(50)")]
public string ARCLIENTWMSOUT { get; set; }
/// <summary>
/// 原箱号
/// </summary>
public string OLD_CNTRNO { get; set; }
/// <summary>
/// 品牌
/// </summary>
public string GOODSMODEL { get; set; }
/// <summary>
/// 幅宽/规格
/// </summary>
public string GOODSMODEL2 { get; set; }
/// <summary>
/// 克重
/// </summary>
public string GOODSMODEL3 { get; set; }
/// <summary>
/// 合同号
/// </summary>
public string GOODSMODEL4 { get; set; }
}
}

@ -315,13 +315,11 @@ namespace VOL.Entity.DomainModels
public bool? ISSPENUM { get; set; }
/// <summary>
///是否批次出库
///是否条件出库
/// </summary>
[Display(Name = "是否批次出库")]
[Display(Name = "是否条件出库")]
[Column(TypeName = "bit")]
[Editable(true)]
public bool ISBATCHSTOCK { get; set; } = false;
public bool? ISBATCHSTOCK { get; set; }
}
}

@ -6,6 +6,7 @@ using VOL.Entity.DomainModels;
using VOL.Core.Utilities;
using System.Linq.Expressions;
using System;
using System.Threading.Tasks;
namespace VOL.WMS.IServices
{
@ -24,6 +25,8 @@ namespace VOL.WMS.IServices
public WebResponseContent (Guid PID, Guid WMSID, string Value);
public WebResponseContent GetConditionList(PageDataOptions options);
public bool (Guid PID);

@ -9,6 +9,15 @@ using VOL.WMS.IServices;
using VOL.Core.BaseProvider;
using VOL.Core.Extensions.AutofacManager;
using VOL.Entity.DomainModels;
using System;
using VOL.Core.Utilities;
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
using VOL.WMS.Repositories;
using System.Linq;
using ConvertHelper;
using System.Collections.Generic;
using static VOL.Entity.DomainModels.OP_WMS_TRUCK;
using OfficeOpenXml.FormulaParsing.Excel.Functions.DateTime;
namespace VOL.WMS.Services
{
@ -23,5 +32,6 @@ namespace VOL.WMS.Services
{
get { return AutofacContainerModule.GetService<IOp_Wms_LogicService>(); }
}
}
}

@ -28,10 +28,41 @@ namespace VOL.WMS.Services
public override PageGridData<Op_Wms_Logic> GetPageData(PageDataOptions options)
{
QueryRelativeExpression = (IQueryable<Op_Wms_Logic> queryable) =>
{
//如果该用户被限制于本公司 则必须
#region 查询
var PID = string.Empty;
var searchParametersList = options.Wheres.DeserializeObject<List<SearchParameters>>();
if (searchParametersList.Exists(x => x.Name == "PID"))
{
PID = searchParametersList.First(x => x.Name == "PID").Value;
queryable = queryable.Where(x => x.PID == Guid.Parse(PID) && x.NAME == "批量出库条件");
}
#endregion
return queryable;
};
var _r = base.GetPageData(options);
return _r;
}
public WebResponseContent GetConditionList(PageDataOptions options)
{
var res = new WebResponseContent();
var searchParametersList = options.Wheres.DeserializeObject<List<SearchParameters>>();
var PID = Guid.Parse(searchParametersList.First(x => x.Name == "PID").Value);
var data = Op_Wms_LogicRepository.Instance.FindAsIQueryable(x => x.PID == PID && x.NAME == "批量出库条件").ToList();
res.OK("获取数据成功", data);
return res;
}
public WebResponseContent DelDetail(SaveModel saveModel)
{
var canchange = BaseCheck.CanChange(saveModel);
@ -72,7 +103,7 @@ namespace VOL.WMS.Services
//如果没有 新增一条
if (string.IsNullOrWhiteSpace(saveModel.getMainDataValueStr("WMSLOGICID")))
if (string.IsNullOrWhiteSpace(saveModel.getMainDataValueStr(" ")))
{
var newrec = new Op_Wms_Logic();
newrec.WMSLOGICID = new Guid();

@ -28,6 +28,8 @@ using VOL.Core.Services;
using ConvertHelper;
using static VOL.Entity.DomainModels.OP_WMS_TRUCK;
using VOL.Core.Configuration;
using FastReport.Editor;
using System.Windows.Forms;
namespace VOL.WMS.Services
{
@ -256,6 +258,10 @@ namespace VOL.WMS.Services
public List<INFO_FILES> Table4List { get; set; }
public List<VW_OP_TRUCK_FILE> Table5List { get; set; }
/// <summary>
/// 出库条件
/// </summary>
public List<Op_Wms_Logic> Table6List { get; set; }
}
@ -444,6 +450,83 @@ namespace VOL.WMS.Services
if (!_r.Status) return _r;
}
List<Op_Wms_Logic> ConditionList = tableExtra.Table6List;
if (!ConditionList.isNullorEmpty())
{
var dealedconditionlist = new List<List<Op_Wms_Logic>>();
dealedconditionlist = DealBodyList(head.WMSPLANID, ConditionList, "OP_WMS_OUT_PLAN");
//var _r = AddTruckFile(saveDataModel, dealedbodylist2[0], dealedbodylist2[1], FileList, head);
//if (!_r.Status) return _r;
Op_Wms_LogicRepository.Instance.AddRange(dealedconditionlist[0]);
Op_Wms_LogicRepository.Instance.UpdateRange(dealedconditionlist[1]);
Op_Wms_LogicRepository.Instance.SaveChanges();
#region 产生条件出库范围
var List = Vw_Op_Wms_PhysicsRepository.Instance.FindAsIQueryable(x => (x.KGS > 0 || x.CBM > 0 || x.PKGS > 0 || x.STORAGEUNITCOUNT > 0)).ToList();
foreach (var item in ConditionList)
{
if (item.VALUE == "MBLNO")
{
List = List.Where(x => x.MBLNO == item.VALUE2).ToList();
}
if (item.VALUE == "GOODSMODEL")
{
List = List.Where(x => x.GOODSMODEL == item.VALUE2).ToList();
}
if (item.VALUE == "GOODSMODEL2")
{
List = List.Where(x => x.GOODSMODEL2 == item.VALUE2).ToList();
}
if (item.VALUE == "GOODSMODEL3")
{
List = List.Where(x => x.GOODSMODEL3 == item.VALUE2).ToList();
}
if (item.VALUE == "GOODSMODEL4")
{
List = List.Where(x => x.GOODSMODEL4 == item.VALUE2).ToList();
}
if (item.VALUE == "OLD_CNTRNO")
{
List = List.Where(x => x.OLD_CNTRNO == item.VALUE2).ToList();
}
if (item.VALUE == "CUSTOMERNAME")
{
List = List.Where(x => x.CUSTOMERNAME == item.VALUE2).ToList();
}
if (item.VALUE == "GOODSOWNER")
{
List = List.Where(x => x.GOODSOWNER == item.VALUE2).ToList();
}
}
//找到目前出库计划里已有的计划明细
var batchList = Op_Wms_LogicRepository.Instance.FindAsIQueryable(x => x.PID == head.WMSPLANID && x.NAME == "批量出库范围").ToList();
foreach (var item in List)
{
if (batchList.Where(x => batchList.Select(s => Guid.Parse(s.VALUE)).Contains(item.WMSPHYSICSID)).Count() > 0) continue;
var logic = new Op_Wms_Logic()
{
WMSLOGICID = new Guid(),
WMSID = item.WMSID,
PID = head.WMSPLANID,
VALUE = item.WMSPHYSICSID.ToString(),
NAME = "批量出库范围"
};
Op_Wms_LogicRepository.Instance.Add(logic);
}
Op_Wms_LogicRepository.Instance.SaveChanges();
#endregion
}
Logger.ADD_PUB("出库通知", head, saveDataModel.Extra.ToString());
return WebResponseContent.Instance.OK();
@ -509,14 +592,14 @@ namespace VOL.WMS.Services
LockList.Remove(headid);
return _webResponse;
}
//取值 是否批次出库
//取值 是否条件出库
var isBatchStock = saveModel.getMainDataValueStr("ISBATCHSTOCK") == "1" ? true : false;
var outplan = OP_WMS_OUT_PLANRepository.Instance.FindFirst(x => x.WMSPLANID ==Guid.Parse(headid));
if (outplan.ISBATCHSTOCK != isBatchStock)
{
LockList.Remove(headid);
return _webResponse.Error("批量出库标识不一致,请恢复");
return _webResponse.Error("条件出库标识不一致,请恢复");
}
//取出校验完成后的从表1.2的数据
@ -616,6 +699,63 @@ namespace VOL.WMS.Services
if (!_r.Status) return _r;
}
List<Op_Wms_Logic> ConditionList = tableExtra.Table6List;
if (!ConditionList.isNullorEmpty())
{
var dealedconditionlist = new List<List<Op_Wms_Logic>>();
dealedconditionlist = DealBodyList(head.WMSPLANID, ConditionList, "OP_WMS_OUT_PLAN");
//var _r = AddTruckFile(saveDataModel, dealedbodylist2[0], dealedbodylist2[1], FileList, head);
//if (!_r.Status) return _r;
Op_Wms_LogicRepository.Instance.AddRange(dealedconditionlist[0]);
Op_Wms_LogicRepository.Instance.UpdateRange(dealedconditionlist[1]);
Op_Wms_LogicRepository.Instance.SaveChanges();
#region 产生条件出库范围
var List = Vw_Op_Wms_PhysicsRepository.Instance.FindAsIQueryable(x => (x.KGS > 0 || x.CBM > 0 || x.PKGS > 0 || x.STORAGEUNITCOUNT > 0)).ToList();
foreach (var item in ConditionList)
{
if (item.VALUE == "MBLNO")
{
List = List.Where(x => x.MBLNO == item.VALUE2).ToList();
}
}
//找到目前出库计划里已有的计划明细
//var batchList = Op_Wms_LogicRepository.Instance.FindAsIQueryable(x => x.PID == head.WMSPLANID && x.NAME == "批量出库范围").ToList();
string sql = $"DELETE FROM Op_Wms_Logic where PID ='{head.WMSPLANID}' AND NAME ='批量出库范围';";
Op_Wms_LogicRepository.Instance.ExecuteSqlCommand(sql);
//foreach (var item in batchList)
//{
// Op_Wms_LogicRepository.Instance.Delete(item);
//}
//Op_Wms_LogicRepository.Instance.SaveChanges();
foreach (var item in List)
{
//if (batchList.Where(x => batchList.Select(s => Guid.Parse(s.VALUE)).Contains(item.WMSPHYSICSID)).Count() > 0) continue;
var logic = new Op_Wms_Logic()
{
WMSLOGICID = new Guid(),
WMSID = item.WMSID,
PID = head.WMSPLANID,
VALUE = item.WMSPHYSICSID.ToString(),
NAME = "批量出库范围"
};
Op_Wms_LogicRepository.Instance.Add(logic);
}
Op_Wms_LogicRepository.Instance.SaveChanges();
#endregion
}
Logger.ADD_PUB("出库通知", head, saveModel.Extra.ToString());
return WebResponseContent.Instance.OK();
@ -693,6 +833,9 @@ namespace VOL.WMS.Services
return _webResponse.OK("保存成功");
}
public WebResponseContent GetNewOutPlan() {
var result = new OP_WMS_OUT_PLAN();
@ -1210,7 +1353,7 @@ namespace VOL.WMS.Services
{
keys[i] = outplangoods_list[i].WMSOUTDETAILID.ToString();
}
//只有正常业务才产生出库明细 批次出库不用产生
//只有正常业务才产生出库明细 条件出库不用产生
if (!(bool)head.ISBATCHSTOCK)
{
List<VW_OP_WMS_OUT_DO_GOODS> outdogoods_list = VW_OP_WMS_OUT_DO_GOODSRepository.Instance.FindAsIQueryable(x => x.WMSPLANDETAILID == new Guid(keys[0])).ToList();
@ -1481,7 +1624,7 @@ namespace VOL.WMS.Services
if (outplan != null && outplan.ISBATCHSTOCK != isBatchStock)
{
return _webResponse.Error("批量出库标识不一致,请恢复");
return _webResponse.Error("条件出库标识不一致,请恢复");
}
if (!isBatchStock) //原有业务逻辑
@ -1575,9 +1718,9 @@ namespace VOL.WMS.Services
}
else
{
// 批次出库逻辑
// 条件出库逻辑
//找到目前出库计划里已有的计划明细
var batchList = Op_Wms_LogicRepository.Instance.FindAsIQueryable(x => x.PID == wmsplanid).ToList();
foreach (var item in List)
@ -1884,7 +2027,7 @@ namespace VOL.WMS.Services
else
if (ctninfo.Count > 0)
{
//只有正常业务才产生出库明细 批次出库不用产生
//只有正常业务才产生出库明细 条件出库不用产生
if (!(bool)head.ISBATCHSTOCK)
{
MakeOutDoDetail(head, ctninfo, newoutdo.WMSDOID);

@ -41,7 +41,7 @@ namespace VOL.WMS.Services
if (outplan != null && outplan.ISBATCHSTOCK != isBatchStock)
{
return _webResponse.Error("批量出库标识不一致,请恢复");
return _webResponse.Error("条件出库标识不一致,请恢复");
}
if (!isBatchStock)//原有业务逻辑

@ -9,6 +9,7 @@ using System.Collections.Generic;
using System.Threading.Tasks;
using VOL.Core.Enums;
using VOL.Core.Filters;
using VOL.Core.Utilities;
using VOL.Entity.DomainModels;
namespace VOL.WMS.Controllers
@ -20,5 +21,12 @@ namespace VOL.WMS.Controllers
{
return Json( Service.SaveLogicList(saveModel));
}
[Route("GetConditionList"), HttpPost, ApiActionPermission()]
public IActionResult GetConditionList([FromBody] PageDataOptions options)
{
return Json(Service.GetConditionList(options));
}
}
}

@ -3,15 +3,94 @@
*ActionAction使
*: [ApiActionPermission("VW_OP_WMS_IN_PLAN",Enums.ActionPermissionOptions.Search)]
*/
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using OfficeOpenXml.FormulaParsing.Excel.Functions.Text;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using VOL.Core.Extensions;
using VOL.Core.Utilities;
using VOL.Entity.DomainModels;
using VOL.WMS.Repositories;
namespace VOL.WMS.Controllers
{
public partial class VW_OP_WMS_IN_PLANController
{
/// <summary>
/// 默认上传文件大小限制3M
/// </summary>
protected int LimitUpFileSizee { get; set; } = 5;
/// <summary>
/// 上传文件-华港
/// </summary>
/// <param name="files"></param>
/// <returns></returns>
[HttpPost, Route("UploadHGTY"), AllowAnonymous]
public WebResponseContent UploadHGTY(List<Microsoft.AspNetCore.Http.IFormFile> files)
{
WebResponseContent webResponseContent = WebResponseContent.Instance;
if (files == null || files.Count == 0) return webResponseContent.Error("请上传文件");
//跟前端的控件名称保持一致
var WMSDOID = Request.Form["WMSDOID"];
var limitFiles = files.Where(x => x.Length > LimitUpFileSizee * 1024 * 1024).Select(s => s.FileName);
if (limitFiles.Count() > 0)
{
return webResponseContent.Error($"文件大小不能超过:{LimitUpFileSizee}M,{string.Join(",", limitFiles)}");
}
string filePath = $"Upload/Tables/INFO_FILES/{DateTime.Now.ToString("yyyMMddHHmmsss") + new Random().Next(1000, 9999)}/";
string fullPath = filePath.MapPath(true);
int i = 0;
// List<string> fileNames = new List<string>();
try
{
if (!Directory.Exists(fullPath)) Directory.CreateDirectory(fullPath);
for (i = 0; i < files.Count; i++)
{
string fileName = files[i].FileName;
//if (fileNames.Contains(fileName))
//{
// fileName += $"({i}){fileName}";
//}
//fileNames.Add(fileName);
using (var stream = new FileStream(fullPath + fileName, FileMode.Create))
{
files[i].CopyTo(stream);
}
var infoFile = new INFO_FILES()
{
GID = Guid.NewGuid(),
CNTRNO = "",
PID = Guid.Parse(WMSDOID),
FILENAME = fileName,
IMGPATH = filePath + fileName,
FILETYPE = "入库执行单",
PWORKTYPE = "入库执行",
CORPID = "",
ModifyDate = DateTime.Now,
CreateDate = DateTime.Now,
UPLOADEMPLY = "PDA",
};
INFO_FILESRepository.Instance.Add(infoFile);
}
//最终保存
INFO_FILESRepository.Instance.SaveChanges();
return webResponseContent.OK("文件上传成功");
}
catch (Exception ex)
{
return webResponseContent.Error("文件上传失败");
}
}
}
}

Loading…
Cancel
Save