问:
SOLVED. Mock service.insert() works with ArgumentMatchers.any() only, triggers exception otherwise
Im creating a test class using Mockito and everything is runnig OK, except by one mock that calls a service layer method and it only works if the input parameter is any() and it throws the following exception if the input parameter is native from the method.

org.springframework.web.util.NestedServletException: Request processing failed; nested exception is java.lang.NullPointerException: Cannot invoke "com.devsuperior.dscatalog.dto.ProductDTO.getId()" because "productDTO" is null at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1014)

Lets go through the code:
The service layer method, productDTO is a DTO class from a ordinary Product entity.

    @Transactional
    public ProductDTO insert(ProductDTO productDTO) {
        Product entity = new Product();
        copyDtoToEntity(productDTO, entity);
        entity = repository.save(entity); // reposity.save() returns a reference to object saved in DB
        return new ProductDTO(entity);
    }
```
<p>the controller layer method:</p>
<pre class="lang-java prettyprint-override"><code>    @PostMapping
    public ResponseEntity<ProductDTO> insert(@RequestBody ProductDTO productDTO){
        productDTO = service.insert(productDTO); //[1]
        URI uri = ServletUriComponentsBuilder.fromCurrentRequest().path("/{id}")
                .buildAndExpand(productDTO.getId()).toUri();
        return ResponseEntity.created(uri).body(productDTO);

    }
</code>```

Before I continue I ran in debug mode this code and the ProdutDTO was correctly instanciated until the mock captured the service.insert(productDTO) call  and after this line [1] productDTO = null

my test class:

@WebMvcTest(ProductResource.class)
public class ProductResourceTests {

    @Autowired
    private MockMvc mockMvc;

    @MockBean
    private ProductService service;

    @Autowired
    private ObjectMapper objectMapper;

    private PageImpl<ProductDTO> page;
    private ProductDTO productDTO;
    private long existingId;
    private long nonExistingId;
    private long dependentId;
    private long productBadCategoryId;
    private String jsonBody;

    @BeforeEach
    void setUp() throws Exception {

        productDTO = Factory.createProductDTO();

        existingId = Factory.getExistingProductId();
        nonExistingId = 100L;
        dependentId = 50L;
        productBadCategoryId = 200L;

        page = new PageImpl<>(List.of(productDTO));

        when(service.findAllPaged(ArgumentMatchers.any())).thenReturn(page);

        when(service.findById(existingId)).thenReturn(productDTO);
        when(service.findById(nonExistingId)).thenThrow(ResourceNotFoundException.class);

        when(service.update(eq(existingId), any())).thenReturn(productDTO);

        when(service.update(eq(nonExistingId), any())).thenThrow(ResourceNotFoundException.class);
        when(service.update(eq(productBadCategoryId), any())).thenThrow(NestedResourceNotFoundException.class);

        doNothing().when(service).delete(existingId);
        doThrow(ResourceNotFoundException.class).when(service).delete(nonExistingId);
        doThrow(DatabaseException.class).when(service).delete(dependentId);

        when(service.insert(any(ProductDTO.class))).thenReturn(productDTO); // IT WORKS! [2]
        //when(service.insert( productDTO )).thenReturn(productDTO); // IT IT DOESNT WORKS!  [3]

        jsonBody = objectMapper.writeValueAsString(productDTO);

    }

```
<p>and finally the test method where the mock call triggers the exception</p>
```@Test
public void insertShouldReturnProductDTOCreated() throws Exception {

    ResultActions result = mockMvc.perform(post("/products").content(jsonBody)
            .contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON));

    result.andExpect(status().isCreated());
    result.andExpect(jsonPath("$.id").exists());
    result.andExpect(jsonPath("$.name").exists());
    result.andExpect(jsonPath("$.description").exists());
}
```

Whenever I uncomment line [3] and comment line [2] the exception above is rised.

Of course I could let this way (its working), but If I want to raise an exception for the case the object to be inserted has some issue,I could build a new service.insert() mock to test the throw of the exception. As it is I can´t because I cant diferentiate a any() object from another one.I have read some similar problems like mine and the proposed solution was to add @Autowired annotation with service variable, but in my case still the issue remains.

The solution and a tentative of explanation what was happening:

Override HashCode/Equals methods in ProducDTO class.

When serializing ProductDTO class (this line-> jsonBody = objectMapper.writeValueAsString(productDTO) ) and upon reception on resource layer it turns again into an object but its new reference  address it is not the same and for instance the non override equals will fail (it compares the reference address and not their content).

Body:
Im creating a test class using Mockito and everything is runnig OK, except by one mock that calls a service layer method and it only works if the input parameter is any() and it throws the following exception if the input parameter is native from the method.

org.springframework.web.util.NestedServletException: Request processing failed; nested exception is java.lang.NullPointerException: Cannot invoke "com.devsuperior.dscatalog.dto.ProductDTO.getId()" because "productDTO" is null at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1014)

Lets go through the code:
The service layer method, productDTO is a DTO class from a ordinary Product entity.

    @Transactional
    public ProductDTO insert(ProductDTO productDTO) {
        Product entity = new Product();
        copyDtoToEntity(productDTO, entity);
        entity = repository.save(entity); // reposity.save() returns a reference to object saved in DB
        return new ProductDTO(entity);
    }

the controller layer method:

    @PostMapping
    public ResponseEntity<ProductDTO> insert(@RequestBody ProductDTO productDTO){
        productDTO = service.insert(productDTO); //[1]
        URI uri = ServletUriComponentsBuilder.fromCurrentRequest().path("/{id}")
                .buildAndExpand(productDTO.getId()).toUri();
        return ResponseEntity.created(uri).body(productDTO);

    }

Before I continue I ran in debug mode this code and the ProdutDTO was correctly instanciated until the mock captured the service.insert(productDTO) call  and after this line [1] productDTO = null

my test class:

@WebMvcTest(ProductResource.class)
public class ProductResourceTests {

    @Autowired
    private MockMvc mockMvc;

    @MockBean
    private ProductService service;

    @Autowired
    private ObjectMapper objectMapper;

    private PageImpl<ProductDTO> page;
    private ProductDTO productDTO;
    private long existingId;
    private long nonExistingId;
    private long dependentId;
    private long productBadCategoryId;
    private String jsonBody;

    @BeforeEach
    void setUp() throws Exception {

        productDTO = Factory.createProductDTO();

        existingId = Factory.getExistingProductId();
        nonExistingId = 100L;
        dependentId = 50L;
        productBadCategoryId = 200L;

        page = new PageImpl<>(List.of(productDTO));

        when(service.findAllPaged(ArgumentMatchers.any())).thenReturn(page);

        when(service.findById(existingId)).thenReturn(productDTO);
        when(service.findById(nonExistingId)).thenThrow(ResourceNotFoundException.class);

        when(service.update(eq(existingId), any())).thenReturn(productDTO);

        when(service.update(eq(nonExistingId), any())).thenThrow(ResourceNotFoundException.class);
        when(service.update(eq(productBadCategoryId), any())).thenThrow(NestedResourceNotFoundException.class);

        doNothing().when(service).delete(existingId);
        doThrow(ResourceNotFoundException.class).when(service).delete(nonExistingId);
        doThrow(DatabaseException.class).when(service).delete(dependentId);

        when(service.insert(any(ProductDTO.class))).thenReturn(productDTO); // IT WORKS! [2]
        //when(service.insert( productDTO )).thenReturn(productDTO); // IT IT DOESNT WORKS!  [3]

        jsonBody = objectMapper.writeValueAsString(productDTO);

    }

and finally the test method where the mock call triggers the exception

@Test
public void insertShouldReturnProductDTOCreated() throws Exception {

    ResultActions result = mockMvc.perform(post("/products").content(jsonBody)
            .contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON));

    result.andExpect(status().isCreated());
    result.andExpect(jsonPath("$.id").exists());
    result.andExpect(jsonPath("$.name").exists());
    result.andExpect(jsonPath("$.description").exists());
}

Whenever I uncomment line [3] and comment line [2] the exception above is rised.

Of course I could let this way (its working), but If I want to raise an exception for the case the object to be inserted has some issue,I could build a new service.insert() mock to test the throw of the exception. As it is I can´t because I cant diferentiate a any() object from another one.I have read some similar problems like mine and the proposed solution was to add @Autowired annotation with service variable, but in my case still the issue remains.

The solution and a tentative of explanation what was happening:

Override HashCode/Equals methods in ProducDTO class.

When serializing ProductDTO class (this line-> jsonBody = objectMapper.writeValueAsString(productDTO) ) and upon reception on resource layer it turns again into an object but its new reference  address it is not the same and for instance the non override equals will fail (it compares the reference address and not their content).


来源: stackexchange

问:
Feeding user input into interactive command line using python script
I've no programming experience and I just started learning python so I will really appreciate any advice or help from the community. Thank you and much appreciated!

So, recently I came across a very interesting module "subprocess.popen" and I was wondering how to use it. Then, I have this whole idea of automating a command line using user input, but I'm not sure if I can do it using subprocess.popen.

Using "ls -la" as an example:

```<code>#Function to ask user to enter input

UserInput = input('Please Enter: ')

#Function to execute command line together with user input
command = ["ls ", UserInput]

import subprocess
subprocess.Popen(command, shell=True)
</code>```

How can I correct it so that it will execute "ls -la", assuming UserInput = -la?

ContentLicense: CC BY-SA 4.0

Body:
I've no programming experience and I just started learning python so I will really appreciate any advice or help from the community. Thank you and much appreciated!

So, recently I came across a very interesting module "subprocess.popen" and I was wondering how to use it. Then, I have this whole idea of automating a command line using user input, but I'm not sure if I can do it using subprocess.popen.

Using "ls -la" as an example:

#Function to ask user to enter input

UserInput = input('Please Enter: ')

#Function to execute command line together with user input
command = ["ls ", UserInput]

import subprocess
subprocess.Popen(command, shell=True)

How can I correct it so that it will execute "ls -la", assuming UserInput = -la?


问:
node-exporter is logging "collector failed" error
I have following docker-compose YAML file:

```<code>...

node-exporter:
    image: prom/node-exporter:latest
    container_name: node-exporter
    restart: unless-stopped
    volumes:
      - /proc:/host/proc:ro
      - /sys:/host/sys:ro
      - /:/rootfs:ro
    command:
      - '--path.procfs=/host/proc'
      - '--path.rootfs=/rootfs'
      - '--path.sysfs=/host/sys'
      - '--collector.filesystem.mount-points-exclude=^/(sys|proc|dev|host|etc)($$|/)'
    expose:
      - 9100
    networks:
      - monitoring

