java – ZIP operation by passing multiple IDs (database entries) using Spring Boot

I am new to Java. I need help choosing multiple IDs to download and compress the result. A GET resource must be created to accommodate multiple input parameters (multiple IDs, such as 100, 101, 102, and so on). My backend MSSQL server needed data. If my newly developed resource is called using the GET method, the database should return data for the above IDs. This result should then be compressed and downloaded to my local download folder. I should be able to unpack the content without error.

Below is the code snippet that uses the ID as an input parameter, retrieves the record specific to that ID, downloads it locally, and compresses it. Now the code needs to be changed to allow multiple IDs to be selected for download and ziping.

@GetMapping("/message/multidownload")
@CrossOrigin(origins = "*")
public void multidownload(@RequestParam("ids") Long id, HttpServletRequest request,
                     HttpServletResponse response) throws Exception {
    MessageEntity messageEntity = messageRepository.findById(id).orElseThrow(() -> new Exception("ID Not found!"));
    String xml = new ObjectMapper().writeValueAsString(messageEntity);
    String fileName = "message.zip";
    String xml_name = "message.xml";
    byte() data = xml.getBytes();
    byte() bytes;
    try (ByteOutputStream bout = new ByteOutputStream();
         ZipOutputStream zout = new ZipOutputStream(bout)) {
        zout.setLevel(1);
        ZipEntry ze = new ZipEntry(xml_name);
        ze.setSize(data.length);
        zout.putNextEntry(ze);
        zout.write(data);
        zout.closeEntry();
        bytes = bout.getBytes();
    }
    response.setContentType("application/zip");
    response.setContentLength(bytes.length);
    response.setHeader("Content-Disposition", "attachment; " + String.format("filename=" + fileName));
    ServletOutputStream outputStream = response.getOutputStream();
    FileCopyUtils.copy(bytes, outputStream);
    outputStream.close();
}

Actual result: Single packed record file

Expected Result: A compressed file with multiple records (passed as parameters in the URL, such as id = 101,102,103,104, and so on).

Plot – Reduce the distance between the legend entries with ads

I create two charts and use Show to layer. However, the legend has a very large gap between the lines. This answer suggests using the image size, but my legend is not a separate graphic object. This other solution uses distances seems to have the same problem. That or I can not figure out how to use spacings properly, I've tried to integrate it into PlotLegendsbut no luck.

I would like to have a one line spacing in the legend without changing the image size or font size.

MWE

x = Range[0, 10];
y = x^2 * RandomReal[];

plt1 = ListPlot[list, PlotStyle -> Blue, PlotRange -> {0, 100}, 
  Frame -> True, FrameLabel -> {Style["Distance [m]", 8], "Conc"}, 
  PlotLabel -> Style["Title", 10
    ], ImageSize -> Small, 
  PlotLegends -> Placed[{Style["numerical", 8, Black]}, {Left, Top}], 
  LabelStyle -> Black, FrameTicksStyle -> 8]

plt2 = Plot[x^2, {x, 0, 10}, PlotStyle -> {Thick, Red}, 
  PlotRange -> {0, 100}, Frame -> True, ImageSize -> Small, 
  PlotLegends -> Placed[{Style["analytical", 8, Black]}, {Left, Top}],
   LabelStyle -> Black, FrameTicksStyle -> 8]

Show[plt2, plt1]

Enter image description here

Help finding multiple entries in a column

I try to query several different colors from a column. I have so far:

