PPModuleLogic.cs 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  1. /*******************************************************************************
  2. * Copyright(c) 2019 DongkeSoft All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:PPModuleLogic.cs
  5. * 2.功能描述:生产计划 年计划 业务逻辑
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * 徐伟 2019/08/30 1.00 新建
  9. *******************************************************************************/
  10. using System;
  11. using System.Collections;
  12. using System.Collections.Generic;
  13. using System.Data;
  14. using System.Text;
  15. using Oracle.DataAccess.Client;
  16. using Dongke.IBOSS.PRD.Basics.BaseResources;
  17. using Dongke.IBOSS.PRD.Basics.DataAccess;
  18. using Dongke.IBOSS.PRD.Service.CMNModuleService;
  19. using Dongke.IBOSS.PRD.Service.DataModels;
  20. using Dongke.IBOSS.PRD.WCF.DataModels;
  21. namespace Dongke.IBOSS.PRD.Service.PPModuleService
  22. {
  23. public class PPModuleLogic
  24. {
  25. #region 计划通用
  26. //获取 序列的值
  27. public static int Seq(string seqName)
  28. {
  29. return Convert.ToInt32(OracleDB.ExecuteScalar($"select {seqName} from dual"));
  30. }
  31. //生产计划类型 列表
  32. public static ServiceResultEntity PlanTypeSearch(ClientRequestEntity cre = null)
  33. {
  34. return OracleDB.ExecuteDataSetSRE("TP_PP_PLAN_TYPE", "search", cre, "displayno asc");
  35. }
  36. //生产计划产品 列表
  37. public static ServiceResultEntity PlanGoodsSearch(ClientRequestEntity cre = null)
  38. {
  39. return OracleDB.ExecuteDataSetSRE("TP_MST_GOODS", "search", cre, "goodsid asc");
  40. }
  41. #endregion
  42. #region 年计划
  43. //年计划 版本
  44. public static int PlanYearVer(int planTypeId)
  45. {
  46. return Convert.ToInt32(OracleDB.ExecuteScalar($"select nvl(max(PLANVER)+1,1) from TP_PP_PLAN_YEAR where PLANTYPEID = {planTypeId}"));
  47. }
  48. //年计划 保存副本
  49. public static int PlanYearCopy(int planId)
  50. {
  51. string sqlStr = @"";
  52. IDBTransaction conn = OracleDB.GetConn();
  53. //读取新ID序列
  54. int newPlanId = Convert.ToInt32(conn.GetSqlResultToObj($"select SEQ_PP_PLAN_YEAR_PLANID.NEXTVAL from dual"));
  55. //复制年计划===========================
  56. //取计划类型ID
  57. int planTypeId = Convert.ToInt32(conn.GetSqlResultToObj($"select PLANTYPEID from TP_PP_PLAN_YEAR where PLANID = {planId}"));
  58. //取最新版本+1
  59. int planVer = Convert.ToInt32(conn.GetSqlResultToObj($"select nvl(max(PLANVER)+1,1) from TP_PP_PLAN_YEAR where PLANTYPEID = {planTypeId}"));
  60. sqlStr = $@"insert into TP_PP_PLAN_YEAR (PLANID, YEARNO, PLANNAME, PLANTYPEID, PLANVER, STARTMONTH, ENDMONTH, STARTDATE, ENDDATE, REMARKS, ACCOUNTID, CREATETIME, CREATEUSERID, UPDATETIME, UPDATEUSERID, OPTIMESTAMP, SESSIONPROGRAM)
  61. select {newPlanId}, YEARNO, PLANNAME||'-副本', PLANTYPEID, {planVer}, STARTMONTH, ENDMONTH, STARTDATE, ENDDATE, REMARKS, ACCOUNTID, CREATETIME, CREATEUSERID, UPDATETIME, UPDATEUSERID, OPTIMESTAMP, SESSIONPROGRAM
  62. from TP_PP_PLAN_YEAR
  63. where PLANID = {planId}";
  64. OracleDB.ExecuteNonQuery(sqlStr, (IDataParameter[])null, conn, false);
  65. //======================================
  66. //复制年计划产量计划====================
  67. sqlStr = $@"insert into TP_PP_PLAN_YEAR_GOODS (PLANID, YEARNO, STARTDATE, ENDDATE, GOODSID, PLANQUANTITY, REMARKS, ACCOUNTID, CREATETIME, CREATEUSERID, UPDATETIME, UPDATEUSERID, OPTIMESTAMP, SESSIONPROGRAM)
  68. select {newPlanId}, YEARNO, STARTDATE, ENDDATE, GOODSID, PLANQUANTITY, REMARKS, ACCOUNTID, CREATETIME, CREATEUSERID, UPDATETIME, UPDATEUSERID, OPTIMESTAMP, SESSIONPROGRAM
  69. from TP_PP_PLAN_YEAR_GOODS
  70. where planid = {planId} ";
  71. OracleDB.ExecuteNonQuery(sqlStr, (IDataParameter[])null, conn, true);
  72. //======================================
  73. return newPlanId;
  74. }
  75. //年计划 列表 只取最新版本
  76. public static ServiceResultEntity PlanYearSearch(ClientRequestEntity cre = null)
  77. {
  78. return OracleDB.ExecuteDataSetSRE("VP_PP_PLAN_YEAR", "search", cre, "planid asc");
  79. }
  80. //年计划 列表 所有版本
  81. public static ServiceResultEntity PlanYearVerSearch(ClientRequestEntity cre = null)
  82. {
  83. return OracleDB.ExecuteDataSetSRE("VP_PP_PLAN_YEAR_VER", "search", cre, "planid asc");
  84. }
  85. //年计划 插入
  86. public static ServiceResultEntity PlanYearInsert(ClientRequestEntity cre = null)
  87. {
  88. return OracleDB.ExecuteNonQuerySRE("TP_PP_PLAN_YEAR", "insert", cre);
  89. }
  90. //年计划 更新
  91. public static ServiceResultEntity PlanYearUpdate(ClientRequestEntity cre = null)
  92. {
  93. return OracleDB.ExecuteNonQuerySRE("TP_PP_PLAN_YEAR", "update", cre);
  94. }
  95. //年计划 删除
  96. public static ServiceResultEntity PlanYearDelete(ClientRequestEntity cre = null)
  97. {
  98. return OracleDB.ExecuteNonQuerySRE("TP_PP_PLAN_YEAR", "delete", cre);
  99. }
  100. //年计划产量 列表
  101. public static ServiceResultEntity PlanYearGoodsSearch(ClientRequestEntity cre = null)
  102. {
  103. ServiceResultEntity sre = new ServiceResultEntity();
  104. return OracleDB.ExecuteDataSetSRE("VP_PP_PLAN_YEAR_GOODS", "search", cre, "plangoodsid asc");
  105. }
  106. //年计划 产量插入
  107. public static ServiceResultEntity PlanYearGoodsInsert(ClientRequestEntity cre = null)
  108. {
  109. return OracleDB.ExecuteNonQuerySRE("TP_PP_PLAN_YEAR_GOODS", "insert", cre);
  110. }
  111. //年计划 产量更新
  112. public static ServiceResultEntity PlanYearGoodsUpdate(ClientRequestEntity cre = null)
  113. {
  114. return OracleDB.ExecuteNonQuerySRE("TP_PP_PLAN_YEAR_GOODS", "update", cre);
  115. }
  116. //年计划 产量删除
  117. public static ServiceResultEntity PlanYearGoodsDelete(ClientRequestEntity cre = null)
  118. {
  119. return OracleDB.ExecuteNonQuerySRE("TP_PP_PLAN_YEAR_GOODS", "delete", cre);
  120. }
  121. #endregion
  122. #region 月计划
  123. //月计划 版本
  124. public static int PlanMonthVer(int planTypeId)
  125. {
  126. return Convert.ToInt32(OracleDB.ExecuteScalar($"select nvl(max(PLANVER)+1,1) from TP_PP_PLAN_MONTH where PLANTYPEID = {planTypeId}"));
  127. }
  128. //月计划 保存副本
  129. public static int PlanMonthCopy(int planId)
  130. {
  131. string sqlStr = @"";
  132. IDBTransaction conn = OracleDB.GetConn();
  133. //读取新ID序列
  134. int newPlanId = Convert.ToInt32(conn.GetSqlResultToObj($"select SEQ_PP_PLAN_MONTH_PLANID.NEXTVAL from dual"));
  135. //复制月计划===========================
  136. //取计划类型ID
  137. int planTypeId = Convert.ToInt32(conn.GetSqlResultToObj($"select PLANTYPEID from TP_PP_PLAN_MONTH where PLANID = {planId}"));
  138. //取最新版本+1
  139. int planVer = Convert.ToInt32(conn.GetSqlResultToObj($"select nvl(max(PLANVER)+1,1) from TP_PP_PLAN_MONTH where PLANTYPEID = {planTypeId}"));
  140. sqlStr = $@"insert into TP_PP_PLAN_MONTH (PLANID, YEARNO, MONTHNO, PLANNAME, PLANTYPEID, PLANVER, STARTDATE, ENDDATE, REMARKS, ACCOUNTID, CREATETIME, CREATEUSERID, UPDATETIME, UPDATEUSERID, OPTIMESTAMP, SESSIONPROGRAM)
  141. select {newPlanId}, YEARNO, MONTHNO, PLANNAME||'-副本', PLANTYPEID, {planVer}, STARTDATE, ENDDATE, REMARKS, ACCOUNTID, CREATETIME, CREATEUSERID, UPDATETIME, UPDATEUSERID, OPTIMESTAMP, SESSIONPROGRAM
  142. from TP_PP_PLAN_MONTH
  143. where PLANID = {planId}";
  144. OracleDB.ExecuteNonQuery(sqlStr, (IDataParameter[])null, conn, false);
  145. //======================================
  146. //复制月计划产量计划====================
  147. sqlStr = $@"insert into TP_PP_PLAN_MONTH_GOODS (PLANID, YEARNO, MONTHNO, STARTDATE, ENDDATE, GOODSID, PLANQUANTITY, REMARKS, ACCOUNTID, CREATETIME, CREATEUSERID, UPDATETIME, UPDATEUSERID, OPTIMESTAMP, SESSIONPROGRAM)
  148. select {newPlanId}, YEARNO, MONTHNO, STARTDATE, ENDDATE, GOODSID, PLANQUANTITY, REMARKS, ACCOUNTID, CREATETIME, CREATEUSERID, UPDATETIME, UPDATEUSERID, OPTIMESTAMP, SESSIONPROGRAM
  149. from TP_PP_PLAN_MONTH_GOODS
  150. where planid = {planId} ";
  151. OracleDB.ExecuteNonQuery(sqlStr, (IDataParameter[])null, conn, true);
  152. //======================================
  153. return newPlanId;
  154. }
  155. //月计划 列表 只取最新版本
  156. public static ServiceResultEntity PlanMonthSearch(ClientRequestEntity cre = null)
  157. {
  158. return OracleDB.ExecuteDataSetSRE("VP_PP_PLAN_MONTH", "search", cre, "planid asc");
  159. }
  160. //月计划 列表 所有版本
  161. public static ServiceResultEntity PlanMonthVerSearch(ClientRequestEntity cre = null)
  162. {
  163. return OracleDB.ExecuteDataSetSRE("VP_PP_PLAN_MONTH_VER", "search", cre, "planid asc");
  164. }
  165. //月计划 插入
  166. public static ServiceResultEntity PlanMonthInsert(ClientRequestEntity cre = null)
  167. {
  168. return OracleDB.ExecuteNonQuerySRE("TP_PP_PLAN_MONTH", "insert", cre);
  169. }
  170. //月计划 更新
  171. public static ServiceResultEntity PlanMonthUpdate(ClientRequestEntity cre = null)
  172. {
  173. return OracleDB.ExecuteNonQuerySRE("TP_PP_PLAN_MONTH", "update", cre);
  174. }
  175. //月计划 删除
  176. public static ServiceResultEntity PlanMonthDelete(ClientRequestEntity cre = null)
  177. {
  178. return OracleDB.ExecuteNonQuerySRE("TP_PP_PLAN_MONTH", "delete", cre);
  179. }
  180. //月计划产量 列表
  181. public static ServiceResultEntity PlanMonthGoodsSearch(ClientRequestEntity cre = null)
  182. {
  183. ServiceResultEntity sre = new ServiceResultEntity();
  184. return OracleDB.ExecuteDataSetSRE("VP_PP_PLAN_MONTH_GOODS", "search", cre, "plangoodsid asc");
  185. }
  186. //月计划 产量插入
  187. public static ServiceResultEntity PlanMonthGoodsInsert(ClientRequestEntity cre = null)
  188. {
  189. return OracleDB.ExecuteNonQuerySRE("TP_PP_PLAN_MONTH_GOODS", "insert", cre);
  190. }
  191. //月计划 产量更新
  192. public static ServiceResultEntity PlanMonthGoodsUpdate(ClientRequestEntity cre = null)
  193. {
  194. return OracleDB.ExecuteNonQuerySRE("TP_PP_PLAN_MONTH_GOODS", "update", cre);
  195. }
  196. //月计划 产量删除
  197. public static ServiceResultEntity PlanMonthGoodsDelete(ClientRequestEntity cre = null)
  198. {
  199. return OracleDB.ExecuteNonQuerySRE("TP_PP_PLAN_MONTH_GOODS", "delete", cre);
  200. }
  201. #endregion
  202. #region 日计划
  203. //日计划 版本
  204. public static int PlanDayVer(int planTypeId)
  205. {
  206. return Convert.ToInt32(OracleDB.ExecuteScalar($"select nvl(max(PLANVER)+1,1) from TP_PP_PLAN_DAY where PLANTYPEID = {planTypeId}"));
  207. }
  208. //日计划 保存副本
  209. public static int PlanDayCopy(int planId)
  210. {
  211. string sqlStr = @"";
  212. IDBTransaction conn = OracleDB.GetConn();
  213. //读取新ID序列
  214. int newPlanId = Convert.ToInt32(conn.GetSqlResultToObj($"select SEQ_PP_PLAN_DAY_PLANID.NEXTVAL from dual"));
  215. //复制日计划===========================
  216. //取计划类型ID
  217. int planTypeId = Convert.ToInt32(conn.GetSqlResultToObj($"select PLANTYPEID from TP_PP_PLAN_DAY where PLANID = {planId}"));
  218. //取最新版本+1
  219. int planVer = Convert.ToInt32(conn.GetSqlResultToObj($"select nvl(max(PLANVER)+1,1) from TP_PP_PLAN_DAY where PLANTYPEID = {planTypeId}"));
  220. sqlStr = $@"insert into TP_PP_PLAN_DAY (PLANID, YEARNO, MONTHNO, DAYNO, PLANNAME, PLANTYPEID, PLANVER, STARTDATE, ENDDATE, REMARKS, ACCOUNTID, CREATETIME, CREATEUSERID, UPDATETIME, UPDATEUSERID, OPTIMESTAMP, SESSIONPROGRAM)
  221. select {newPlanId}, YEARNO, MONTHNO, DAYNO, PLANNAME||'-副本', PLANTYPEID, {planVer}, STARTDATE, ENDDATE, REMARKS, ACCOUNTID, CREATETIME, CREATEUSERID, UPDATETIME, UPDATEUSERID, OPTIMESTAMP, SESSIONPROGRAM
  222. from TP_PP_PLAN_DAY
  223. where PLANID = {planId}";
  224. OracleDB.ExecuteNonQuery(sqlStr, (IDataParameter[])null, conn, false);
  225. //======================================
  226. //复制日计划产量计划====================
  227. sqlStr = $@"insert into TP_PP_PLAN_DAY_GOODS (PLANID, YEARNO, MONTHNO, DAYNO, STARTDATE, ENDDATE, GOODSID, PLANQUANTITY, REMARKS, ACCOUNTID, CREATETIME, CREATEUSERID, UPDATETIME, UPDATEUSERID, OPTIMESTAMP, SESSIONPROGRAM)
  228. select {newPlanId}, YEARNO, MONTHNO, DAYNO, STARTDATE, ENDDATE, GOODSID, PLANQUANTITY, REMARKS, ACCOUNTID, CREATETIME, CREATEUSERID, UPDATETIME, UPDATEUSERID, OPTIMESTAMP, SESSIONPROGRAM
  229. from TP_PP_PLAN_DAY_GOODS
  230. where planid = {planId} ";
  231. OracleDB.ExecuteNonQuery(sqlStr, (IDataParameter[])null, conn, true);
  232. //======================================
  233. return newPlanId;
  234. }
  235. //日计划 列表 只取最新版本
  236. public static ServiceResultEntity PlanDaySearch(ClientRequestEntity cre = null)
  237. {
  238. return OracleDB.ExecuteDataSetSRE("VP_PP_PLAN_DAY", "search", cre, "planid asc");
  239. }
  240. //日计划 列表 所有版本
  241. public static ServiceResultEntity PlanDayVerSearch(ClientRequestEntity cre = null)
  242. {
  243. return OracleDB.ExecuteDataSetSRE("VP_PP_PLAN_DAY_VER", "search", cre, "planid asc");
  244. }
  245. //日计划 插入
  246. public static ServiceResultEntity PlanDayInsert(ClientRequestEntity cre = null)
  247. {
  248. return OracleDB.ExecuteNonQuerySRE("TP_PP_PLAN_DAY", "insert", cre);
  249. }
  250. //日计划 更新
  251. public static ServiceResultEntity PlanDayUpdate(ClientRequestEntity cre = null)
  252. {
  253. return OracleDB.ExecuteNonQuerySRE("TP_PP_PLAN_DAY", "update", cre);
  254. }
  255. //日计划 删除
  256. public static ServiceResultEntity PlanDayDelete(ClientRequestEntity cre = null)
  257. {
  258. return OracleDB.ExecuteNonQuerySRE("TP_PP_PLAN_DAY", "delete", cre);
  259. }
  260. //日计划产量 列表
  261. public static ServiceResultEntity PlanDayGoodsSearch(ClientRequestEntity cre = null)
  262. {
  263. ServiceResultEntity sre = new ServiceResultEntity();
  264. return OracleDB.ExecuteDataSetSRE("VP_PP_PLAN_DAY_GOODS", "search", cre, "plangoodsid asc");
  265. }
  266. //日计划 产量插入
  267. public static ServiceResultEntity PlanDayGoodsInsert(ClientRequestEntity cre = null)
  268. {
  269. return OracleDB.ExecuteNonQuerySRE("TP_PP_PLAN_DAY_GOODS", "insert", cre);
  270. }
  271. //日计划 产量更新
  272. public static ServiceResultEntity PlanDayGoodsUpdate(ClientRequestEntity cre = null)
  273. {
  274. return OracleDB.ExecuteNonQuerySRE("TP_PP_PLAN_DAY_GOODS", "update", cre);
  275. }
  276. //日计划 产量删除
  277. public static ServiceResultEntity PlanDayGoodsDelete(ClientRequestEntity cre = null)
  278. {
  279. return OracleDB.ExecuteNonQuerySRE("TP_PP_PLAN_DAY_GOODS", "delete", cre);
  280. }
  281. #endregion
  282. }
  283. }