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.

703 lines
38 KiB

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