...
</code>```

when I run docker-compose up in the logs I am seeing the following:

```<code>ts=2022-12-09T03:42:29.448Z caller=tls_config.go:232 level=info msg="Listening on" address=[::]:9100
ts=2022-12-09T03:42:29.448Z caller=tls_config.go:235 level=info msg="TLS is disabled." http2=false address=[::]:9100
ts=2022-12-09T03:43:07.813Z caller=collector.go:169 level=error msg="collector failed" name=os duration_seconds=6.5056e-05 err="open /rootfs/etc/os-release: permission denied"
</code>```

Is there any config change I need to do in order to fix this error?

Body:
I have following docker-compose YAML file:

...

node-exporter:
    image: prom/node-exporter:latest
    container_name: node-exporter
    restart: unless-stopped
    volumes:
      - /proc:/host/proc:ro
      - /sys:/host/sys:ro
      - /:/rootfs:ro
    command:
      - '--path.procfs=/host/proc'
      - '--path.rootfs=/rootfs'
      - '--path.sysfs=/host/sys'
      - '--collector.filesystem.mount-points-exclude=^/(sys|proc|dev|host|etc)($$|/)'
    expose:
      - 9100
    networks:
      - monitoring

...

when I run docker-compose up in the logs I am seeing the following:

ts=2022-12-09T03:42:29.448Z caller=tls_config.go:232 level=info msg="Listening on" address=[::]:9100
ts=2022-12-09T03:42:29.448Z caller=tls_config.go:235 level=info msg="TLS is disabled." http2=false address=[::]:9100
ts=2022-12-09T03:43:07.813Z caller=collector.go:169 level=error msg="collector failed" name=os duration_seconds=6.5056e-05 err="open /rootfs/etc/os-release: permission denied"

Is there any config change I need to do in order to fix this error?


问:
How to create an abstract base class (generally a parent class) that requires its children to have a specific method which sets a specific property?
I want to define an abstract base class, called ParentClass. I want every child class of ParentClass to have a method called "fit" that defines a property "required". If someone tries to create a child class which does not have the "required" property within its fit method, I want an error to be created when the object's fit method is called. I am having trouble doing this.

The context is that I want to create a Parent class, abstract or otherwise, that requires its children to behave in a certain way and have certain properties so that I can trust them to behave in certain ways no matter who is creating children classes. I have found similar questions, but nothing precisely like what I am asking.

My naive attempt was something like the following:

```<code>class ParentClass(ABC):

    @abstractmethod
    def fit(self):
        self.required = True

class ChildClass(ParentClass):
    def __init__(self):
        pass

    def fit(self):
        self.required = True

class ChildClass2(ParentClass):
    def __init__(self):
        pass

    def fit(self):
        self.not_essential = True
</code>```

This doesn't work, but if possible I would like to refactor ParentClass in such a way that if someone runs:

```<code>>> b = ChildClass()
>> b.fit()
</code>```

everything works fine, but if someone tries to run

```<code>>> b2 = ChildClass2()
>> b2.fit()
</code>```

an error is thrown because the fit method of ChildClass2 doesn't define "required".

Is this possible in Python?

A related question is whether there is a better way to think about structuring my problem. Perhaps there is a better paradigm to achieve what I want? I understand that I can force child classes to have certain methods defined. A clunky way to achieve what I want is to have every property I want to be defined to be returned by a required method, but this feels very clunky, particularly if the number of properties I want to enforce as part of a standard becomes rather large.

Body:
I want to define an abstract base class, called ParentClass. I want every child class of ParentClass to have a method called "fit" that defines a property "required". If someone tries to create a child class which does not have the "required" property within its fit method, I want an error to be created when the object's fit method is called. I am having trouble doing this.

The context is that I want to create a Parent class, abstract or otherwise, that requires its children to behave in a certain way and have certain properties so that I can trust them to behave in certain ways no matter who is creating children classes. I have found similar questions, but nothing precisely like what I am asking.

My naive attempt was something like the following:

class ParentClass(ABC):

    @abstractmethod
    def fit(self):
        self.required = True

class ChildClass(ParentClass):
    def __init__(self):
        pass

    def fit(self):
        self.required = True

class ChildClass2(ParentClass):
    def __init__(self):
        pass

    def fit(self):
        self.not_essential = True

This doesn't work, but if possible I would like to refactor ParentClass in such a way that if someone runs:

>> b = ChildClass()
>> b.fit()

everything works fine, but if someone tries to run

>> b2 = ChildClass2()
>> b2.fit()

an error is thrown because the fit method of ChildClass2 doesn't define "required".

Is this possible in Python?

A related question is whether there is a better way to think about structuring my problem. Perhaps there is a better paradigm to achieve what I want? I understand that I can force child classes to have certain methods defined. A clunky way to achieve what I want is to have every property I want to be defined to be returned by a required method, but this feels very clunky, particularly if the number of properties I want to enforce as part of a standard becomes rather large.


问:
Vaadin throws an exception while refreshing the page
I am running tests for my Vaadin application and getting the following exception while clicking on the reload page button on the Chrome.

2022-12-08 19:50:52.543 ERROR 26592 --- [nio-8080-exec-1] c.v.flow.router.InternalServerError      : There was an exception
while trying to navigate to ''

java.lang.IllegalStateException: Can't move a node from one state tree
to another. If this is intentional, first remove the node from its
current state tree by calling removeFromTree  at
com.vaadin.flow.internal.StateNode.doSetTree(StateNode.java:739)
~[flow-server-23.2.7.jar:23.2.7]  at
com.vaadin.flow.internal.StateNode.lambda$setTree$3(StateNode.java:380)
~[flow-server-23.2.7.jar:23.2.7]  at
com.vaadin.flow.internal.StateNode.visitNodeTree(StateNode.java:688)
~[flow-server-23.2.7.jar:23.2.7]  at
com.vaadin.flow.internal.StateNode.setTree(StateNode.java:380)
~[flow-server-23.2.7.jar:23.2.7]  at
com.vaadin.flow.internal.StateNode.setParent(StateNode.java:274)
~[flow-server-23.2.7.jar:23.2.7]  at
com.vaadin.flow.internal.nodefeature.NodeFeature.attachPotentialChild(NodeFeature.java:80)
~[flow-server-23.2.7.jar:23.2.7]  at
com.vaadin.flow.internal.nodefeature.StateNodeNodeList.add(StateNodeNodeList.java:55)
~[flow-server-23.2.7.jar:23.2.7]  at
com.vaadin.flow.internal.nodefeature.ElementChildrenList.add(ElementChildrenList.java:44)
~[flow-server-23.2.7.jar:23.2.7]  at
com.vaadin.flow.dom.impl.AbstractNodeStateProvider.insertChild(AbstractNodeStateProvider.java:104)
~[flow-server-23.2.7.jar:23.2.7]  at
com.vaadin.flow.dom.Node.insertChild(Node.java:386)
~[flow-server-23.2.7.jar:23.2.7]  at
com.vaadin.flow.dom.Node.appendChild(Node.java:163)
~[flow-server-23.2.7.jar:23.2.7]  at
com.vaadin.flow.dom.Node.appendChild(Node.java:147)
~[flow-server-23.2.7.jar:23.2.7]  at
com.vaadin.flow.component.internal.JavaScriptBootstrapUI$JavaScriptUIInternalUpdater.updateRoot(JavaScriptBootstrapUI.java:422)
~[flow-server-23.2.7.jar:23.2.7]  at
com.vaadin.flow.component.internal.UIInternals.showRouteTarget(UIInternals.java:764)
~[flow-server-23.2.7.jar:23.2.7]  at
com.vaadin.flow.router.internal.AbstractNavigationStateRenderer.handle(AbstractNavigationStateRenderer.java:222)
~[flow-server-23.2.7.jar:23.2.7]  at
com.vaadin.flow.component.internal.JavaScriptNavigationStateRenderer.handle(JavaScriptNavigationStateRenderer.java:78)
~[flow-server-23.2.7.jar:23.2.7]  at
com.vaadin.flow.component.internal.JavaScriptBootstrapUI.handleNavigation(JavaScriptBootstrapUI.java:317)
~[flow-server-23.2.7.jar:23.2.7]  at
com.vaadin.flow.component.internal.JavaScriptBootstrapUI.renderViewForRoute(JavaScriptBootstrapUI.java:280)
~[flow-server-23.2.7.jar:23.2.7]  at
com.vaadin.flow.component.internal.JavaScriptBootstrapUI.connectClient(JavaScriptBootstrapUI.java:147)
~[flow-server-23.2.7.jar:23.2.7]  at
java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native
Method) ~[na:na]  at
java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
~[na:na]  at
java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
~[na:na]  at
java.base/java.lang.reflect.Method.invoke(Method.java:564) ~[na:na]
at
com.vaadin.flow.server.communication.rpc.PublishedServerEventHandlerRpcHandler.invokeMethod(PublishedServerEventHandlerRpcHandler.java:222)
~[flow-server-23.2.7.jar:23.2.7]  at
com.vaadin.flow.server.communication.rpc.PublishedServerEventHandlerRpcHandler.invokeMethod(PublishedServerEventHandlerRpcHandler.java:199)
~[flow-server-23.2.7.jar:23.2.7]  at
com.vaadin.flow.server.communication.rpc.PublishedServerEventHandlerRpcHandler.invokeMethod(PublishedServerEventHandlerRpcHandler.java:149)
~[flow-server-23.2.7.jar:23.2.7]  at
com.vaadin.flow.server.communication.rpc.PublishedServerEventHandlerRpcHandler.handleNode(PublishedServerEventHandlerRpcHandler.java:132)
~[flow-server-23.2.7.jar:23.2.7]  at
com.vaadin.flow.server.communication.rpc.AbstractRpcInvocationHandler.handle(AbstractRpcInvocationHandler.java:75)
~[flow-server-23.2.7.jar:23.2.7]  at
com.vaadin.flow.server.communication.ServerRpcHandler.handleInvocationData(ServerRpcHandler.java:438)
~[flow-server-23.2.7.jar:23.2.7]  at
com.vaadin.flow.server.communication.ServerRpcHandler.lambda$handleInvocations$1(ServerRpcHandler.java:419)
~[flow-server-23.2.7.jar:23.2.7]  at
java.base/java.util.ArrayList.forEach(ArrayList.java:1511) ~[na:na]
at
com.vaadin.flow.server.communication.ServerRpcHandler.handleInvocations(ServerRpcHandler.java:419)
~[flow-server-23.2.7.jar:23.2.7]  at
com.vaadin.flow.server.communication.ServerRpcHandler.handleRpc(ServerRpcHandler.java:320)
~[flow-server-23.2.7.jar:23.2.7]  at
com.vaadin.flow.server.communication.UidlRequestHandler.synchronizedHandleRequest(UidlRequestHandler.java:115)
~[flow-server-23.2.7.jar:23.2.7]  at
com.vaadin.flow.server.SynchronizedRequestHandler.handleRequest(SynchronizedRequestHandler.java:40)
~[flow-server-23.2.7.jar:23.2.7]  at
com.vaadin.flow.server.VaadinService.handleRequest(VaadinService.java:1564)
~[flow-server-23.2.7.jar:23.2.7]  at
com.vaadin.flow.server.VaadinServlet.service(VaadinServlet.java:369)
~[flow-server-23.2.7.jar:23.2.7]  at
com.vaadin.flow.spring.SpringServlet.service(SpringServlet.java:106)
~[vaadin-spring-23.2.7.jar:na]    at
javax.servlet.http.HttpServlet.service(HttpServlet.java:764)
~[tomcat-embed-core-9.0.65.jar:4.0.FR]    at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:227)
~[tomcat-embed-core-9.0.65.jar:9.0.65]    at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
~[tomcat-embed-core-9.0.65.jar:9.0.65]    at
org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:711)
~[tomcat-embed-core-9.0.65.jar:9.0.65]    at
org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:459)
~[tomcat-embed-core-9.0.65.jar:9.0.65]    at
org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:353)
~[tomcat-embed-core-9.0.65.jar:9.0.65]    at
org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:313)
~[tomcat-embed-core-9.0.65.jar:9.0.65]    at
org.springframework.web.servlet.mvc.ServletForwardingController.handleRequestInternal(ServletForwardingController.java:141)
~[spring-webmvc-5.3.23.jar:5.3.23]    at
org.springframework.web.servlet.mvc.AbstractController.handleRequest(AbstractController.java:177)
~[spring-webmvc-5.3.23.jar:5.3.23]    at
org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:51)
~[spring-webmvc-5.3.23.jar:5.3.23]    at
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1071)
~[spring-webmvc-5.3.23.jar:5.3.23]    at
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:964)
~[spring-webmvc-5.3.23.jar:5.3.23]    at
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006)
~[spring-webmvc-5.3.23.jar:5.3.23]    at
org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:909)
~[spring-webmvc-5.3.23.jar:5.3.23]    at
javax.servlet.http.HttpServlet.service(HttpServlet.java:681)
~[tomcat-embed-core-9.0.65.jar:4.0.FR]    at
org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883)
~[spring-webmvc-5.3.23.jar:5.3.23]    at
javax.servlet.http.HttpServlet.service(HttpServlet.java:764)
~[tomcat-embed-core-9.0.65.jar:4.0.FR]    at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:227)
~[tomcat-embed-core-9.0.65.jar:9.0.65]    at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
~[tomcat-embed-core-9.0.65.jar:9.0.65]    at
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
~[tomcat-embed-websocket-9.0.65.jar:9.0.65]   at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
~[tomcat-embed-core-9.0.65.jar:9.0.65]    at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
~[tomcat-embed-core-9.0.65.jar:9.0.65]    at
org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100)
~[spring-web-5.3.23.jar:5.3.23]   at
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)
~[spring-web-5.3.23.jar:5.3.23]   at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
~[tomcat-embed-core-9.0.65.jar:9.0.65]    at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
~[tomcat-embed-core-9.0.65.jar:9.0.65]    at
org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93)
~[spring-web-5.3.23.jar:5.3.23]   at
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)
~[spring-web-5.3.23.jar:5.3.23]   at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
~[tomcat-embed-core-9.0.65.jar:9.0.65]    at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
~[tomcat-embed-core-9.0.65.jar:9.0.65]    at
org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201)
~[spring-web-5.3.23.jar:5.3.23]   at
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)
~[spring-web-5.3.23.jar:5.3.23]   at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
~[tomcat-embed-core-9.0.65.jar:9.0.65]    at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
~[tomcat-embed-core-9.0.65.jar:9.0.65]    at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:197)
~[tomcat-embed-core-9.0.65.jar:9.0.65]    at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97)
~[tomcat-embed-core-9.0.65.jar:9.0.65]    at
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:541)
~[tomcat-embed-core-9.0.65.jar:9.0.65]    at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:135)
~[tomcat-embed-core-9.0.65.jar:9.0.65]    at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
~[tomcat-embed-core-9.0.65.jar:9.0.65]    at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78)
~[tomcat-embed-core-9.0.65.jar:9.0.65]    at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:360)
~[tomcat-embed-core-9.0.65.jar:9.0.65]    at
org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:399)
~[tomcat-embed-core-9.0.65.jar:9.0.65]    at
org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
~[tomcat-embed-core-9.0.65.jar:9.0.65]    at
org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:890)
~[tomcat-embed-core-9.0.65.jar:9.0.65]    at
org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1789)
~[tomcat-embed-core-9.0.65.jar:9.0.65]    at
org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
~[tomcat-embed-core-9.0.65.jar:9.0.65]    at
org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191)
~[tomcat-embed-core-9.0.65.jar:9.0.65]    at
org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)
~[tomcat-embed-core-9.0.65.jar:9.0.65]    at
org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
~[tomcat-embed-core-9.0.65.jar:9.0.65]    at
java.base/java.lang.Thread.run(Thread.java:832) ~[na:na]

I don't understand what does it mean and how to avoid it. If I restart application it does display what it suppose to do. It is not happening every time, but quite often.
What can I do to get rid of it?


问:
Java external package not founded by using php to run the java program
This is my first web application project and I was required to run the java code using php but this error occurs.

```<code>src\Convertion.java:12: error: package org.apache.poi.examples.ss does not exist
import org.apache.poi.examples.ss.ToCSV;
</code>```

I have included all the jar files needed to run the program also the classpath is already set in the system variable but the error is display i haven't included the org.apache.poi.examples.ss package.

So here is my code for my php and java

test.php

```<code><?php
    exec('javac -cp "poi-bin-5.2.3/poi-5.2.3.jar; poi-bin-5.2.3/poi-examples-5.2.3.jar; poi-bin-5.2.3/lib/commons-io-2.11.0.jar; poi-bin-5.2.3/lib/log4j-api-2.18.0.jar; " src/Convertion.java', $output);
    exec('java -cp "poi-bin-5.2.3/poi-5.2.3.jar; poi-bin-5.2.3/poi-examples-5.2.3.jar; poi-bin-5.2.3/lib/commons-io-2.11.0.jar; poi-bin-5.2.3/lib/log4j-api-2.18.0.jar; " src/Convertion.java', $output);
