TmstruckLeaveFactoryResultController.java 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. package com.steerinfo.dil.controller;
  2. import com.steerinfo.dil.feign.ESFeign;
  3. import com.steerinfo.dil.model.TmstruckLeaveFactoryResult;
  4. import com.steerinfo.dil.service.ITmstruckLeaveFactoryResultService;
  5. import com.steerinfo.dil.util.BaseRESTfulController;
  6. import com.steerinfo.dil.util.ColumnDataUtil;
  7. import com.steerinfo.dil.util.PageListAdd;
  8. import com.steerinfo.framework.controller.RESTfulResult;
  9. import com.steerinfo.framework.service.pagehelper.PageHelper;
  10. import com.steerinfo.route.service.impl.RouteServiceImpl;
  11. import io.swagger.annotations.ApiImplicitParam;
  12. import io.swagger.annotations.ApiImplicitParams;
  13. import io.swagger.annotations.ApiOperation;
  14. import io.swagger.models.auth.In;
  15. import org.springframework.beans.factory.annotation.Autowired;
  16. import org.springframework.web.bind.annotation.*;
  17. import java.io.File;
  18. import java.math.BigDecimal;
  19. import java.util.Arrays;
  20. import java.util.HashMap;
  21. import java.util.List;
  22. import java.util.Map;
  23. /**
  24. * TmstruckLeaveFactoryResult RESTful接口:
  25. * @author generator
  26. * @version 1.0-SNAPSHORT 2021-09-11 10:32
  27. * 类描述
  28. * 修订历史:
  29. * 日期:2021-09-11
  30. * 作者:TXF
  31. * 参考:
  32. * 描述:TmstruckLeaveFactoryResult RESTful接口
  33. * @see null
  34. * @Copyright 湖南视拓信息技术股份有限公司. All rights reserved.
  35. */
  36. @RestController
  37. @RequestMapping("/${api.version}/tmstruckleavefactoryresults")
  38. public class TmstruckLeaveFactoryResultController extends BaseRESTfulController {
  39. @Autowired
  40. ITmstruckLeaveFactoryResultService tmstruckLeaveFactoryResultService;
  41. @Autowired
  42. private RouteServiceImpl routeService;
  43. @Autowired
  44. ESFeign esFeign;
  45. @Autowired
  46. ColumnDataUtil columnDataUtil;
  47. @ApiOperation(value="新增汽车出厂实绩:oms远程调用")
  48. @ApiImplicitParams({
  49. @ApiImplicitParam(name = "mapValue", value = "总实绩ID、线路终点", required = false, dataType = "Map"),
  50. })
  51. @PostMapping("/addLeaveFactory")
  52. public RESTfulResult addLeaveFactory(@RequestBody(required=false) Map<String,Object> mapValue){
  53. int i = tmstruckLeaveFactoryResultService.addLeaveFactory(mapValue);
  54. return success(i);
  55. }
  56. @ApiOperation(value="查询出厂实绩")
  57. @ApiImplicitParams({
  58. @ApiImplicitParam(name = "mapValue", value = "表头和参数", required = false, dataType = "map"),
  59. @ApiImplicitParam(name = "apiId(110)", value = "动态表头", required = false, dataType = "Integer"),
  60. @ApiImplicitParam(name = "pageNum", value = "页码", required = false, dataType = "Integer"),
  61. @ApiImplicitParam(name = "pageSize", value = "页", required = false, dataType = "Integer"),
  62. @ApiImplicitParam(name = "status", value = "状态码", required = false, dataType = "Integer"),
  63. })
  64. @PostMapping("/getLeaveFactoryResult")
  65. public RESTfulResult getLeaveFactoryResult(@RequestBody(required=false) Map<String,Object> mapValue,
  66. Integer apiId,
  67. Integer pageNum,
  68. Integer pageSize,
  69. Integer orderType,
  70. String con,
  71. String carrierSsoId,
  72. String userId,
  73. String userIds){
  74. int count=0;
  75. if (userId!=null){
  76. mapValue.put("userId",userId);
  77. count++;
  78. }
  79. if (userIds!=null){
  80. mapValue.put("userIds",userIds);
  81. count++;
  82. }
  83. if (orderType!=null){
  84. mapValue.put("orderTypee", orderType);
  85. count++;
  86. }
  87. if(carrierSsoId != null){
  88. if(!"null".equals(carrierSsoId)){
  89. mapValue.put("carrierSsoId", carrierSsoId);
  90. }
  91. }
  92. //框计算
  93. if(con != null){
  94. if(!"undefined".equals(con)){
  95. String index="get_leavefactory_list";//设置要查询的索引名称
  96. return success(esFeign.getConResult(mapValue,index,apiId,pageNum,pageSize,con));//获取查询结果
  97. }
  98. }
  99. List<Map<String, Object>> allLeaveFactoryResult = null;
  100. //如果有条件查询则跳过初始化,和创建索引
  101. if(mapValue.size() == count){
  102. //将查询结果存入索引中
  103. allLeaveFactoryResult = tmstruckLeaveFactoryResultService.getLeaveFactoryResult(mapValue);
  104. Map<String, Object> map = new HashMap<>();
  105. //添加索引
  106. map.put("index","get_leavefactory_list");
  107. //添加id
  108. map.put("indexId","leaveFactoryId");
  109. allLeaveFactoryResult.add(map);
  110. //新建索引
  111. esFeign.insertIndex(allLeaveFactoryResult);
  112. //删除
  113. allLeaveFactoryResult.remove(allLeaveFactoryResult.size()-1);
  114. }
  115. if(allLeaveFactoryResult == null)
  116. allLeaveFactoryResult = tmstruckLeaveFactoryResultService.getLeaveFactoryResult(mapValue);
  117. PageHelper.startPage(pageNum,pageSize);
  118. //分页数据
  119. List<Map<String, Object>> leaveFactoryResult = tmstruckLeaveFactoryResultService.getLeaveFactoryResult(mapValue);
  120. PageListAdd pageList = columnDataUtil.tableColumnData(apiId, allLeaveFactoryResult,leaveFactoryResult);
  121. return success(pageList);
  122. }
  123. @ApiOperation(value="PAD扫描汽车出厂实绩")
  124. @ApiImplicitParams({
  125. @ApiImplicitParam(name = "mapValue", value = "", required = false, dataType = "Map"),
  126. @ApiImplicitParam(name = "orderNumber", value = "", required = false, dataType = "String"),
  127. })
  128. @PostMapping("/addLeaveFactoryResult")
  129. public RESTfulResult addLeaveFactoryResult(@RequestBody(required=false) Map<String,Object> mapValue){
  130. //中交新路接口
  131. // Map<String, Object> parem=tmstruckLeaveFactoryResultService.getTruckFactoryResult("WYSDD2021091000000002");
  132. // parem.put("turnOf","0");
  133. // routeService.saveRoute(parem);
  134. int leaveFactory = 0;
  135. try {
  136. leaveFactory = tmstruckLeaveFactoryResultService.leaveFactoryByPDA(mapValue);
  137. }catch (Exception e){
  138. return failed(e.getMessage());
  139. }
  140. return success(leaveFactory);
  141. }
  142. @ApiOperation(value="APP查询汽车出厂实绩")
  143. @PostMapping("/getLeaveFactoryList")
  144. public RESTfulResult getLeaveFactoryList(@RequestParam String orderNumber) {
  145. List<Map<String,Object>> mapList = tmstruckLeaveFactoryResultService.getLeaveFactoryList(orderNumber);
  146. return success(mapList);
  147. }
  148. }