Skip to content

Commit

Permalink
WORK ON DOCUMENT CONTROLLER
Browse files Browse the repository at this point in the history
CREATE NOMENCLATURE CONTROLLER
TODO:
REQUEST MANIPULATION
MESSAGE MANIPULATION
DOCUMENT MANIPULATION
DOCUMENT FILE MANIPULATION
TASK MANIPULATION
SHOW CONTEOLLED TASK FOR USER
SHOW USERS TASK
STOREHAUSE MANIPULATION
GOOD PRODUCTION AND SERVICE
REGISTER BED PRODUCT
  • Loading branch information
FairWindCo committed Oct 29, 2015
1 parent 266243f commit 6343e7f
Show file tree
Hide file tree
Showing 10 changed files with 553 additions and 93 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ public Object simpleClientList(@RequestParam(required = false) Integer page_num,
@ResponseBody
public Object simpleAgrimentsList(@RequestParam(required = false) Integer page_num, @RequestParam(required = false) Integer per_page,@RequestParam(value = "pkey_val[]",required = false) String pkey,@RequestParam(value = "q_word[]",required = false) String[] qword,@RequestParam(required = false) Long counterpart_id) {
//Sort sort= FormSort.formSortFromSortDescription(orderby);
Sort sort=new Sort(Sort.Direction.ASC,"shortName");
Sort sort=new Sort(Sort.Direction.ASC,"name");
PageRequest pager=null;
if(page_num!=null && per_page!=null) {
page_num= page_num<1?1:page_num;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,13 +189,13 @@ public boolean update(HttpServletRequest req,Request request){
}
}
UserDetailsAdapter userDetail=(UserDetailsAdapter) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
if(userDetail==null){
if(userDetail!=null){
request.setResponsiblePerson(userDetail.getUserPerson());
} else {
return false;
}
Long counterparty_id=Utils.getLongParameter("counterpart_id",req);
Long requesttype=Utils.getLongParameter("requesttype",req);
Long requesttype=Utils.getLongParameter("typeRequest",req);
Long agreement_id=Utils.getLongParameter("agreement_id", req);
Long parent_request_id=Utils.getLongParameter("parent_request_id", req);
if(counterparty_id!=null){
Expand All @@ -204,7 +204,9 @@ public boolean update(HttpServletRequest req,Request request){
}
if(agreement_id!=null){
Agreement agreement=agrimentRepository.findOne(agreement_id);
request.setCounterparty(agreement.getCounterparty());
if(agreement!=null) {
request.setCounterparty(agreement.getCounterparty());
}
request.setAgreement(agreement);
}
if(parent_request_id!=null){
Expand Down Expand Up @@ -290,7 +292,7 @@ public JGridRowsResponse<RequestItems> getItemTable(HttpServletRequest request){
}

@Transactional(readOnly = false)
@RequestMapping(value = "/edit", method = {RequestMethod.POST,RequestMethod.GET})
@RequestMapping(value = "/subscribe", method = {RequestMethod.POST,RequestMethod.GET})
public void subscribe(@RequestParam long id,HttpServletResponse response)throws IOException {
UserDetailsAdapter userDetail=(UserDetailsAdapter) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
Request request = requestRepository.findOne(id);
Expand All @@ -309,7 +311,7 @@ public void subscribe(@RequestParam long id,HttpServletResponse response)throws

@Transactional(readOnly = false)
@RequestMapping(value = "/edit", method = {RequestMethod.POST,RequestMethod.GET})
public void editor(@RequestParam String oper,@RequestParam long id,HttpServletRequest req,HttpServletResponse response)throws IOException {
public void editor(@RequestParam String oper,@RequestParam Long id,HttpServletRequest req,HttpServletResponse response)throws IOException {
switch (oper){
case "add":
Request request=new Request();
Expand All @@ -319,6 +321,10 @@ public void editor(@RequestParam String oper,@RequestParam long id,HttpServletRe
}
break;
case "edit":
if(id==null){
response.sendError(406,"NO REQUEST FOUND");
return;
}
Request fromDB= requestRepository.getOne(id);
if(fromDB.isExecuted() || fromDB.getApprovedPerson()!=null){
response.sendError(403,"FORBIDDEN!");
Expand All @@ -337,6 +343,10 @@ public void editor(@RequestParam String oper,@RequestParam long id,HttpServletRe

break;
case "del":
if(id==null){
response.sendError(406,"NO REQUEST FOUND");
return;
}
requestRepository.delete(id);
response.setStatus(200);
break;
Expand Down Expand Up @@ -375,7 +385,7 @@ public boolean updateItem(HttpServletRequest req,RequestItems item,Request paren

@Transactional(readOnly = false)
@RequestMapping(value = "/editItem", method = {RequestMethod.POST,RequestMethod.GET})
public void itemEditor(@RequestParam String oper,@RequestParam long id,@RequestParam long requestid,HttpServletRequest req,HttpServletResponse response)throws IOException {
public void itemEditor(@RequestParam String oper,@RequestParam Long id,@RequestParam long requestid,HttpServletRequest req,HttpServletResponse response)throws IOException {
Request request = requestRepository.findOne(requestid);
if (request == null) {
response.sendError(404, "REQUEST NOT FOUND!");
Expand All @@ -394,6 +404,10 @@ public void itemEditor(@RequestParam String oper,@RequestParam long id,@RequestP
response.setStatus(200);
}break;
case "edit": {
if(id==null){
response.sendError(406,"NO REQUEST ITEM FOUND");
return;
}
RequestItems item=requestItemRepository.findOne(id);
if (item != null) {
if(!updateItem(req, item, request)){
Expand All @@ -408,6 +422,10 @@ public void itemEditor(@RequestParam String oper,@RequestParam long id,@RequestP

}break;
case "del":
if(id==null){
response.sendError(406,"NO REQUEST ITEM FOUND");
return;
}
requestRepository.delete(id);
requestRepository.save(request);
response.setStatus(200);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ public JGridRowsResponse<Document> getDocumentsTable(HttpServletRequest request,
}

@Transactional(readOnly = false)
@RequestMapping(value = "/edit", method = {RequestMethod.POST,RequestMethod.GET})
@RequestMapping(value = "/edit_nomenclature", method = {RequestMethod.POST,RequestMethod.GET})
public void nomenclatureeditor(@RequestParam String oper,@RequestParam long moveid,HttpServletRequest request,HttpServletResponse response)throws IOException {
Movement movement=movementRepository.findOne(moveid);
if(movement==null){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,25 +23,25 @@ public interface RequestRepository extends JpaRepository<Request,Long>{
@Query("select r from RequestItems r where r.request.id=:requestId")
Page<RequestItems> getState(@Param(value = "requestId") long requestId, Pageable pager);
@Query("select r from RequestItems r where r.request.id=:requestId")
List<RequestItems> getState(@Param(value = "storehouseId") long requestId);
List<RequestItems> getState(@Param(value = "requestId") long requestId);
@Query("select r from RequestItems r where r.request.id=:requestId")
List<RequestItems> getState(@Param(value = "storehouseId") long requestId, Sort sort);
List<RequestItems> getState(@Param(value = "requestId") long requestId, Sort sort);


@Query("select r from RequestItems r where r.request.id=:requestId and r.nomenclature.name like %:name%")
Page<RequestItems> getState(@Param(value = "requestId") long requestId,@Param(value = "name")String name, Pageable pager);
@Query("select r from RequestItems r where r.request.id=:requestId and r.nomenclature.name like %:name%")
List<RequestItems> getState(@Param(value = "storehouseId") long requestId,@Param(value = "name")String name);
List<RequestItems> getState(@Param(value = "requestId") long requestId,@Param(value = "name")String name);
@Query("select r from RequestItems r where r.request.id=:requestId and r.nomenclature.name like %:name%")
List<RequestItems> getState(@Param(value = "storehouseId") long requestId,@Param(value = "name")String name, Sort sort);
List<RequestItems> getState(@Param(value = "requestId") long requestId,@Param(value = "name")String name, Sort sort);


@Query("select r from Request r where r.id = :requestId or r.counterparty.shortName like %:requestId% or r.agreement.name like %:requestId%")
Page<Request> find(@Param(value = "requestId") String requestId, Pageable pager);
@Query("select r from Request r where r.id = :requestId or r.counterparty.shortName like %:requestId% or r.agreement.name like %:requestId%")
List<Request> find(@Param(value = "storehouseId") String requestId);
List<Request> find(@Param(value = "requestId") String requestId);
@Query("select r from Request r where r.id = :requestId or r.counterparty.shortName like %:requestId% or r.agreement.name like %:requestId%")
List<Request> find(@Param(value = "storehouseId") String requestId, Sort sort);
List<Request> find(@Param(value = "requestId") String requestId, Sort sort);


}
5 changes: 4 additions & 1 deletion src/main/resources/label_en_US.properties
Original file line number Diff line number Diff line change
Expand Up @@ -242,4 +242,7 @@ label.storehouse.operation.UTILIZATION=UTILIZATION
label.PURCHASE=REQUEST PURCHASE
label.RSHIPMENT=REQUEST SHIPMENT
label.PRODUCTION=REQUEST PRODATION
label.REPAIR=REQUEST REPAIT
label.REPAIR=REQUEST REPAIT
label.requests.type=Request Type
label.requests.counterparty=Counerparty
label.requests.agreements=Agreements
5 changes: 4 additions & 1 deletion src/main/resources/label_ru_RU.properties
Original file line number Diff line number Diff line change
Expand Up @@ -241,4 +241,7 @@ label.storehouse.operation.UTILIZATION=UTILIZATION
label.PURCHASE=REQUEST PURCHASE
label.RSHIPMENT=REQUEST SHIPMENT
label.PRODUCTION=REQUEST PRODATION
label.REPAIR=REQUEST REPAIT
label.REPAIR=REQUEST REPAIT
label.requests.type=Request Type
label.requests.counterparty=Counerparty
label.requests.agreements=Agreements
5 changes: 4 additions & 1 deletion src/main/resources/label_ua_UA.properties
Original file line number Diff line number Diff line change
Expand Up @@ -242,4 +242,7 @@ label.storehouse.operation.UTILIZATION=UTILIZATION
label.PURCHASE=REQUEST PURCHASE
label.RSHIPMENT=REQUEST SHIPMENT
label.PRODUCTION=REQUEST PRODATION
label.REPAIR=REQUEST REPAIT
label.REPAIR=REQUEST REPAIT
label.requests.type=Request Type
label.requests.counterparty=Counerparty
label.requests.agreements=Agreements
Loading

0 comments on commit 6343e7f

Please sign in to comment.