?>

</code>```

Convertion.java

```<code>package src;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.util.ArrayList;

//Error here
import org.apache.poi.examples.ss.ToCSV;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellType;
import org.apache.poi.ss.usermodel.DataFormatter;
import org.apache.poi.ss.usermodel.FormulaEvaluator;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.usermodel.WorkbookFactory;
//

public class Convertion {
///code//
}

</code>```

I go through all the articles but still unable to solve the error

Any idea what is wrong with my code?

Body:
This is my first web application project and I was required to run the java code using php but this error occurs.

src\Convertion.java:12: error: package org.apache.poi.examples.ss does not exist
import org.apache.poi.examples.ss.ToCSV;

I have included all the jar files needed to run the program also the classpath is already set in the system variable but the error is display i haven't included the org.apache.poi.examples.ss package.

So here is my code for my php and java

test.php

<?php
    exec('javac -cp "poi-bin-5.2.3/poi-5.2.3.jar; poi-bin-5.2.3/poi-examples-5.2.3.jar; poi-bin-5.2.3/lib/commons-io-2.11.0.jar; poi-bin-5.2.3/lib/log4j-api-2.18.0.jar; " src/Convertion.java', $output);
    exec('java -cp "poi-bin-5.2.3/poi-5.2.3.jar; poi-bin-5.2.3/poi-examples-5.2.3.jar; poi-bin-5.2.3/lib/commons-io-2.11.0.jar; poi-bin-5.2.3/lib/log4j-api-2.18.0.jar; " src/Convertion.java', $output);
?>

Convertion.java

package src;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.util.ArrayList;

//Error here
import org.apache.poi.examples.ss.ToCSV;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellType;
import org.apache.poi.ss.usermodel.DataFormatter;
import org.apache.poi.ss.usermodel.FormulaEvaluator;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.usermodel.WorkbookFactory;
//

public class Convertion {
///code//
}

I go through all the articles but still unable to solve the error

Any idea what is wrong with my code?


问:
Monitoring PUB/SUB pattren in ZeroMQ in python
I am using a PUB/SUB patteren.
I need to monitor this.

I got following code for monitor REP/REP patteren, I want something like this for PUB/SUB..
when I am changing PUB/SUB in this but then this code is not working.
Please let me know if how monitoring is possible for PUB/SUB

```<code>import time
import zmq
from zmq.devices.basedevice import ProcessDevice
from zmq.devices.monitoredqueuedevice import MonitoredQueue
from zmq.utils.strtypes import asbytes
from multiprocessing import Process
import random

frontend_port = 8888
backend_port = 8882
monitor_port = 5562
number_of_workers = 2

def monitordevice():
    in_prefix=asbytes('in')
    out_prefix=asbytes('out')
    monitoringdevice = MonitoredQueue(zmq.XREP, zmq.XREQ, zmq.PUB, in_prefix, out_prefix)

    monitoringdevice.bind_in("tcp://127.0.0.1:%d" % frontend_port)
    monitoringdevice.bind_out("tcp://127.0.0.1:%d" % backend_port)
    monitoringdevice.bind_mon("tcp://127.0.0.1:%d" % monitor_port)

    monitoringdevice.setsockopt_in(zmq.SNDHWM, 1)
    monitoringdevice.setsockopt_out(zmq.SNDHWM, 1)
    monitoringdevice.start()
    print("Program: Monitoring device has started")

def server(backend_port):
    print("Program: Server connecting to device")
    context = zmq.Context()
    socket = context.socket(zmq.PUB)
    socket.bind("tcp://127.0.0.1:%s" % backend_port)
    server_id = random.randrange(1,10005)
    while True:
        message = socket.recv()
        print("Server: Received - %s" % message)
        socket.send_string("Response from server #%s" % server_id)

def client(frontend_port, client_id):
    print("Program: Worker #%s connecting to device" % client_id)
    context = zmq.Context()
    socket = context.socket(zmq.REQ)
    socket.connect("tcp://127.0.0.1:%s" % frontend_port)
    request_num = 1
    socket.send_string("Request #%s from client#%s" % (request_num, client_id))
    message = socket.recv_multipart()
    print("Client: Received - %s" % message)

def monitor():
    print("Starting monitoring process")
    context = zmq.Context()
    socket = context.socket(zmq.SUB)
    print("Collecting updates from server...")
    socket.connect ("tcp://127.0.0.1:%s" % monitor_port)
    socket.setsockopt_string(zmq.SUBSCRIBE, "")
    while True:
        string = socket.recv_multipart()
        print("Monitoring Client: %s" % string)

if __name__ == "__main__":
    monitoring_p = Process(target=monitordevice)
    monitoring_p.start()
    server_p = Process(target=server, args=(backend_port,))
    server_p.start()
    monitorclient_p = Process(target=monitor)
    monitorclient_p.start()
    time.sleep(2)

    for client_id in range(number_of_workers):
        Process(target=client, args=(frontend_port, client_id,)).start()

    time.sleep(10)
    server_p.terminate()
    monitorclient_p.terminate()
    monitoring_p.terminate()