= Query (& # 39; raw data & # 39;! C1: J1000, "select E, D, I, J, C, F, H where H & gt; is M & # 39; and F = & 39; Green & # 39; and C = & # 39; schools & # 39; in the order of E contains ").

For example, I would like to query all elements that are green, red and blue in column F. Is there a way to query a multiple selection in a column?

javascript – Filters for column HTML table with jquery through entries in the table header

I need someone to help me with this problem.
I have a table from which to schedule staff shifts, and I need to be able to filter the columns with data extracted from them MySQLAs an example I only use the data shown in the table.

 

    $(document).ready(function(){

        $("#search").keyup(function(){

        _this = this;

        

            $.each($("#datos tbody tr"), function() {

            if($(this).text().toLowerCase().indexOf($(_this).val().toLowerCase()) === -1)

            $(this).hide();

            else

            $(this).show();

            });

        });

    });
#datos thead
{
  font-weight:bold;
  color:red;
}







First name Surname 01 NOV 02. NOV 03. NOV 04 NOV 05 NOV
John Riquelme T T T D D
Robert Andrade D D D T T
You take Riquelme D D D T T

The problem with everything is that the search filter works well, but I want to try to filter it by columns, d. H. That entries are under the column header and can be filtered by the information in this column. An example would be something like that.








First name Surname 01 NOV 02. NOV 03. NOV 04 NOV 05 NOV
John Riquelme T T T D D
Robert Andrade D D D T T
You take Riquelme D D D T T

Do you need a change? jquery What did I add above? And that works by classes and filters the values ​​only by columns?

Please avoid the use of datatables because the table I work with is too big (different columns) and I only need this to create filters, nor the use of tablefilterfree,

china – Number of Chinese tourist visa entries

I'm an Indian living in the US, flying from the US to India with a two-hour transit in China and then back to the US with a three-day gap between the India-China and China-USA flights.

I think I should have a simple visa tourist visa for the return journey, but both agencies that I consulted have advised me to apply for a double entry instead. Has anyone experienced something similar? Has anyone got his tourist visa denied because of such ambiguity?

If it helps, the responsible Chinese consulate is in San Francisco.

Algorithms – Iterate Cartesian product (cross product) of ordered lists of positive numbers in order of decreasing product entries (including MVCE of a stub)

Suppose I have several sorted lists of positive numbers, such as:

double() a1 = new double(){0.70, 0.20, 0.10};
double() a2 = new double(){0.80, 0.10, 0.05, 0.05};
double() a3 = new double(){0.60, 0.15, 0.14, 0.10, 0.01};

I would like to iterate the Cartesian product of these arrays in descending order of entries:

0000: Combo(product=3.36e-01, vals=(0.70, 0.80, 0.60), indexes=(0, 0, 0))
0001: Combo(product=9.60e-02, vals=(0.20, 0.80, 0.60), indexes=(1, 0, 0))
0002: Combo(product=8.40e-02, vals=(0.70, 0.80, 0.15), indexes=(0, 0, 1))
0003: Combo(product=7.84e-02, vals=(0.70, 0.80, 0.14), indexes=(0, 0, 2))
0004: Combo(product=5.60e-02, vals=(0.70, 0.80, 0.10), indexes=(0, 0, 3))
0005: Combo(product=4.80e-02, vals=(0.10, 0.80, 0.60), indexes=(2, 0, 0))
...

For example, In the above example, the first entry is obvious (because the arrays are sorted) and a combination of the first values: (0.70, 0.80, 0.60) with product 0.70*0.80*0.60 = 3.36e-01 and corresponding value indexes in arrays a1, a2, a3 are (0, 0, 0), Now the second entry is less obvious, we should change it 0.70 to 0.20? Or 0.60 to 0.15? Or 0.80 to 0.10? The second should be (0.20, 0.80, 0.60)with product 9.60e-02indices (1, 0, 0),

Here is a program in Java to generate / print them: https://repl.it/repls/FilthyGreatRotation (the whole logic is in printWholeCartesianProduct() Method)
This program generates it in lexicographical order and then sorts the entire record by product.

question: Is there an easy way to generate the combos in the right order?

The reason for that: I do not have the lists in the first place, just iterators over some sorted collections of numbers. Possibly very long, length not known in advance, but it is known that the numbers in each iterator are sorted.

MVCE to play (as in the above link https://repl.it):

import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.StringJoiner;
import java.util.function.Consumer;
import java.util.stream.Collectors;

public class Main {

    public static void main(String() args) {
        List> data = createData();
        printWholeCartesianProduct(data);
    }

    public static List> createData() {
        double() a1 = new double(){0.70, 0.20, 0.10};
        double() a2 = new double(){0.80, 0.10, 0.05, 0.05};
        double() a3 = new double(){0.60, 0.15, 0.14, 0.10, 0.01};
        return createData(a1, a2, a3);
    }

    public static void  printWholeCartesianProduct(List> data) {
        final DecimalFormat df = new DecimalFormat("0.00");

        // print input data
        String matrix = data.stream()
            .map(l -> l.stream().map(df::format).collect(Collectors.joining(", ")))
            .map(row -> "(" + row + ")")
            .collect(Collectors.joining("n"));
        System.out.println("Input data:n" + matrix);

        // collect combos as they are generated
        final List combos = new ArrayList<>();
        Consumer callback = indexes -> {
            double() v = new double(indexes.length);
            double prod = 1;
            for (int i = 0; i < indexes.length; i++) {
                List col = data.get(i);
                int index = indexes(i);
                v(i) = col.get(index);
                prod *= v(i);
            }
            combos.add(new Combo(prod, v, indexes.clone()));
        };

        // generate combos
        int() c = new int(data.size());
        int ptr = c.length - 1;
        while (ptr >= 0) {
            callback.accept(c);
            c(ptr)++; // increment
            if (c(ptr) == data.get(ptr).size()) { // carry
                do {
                    ptr--;
                } while(ptr >= 0 && c(ptr) == data.get(ptr).size() - 1);
                if (ptr < 0) {
                    break;
                }
                c(ptr)++;
                // zero out
                while (++ptr <= c.length - 1) {
                    c(ptr) = 0;
                }
                ptr = c.length - 1;
            }
        }

        // cheating - sort after generation and print result
        combos.sort((o1, o2) -> Double.compare(o2.product, o1.product));
        StringBuilder sb = new StringBuilder();
        double totalP = 0;
        for (int i = 0; i < combos.size(); i++) {
            sb.append(String.format("%04d: ", i)).append(combos.get(i)).append("n");
            totalP += combos.get(i).product;
        }
        System.out.printf("Cartesian product in descending product (total p=%.3e):n%s", totalP, sb.toString());
    }

    public static List asList(double() a) {
        return Arrays.stream(a).boxed().collect(Collectors.toList());
    }

    public static List> createData(double()... arrays) {
        final List> vals = new ArrayList<>();
        Arrays.stream(arrays).forEachOrdered(a -> vals.add(asList(a)));
        return vals;
    }

    static class Combo {
        final double product;
        final double() vals;
        final int() indexes;

        Combo(double product, double() vals, int() indexes) {
            this.product = product;
            this.vals = vals;
            this.indexes = indexes;
        }

        @Override
        public String toString() {
            return new StringJoiner(", ", Combo.class.getSimpleName() + "(", ")")
                .add("product=" + String.format("%.2e", product))
                .add("vals=(" + Arrays.stream(vals).boxed().map(v -> String.format("%.2f", v)).collect(
                    Collectors.joining(", ")) + ")")
                .add("indexes=" + Arrays.toString(indexes))
                .toString();
        }
    }
}
```

Algorithms – Cartesian product (cross product) of sorted lists of numbers in order of decreasing product of entries (MVCE of a stub included)

Suppose I have several sorted number lists, for example:

double() a1 = new double(){0.70, 0.20, 0.10};
double() a2 = new double(){0.80, 0.10, 0.05, 0.05};
double() a3 = new double(){0.60, 0.15, 0.14, 0.10, 0.01};

I would like to iterate the Cartesian product of these arrays in descending order of entries:

0000: Combo(product=3.36e-01, vals=(0.70, 0.80, 0.60), indexes=(0, 0, 0))
0001: Combo(product=9.60e-02, vals=(0.20, 0.80, 0.60), indexes=(1, 0, 0))
0002: Combo(product=8.40e-02, vals=(0.70, 0.80, 0.15), indexes=(0, 0, 1))
0003: Combo(product=7.84e-02, vals=(0.70, 0.80, 0.14), indexes=(0, 0, 2))
0004: Combo(product=5.60e-02, vals=(0.70, 0.80, 0.10), indexes=(0, 0, 3))
0005: Combo(product=4.80e-02, vals=(0.10, 0.80, 0.60), indexes=(2, 0, 0))
...

For example, In the above example, the first entry is obvious (because the arrays are sorted) and a combination of the first values: (0.70, 0.80, 0.60) with product 0.70*0.80*0.60 = 3.36e-01 and corresponding value indexes in arrays a1, a2, a3 are (0, 0, 0), Now the second entry is less obvious, we should change it 0.70 to 0.20? Or 0.60 to 0.15? Or 0.80 to 0.10? The second should be (0.20, 0.80, 0.60)with product 9.60e-02indices (1, 0, 0),

Here is a program in Java to generate / print them: https://repl.it/repls/FilthyGreatRotation (the whole logic is in printWholeCartesianProduct() Method)
This program generates it in lexicographical order and then sorts the entire record by product.

question: Is there an easy way to generate the combos in the right order?

The reason for that: I do not have the lists in the first place, just iterators over some sorted collections of numbers. Possibly very long, length not known in advance, but it is known that the numbers in each iterator are sorted.

MVCE to play (as in the above link https://repl.it):

import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.StringJoiner;
import java.util.function.Consumer;
import java.util.stream.Collectors;

public class Main {

    public static void main(String() args) {
        List> data = createData();
        printWholeCartesianProduct(data);
    }

    public static List> createData() {
        double() a1 = new double(){0.70, 0.20, 0.10};
        double() a2 = new double(){0.80, 0.10, 0.05, 0.05};
        double() a3 = new double(){0.60, 0.15, 0.14, 0.10, 0.01};
        return createData(a1, a2, a3);
    }

    public static void  printWholeCartesianProduct(List> data) {
        final DecimalFormat df = new DecimalFormat("0.00");

        // print input data
        String matrix = data.stream()
            .map(l -> l.stream().map(df::format).collect(Collectors.joining(", ")))
            .map(row -> "(" + row + ")")
            .collect(Collectors.joining("n"));
        System.out.println("Input data:n" + matrix);

        // collect combos as they are generated
        final List combos = new ArrayList<>();
        Consumer callback = indexes -> {
            double() v = new double(indexes.length);
            double prod = 1;
            for (int i = 0; i < indexes.length; i++) {
                List col = data.get(i);
                int index = indexes(i);
                v(i) = col.get(index);
                prod *= v(i);
            }
            combos.add(new Combo(prod, v, indexes.clone()));
        };

        // generate combos
        int() c = new int(data.size());
        int ptr = c.length - 1;
        while (ptr >= 0) {
            callback.accept(c);
            c(ptr)++; // increment
            if (c(ptr) == data.get(ptr).size()) { // carry
                do {
                    ptr--;
                } while(ptr >= 0 && c(ptr) == data.get(ptr).size() - 1);
                if (ptr < 0) {
                    break;
                }
                c(ptr)++;
                // zero out
                while (++ptr <= c.length - 1) {
                    c(ptr) = 0;
                }
                ptr = c.length - 1;
            }
        }

        // cheating - sort after generation and print result
        combos.sort((o1, o2) -> Double.compare(o2.product, o1.product));
        StringBuilder sb = new StringBuilder();
        double totalP = 0;
        for (int i = 0; i < combos.size(); i++) {
            sb.append(String.format("%04d: ", i)).append(combos.get(i)).append("n");
            totalP += combos.get(i).product;
        }
        System.out.printf("Cartesian product in descending product (total p=%.3e):n%s", totalP, sb.toString());
    }

    public static List asList(double() a) {
        return Arrays.stream(a).boxed().collect(Collectors.toList());
    }

    public static List> createData(double()... arrays) {
        final List> vals = new ArrayList<>();
        Arrays.stream(arrays).forEachOrdered(a -> vals.add(asList(a)));
        return vals;
    }

    static class Combo {
        final double product;
        final double() vals;
        final int() indexes;

        Combo(double product, double() vals, int() indexes) {
            this.product = product;
            this.vals = vals;
            this.indexes = indexes;
        }

        @Override
        public String toString() {
            return new StringJoiner(", ", Combo.class.getSimpleName() + "(", ")")
                .add("product=" + String.format("%.2e", product))
                .add("vals=(" + Arrays.stream(vals).boxed().map(v -> String.format("%.2f", v)).collect(
                    Collectors.joining(", ")) + ")")
                .add("indexes=" + Arrays.toString(indexes))
                .toString();
        }
    }
}
```

union – I'm trying to arrange a 3-column table as if the columns were grouped together so they would be sorted as 3 separate entries

I came across a somewhat unique obstacle with my current project. Below is a replica MySQL table to better describe the problem I'm trying to solve.

mysql> describe `minimized_event_instructions`;
+-----------------+------------------+
| Field           | Type             |
+-----------------+------------------+
| id              | int(10) unsigned |
| event_inst_min  | tinytext         |
| custom_time_1   | datetime         |
| custom_time_2   | datetime         |
| custom_time_3   | datetime         |
| deploy_time     | datetime         |
| completion_time | datetime         |
| error           | tinytext         |
+-----------------+------------------+

Particularly noteworthy are the custom_time_X fields. Each of the 3 fields contains a date and time for a particular phase of each event. However, I have come across the need to arrange the table according to these fields.

I tried the following query – thought I was smart:

mysql> SELECT  `a`.`custom_time_1` AS `combined_times`,
    ->         `b`.`custom_time_2` AS `combined_times`,
    ->         `c`.`custom_time_3` AS `combined_times`
    -> 
    -> FROM `minimized_event_instructions` AS `a`
    -> CROSS JOIN `minimized_event_instructions` AS `b`
    -> CROSS JOIN `minimized_event_instructions` AS `c`;

… but in the end I got that.

+---------------------+---------------------+---------------------+
| combined_times      | combined_times      | combined_times      |
+---------------------+---------------------+---------------------+
| 2019.10.23 01:15:00 | 2019.10.23 05:25:00 | 2019.10.23 10:30:00 |
| 2019.10.23 01:15:00 | 2019.10.23 05:25:00 | 2019.10.23 10:30:00 |
| 2019.10.23 01:15:00 | 2019.10.23 05:25:00 | 2019.10.23 10:30:00 |
+---------------------+---------------------+---------------------+

Then I tried with UNION:

SELECT  `a`.`custom_time_1` AS `combined_times`
FROM `client_custom_sms_times` AS `a`
UNION
SELECT  `b`.`custom_time_2` AS `combined_times`
FROM `client_custom_sms_times` AS `b`
UNION
SELECT  `c`.`custom_time_3` AS `combined_times`
FROM `client_custom_sms_times` AS `c`;

But that only gave me that … which is soooo close – but totally useless:

+---------------------+
| combined_times      |
+---------------------+
| 2019.10.23 01:15:00 |
| 2019.10.23 05:25:00 |
| 2019.10.23 10:30:00 |
+---------------------+

I tried a few other things without success. The result set I'm looking for would ideally look something like this:

+----+----------------+---------------------+-------------+-----------------+-------+
| id | event_inst_min | combined_times      | deploy_time | completion_time | error |
+----+----------------+---------------------+-------------+-----------------+-------+
|  5 | inst:f2:rak... | 2019.10.23 01:15:00 |        null |            null |  null |
| 12 | inst:f2:211... | 2019.10.23 01:20:00 |        null |            null |  null |
|  2 | inst:71        | 2019.10.23 02:30:00 |        null |            null |  null |
| 12 | inst:f2:211... | 2019.10.23 02:35:00 |        null |            null |  null |
|  2 | inst:71        | 2019.10.23 03:00:00 |        null |            null |  null |
|  5 | inst:f2:rak... | 2019.10.23 05:25:00 |        null |            null |  null |
| 12 | inst:f2:211... | 2019.10.23 10:30:00 |        null |            null |  null |
|  2 | inst:71        | 2019.10.23 10:05:00 |        null |            null |  null |
+----+----------------+---------------------+-------------+-----------------+-------+

I've wasted too much time solving this problem … any thoughts? I had thought about creating a temporary table and entering only 3 records for each record from the original table. But if there is a more direct method with a single query, that would be ideal.

Thanks in advance for any help anyone could have.

Information Architecture – Timesheet Entries UX

How to differentiate new time entries

I have a timesheet that looks like this:
Timesheet

Which works fine. Customers can see all their time entries on one screen and see the times of the week at a glance.

However, the problem occurs when a user needs to enter his timesheets and can edit up to 5 different tasks that need to be added through the Add Time drop-down list.

User story:

As a user, I fill in my timesheet at the end of the week and it adds up to 34.5 hours

Then, two days later, I have to add the extra time for another job I worked on that I forgot. The total number of hours in the weeks is now 42 hours.

34.5 hours – Task 1

7.5 hours – task 2

However, I do not know to which project the total time was assigned.


What is the best way to distinguish this new information that has been added

  • New time added from different mappings
  • How to know at a glance which time has been assigned to which task

Hope that's clear ..