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.

324 lines
12 KiB

11 months ago
11 months ago
  1. package com.spring.ifs.bean;
  2. import com.spring.ifs.api.BaseSearchApi;
  3. import com.spring.ifs.api.BaseSearchApiTest;
  4. import com.spring.ifs.api.IfsServer;
  5. import com.spring.ifs.api.TechnicalClassApi;
  6. import com.spring.ifs.data.*;
  7. import com.spring.modules.base.entity.WorkCenterCost;
  8. import com.spring.modules.base.vo.PersonnelLevelVo;
  9. import com.spring.modules.part.entity.APIEntity.PartIfsInventory;
  10. import ifs.fnd.ap.APException;
  11. import ifs.fnd.ap.Server;
  12. import org.slf4j.Logger;
  13. import org.slf4j.LoggerFactory;
  14. import org.springframework.beans.factory.annotation.Autowired;
  15. import org.springframework.stereotype.Component;
  16. import java.util.ArrayList;
  17. import java.util.HashMap;
  18. import java.util.List;
  19. import java.util.Map;
  20. /**
  21. * @description: 基础查询的实现类
  22. * @author LR
  23. * @date 2024/12/9 11:49
  24. * @version 1.0
  25. */
  26. @Component
  27. public class BaseSearchBeanTest {
  28. @Autowired
  29. private IfsServer ifsServer;
  30. private static final Logger logger = LoggerFactory.getLogger(BaseSearchBean.class);
  31. /**
  32. * @description: 查询加工中心
  33. * @author LR
  34. * @date 2024/12/12 13:23
  35. * @version 1.0
  36. */
  37. public List<WorkCenter> getWorkCenterNos(BaseSearchData inData) throws APException {
  38. //查询的参数
  39. String username = inData.getIfsUsername();
  40. String password = inData.getIfsPassword();
  41. String siteCon = inData.getSiteCon();
  42. String ifsRowVersion = inData.getIfsRowVersion();
  43. logger.info("请求参数:"+siteCon);
  44. //获取连接
  45. Server srv = ifsServer.getIfsServer(username, password);
  46. List<WorkCenter> resultList = BaseSearchApiTest.getWorkCenterNos(srv, siteCon, ifsRowVersion);;
  47. logger.info("返回集合大小:"+resultList.size());
  48. return resultList;
  49. }
  50. /**
  51. * @description: 查询
  52. * @author LR
  53. * @date 2024/12/12 13:24
  54. * @version 1.0
  55. */
  56. public List<WarehouseLocation> getWarehouseLocations(BaseSearchData inData) throws APException {
  57. //查询的参数
  58. String username = inData.getIfsUsername();
  59. String password = inData.getIfsPassword();
  60. String siteCon = inData.getSiteCon();
  61. String ifsRowVersion = inData.getIfsRowVersion();
  62. logger.info("请求参数:"+siteCon);
  63. //获取连接
  64. Server srv = ifsServer.getIfsServer(username, password);
  65. List<WarehouseLocation> resultList = new ArrayList<>();
  66. int pageSize = 200;
  67. //迭代查询
  68. for(int i = 0; i < 150; i++){
  69. int startIndex = i * pageSize;
  70. List<WarehouseLocation> tempList = BaseSearchApiTest.getWarehouseLocations(srv, siteCon, startIndex, pageSize);
  71. //判断查询是否结束
  72. if(tempList.size() > 0) {
  73. resultList.addAll(tempList);
  74. }else {
  75. break;
  76. }
  77. }
  78. logger.info("返回集合大小:"+resultList.size());
  79. return resultList;
  80. }
  81. /**
  82. * @description: 获取人员等级的信息
  83. * @author LR
  84. * @date 2024/12/12 13:29
  85. * @version 1.0
  86. */
  87. public List<LaborClass> getIfsLaborClasss(BaseSearchData inData) throws APException {
  88. //查询的参数
  89. String username = inData.getIfsUsername();
  90. String password = inData.getIfsPassword();
  91. String siteCon = inData.getSiteCon();
  92. String ifsRowVersion = inData.getIfsRowVersion();
  93. //获取连接
  94. Server srv = ifsServer.getIfsServer(username, password);
  95. return BaseSearchApiTest.getIfsLaborClasss(srv, siteCon, ifsRowVersion);
  96. }
  97. /**
  98. * @description: 查询物料件的信息
  99. * @author LR
  100. * @date 2024/12/9 13:28
  101. * @version 1.0
  102. */
  103. public List<PartCatalog> getMasterParts(BaseSearchData inData) throws APException {
  104. //公共参数
  105. String username = inData.getIfsUsername();
  106. String password = inData.getIfsPassword();
  107. String ifsRowVersion = inData.getIfsRowVersion();
  108. //获取连接
  109. Server srv = ifsServer.getIfsServer(username, password);
  110. List<PartCatalog> resultList = new ArrayList<>();
  111. int pageSize = 200;
  112. //迭代查询
  113. for(int i = 0; i < 10; i++){
  114. int startIndex = i * pageSize;
  115. List<PartCatalog> tempList = BaseSearchApiTest.getPartCatalogs(srv, ifsRowVersion, startIndex, pageSize);
  116. //判断查询是否结束
  117. if(tempList.size() > 0) {
  118. resultList.addAll(tempList);
  119. }else {
  120. break;
  121. }
  122. }
  123. logger.info("返回集合大小:"+resultList.size());
  124. return resultList;
  125. }
  126. /**
  127. * @description: 查询库存件的属性值
  128. * @author LR
  129. * @date 2024/12/12 13:33
  130. * @version 1.0
  131. */
  132. public List<InventoryValue> getInventoryValues(BaseSearchData inData) throws APException {
  133. //查询的参数
  134. String username = inData.getIfsUsername();
  135. String password = inData.getIfsPassword();
  136. String siteCon = inData.getSiteCon();
  137. String ifsRowVersion = inData.getIfsRowVersion();
  138. logger.info("库存件cost value请求参数:"+siteCon);
  139. //获取连接
  140. Server srv = ifsServer.getIfsServer(username, password);
  141. List<InventoryValue> resultList = new ArrayList<>();
  142. int pageSize = 200;
  143. //迭代查询
  144. for(int i = 0; i < 10; i++){
  145. int startIndex = i * pageSize;
  146. List<InventoryValue> tempList = BaseSearchApiTest.getInventoryValues(srv, siteCon, ifsRowVersion, startIndex, pageSize);
  147. //判断查询是否结束
  148. if(tempList.size() > 0) {
  149. resultList.addAll(tempList);
  150. }else {
  151. break;
  152. }
  153. }
  154. logger.info("返回集合大小:"+resultList.size());
  155. return resultList;
  156. }
  157. /**
  158. * @description: 按照条件查询库存件的成本
  159. * @author LR
  160. * @date 2025/1/17 11:40
  161. * @version 1.0
  162. */
  163. public InventoryValue getInventoryValueByPartNo(BaseSearchData inData) throws APException {
  164. //查询的参数
  165. String site = inData.getSite();
  166. String partNo = inData.getPartNo();
  167. String username = inData.getIfsUsername();
  168. String password = inData.getIfsPassword();
  169. logger.info("库存件cost value请求参数 域:"+site+",物料编码:"+partNo);
  170. //获取连接
  171. Server srv = ifsServer.getIfsServer(username, password);
  172. InventoryValue resultRow = BaseSearchApiTest.getInventoryValueByPartNo(srv, site, partNo);
  173. //判断null
  174. if(resultRow == null) {
  175. throw new APException("库存件按成本不存在!");
  176. }
  177. logger.info("返回集合大小:"+resultRow.toString());
  178. return resultRow;
  179. }
  180. /**
  181. * @description: 按照条件查询技术等级的数据
  182. * @author LR
  183. * @date 2025/1/17 13:20
  184. * @version 1.0
  185. */
  186. public List<TechnicalAttribute> getTechnicalAttributesByCon(BaseSearchData inData) throws APException {
  187. String username = inData.getIfsUsername();
  188. String password = inData.getIfsPassword();
  189. String keyRef = inData.getKeyRef();
  190. String luName = inData.getLuName() ;
  191. //获取连接
  192. Server srv = ifsServer.getIfsServer(username, password);
  193. //查询主表对应的信息
  194. Map<String, String> resultMap = TechnicalClassApi.getTechnicalClass(srv, luName, keyRef);
  195. //获取关联键
  196. String technicalSpecNo = resultMap.get("TECHNICAL_SPEC_NO");
  197. //查询技术等级属性的列表数据
  198. List<TechnicalAttribute> resultList = BaseSearchApi.getTechnicalAttributesByCon(srv, technicalSpecNo);
  199. return resultList;
  200. }
  201. /**
  202. * @description: 查询加工中心成本
  203. * @author LR
  204. * @date 2025/1/17 13:20
  205. * @version 1.0
  206. */
  207. public List<WorkCenterCost> getWorkCenterCosts(BaseSearchData inData) throws APException {
  208. //查询的参数
  209. String username = inData.getIfsUsername();
  210. String password = inData.getIfsPassword();
  211. String siteCon = inData.getSiteCon();
  212. String ifsRowVersion = inData.getIfsRowVersion();
  213. logger.info("加工中心成本的请求参数:"+siteCon);
  214. List<WorkCenterCost> resultList = new ArrayList<>();
  215. int pageSize = 200;
  216. //获取连接
  217. Server srv = ifsServer.getIfsServer(username, password);
  218. //迭代查询
  219. for(int i = 0; i < 20; i++){
  220. int startIndex = i * pageSize;
  221. List<WorkCenterCost> tempList = BaseSearchApi.getWorkCenterCosts(srv, siteCon, ifsRowVersion, startIndex, pageSize);
  222. //判断查询是否结束
  223. if(tempList.size() > 0) {
  224. resultList.addAll(tempList);
  225. }else {
  226. break;
  227. }
  228. }
  229. logger.info("返回集合大小:"+resultList.size());
  230. return resultList;
  231. }
  232. /**
  233. * @description: 按照时间获取所有域下的库存件信息
  234. * @author LR
  235. * @date 2025/3/7 11:01
  236. * @version 1.0
  237. */
  238. public List<PartIfsInventory> getInventoryParts(BaseSearchData inData) throws APException {
  239. //查询的参数
  240. String ifsRowVersion = inData.getIfsRowVersion();
  241. String username = inData.getIfsUsername();
  242. String password = inData.getIfsPassword();
  243. logger.info("库存件查询的请求参数:"+ifsRowVersion);
  244. List<PartIfsInventory> resultList = new ArrayList<>();
  245. int pageSize = 200;
  246. //获取连接
  247. Server srv = ifsServer.getIfsServer(username, password);
  248. //迭代查询
  249. for(int i = 0; i < 100; i++){
  250. int startIndex = i * pageSize;
  251. List<PartIfsInventory> tempList = BaseSearchApi.getInventoryParts(srv, ifsRowVersion, startIndex, pageSize);
  252. //判断查询是否结束
  253. if(tempList.size() > 0) {
  254. resultList.addAll(tempList);
  255. }else {
  256. break;
  257. }
  258. }
  259. //过滤重复的数据
  260. List<PartIfsInventory> returnList = new ArrayList<>();
  261. Map<String, Integer> checkMap = new HashMap<>();
  262. for (PartIfsInventory partIfsInventory : resultList){
  263. String key = partIfsInventory.getContract() +"-"+partIfsInventory.getPartNo();
  264. if (checkMap.containsKey(key)){
  265. int index = checkMap.get(key);
  266. returnList.set(index, partIfsInventory);
  267. }else {
  268. returnList.add(partIfsInventory);
  269. checkMap.put(key, returnList.size() - 1);
  270. }
  271. }
  272. logger.info("返回集合大小:"+returnList.size());
  273. return returnList;
  274. }
  275. /**
  276. * @description: 查询人员等级成本
  277. * @author LR
  278. * @date 2025/5/6 11:55
  279. * @version 1.0
  280. */
  281. public List<PersonnelLevelVo> getLaborClassCosts(BaseSearchData inData) throws APException {
  282. //查询的参数
  283. logger.info("人员等级成本开始查询!");
  284. String username = inData.getIfsUsername();
  285. String password = inData.getIfsPassword();
  286. String siteCon = inData.getSiteCon();
  287. List<PersonnelLevelVo> resultList = new ArrayList<>();
  288. int pageSize = 200;
  289. try {
  290. Server srv = ifsServer.getIfsServer(username, password);
  291. //迭代查询
  292. for(int i = 0; i < 150; i++){
  293. int startIndex = i * pageSize;
  294. List<PersonnelLevelVo> tempList = BaseSearchApi.getLaborClassCosts(srv, siteCon, startIndex, pageSize);
  295. //判断查询是否结束
  296. if(tempList.size() > 0) {
  297. resultList.addAll(tempList);
  298. }else {
  299. break;
  300. }
  301. }
  302. } catch (APException e){
  303. throw new APException("异常信息:"+e.getMessage());
  304. }
  305. logger.info("人员等级成本结束查询,返回集合大小:"+resultList.size());
  306. return resultList;
  307. }
  308. }