</code>```

when I am changing PUB/SUB in above code then this code is not working.
Please let me know if how monitoring is possible for PUB/SUB

Body:
I am using a PUB/SUB patteren.
I need to monitor this.

I got following code for monitor REP/REP patteren, I want something like this for PUB/SUB..
when I am changing PUB/SUB in this but then this code is not working.
Please let me know if how monitoring is possible for PUB/SUB

import time
import zmq
from zmq.devices.basedevice import ProcessDevice
from zmq.devices.monitoredqueuedevice import MonitoredQueue
from zmq.utils.strtypes import asbytes
from multiprocessing import Process
import random

frontend_port = 8888
backend_port = 8882
monitor_port = 5562
number_of_workers = 2

def monitordevice():
    in_prefix=asbytes('in')
    out_prefix=asbytes('out')
    monitoringdevice = MonitoredQueue(zmq.XREP, zmq.XREQ, zmq.PUB, in_prefix, out_prefix)

    monitoringdevice.bind_in("tcp://127.0.0.1:%d" % frontend_port)
    monitoringdevice.bind_out("tcp://127.0.0.1:%d" % backend_port)
    monitoringdevice.bind_mon("tcp://127.0.0.1:%d" % monitor_port)

    monitoringdevice.setsockopt_in(zmq.SNDHWM, 1)
    monitoringdevice.setsockopt_out(zmq.SNDHWM, 1)
    monitoringdevice.start()
    print("Program: Monitoring device has started")

def server(backend_port):
    print("Program: Server connecting to device")
    context = zmq.Context()
    socket = context.socket(zmq.PUB)
    socket.bind("tcp://127.0.0.1:%s" % backend_port)
    server_id = random.randrange(1,10005)
    while True:
        message = socket.recv()
        print("Server: Received - %s" % message)
        socket.send_string("Response from server #%s" % server_id)

def client(frontend_port, client_id):
    print("Program: Worker #%s connecting to device" % client_id)
    context = zmq.Context()
    socket = context.socket(zmq.REQ)
    socket.connect("tcp://127.0.0.1:%s" % frontend_port)
    request_num = 1
    socket.send_string("Request #%s from client#%s" % (request_num, client_id))
    message = socket.recv_multipart()
    print("Client: Received - %s" % message)

def monitor():
    print("Starting monitoring process")
    context = zmq.Context()
    socket = context.socket(zmq.SUB)
    print("Collecting updates from server...")
    socket.connect ("tcp://127.0.0.1:%s" % monitor_port)
    socket.setsockopt_string(zmq.SUBSCRIBE, "")
    while True:
        string = socket.recv_multipart()
        print("Monitoring Client: %s" % string)

if __name__ == "__main__":
    monitoring_p = Process(target=monitordevice)
    monitoring_p.start()
    server_p = Process(target=server, args=(backend_port,))
    server_p.start()
    monitorclient_p = Process(target=monitor)
    monitorclient_p.start()
    time.sleep(2)

    for client_id in range(number_of_workers):
        Process(target=client, args=(frontend_port, client_id,)).start()

    time.sleep(10)
    server_p.terminate()
    monitorclient_p.terminate()
    monitoring_p.terminate()

when I am changing PUB/SUB in above code then this code is not working.
Please let me know if how monitoring is possible for PUB/SUB


问:
Can I listen to a Bluetooth data receipt on a broadcast receiver on android and if I can, how?
I'm trying to build a Bluetooth emergency beacon(a MCU hooked up to a Bluetooth module),which after I press a button sends some data to my android app on my phone. I want to listen to this data reception (even when the app is not in the foreground) and then do something in my app, like call 911. So what's the way to do that, if there's any.</p>


问:
why laravel model property return 0 value during insert
database oracle.
column name travel_id. first it was number datatype and primary key. after some change datatype was changed to varchar but in laravel when we assign varchar value it shows invalid number during insert operation.</p>
```<code>$travel = new TravelModal();

$travel->travel_id = 'ABCD123';

dd($travel->toArray());
**
[
  'travel_id' => 0
]
**
</code>```

Body:
database oracle.
column name travel_id. first it was number datatype and primary key. after some change datatype was changed to varchar but in laravel when we assign varchar value it shows invalid number during insert operation.

$travel = new TravelModal();

$travel->travel_id = 'ABCD123';

dd($travel->toArray());
**
[
  'travel_id' => 0
]
**


问:
Is there a global variable that is set when Playwright is running tests?
I want to be able to branch my code when Playwright is running tests. Is there a variable that is available? I have tried playwright.

(the reason I want to branch my code is because urql cache exchange doesn't play nicely with Playwright)


问:
Editable package not able to be imported by pylint
I have added two editable git repo in Pipfile and when I install the package by pipenv so one git repo is added to sys.path but not another one. I can see the folder is present in <pipenv -venv>/src but not in sys.path but I am able to use those classes in the main project but pylint is not able to import.

init.py empty file are added to folder
************* Module jenkins_manager.jenkins_controller jenkins_manager/jenkins_controller.py:22:0: E0401: Unable to import 'eks_manager.eks_config' (import-error) jenkins_manager/jenkins_controller.py:23:0: E0401: Unable to import 'eks_manager.eks_secret' (import-error)


问:
Correct way to use Go Pprof to compare execution-time differences in two versions of a same functionality
I am running a Golang project in a container environment which has two pods.

Pod1: user-interaction and data-access layer.

Pod2: Database server.

The data-access layer involves functions like data validation, do get on db to check if data already exist, insert data, and many more data manipulation tasks...

I have two versions of the project with two differnt databases. (Database APIs in data-access layers are abstracted so that I can replace the redis with postgres or any other databases.)

Redis db (data access layer implemented with redis package).

Postgresql db (data access layer implemented with pgx package).

Now to compare the two versions I ran a command at pod1 to create 100000 records in each, and observed huge difference in command execution time.

Redis: 2m30s

Postgres: 9m20s

I need to debug which part of the code is taking more time, so what is the correct way to use Pprof tool? (should I run pprof for entire time of the command execution and compare? or should I run both for a minute and compare?, which pprof profiling should I use?).

Thanks


问:
Filtering Tigris primary_roads to only lower 48
I am pretty new to coding and r, and I am working on a modeling project using the Tigris package in r and ggplot2 for visualization. I am trying to construct a primary roads data frame but only using the data for the lower 48 states. In Tigris, primary_roads does not seem to include an argument for states and therein lies my problem. I've managed to painstakingly filter out MOST of the data for Alaska, Hawaii, and Puerto Rico by filtering within the FULLNAME column of primary_roads, but that has involved looking up the local names for highways in those locations on various web sources and manually removing them with a filtering code, but I can't seem to get all of them. I will include the code which I've come up with as well as the ggplot output that has the problem areas circled. Any tips are greatly appreciated. This is sort of just a fun side project that spawned from a class assignment that I enjoyed, so there isn't really a timeline on this, and I'm open to suggestions. I was thinking maybe there is a filter someone has come up with? Or maybe something I can use in ggplot to filter out the geometry in the primary_roads table? Or is there something similar to ArcGIS clip function in ggplot2 that I could use to filter other data from the Tigris package to the boundaries of the lower 48 geometry I create in the code? Thanks in advance and I look forward to working with any help and anyone willing to help me with this.

```<code>library(tidyverse)
library(ggplot2)
library(tigris)
library(dplyr)

#combining tigris and dplyr packages to create a geometry
st <- tigris::states() %>%
  dplyr::filter(GEOID < "60") %>% #GEOID's above 60 are territories and islands, etc. So I'm removing them for scaling.
  tigris::shift_geometry()

#removing Alaska and Hawaii from the geometry
lower_48 <- st %>% filter(!NAME %in% c("Alaska", "Hawaii"))

