|
|
package com.spring.ifs.api;
import com.spring.common.utils.DateUtils;import com.spring.ifs.data.*;import com.spring.ifs.utils.IfsConverterToMap;import com.spring.ifs.utils.IfsPlsqlUtils;import com.spring.modules.base.entity.WorkCenterCost;import com.spring.modules.base.vo.PersonnelLevelVo;import com.spring.modules.part.entity.APIEntity.PartIfsInventory;import com.spring.modules.part.vo.InventoryPartUnitCostSumVo;import com.spring.modules.part.vo.LocationInformationVo;import com.spring.modules.part.vo.WorkCenterVo;import ifs.fnd.ap.APException;import ifs.fnd.ap.RecordCollection;import ifs.fnd.ap.Server;import org.slf4j.Logger;
import java.math.BigDecimal;import java.math.MathContext;import java.math.RoundingMode;import java.util.ArrayList;import java.util.HashMap;import java.util.List;import java.util.Map;
/*** @description: 基础查询的api* @author LR* @date 2024/12/12 10:44* @version 1.0*/public class BaseSearchApi {
private static Logger logger = org.slf4j.LoggerFactory.getLogger(BaseSearchApi.class);
/** * @description: 查询IFS的加工中心 * @author LR * @date 2024/12/12 11:02 * @version 1.0 */ public static List<WorkCenterVo> getWorkCenterNos(Server srv, String siteCon, String ifsRowVersion) throws APException { StringBuilder searchSql = new StringBuilder(); searchSql.append("SELECT wc.contract site, wc.work_center_no, wc.description work_center_desc, wc.work_center_code_db,"); searchSql.append(" (CASE WHEN work_center_code_db='I' THEN '内部' ELSE '外部' END) work_center_type, 100 efficiency,"); searchSql.append(" TO_CHAR(NVL(wc.average_capacity, 0), 'FM99999999999999999999999999999999999999.999999') averageCapacity,"); searchSql.append(" NVL(wc.utilization, 0) utilization, wc.sched_capacity_db capacity_type_db,"); searchSql.append(" (CASE WHEN sched_capacity_db = 'I' THEN '无限产能' ELSE '有限产能' END) capacity_type, wc.uom um_id,"); searchSql.append(" (CASE WHEN wc.objstate = 'Active' THEN 'Y' ELSE 'N' END) show_in_query_flag,"); searchSql.append(" (CASE WHEN wc.objstate = 'Active' THEN 'Y' ELSE 'N' END) active, wc.note_text remark, wc.create_date created_date,"); searchSql.append(" wc.PRODUCTION_LINE pro_line_no, 'N' can_create_new_roll_flag, 'N' need_setup_flag, wc.objid ifsRowId, wc.OBJVERSION ifsRowVersion"); searchSql.append(" FROM ifsapp.WORK_CENTER wc"); searchSql.append(" WHERE wc.work_center_code_db IN ('I','O')"); //添加判断的查询条件
if(!(null == siteCon || "".equals(siteCon))) { searchSql.append(" AND wc.contract IN "+siteCon); } //设置查询的入参
Map<String, String> inParam = new HashMap<>(); /*if(!(null == ifsRowVersion || "".equals(ifsRowVersion))) { searchSql.append(" AND wc.OBJVERSION >= :ifsRowVersion"); inParam.put("ifsRowVersion", ifsRowVersion); }*/ //添加排序语句
searchSql.append(" ORDER BY wc.OBJVERSION, wc.contract, wc.work_center_no"); //调用查询的通用方法
RecordCollection recordCollection = IfsPlsqlUtils.execSqlSearchGetRecordCollection(srv, searchSql, inParam); //判断能否返回
if (recordCollection == null) { return new ArrayList<>(); } else { List<WorkCenterVo> resultItems = new ArrayList<>(); //调用通用的处理方法 返回Map
List<Map<String, String>> resultList = IfsConverterToMap.ConverterIfsToList(recordCollection); //判断是否存在数据
if(resultList == null) { return resultItems; } //获取数据转bean
for (int i = 0; i < resultList.size(); i++) { Map<String, String> tempMap = resultList.get(i); WorkCenterVo tempItem = new WorkCenterVo(); //设置参数
//tempItem.setIfsRowId(tempMap.get("IFSROWID"));
tempItem.setIfsRowVersion(tempMap.get("IFSROWVERSION")); tempItem.setSite(tempMap.get("SITE")); tempItem.setWorkCenterNo(tempMap.get("WORK_CENTER_NO")); tempItem.setWorkCenterDesc(tempMap.get("WORK_CENTER_DESC")); tempItem.setWorkCenterTypeDB(tempMap.get("WORK_CENTER_CODE_DB")); tempItem.setWorkCenterType(tempMap.get("WORK_CENTER_TYPE")); tempItem.setAverageCapacity(new BigDecimal(tempMap.get("AVERAGECAPACITY"))); tempItem.setEfficiency(new BigDecimal(tempMap.get("EFFICIENCY"))); tempItem.setUtilization(new BigDecimal(tempMap.get("UTILIZATION"))); tempItem.setCapacityTypeDB(tempMap.get("CAPACITY_TYPE_DB")); tempItem.setCapacityType(tempMap.get("CAPACITY_TYPE")); tempItem.setUmId(tempMap.get("UM_ID")); tempItem.setActive("Y"); tempItem.setShowInQueryFlag(tempMap.get("SHOW_IN_QUERY_FLAG")); tempItem.setActive(tempMap.get("ACTIVE")); tempItem.setRemark(tempMap.get("REMARK")); tempItem.setCreatedDate(DateUtils.getStringToDate(tempMap.get("CREATED_DATE"), "yyyy-MM-dd HH:mm:ss")); tempItem.setProLineNo(tempMap.get("PRO_LINE_NO")); tempItem.setCanCreateNewRollFlag(tempMap.get("CAN_CREATE_NEW_ROLL_FLAG")); tempItem.setNeedSetupFlag(tempMap.get("NEED_SETUP_FLAG")); //添加对象
resultItems.add(tempItem); } return resultItems; } }
/** * @description: 查询机台的信息 * @author LR * @date 2024/12/12 11:23 * @version 1.0 */ public static List<LocationInformationVo> getWarehouseLocations(Server srv, String siteCon, int startIndex, int pageSize) throws APException { StringBuilder searchSql = new StringBuilder(); searchSql.append("SELECT contract site, location_no location_id, location_name, warehouse warehouse_id, 'Y' active, NULL create_date, 'admin' create_by,"); searchSql.append(" '' update_date, '' update_by, location_type location_type"); searchSql.append(" FROM ifsapp.INVENTORY_LOCATION14"); searchSql.append(" WHERE location_type = 'Picking'"); //添加判断的查询条
if(!(null == siteCon || "".equals(siteCon))) { searchSql.append(" AND contract IN "+siteCon); } //设置查询的入参
Map<String, String> inParam = new HashMap<>(); //添加排序语句
searchSql.append(" ORDER BY contract, location_no"); //添加分页的查询语句
searchSql.append(" OFFSET "+startIndex+" ROWS FETCH NEXT "+pageSize+" ROWS ONLY"); //打印sql日志
logger.info("查询sql:"+searchSql.toString()); //调用查询的通用方法
RecordCollection recordCollection = IfsPlsqlUtils.execSqlSearchGetRecordCollection(srv, searchSql, inParam); //判断能否返回
if (recordCollection == null) { return new ArrayList<>(); } else { List<LocationInformationVo> resultItems = new ArrayList<>(); //调用通用的处理方法 返回Map
List<Map<String, String>> resultList = IfsConverterToMap.ConverterIfsToList(recordCollection); //判断是否存在数据
if(resultList == null) { return resultItems; } //获取数据转bean
for (int i = 0; i < resultList.size(); i++) { Map<String, String> tempMap = resultList.get(i); LocationInformationVo tempItem = new LocationInformationVo(); //设置参数
//tempItem.setIfsRowId(tempMap.get("IFSROWID"));
//tempItem.setIfsRowVersion(tempMap.get("IFSROWVERSION"));
tempItem.setSite(tempMap.get("SITE")); tempItem.setLocationId(tempMap.get("LOCATION_ID")); tempItem.setLocationName(tempMap.get("LOCATION_NAME")); tempItem.setWarehouseId(tempMap.get("WAREHOUSE_ID")); tempItem.setActive(tempMap.get("ACTIVE")); tempItem.setCreateDate(null); // 从tempMap获取值,不再直接设为null
tempItem.setCreateBy("admin"); // 注意:字段名也改为大写
tempItem.setUpdateDate(null); // 从tempMap获取值,不再直接设为null
tempItem.setUpdateBy(null);//直接设为null,因为SQL中对应字段是NULL
tempItem.setLocationType(tempMap.get("LOCATION_TYPE")); //添加对象
resultItems.add(tempItem); } return resultItems; } }
/** * @description: 查询人员等级 * @author LR * @date 2024/12/12 11:27 * @version 1.0 */ public static List<PersonnelLevelVo> getIfsLaborClasss(Server srv, String siteCon, String ifsRowVersion) throws APException { StringBuilder searchSql = new StringBuilder(); searchSql.append("SELECT lc.contract site, lc.labor_class_no level_id, lc.labor_class_description level_desc,"); searchSql.append(" (CASE WHEN lc.objstate = 'Active' THEN 'Y' ELSE 'N' END) active, sysdate create_date, 'Admin' create_by,"); searchSql.append(" (CASE WHEN lc.objstate = 'Active' THEN 'Y' ELSE 'N' END) show_in_query_flag,"); searchSql.append(" NULL update_date, NULL update_by, 100 level_cost, lc.objid ifsRowId, lc.OBJVERSION ifsRowVersion"); searchSql.append(" FROM ifsapp.labor_class lc"); //添加判断的查询条件
if(!(null == siteCon || "".equals(siteCon))) { searchSql.append(" WHERE lc.contract IN "+siteCon); } //设置查询的入参
Map<String, String> inParam = new HashMap<>(); if(!(null == ifsRowVersion || "".equals(ifsRowVersion))) { searchSql.append(" AND lc.OBJVERSION >= :ifsRowVersion"); inParam.put("ifsRowVersion", ifsRowVersion); } //添加排序语句
searchSql.append(" ORDER BY lc.OBJVERSION, lc.contract, lc.labor_class_no"); //调用查询的通用方法
RecordCollection recordCollection = IfsPlsqlUtils.execSqlSearchGetRecordCollection(srv, searchSql, inParam); //判断能否返回
if (recordCollection == null) { return new ArrayList<>(); } else { List<PersonnelLevelVo> resultItems = new ArrayList<>(); //调用通用的处理方法 返回Map
List<Map<String, String>> resultList = IfsConverterToMap.ConverterIfsToList(recordCollection); //判断是否存在数据
if(resultList == null) { return resultItems; } //获取数据转bean
for (int i = 0; i < resultList.size(); i++) { Map<String, String> tempMap = resultList.get(i); PersonnelLevelVo tempItem = new PersonnelLevelVo(); //设置参数
//tempItem.setIfsRowId(tempMap.get("IFSROWID"));
tempItem.setIfsRowVersion(tempMap.get("IFSROWVERSION")); tempItem.setSite(tempMap.get("SITE")); tempItem.setLevelId(tempMap.get("LEVEL_ID")); tempItem.setLevelDesc(tempMap.get("LEVEL_DESC")); tempItem.setActive("Y"); tempItem.setShowInQueryFlag(tempMap.get("SHOW_IN_QUERY_FLAG")); tempItem.setCreateDate(DateUtils.getStringToDate(tempMap.get("CREATE_DATE"), "yyyy-MM-dd HH:mm:ss")); // 从tempMap获取值
tempItem.setCreateBy(tempMap.get("CREATE_BY")); // 注意:字段名也改为大写
tempItem.setUpdateDate(null); // 从tempMap获取值
tempItem.setUpdateBy(tempMap.get("UPDATE_BY")); // 从tempMap获取值
tempItem.setLevelCost(new BigDecimal(tempMap.get("LEVEL_COST"))); // 获取成本值
//添加对象
resultItems.add(tempItem); } return resultItems; } }
/** * @description: 获取物料件的数据 * @author LR * @date 2024/12/12 11:34 * @version 1.0 */ public static List<PartCatalog> getPartCatalogs(Server srv, String ifsRowVersion, int startIndex, int pageSize) throws APException { StringBuilder searchSql = new StringBuilder(); searchSql.append("SELECT PART_NO, DESCRIPTION partDesc, INFO_TEXT, STD_NAME_ID, UNIT_CODE,"); searchSql.append(" LOT_TRACKING_CODE, WEIGHT_NET, UOM_FOR_WEIGHT_NET, VOLUME_NET, UOM_FOR_VOLUME_NET,"); //2025-03-21 新增字段
searchSql.append(" PART_MAIN_GROUP, CONDITION_CODE_USAGE_DB, MULTILEVEL_TRACKING_DB, ALLOW_AS_NOT_CONSUMED_DB,"); searchSql.append(" LOT_QUANTITY_RULE, SUB_LOT_RULE, COMPONENT_LOT_RULE,"); searchSql.append(" OBJID ifsRowId, OBJVERSION ifsRowVersion"); searchSql.append(" FROM IFSAPP.PART_CATALOG pc"); //设置查询的入参
Map<String, String> inParam = new HashMap<>(); if(!(null == ifsRowVersion || "".equals(ifsRowVersion))) { searchSql.append(" WHERE pc.OBJVERSION >= :ifsRowVersion"); inParam.put("ifsRowVersion", ifsRowVersion); } //添加排序语句
searchSql.append(" ORDER BY pc.OBJVERSION, pc.PART_NO, pc.DESCRIPTION"); //添加分页的查询语句
searchSql.append(" OFFSET "+startIndex+" ROWS FETCH NEXT "+pageSize+" ROWS ONLY"); //调用查询的通用方法
RecordCollection recordCollection = IfsPlsqlUtils.execSqlSearchGetRecordCollection(srv, searchSql, inParam); //判断能否返回
if (recordCollection == null) { return new ArrayList<>(); } else { List<PartCatalog> resultItems = new ArrayList<>(); //调用通用的处理方法 返回Map
List<Map<String, String>> resultList = IfsConverterToMap.ConverterIfsToList(recordCollection); //获取数据转bean
for (int i = 0; i < resultList.size(); i++) { Map<String, String> tempMap = resultList.get(i); PartCatalog tempItem = new PartCatalog(); //设置参数
tempItem.setIfsRowId(tempMap.get("IFSROWID")); tempItem.setIfsRowVersion(tempMap.get("IFSROWVERSION")); tempItem.setPartNo(tempMap.get("PART_NO").trim()); tempItem.setPartDesc(tempMap.get("PARTDESC")); // 注意:使用小写的partDesc以匹配属性名
tempItem.setInfoText(tempMap.get("INFO_TEXT")); tempItem.setUnitCode(tempMap.get("UNIT_CODE")); tempItem.setLotTrackingCode(tempMap.get("LOT_TRACKING_CODE")); String weightNet = tempMap.get("WEIGHT_NET"); if (null == weightNet || "".equals(weightNet) ||"NULL".equalsIgnoreCase(weightNet)) { tempItem.setWeightNet(null); }else { BigDecimal weightNetNum = new BigDecimal(weightNet); MathContext mc = new MathContext(6, RoundingMode.HALF_UP); BigDecimal result = weightNetNum.round(mc); tempItem.setWeightNetNum(result); }
tempItem.setUomForWeightNet(tempMap.get("UOM_FOR_WEIGHT_NET")); String volumeNet = tempMap.get("VOLUME_NET"); if (null == volumeNet || "".equals(volumeNet) ||"NULL".equalsIgnoreCase(volumeNet)) { tempItem.setVolumeNet(null); }else { BigDecimal volumeNetNum = new BigDecimal(volumeNet); MathContext mc = new MathContext(6, RoundingMode.HALF_UP); BigDecimal result = volumeNetNum.round(mc); tempItem.setVolumeNetNum(result); } tempItem.setUomForVolumeNet(tempMap.get("UOM_FOR_VOLUME_NET")); //新增字段
tempItem.setPartMainGroup(tempMap.get("PART_MAIN_GROUP")); String conditionCodeUsageDb = tempMap.get("CONDITION_CODE_USAGE_DB"); if ("ALLOW_COND_CODE".equalsIgnoreCase(conditionCodeUsageDb)) { tempItem.setConditionCodeUsageDb("Y"); }else { tempItem.setConditionCodeUsageDb("N"); } String multilevelTrackingDb = tempMap.get("MULTILEVEL_TRACKING_DB"); if ("TRACKING_ON".equalsIgnoreCase(multilevelTrackingDb)) { tempItem.setMultilevelTrackingDb("Y"); }else { tempItem.setMultilevelTrackingDb("N"); } String allowAsNotConsumedDb = tempMap.get("ALLOW_AS_NOT_CONSUMED_DB"); if ("TRUE".equalsIgnoreCase(allowAsNotConsumedDb)) { tempItem.setAllowAsNotConsumedDb("Y"); }else { tempItem.setAllowAsNotConsumedDb("N"); }
tempItem.setLotQuantityRule(tempMap.get("LOT_QUANTITY_RULE")); tempItem.setSubLotRule(tempMap.get("SUB_LOT_RULE")); tempItem.setComponentLotRule(tempMap.get("COMPONENT_LOT_RULE")); //添加对象
resultItems.add(tempItem); } return resultItems; } }
/** * @description: 查询库存件的属性值 * @author LR * @date 2024/12/12 11:38 * @version 1.0 */ public static List<InventoryPartUnitCostSumVo> getInventoryValues(Server srv, String siteCon, String ifsRowVersion, int startIndex, int pageSize) throws APException { StringBuilder searchSql = new StringBuilder(); searchSql.append("SELECT OBJID ifsRowId, OBJVERSION ifsRowVersion, CONTRACT site, PART_NO, CONFIGURATION_ID, LOT_BATCH_NO, SERIAL_NO,"); searchSql.append(" ifsapp.Inventory_Part_Unit_Cost_API.Get_Inventory_Value_By_Method(CONTRACT,PART_NO,CONFIGURATION_ID,LOT_BATCH_NO,SERIAL_NO) inventoryValue"); searchSql.append(" FROM ifsapp.INVENTORY_PART_UNIT_COST_SUM pcs"); searchSql.append(" WHERE pcs.CONFIGURATION_ID = '*'"); //添加判断的查询条件
if(!(null == siteCon || "".equals(siteCon))) { searchSql.append(" AND pcs.contract IN "+siteCon); } //设置查询的入参
Map<String, String> inParam = new HashMap<>(); if(!(null == ifsRowVersion || "".equals(ifsRowVersion))) { searchSql.append(" AND pcs.OBJVERSION >= :ifsRowVersion"); inParam.put("ifsRowVersion", ifsRowVersion); } //添加排序语句
searchSql.append(" ORDER BY pcs.OBJVERSION, pcs.contract, pcs.PART_NO"); //添加分页的查询语句
searchSql.append(" OFFSET "+startIndex+" ROWS FETCH NEXT "+pageSize+" ROWS ONLY"); //调用查询的通用方法
RecordCollection recordCollection = IfsPlsqlUtils.execSqlSearchGetRecordCollection(srv, searchSql, inParam); //判断能否返回
if (recordCollection == null) { return new ArrayList<>(); } else { List<InventoryPartUnitCostSumVo> resultItems = new ArrayList<>(); //调用通用的处理方法 返回Map
List<Map<String, String>> resultList = IfsConverterToMap.ConverterIfsToList(recordCollection); //获取数据转bean
for (int i = 0; i < resultList.size(); i++) { Map<String, String> tempMap = resultList.get(i); InventoryPartUnitCostSumVo tempItem = new InventoryPartUnitCostSumVo(); //设置参数
//tempItem.setIfsRowId(tempMap.get("IFSROWID"));
tempItem.setIfsRowVersion(tempMap.get("IFSROWVERSION")); tempItem.setSite(tempMap.get("SITE")); tempItem.setPartNo(tempMap.get("PART_NO")); tempItem.setConfigurationId(tempMap.get("CONFIGURATION_ID")); tempItem.setLotBatchNo(tempMap.get("LOT_BATCH_NO")); tempItem.setSerialNo(tempMap.get("SERIAL_NO")); tempItem.setInventoryValue(tempMap.get("INVENTORYVALUE")); //添加对象
resultItems.add(tempItem); } return resultItems; } }
/** * @description: 根据条件查询库存件的成本价 * @author LR * @date 2025/1/17 11:36 * @version 1.0 */ public static InventoryPartUnitCostSumVo getInventoryValueByPartNo(Server srv, String contract, String partNo) throws APException { StringBuilder searchSql = new StringBuilder(); searchSql.append("SELECT OBJID ifsRowId, OBJVERSION ifsRowVersion, CONTRACT site, PART_NO, CONFIGURATION_ID, LOT_BATCH_NO, SERIAL_NO,"); searchSql.append(" ifsapp.Inventory_Part_Unit_Cost_API.Get_Inventory_Value_By_Method(CONTRACT,PART_NO,CONFIGURATION_ID,LOT_BATCH_NO,SERIAL_NO) inventoryValue"); searchSql.append(" FROM ifsapp.INVENTORY_PART_UNIT_COST_SUM pcs"); searchSql.append(" WHERE pcs.CONTRACT = :contract AND pcs.PART_NO = :partNo AND pcs.CONFIGURATION_ID = '*'"); //设置查询的入参
Map<String, String> inParam = new HashMap<>(); inParam.put("contract", contract); inParam.put("partNo", partNo); //调用查询的通用方法
RecordCollection recordCollection = IfsPlsqlUtils.execSqlSearchGetRecordCollection(srv, searchSql, inParam); //判断能否返回
if (recordCollection == null) { return null; } else { //调用通用的处理方法 返回Map
Map<String, String> resultMap = IfsConverterToMap.ConverterIfsToMap(recordCollection.get(0)); InventoryPartUnitCostSumVo resultRow = new InventoryPartUnitCostSumVo(); //设置参数
resultRow.setIfsRowId(resultMap.get("IFSROWID")); resultRow.setIfsRowVersion(resultMap.get("IFSROWVERSION")); resultRow.setSite(resultMap.get("SITE")); resultRow.setPartNo(resultMap.get("PART_NO")); resultRow.setConfigurationId(resultMap.get("CONFIGURATION_ID")); resultRow.setLotBatchNo(resultMap.get("LOT_BATCH_NO")); resultRow.setSerialNo(resultMap.get("SERIAL_NO")); resultRow.setInventoryValue(resultMap.get("INVENTORYVALUE")); return resultRow; } }
/** * @description: 查询技术等级的属性列表 * @author LR * @date 2025/1/17 14:12 * @version 1.0 */ public static List<TechnicalAttribute> getTechnicalAttributesByCon(Server srv, String technicalSpecNo) throws APException { StringBuilder searchSql = new StringBuilder(); searchSql.append("SELECT OBJID ifsRowId, OBJVERSION ifsRowVersion, TECHNICAL_SPEC_NO, TECHNICAL_CLASS, ATTRIB_NUMBER, ATTRIBUTE,"); searchSql.append(" VALUE_NO, LOWER_LIMIT, UPPER_LIMIT, INFO, ALT_VALUE_NO, ALT_UNIT,"); searchSql.append(" CASE WHEN objtype = 'TechnicalSpecNumeric' THEN 'Numeric'"); searchSql.append(" WHEN objtype = 'TechnicalSpecAlphanum' THEN 'Alpha' ELSE '' END attributeType"); searchSql.append(" FROM ifsapp.TECHNICAL_SPECIFICATION_BOTH"); searchSql.append(" WHERE TECHNICAL_SPEC_NO = :technicalSpecNo");
//设置查询的入参
Map<String, String> inParam = new HashMap<>(); inParam.put("technicalSpecNo", technicalSpecNo); //调用查询的通用方法
RecordCollection recordCollection = IfsPlsqlUtils.execSqlSearchGetRecordCollection(srv, searchSql, inParam); //判断能否返回
if (recordCollection == null) { return new ArrayList<>(); } else { List<TechnicalAttribute> technicalAttributes = new ArrayList<>(); //处理结果集
List<Map<String, String>> resultList = IfsConverterToMap.ConverterIfsToList(recordCollection); //获取数据转bean
for (int i = 0; i < resultList.size(); i++) { Map<String, String> tempMap = resultList.get(i); TechnicalAttribute tempItem = new TechnicalAttribute(); //设置参数
tempItem.setIfsRowId(tempMap.get("IFSROWID")); tempItem.setIfsRowVersion(tempMap.get("IFSROWVERSION")); tempItem.setTechnicalSpecNo(tempMap.get("TECHNICAL_SPEC_NO")); tempItem.setTechnicalClass(tempMap.get("TECHNICAL_CLASS")); tempItem.setAttribute(tempMap.get("ATTRIBUTE")); tempItem.setValueNo(tempMap.get("VALUE_NO")); tempItem.setLowerLimit(tempMap.get("LOWER_LIMIT")); tempItem.setUpperLimit(tempMap.get("UPPER_LIMIT")); tempItem.setInfo(tempMap.get("INFO")); tempItem.setAttributeType(tempMap.get("ATTRIBUTETYPE")); //添加对象
technicalAttributes.add(tempItem); } return technicalAttributes; } }
/** * @description: 加工中心成本 * @author LR * @date 2025/2/10 15:17 * @version 1.0 */ public static List<WorkCenterCost> getWorkCenterCosts(Server srv, String siteCon, String ifsRowVersion, int startIndex, int pageSize) throws APException { StringBuilder searchSql = new StringBuilder(); searchSql.append("SELECT OBJID ifsRowId, OBJVERSION ifsRowVersion, CONTRACT, WORK_CENTER_NO,"); searchSql.append(" ifsapp.WORK_CENTER_API.Get_Description(CONTRACT, WORK_CENTER_NO) workCenterDesc,"); searchSql.append(" COST_SET, '' costSetDesc, WC_RATE, WC_COST_CODE,"); searchSql.append(" OVERHEAD1_FAC, OVERHEAD1_APPL, OVERHEAD2_FAC, OVERHEAD2_APPL,"); searchSql.append(" to_char(START_DATE, 'yyyy-MM-dd') START_DATE, to_char(END_DATE, 'yyyy-MM-dd') END_DATE"); searchSql.append(" FROM ifsapp.WORK_CENTER_COST"); searchSql.append(" WHERE ifsapp.Work_Center_API.Get_Work_Center_Code_Db(contract, work_center_no) = 'I'"); searchSql.append(" AND COST_SET = '1' AND END_DATE IS NULL");
//设置查询的入参
Map<String, String> inParam = new HashMap<>(); //判断是否存在入参
/*if (!(ifsRowVersion == null || "".equals(ifsRowVersion))){ searchSql.append(" AND OBJVERSION >= :ifsRowVersion"); inParam.put("ifsRowVersion", ifsRowVersion); }*/ //添加排序语句
searchSql.append(" ORDER BY CONTRACT, WORK_CENTER_NO, COST_SET, START_DATE"); //添加分页的查询语句
searchSql.append(" OFFSET "+startIndex+" ROWS FETCH NEXT "+pageSize+" ROWS ONLY"); logger.info("加工中心成本查询语句sql"+searchSql.toString()); //调用查询的通用方法
RecordCollection recordCollection = IfsPlsqlUtils.execSqlSearchGetRecordCollection(srv, searchSql, inParam); //判断能否返回
if (recordCollection == null) { return new ArrayList<>(); } else { List<WorkCenterCost> technicalAttributes = new ArrayList<>(); //处理结果集
List<Map<String, String>> resultList = IfsConverterToMap.ConverterIfsToList(recordCollection); //获取数据转bean
for (int i = 0; i < resultList.size(); i++) { Map<String, String> tempMap = resultList.get(i); WorkCenterCost tempItem = new WorkCenterCost(); //设置参数
tempItem.setIfsRowId(tempMap.get("IFSROWID")); tempItem.setIfsRowVersion(tempMap.get("IFSROWVERSION")); tempItem.setSite(tempMap.get("CONTRACT")); tempItem.setWorkCenterNo(tempMap.get("WORK_CENTER_NO")); tempItem.setWorkCenterDesc(tempMap.get("WORKCENTERDESC")); tempItem.setCostSet(tempMap.get("COST_SET")); tempItem.setCostSetDesc(tempMap.get("COSTSETDESC")); tempItem.setWcRate(tempMap.get("WC_RATE")); tempItem.setWcCostCode(tempMap.get("WC_COST_CODE")); tempItem.setOverhead1Fac(tempMap.get("OVERHEAD1_FAC")); tempItem.setOverhead2Fac(tempMap.get("OVERHEAD2_FAC")); tempItem.setOverhead1Appl(tempMap.get("OVERHEAD1_APPL")); tempItem.setOverhead2Appl(tempMap.get("OVERHEAD2_APPL")); String startDate = tempMap.get("START_DATE"); if (!(null == startDate || "".equals(startDate))){ tempItem.setBeginDate(DateUtils.getStringToDate(startDate, "yyyy-MM-dd")); } String endDate = tempMap.get("END_DATE"); if (!(null == endDate || "".equals(endDate))) { tempItem.setEndDate(DateUtils.getStringToDate(endDate, "yyyy-MM-dd")); } //添加对象
technicalAttributes.add(tempItem); } return technicalAttributes; } }
/** * @description: 按照时间获取所有域下的库存件信息 * @author LR * @date 2025/3/7 10:58 * @version 1.0 */ public static List<PartIfsInventory> getInventoryParts(Server srv, String ifsRowVersion, int startIndex, int pageSize) throws APException { StringBuilder searchSql = new StringBuilder(); searchSql.append("SELECT OBJID ifsRowId, OBJVERSION ifsRowVersion, PART_NO, DESCRIPTION, CONTRACT, TYPE_CODE, PLANNER_BUYER,"); searchSql.append(" UNIT_MEAS, PRIME_COMMODITY, SECOND_COMMODITY, ASSET_CLASS, PART_STATUS, ABC_CLASS, FREQUENCY_CLASS, LIFECYCLE_STAGE,"); 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,"); searchSql.append(" NOTE_TEXT, LEAD_TIME_CODE, PURCH_LEADTIME, MANUF_LEADTIME, EXPECTED_LEADTIME, DURABILITY_DAY, COUNTRY_OF_ORIGIN, REGION_OF_ORIGIN,"); searchSql.append(" SUPPLY_CODE, INVENTORY_VALUATION_METHOD, INVENTORY_PART_COST_LEVEL, INVOICE_CONSIDERATION, ZERO_COST_FLAG, PART_COST_GROUP_ID,"); searchSql.append(" STD_NAME_ID, ENG_ATTRIBUTE, SUPPLY_CODE, CF$_CCL_COMM_GROUP_3 COMM_GROUP_3"); searchSql.append(" FROM ifsapp.INVENTORY_PART_CFV"); searchSql.append(" WHERE OBJVERSION >:ifsRowVersion");
//设置查询的入参
Map<String, String> inParam = new HashMap<>(); inParam.put("ifsRowVersion", ifsRowVersion); //添加排序语句
searchSql.append(" ORDER BY OBJVERSION ASC"); //添加分页的查询语句
searchSql.append(" OFFSET "+startIndex+" ROWS FETCH NEXT "+pageSize+" ROWS ONLY"); logger.info("库存件查询语句sql"+searchSql.toString()); //调用查询的通用方法
RecordCollection recordCollection = IfsPlsqlUtils.execSqlSearchGetRecordCollection(srv, searchSql, inParam); //判断能否返回
if (recordCollection == null) { return new ArrayList<>(); } else { List<PartIfsInventory> returnlList = new ArrayList<>(); //处理结果集
List<Map<String, String>> resultList = IfsConverterToMap.ConverterIfsToList(recordCollection); //获取数据转bean
for (int i = 0; i < resultList.size(); i++) { Map<String, String> tempMap = resultList.get(i); PartIfsInventory tempItem = new PartIfsInventory(); //设置参数
tempItem.setIfsRowId(tempMap.get("IFSROWID")); tempItem.setIfsRowVersion(tempMap.get("IFSROWVERSION")); tempItem.setContract(tempMap.get("CONTRACT")); tempItem.setPartNo(tempMap.get("PART_NO")); tempItem.setPartDesc(tempMap.get("DESCRIPTION")); tempItem.setTypeCode(tempMap.get("TYPE_CODE")); tempItem.setPlannerBuyer(tempMap.get("PLANNER_BUYER")); tempItem.setUnitMeas(tempMap.get("UNIT_MEAS")); tempItem.setPrimeCommodity(tempMap.get("PRIME_COMMODITY")); tempItem.setSecondCommodity(tempMap.get("SECOND_COMMODITY")); tempItem.setAssetClass(tempMap.get("ASSET_CLASS")); tempItem.setPartStatus(tempMap.get("PART_STATUS")); tempItem.setAbcClass(tempMap.get("ABC_CLASS")); tempItem.setFrequencyClass(tempMap.get("FREQUENCY_CLASS")); tempItem.setLifecycleStage(tempMap.get("LIFECYCLE_STAGE")); tempItem.setHazardCode(tempMap.get("HAZARD_CODE")); tempItem.setAccountingGroup(tempMap.get("ACCOUNTING_GROUP")); tempItem.setPartProductCode(tempMap.get("PART_PRODUCT_CODE")); tempItem.setPartProductFamily(tempMap.get("PART_PRODUCT_FAMILY")); tempItem.setTypeDesignation(tempMap.get("TYPE_DESIGNATION")); tempItem.setDimQuality(tempMap.get("DIM_QUALITY")); tempItem.setNoteText(tempMap.get("NOTE_TEXT")); tempItem.setLeadTimeCode(tempMap.get("LEAD_TIME_CODE")); tempItem.setManufLeadtime(tempMap.get("MANUF_LEADTIME")); tempItem.setExpectedLeadtime(tempMap.get("EXPECTED_LEADTIME")); String durabilityDay = tempMap.get("DURABILITY_DAY"); if (null == durabilityDay || "".equals(durabilityDay) || "NULL".equalsIgnoreCase(durabilityDay)){ tempItem.setDurabilityDay("0"); }else { BigDecimal bigDecimal = new BigDecimal(durabilityDay); // 去除尾部的零
bigDecimal = bigDecimal.setScale(0, BigDecimal.ROUND_HALF_UP); bigDecimal = bigDecimal.stripTrailingZeros(); // 设置小数位数,最多保留 16 位有效数字
String formatterValue = bigDecimal.toPlainString(); tempItem.setDurabilityDay(formatterValue); } tempItem.setCountryOfOrigin(tempMap.get("COUNTRY_OF_ORIGIN")); tempItem.setRegionOfOrigin(tempMap.get("REGION_OF_ORIGIN")); tempItem.setInventoryValuationMethod(tempMap.get("INVENTORY_VALUATION_METHOD")); tempItem.setInventoryPartCostLevel(tempMap.get("INVENTORY_PART_COST_LEVEL")); tempItem.setInvoiceConsideration(tempMap.get("INVOICE_CONSIDERATION")); tempItem.setZeroCostFlag(tempMap.get("ZERO_COST_FLAG")); tempItem.setPartCostGroupId(tempMap.get("PART_COST_GROUP_ID")); tempItem.setEngAttribute(tempMap.get("ENG_ATTRIBUTE")); String createdDate = tempMap.get("CREATE_DATE"); if (!(null == createdDate || "".equals(createdDate))){ tempItem.setCreatedDate(DateUtils.getStringToDate(createdDate, "yyyy-MM-dd HH:mm:ss")); } tempItem.setSupplyCode(tempMap.get("SUPPLY_CODE")); tempItem.setCommGroup3(tempMap.get("COMM_GROUP_3")); //添加对象
returnlList.add(tempItem); } return returnlList; } }
/** * @description: 查询人员等级成本 * @author LR * @date 2025/5/6 11:58 * @version 1.0 */ public static List<PersonnelLevelVo> getLaborClassCosts(Server srv, String siteCon, int startIndex, int pageSize) throws APException { StringBuilder searchSql = new StringBuilder(); searchSql.append("SELECT lcc.OBJID ifsRowId, lcc.OBJVERSION ifsRowVersion, lcc.CONTRACT, lcc.LABOR_CLASS_NO,"); searchSql.append(" lc.labor_class_description laborClassDesc,"); searchSql.append(" lcc.COST_SET, '' costSetDesc,"); searchSql.append(" lcc.labor_class_RATE, lcc.labor_class_COST_CODE,"); searchSql.append(" to_char(lcc.START_DATE, 'yyyy-MM-dd') START_DATE, to_char(lcc.END_DATE, 'yyyy-MM-dd') END_DATE,"); searchSql.append(" (CASE WHEN lc.objstate = 'Active' THEN 'Y' ELSE 'N' END) active"); searchSql.append(" FROM ifsapp.LABOR_CLASS_COST lcc"); searchSql.append(" LEFT JOIN ifsapp.labor_class lc ON lc.CONTRACT = lcc.CONTRACT AND lc.LABOR_CLASS_NO = lcc.LABOR_CLASS_NO"); searchSql.append(" WHERE lcc.COST_SET = '1' AND lcc.END_DATE IS NULL");
//添加判断的查询条件
if(!(null == siteCon || "".equals(siteCon))) { searchSql.append(" AND lcc.contract IN "+siteCon); } //设置查询的入参
Map<String, String> inParam = new HashMap<>(); //添加排序语句
searchSql.append(" ORDER BY lcc.CONTRACT, lcc.LABOR_CLASS_NO"); //添加分页的查询语句
searchSql.append(" OFFSET "+startIndex+" ROWS FETCH NEXT "+pageSize+" ROWS ONLY"); logger.info("人员等级成本查询语句sql"+searchSql.toString()); //调用查询的通用方法
RecordCollection recordCollection = IfsPlsqlUtils.execSqlSearchGetRecordCollection(srv, searchSql, inParam); //判断能否返回
if (recordCollection == null) { return new ArrayList<>(); } else { List<PersonnelLevelVo> returnlList = new ArrayList<>(); //处理结果集
List<Map<String, String>> resultList = IfsConverterToMap.ConverterIfsToList(recordCollection); //获取数据转bean
for (int i = 0; i < resultList.size(); i++) { Map<String, String> tempMap = resultList.get(i); PersonnelLevelVo tempItem = new PersonnelLevelVo(); //设置参数
//tempItem.setIfsRowId(tempMap.get("IFSROWID"));
tempItem.setIfsRowVersion(tempMap.get("IFSROWVERSION")); tempItem.setSite(tempMap.get("CONTRACT")); tempItem.setLevelId(tempMap.get("LABOR_CLASS_NO")); tempItem.setLevelDesc(tempMap.get("LABORCLASSDESC")); tempItem.setActive(tempMap.get("ACTIVE")); tempItem.setCreateDate(DateUtils.getStringToDate(tempMap.get("START_DATE"), "yyyy-MM-dd")); tempItem.setCreateBy(tempMap.get("Admin")); tempItem.setUpdateDate(null); // 从tempMap获取值
tempItem.setUpdateBy(tempMap.get("UPDATE_BY")); // 从tempMap获取值
tempItem.setLevelCost(new BigDecimal(tempMap.get("LABOR_CLASS_RATE")).setScale(6, BigDecimal.ROUND_HALF_UP)); //添加对象
returnlList.add(tempItem); } return returnlList; } }}
|