WmshGridMaterialController.java 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  1. package com.steerinfo.dil.controller;
  2. import com.steerinfo.dil.service.IWmshGridMaterialService;
  3. import com.steerinfo.dil.util.ColumnDataUtil;
  4. import com.steerinfo.dil.util.DataChange;
  5. import com.steerinfo.dil.util.PageListAdd;
  6. import com.steerinfo.framework.controller.BaseRESTfulController;
  7. import com.steerinfo.framework.controller.RESTfulResult;
  8. import com.steerinfo.framework.service.pagehelper.PageHelper;
  9. import io.swagger.annotations.ApiImplicitParam;
  10. import io.swagger.annotations.ApiImplicitParams;
  11. import io.swagger.annotations.ApiModelProperty;
  12. import io.swagger.annotations.ApiOperation;
  13. import org.springframework.beans.factory.annotation.Autowired;
  14. import org.springframework.web.bind.annotation.PostMapping;
  15. import org.springframework.web.bind.annotation.RequestBody;
  16. import org.springframework.web.bind.annotation.RequestMapping;
  17. import org.springframework.web.bind.annotation.RestController;
  18. import java.math.BigDecimal;
  19. import java.text.SimpleDateFormat;
  20. import java.util.*;
  21. /**
  22. * WmshGridMaterial RESTful接口:
  23. * @author generator
  24. * @version 1.0-SNAPSHORT 2021-10-09 07:25
  25. * 类描述
  26. * 修订历史:
  27. * 日期:2021-10-09
  28. * 作者:generator
  29. * 参考:
  30. * 描述:WmshGridMaterial RESTful接口
  31. * @see null
  32. * @Copyright 湖南视拓信息技术股份有限公司. All rights reserved.
  33. */
  34. @RestController
  35. @RequestMapping("/${api.version}/wmshgridmaterials")
  36. public class WmshGridMaterialController extends BaseRESTfulController {
  37. @Autowired
  38. IWmshGridMaterialService wmshGridMaterialService;
  39. @Autowired
  40. ColumnDataUtil columnDataUtil;
  41. private final SimpleDateFormat sdfDateTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  42. /**
  43. * 展示下游港口港存库库存列表
  44. * @param mapVal
  45. * @param pageNum
  46. * @param pageSize
  47. * @param apiId
  48. * @return
  49. */
  50. @ApiOperation(value="展示下游港口港存库库存列表", notes="分页查询")
  51. @ApiImplicitParams({
  52. @ApiImplicitParam(name = "pageNum", value = "查询页数", required = false, dataType = "Integer"),
  53. @ApiImplicitParam(name = "pageSize", value = "每页记录数", required = false, dataType = "Integer"),
  54. @ApiImplicitParam(name = "apiId", value = "158", required = false, dataType = "BigDecimal"),
  55. })
  56. @PostMapping(value = "/getUnloadPortStockList")
  57. public RESTfulResult getUnloadPortStockList(@RequestBody(required = false) Map<String,Object> mapVal,
  58. Integer pageNum,
  59. Integer pageSize,
  60. Integer apiId){
  61. PageHelper.startPage(pageNum, pageSize);
  62. //分页查询数据
  63. List<Map<String, Object>> columnList = wmshGridMaterialService.getUnloadPortStockList(mapVal);
  64. PageListAdd data = columnDataUtil.tableColumnData(apiId, null, columnList);
  65. return success(data);
  66. }
  67. /**
  68. * 展示万州港港存库库存列表
  69. * @param mapVal
  70. * @param pageNum
  71. * @param pageSize
  72. * @param apiId
  73. * @return
  74. */
  75. @ApiOperation(value="展示万州港港存库库存列表", notes="分页查询")
  76. @ApiImplicitParams({
  77. @ApiImplicitParam(name = "pageNum", value = "查询页数", required = false, dataType = "Integer"),
  78. @ApiImplicitParam(name = "pageSize", value = "每页记录数", required = false, dataType = "Integer"),
  79. @ApiImplicitParam(name = "apiId", value = "158", required = false, dataType = "BigDecimal"),
  80. })
  81. @PostMapping(value = "/getLoadPortStockList")
  82. public RESTfulResult getLoadPortStockList(@RequestBody(required = false) Map<String,Object> mapVal,
  83. Integer pageNum,
  84. Integer pageSize,
  85. Integer apiId,
  86. String con){
  87. if (con!=null&&!"".equals(con)){
  88. mapVal.put("con",con);
  89. }
  90. Date now=new Date();
  91. int hour = now.getHours();
  92. if(hour >=8 && hour < 18){
  93. now.setHours(8);
  94. }else{
  95. now.setHours(18);
  96. }
  97. now.setMinutes(0);
  98. now.setSeconds(0);
  99. mapVal.put("time",now);
  100. PageHelper.startPage(pageNum, pageSize);
  101. //分页查询数据
  102. List<Map<String, Object>> columnList = wmshGridMaterialService.getLoadPortStockList(mapVal);
  103. PageListAdd data = columnDataUtil.tableColumnData(apiId, null, columnList);
  104. return success(data);
  105. }
  106. /**
  107. * 获取下游港口库存吨位
  108. * @param mapVal
  109. * @return
  110. */
  111. @PostMapping(value = "/getDownPortStockList")
  112. public RESTfulResult getDownPortStockList(@RequestBody(required = false) Map<String,Object> mapVal){
  113. //查询所有在途的发货通知下的外轮
  114. List<Map<String,Object>> list = wmshGridMaterialService.selectAllShip(mapVal);
  115. //遍历获取所有的大类分类及求和
  116. Map<String, BigDecimal> types=new HashMap<>();
  117. for(int i=0;i<list.size();i++){
  118. Map<String,Object> ship = list.get(i);
  119. BigDecimal tonnage = DataChange.dataToBigDecimal(ship.get("gmTonnage"));
  120. if(types.containsKey(ship.get("type")) && tonnage.doubleValue()>0){
  121. //统计下游港口>0的库存
  122. BigDecimal result=types.get(ship.get("type")).add(tonnage);
  123. types.put(ship.get("type").toString(),result);
  124. }else{
  125. types.put(ship.get("type").toString(),tonnage);
  126. }
  127. }
  128. //添加结果
  129. for(int i=0;i<list.size();i++){
  130. Map<String,Object> ship = list.get(i);
  131. ship.put("typeTotalTonnage",types.get(ship.get("type").toString()).setScale(2));
  132. }
  133. return success(list);
  134. }
  135. /**
  136. * 获取在途库存信息
  137. * @param mapVal
  138. * @return
  139. */
  140. @PostMapping(value = "/getRunStockList")
  141. public RESTfulResult getRunStockList(@RequestBody(required = false) Map<String,Object> mapVal){
  142. return success(wmshGridMaterialService.getRunStockList(mapVal));
  143. }
  144. @ApiOperation(value="船舶动态表展示库存吨位", notes="分页查询")
  145. @ApiImplicitParams({
  146. @ApiImplicitParam(name = "pageNum", value = "查询页数", required = false, dataType = "Integer"),
  147. @ApiImplicitParam(name = "pageSize", value = "每页记录数", required = false, dataType = "Integer"),
  148. @ApiImplicitParam(name = "apiId", value = "158", required = false, dataType = "BigDecimal"),
  149. })
  150. @PostMapping(value = "/gePortStockList")
  151. public RESTfulResult gePortStockList(@RequestBody(required = false) Map<String,Object> mapVal
  152. ){
  153. List<Map<String, Object>> columnList = wmshGridMaterialService.getLoadPortStockList(mapVal);
  154. return success(columnList);
  155. }
  156. /**
  157. * 展示万州港港存库库存列表
  158. * @param mapVal
  159. * @param pageNum
  160. * @param pageSize
  161. * @param apiId
  162. * @return
  163. */
  164. @ApiOperation(value="展示万州港当前物资实时库存", notes="分页查询")
  165. @ApiImplicitParams({
  166. @ApiImplicitParam(name = "pageNum", value = "查询页数", required = false, dataType = "Integer"),
  167. @ApiImplicitParam(name = "pageSize", value = "每页记录数", required = false, dataType = "Integer"),
  168. @ApiImplicitParam(name = "apiId", value = "158", required = false, dataType = "BigDecimal"),
  169. })
  170. @PostMapping(value = "/getLoadPortStockByMaterialName")
  171. public RESTfulResult getLoadPortStockByMaterialName(@RequestBody(required = false) Map<String,Object> mapVal,
  172. Integer pageNum,
  173. Integer pageSize,
  174. Integer apiId,
  175. String con){
  176. if (con!=null&&!"".equals(con)){
  177. mapVal.put("con",con);
  178. }
  179. PageHelper.startPage(pageNum, pageSize);
  180. //分页查询数据
  181. List<Map<String, Object>> columnList = wmshGridMaterialService.getLoadPortStockByMaterialName(mapVal);
  182. PageListAdd data = columnDataUtil.tableColumnData(apiId, null, columnList);
  183. return success(data);
  184. }
  185. /**
  186. * 展示万州港港存库库存列表
  187. * @param mapVal
  188. * @param pageNum
  189. * @param pageSize
  190. * @param apiId
  191. * @return
  192. */
  193. @ApiOperation(value="展示港存库出库", notes="分页查询")
  194. @ApiImplicitParams({
  195. @ApiImplicitParam(name = "pageNum", value = "查询页数", required = false, dataType = "Integer"),
  196. @ApiImplicitParam(name = "pageSize", value = "每页记录数", required = false, dataType = "Integer"),
  197. @ApiImplicitParam(name = "apiId", value = "494", required = false, dataType = "BigDecimal"),
  198. })
  199. @PostMapping(value = "/getUnLockPortStock")
  200. public RESTfulResult getUnLockPortStock(@RequestBody(required = false) Map<String,Object> mapVal,
  201. Integer pageNum,
  202. Integer pageSize,
  203. Integer apiId,
  204. String con,
  205. String activeName,
  206. String startTime,
  207. String endTime){
  208. if (con!=null&&!"".equals(con)){
  209. mapVal.put("con",con);
  210. }
  211. if (activeName!=null&&!"".equals(activeName)){
  212. mapVal.put("activeName",activeName);
  213. }
  214. if (startTime!=null&&!"".equals(startTime)){
  215. mapVal.put("startTime",startTime);
  216. }
  217. if (endTime!=null&&!"".equals(endTime)){
  218. mapVal.put("endTime",endTime);
  219. }
  220. PageHelper.startPage(pageNum, pageSize);
  221. DataChange.queryDataByDateTime(startTime, endTime, mapVal, sdfDateTime);//根据时间段查询数据
  222. //分页查询数据
  223. List<Map<String, Object>> columnList = wmshGridMaterialService.getUnLockPortStock(mapVal);
  224. PageListAdd data = columnDataUtil.tableColumnData(apiId, null, columnList);
  225. return success(data);
  226. }
  227. //清场
  228. @ApiModelProperty(value = "清场远程调用")
  229. @ApiImplicitParams({
  230. @ApiImplicitParam(name = "amsContractBreach", value = "违约规则实体", required = false, dataType = "AmsContractBreach"),
  231. })
  232. @PostMapping("/clearWmshGridMaterial")
  233. public RESTfulResult clearWmshGridMaterial(@RequestBody Map<String,Object> map) {
  234. int result = wmshGridMaterialService.clearWmshGridMaterial(map);
  235. return success(result);
  236. }
  237. @ApiModelProperty(value = "修改远程调用")
  238. @PostMapping("/updateWmshGridMaterial")
  239. public RESTfulResult updateWmshGridMaterial(@RequestBody Map<String,Object> map) {
  240. int result = wmshGridMaterialService.updateWmshGridMaterial(map);
  241. return success(result);
  242. }
  243. }