transp <- primary_roads()%>% filter(!FULLNAME %in% c("I- H-201","I- H-1","I- H-3","I- H2","I- H-2","Alaska Fwy","Alaskan Way Viaduct","Minnesota Dr", "Pr- 1","Pr- 10","Pr- 165","Pr- 17","Pr- 18","Pr- 181","Pr- 2","Pr- 20","Pr- 22","Pr- 24","Pr- 26","Pr- 3","Pr- 30","Pr- 52","Pr- 53","Pr- 60","Pr- 66","Pr- 165","Pr-66","
Pr-165","Pr-165","Carr 5","Pr-165","Pr-165","Carr 5","Carr Militar","Ave Central","Expreso Baldorioty de Castro","Expreso Luis Munoz Rivera","Expreso Las Americas","Expreso Loiza","
                                                     + Expreso Rafael Martinez Nadal","Expreso Jose de Diego","Expreso Cruz Ortiz Stella","Expreso Jose C Barbosa","Expreso Jose Celso Barbosa","Expreso Roman Baldorioty de Castro","Expreso Cruz Ortíz Stella","Expreso el Caño","
                                                     + Expreso Río Hondo","Autopista Luis A Ferre","Autopista Luis A Ferré","Kamehameha Hwy","Kalanianaole Hwy","W Moanalua Fwy","Moanalua Fwy","
                                                     + Lunalilo Fwy","Ave John F Kennedy","W H1 Fwy","
                                                     + S H2 Fwy","W H3 Fwy","S H2 Fwy","Lunalilo Fwy","Expreso Rafael Martinez Nadal","Expreso Río Hondo","E Parks Hwy","George Parks Hwy","New Seward Hwy","New Seward Hwy","Seward Hwy","Glenn Hwy"))
</code>```

I have attached the image of the ggplot output I made using these. The red lines are the primary_roads data. Ignore the purple gradient and green areas, as those are other parameters I've already completed the code for. The plot output is almost where I want it to be doing it the long, hard way, but there has to be a better way! Thanks everyone. It's a fun project but I'm sort of stuck on this step.

I am hoping to have the output only include data for the lower 48 US states. Hopefully someone more experienced with Tigris and/or ggplot2 might have some ideas about it?

Body:
I am pretty new to coding and r, and I am working on a modeling project using the Tigris package in r and ggplot2 for visualization. I am trying to construct a primary roads data frame but only using the data for the lower 48 states. In Tigris, primary_roads does not seem to include an argument for states and therein lies my problem. I've managed to painstakingly filter out MOST of the data for Alaska, Hawaii, and Puerto Rico by filtering within the FULLNAME column of primary_roads, but that has involved looking up the local names for highways in those locations on various web sources and manually removing them with a filtering code, but I can't seem to get all of them. I will include the code which I've come up with as well as the ggplot output that has the problem areas circled. Any tips are greatly appreciated. This is sort of just a fun side project that spawned from a class assignment that I enjoyed, so there isn't really a timeline on this, and I'm open to suggestions. I was thinking maybe there is a filter someone has come up with? Or maybe something I can use in ggplot to filter out the geometry in the primary_roads table? Or is there something similar to ArcGIS clip function in ggplot2 that I could use to filter other data from the Tigris package to the boundaries of the lower 48 geometry I create in the code? Thanks in advance and I look forward to working with any help and anyone willing to help me with this.

library(tidyverse)
library(ggplot2)
library(tigris)
library(dplyr)

#combining tigris and dplyr packages to create a geometry
st <- tigris::states() %>%
  dplyr::filter(GEOID < "60") %>% #GEOID's above 60 are territories and islands, etc. So I'm removing them for scaling.
  tigris::shift_geometry()

#removing Alaska and Hawaii from the geometry
lower_48 <- st %>% filter(!NAME %in% c("Alaska", "Hawaii"))

transp <- primary_roads()%>% filter(!FULLNAME %in% c("I- H-201","I- H-1","I- H-3","I- H2","I- H-2","Alaska Fwy","Alaskan Way Viaduct","Minnesota Dr", "Pr- 1","Pr- 10","Pr- 165","Pr- 17","Pr- 18","Pr- 181","Pr- 2","Pr- 20","Pr- 22","Pr- 24","Pr- 26","Pr- 3","Pr- 30","Pr- 52","Pr- 53","Pr- 60","Pr- 66","Pr- 165","Pr-66","
Pr-165","Pr-165","Carr 5","Pr-165","Pr-165","Carr 5","Carr Militar","Ave Central","Expreso Baldorioty de Castro","Expreso Luis Munoz Rivera","Expreso Las Americas","Expreso Loiza","
                                                     + Expreso Rafael Martinez Nadal","Expreso Jose de Diego","Expreso Cruz Ortiz Stella","Expreso Jose C Barbosa","Expreso Jose Celso Barbosa","Expreso Roman Baldorioty de Castro","Expreso Cruz Ortíz Stella","Expreso el Caño","
                                                     + Expreso Río Hondo","Autopista Luis A Ferre","Autopista Luis A Ferré","Kamehameha Hwy","Kalanianaole Hwy","W Moanalua Fwy","Moanalua Fwy","
                                                     + Lunalilo Fwy","Ave John F Kennedy","W H1 Fwy","
                                                     + S H2 Fwy","W H3 Fwy","S H2 Fwy","Lunalilo Fwy","Expreso Rafael Martinez Nadal","Expreso Río Hondo","E Parks Hwy","George Parks Hwy","New Seward Hwy","New Seward Hwy","Seward Hwy","Glenn Hwy"))

I have attached the image of the ggplot output I made using these. The red lines are the primary_roads data. Ignore the purple gradient and green areas, as those are other parameters I've already completed the code for. The plot output is almost where I want it to be doing it the long, hard way, but there has to be a better way! Thanks everyone. It's a fun project but I'm sort of stuck on this step.

I am hoping to have the output only include data for the lower 48 US states. Hopefully someone more experienced with Tigris and/or ggplot2 might have some ideas about it?


问:
SocketException: Connection failed (OS Error: Network is unreachable, errno = 101)
I'm using Flutter, and having this problem when I run the code using emulator. Before this, It can be run without any error tho.. This is what it says in the console..

```<code>I/flutter ( 9907): 3-2022-12-09 04:23:16.804353 -- MqttConnectionKeepAlive::pingRequired
    I/flutter ( 9907): 3-2022-12-09 04:23:16.866248 -- MqttConnectionKeepAlive::pingRequired - NOT sending ping - not connected
    I/flutter ( 9907): 3-2022-12-09 04:23:16.866614 -- MqttConnectionKeepAlive::pingRequired - restarting ping timer
</code>```

I did have function for callback ping here

```<code>MqttServerClient client =
    MqttServerClient(MqttConstants.broker, MqttConstants.clientId);

Future<Stream<List<MqttReceivedMessage<MqttMessage>>>?> mqttSubscribe(
    {required String topic}) async {
  // init client
  client = MqttServerClient(MqttConstants.broker, MqttConstants.clientId);
  client.port = MqttConstants.port;
  client.autoReconnect = true;
  client.logging(on: true);
  client.keepAlivePeriod = 60;
  client.pongCallback = pong;
  client.onDisconnected = onDisconnected;

  final connMess = MqttConnectMessage()
      .authenticateAs(MqttConstants.username, MqttConstants.password)
      .withClientIdentifier(MqttConstants.clientId)
      .withWillQos(MqttQos.atLeastOnce)
      .startClean(); // Non persistent session for testing
  print('EXAMPLE::Mqtt client connecting....');
  client.connectionMessage = connMess;

  // Connect to mqtt broker
  try {
    await client.connect();
    // if connected, subscribe to a topic
    if (client.connectionStatus?.state == MqttConnectionState.connected) {
      // subscribe to topic
      client.subscribe(topic, MqttQos.atMostOnce);
      return client.updates;
    } else {
      return null;
    }
  } on NoConnectionException catch (e) {
    log(e.toString());
  }
}

void pong() {
  print('ping response arrived');
}

void onDisconnected() {
  print('disconnected');
}
</code>```

What's the problem? I'm confuse since before this, it can be run smoothly..

Body:
I'm using Flutter, and having this problem when I run the code using emulator. Before this, It can be run without any error tho.. This is what it says in the console..

I/flutter ( 9907): 3-2022-12-09 04:23:16.804353 -- MqttConnectionKeepAlive::pingRequired
    I/flutter ( 9907): 3-2022-12-09 04:23:16.866248 -- MqttConnectionKeepAlive::pingRequired - NOT sending ping - not connected
    I/flutter ( 9907): 3-2022-12-09 04:23:16.866614 -- MqttConnectionKeepAlive::pingRequired - restarting ping timer

I did have function for callback ping here

MqttServerClient client =
    MqttServerClient(MqttConstants.broker, MqttConstants.clientId);

Future<Stream<List<MqttReceivedMessage<MqttMessage>>>?> mqttSubscribe(
    {required String topic}) async {
  // init client
  client = MqttServerClient(MqttConstants.broker, MqttConstants.clientId);
  client.port = MqttConstants.port;
  client.autoReconnect = true;
  client.logging(on: true);
  client.keepAlivePeriod = 60;
  client.pongCallback = pong;
  client.onDisconnected = onDisconnected;

  final connMess = MqttConnectMessage()
      .authenticateAs(MqttConstants.username, MqttConstants.password)
      .withClientIdentifier(MqttConstants.clientId)
      .withWillQos(MqttQos.atLeastOnce)
      .startClean(); // Non persistent session for testing
  print('EXAMPLE::Mqtt client connecting....');
  client.connectionMessage = connMess;

  // Connect to mqtt broker
  try {
    await client.connect();
    // if connected, subscribe to a topic
    if (client.connectionStatus?.state == MqttConnectionState.connected) {
      // subscribe to topic
      client.subscribe(topic, MqttQos.atMostOnce);
      return client.updates;
    } else {
      return null;
    }
  } on NoConnectionException catch (e) {
    log(e.toString());
  }
}

void pong() {
  print('ping response arrived');
}

void onDisconnected() {
  print('disconnected');
}

What's the problem? I'm confuse since before this, it can be run smoothly..


问:
How to convert gini score summary into a dataframe with the column of score's name?
I use the code got a gini score,

```<code>df.rf <- randomForest(agree_prep ~ ., data =fdat, ntree = 200, importance = TRUE)
</code>```

since I only need its score, I subset the result like this:

```<code>df.gini<-sort(df.rf$importance[,4], decreasing =T)
</code>```

the output like this:

```<code>              decline_adhere                decline_other                 decline_risk               decline_family             decline_decrease
                   6.8802537                    6.0835827                    5.4944119                    3.4293362                    2.3367269
                    fac_name                 decline_test               risk_low_known                       county    service_received_msm_risk
                   1.5975638                    1.1784957                    0.9873187                    0.9775094                    0.7010712
            risk_low_condoms           risk_medium_status service_received_msm_condoms     service_received_msm_pep               risk_low_other
                   0.6934007                    0.4977904                    0.4772047                    0.4649514                    0.4411217
              decline_return               risk_low_never     service_received_msm_hiv  inform_dec_sex_work_refused
                   0.4330664                    0.3774400                    0.3586177                    0.3386593
</code>```

However, when I use the command: gini<-as.data.frame(gini), it coverts the dataframe with only one col called "gini", the score's name also shows up but not as a separated col. It like this:

```<code>     col1
     gini
xxx. 0.1
xxx. 0.5
xxx. 0.4

</code>```

So my question is how to convert the gini score result into dataframe with both col name and its socre. like this:

```<code>col1. col2
name  gini
xxxx. 0.1
xxxx. 0.5
xxxx. 0.4
</code>```

Thanks~~!

Body:
I use the code got a gini score,

df.rf <- randomForest(agree_prep ~ ., data =fdat, ntree = 200, importance = TRUE)

since I only need its score, I subset the result like this:

df.gini<-sort(df.rf$importance[,4], decreasing =T)

the output like this:

              decline_adhere                decline_other                 decline_risk               decline_family             decline_decrease
                   6.8802537                    6.0835827                    5.4944119                    3.4293362                    2.3367269
                    fac_name                 decline_test               risk_low_known                       county    service_received_msm_risk
                   1.5975638                    1.1784957                    0.9873187                    0.9775094                    0.7010712
            risk_low_condoms           risk_medium_status service_received_msm_condoms     service_received_msm_pep               risk_low_other
                   0.6934007                    0.4977904                    0.4772047                    0.4649514                    0.4411217
              decline_return               risk_low_never     service_received_msm_hiv  inform_dec_sex_work_refused
                   0.4330664                    0.3774400                    0.3586177                    0.3386593

However, when I use the command: gini<-as.data.frame(gini), it coverts the dataframe with only one col called "gini", the score's name also shows up but not as a separated col. It like this:

     col1
     gini
xxx. 0.1
xxx. 0.5
xxx. 0.4

So my question is how to convert the gini score result into dataframe with both col name and its socre. like this:

col1. col2
name  gini
xxxx. 0.1
xxxx. 0.5
xxxx. 0.4

Thanks~~!


问:
How to get {x, y} position of dropped element on drop section instead absolute position in React Dnd
I am trying to drag pointer to drop section but I am not able to get position {x, y} relative to drop section. Using React DnD 16.0.1


问:
Automatically change the boolean value in the database when a certain event occurs
Project: Spring Boot, Java, Postgres ...

Hi guys. We have something like subscriptions. When a user puts a plus in the checkbox in the personal account to receive a notification by mail, various notifications are sent to him.
When he puts this plus in his personal account, the value of hasEmailNotify in the database changes to true, and when he removes the plus from the checkbox, it changes to false.

Now we want the user to be able to define - during what period of time he wants to receive a notification - a week, a month, always. Obviously, from the front, I will receive the value of a certain period of time if the user wants only a temporary subscription, for example, for a week. How can I make the hasemailNotify value in the database automatically change from true to false after this period of time has elapsed?


问:
Get Check, Uncheck status of Checkboxes from html table
HTML:

```<code><table class="table table-sm table-striped table-bordered table-hover" id="boflogbook">
             <thead>
              <!--<tr>
                <th colspan="12"><input type="submit" name="updateBtn" value="Submit"></th>
              </tr>-->
              <tr>
                <!--<th align="center"><input type="checkbox" id="selectall" onClick="selectAll(this)"></th>-->
                <th style="display:none;">ID</th>
                <th>Department</th>
                <th>Issue Name</th>
                <th>Released</th>
                <th>Completed</th>
                <th>Action</th>
              </tr>
             </thead>
             <tbody id="tableData">
             </tbody>
          </table>
</code>```

Jquery:

```<code><script type="text/javascript">
  $(document).ready(function(){
      getAllIssues();

    function getAllIssues(){
     $.ajax({
        url: "getalldicsectissues.php",
        type: "POST",
        dataType: "json",
        success: function (res){
          getAllIssueRecords(res.data);
        }
     });
    }
    function getAllIssueRecords(response){
        var data="";
        $.each(response,function(index,value){
            data +="<tr>";
            //data +="<td>"+"<input type='checkbox' id='chkbx' name='chkbx[]'>"+"</td>";
            data +="<td style='display:none;'>"+value.id+"</td>";
            data +="<td>"+value.dept_name+"</td>";
            data +="<td>"+value.issue_short+"</td>";
            if(value.visible_to==1)
                data +="<td>"+"<input type='checkbox' id='visible_to' name='visible_to' checked>"+"</td>";
            else
                data +="<td>"+"<input type='checkbox' id='visible_to' name='visible_to' >"+"</td>";

            if(value.iscompleted==1){
                data +="<td>"+"<input type='checkbox' id='iscompleted' name='iscompleted' checked>"+"</td>";
            }
            else{
                data +="<td>"+"<input type='checkbox' id='iscompleted' name='iscompleted'  >"+"</td>";
            }
            data +="<td data-attr="+value.id+"><a class='btn-warning btnEdit' id='edit'><i class='fa-solid fa-pen-to-square'></i></a>";
            data +="</tr>";
        });
        $("#tableData").html(data);
    }

  $(document).on("click",".btnEdit",function(){
      visible_to=$('input:checkbox[name=visible_to]').is(':checked');
      if(visible_to==true)
          visible_to=1;
      else
          visible_to=0;

      iscompleted=$('input:checkbox[name=iscompleted]').is(':checked');
      if(iscompleted==true)
          iscompleted=1;
      else
          iscompleted=0;

      console.log(dept_name);
      console.log(issue_short);
      console.log(visible_to);
      console.log(iscompleted);
      console.log(issue_id);

      $.ajax({
      url: "updatereleasecomplete.php",
      type: "POST",
      data:{issue_id:issue_id,dept_name:dept_name,issue_short:issue_short,visible_to:visible_to,iscompleted:iscompleted},
      success: function (res) {
           if(res==100){
               toastr.success('Record updated.');
               getAllIssues();
           }
           else{
               toastr.error('Record could not be updated.');
               getAllIssues();
           }
      },
    });
  });
 });
</script>
</code>```

I am unable to get correct checkbox status: whether checked or unchecked.
Case 1: When both the checkboxes are unchecked and button is clicked, 1 and 0 is printed on console.
Case 2: When both the checkboxes are checked and button is clicked, 1 and 1 is printed on console.
Case 3: When first box is unchecked and second is checked, 1 and 1 printed on console.

Kindly help to resolve the above problems.

Body:
HTML:

                ID
                Department
                Issue Name
                Released
                Completed
                Action

Jquery:

I am unable to get correct checkbox status: whether checked or unchecked.
Case 1: When both the checkboxes are unchecked and button is clicked, 1 and 0 is printed on console.
Case 2: When both the checkboxes are checked and button is clicked, 1 and 1 is printed on console.
Case 3: When first box is unchecked and second is checked, 1 and 1 printed on console.

Kindly help to resolve the above problems.


问:
Form data in view is lost or reset after modal popup
My form displays a dropdown list containing a list of statuses. When the selection changes a function is called thruough the dopdown list onchange property and the function calls up a modal. The intention is to gather additional user input thru an text input field.

After the modal is closed, however, the supposed changed status is no longer detected in my controller when the form is submitted. It seems the modal pop-up somehow lost the selected value in the form. Any help?

The dropdown list successfully triggers the function, thus the modal is shown. Nothing is done in the function for now, I just close it.

Here's how the form, modal, and function are placed in the view (among other things):

```<code>    <?php $form = ActiveForm::begin([
        'id'=>'formSave',
        "class"=>"ph-form__inline", 'method' => 'post',
        'fieldConfig' => [
        'template' => "{input}",
        'options' => [
        'tag' => false,
        ],
        ],
    ]);
    ?>

<?= $form->field($model, 'status')->dropDownList($model->listAllowedStatuses($model->status),["prompt" =>'Select Status', "class" => "ph-form__inline", "id"=>"selStatus", "name"=>"selStatus", "onchange"=>"inputReason()"])->label(false)?>

<!-- Modal -->
<div class="modal fade" id="inputModal" tabindex="-1" aria-labelledby="input" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title">Please input (optional) reason for change:</h5>
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                <span aria-hidden="true">×</span>
                </button>
            </div>
            <div class="modal-body">
                <?= $form->field($model, 'status_update_message')->input("text",["class" => "ph-form__input__field", "name"=>"textInput", "id"=>"textInput"])?>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
                <button type="button" class="btn btn-primary" onclick="save()", id="save" name="save">Save</button>
            </div>
        </div>
    </div>
</div>

<script>
    function inputReason(){
        $("#inputModal").modal('show');

    }
</script>
<?php ActiveForm::end(); ?>
</code>```

The function that is triggered by drop-down's onchange, shows the modal: The plan is to add here the fetching of the text input data and placing it in the model, then close the modal, where a button is clicked in the underlying form to submit. The modal should not submit the form itself, just get input and "add" it to the  current form.

Perhaps this approach is wrong, or there's a better way to do it. Currently, it works in this setup: render form, select new value, click submit, and the controller detects the change and proceeds. After adding the modal, the controller no longer detects change:
render form, select new value, POP MODAL - accept text input - CLOSE, click submit, and the controller detects the change and proceeds. Appreciate your help.

Body:
My form displays a dropdown list containing a list of statuses. When the selection changes a function is called thruough the dopdown list onchange property and the function calls up a modal. The intention is to gather additional user input thru an text input field.

After the modal is closed, however, the supposed changed status is no longer detected in my controller when the form is submitted. It seems the modal pop-up somehow lost the selected value in the form. Any help?

The dropdown list successfully triggers the function, thus the modal is shown. Nothing is done in the function for now, I just close it.

Here's how the form, modal, and function are placed in the view (among other things):

    <?php $form = ActiveForm::begin([
        'id'=>'formSave',
        "class"=>"ph-form__inline", 'method' => 'post',
        'fieldConfig' => [
        'template' => "{input}",
        'options' => [
        'tag' => false,
        ],
        ],
    ]);
    ?>

<?= $form->field($model, 'status')->dropDownList($model->listAllowedStatuses($model->status),["prompt" =>'Select Status', "class" => "ph-form__inline", "id"=>"selStatus", "name"=>"selStatus", "onchange"=>"inputReason()"])->label(false)?>

Please input (optional) reason for change:

                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                ×
                </button>

                <?= $form->field($model, 'status_update_message')->input("text",["class" => "ph-form__input__field", "name"=>"textInput", "id"=>"textInput"])?>

                <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
                <button type="button" class="btn btn-primary" onclick="save()", id="save" name="save">Save</button>

<?php ActiveForm::end(); ?>

The function that is triggered by drop-down's onchange, shows the modal: The plan is to add here the fetching of the text input data and placing it in the model, then close the modal, where a button is clicked in the underlying form to submit. The modal should not submit the form itself, just get input and "add" it to the  current form.

Perhaps this approach is wrong, or there's a better way to do it. Currently, it works in this setup: render form, select new value, click submit, and the controller detects the change and proceeds. After adding the modal, the controller no longer detects change:
render form, select new value, POP MODAL - accept text input - CLOSE, click submit, and the controller detects the change and proceeds. Appreciate your help.


问:
What is the formula for seasonal ARIMA model (2,1,2) (0,0,1)[4] w/ drift?
What is/how to get the formula for seasonal ARIMA model (2,1,2) (0,0,1)[4] w/ drift?

```<code>
</code>```

Model: ARIMA(2,1,2)(0,0,1)[4] w/ drift

Coefficients:
ar1      ar2     ma1     ma2    sma1  constant
-0.7644  -0.7437  0.4964  0.9233  0.6741  3335.837
s.e.   0.0690   0.0608  0.0362  0.0393  0.0713  1246.015

sigma^2 estimated as 18215276:  log likelihood=-1787.95
AIC=3589.9   AICc=3590.54   BIC=3612.37

```<code>
</code>```

Ive been trying to figure out how to translate the model into a formula but cannot figure it out, any help? I have used the textbook Forecasting: Principles and Practice (2nd ed.) by Athanasopoulos & Hyndman but it did not seem to help much. I can find examples for other ARIMA's but I cannot decifer it to adjust it for my specific model.

Body:
What is/how to get the formula for seasonal ARIMA model (2,1,2) (0,0,1)[4] w/ drift?

Model: ARIMA(2,1,2)(0,0,1)[4] w/ drift

Coefficients:
ar1      ar2     ma1     ma2    sma1  constant
-0.7644  -0.7437  0.4964  0.9233  0.6741  3335.837
s.e.   0.0690   0.0608  0.0362  0.0393  0.0713  1246.015

sigma^2 estimated as 18215276:  log likelihood=-1787.95
AIC=3589.9   AICc=3590.54   BIC=3612.37

Ive been trying to figure out how to translate the model into a formula but cannot figure it out, any help? I have used the textbook Forecasting: Principles and Practice (2nd ed.) by Athanasopoulos & Hyndman but it did not seem to help much. I can find examples for other ARIMA's but I cannot decifer it to adjust it for my specific model.


问:
Flutter: How to get property from string variable
If I have a class like that:

class Object {
  final int id;
  final String name;

  Object({
    required this.id,
    required this.name,
  });
}

final item = Object(id: 0, name: "Alex");
```
<p>And converted variable from <code>json</code> like that: fetched <code>json</code> from the service:</p>
<pre class="lang-json prettyprint-override"><code>{ "value": "{{item.name}}", }
</code>```

variable:

final text = json\["value"\].stringValue;
```
<p>And replaced it to:</p>
<pre class="lang-dart prettyprint-override"><code>final first = text.replaceAll('{{', '\${');
final last = first.replaceAll('}}', '}');
</code>```

Then how to use in text that variable?

I have tried like that below:

Container(
  child: Text(last),
);
```
<p>But can't show my <code>item.name</code> property.</p>
<p>Just showing text:</p>
<pre class="lang-dart prettyprint-override"><code>"${item.name}"
</code>```

My expected result is:

```<code>"Alex"
</code>```

Body:
If I have a class like that:

class Object {
  final int id;
  final String name;

  Object({
    required this.id,
    required this.name,
  });
}

final item = Object(id: 0, name: "Alex");

And converted variable from json like that: fetched json from the service:

{ "value": "{{item.name}}", }

variable:

final text = json\["value"\].stringValue;

And replaced it to:

final first = text.replaceAll('{{', '\${');
final last = first.replaceAll('}}', '}');

Then how to use in text that variable?

I have tried like that below:

Container(
  child: Text(last),
);

But can't show my item.name property.

Just showing text:

"${item.name}"

My expected result is:

"Alex"


问:
How we get the ledger Of Item Month wise
Here Is my Query of Item Ledger Days Wise But I want to get the item ledger Month wise

```<code>
select STOCK_LEDGER.ITEM_ID,
       STOCK_LEDGER.TITLE,
        TO_CHAR(to_date(STOCK_LEDGER.DAT,'yy-mm-dd')) DAT,
       STOCK_LEDGER.DEPTNO,
       STOCK_LEDGER.DNAME,
       STOCK_LEDGER.NAME,
       STOCK_LEDGER.OPENING_STOCK,
       STOCK_LEDGER.STOCK_IN,
       round(nvl(sum(V_NEWGRNDETAIL.NET_AMNT), 0) /
             nvl(sum(V_NEWGRNDETAIL.QTY), 0),
             2) as pprice,
       nvl(STOCK_LEDGER.STOCK_IN, 0) *

       nvl(round(nvl(sum(V_NEWGRNDETAIL.NET_AMNT), 0) /
                 nvl(sum(V_NEWGRNDETAIL.QTY), 0),
                 2),
           0) as tot,
       STOCK_LEDGER.STOCK_OUT,
       (select round(sum(sal_price) / sum(qty), 2)
          from (select nvl(sal_price, 0) * nvl(stock_in, 0) as sal_price,
                       ITEM_ID,
                       STOCK_IN as qty,
                       nvl(trunc(nvl(nvl(grn_detail.stock_in, 0) *
                                     nvl(grn_detail.rate, 0),
                                     0) -
                                 nvl(nvl(nvl(grn_detail.GIN_QTY, 0) *
                                         nvl(grn_detail.rate, 0),
                                         0) / 100 * nvl(grn_detail.disc, 0),
                                     0)),
                           0) +
                       nvl(round(nvl(nvl(nvl(grn_detail.stock_in, 0) *
                                         nvl(grn_detail.rate, 0),
                                         0) -
                                     nvl(nvl(nvl(grn_detail.stock_in, 0) *
                                             nvl(grn_detail.rate, 0),
                                             0) / 100 *
                                         nvl(grn_detail.disc, 0),
                                         0),
                                     0) / 100 * nvl(grn_detail.tax_per, 0),
                                 2),
                           0) as NET_AMOUNT
                  from grn_detail)
         where item_id = STOCK_LEDGER.ITEM_ID
         group by item_id) as sprc,
       NVL(STOCK_LEDGER.STOCK_OUT, 0) *
       NVL((select round(sum(sal_price) / sum(qty), 2)
             from (select nvl(sal_price, 0) * nvl(stock_in, 0) as sal_price,
                          ITEM_ID,
                          STOCK_IN as qty,
                          nvl(trunc(nvl(nvl(grn_detail.stock_in, 0) *
                                        nvl(grn_detail.rate, 0),
                                        0) -
                                    nvl(nvl(nvl(grn_detail.GIN_QTY, 0) *
                                            nvl(grn_detail.rate, 0),
                                            0) / 100 *
                                        nvl(grn_detail.disc, 0),
                                        0)),
                              0) +
                          nvl(round(nvl(nvl(nvl(grn_detail.stock_in, 0) *
                                            nvl(grn_detail.rate, 0),
                                            0) -
                                        nvl(nvl(nvl(grn_detail.stock_in, 0) *
                                                nvl(grn_detail.rate, 0),
                                                0) / 100 *
                                            nvl(grn_detail.disc, 0),
                                            0),
                                        0) / 100 *
                                    nvl(grn_detail.tax_per, 0),
                                    2),
                              0) as NET_AMOUNT
                     from grn_detail)
            where item_id = STOCK_LEDGER.ITEM_ID
            group by item_id),
           0) AS STOT,
       STOCK_LEDGER.CLOSING_STOCK
  from STOCK_LEDGER, V_NEWGRNDETAIL
 where V_NEWGRNDETAIL.item_id = STOCK_LEDGER.item_id
   AND STOCK_LEDGER.DEPTNO IN (84, 79, 380, 381)
   AND STOCK_LEDGER.ITEM_ID = 786
   and STOCK_LEDGER.DEPTNO in (79, 84, 380, 381)
   AND STOCK_LEDGER.DNAME = 'Pharmacy'
   --and STOCK_LEDGER.DAT > TO_DATE('22-02-13','YYYY,MM,DD')
 group by STOCK_LEDGER.ITEM_ID,
          STOCK_LEDGER.DAT,
          STOCK_LEDGER.DEPTNO,
          STOCK_LEDGER.TITLE,
          STOCK_LEDGER.DNAME,
          STOCK_LEDGER.NAME,
          STOCK_LEDGER.OPENING_STOCK,
          STOCK_LEDGER.STOCK_IN,
          STOCK_LEDGER.STOCK_OUT,
          STOCK_LEDGER.CLOSING_STOCK,
          STOCK_LEDGER.TITLE
 ORDER BY STOCK_LEDGER.DAT

</code>```

Here i am trying to get item ledger month wise but If I get month from date and sum opening, closing ,stock_in and stock_out and order by date then it will not give good result i want every month closing balance will be next month opening balance

```<code>SELECT ITEM_ID,TITLE,DAT,SUM(OPENING_STOCK),SUM(STOCK_IN),(SUM(OPENING_STOCK)+ SUM(STOCK_IN))AS TOT,SUM(STOCK_OUT),SUM(CLOSING_STOCK) FROM(
select STOCK_LEDGER.ITEM_ID,
       STOCK_LEDGER.TITLE,
       --TO_CHAR(to_date(STOCK_LEDGER.DAT,'yy-mm-dd'),'MON') MONTH,
        TO_CHAR(to_date(STOCK_LEDGER.DAT,'yy-mm-dd'),'yyyy,mm') DAT,
       STOCK_LEDGER.DEPTNO,
       STOCK_LEDGER.DNAME,
       STOCK_LEDGER.NAME,
       STOCK_LEDGER.OPENING_STOCK,
       STOCK_LEDGER.STOCK_IN,
       round(nvl(sum(V_NEWGRNDETAIL.NET_AMNT), 0) /
             nvl(sum(V_NEWGRNDETAIL.QTY), 0),
             2) as pprice,
       nvl(STOCK_LEDGER.STOCK_IN, 0) *

       nvl(round(nvl(sum(V_NEWGRNDETAIL.NET_AMNT), 0) /
                 nvl(sum(V_NEWGRNDETAIL.QTY), 0),
                 2),
           0) as tot,
       STOCK_LEDGER.STOCK_OUT,
       (select round(sum(sal_price) / sum(qty), 2)
          from (select nvl(sal_price, 0) * nvl(stock_in, 0) as sal_price,
                       ITEM_ID,
                       STOCK_IN as qty,
                       nvl(trunc(nvl(nvl(grn_detail.stock_in, 0) *
                                     nvl(grn_detail.rate, 0),
                                     0) -
                                 nvl(nvl(nvl(grn_detail.GIN_QTY, 0) *
                                         nvl(grn_detail.rate, 0),
                                         0) / 100 * nvl(grn_detail.disc, 0),
                                     0)),
                           0) +
                       nvl(round(nvl(nvl(nvl(grn_detail.stock_in, 0) *
                                         nvl(grn_detail.rate, 0),
                                         0) -
                                     nvl(nvl(nvl(grn_detail.stock_in, 0) *
                                             nvl(grn_detail.rate, 0),
                                             0) / 100 *
                                         nvl(grn_detail.disc, 0),
                                         0),
                                     0) / 100 * nvl(grn_detail.tax_per, 0),
                                 2),
                           0) as NET_AMOUNT
                  from grn_detail)
         where item_id = STOCK_LEDGER.ITEM_ID
         group by item_id) as sprc,
       NVL(STOCK_LEDGER.STOCK_OUT, 0) *
       NVL((select round(sum(sal_price) / sum(qty), 2)
             from (select nvl(sal_price, 0) * nvl(stock_in, 0) as sal_price,
                          ITEM_ID,
                          STOCK_IN as qty,
                          nvl(trunc(nvl(nvl(grn_detail.stock_in, 0) *
                                        nvl(grn_detail.rate, 0),
                                        0) -
                                    nvl(nvl(nvl(grn_detail.GIN_QTY, 0) *
                                            nvl(grn_detail.rate, 0),
                                            0) / 100 *
                                        nvl(grn_detail.disc, 0),
                                        0)),
                              0) +
                          nvl(round(nvl(nvl(nvl(grn_detail.stock_in, 0) *
                                            nvl(grn_detail.rate, 0),
                                            0) -
                                        nvl(nvl(nvl(grn_detail.stock_in, 0) *
                                                nvl(grn_detail.rate, 0),
                                                0) / 100 *
                                            nvl(grn_detail.disc, 0),
                                            0),
                                        0) / 100 *
                                    nvl(grn_detail.tax_per, 0),
                                    2),
                              0) as NET_AMOUNT
                     from grn_detail)
            where item_id = STOCK_LEDGER.ITEM_ID
            group by item_id),
           0) AS STOT,
       STOCK_LEDGER.CLOSING_STOCK
  from STOCK_LEDGER, V_NEWGRNDETAIL
 where V_NEWGRNDETAIL.item_id = STOCK_LEDGER.item_id
   AND STOCK_LEDGER.DEPTNO IN (84, 79, 380, 381)
   AND STOCK_LEDGER.ITEM_ID = 786
   and STOCK_LEDGER.DEPTNO in (79, 84, 380, 381)
   AND STOCK_LEDGER.DNAME = 'Pharmacy'
   --and STOCK_LEDGER.DAT > TO_DATE('22-02-13','YYYY,MM,DD')
 group by STOCK_LEDGER.ITEM_ID,
          STOCK_LEDGER.DAT,
          STOCK_LEDGER.DEPTNO,
          STOCK_LEDGER.TITLE,
          STOCK_LEDGER.DNAME,
          STOCK_LEDGER.NAME,
          STOCK_LEDGER.OPENING_STOCK,
          STOCK_LEDGER.STOCK_IN,
          STOCK_LEDGER.STOCK_OUT,
          STOCK_LEDGER.CLOSING_STOCK,
          STOCK_LEDGER.TITLE
 ORDER BY STOCK_LEDGER.DAT
 )
 GROUP BY ITEM_ID,TITLE,DAT
 ORDER BY DAT

</code>```

Body:
Here Is my Query of Item Ledger Days Wise But I want to get the item ledger Month wise

select STOCK_LEDGER.ITEM_ID,
       STOCK_LEDGER.TITLE,
        TO_CHAR(to_date(STOCK_LEDGER.DAT,'yy-mm-dd')) DAT,
       STOCK_LEDGER.DEPTNO,
       STOCK_LEDGER.DNAME,
       STOCK_LEDGER.NAME,
       STOCK_LEDGER.OPENING_STOCK,
       STOCK_LEDGER.STOCK_IN,
       round(nvl(sum(V_NEWGRNDETAIL.NET_AMNT), 0) /
             nvl(sum(V_NEWGRNDETAIL.QTY), 0),
             2) as pprice,
       nvl(STOCK_LEDGER.STOCK_IN, 0) *

       nvl(round(nvl(sum(V_NEWGRNDETAIL.NET_AMNT), 0) /
                 nvl(sum(V_NEWGRNDETAIL.QTY), 0),
                 2),
           0) as tot,
       STOCK_LEDGER.STOCK_OUT,
       (select round(sum(sal_price) / sum(qty), 2)
          from (select nvl(sal_price, 0) * nvl(stock_in, 0) as sal_price,
                       ITEM_ID,
                       STOCK_IN as qty,
                       nvl(trunc(nvl(nvl(grn_detail.stock_in, 0) *
                                     nvl(grn_detail.rate, 0),
                                     0) -
                                 nvl(nvl(nvl(grn_detail.GIN_QTY, 0) *
                                         nvl(grn_detail.rate, 0),
                                         0) / 100 * nvl(grn_detail.disc, 0),
                                     0)),
                           0) +
                       nvl(round(nvl(nvl(nvl(grn_detail.stock_in, 0) *
                                         nvl(grn_detail.rate, 0),
                                         0) -
                                     nvl(nvl(nvl(grn_detail.stock_in, 0) *
                                             nvl(grn_detail.rate, 0),
                                             0) / 100 *
                                         nvl(grn_detail.disc, 0),
                                         0),
                                     0) / 100 * nvl(grn_detail.tax_per, 0),
                                 2),
                           0) as NET_AMOUNT
                  from grn_detail)
         where item_id = STOCK_LEDGER.ITEM_ID
         group by item_id) as sprc,
       NVL(STOCK_LEDGER.STOCK_OUT, 0) *
       NVL((select round(sum(sal_price) / sum(qty), 2)
             from (select nvl(sal_price, 0) * nvl(stock_in, 0) as sal_price,
                          ITEM_ID,
                          STOCK_IN as qty,
                          nvl(trunc(nvl(nvl(grn_detail.stock_in, 0) *
                                        nvl(grn_detail.rate, 0),
                                        0) -
                                    nvl(nvl(nvl(grn_detail.GIN_QTY, 0) *
                                            nvl(grn_detail.rate, 0),
                                            0) / 100 *
                                        nvl(grn_detail.disc, 0),
                                        0)),
                              0) +
                          nvl(round(nvl(nvl(nvl(grn_detail.stock_in, 0) *
                                            nvl(grn_detail.rate, 0),
                                            0) -
                                        nvl(nvl(nvl(grn_detail.stock_in, 0) *
                                                nvl(grn_detail.rate, 0),
                                                0) / 100 *
                                            nvl(grn_detail.disc, 0),
                                            0),
                                        0) / 100 *
                                    nvl(grn_detail.tax_per, 0),
                                    2),
                              0) as NET_AMOUNT
                     from grn_detail)
            where item_id = STOCK_LEDGER.ITEM_ID
            group by item_id),
           0) AS STOT,
       STOCK_LEDGER.CLOSING_STOCK
  from STOCK_LEDGER, V_NEWGRNDETAIL
 where V_NEWGRNDETAIL.item_id = STOCK_LEDGER.item_id
   AND STOCK_LEDGER.DEPTNO IN (84, 79, 380, 381)
   AND STOCK_LEDGER.ITEM_ID = 786
   and STOCK_LEDGER.DEPTNO in (79, 84, 380, 381)
   AND STOCK_LEDGER.DNAME = 'Pharmacy'
   --and STOCK_LEDGER.DAT > TO_DATE('22-02-13','YYYY,MM,DD')
 group by STOCK_LEDGER.ITEM_ID,
          STOCK_LEDGER.DAT,
          STOCK_LEDGER.DEPTNO,
          STOCK_LEDGER.TITLE,
          STOCK_LEDGER.DNAME,
          STOCK_LEDGER.NAME,
          STOCK_LEDGER.OPENING_STOCK,
          STOCK_LEDGER.STOCK_IN,
          STOCK_LEDGER.STOCK_OUT,
          STOCK_LEDGER.CLOSING_STOCK,
          STOCK_LEDGER.TITLE
 ORDER BY STOCK_LEDGER.DAT

Here i am trying to get item ledger month wise but If I get month from date and sum opening, closing ,stock_in and stock_out and order by date then it will not give good result i want every month closing balance will be next month opening balance

SELECT ITEM_ID,TITLE,DAT,SUM(OPENING_STOCK),SUM(STOCK_IN),(SUM(OPENING_STOCK)+ SUM(STOCK_IN))AS TOT,SUM(STOCK_OUT),SUM(CLOSING_STOCK) FROM(
select STOCK_LEDGER.ITEM_ID,
       STOCK_LEDGER.TITLE,
       --TO_CHAR(to_date(STOCK_LEDGER.DAT,'yy-mm-dd'),'MON') MONTH,
        TO_CHAR(to_date(STOCK_LEDGER.DAT,'yy-mm-dd'),'yyyy,mm') DAT,
       STOCK_LEDGER.DEPTNO,
       STOCK_LEDGER.DNAME,
       STOCK_LEDGER.NAME,
       STOCK_LEDGER.OPENING_STOCK,
       STOCK_LEDGER.STOCK_IN,
       round(nvl(sum(V_NEWGRNDETAIL.NET_AMNT), 0) /
             nvl(sum(V_NEWGRNDETAIL.QTY), 0),
             2) as pprice,
       nvl(STOCK_LEDGER.STOCK_IN, 0) *

       nvl(round(nvl(sum(V_NEWGRNDETAIL.NET_AMNT), 0) /
                 nvl(sum(V_NEWGRNDETAIL.QTY), 0),
                 2),
           0) as tot,
       STOCK_LEDGER.STOCK_OUT,
       (select round(sum(sal_price) / sum(qty), 2)
          from (select nvl(sal_price, 0) * nvl(stock_in, 0) as sal_price,
                       ITEM_ID,
                       STOCK_IN as qty,
                       nvl(trunc(nvl(nvl(grn_detail.stock_in, 0) *
                                     nvl(grn_detail.rate, 0),
                                     0) -
                                 nvl(nvl(nvl(grn_detail.GIN_QTY, 0) *
                                         nvl(grn_detail.rate, 0),
                                         0) / 100 * nvl(grn_detail.disc, 0),
                                     0)),
                           0) +
                       nvl(round(nvl(nvl(nvl(grn_detail.stock_in, 0) *
                                         nvl(grn_detail.rate, 0),
                                         0) -
                                     nvl(nvl(nvl(grn_detail.stock_in, 0) *
                                             nvl(grn_detail.rate, 0),
                                             0) / 100 *
                                         nvl(grn_detail.disc, 0),
                                         0),
                                     0) / 100 * nvl(grn_detail.tax_per, 0),
                                 2),
                           0) as NET_AMOUNT
                  from grn_detail)
         where item_id = STOCK_LEDGER.ITEM_ID
         group by item_id) as sprc,
       NVL(STOCK_LEDGER.STOCK_OUT, 0) *
       NVL((select round(sum(sal_price) / sum(qty), 2)
             from (select nvl(sal_price, 0) * nvl(stock_in, 0) as sal_price,
                          ITEM_ID,
                          STOCK_IN as qty,
                          nvl(trunc(nvl(nvl(grn_detail.stock_in, 0) *
                                        nvl(grn_detail.rate, 0),
                                        0) -
                                    nvl(nvl(nvl(grn_detail.GIN_QTY, 0) *
                                            nvl(grn_detail.rate, 0),
                                            0) / 100 *
                                        nvl(grn_detail.disc, 0),
                                        0)),
                              0) +
                          nvl(round(nvl(nvl(nvl(grn_detail.stock_in, 0) *
                                            nvl(grn_detail.rate, 0),
                                            0) -
                                        nvl(nvl(nvl(grn_detail.stock_in, 0) *
                                                nvl(grn_detail.rate, 0),
                                                0) / 100 *
                                            nvl(grn_detail.disc, 0),
                                            0),
                                        0) / 100 *
                                    nvl(grn_detail.tax_per, 0),
                                    2),
                              0) as NET_AMOUNT
                     from grn_detail)
            where item_id = STOCK_LEDGER.ITEM_ID
            group by item_id),
           0) AS STOT,
       STOCK_LEDGER.CLOSING_STOCK
  from STOCK_LEDGER, V_NEWGRNDETAIL
 where V_NEWGRNDETAIL.item_id = STOCK_LEDGER.item_id
   AND STOCK_LEDGER.DEPTNO IN (84, 79, 380, 381)
   AND STOCK_LEDGER.ITEM_ID = 786
   and STOCK_LEDGER.DEPTNO in (79, 84, 380, 381)
   AND STOCK_LEDGER.DNAME = 'Pharmacy'
   --and STOCK_LEDGER.DAT > TO_DATE('22-02-13','YYYY,MM,DD')
 group by STOCK_LEDGER.ITEM_ID,
          STOCK_LEDGER.DAT,
          STOCK_LEDGER.DEPTNO,
          STOCK_LEDGER.TITLE,
          STOCK_LEDGER.DNAME,
          STOCK_LEDGER.NAME,
          STOCK_LEDGER.OPENING_STOCK,
          STOCK_LEDGER.STOCK_IN,
          STOCK_LEDGER.STOCK_OUT,
          STOCK_LEDGER.CLOSING_STOCK,
          STOCK_LEDGER.TITLE
 ORDER BY STOCK_LEDGER.DAT
 )
 GROUP BY ITEM_ID,TITLE,DAT
 ORDER BY DAT


问:
how can i implement inverted index on numbers
I am new to python. I have a csv file having GCF_NO as column heading and WP_NO as values. I need to use this file and make a inverted index using python. Please guide

enter image description here