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.

683 lines
37 KiB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
1 year ago
2 years ago
2 years ago
2 years ago
1 year ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
1 year ago
1 year ago
1 year ago
1 year ago
2 years 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.base.vo.PersonnelLevelVo;
  8. import com.spring.modules.part.entity.APIEntity.PartIfsInventory;
  9. import com.spring.modules.part.vo.InventoryPartUnitCostSumVo;
  10. import com.spring.modules.part.vo.LocationInformationVo;
  11. import com.spring.modules.part.vo.WorkCenterVo;
  12. import ifs.fnd.ap.APException;
  13. import ifs.fnd.ap.RecordCollection;
  14. import ifs.fnd.ap.Server;
  15. import org.slf4j.Logger;
  16. import java.math.BigDecimal;
  17. import java.math.MathContext;
  18. import java.math.RoundingMode;
  19. import java.util.ArrayList;
  20. import java.util.HashMap;
  21. import java.util.List;
  22. import java.util.Map;
  23. /**
  24. * @description: 基础查询的api
  25. * @author LR
  26. * @date 2024/12/12 10:44
  27. * @version 1.0
  28. */
  29. public class BaseSearchApi {
  30. private static Logger logger = org.slf4j.LoggerFactory.getLogger(BaseSearchApi.class);
  31. /**
  32. * @description: 查询IFS的加工中心
  33. * @author LR
  34. * @date 2024/12/12 11:02
  35. * @version 1.0
  36. */
  37. public static List<WorkCenterVo> getWorkCenterNos(Server srv, String siteCon, String ifsRowVersion) throws APException {
  38. StringBuilder searchSql = new StringBuilder();
  39. searchSql.append("SELECT wc.contract site, wc.work_center_no, wc.description work_center_desc, wc.work_center_code_db,");
  40. searchSql.append(" (CASE WHEN work_center_code_db='I' THEN '内部' ELSE '外部' END) work_center_type, 100 efficiency,");
  41. searchSql.append(" TO_CHAR(NVL(wc.average_capacity, 0), 'FM99999999999999999999999999999999999999.999999') averageCapacity,");
  42. searchSql.append(" NVL(wc.utilization, 0) utilization, wc.sched_capacity_db capacity_type_db,");
  43. searchSql.append(" (CASE WHEN sched_capacity_db = 'I' THEN '无限产能' ELSE '有限产能' END) capacity_type, wc.uom um_id,");
  44. searchSql.append(" (CASE WHEN wc.objstate = 'Active' THEN 'Y' ELSE 'N' END) active, wc.note_text remark, wc.create_date created_date,");
  45. searchSql.append(" wc.PRODUCTION_LINE pro_line_no, 'N' can_create_new_roll_flag, 'N' need_setup_flag, wc.objid ifsRowId, wc.OBJVERSION ifsRowVersion");
  46. searchSql.append(" FROM ifsapp.WORK_CENTER wc");
  47. searchSql.append(" WHERE wc.work_center_code_db IN ('I','O')");
  48. //添加判断的查询条件
  49. if(!(null == siteCon || "".equals(siteCon))) {
  50. searchSql.append(" AND wc.contract IN "+siteCon);
  51. }
  52. //设置查询的入参
  53. Map<String, String> inParam = new HashMap<>();
  54. if(!(null == ifsRowVersion || "".equals(ifsRowVersion))) {
  55. searchSql.append(" AND wc.OBJVERSION >= :ifsRowVersion");
  56. inParam.put("ifsRowVersion", ifsRowVersion);
  57. }
  58. //添加排序语句
  59. searchSql.append(" ORDER BY wc.OBJVERSION, wc.contract, wc.work_center_no");
  60. //调用查询的通用方法
  61. RecordCollection recordCollection = IfsPlsqlUtils.execSqlSearchGetRecordCollection(srv, searchSql, inParam);
  62. //判断能否返回
  63. if (recordCollection == null) {
  64. return new ArrayList<>();
  65. } else {
  66. List<WorkCenterVo> resultItems = new ArrayList<>();
  67. //调用通用的处理方法 返回Map
  68. List<Map<String, String>> resultList = IfsConverterToMap.ConverterIfsToList(recordCollection);
  69. //判断是否存在数据
  70. if(resultList == null) {
  71. return resultItems;
  72. }
  73. //获取数据转bean
  74. for (int i = 0; i < resultList.size(); i++) {
  75. Map<String, String> tempMap = resultList.get(i);
  76. WorkCenterVo tempItem = new WorkCenterVo();
  77. //设置参数
  78. //tempItem.setIfsRowId(tempMap.get("IFSROWID"));
  79. tempItem.setIfsRowVersion(tempMap.get("IFSROWVERSION"));
  80. tempItem.setSite(tempMap.get("SITE"));
  81. tempItem.setWorkCenterNo(tempMap.get("WORK_CENTER_NO"));
  82. tempItem.setWorkCenterDesc(tempMap.get("WORK_CENTER_DESC"));
  83. tempItem.setWorkCenterTypeDB(tempMap.get("WORK_CENTER_CODE_DB"));
  84. tempItem.setWorkCenterType(tempMap.get("WORK_CENTER_TYPE"));
  85. tempItem.setAverageCapacity(new BigDecimal(tempMap.get("AVERAGECAPACITY")));
  86. tempItem.setEfficiency(new BigDecimal(tempMap.get("EFFICIENCY")));
  87. tempItem.setUtilization(new BigDecimal(tempMap.get("UTILIZATION")));
  88. tempItem.setCapacityTypeDB(tempMap.get("CAPACITY_TYPE_DB"));
  89. tempItem.setCapacityType(tempMap.get("CAPACITY_TYPE"));
  90. tempItem.setUmId(tempMap.get("UM_ID"));
  91. tempItem.setActive(tempMap.get("ACTIVE"));
  92. tempItem.setRemark(tempMap.get("REMARK"));
  93. tempItem.setCreatedDate(DateUtils.getStringToDate(tempMap.get("CREATED_DATE"), "yyyy-MM-dd HH:mm:ss"));
  94. tempItem.setProLineNo(tempMap.get("PRO_LINE_NO"));
  95. tempItem.setCanCreateNewRollFlag(tempMap.get("CAN_CREATE_NEW_ROLL_FLAG"));
  96. tempItem.setNeedSetupFlag(tempMap.get("NEED_SETUP_FLAG"));
  97. //添加对象
  98. resultItems.add(tempItem);
  99. }
  100. return resultItems;
  101. }
  102. }
  103. /**
  104. * @description: 查询机台的信息
  105. * @author LR
  106. * @date 2024/12/12 11:23
  107. * @version 1.0
  108. */
  109. public static List<LocationInformationVo> getWarehouseLocations(Server srv, String siteCon, String ifsRowVersion, int startIndex, int pageSize) throws APException {
  110. StringBuilder searchSql = new StringBuilder();
  111. searchSql.append("SELECT contract site, location_no location_id, location_name, warehouse warehouse_id, 'Y' active, NULL create_date, 'admin' create_by,");
  112. searchSql.append(" '' update_date, '' update_by, location_type location_type");
  113. searchSql.append(" FROM ifsapp.INVENTORY_LOCATION14");
  114. searchSql.append(" WHERE 1 = 1");
  115. //添加判断的查询条件
  116. if(!(null == siteCon || "".equals(siteCon))) {
  117. searchSql.append(" AND contract IN "+siteCon);
  118. }
  119. //设置查询的入参
  120. Map<String, String> inParam = new HashMap<>();
  121. //添加排序语句
  122. searchSql.append(" ORDER BY contract, location_no");
  123. //添加分页的查询语句
  124. searchSql.append(" OFFSET "+startIndex+" ROWS FETCH NEXT "+pageSize+" ROWS ONLY");
  125. //调用查询的通用方法
  126. RecordCollection recordCollection = IfsPlsqlUtils.execSqlSearchGetRecordCollection(srv, searchSql, inParam);
  127. //判断能否返回
  128. if (recordCollection == null) {
  129. return new ArrayList<>();
  130. } else {
  131. List<LocationInformationVo> resultItems = new ArrayList<>();
  132. //调用通用的处理方法 返回Map
  133. List<Map<String, String>> resultList = IfsConverterToMap.ConverterIfsToList(recordCollection);
  134. //判断是否存在数据
  135. if(resultList == null) {
  136. return resultItems;
  137. }
  138. //获取数据转bean
  139. for (int i = 0; i < resultList.size(); i++) {
  140. Map<String, String> tempMap = resultList.get(i);
  141. LocationInformationVo tempItem = new LocationInformationVo();
  142. //设置参数
  143. //tempItem.setIfsRowId(tempMap.get("IFSROWID"));
  144. tempItem.setIfsRowVersion(tempMap.get("IFSROWVERSION"));
  145. tempItem.setSite(tempMap.get("SITE"));
  146. tempItem.setLocationId(tempMap.get("LOCATION_ID"));
  147. tempItem.setLocationName(tempMap.get("LOCATION_NAME"));
  148. tempItem.setWarehouseId(tempMap.get("WAREHOUSE_ID"));
  149. tempItem.setActive(tempMap.get("ACTIVE"));
  150. tempItem.setCreateDate(null); // 从tempMap获取值,不再直接设为null
  151. tempItem.setCreateBy("admin"); // 注意:字段名也改为大写
  152. tempItem.setUpdateDate(null); // 从tempMap获取值,不再直接设为null
  153. tempItem.setUpdateBy(null);//直接设为null,因为SQL中对应字段是NULL
  154. tempItem.setLocationType(tempMap.get("LOCATION_TYPE"));
  155. //添加对象
  156. resultItems.add(tempItem);
  157. }
  158. return resultItems;
  159. }
  160. }
  161. /**
  162. * @description: 查询人员等级
  163. * @author LR
  164. * @date 2024/12/12 11:27
  165. * @version 1.0
  166. */
  167. public static List<PersonnelLevelVo> getIfsLaborClasss(Server srv, String siteCon, String ifsRowVersion) throws APException {
  168. StringBuilder searchSql = new StringBuilder();
  169. searchSql.append("SELECT lc.contract site, lc.labor_class_no level_id, lc.labor_class_description level_desc,");
  170. searchSql.append(" (CASE WHEN lc.objstate = 'Active' THEN 'Y' ELSE 'N' END) active, sysdate create_date, 'Admin' create_by,");
  171. searchSql.append(" NULL update_date, NULL update_by, 100 level_cost, lc.objid ifsRowId, lc.OBJVERSION ifsRowVersion");
  172. searchSql.append(" FROM ifsapp.labor_class lc");
  173. //添加判断的查询条件
  174. if(!(null == siteCon || "".equals(siteCon))) {
  175. searchSql.append(" WHERE lc.contract IN "+siteCon);
  176. }
  177. //设置查询的入参
  178. Map<String, String> inParam = new HashMap<>();
  179. if(!(null == ifsRowVersion || "".equals(ifsRowVersion))) {
  180. searchSql.append(" AND lc.OBJVERSION >= :ifsRowVersion");
  181. inParam.put("ifsRowVersion", ifsRowVersion);
  182. }
  183. //添加排序语句
  184. searchSql.append(" ORDER BY lc.OBJVERSION, lc.contract, lc.labor_class_no");
  185. //调用查询的通用方法
  186. RecordCollection recordCollection = IfsPlsqlUtils.execSqlSearchGetRecordCollection(srv, searchSql, inParam);
  187. //判断能否返回
  188. if (recordCollection == null) {
  189. return new ArrayList<>();
  190. } else {
  191. List<PersonnelLevelVo> resultItems = new ArrayList<>();
  192. //调用通用的处理方法 返回Map
  193. List<Map<String, String>> resultList = IfsConverterToMap.ConverterIfsToList(recordCollection);
  194. //判断是否存在数据
  195. if(resultList == null) {
  196. return resultItems;
  197. }
  198. //获取数据转bean
  199. for (int i = 0; i < resultList.size(); i++) {
  200. Map<String, String> tempMap = resultList.get(i);
  201. PersonnelLevelVo tempItem = new PersonnelLevelVo();
  202. //设置参数
  203. //tempItem.setIfsRowId(tempMap.get("IFSROWID"));
  204. tempItem.setIfsRowVersion(tempMap.get("IFSROWVERSION"));
  205. tempItem.setSite(tempMap.get("SITE"));
  206. tempItem.setLevelId(tempMap.get("LEVEL_ID"));
  207. tempItem.setLevelDesc(tempMap.get("LEVEL_DESC"));
  208. tempItem.setActive(tempMap.get("ACTIVE"));
  209. tempItem.setCreateDate(DateUtils.getStringToDate(tempMap.get("CREATE_DATE"), "yyyy-MM-dd HH:mm:ss")); // 从tempMap获取值
  210. tempItem.setCreateBy(tempMap.get("CREATE_BY")); // 注意:字段名也改为大写
  211. tempItem.setUpdateDate(null); // 从tempMap获取值
  212. tempItem.setUpdateBy(tempMap.get("UPDATE_BY")); // 从tempMap获取值
  213. tempItem.setLevelCost(new BigDecimal(tempMap.get("LEVEL_COST"))); // 获取成本值
  214. //添加对象
  215. resultItems.add(tempItem);
  216. }
  217. return resultItems;
  218. }
  219. }
  220. /**
  221. * @description: 获取物料件的数据
  222. * @author LR
  223. * @date 2024/12/12 11:34
  224. * @version 1.0
  225. */
  226. public static List<PartCatalog> getPartCatalogs(Server srv, String ifsRowVersion, int startIndex, int pageSize) throws APException {
  227. StringBuilder searchSql = new StringBuilder();
  228. searchSql.append("SELECT PART_NO, DESCRIPTION partDesc, INFO_TEXT, STD_NAME_ID, UNIT_CODE,");
  229. searchSql.append(" LOT_TRACKING_CODE, WEIGHT_NET, UOM_FOR_WEIGHT_NET, VOLUME_NET, UOM_FOR_VOLUME_NET,");
  230. //2025-03-21 新增字段
  231. searchSql.append(" PART_MAIN_GROUP, CONDITION_CODE_USAGE_DB, MULTILEVEL_TRACKING_DB, ALLOW_AS_NOT_CONSUMED_DB,");
  232. searchSql.append(" LOT_QUANTITY_RULE, SUB_LOT_RULE, COMPONENT_LOT_RULE,");
  233. searchSql.append(" OBJID ifsRowId, OBJVERSION ifsRowVersion");
  234. searchSql.append(" FROM IFSAPP.PART_CATALOG pc");
  235. //设置查询的入参
  236. Map<String, String> inParam = new HashMap<>();
  237. if(!(null == ifsRowVersion || "".equals(ifsRowVersion))) {
  238. searchSql.append(" WHERE pc.OBJVERSION >= :ifsRowVersion");
  239. inParam.put("ifsRowVersion", ifsRowVersion);
  240. }
  241. //添加排序语句
  242. searchSql.append(" ORDER BY pc.OBJVERSION, pc.PART_NO, pc.DESCRIPTION");
  243. //添加分页的查询语句
  244. searchSql.append(" OFFSET "+startIndex+" ROWS FETCH NEXT "+pageSize+" ROWS ONLY");
  245. //调用查询的通用方法
  246. RecordCollection recordCollection = IfsPlsqlUtils.execSqlSearchGetRecordCollection(srv, searchSql, inParam);
  247. //判断能否返回
  248. if (recordCollection == null) {
  249. return new ArrayList<>();
  250. } else {
  251. List<PartCatalog> resultItems = new ArrayList<>();
  252. //调用通用的处理方法 返回Map
  253. List<Map<String, String>> resultList = IfsConverterToMap.ConverterIfsToList(recordCollection);
  254. //获取数据转bean
  255. for (int i = 0; i < resultList.size(); i++) {
  256. Map<String, String> tempMap = resultList.get(i);
  257. PartCatalog tempItem = new PartCatalog();
  258. //设置参数
  259. tempItem.setIfsRowId(tempMap.get("IFSROWID"));
  260. tempItem.setIfsRowVersion(tempMap.get("IFSROWVERSION"));
  261. tempItem.setPartNo(tempMap.get("PART_NO").trim());
  262. tempItem.setPartDesc(tempMap.get("PARTDESC")); // 注意:使用小写的partDesc以匹配属性名
  263. tempItem.setInfoText(tempMap.get("INFO_TEXT"));
  264. tempItem.setUnitCode(tempMap.get("UNIT_CODE"));
  265. tempItem.setLotTrackingCode(tempMap.get("LOT_TRACKING_CODE"));
  266. String weightNet = tempMap.get("WEIGHT_NET");
  267. if (null == weightNet || "".equals(weightNet) ||"NULL".equalsIgnoreCase(weightNet)) {
  268. tempItem.setWeightNet(null);
  269. }else {
  270. BigDecimal weightNetNum = new BigDecimal(weightNet);
  271. MathContext mc = new MathContext(6, RoundingMode.HALF_UP);
  272. BigDecimal result = weightNetNum.round(mc);
  273. tempItem.setWeightNetNum(result);
  274. }
  275. tempItem.setUomForWeightNet(tempMap.get("UOM_FOR_WEIGHT_NET"));
  276. String volumeNet = tempMap.get("VOLUME_NET");
  277. if (null == volumeNet || "".equals(volumeNet) ||"NULL".equalsIgnoreCase(volumeNet)) {
  278. tempItem.setVolumeNet(null);
  279. }else {
  280. BigDecimal volumeNetNum = new BigDecimal(volumeNet);
  281. MathContext mc = new MathContext(6, RoundingMode.HALF_UP);
  282. BigDecimal result = volumeNetNum.round(mc);
  283. tempItem.setVolumeNetNum(result);
  284. }
  285. tempItem.setUomForVolumeNet(tempMap.get("UOM_FOR_VOLUME_NET"));
  286. //新增字段
  287. tempItem.setPartMainGroup(tempMap.get("PART_MAIN_GROUP"));
  288. String conditionCodeUsageDb = tempMap.get("CONDITION_CODE_USAGE_DB");
  289. if ("ALLOW_COND_CODE".equalsIgnoreCase(conditionCodeUsageDb)) {
  290. tempItem.setConditionCodeUsageDb("Y");
  291. }else {
  292. tempItem.setConditionCodeUsageDb("N");
  293. }
  294. String multilevelTrackingDb = tempMap.get("MULTILEVEL_TRACKING_DB");
  295. if ("TRACKING_ON".equalsIgnoreCase(multilevelTrackingDb)) {
  296. tempItem.setMultilevelTrackingDb("Y");
  297. }else {
  298. tempItem.setMultilevelTrackingDb("N");
  299. }
  300. String allowAsNotConsumedDb = tempMap.get("ALLOW_AS_NOT_CONSUMED_DB");
  301. if ("TRUE".equalsIgnoreCase(allowAsNotConsumedDb)) {
  302. tempItem.setAllowAsNotConsumedDb("Y");
  303. }else {
  304. tempItem.setAllowAsNotConsumedDb("N");
  305. }
  306. tempItem.setLotQuantityRule(tempMap.get("LOT_QUANTITY_RULE"));
  307. tempItem.setSubLotRule(tempMap.get("SUB_LOT_RULE"));
  308. tempItem.setComponentLotRule(tempMap.get("COMPONENT_LOT_RULE"));
  309. //添加对象
  310. resultItems.add(tempItem);
  311. }
  312. return resultItems;
  313. }
  314. }
  315. /**
  316. * @description: 查询库存件的属性值
  317. * @author LR
  318. * @date 2024/12/12 11:38
  319. * @version 1.0
  320. */
  321. public static List<InventoryPartUnitCostSumVo> getInventoryValues(Server srv, String siteCon, String ifsRowVersion, int startIndex, int pageSize) throws APException {
  322. StringBuilder searchSql = new StringBuilder();
  323. searchSql.append("SELECT OBJID ifsRowId, OBJVERSION ifsRowVersion, CONTRACT site, PART_NO, CONFIGURATION_ID, LOT_BATCH_NO, SERIAL_NO,");
  324. searchSql.append(" ifsapp.Inventory_Part_Unit_Cost_API.Get_Inventory_Value_By_Method(CONTRACT,PART_NO,CONFIGURATION_ID,LOT_BATCH_NO,SERIAL_NO) inventoryValue");
  325. searchSql.append(" FROM ifsapp.INVENTORY_PART_UNIT_COST_SUM pcs");
  326. searchSql.append(" WHERE pcs.CONFIGURATION_ID = '*'");
  327. //添加判断的查询条件
  328. if(!(null == siteCon || "".equals(siteCon))) {
  329. searchSql.append(" AND pcs.contract IN "+siteCon);
  330. }
  331. //设置查询的入参
  332. Map<String, String> inParam = new HashMap<>();
  333. if(!(null == ifsRowVersion || "".equals(ifsRowVersion))) {
  334. searchSql.append(" AND pcs.OBJVERSION >= :ifsRowVersion");
  335. inParam.put("ifsRowVersion", ifsRowVersion);
  336. }
  337. //添加排序语句
  338. searchSql.append(" ORDER BY pcs.OBJVERSION, pcs.contract, pcs.PART_NO");
  339. //添加分页的查询语句
  340. searchSql.append(" OFFSET "+startIndex+" ROWS FETCH NEXT "+pageSize+" ROWS ONLY");
  341. //调用查询的通用方法
  342. RecordCollection recordCollection = IfsPlsqlUtils.execSqlSearchGetRecordCollection(srv, searchSql, inParam);
  343. //判断能否返回
  344. if (recordCollection == null) {
  345. return new ArrayList<>();
  346. } else {
  347. List<InventoryPartUnitCostSumVo> resultItems = new ArrayList<>();
  348. //调用通用的处理方法 返回Map
  349. List<Map<String, String>> resultList = IfsConverterToMap.ConverterIfsToList(recordCollection);
  350. //获取数据转bean
  351. for (int i = 0; i < resultList.size(); i++) {
  352. Map<String, String> tempMap = resultList.get(i);
  353. InventoryPartUnitCostSumVo tempItem = new InventoryPartUnitCostSumVo();
  354. //设置参数
  355. //tempItem.setIfsRowId(tempMap.get("IFSROWID"));
  356. tempItem.setIfsRowVersion(tempMap.get("IFSROWVERSION"));
  357. tempItem.setSite(tempMap.get("SITE"));
  358. tempItem.setPartNo(tempMap.get("PART_NO"));
  359. tempItem.setConfigurationId(tempMap.get("CONFIGURATION_ID"));
  360. tempItem.setLotBatchNo(tempMap.get("LOT_BATCH_NO"));
  361. tempItem.setSerialNo(tempMap.get("SERIAL_NO"));
  362. tempItem.setInventoryValue(tempMap.get("INVENTORYVALUE"));
  363. //添加对象
  364. resultItems.add(tempItem);
  365. }
  366. return resultItems;
  367. }
  368. }
  369. /**
  370. * @description: 根据条件查询库存件的成本价
  371. * @author LR
  372. * @date 2025/1/17 11:36
  373. * @version 1.0
  374. */
  375. public static InventoryPartUnitCostSumVo getInventoryValueByPartNo(Server srv, String contract, String partNo) throws APException {
  376. StringBuilder searchSql = new StringBuilder();
  377. searchSql.append("SELECT OBJID ifsRowId, OBJVERSION ifsRowVersion, CONTRACT site, PART_NO, CONFIGURATION_ID, LOT_BATCH_NO, SERIAL_NO,");
  378. searchSql.append(" ifsapp.Inventory_Part_Unit_Cost_API.Get_Inventory_Value_By_Method(CONTRACT,PART_NO,CONFIGURATION_ID,LOT_BATCH_NO,SERIAL_NO) inventoryValue");
  379. searchSql.append(" FROM ifsapp.INVENTORY_PART_UNIT_COST_SUM pcs");
  380. searchSql.append(" WHERE pcs.CONTRACT = :contract AND pcs.PART_NO = :partNo AND pcs.CONFIGURATION_ID = '*'");
  381. //设置查询的入参
  382. Map<String, String> inParam = new HashMap<>();
  383. inParam.put("contract", contract);
  384. inParam.put("partNo", partNo);
  385. //调用查询的通用方法
  386. RecordCollection recordCollection = IfsPlsqlUtils.execSqlSearchGetRecordCollection(srv, searchSql, inParam);
  387. //判断能否返回
  388. if (recordCollection == null) {
  389. return null;
  390. } else {
  391. //调用通用的处理方法 返回Map
  392. Map<String, String> resultMap = IfsConverterToMap.ConverterIfsToMap(recordCollection.get(0));
  393. InventoryPartUnitCostSumVo resultRow = new InventoryPartUnitCostSumVo();
  394. //设置参数
  395. resultRow.setIfsRowId(resultMap.get("IFSROWID"));
  396. resultRow.setIfsRowVersion(resultMap.get("IFSROWVERSION"));
  397. resultRow.setSite(resultMap.get("SITE"));
  398. resultRow.setPartNo(resultMap.get("PART_NO"));
  399. resultRow.setConfigurationId(resultMap.get("CONFIGURATION_ID"));
  400. resultRow.setLotBatchNo(resultMap.get("LOT_BATCH_NO"));
  401. resultRow.setSerialNo(resultMap.get("SERIAL_NO"));
  402. resultRow.setInventoryValue(resultMap.get("INVENTORYVALUE"));
  403. return resultRow;
  404. }
  405. }
  406. /**
  407. * @description: 查询技术等级的属性列表
  408. * @author LR
  409. * @date 2025/1/17 14:12
  410. * @version 1.0
  411. */
  412. public static List<TechnicalAttribute> getTechnicalAttributesByCon(Server srv, String technicalSpecNo) throws APException {
  413. StringBuilder searchSql = new StringBuilder();
  414. searchSql.append("SELECT OBJID ifsRowId, OBJVERSION ifsRowVersion, TECHNICAL_SPEC_NO, TECHNICAL_CLASS, ATTRIB_NUMBER, ATTRIBUTE,");
  415. searchSql.append(" VALUE_NO, LOWER_LIMIT, UPPER_LIMIT, INFO, ALT_VALUE_NO, ALT_UNIT,");
  416. searchSql.append(" CASE WHEN objtype = 'TechnicalSpecNumeric' THEN 'Numeric'");
  417. searchSql.append(" WHEN objtype = 'TechnicalSpecAlphanum' THEN 'Alpha' ELSE '' END attributeType");
  418. searchSql.append(" FROM ifsapp.TECHNICAL_SPECIFICATION_BOTH");
  419. searchSql.append(" WHERE TECHNICAL_SPEC_NO = :technicalSpecNo");
  420. //设置查询的入参
  421. Map<String, String> inParam = new HashMap<>();
  422. inParam.put("technicalSpecNo", technicalSpecNo);
  423. //调用查询的通用方法
  424. RecordCollection recordCollection = IfsPlsqlUtils.execSqlSearchGetRecordCollection(srv, searchSql, inParam);
  425. //判断能否返回
  426. if (recordCollection == null) {
  427. return new ArrayList<>();
  428. } else {
  429. List<TechnicalAttribute> technicalAttributes = new ArrayList<>();
  430. //处理结果集
  431. List<Map<String, String>> resultList = IfsConverterToMap.ConverterIfsToList(recordCollection);
  432. //获取数据转bean
  433. for (int i = 0; i < resultList.size(); i++) {
  434. Map<String, String> tempMap = resultList.get(i);
  435. TechnicalAttribute tempItem = new TechnicalAttribute();
  436. //设置参数
  437. tempItem.setIfsRowId(tempMap.get("IFSROWID"));
  438. tempItem.setIfsRowVersion(tempMap.get("IFSROWVERSION"));
  439. tempItem.setTechnicalSpecNo(tempMap.get("TECHNICAL_SPEC_NO"));
  440. tempItem.setTechnicalClass(tempMap.get("TECHNICAL_CLASS"));
  441. tempItem.setAttribute(tempMap.get("ATTRIBUTE"));
  442. tempItem.setValueNo(tempMap.get("VALUE_NO"));
  443. tempItem.setLowerLimit(tempMap.get("LOWER_LIMIT"));
  444. tempItem.setUpperLimit(tempMap.get("UPPER_LIMIT"));
  445. tempItem.setInfo(tempMap.get("INFO"));
  446. tempItem.setAttributeType(tempMap.get("ATTRIBUTETYPE"));
  447. //添加对象
  448. technicalAttributes.add(tempItem);
  449. }
  450. return technicalAttributes;
  451. }
  452. }
  453. /**
  454. * @description: 加工中心成本
  455. * @author LR
  456. * @date 2025/2/10 15:17
  457. * @version 1.0
  458. */
  459. public static List<WorkCenterCost> getWorkCenterCosts(Server srv, String siteCon, String ifsRowVersion, int startIndex, int pageSize) throws APException {
  460. StringBuilder searchSql = new StringBuilder();
  461. searchSql.append("SELECT OBJID ifsRowId, OBJVERSION ifsRowVersion, CONTRACT, WORK_CENTER_NO,");
  462. searchSql.append(" ifsapp.WORK_CENTER_API.Get_Description(CONTRACT, WORK_CENTER_NO) workCenterDesc,");
  463. searchSql.append(" COST_SET, ifsapp.COST_SET_API.Get_Description(CONTRACT,COST_SET) costSetDesc, WC_RATE, WC_COST_CODE,");
  464. searchSql.append(" OVERHEAD1_FAC, OVERHEAD1_APPL, OVERHEAD2_FAC, OVERHEAD2_APPL,");
  465. searchSql.append(" to_char(START_DATE, 'yyyy-MM-dd') START_DATE, to_char(END_DATE, 'yyyy-MM-dd') END_DATE");
  466. searchSql.append(" FROM ifsapp.WORK_CENTER_COST");
  467. searchSql.append(" WHERE ifsapp.Work_Center_API.Get_Work_Center_Code_Db(contract, work_center_no) = 'I'");
  468. searchSql.append(" AND COST_SET = '1' AND END_DATE IS NULL");
  469. //设置查询的入参
  470. Map<String, String> inParam = new HashMap<>();
  471. //判断是否存在入参
  472. /*if (!(ifsRowVersion == null || "".equals(ifsRowVersion))){
  473. searchSql.append(" AND OBJVERSION >= :ifsRowVersion");
  474. inParam.put("ifsRowVersion", ifsRowVersion);
  475. }*/
  476. //添加排序语句
  477. searchSql.append(" ORDER BY CONTRACT, WORK_CENTER_NO, COST_SET, START_DATE");
  478. //添加分页的查询语句
  479. searchSql.append(" OFFSET "+startIndex+" ROWS FETCH NEXT "+pageSize+" ROWS ONLY");
  480. logger.info("加工中心成本查询语句sql"+searchSql.toString());
  481. //调用查询的通用方法
  482. RecordCollection recordCollection = IfsPlsqlUtils.execSqlSearchGetRecordCollection(srv, searchSql, inParam);
  483. //判断能否返回
  484. if (recordCollection == null) {
  485. return new ArrayList<>();
  486. } else {
  487. List<WorkCenterCost> technicalAttributes = new ArrayList<>();
  488. //处理结果集
  489. List<Map<String, String>> resultList = IfsConverterToMap.ConverterIfsToList(recordCollection);
  490. //获取数据转bean
  491. for (int i = 0; i < resultList.size(); i++) {
  492. Map<String, String> tempMap = resultList.get(i);
  493. WorkCenterCost tempItem = new WorkCenterCost();
  494. //设置参数
  495. tempItem.setIfsRowId(tempMap.get("IFSROWID"));
  496. tempItem.setIfsRowVersion(tempMap.get("IFSROWVERSION"));
  497. tempItem.setSite(tempMap.get("CONTRACT"));
  498. tempItem.setWorkCenterNo(tempMap.get("WORK_CENTER_NO"));
  499. tempItem.setWorkCenterDesc(tempMap.get("WORKCENTERDESC"));
  500. tempItem.setCostSet(tempMap.get("COST_SET"));
  501. tempItem.setCostSetDesc(tempMap.get("COSTSETDESC"));
  502. tempItem.setWcRate(tempMap.get("WC_RATE"));
  503. tempItem.setWcCostCode(tempMap.get("WC_COST_CODE"));
  504. tempItem.setOverhead1Fac(tempMap.get("OVERHEAD1_FAC"));
  505. tempItem.setOverhead2Fac(tempMap.get("OVERHEAD2_FAC"));
  506. tempItem.setOverhead1Appl(tempMap.get("OVERHEAD1_APPL"));
  507. tempItem.setOverhead2Appl(tempMap.get("OVERHEAD2_APPL"));
  508. String startDate = tempMap.get("START_DATE");
  509. if (!(null == startDate || "".equals(startDate))){
  510. tempItem.setBeginDate(DateUtils.getStringToDate(startDate, "yyyy-MM-dd"));
  511. }
  512. String endDate = tempMap.get("END_DATE");
  513. if (!(null == endDate || "".equals(endDate))) {
  514. tempItem.setEndDate(DateUtils.getStringToDate(endDate, "yyyy-MM-dd"));
  515. }
  516. //添加对象
  517. technicalAttributes.add(tempItem);
  518. }
  519. return technicalAttributes;
  520. }
  521. }
  522. /**
  523. * @description: 按照时间获取所有域下的库存件信息
  524. * @author LR
  525. * @date 2025/3/7 10:58
  526. * @version 1.0
  527. */
  528. public static List<PartIfsInventory> getInventoryParts(Server srv, String ifsRowVersion, int startIndex, int pageSize) throws APException {
  529. StringBuilder searchSql = new StringBuilder();
  530. searchSql.append("SELECT OBJID ifsRowId, OBJVERSION ifsRowVersion, PART_NO, DESCRIPTION, CONTRACT, TYPE_CODE, PLANNER_BUYER,");
  531. searchSql.append(" UNIT_MEAS, PRIME_COMMODITY, SECOND_COMMODITY, ASSET_CLASS, PART_STATUS, ABC_CLASS, FREQUENCY_CLASS, LIFECYCLE_STAGE,");
  532. searchSql.append(" HAZARD_CODE, ACCOUNTING_GROUP, PART_PRODUCT_CODE, PART_PRODUCT_FAMILY, TYPE_DESIGNATION, DIM_QUALITY, CREATE_DATE,");
  533. searchSql.append(" NOTE_TEXT, LEAD_TIME_CODE, PURCH_LEADTIME, MANUF_LEADTIME, EXPECTED_LEADTIME, DURABILITY_DAY, COUNTRY_OF_ORIGIN, REGION_OF_ORIGIN,");
  534. searchSql.append(" SUPPLY_CODE, INVENTORY_VALUATION_METHOD, INVENTORY_PART_COST_LEVEL, INVOICE_CONSIDERATION, ZERO_COST_FLAG, PART_COST_GROUP_ID,");
  535. searchSql.append(" STD_NAME_ID, ENG_ATTRIBUTE");
  536. searchSql.append(" FROM ifsapp.INVENTORY_PART");
  537. searchSql.append(" WHERE OBJVERSION >:ifsRowVersion");
  538. //设置查询的入参
  539. Map<String, String> inParam = new HashMap<>();
  540. inParam.put("ifsRowVersion", ifsRowVersion);
  541. //添加排序语句
  542. searchSql.append(" ORDER BY OBJVERSION ASC");
  543. //添加分页的查询语句
  544. searchSql.append(" OFFSET "+startIndex+" ROWS FETCH NEXT "+pageSize+" ROWS ONLY");
  545. logger.info("库存件查询语句sql"+searchSql.toString());
  546. //调用查询的通用方法
  547. RecordCollection recordCollection = IfsPlsqlUtils.execSqlSearchGetRecordCollection(srv, searchSql, inParam);
  548. //判断能否返回
  549. if (recordCollection == null) {
  550. return new ArrayList<>();
  551. } else {
  552. List<PartIfsInventory> returnlList = new ArrayList<>();
  553. //处理结果集
  554. List<Map<String, String>> resultList = IfsConverterToMap.ConverterIfsToList(recordCollection);
  555. //获取数据转bean
  556. for (int i = 0; i < resultList.size(); i++) {
  557. Map<String, String> tempMap = resultList.get(i);
  558. PartIfsInventory tempItem = new PartIfsInventory();
  559. //设置参数
  560. tempItem.setIfsRowId(tempMap.get("IFSROWID"));
  561. tempItem.setIfsRowVersion(tempMap.get("IFSROWVERSION"));
  562. tempItem.setContract(tempMap.get("CONTRACT"));
  563. tempItem.setPartNo(tempMap.get("PART_NO"));
  564. tempItem.setPartDesc(tempMap.get("DESCRIPTION"));
  565. tempItem.setTypeCode(tempMap.get("TYPE_CODE"));
  566. tempItem.setPlannerBuyer(tempMap.get("PLANNER_BUYER"));
  567. tempItem.setUnitMeas(tempMap.get("UNIT_MEAS"));
  568. tempItem.setPrimeCommodity(tempMap.get("PRIME_COMMODITY"));
  569. tempItem.setSecondCommodity(tempMap.get("SECOND_COMMODITY"));
  570. tempItem.setAssetClass(tempMap.get("ASSET_CLASS"));
  571. tempItem.setPartStatus(tempMap.get("PART_STATUS"));
  572. tempItem.setAbcClass(tempMap.get("ABC_CLASS"));
  573. tempItem.setFrequencyClass(tempMap.get("FREQUENCY_CLASS"));
  574. tempItem.setLifecycleStage(tempMap.get("LIFECYCLE_STAGE"));
  575. tempItem.setHazardCode(tempMap.get("HAZARD_CODE"));
  576. tempItem.setAccountingGroup(tempMap.get("ACCOUNTING_GROUP"));
  577. tempItem.setPartProductCode(tempMap.get("PART_PRODUCT_CODE"));
  578. tempItem.setPartProductFamily(tempMap.get("PART_PRODUCT_FAMILY"));
  579. tempItem.setTypeDesignation(tempMap.get("TYPE_DESIGNATION"));
  580. tempItem.setDimQuality(tempMap.get("DIM_QUALITY"));
  581. tempItem.setNoteText(tempMap.get("NOTE_TEXT"));
  582. tempItem.setLeadTimeCode(tempMap.get("LEAD_TIME_CODE"));
  583. tempItem.setManufLeadtime(tempMap.get("MANUF_LEADTIME"));
  584. tempItem.setExpectedLeadtime(tempMap.get("EXPECTED_LEADTIME"));
  585. tempItem.setDurabilityDay(tempMap.get("DURABILITY_DAY"));
  586. tempItem.setCountryOfOrigin(tempMap.get("COUNTRY_OF_ORIGIN"));
  587. tempItem.setRegionOfOrigin(tempMap.get("REGION_OF_ORIGIN"));
  588. tempItem.setInventoryValuationMethod(tempMap.get("INVENTORY_VALUATION_METHOD"));
  589. tempItem.setInventoryPartCostLevel(tempMap.get("INVENTORY_PART_COST_LEVEL"));
  590. tempItem.setInvoiceConsideration(tempMap.get("INVOICE_CONSIDERATION"));
  591. tempItem.setZeroCostFlag(tempMap.get("ZERO_COST_FLAG"));
  592. tempItem.setPartCostGroupId(tempMap.get("PART_COST_GROUP_ID"));
  593. tempItem.setEngAttribute(tempMap.get("ENG_ATTRIBUTE"));
  594. String createdDate = tempMap.get("CREATE_DATE");
  595. if (!(null == createdDate || "".equals(createdDate))){
  596. tempItem.setCreatedDate(DateUtils.getStringToDate(createdDate, "yyyy-MM-dd HH:mm:ss"));
  597. }
  598. //添加对象
  599. returnlList.add(tempItem);
  600. }
  601. return returnlList;
  602. }
  603. }
  604. /**
  605. * @description: 查询人员等级成本
  606. * @author LR
  607. * @date 2025/5/6 11:58
  608. * @version 1.0
  609. */
  610. public static List<PersonnelLevelVo> getLaborClassCosts(Server srv, String siteCon, int startIndex, int pageSize) throws APException {
  611. StringBuilder searchSql = new StringBuilder();
  612. searchSql.append("SELECT lcc.OBJID ifsRowId, lcc.OBJVERSION ifsRowVersion, lcc.CONTRACT, lcc.LABOR_CLASS_NO,");
  613. searchSql.append(" ifsapp.LABOR_CLASS_API.Get_labor_class_Description(lcc.CONTRACT, lcc.LABOR_CLASS_NO) laborClassDesc,");
  614. searchSql.append(" lcc.COST_SET, ifsapp.COST_SET_API.Get_Description(lcc.CONTRACT,lcc.COST_SET) costSetDesc,");
  615. searchSql.append(" lcc.labor_class_RATE, lcc.labor_class_COST_CODE,");
  616. searchSql.append(" to_char(lcc.START_DATE, 'yyyy-MM-dd') START_DATE, to_char(lcc.END_DATE, 'yyyy-MM-dd') END_DATE,");
  617. searchSql.append(" (CASE WHEN lc.objstate = 'Active' THEN 'Y' ELSE 'N' END) active");
  618. searchSql.append(" FROM ifsapp.LABOR_CLASS_COST lcc");
  619. searchSql.append(" LEFT JOIN ifsapp.labor_class lc ON lc.CONTRACT = lcc.CONTRACT AND lc.LABOR_CLASS_NO = lcc.LABOR_CLASS_NO");
  620. searchSql.append(" WHERE lcc.COST_SET = '1' AND lcc.END_DATE IS NULL");
  621. //添加判断的查询条件
  622. if(!(null == siteCon || "".equals(siteCon))) {
  623. searchSql.append(" AND lcc.contract IN "+siteCon);
  624. }
  625. //设置查询的入参
  626. Map<String, String> inParam = new HashMap<>();
  627. //添加排序语句
  628. searchSql.append(" ORDER BY lcc.CONTRACT, lcc.LABOR_CLASS_NO");
  629. //添加分页的查询语句
  630. searchSql.append(" OFFSET "+startIndex+" ROWS FETCH NEXT "+pageSize+" ROWS ONLY");
  631. logger.info("人员等级成本查询语句sql"+searchSql.toString());
  632. //调用查询的通用方法
  633. RecordCollection recordCollection = IfsPlsqlUtils.execSqlSearchGetRecordCollection(srv, searchSql, inParam);
  634. //判断能否返回
  635. if (recordCollection == null) {
  636. return new ArrayList<>();
  637. } else {
  638. List<PersonnelLevelVo> returnlList = new ArrayList<>();
  639. //处理结果集
  640. List<Map<String, String>> resultList = IfsConverterToMap.ConverterIfsToList(recordCollection);
  641. //获取数据转bean
  642. for (int i = 0; i < resultList.size(); i++) {
  643. Map<String, String> tempMap = resultList.get(i);
  644. PersonnelLevelVo tempItem = new PersonnelLevelVo();
  645. //设置参数
  646. //tempItem.setIfsRowId(tempMap.get("IFSROWID"));
  647. tempItem.setIfsRowVersion(tempMap.get("IFSROWVERSION"));
  648. tempItem.setSite(tempMap.get("CONTRACT"));
  649. tempItem.setLevelId(tempMap.get("LABOR_CLASS_NO"));
  650. tempItem.setLevelDesc(tempMap.get("LABORCLASSDESC"));
  651. tempItem.setActive(tempMap.get("ACTIVE"));
  652. tempItem.setCreateDate(DateUtils.getStringToDate(tempMap.get("START_DATE"), "yyyy-MM-dd"));
  653. tempItem.setCreateBy(tempMap.get("Admin"));
  654. tempItem.setUpdateDate(null); // 从tempMap获取值
  655. tempItem.setUpdateBy(tempMap.get("UPDATE_BY")); // 从tempMap获取值
  656. tempItem.setLevelCost(new BigDecimal(tempMap.get("LABOR_CLASS_RATE")));
  657. //添加对象
  658. returnlList.add(tempItem);
  659. }
  660. return returnlList;
  661. }
  662. }
  663. }