You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

493 lines
26 KiB

11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
  1. package com.spring.ifs.api;
  2. import com.spring.common.utils.DateUtils;
  3. import com.spring.ifs.data.*;
  4. import com.spring.ifs.utils.IfsConverterToMap;
  5. import com.spring.ifs.utils.IfsPlsqlUtils;
  6. import com.spring.modules.base.entity.WorkCenterCost;
  7. import com.spring.modules.part.vo.InventoryPartUnitCostSumVo;
  8. import ifs.fnd.ap.APException;
  9. import ifs.fnd.ap.RecordCollection;
  10. import ifs.fnd.ap.Server;
  11. import java.util.ArrayList;
  12. import java.util.HashMap;
  13. import java.util.List;
  14. import java.util.Map;
  15. /**
  16. * @description: 基础查询的api
  17. * @author LR
  18. * @date 2024/12/12 10:44
  19. * @version 1.0
  20. */
  21. public class BaseSearchApiTest {
  22. /**
  23. * @description: 查询IFS的加工中心
  24. * @author LR
  25. * @date 2024/12/12 11:02
  26. * @version 1.0
  27. */
  28. public static List<WorkCenter> getWorkCenterNos(Server srv, String siteCon, String ifsRowVersion) throws APException {
  29. StringBuilder searchSql = new StringBuilder();
  30. searchSql.append("SELECT wc.contract site, wc.work_center_no, wc.description work_center_desc, wc.work_center_code_db,");
  31. searchSql.append(" (CASE WHEN work_center_code_db='I' THEN '内部' ELSE '外部' END) work_center_type, 100 efficiency,");
  32. searchSql.append(" TO_CHAR(NVL(wc.average_capacity, 0), 'FM99999999999999999999999999999999999999.999999') averageCapacity,");
  33. searchSql.append(" NVL(wc.utilization, 0) utilization, wc.sched_capacity_db capacity_type_db,");
  34. searchSql.append(" (CASE WHEN sched_capacity_db = 'I' THEN '无限产能' ELSE '有限产能' END) capacity_type, wc.uom um_id,");
  35. searchSql.append(" (CASE WHEN wc.objstate = 'Active' THEN 'Y' ELSE 'N' END) active, wc.note_text remark, wc.create_date created_date,");
  36. searchSql.append(" wc.PRODUCTION_LINE pro_line_no, 'N' can_create_new_roll_flag, 'N' need_setup_flag, wc.objid ifsRowId, wc.OBJVERSION ifsRowVersion");
  37. searchSql.append(" FROM ifsapp.WORK_CENTER wc");
  38. searchSql.append(" WHERE wc.work_center_code_db IN ('I','O')");
  39. //添加判断的查询条件
  40. if(!(null == siteCon || "".equals(siteCon))) {
  41. searchSql.append(" AND wc.contract IN "+siteCon);
  42. }
  43. //设置查询的入参
  44. Map<String, String> inParam = new HashMap<>();
  45. if(!(null == ifsRowVersion || "".equals(ifsRowVersion))) {
  46. searchSql.append(" AND wc.OBJVERSION >= :ifsRowVersion");
  47. inParam.put("ifsRowVersion", ifsRowVersion);
  48. }
  49. //添加排序语句
  50. searchSql.append(" ORDER BY wc.OBJVERSION, wc.contract, wc.work_center_no");
  51. //调用查询的通用方法
  52. RecordCollection recordCollection = IfsPlsqlUtils.execSqlSearchGetRecordCollection(srv, searchSql, inParam);
  53. //判断能否返回
  54. if (recordCollection == null) {
  55. return new ArrayList<>();
  56. } else {
  57. List<WorkCenter> resultItems = new ArrayList<>();
  58. //调用通用的处理方法 返回Map
  59. List<Map<String, String>> resultList = IfsConverterToMap.ConverterIfsToList(recordCollection);
  60. //判断是否存在数据
  61. if(resultList == null) {
  62. return resultItems;
  63. }
  64. //获取数据转bean
  65. for (int i = 0; i < resultList.size(); i++) {
  66. Map<String, String> tempMap = resultList.get(i);
  67. WorkCenter tempItem = new WorkCenter();
  68. //设置参数
  69. tempItem.setIfsRowId(tempMap.get("IFSROWID"));
  70. tempItem.setIfsRowVersion(tempMap.get("IFSROWVERSION"));
  71. tempItem.setSite(tempMap.get("SITE"));
  72. tempItem.setWorkCenterNo(tempMap.get("WORK_CENTER_NO"));
  73. tempItem.setWorkCenterDesc(tempMap.get("WORK_CENTER_DESC"));
  74. tempItem.setWorkCenterTypeDb(tempMap.get("WORK_CENTER_CODE_DB"));
  75. tempItem.setWorkCenterType(tempMap.get("WORK_CENTER_TYPE"));
  76. tempItem.setAverageCapacity(tempMap.get("AVERAGECAPACITY"));
  77. tempItem.setEfficiency(tempMap.get("EFFICIENCY"));
  78. tempItem.setUtilization(tempMap.get("UTILIZATION"));
  79. tempItem.setCapacityTypeDb(tempMap.get("CAPACITY_TYPE_DB"));
  80. tempItem.setCapacityType(tempMap.get("CAPACITY_TYPE"));
  81. tempItem.setUmId(tempMap.get("UM_ID"));
  82. tempItem.setActive(tempMap.get("ACTIVE"));
  83. tempItem.setRemark(tempMap.get("REMARK"));
  84. tempItem.setCreatedDate(tempMap.get("CREATED_DATE"));
  85. tempItem.setProLineNo(tempMap.get("PRO_LINE_NO"));
  86. tempItem.setCanCreateNewRollFlag(tempMap.get("CAN_CREATE_NEW_ROLL_FLAG"));
  87. tempItem.setNeedSetupFlag(tempMap.get("NEED_SETUP_FLAG"));
  88. //添加对象
  89. resultItems.add(tempItem);
  90. }
  91. return resultItems;
  92. }
  93. }
  94. /**
  95. * @description: 查询机台的信息
  96. * @author LR
  97. * @date 2024/12/12 11:23
  98. * @version 1.0
  99. */
  100. public static List<WarehouseLocation> getWarehouseLocations(Server srv, String siteCon, String ifsRowVersion, int startIndex, int pageSize) throws APException {
  101. StringBuilder searchSql = new StringBuilder();
  102. searchSql.append("SELECT wbb.contract site, wbb.location_no location_id, wbb.description location_name, wbb.warehouse_id, 'Y' active, NULL create_date, 'admin' create_by,");
  103. searchSql.append(" NULL update_date, NULL update_by, ilt.inventory_location_type location_type, wbb.objid ifsRowId, wbb.OBJVERSION ifsRowVersion");
  104. searchSql.append(" FROM ifsapp.WAREHOUSE_BAY_BIN wbb, ifsapp.INVENTORY_LOCATION_GROUP ilt");
  105. searchSql.append(" WHERE wbb.location_group = ilt.LOCATION_GROUP");
  106. //添加判断的查询条件
  107. if(!(null == siteCon || "".equals(siteCon))) {
  108. searchSql.append(" AND wbb.contract IN "+siteCon);
  109. }
  110. //设置查询的入参
  111. Map<String, String> inParam = new HashMap<>();
  112. if(!(null == ifsRowVersion || "".equals(ifsRowVersion))) {
  113. searchSql.append(" AND wbb.OBJVERSION >= :ifsRowVersion");
  114. inParam.put("ifsRowVersion", ifsRowVersion);
  115. }
  116. //添加排序语句
  117. searchSql.append(" ORDER BY wbb.OBJVERSION, wbb.contract, wbb.location_no");
  118. //添加分页的查询语句
  119. searchSql.append(" OFFSET "+startIndex+" ROWS FETCH NEXT "+pageSize+" ROWS ONLY");
  120. //调用查询的通用方法
  121. RecordCollection recordCollection = IfsPlsqlUtils.execSqlSearchGetRecordCollection(srv, searchSql, inParam);
  122. //判断能否返回
  123. if (recordCollection == null) {
  124. return new ArrayList<>();
  125. } else {
  126. List<WarehouseLocation> resultItems = new ArrayList<>();
  127. //调用通用的处理方法 返回Map
  128. List<Map<String, String>> resultList = IfsConverterToMap.ConverterIfsToList(recordCollection);
  129. //判断是否存在数据
  130. if(resultList == null) {
  131. return resultItems;
  132. }
  133. //获取数据转bean
  134. for (int i = 0; i < resultList.size(); i++) {
  135. Map<String, String> tempMap = resultList.get(i);
  136. WarehouseLocation tempItem = new WarehouseLocation();
  137. //设置参数
  138. tempItem.setIfsRowId(tempMap.get("IFSROWID"));
  139. tempItem.setIfsRowVersion(tempMap.get("IFSROWVERSION"));
  140. tempItem.setSite(tempMap.get("SITE"));
  141. tempItem.setLocationId(tempMap.get("LOCATION_ID"));
  142. tempItem.setLocationName(tempMap.get("LOCATION_NAME"));
  143. tempItem.setWarehouseId(tempMap.get("WAREHOUSE_ID"));
  144. tempItem.setActive(tempMap.get("ACTIVE"));
  145. tempItem.setCreateDate(tempMap.get("CREATE_DATE")); // 从tempMap获取值,不再直接设为null
  146. tempItem.setCreateBy(tempMap.get("CREATE_BY")); // 注意:字段名也改为大写
  147. tempItem.setUpdateDate(tempMap.get("UPDATE_DATE")); // 从tempMap获取值,不再直接设为null
  148. tempItem.setUpdateBy(tempMap.get("UPDATE_BY"));//直接设为null,因为SQL中对应字段是NULL
  149. tempItem.setLocationType(tempMap.get("LOCATION_TYPE"));
  150. //添加对象
  151. resultItems.add(tempItem);
  152. }
  153. return resultItems;
  154. }
  155. }
  156. /**
  157. * @description: 查询人员等级
  158. * @author LR
  159. * @date 2024/12/12 11:27
  160. * @version 1.0
  161. */
  162. public static List<LaborClass> getIfsLaborClasss(Server srv, String siteCon, String ifsRowVersion) throws APException {
  163. StringBuilder searchSql = new StringBuilder();
  164. searchSql.append("SELECT lc.contract site, lc.labor_class_no level_id, lc.labor_class_description level_desc,");
  165. searchSql.append(" (CASE WHEN lc.objstate = 'Active' THEN 'Y' ELSE 'N' END) active, sysdate create_date, 'Admin' create_by,");
  166. searchSql.append(" NULL update_date, NULL update_by, 100 level_cost, lc.objid ifsRowId, lc.OBJVERSION ifsRowVersion");
  167. searchSql.append(" FROM ifsapp.labor_class lc");
  168. //添加判断的查询条件
  169. if(!(null == siteCon || "".equals(siteCon))) {
  170. searchSql.append(" WHERE lc.contract IN "+siteCon);
  171. }
  172. //设置查询的入参
  173. Map<String, String> inParam = new HashMap<>();
  174. if(!(null == ifsRowVersion || "".equals(ifsRowVersion))) {
  175. searchSql.append(" AND lc.OBJVERSION >= :ifsRowVersion");
  176. inParam.put("ifsRowVersion", ifsRowVersion);
  177. }
  178. //添加排序语句
  179. searchSql.append(" ORDER BY lc.OBJVERSION, lc.contract, lc.labor_class_no");
  180. //调用查询的通用方法
  181. RecordCollection recordCollection = IfsPlsqlUtils.execSqlSearchGetRecordCollection(srv, searchSql, inParam);
  182. //判断能否返回
  183. if (recordCollection == null) {
  184. return new ArrayList<>();
  185. } else {
  186. List<LaborClass> resultItems = new ArrayList<>();
  187. //调用通用的处理方法 返回Map
  188. List<Map<String, String>> resultList = IfsConverterToMap.ConverterIfsToList(recordCollection);
  189. //判断是否存在数据
  190. if(resultList == null) {
  191. return resultItems;
  192. }
  193. //获取数据转bean
  194. for (int i = 0; i < resultList.size(); i++) {
  195. Map<String, String> tempMap = resultList.get(i);
  196. LaborClass tempItem = new LaborClass();
  197. //设置参数
  198. tempItem.setIfsRowId(tempMap.get("IFSROWID"));
  199. tempItem.setIfsRowVersion(tempMap.get("IFSROWVERSION"));
  200. tempItem.setSite(tempMap.get("SITE"));
  201. tempItem.setLevelId(tempMap.get("LEVEL_ID"));
  202. tempItem.setLevelDesc(tempMap.get("LEVEL_DESC"));
  203. tempItem.setActive(tempMap.get("ACTIVE"));
  204. tempItem.setCreateDate(tempMap.get("CREATE_DATE")); // 从tempMap获取值
  205. tempItem.setCreateBy(tempMap.get("CREATE_BY")); // 注意:字段名也改为大写
  206. tempItem.setUpdateDate(tempMap.get("UPDATE_DATE")); // 从tempMap获取值
  207. tempItem.setUpdateBy(tempMap.get("UPDATE_BY")); // 从tempMap获取值
  208. tempItem.setLevelCost(tempMap.get("LEVEL_COST")); // 获取成本值
  209. //添加对象
  210. resultItems.add(tempItem);
  211. }
  212. return resultItems;
  213. }
  214. }
  215. /**
  216. * @description: 获取物料件的数据
  217. * @author LR
  218. * @date 2024/12/12 11:34
  219. * @version 1.0
  220. */
  221. public static List<PartCatalog> getPartCatalogs(Server srv, String ifsRowVersion, int startIndex, int pageSize) throws APException {
  222. StringBuilder searchSql = new StringBuilder();
  223. searchSql.append("SELECT PART_NO, DESCRIPTION partDesc, INFO_TEXT, STD_NAME_ID, UNIT_CODE,");
  224. searchSql.append(" LOT_TRACKING_CODE, WEIGHT_NET, UOM_FOR_WEIGHT_NET, VOLUME_NET, UOM_FOR_VOLUME_NET,");
  225. searchSql.append(" OBJID ifsRowId, OBJVERSION ifsRowVersion");
  226. searchSql.append(" FROM IFSAPP.PART_CATALOG pc");
  227. //设置查询的入参
  228. Map<String, String> inParam = new HashMap<>();
  229. if(!(null == ifsRowVersion || "".equals(ifsRowVersion))) {
  230. searchSql.append(" AND pc.OBJVERSION >= :ifsRowVersion");
  231. inParam.put("ifsRowVersion", ifsRowVersion);
  232. }
  233. //添加排序语句
  234. searchSql.append(" ORDER BY pc.OBJVERSION, pc.PART_NO, pc.DESCRIPTION");
  235. //添加分页的查询语句
  236. searchSql.append(" OFFSET "+startIndex+" ROWS FETCH NEXT "+pageSize+" ROWS ONLY");
  237. //调用查询的通用方法
  238. RecordCollection recordCollection = IfsPlsqlUtils.execSqlSearchGetRecordCollection(srv, searchSql, inParam);
  239. //判断能否返回
  240. if (recordCollection == null) {
  241. return new ArrayList<>();
  242. } else {
  243. List<PartCatalog> resultItems = new ArrayList<>();
  244. //调用通用的处理方法 返回Map
  245. List<Map<String, String>> resultList = IfsConverterToMap.ConverterIfsToList(recordCollection);
  246. //获取数据转bean
  247. for (int i = 0; i < resultList.size(); i++) {
  248. Map<String, String> tempMap = resultList.get(i);
  249. PartCatalog tempItem = new PartCatalog();
  250. //设置参数
  251. tempItem.setIfsRowId(tempMap.get("IFSROWID"));
  252. tempItem.setIfsRowVersion(tempMap.get("IFSROWVERSION"));
  253. tempItem.setPartNo(tempMap.get("PART_NO"));
  254. tempItem.setPartDesc(tempMap.get("PARTDESC")); // 注意:使用小写的partDesc以匹配属性名
  255. tempItem.setInfoText(tempMap.get("INFO_TEXT"));
  256. tempItem.setStdNameId(tempMap.get("STD_NAME_ID"));
  257. tempItem.setUnitCode(tempMap.get("UNIT_CODE"));
  258. tempItem.setLotTrackingCode(tempMap.get("LOT_TRACKING_CODE"));
  259. tempItem.setWeightNet(tempMap.get("WEIGHT_NET"));
  260. tempItem.setUomForWeightNet(tempMap.get("UOM_FOR_WEIGHT_NET"));
  261. tempItem.setVolumeNet(tempMap.get("VOLUME_NET"));
  262. tempItem.setUomForVolumeNet(tempMap.get("UOM_FOR_VOLUME_NET"));
  263. //添加对象
  264. resultItems.add(tempItem);
  265. }
  266. return resultItems;
  267. }
  268. }
  269. /**
  270. * @description: 查询库存件的属性值
  271. * @author LR
  272. * @date 2024/12/12 11:38
  273. * @version 1.0
  274. */
  275. public static List<InventoryValue> getInventoryValues(Server srv, String siteCon, String ifsRowVersion, int startIndex, int pageSize) throws APException {
  276. StringBuilder searchSql = new StringBuilder();
  277. searchSql.append("SELECT OBJID ifsRowId, OBJVERSION ifsRowVersion, CONTRACT site, PART_NO, CONFIGURATION_ID, LOT_BATCH_NO, SERIAL_NO,");
  278. searchSql.append(" ifsapp.Inventory_Part_Unit_Cost_API.Get_Inventory_Value_By_Method(CONTRACT,PART_NO,CONFIGURATION_ID,LOT_BATCH_NO,SERIAL_NO) inventoryValue");
  279. searchSql.append(" FROM ifsapp.INVENTORY_PART_UNIT_COST_SUM pcs");
  280. searchSql.append(" WHERE pcs.CONFIGURATION_ID = '*'");
  281. //添加判断的查询条件
  282. if(!(null == siteCon || "".equals(siteCon))) {
  283. searchSql.append(" AND pcs.contract IN "+siteCon);
  284. }
  285. //设置查询的入参
  286. Map<String, String> inParam = new HashMap<>();
  287. if(!(null == ifsRowVersion || "".equals(ifsRowVersion))) {
  288. searchSql.append(" AND pcs.OBJVERSION >= :ifsRowVersion");
  289. inParam.put("ifsRowVersion", ifsRowVersion);
  290. }
  291. //添加排序语句
  292. searchSql.append(" ORDER BY pcs.OBJVERSION, pcs.contract, pcs.PART_NO");
  293. //添加分页的查询语句
  294. searchSql.append(" OFFSET "+startIndex+" ROWS FETCH NEXT "+pageSize+" ROWS ONLY");
  295. //调用查询的通用方法
  296. RecordCollection recordCollection = IfsPlsqlUtils.execSqlSearchGetRecordCollection(srv, searchSql, inParam);
  297. //判断能否返回
  298. if (recordCollection == null) {
  299. return new ArrayList<>();
  300. } else {
  301. List<InventoryValue> resultItems = new ArrayList<>();
  302. //调用通用的处理方法 返回Map
  303. List<Map<String, String>> resultList = IfsConverterToMap.ConverterIfsToList(recordCollection);
  304. //获取数据转bean
  305. for (int i = 0; i < resultList.size(); i++) {
  306. Map<String, String> tempMap = resultList.get(i);
  307. InventoryValue tempItem = new InventoryValue();
  308. //设置参数
  309. tempItem.setIfsRowId(tempMap.get("IFSROWID"));
  310. tempItem.setIfsRowVersion(tempMap.get("IFSROWVERSION"));
  311. tempItem.setSite(tempMap.get("SITE"));
  312. tempItem.setPartNo(tempMap.get("PART_NO"));
  313. tempItem.setConfigurationId(tempMap.get("CONFIGURATION_ID"));
  314. tempItem.setLotBatchNo(tempMap.get("LOT_BATCH_NO"));
  315. tempItem.setSerialNo(tempMap.get("SERIAL_NO"));
  316. tempItem.setInventoryValue(tempMap.get("INVENTORYVALUE"));
  317. //添加对象
  318. resultItems.add(tempItem);
  319. }
  320. return resultItems;
  321. }
  322. }
  323. /**
  324. * @description: 根据条件查询库存件的成本价
  325. * @author LR
  326. * @date 2025/1/17 11:36
  327. * @version 1.0
  328. */
  329. public static InventoryValue getInventoryValueByPartNo(Server srv, String contract, String partNo) throws APException {
  330. StringBuilder searchSql = new StringBuilder();
  331. searchSql.append("SELECT OBJID ifsRowId, OBJVERSION ifsRowVersion, CONTRACT site, PART_NO, CONFIGURATION_ID, LOT_BATCH_NO, SERIAL_NO,");
  332. searchSql.append(" ifsapp.Inventory_Part_Unit_Cost_API.Get_Inventory_Value_By_Method(CONTRACT,PART_NO,CONFIGURATION_ID,LOT_BATCH_NO,SERIAL_NO) inventoryValue");
  333. searchSql.append(" FROM ifsapp.INVENTORY_PART_UNIT_COST_SUM pcs");
  334. searchSql.append(" WHERE pcs.CONTRACT = : contract AND pcs.PART_NO = :partNo AND pcs.CONFIGURATION_ID = '*'");
  335. //设置查询的入参
  336. Map<String, String> inParam = new HashMap<>();
  337. inParam.put("contract", contract);
  338. inParam.put("partNo", partNo);
  339. //调用查询的通用方法
  340. RecordCollection recordCollection = IfsPlsqlUtils.execSqlSearchGetRecordCollection(srv, searchSql, inParam);
  341. //判断能否返回
  342. if (recordCollection == null) {
  343. return null;
  344. } else {
  345. //调用通用的处理方法 返回Map
  346. Map<String, String> resultMap = IfsConverterToMap.ConverterIfsToMap(recordCollection.get(0));
  347. InventoryValue resultRow = new InventoryValue();
  348. //设置参数
  349. resultRow.setIfsRowId(resultMap.get("IFSROWID"));
  350. resultRow.setIfsRowVersion(resultMap.get("IFSROWVERSION"));
  351. resultRow.setSite(resultMap.get("SITE"));
  352. resultRow.setPartNo(resultMap.get("PART_NO"));
  353. resultRow.setConfigurationId(resultMap.get("CONFIGURATION_ID"));
  354. resultRow.setLotBatchNo(resultMap.get("LOT_BATCH_NO"));
  355. resultRow.setSerialNo(resultMap.get("SERIAL_NO"));
  356. resultRow.setInventoryValue(resultMap.get("INVENTORYVALUE"));
  357. return resultRow;
  358. }
  359. }
  360. /**
  361. * @description: 查询技术等级的属性列表
  362. * @author LR
  363. * @date 2025/1/17 14:12
  364. * @version 1.0
  365. */
  366. public static List<TechnicalAttribute> getTechnicalAttributesByCon(Server srv, String technicalSpecNo) throws APException {
  367. StringBuilder searchSql = new StringBuilder();
  368. searchSql.append("SELECT OBJID ifsRowId, OBJVERSION ifsRowVersion, TECHNICAL_SPEC_NO, TECHNICAL_CLASS, ATTRIB_NUMBER, ATTRIBUTE,");
  369. searchSql.append(" VALUE_NO, LOWER_LIMIT, UPPER_LIMIT, INFO, ALT_VALUE_NO, ALT_UNIT,");
  370. searchSql.append(" CASE WHEN objtype = 'TechnicalSpecNumeric' THEN 'Numeric'");
  371. searchSql.append(" WHEN objtype = 'TechnicalSpecAlphanum' THEN 'Alpha' ELSE '' END attributeType");
  372. searchSql.append(" FROM ifsapp.TECHNICAL_SPECIFICATION_BOTH");
  373. searchSql.append(" WHERE TECHNICAL_SPEC_NO = :technicalSpecNo");
  374. //设置查询的入参
  375. Map<String, String> inParam = new HashMap<>();
  376. inParam.put("technicalSpecNo", technicalSpecNo);
  377. //调用查询的通用方法
  378. RecordCollection recordCollection = IfsPlsqlUtils.execSqlSearchGetRecordCollection(srv, searchSql, inParam);
  379. //判断能否返回
  380. if (recordCollection == null) {
  381. return new ArrayList<>();
  382. } else {
  383. List<TechnicalAttribute> technicalAttributes = new ArrayList<>();
  384. //处理结果集
  385. List<Map<String, String>> resultList = IfsConverterToMap.ConverterIfsToList(recordCollection);
  386. //获取数据转bean
  387. for (int i = 0; i < resultList.size(); i++) {
  388. Map<String, String> tempMap = resultList.get(i);
  389. TechnicalAttribute tempItem = new TechnicalAttribute();
  390. //设置参数
  391. tempItem.setIfsRowId(tempMap.get("IFSROWID"));
  392. tempItem.setIfsRowVersion(tempMap.get("IFSROWVERSION"));
  393. tempItem.setTechnicalSpecNo(tempMap.get("TECHNICAL_SPEC_NO"));
  394. tempItem.setTechnicalClass(tempMap.get("TECHNICAL_CLASS"));
  395. tempItem.setAttribute(tempMap.get("ATTRIBUTE"));
  396. tempItem.setValueNo(tempMap.get("VALUE_NO"));
  397. tempItem.setLowerLimit(tempMap.get("LOWER_LIMIT"));
  398. tempItem.setUpperLimit(tempMap.get("UPPER_LIMIT"));
  399. tempItem.setInfo(tempMap.get("INFO"));
  400. tempItem.setAttributeType(tempMap.get("ATTRIBUTETYPE"));
  401. //添加对象
  402. technicalAttributes.add(tempItem);
  403. }
  404. return technicalAttributes;
  405. }
  406. }
  407. /**
  408. * @description: 加工中心成本
  409. * @author LR
  410. * @date 2025/2/10 15:17
  411. * @version 1.0
  412. */
  413. public static List<WorkCenterCost> getWorkCenterCosts(Server srv, String siteCon, String ifsRowVersion, int startIndex, int pageSize) throws APException {
  414. StringBuilder searchSql = new StringBuilder();
  415. searchSql.append("SELECT OBJID ifsRowId, OBJVERSION ifsRowVersion, CONTRACT, WORK_CENTER_NO,");
  416. searchSql.append(" ifsapp.WORK_CENTER_API.Get_Description(CONTRACT, WORK_CENTER_NO) workCenterDesc,");
  417. searchSql.append(" COST_SET, ifsapp.COST_SET_API.Get_Description(CONTRACT,COST_SET) costSetDesc, WC_RATE, WC_COST_CODE,");
  418. searchSql.append(" OVERHEAD1_FAC, OVERHEAD1_APPL, OVERHEAD2_FAC, OVERHEAD2_APPL,");
  419. searchSql.append(" to_char(START_DATE, 'yyyy-MM-dd') START_DATE, to_char(END_DATE, 'yyyy-MM-dd') END_DATE");
  420. searchSql.append(" FROM ifsapp.WORK_CENTER_COST");
  421. searchSql.append(" WHERE ifsapp.Work_Center_API.Get_Work_Center_Code_Db(contract, work_center_no) = 'I'");
  422. searchSql.append(" AND COST_SET = '1' AND END_DATE IS NULL");
  423. //设置查询的入参
  424. Map<String, String> inParam = new HashMap<>();
  425. //判断是否存在入参
  426. if (!(ifsRowVersion == null || "".equals(ifsRowVersion))){
  427. searchSql.append(" AND OBJVERSION >= :ifsRowVersion");
  428. inParam.put("ifsRowVersion", ifsRowVersion);
  429. }
  430. //添加排序语句
  431. searchSql.append(" ORDER BY CONTRACT, WORK_CENTER_NO, COST_SET, START_DATE");
  432. //添加分页的查询语句
  433. searchSql.append(" OFFSET "+startIndex+" ROWS FETCH NEXT "+pageSize+" ROWS ONLY");
  434. //调用查询的通用方法
  435. RecordCollection recordCollection = IfsPlsqlUtils.execSqlSearchGetRecordCollection(srv, searchSql, inParam);
  436. //判断能否返回
  437. if (recordCollection == null) {
  438. return new ArrayList<>();
  439. } else {
  440. List<WorkCenterCost> technicalAttributes = new ArrayList<>();
  441. //处理结果集
  442. List<Map<String, String>> resultList = IfsConverterToMap.ConverterIfsToList(recordCollection);
  443. //获取数据转bean
  444. for (int i = 0; i < resultList.size(); i++) {
  445. Map<String, String> tempMap = resultList.get(i);
  446. WorkCenterCost tempItem = new WorkCenterCost();
  447. //设置参数
  448. tempItem.setIfsRowId(tempMap.get("IFSROWID"));
  449. tempItem.setIfsRowVersion(tempMap.get("IFSROWVERSION"));
  450. tempItem.setSite(tempMap.get("CONTRACT"));
  451. tempItem.setWorkCenterNo(tempMap.get("WORK_CENTER_NO"));
  452. tempItem.setWorkCenterDesc(tempMap.get("WORKCENTERDESC"));
  453. tempItem.setCostSet(tempMap.get("COST_SET"));
  454. tempItem.setWcRate(tempMap.get("WC_RATE"));
  455. tempItem.setCostSetDesc(tempMap.get("COSTSETDESC"));
  456. tempItem.setWcCostCode(tempMap.get("WC_COST_CODE"));
  457. tempItem.setOverhead1Fac(tempMap.get("OVERHEAD1_FAC"));
  458. tempItem.setOverhead2Fac(tempMap.get("OVERHEAD2_FAC"));
  459. tempItem.setOverhead1Appl(tempMap.get("OVERHEAD1_APPL"));
  460. tempItem.setOverhead2Appl(tempMap.get("OVERHEAD2_APPL"));
  461. String startDate = tempMap.get("START_DATE");
  462. if (!(null == startDate || "".equals(startDate))){
  463. tempItem.setBeginDate(DateUtils.getStringToDate(startDate, "yyyy-MM-dd"));
  464. }else{
  465. tempItem.setBeginDate(null);
  466. }
  467. String endDate = tempMap.get("END_DATE");
  468. if (!(null == endDate || "".equals(endDate))) {
  469. tempItem.setEndDate(DateUtils.getStringToDate(endDate, "yyyy-MM-dd"));
  470. }else{
  471. tempItem.setEndDate(null);
  472. }
  473. //添加对象
  474. technicalAttributes.add(tempItem);
  475. }
  476. return technicalAttributes;
  477. }
  478. }
  479. }