TmstruckReceiptResultController.java 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  1. package com.steerinfo.dil.controller;
  2. import com.steerinfo.dil.feign.ESFeign;
  3. import com.steerinfo.dil.model.TmstruckReceiptResult;
  4. import com.steerinfo.dil.service.ITmstruckReceiptResultService;
  5. import com.steerinfo.dil.util.BaseRESTfulController;
  6. import com.steerinfo.dil.util.ColumnDataUtil;
  7. import com.steerinfo.dil.util.DataChange;
  8. import com.steerinfo.dil.util.PageListAdd;
  9. import com.steerinfo.framework.controller.RESTfulResult;
  10. import com.steerinfo.framework.service.pagehelper.PageHelper;
  11. import com.steerinfo.route.config.ImageFileUtils;
  12. import com.steerinfo.route.mapper.TmstruckArrivalResultMapper;
  13. import com.steerinfo.route.model.TmstruckReceiptResultChild;
  14. import com.steerinfo.route.service.impl.TmstruckReceiptResultChildServiceImpl;
  15. import io.swagger.annotations.ApiImplicitParam;
  16. import io.swagger.annotations.ApiImplicitParams;
  17. import io.swagger.annotations.ApiOperation;
  18. import org.springframework.beans.factory.annotation.Autowired;
  19. import org.springframework.web.bind.annotation.*;
  20. import java.math.BigDecimal;
  21. import java.text.SimpleDateFormat;
  22. import java.util.*;
  23. /**
  24. * TmstruckReceiptResult RESTful接口:
  25. * @author generator
  26. * @version 1.0-SNAPSHORT 2021-09-10 10:10
  27. * 类描述
  28. * 修订历史:
  29. * 日期:2021-09-10
  30. * 作者:generator
  31. * 参考:
  32. * 描述:TmstruckReceiptResult RESTful接口
  33. * @see null
  34. * @Copyright 湖南视拓信息技术股份有限公司. All rights reserved.
  35. */
  36. @RestController
  37. @RequestMapping("/${api.version}/tmstruckreceiptresults")
  38. public class TmstruckReceiptResultController extends BaseRESTfulController {
  39. @Autowired
  40. ITmstruckReceiptResultService tmstruckReceiptResultService;
  41. @Autowired
  42. TmstruckArrivalResultMapper tmstruckArrivalResultMapper;
  43. @Autowired
  44. TmstruckReceiptResultChildServiceImpl tmstruckReceiptResultChildService;
  45. @Autowired
  46. ESFeign esFeign;
  47. @Autowired
  48. ColumnDataUtil columnDataUtil;
  49. @Autowired
  50. ImageFileUtils imageFileUtils;
  51. private final SimpleDateFormat sdfDate = new SimpleDateFormat("yyyy-MM-dd");
  52. private final SimpleDateFormat sdfDateTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  53. // @ApiOperation(value="查询收货实绩")
  54. // @ApiImplicitParams({
  55. // @ApiImplicitParam(name = "mapValue", value = "表头和参数", required = false, dataType = "map"),
  56. // @ApiImplicitParam(name = "apiId(107)", value = "动态表头", required = false, dataType = "Integer"),
  57. // @ApiImplicitParam(name = "pageNum", value = "页码", required = false, dataType = "Integer"),
  58. // @ApiImplicitParam(name = "pageSize", value = "页", required = false, dataType = "Integer"),
  59. // @ApiImplicitParam(name = "status", value = "状态码", required = false, dataType = "Integer"),
  60. // })
  61. // @PostMapping("/getArrivalResult")
  62. // public RESTfulResult getArrivalResult(@RequestBody(required=false) Map<String,Object> mapValue,
  63. // Integer apiId,
  64. // Integer pageNum,
  65. // Integer pageSize,
  66. // Integer orderType,
  67. // String con
  68. // ){
  69. // mapValue.put("orderTypee", orderType);
  70. // PageHelper.startPage(pageNum,pageSize);
  71. // //分页数据
  72. // List<Map<String, Object>> receiveResult = tmstruckReceiptResultService.getReceiveResult(mapValue);
  73. // PageListAdd pageList = columnDataUtil.tableColumnData(apiId, null,receiveResult);
  74. // return success(pageList);
  75. // }
  76. @ApiOperation(value="新增钢材到异地库达州站驻港人员确定收货")
  77. @PostMapping("/addSteelNzReceiptResult")
  78. public RESTfulResult addSteelNzReceiptResult(@RequestBody(required = false) Map<String, Object> map) {
  79. int i = tmstruckReceiptResultService.addSteelNzReceiptResult(map);
  80. return success(i);
  81. }
  82. /**
  83. * 新增收货实绩
  84. * @param map
  85. * @return
  86. */
  87. @ApiOperation(value="新增收货实绩")
  88. @ApiImplicitParams({
  89. @ApiImplicitParam(name = "map", value = "收货实绩map", required = false, dataType = "java.util.Map")
  90. })
  91. @PostMapping(value = "/addTmstruckReceiptResult")
  92. public RESTfulResult addTmstruckReceiptResult(@RequestBody(required = false) Map<String, Object> map){
  93. BigDecimal alreadyExistsArrivalResult = tmstruckArrivalResultMapper.alreadyExistsArrivalResult((String) map.get("orderNumber"));
  94. if(alreadyExistsArrivalResult!=null){
  95. TmstruckReceiptResult tmstruckReceiptResult = new TmstruckReceiptResult();
  96. //获取运输订单号和收货点地址
  97. String orderNumber = (String) map.get("orderNumber");
  98. String resultArrivalAddress = (String) map.get("resultArrivalAddress");
  99. //获取空货箱照片、已签字的送货单照片
  100. String resultEmptyContainerPhoto = (String) map.get("url1");
  101. String resultSignedNotePhoto = (String) map.get("url2");
  102. tmstruckReceiptResult.setResultArrivalAddress(resultArrivalAddress);
  103. tmstruckReceiptResult.setResultEmptyContainerPhoto(resultEmptyContainerPhoto);
  104. tmstruckReceiptResult.setResultSignedNotePhoto(resultSignedNotePhoto);
  105. if(map.containsKey("url3")){
  106. //如果有,获取客户签收单照片
  107. String resultReceiveNotePhoto = (String) map.get("url3");
  108. tmstruckReceiptResult.setResultReceiveNotePhoto(resultReceiveNotePhoto);
  109. }
  110. //新增收货实绩主表
  111. BigDecimal receiptResultId = tmstruckReceiptResultService.addTmstruckReceiptResult(orderNumber, tmstruckReceiptResult);
  112. //初始化收货实绩子表信息
  113. TmstruckReceiptResultChild tmstruckReceiptResultChild = new TmstruckReceiptResultChild();
  114. //关联收货实绩主表
  115. tmstruckReceiptResultChild.setReceiptResultId(receiptResultId);
  116. //如果有,获取最多三张其他照片
  117. if(map.containsKey("fourFiles")){
  118. List<String> fourFiles = (List<String>) map.get("fourFiles");
  119. if(fourFiles.size()==0){}
  120. else if(fourFiles.size()==1){
  121. tmstruckReceiptResultChild.setOtherPhoto1(fourFiles.get(0));
  122. }else if(fourFiles.size()==2){
  123. tmstruckReceiptResultChild.setOtherPhoto1(fourFiles.get(0));
  124. tmstruckReceiptResultChild.setOtherPhoto2(fourFiles.get(1));
  125. }else {
  126. tmstruckReceiptResultChild.setOtherPhoto1(fourFiles.get(0));
  127. tmstruckReceiptResultChild.setOtherPhoto2(fourFiles.get(1));
  128. tmstruckReceiptResultChild.setOtherPhoto3(fourFiles.get(2));
  129. }
  130. }
  131. //新增收货实绩子表
  132. int i = tmstruckReceiptResultChildService.addTmstruckReceiptResultChild(tmstruckReceiptResultChild);
  133. return success(i);
  134. }else{
  135. return success(4);
  136. }
  137. }
  138. @ApiOperation(value="展示抵达实绩信息")
  139. @ApiImplicitParams({
  140. @ApiImplicitParam(name = "apiId(470)", value = "表头", required = false, dataType = "Interger")
  141. })
  142. @PostMapping("/getArrivalResult")
  143. public RESTfulResult getArrivalResult(@RequestBody(required=false) Map<String, Object> mapValue,
  144. Integer apiId,
  145. Integer pageNum,
  146. Integer pageSize,
  147. String startTime,
  148. String endTime,
  149. String con){
  150. if (con != null && (con.equals("") || con.equals("undefined")) ) {
  151. con = null;
  152. }
  153. if (con != null && con.length() != 0) {
  154. mapValue.put("con","%" + con + "%");
  155. }
  156. DataChange.queryDataByDateTime(startTime, endTime, mapValue, sdfDateTime);
  157. PageHelper.startPage(pageNum,pageSize);
  158. List<Map<String, Object>> receiptResultInfo = tmstruckReceiptResultService.getReceiptResultInfo(mapValue);
  159. PageListAdd pageList = columnDataUtil.tableColumnData(apiId,null,receiptResultInfo);
  160. return success(pageList);
  161. }
  162. @ApiOperation(value = "获取抵达作业照片")
  163. @PostMapping("/getArrivalPhoto")
  164. public RESTfulResult getArrivalPhoto(@RequestParam String orderNumber){
  165. String receiptPhoto = tmstruckReceiptResultService.getReceiptPhoto(orderNumber);
  166. String photo =null;
  167. try {
  168. photo = imageFileUtils.downloadFile(receiptPhoto).toString();
  169. } catch (Exception e) {
  170. e.printStackTrace();
  171. }
  172. return success(photo);
  173. }
  174. @ApiOperation(value="展示收货实绩信息")
  175. @ApiImplicitParams({
  176. @ApiImplicitParam(name = "apiId(470)", value = "表头", required = false, dataType = "Interger")
  177. })
  178. @PostMapping("/getReceivingResult")
  179. public RESTfulResult getReceivingResult(@RequestBody(required=false) Map<String, Object> mapValue,
  180. Integer apiId,
  181. Integer pageNum,
  182. Integer pageSize,
  183. String startTime,
  184. String endTime,
  185. String con){
  186. if (con != null && (con.equals("") || con.equals("undefined")) ) {
  187. con = null;
  188. }
  189. if (con != null && con.length() != 0) {
  190. mapValue.put("con","%" + con + "%");
  191. }
  192. DataChange.queryDataByDateTime(startTime, endTime, mapValue, sdfDateTime);
  193. PageHelper.startPage(pageNum,pageSize);
  194. List<Map<String, Object>> receiptResultInfo = tmstruckReceiptResultService.getReceivingResult(mapValue);
  195. PageListAdd pageList = columnDataUtil.tableColumnData(apiId,null,receiptResultInfo);
  196. return success(pageList);
  197. }
  198. @ApiOperation(value = "获取收货作业照片")
  199. @PostMapping("/getReceivingPhoto")
  200. public RESTfulResult getReceivingPhoto(@RequestParam String orderNumber) throws Exception {
  201. List<Map<String,Object>> mapList = tmstruckReceiptResultService.getReceivingPhoto(orderNumber);
  202. Map<String,Object> result=new HashMap<>();
  203. for(Map<String,Object> map:mapList){
  204. if(map.containsKey("resultEmptyContainerPhoto") && map.get("resultEmptyContainerPhoto")!=null){
  205. String resultEmptyContainerPhoto = (String) imageFileUtils.downloadFile(map.get("resultEmptyContainerPhoto").toString());
  206. result.put("resultEmptyContainerPhoto",resultEmptyContainerPhoto);
  207. }
  208. if(map.containsKey("resultSignedNotePhoto") && map.get("resultSignedNotePhoto")!=null){
  209. String resultSignedNotePhoto = (String) imageFileUtils.downloadFile(map.get("resultSignedNotePhoto").toString());
  210. result.put("resultSignedNotePhoto",resultSignedNotePhoto);
  211. }
  212. //追加的图片
  213. if(map.containsKey("otherPhoto1") && map.get("otherPhoto1")!=null){
  214. String resultSignedNotePhoto =(String) imageFileUtils.downloadFile(map.get("otherPhoto1").toString());
  215. result.put("otherPhoto1",resultSignedNotePhoto);
  216. }
  217. if(map.containsKey("otherPhoto2") && map.get("otherPhoto2") !=null){
  218. String resultSignedNotePhoto =(String) imageFileUtils.downloadFile(map.get("otherPhoto2").toString());
  219. result.put("otherPhoto2",resultSignedNotePhoto);
  220. }
  221. if(map.containsKey("otherPhoto3") && map.get("otherPhoto3") !=null){
  222. String resultSignedNotePhoto =(String) imageFileUtils.downloadFile(map.get("otherPhoto3").toString());
  223. result.put("otherPhoto3",resultSignedNotePhoto);
  224. }
  225. }
  226. return success(result);
  227. }
  228. @ApiOperation(value = "获取收货作业照片")
  229. @PostMapping("/getReceivingPhotoByUrl")
  230. public Map<String,Object> getReceivingPhotoByUrl(@RequestParam String orderNumber) throws Exception {
  231. List<Map<String,Object>> mapList = tmstruckReceiptResultService.getReceivingPhoto(orderNumber);
  232. Map<String,Object> mapvalue = null;
  233. if (mapList!=null && mapList.size()>0){
  234. //必选的图片
  235. mapvalue=mapList.get(0);
  236. //追加的三张图片
  237. if(mapList.get(1)!=null){
  238. mapvalue.putAll(mapList.get(1));
  239. }
  240. }
  241. return mapvalue;
  242. }
  243. }