IwbDefinition.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524
  1. using System;
  2. using System.Data.Entity;
  3. using System.Linq;
  4. using System.Threading.Tasks;
  5. using Abp.Domain.Repositories;
  6. using IwbZero.Helper;
  7. using ShwasherSys.CompanyInfo;
  8. using ShwasherSys.Inspection;
  9. using ShwasherSys.Order;
  10. namespace ShwasherSys
  11. {
  12. /// <summary>
  13. /// 订单类型
  14. /// </summary>
  15. public class OrderTypeDefinition
  16. {
  17. /// <summary>
  18. /// 内销
  19. /// </summary>
  20. public const int InSale = 1;
  21. /// <summary>
  22. /// 外销
  23. /// </summary>
  24. public const int OutSale = 2;
  25. /// <summary>
  26. /// 换货
  27. /// </summary>
  28. public const int Exchange = 3;
  29. public static async Task<string> GetNewOrderNo(IRepository<OrderHeader, string> orderHeaderRepository)
  30. {
  31. string lcRetVal = "";
  32. DateTime loTemp = DateTime.Parse(DateTime.Now.Year + "-" + DateTime.Now.Month + "-01");
  33. loTemp = loTemp.AddSeconds(-1);
  34. var order =await orderHeaderRepository.GetAll().Where(i => i.TimeCreated > loTemp).OrderByDescending(i => i.Id).FirstOrDefaultAsync();
  35. if (order!=null)
  36. {
  37. int liTempNo = 0;
  38. liTempNo = Convert.ToInt32(order.Id);
  39. liTempNo++;
  40. lcRetVal = liTempNo.ToString();
  41. if (lcRetVal.Length < 10)
  42. {
  43. lcRetVal = "0" + lcRetVal;
  44. }
  45. }
  46. else
  47. {
  48. DateTime loDate = DateTime.Today;
  49. int liMonth = loDate.Date.Month;
  50. string lcMonth = liMonth < 10 ? "0" + liMonth : liMonth.ToString();
  51. lcRetVal = loDate.Date.Year + lcMonth + "0001";
  52. }
  53. return lcRetVal;
  54. }
  55. }
  56. /// <summary>
  57. /// 产品类型定义
  58. /// </summary>
  59. public class ProductTypeDefinition
  60. {
  61. /// <summary>
  62. /// 半成品
  63. /// </summary>
  64. public const int Semi = 2;
  65. /// <summary>
  66. /// 成品
  67. /// </summary>
  68. public const int Finish = 1;
  69. public static async Task<string> GetDisProductNo(IRepository<DisqualifiedProduct> repository,int type)
  70. {
  71. string startNo = $"{DateTime.Now:yyMMdd}";
  72. var lastEntity = await repository.GetAll().Where(a => a.DisqualifiedNo.StartsWith(startNo)).OrderByDescending(a => a.Id)
  73. .FirstOrDefaultAsync();
  74. int noLength = 4, index = 0;
  75. if (lastEntity != null)
  76. {
  77. var entityNo = lastEntity.DisqualifiedNo;
  78. index = Convert.ToInt32(entityNo.Substring(entityNo.Length - noLength));
  79. }
  80. index++;
  81. string no = $"{startNo}{type}{index.LeftPad(noLength)}";
  82. if ((await repository.CountAsync(a=>a.DisqualifiedNo==no)) > 0)
  83. {
  84. no = await GetDisProductNo(repository,type);
  85. }
  86. return no;
  87. }
  88. }
  89. public class DisProductStateDefinition
  90. {
  91. /// <summary>
  92. /// 未处理
  93. /// </summary>
  94. public const int NoHandle = 1;
  95. /// <summary>
  96. /// 降级使用
  97. /// </summary>
  98. public const int Downgrade = 2;
  99. /// <summary>
  100. /// 报废处理
  101. /// </summary>
  102. public const int Scrapped = 3;
  103. /// <summary>
  104. /// 不报废降级
  105. /// </summary>
  106. public const int ScrappedDowngrade = 4;
  107. /// <summary>
  108. /// 返工反镀
  109. /// </summary>
  110. public const int AntiPlating = 5;
  111. /// <summary>
  112. /// 正常退货(无需检验)
  113. /// </summary>
  114. public const int NormalReturn = 6;
  115. /// <summary>
  116. /// 已降级
  117. /// </summary>
  118. public const int DowngradeHandled = 8;
  119. /// <summary>
  120. /// 已报废
  121. /// </summary>
  122. public const int ScrappedHandled = 9;
  123. /// <summary>
  124. /// 外购退货
  125. /// </summary>
  126. public const int OutPurchaseReturnGood = 10;
  127. /// <summary>
  128. /// 特殊采购(特采)
  129. /// </summary>
  130. public const int SpecialPurchase = 11;
  131. }
  132. public class LicenseTypeDefinition
  133. {
  134. /// <summary>
  135. /// 公司证照
  136. /// </summary>
  137. public const string Company = "公司证照";
  138. /// <summary>
  139. /// 员工证照
  140. /// </summary>
  141. public const string Employee = "员工证照";
  142. /// <summary>
  143. /// 设备证照
  144. /// </summary>
  145. public const string Device = "设备证照";
  146. /// <summary>
  147. /// 文书存档
  148. /// </summary>
  149. public const string Document = "文书存档";
  150. /// <summary>
  151. /// 其他
  152. /// </summary>
  153. public const string Other = "其他";
  154. }
  155. /// <summary>
  156. /// 维护设备类型
  157. /// </summary>
  158. public class MaintainTypeDefinition
  159. {
  160. /// <summary>
  161. /// 模具
  162. /// </summary>
  163. public const int Mold = 1;
  164. /// <summary>
  165. /// 设备
  166. /// </summary>
  167. public const int Device = 2;
  168. /// <summary>
  169. /// 其他
  170. /// </summary>
  171. public const int Other = 3;
  172. public static async Task<string> GetMoldNo(IRepository<Mold,int> repository)
  173. {
  174. string startNo = "SDA";
  175. var lastEntity = await repository.GetAll().Where(a => a.No.StartsWith(startNo)).OrderByDescending(a => a.Id)
  176. .FirstOrDefaultAsync();
  177. int noLength=6,index = 0;
  178. if (lastEntity!=null)
  179. {
  180. var entityNo = lastEntity.No;
  181. index = Convert.ToInt32(entityNo.Substring(entityNo.Length - noLength));
  182. }
  183. index++;
  184. string no = $"{startNo}{index.LeftPad(noLength)}";
  185. if ((await repository.CountAsync(a=>a.No==no)) > 0)
  186. {
  187. no = await GetMoldNo(repository);
  188. }
  189. return no;
  190. }
  191. public static async Task<string> GetDeviceNo(IRepository<FixedAsset,int> repository)
  192. {
  193. string startNo = "SDB";
  194. var lastEntity = await repository.GetAll().Where(a => a.No.StartsWith(startNo)).OrderByDescending(a => a.Id)
  195. .FirstOrDefaultAsync();
  196. int noLength=6,index = 0;
  197. if (lastEntity!=null)
  198. {
  199. var entityNo = lastEntity.No;
  200. index = Convert.ToInt32(entityNo.Substring(entityNo.Length - noLength));
  201. }
  202. index++;
  203. string no = $"{startNo}{index.LeftPad(noLength)}";
  204. if ((await repository.CountAsync(a=>a.No==no)) > 0)
  205. {
  206. no = await GetDeviceNo(repository);
  207. }
  208. return no;
  209. }
  210. public static async Task<string> GetDeviceMgPlanNo(IRepository<DeviceMgPlan,int> repository,int type)
  211. {
  212. string typeStr = type == 1 ? "SDA" : type == 2 ? "SDB" : "SDZ";
  213. string startNo = $"{typeStr}{DateTime.Now:yyMMdd}";
  214. var lastEntity = await repository.GetAll().Where(a => a.No.StartsWith(startNo)).OrderByDescending(a => a.Id)
  215. .FirstOrDefaultAsync();
  216. int noLength=4,index = 0;
  217. if (lastEntity!=null)
  218. {
  219. var entityNo = lastEntity.No;
  220. index = Convert.ToInt32(entityNo.Substring(entityNo.Length - noLength));
  221. }
  222. index++;
  223. string no = $"{startNo}{index.LeftPad(noLength)}";
  224. if ((await repository.CountAsync(a=>a.No==no)) > 0)
  225. {
  226. no = await GetDeviceMgPlanNo(repository,type);
  227. }
  228. return no;
  229. }
  230. public static async Task<string> GetMaintainRecordNo(IRepository<MaintenanceRecord,string> repository,int type)
  231. {
  232. string startNo = $"{DateTime.Now:yyMM}";
  233. var lastEntity = await repository.GetAll().Where(a => a.Id.StartsWith(startNo)).OrderByDescending(a => a.Id)
  234. .FirstOrDefaultAsync();
  235. int noLength=5,index = 0;
  236. if (lastEntity!=null)
  237. {
  238. var entityNo = lastEntity.Id;
  239. index = Convert.ToInt32(entityNo.Substring(entityNo.Length - noLength));
  240. }
  241. index++;
  242. string no = $"{startNo}{type}{index.LeftPad(noLength)}";
  243. if ((await repository.CountAsync(a=>a.Id==no)) > 0)
  244. {
  245. no = await GetMaintainRecordNo(repository,type);
  246. }
  247. return no;
  248. }
  249. }
  250. /// <summary>
  251. /// 维护记录状态
  252. /// </summary>
  253. public class MaintainStateDefinition
  254. {
  255. /// <summary>
  256. /// 新建
  257. /// </summary>
  258. public const int New = 1;
  259. /// <summary>
  260. /// 开始
  261. /// </summary>
  262. public const int Start = 2;
  263. /// <summary>
  264. /// 完成
  265. /// </summary>
  266. public const int Complete = 3;
  267. /// <summary>
  268. /// 结束
  269. /// </summary>
  270. public const int End = 4;
  271. public static string GetTypeName(int type)
  272. {
  273. var str = "";
  274. switch (type)
  275. {
  276. case 1:
  277. str = "新建";
  278. break;
  279. case 2:
  280. str = "开始";
  281. break;
  282. case 3:
  283. str = "完成";
  284. break;
  285. case 4:
  286. str = "结束";
  287. break;
  288. }
  289. return str;
  290. }
  291. }
  292. public class WorkTypeDefinition
  293. {
  294. /// <summary>
  295. /// 生产
  296. /// </summary>
  297. public const int Product = 1;
  298. /// <summary>
  299. /// 包装
  300. /// </summary>
  301. public const int Package = 2;
  302. /// <summary>
  303. /// 包装核件
  304. /// </summary>
  305. public const int VerifyPackage = 3;
  306. /// <summary>
  307. /// 模具维护
  308. /// </summary>
  309. public const int MoldMg = 4;
  310. /// <summary>
  311. /// 设备维护
  312. /// </summary>
  313. public const int DeviceMg = 5;
  314. public static string GetWorkTypeName(int type)
  315. {
  316. var str = "";
  317. switch (type)
  318. {
  319. case 1:
  320. str = "车间生产";
  321. break;
  322. case 2:
  323. str = "包装负责";
  324. break;
  325. case 3:
  326. str = "包装核件";
  327. break;
  328. case 4:
  329. str = "模具维护";
  330. break;
  331. case 5:
  332. str = "设备维护";
  333. break;
  334. }
  335. return str;
  336. }
  337. public static async Task<string> GetPerformanceNo(IRepository<EmployeeWorkPerformance> repository,int type)
  338. {
  339. string startNo = $"{DateTime.Now:yyMMdd}";
  340. var lastEntity = await repository.GetAll().Where(a => a.PerformanceNo.StartsWith(startNo)).OrderByDescending(a => a.Id)
  341. .FirstOrDefaultAsync();
  342. int noLength=5,index = 0;
  343. if (lastEntity!=null)
  344. {
  345. var entityNo = lastEntity.PerformanceNo;
  346. index = Convert.ToInt32(entityNo.Substring(entityNo.Length - noLength));
  347. }
  348. index++;
  349. string no = $"{startNo}{type}{index.LeftPad(noLength)}";
  350. if ((await repository.CountAsync(a=>a.PerformanceNo==no)) > 0)
  351. {
  352. no = await GetPerformanceNo(repository,type);
  353. }
  354. return no;
  355. }
  356. }
  357. public class InspectConfirmStateDefinition
  358. {
  359. /// <summary>
  360. /// 未确认
  361. /// </summary>
  362. public const int New = 1;
  363. /// <summary>
  364. /// 已确认
  365. /// </summary>
  366. public const int Confirm = 2;
  367. public static async Task<string> GetReportNo(IRepository<ProductInspectReport> repository)
  368. {
  369. string startNo = $"{DateTime.Now:yyMM}";
  370. var lastEntity = await repository.GetAll().Where(a => a.ProductInspectReportNo.StartsWith(startNo)&& a.ProductInspectReportNo.Length<20).OrderByDescending(a => a.Id)
  371. .FirstOrDefaultAsync();
  372. int noLength = 6, index = 0;
  373. if (lastEntity != null)
  374. {
  375. var entityNo = lastEntity.ProductInspectReportNo;
  376. index = Convert.ToInt32(entityNo.Substring(entityNo.Length - noLength));
  377. }
  378. index++;
  379. string no = $"{startNo}{index.LeftPad(noLength)}";
  380. if ((await repository.CountAsync(a=>a.ProductInspectReportNo==no)) > 0)
  381. {
  382. no = await GetReportNo(repository);
  383. }
  384. return no;
  385. }
  386. }
  387. public class StoreHouseType
  388. {
  389. /// <summary>
  390. /// 成品仓库
  391. /// </summary>
  392. public const int Finish = 1;
  393. /// <summary>
  394. /// 半成品仓库
  395. /// </summary>
  396. public const int SemiFinish = 2;
  397. /// <summary>
  398. /// 原材料仓库
  399. /// </summary>
  400. public const int Rm = 3;
  401. }
  402. //1:新建 2:盘点中 3:盘点完成 4:取消关闭
  403. public class InventoryCheckState
  404. {
  405. public const int New = 1;
  406. public const int Checking = 2;
  407. public const int Finish = 3;
  408. public const int Closed = 4;
  409. }
  410. //1:生产检验不合格 2:退货检验不合格
  411. public class DisqualifiedType
  412. {
  413. public const int ProductionCheck = 1;
  414. public const int ReturnCheck = 2;
  415. }
  416. /// <summary>
  417. /// 退货/换货
  418. /// </summary>
  419. public class ReturnGoodType
  420. {
  421. public const int Return = 1;
  422. public const int Change = 2;
  423. }
  424. /// <summary>
  425. /// 退货单状态
  426. /// </summary>
  427. public class ReturnGoodStateDefinition
  428. {
  429. /// <summary>
  430. /// 新建
  431. /// </summary>
  432. public const int New = 1;
  433. /// <summary>
  434. /// 检验中
  435. /// </summary>
  436. public const int Check = 2;
  437. /// <summary>
  438. /// 已检验
  439. /// </summary>
  440. public const int HasChecked = 3;
  441. /// <summary>
  442. /// 申请退款
  443. /// </summary>
  444. public const int RefundApply = 4;
  445. /// <summary>
  446. /// 确认退款
  447. /// </summary>
  448. public const int RefundConfirm = 5;
  449. /// <summary>
  450. /// 结束
  451. /// </summary>
  452. public const int End = 9;
  453. }
  454. /// <summary>
  455. ///发票类型
  456. /// </summary>
  457. public class InvoiceTypeDefinition
  458. {
  459. /// <summary>
  460. /// 正常发票
  461. /// </summary>
  462. public const int Normal = 0;
  463. /// <summary>
  464. /// 红冲发票(退款)
  465. /// </summary>
  466. public const int RedReturn = 1;
  467. /// <summary>
  468. /// 红冲发票(少收)
  469. /// </summary>
  470. public const int RedLess = 2;
  471. /// <summary>
  472. /// 红冲发票(多收)
  473. /// </summary>
  474. public const int RedOver = 3;
  475. }
  476. /// <summary>
  477. /// 订单明细紧急程度
  478. /// </summary>
  479. public class OrderItemEmergencyLevel
  480. {
  481. /// <summary>
  482. /// 正常(默认)
  483. /// </summary>
  484. public const int Normal = 1;
  485. /// <summary>
  486. /// 紧急
  487. /// </summary>
  488. public const int Urge = 2;
  489. /// <summary>
  490. /// 延期
  491. /// </summary>
  492. public const int Delay = 3;
  493. }
  494. }