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.

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