| | |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.text.DecimalFormat; |
| | | import java.time.LocalDate; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * 设备产品过程参数采集Controller |
| | |
| | | DaParamCollection OP130_ThreePhaseResistance3 = daParamCollectionService.getOne(new LambdaQueryWrapper<DaParamCollection>().eq(DaParamCollection::getParamCode, "OP130_ThreePhaseResistance3").eq(DaParamCollection::getSfcCode,daParamCollection.getProductNum())); |
| | | DaParamCollection OP130_BalanceDegree2 = daParamCollectionService.getOne(new LambdaQueryWrapper<DaParamCollection>().eq(DaParamCollection::getParamCode, "OP130_ThreePhaseResistance2").eq(DaParamCollection::getSfcCode,daParamCollection.getProductNum())); |
| | | DaParamCollection OP130_BalanceDegree1 = daParamCollectionService.getOne(new LambdaQueryWrapper<DaParamCollection>().eq(DaParamCollection::getParamCode, "OP130_ThreePhaseResistance1").eq(DaParamCollection::getSfcCode,daParamCollection.getProductNum())); |
| | | info.setParam27(OP130_ThreePhaseResistance3.getParamValue()+","+OP130_BalanceDegree2.getParamValue()+","+OP130_BalanceDegree1.getParamValue()); |
| | | info.setParam27(getParam27(OP130_ThreePhaseResistance3.getParamValue()+","+OP130_BalanceDegree2.getParamValue()+","+OP130_BalanceDegree1.getParamValue())); |
| | | |
| | | DaParamCollection OP130_28_BalanceDegree1 = daParamCollectionService.getOne(new LambdaQueryWrapper<DaParamCollection>().eq(DaParamCollection::getParamCode, "OP130_BalanceDegree1").eq(DaParamCollection::getSfcCode,daParamCollection.getProductNum())); |
| | | DaParamCollection OP130_28_BalanceDegree2 = daParamCollectionService.getOne(new LambdaQueryWrapper<DaParamCollection>().eq(DaParamCollection::getParamCode, "OP130_BalanceDegree2").eq(DaParamCollection::getSfcCode,daParamCollection.getProductNum())); |
| | | DaParamCollection OP130_28_BalanceDegree3 = daParamCollectionService.getOne(new LambdaQueryWrapper<DaParamCollection>().eq(DaParamCollection::getParamCode, "OP130_BalanceDegree3").eq(DaParamCollection::getSfcCode,daParamCollection.getProductNum())); |
| | | info.setParam28(OP130_28_BalanceDegree1.getParamValue()+","+OP130_28_BalanceDegree2.getParamValue()+","+OP130_28_BalanceDegree3.getParamValue()); |
| | | info.setParam28(getParam28(OP130_28_BalanceDegree1.getParamValue()+","+OP130_28_BalanceDegree2.getParamValue()+","+OP130_28_BalanceDegree3.getParamValue())); |
| | | |
| | | info.setParam29(getParam29(daParamCollection.getProductNum())); |
| | | |
| | |
| | | } |
| | | |
| | | public static void main(String[] args) { |
| | | String input = "4.257426"; |
| | | String param27 = "49.260002,49.122525,49.06235235"; |
| | | String param28 = "0.163,0.061,0.224"; |
| | | // 按逗号分割字符串 |
| | | String[] parts = param27.split(","); |
| | | |
| | | // 确定起始位置和结束位置 |
| | | int startIndex = 13; // 起始位置 |
| | | int endIndex = 26; // 结束位置 |
| | | // 创建一个 DecimalFormat 实例,用于格式化数字 |
| | | DecimalFormat df = new DecimalFormat("#.00"); |
| | | |
| | | // 截取字符串 |
| | | String extracted = input.substring(0, 4); |
| | | // 遍历分割后的数组,并格式化每个元素 |
| | | // for (String part : parts) { |
| | | // double value = Double.parseDouble(part); |
| | | // String formattedValue = df.format(value); |
| | | // System.out.println(formattedValue); |
| | | // } |
| | | |
| | | System.out.println(getReviewerDate()); |
| | | String result = Arrays.stream(parts) |
| | | .map(part -> df.format(Double.parseDouble(part))) |
| | | .collect(Collectors.joining(",")); |
| | | |
| | | System.out.println(result); |
| | | System.out.println(getParam28(param28)); |
| | | |
| | | } |
| | | |
| | | public static String getParam28(String input) { |
| | | // 分割字符串 |
| | | String[] parts = input.split(","); |
| | | StringBuilder sb = new StringBuilder(); |
| | | |
| | | for (int i = 0; i < parts.length; i++) { |
| | | // 在每个部分后面加上 % |
| | | sb.append(parts[i]).append("%"); |
| | | if (i < parts.length - 1) { |
| | | sb.append(","); |
| | | } |
| | | } |
| | | |
| | | return sb.toString(); |
| | | } |
| | | |
| | | public String getParam27(String param){ |
| | | String[] parts = param.split(","); |
| | | DecimalFormat df = new DecimalFormat("#.00"); |
| | | String result = Arrays.stream(parts) |
| | | .map(part -> df.format(Double.parseDouble(part))) |
| | | .collect(Collectors.joining(",")); |
| | | return result; |
| | | } |
| | | |
| | | /** |