Commit c734d17c by zxw

单警柜切换模式

物资详情换orgid
第三方停启用状态
第三方批量完成打印单
统计导出调整
parent 4366ac90
......@@ -274,7 +274,7 @@ namespace JunmpPoliceStation.Controllers
/// <param name="jdata"></param>
/// <returns></returns>
[HttpPost("ChangeCabinetType")]
[NoSign]
public async Task<HttpResponseMessage> ChangeCabinetType([FromBody] JObject jdata)
{
return await Task.Run(() =>
......@@ -317,12 +317,20 @@ namespace JunmpPoliceStation.Controllers
var innerInv = updateInv.Where(x => x.CurrentState == 3).ToList();
if (innerInv.Count > 0)
{
return JsonManager.SimpleStatusResponse(ResultCode.CABINET_INVENTORY_EXIST);
//return JsonManager.SimpleStatusResponse(ResultCode.CABINET_INVENTORY_EXIST);
//清除物资绑定
foreach (var inventory in innerInv)
{
inventory.CabinetId = null;
inventory.CurrentState = 8;
updateInvs.Add(inventory);
}
}
var outInv = updateInv.Where(x => x.CurrentState == 7).ToList();
foreach (var Inv in outInv)
{
Inv.CabinetId = null;
Inv.CurrentState = 8;
updateInvs.Add(Inv);
}
}
......
......@@ -9222,11 +9222,11 @@ namespace JunmpPoliceStation.Controllers
{
if (entity.level == "本级")
{
expression = t => t.WarehouseCodeNavigation.OrgizationId.Equals(OrgId);
expression = t => t.OrgId.Equals(OrgId);
}
else
{
expression = t => dataList.Select(c => c.Id).Contains(t.WarehouseCodeNavigation.OrgizationId);
expression = t => dataList.Select(c => c.Id).Contains(t.OrgId);
}
}
else
......@@ -9289,11 +9289,18 @@ namespace JunmpPoliceStation.Controllers
expression = LambdaExtensions.AndAlso(expression, t => t.CurrentState != 6 && t.IsFixed == true);
break;
}
case "单警柜装备":
case "单警柜中":
{
expression = LambdaExtensions.AndAlso(expression, t => t.CurrentState == 3 || t.CurrentState == 7);
break;
}
case "仓库装备":
{
//(不包括单警柜的装备)
expression = LambdaExtensions.AndAlso(expression, t => t.CurrentState != 3 && t.CurrentState != 7);
break;
}
default:
break;
}
......@@ -9399,8 +9406,8 @@ namespace JunmpPoliceStation.Controllers
equipment.EquipmentCode,
warehouseName = equipment.WarehouseCodeNavigation?.Name,
equipment.WarehouseCode,
equipment.WarehouseCodeNavigation?.Orgization?.Name,
equipment.WarehouseCodeNavigation?.OrgizationId,
equipment.Org?.Name,
equipment.OrgId,
supplierName = equipment.SupplierCodeNavigation?.Name,
equipment.SupplierCode,
cabinetID = equipment.Cabinet?.Id,
......
......@@ -16,6 +16,9 @@ using System.Linq.Expressions;
using System.Net.Http;
using System.Threading.Tasks;
using JmpCommon.Tools;
using System.Configuration;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
namespace JunmpPoliceStation.Controllers
{
......@@ -243,28 +246,45 @@ namespace JunmpPoliceStation.Controllers
string id = entity.id;
string state = entity.state;
var OrgInfo = _unitOfWork.OrganizationRepository.Get(p => p.Id.Equals(id));
if (OrgInfo != null)
using (var scope = _unitOfWork.BeginTransaction())
{
OrgInfo.State = short.Parse(state);
bool result = _unitOfWork.OrganizationRepository.Update(OrgInfo, true);
if (result)
try
{
return JsonManager.SimpleStatusResponse(ResultCode.OPERATE_SUCCESS);
var OrgInfo = _unitOfWork.OrganizationRepository.Get(p => p.Id.Equals(id));
if (OrgInfo != null)
{
OrgInfo.State = short.Parse(state);
bool result = _unitOfWork.OrganizationRepository.Update(OrgInfo, true);
if (result)
{
//更新第三方停启用状态
using (var dbContext = new ApiSysDbContext())
{
dbContext.Database.ExecuteSqlRaw("update api_org set state={0} WHERE id={1}", OrgInfo.State, OrgInfo.Id);
}
scope.Commit();
return JsonManager.SimpleStatusResponse(ResultCode.OPERATE_SUCCESS);
}
else
{
scope.Rollback();
return JsonManager.SimpleStatusResponse(ResultCode.OPERATE_FAILED);
}
}
else
{
scope.Rollback();
return JsonManager.SimpleStatusResponse(ResultCode.ORGANIZATION_ERROR);
}
}
else
catch (Exception e)
{
return JsonManager.SimpleStatusResponse(ResultCode.OPERATE_FAILED);
scope.Rollback();
throw;
}
}
else
{
return JsonManager.SimpleStatusResponse(ResultCode.ORGANIZATION_ERROR);
}
}
else
{
......@@ -1453,6 +1473,13 @@ namespace JunmpPoliceStation.Controllers
#endregion
}
public class ApiSysDbContext : DbContext
{
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
var configuration = Startup.ServiceLocator.Instance.GetService<IConfiguration>();
optionsBuilder.UseSqlServer(configuration.GetConnectionString("ApiSysConnection"));
}
}
}
......@@ -21,6 +21,7 @@ using JunmpPoliceStation.Extensions;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
using MySqlX.XDevAPI.Common;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Rextec.SOA.Infrastructure;
......@@ -744,6 +745,75 @@ namespace JunmpPoliceStation.Controllers
}
/// <summary>
/// 批量更新EPC打印状态(第三方使用)
/// </summary>
/// <param name="jdata"></param>
/// <returns></returns>
/// <remarks>
/// /// ## 例子
///
/// {
/// "idList":["111","222"],
/// }
/// </remarks>
[HttpPost("UpdateRangeEpcStateDevelop")]
[ServiceFilter(typeof(ActionLimitAttribute))]
//[NoSign]
public async Task<HttpResponseMessage> UpdateRangeEpcStateDevelop([FromBody] JObject jdata)
{
return await Task.Run(() =>
{
try
{
if (jdata != null)
{
var entity = JsonManager.GetJsonEntity(jdata);
if (!entity.idList is IEnumerable)
{
return JsonManager.SimpleCustResponse($"idList is require");
}
var list = new List<string>();
foreach (var id in entity.idList)
{
list.Add(id.ToString());
}
var epcs = _unitOfWork.DbContext.CommonJpPurchaseEpcs
.Where(t => list.Contains(t.Id)
&& (t.CurrentState == 0 || t.CurrentState == 1) //允许重复执行打印绑定操作
)
.ToList();
if (epcs.Count > 0)
{
foreach (var epc in epcs)
{
epc.CurrentState = 1;
}
}
bool result = _unitOfWork.PurchaseEpcsRepository.Update(epcs);
return JsonManager.SimpleStatusResponse(ResultCode.OPERATE_SUCCESS);
}
else
{
return JsonManager.SimpleStatusResponse(ResultCode.REQUEST_DATA_ERROR);
}
}
catch (Exception ex)
{
//_logger.LogError("Login/SignIn 错误:" + ex.ToString());
return JsonManager.SimpleStatusResponse(ResultCode.OPERATE_FAILED);
}
});
}
/// <summary>
/// 获取装备号型、供应商
/// </summary>
/// <param name="jdata"></param>
......@@ -3793,7 +3863,7 @@ namespace JunmpPoliceStation.Controllers
/// <param name="jdata"></param>
/// <returns></returns>
[HttpPost("EditInventory")]
[SwaggerIgnore]
//[SwaggerIgnore]
public async Task<HttpResponseMessage> EditInventory([FromBody] JObject jdata)
{
return await Task.Run(() =>
......
......@@ -642,7 +642,7 @@ namespace JunmpPoliceStation.Controllers
c.FirstOrDefault().OrgName,
c.FirstOrDefault().FindCode,
c.FirstOrDefault().OrgCode,
zsCount = c.Count(f => f.CurrentState != 6&&f.CurrentState!=null),
zsCount = c.Count(f => f.CurrentState != 6 && f.CurrentState != null),
zkCount = c.Where(f => f.CurrentState.Equals(0) || f.CurrentState.Equals(3)).Count(),
ckCount = c.Where(f => !(f.CurrentState == null || f.CurrentState.Equals(0) || f.CurrentState.Equals(3) || f.CurrentState.Equals(6))).Count(),
bfCount = c.Where(f => f.CurrentState.Equals(6)).Count(),
......@@ -788,7 +788,7 @@ namespace JunmpPoliceStation.Controllers
"Org" ,
"Org.BaseJpCabinetOutinlogs" ,
"CommonJpEquipmentStates",
};
var Infoparam = new string[] { };
......@@ -820,7 +820,7 @@ namespace JunmpPoliceStation.Controllers
code = c.FirstOrDefault().EquipmentCodeNavigation?.Equipment?.Code,
equipmentCode = c.Key,
equipmentName = c.FirstOrDefault().EquipmentCodeNavigation.Name,
sumCount = c.Where(p=>p.CurrentState!=6).Count(),
sumCount = c.Where(p => p.CurrentState != 6).Count(),
syCount = c.Sum(c => c.Org.BaseJpCabinetOutinlogs.Where(p => p.State == "out" && p.OperationTime >= Convert.ToDateTime(startTime) && p.OperationTime <= Convert.ToDateTime(endTime)).Count()) + c.Sum(c => c.CommonJpEquipmentStates.Where(f => (f.ActionState.Equals(2) || f.ActionState.Equals(3) || f.ActionState.Equals(5) || f.ActionState.Equals(14) || f.ActionState.Equals(15)) && f.OutTime >= Convert.ToDateTime(startTime) && f.OutTime <= Convert.ToDateTime(endTime)).Count()),
wxCount = c.Sum(c => c.CommonJpEquipmentStates.Where(f => f.ActionState.Equals(6) && f.OutTime >= Convert.ToDateTime(startTime) && f.OutTime <= Convert.ToDateTime(endTime)).Count())
......@@ -890,7 +890,7 @@ namespace JunmpPoliceStation.Controllers
string OrgId = Guid.Empty.ToString();
string startTime = entity.startTime;
string endTime = entity.endTime;
string endTime = Convert.ToDateTime(entity.endTime).AddDays(1).ToString();
......@@ -916,7 +916,9 @@ namespace JunmpPoliceStation.Controllers
"EquipmentCodeNavigation" ,
"WarehouseCodeNavigation" ,
"WarehouseCodeNavigation.Orgization",
"CommonJpEquipmentStates"
"CommonJpEquipmentStates",
"Org",
"Org.BaseJpCabinetOutinlogs",
};
Expression<Func<CommonJpEquipmentInventory, bool>> expression = t => IdList.Contains(t.WarehouseCodeNavigation.OrgizationId) && (!t.InventoryState.Equals("loss"));
......@@ -937,14 +939,14 @@ namespace JunmpPoliceStation.Controllers
orgName = x.FirstOrDefault().WarehouseCodeNavigation.Orgization.Name,
orgCode = x.FirstOrDefault().WarehouseCodeNavigation.Orgization.Code,
sumCount = x.Count(),
syCount = x.Sum(c => c.CommonJpEquipmentStates.Where(f => (f.State.Equals(1) || f.State.Equals(3)) && (f.ActionState.Equals(2) || f.ActionState.Equals(3) || f.ActionState.Equals(5) || f.ActionState.Equals(14) || f.ActionState.Equals(15)) && f.OutTime >= Convert.ToDateTime(startTime) && f.OutTime <= Convert.ToDateTime(endTime).AddDays(1)).Count()),
syCount = x.Sum(c => c.Org.BaseJpCabinetOutinlogs.Where(p => p.State == "out" && p.OperationTime >= Convert.ToDateTime(startTime) && p.OperationTime <= Convert.ToDateTime(endTime)).Count()) + x.Sum(c => c.CommonJpEquipmentStates.Where(f => (f.ActionState.Equals(2) || f.ActionState.Equals(3) || f.ActionState.Equals(5) || f.ActionState.Equals(14) || f.ActionState.Equals(15)) && f.OutTime >= Convert.ToDateTime(startTime) && f.OutTime <= Convert.ToDateTime(endTime)).Count()),
wxCount = x.Sum(c => c.CommonJpEquipmentStates.Where(f => f.ActionState.Equals(6) && f.OutTime >= Convert.ToDateTime(startTime) && f.OutTime <= Convert.ToDateTime(endTime)).Count()),
children = x.GroupBy(a => a.EquipmentCode).Select(c => new
{
equipmentCode = c.Key,
equipmentName = c.FirstOrDefault().EquipmentCodeNavigation.Name,
sumCount = c.Count(),
syCount = c.Sum(c => c.CommonJpEquipmentStates.Where(f => (f.State.Equals(1) || f.State.Equals(3)) && (f.ActionState.Equals(2) || f.ActionState.Equals(3) || f.ActionState.Equals(5) || f.ActionState.Equals(14) || f.ActionState.Equals(15)) && f.OutTime >= Convert.ToDateTime(startTime) && f.OutTime <= Convert.ToDateTime(endTime)).Count()),
syCount = c.Sum(c => c.Org.BaseJpCabinetOutinlogs.Where(p => p.State == "out" && p.OperationTime >= Convert.ToDateTime(startTime) && p.OperationTime <= Convert.ToDateTime(endTime)).Count()) + c.Sum(c => c.CommonJpEquipmentStates.Where(f => (f.ActionState.Equals(2) || f.ActionState.Equals(3) || f.ActionState.Equals(5) || f.ActionState.Equals(14) || f.ActionState.Equals(15)) && f.OutTime >= Convert.ToDateTime(startTime) && f.OutTime <= Convert.ToDateTime(endTime)).Count()),
wxCount = c.Sum(c => c.CommonJpEquipmentStates.Where(f => f.ActionState.Equals(6) && f.OutTime >= Convert.ToDateTime(startTime) && f.OutTime <= Convert.ToDateTime(endTime)).Count())
}).OrderByDescending(f => f.syCount).ToList()
}).OrderBy(c => c.orgCode).ToList().Where(c => c.syCount > 0);
......@@ -1172,7 +1174,7 @@ namespace JunmpPoliceStation.Controllers
yearEndPrice = c.Where(f => !f.CurrentState.Equals(6) && f.Price != null && f.CreateTime?.Year <= year).Sum(k => k.Price),
yearAddCount = c.Where(f => !f.CurrentState.Equals(6) && f.CreateTime?.Year == year).Count(),
yearDelCount = c.Where(f => f.CurrentState.Equals(6) && f.CreateTime?.Year == year).Count(),
children = c.OrderBy(z => z.TypeOneId).ThenBy(z=>z.TypeTwoId).ThenBy(z => z.TypeThreeId).ThenBy(z => z.EquipmentCode1).GroupBy(a => a.EquipmentCode).Select(c => new
children = c.OrderBy(z => z.TypeOneId).ThenBy(z => z.TypeTwoId).ThenBy(z => z.TypeThreeId).ThenBy(z => z.EquipmentCode1).GroupBy(a => a.EquipmentCode).Select(c => new
{
id = c.FirstOrDefault().EquipmentCode,
name = c.FirstOrDefault().EquipmentName,
......@@ -1529,7 +1531,7 @@ namespace JunmpPoliceStation.Controllers
ParentName = c.FirstOrDefault().Name,
EquipmentName = c.FirstOrDefault().EquipmentName,
SizeName = c.FirstOrDefault().SizeName,
zsCount = c.Count(f => f.CurrentState != 6 ),
zsCount = c.Count(f => f.CurrentState != 6),
Price = c.FirstOrDefault().Price,
sumPrice = c.Count(f => f.CurrentState != 6) * c.Key.Price,
}
......@@ -1654,7 +1656,7 @@ namespace JunmpPoliceStation.Controllers
rowNumber = (idx + 1) + "",
id = c.FirstOrDefault().TypeOneId,
name = c.FirstOrDefault().ParentName,
zsCount = c.Count(f => f.CurrentState != 6 ),
zsCount = c.Count(f => f.CurrentState != 6 && f.CurrentState != null),
zkCount = c.Where(f => f.CurrentState.Equals(0) || f.CurrentState.Equals(3)).Count(),
ckCount = c.Where(f => !(f.CurrentState == null || f.CurrentState.Equals(0) || f.CurrentState.Equals(3) || f.CurrentState.Equals(6))).Count(),
bfCount = c.Where(f => f.CurrentState.Equals(6)).Count(),
......@@ -1663,7 +1665,7 @@ namespace JunmpPoliceStation.Controllers
rowNumber = (idx + 1) + "." + (idx1 + 1),
id = c.FirstOrDefault().TypeTwoId,
name = c.FirstOrDefault().TypeName,
zsCount = c.Count(f => f.CurrentState != 6),
zsCount = c.Count(f => f.CurrentState != 6 && f.CurrentState != null),
zkCount = c.Where(f => f.CurrentState.Equals(0) || f.CurrentState.Equals(3)).Count(),
ckCount = c.Where(f => !(f.CurrentState == null || f.CurrentState.Equals(0) || f.CurrentState.Equals(3) || f.CurrentState.Equals(6))).Count(),
bfCount = c.Where(f => f.CurrentState.Equals(6)).Count(),
......@@ -1672,7 +1674,7 @@ namespace JunmpPoliceStation.Controllers
rowNumber = (idx + 1) + "." + (idx1 + 1) + "." + (idx2 + 1),
id = c.FirstOrDefault().TypeThreeId,
name = c.FirstOrDefault().Name,
zsCount = c.Count(f => f.CurrentState != 6),
zsCount = c.Count(f => f.CurrentState != 6 && f.CurrentState != null),
zkCount = c.Where(f => f.CurrentState.Equals(0) || f.CurrentState.Equals(3)).Count(),
ckCount = c.Where(f => !(f.CurrentState == null || f.CurrentState.Equals(0) || f.CurrentState.Equals(3) || f.CurrentState.Equals(6))).Count(),
bfCount = c.Where(f => f.CurrentState.Equals(6)).Count(),
......@@ -1681,7 +1683,7 @@ namespace JunmpPoliceStation.Controllers
rowNumber = (idx + 1) + "." + (idx1 + 1) + "." + (idx2 + 1) + "." + (idx3 + 1),
id = c.FirstOrDefault().EquipmentCode,
name = c.FirstOrDefault().EquipmentName,
zsCount = c.Count(f => f.CurrentState != 6),
zsCount = c.Count(f => f.CurrentState != 6 && f.CurrentState != null),
zkCount = c.Where(f => f.CurrentState.Equals(0) || f.CurrentState.Equals(3)).Count(),
ckCount = c.Where(f => !(f.CurrentState == null || f.CurrentState.Equals(0) || f.CurrentState.Equals(3) || f.CurrentState.Equals(6))).Count(),
bfCount = c.Where(f => f.CurrentState.Equals(6)).Count(),
......@@ -1694,7 +1696,7 @@ namespace JunmpPoliceStation.Controllers
suplierName = c.Key.SupplierName,
price = c.Key.Price,
sumPrice = c.Count(f => f.CurrentState != null) * c.Key.Price,
zsCount = c.Count(f => f.CurrentState != 6),
zsCount = c.Count(f => f.CurrentState != 6 && f.CurrentState != null),
zkCount = c.Where(f => f.CurrentState.Equals(0) || f.CurrentState.Equals(3)).Count(),
ckCount = c.Where(f => !(f.CurrentState == null || f.CurrentState.Equals(0) || f.CurrentState.Equals(3) || f.CurrentState.Equals(6))).Count(),
bfCount = c.Where(f => f.CurrentState.Equals(6)).Count()
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论