NoCarController.java 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. package com.jkcredit.invoice.controller.localBussiness;
  2. import cn.afterturn.easypoi.excel.ExcelImportUtil;
  3. import cn.afterturn.easypoi.excel.entity.ImportParams;
  4. import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
  5. import com.jkcredit.invoice.annotation.LoginRequired;
  6. import com.jkcredit.invoice.mapper.waybill.NoCarWaybillMapper;
  7. import com.jkcredit.invoice.model.entity.Calculate.NoCarCalculateInfor;
  8. import com.jkcredit.invoice.model.entity.customer.CustomerCarRec;
  9. import com.jkcredit.invoice.model.entity.invoice.BillInvoice;
  10. import com.jkcredit.invoice.model.entity.waybill.NoCarWayBill;
  11. import com.jkcredit.invoice.service.CalculateInfor.NoCarCalculateInfoService;
  12. import com.jkcredit.invoice.service.lowerService.NoCarService;
  13. import com.jkcredit.invoice.service.nocar.NoCarBillWayService;
  14. import com.jkcredit.invoice.service.nocar.NoCarRecService;
  15. import com.jkcredit.invoice.service.nocar.NocarInvoiceService;
  16. import com.jkcredit.invoice.util.ReadExcelUtil;
  17. import com.jkcredit.invoice.util.RespR;
  18. import io.swagger.annotations.Api;
  19. import io.swagger.annotations.ApiOperation;
  20. import org.springframework.beans.factory.annotation.Autowired;
  21. import org.springframework.util.StringUtils;
  22. import org.springframework.web.bind.annotation.PostMapping;
  23. import org.springframework.web.bind.annotation.RequestMapping;
  24. import org.springframework.web.bind.annotation.RequestParam;
  25. import org.springframework.web.bind.annotation.RestController;
  26. import org.springframework.web.multipart.MultipartFile;
  27. import java.io.File;
  28. import java.util.List;
  29. @Api(tags = "无车操作")
  30. @RestController
  31. @RequestMapping(value = {"/noCar"})
  32. public class NoCarController {
  33. @Autowired
  34. NoCarRecService noCarRecService;
  35. @Autowired
  36. NoCarBillWayService noCarBillWayService;
  37. @Autowired
  38. NocarInvoiceService nocarInvoiceService;
  39. @Autowired
  40. NoCarCalculateInfoService noCarCalculateInfoService;
  41. @Autowired
  42. NoCarWaybillMapper noCarWaybillMapper;
  43. @Autowired
  44. NoCarService noCarService;
  45. /**
  46. * 分页查询无车备案信息
  47. *
  48. * @param page 参数集
  49. * @return 用户集合
  50. */
  51. @PostMapping("/findCarRec")
  52. @ApiOperation(value="分页查询无车/自有车备案信息", notes="分页查询无车/自有车备案信息")
  53. @LoginRequired
  54. public RespR getCustomersByPage(Page page, CustomerCarRec customerCarRec) {
  55. try {
  56. RespR respR = new RespR(noCarRecService.findByPageAndCarRec(page, customerCarRec));
  57. return respR;
  58. }catch (Exception e){
  59. e.printStackTrace();
  60. return new RespR(false,e.getMessage());
  61. }
  62. }
  63. public void setTimeDue(NoCarWayBill noCarWayBill){
  64. if(!StringUtils.isEmpty(noCarWayBill.getStartBegin()) && !"null".equals(noCarWayBill.getStartBegin())){
  65. String [] res = noCarWayBill.getStartBegin().split(",");
  66. noCarWayBill.setStartBegin(res[0]);
  67. noCarWayBill.setStartEnd(res[1]);
  68. }else{
  69. noCarWayBill.setStartBegin(null);
  70. }
  71. if(!StringUtils.isEmpty(noCarWayBill.getEndBegin()) && !"null".equals(noCarWayBill.getEndBegin())){
  72. String [] res = noCarWayBill.getEndBegin().split(",");
  73. noCarWayBill.setEndBegin(res[0]);
  74. noCarWayBill.setEndEnd(res[1]);
  75. }else{
  76. noCarWayBill.setEndBegin(null);
  77. }
  78. }
  79. /**
  80. * 分页查询运单信息
  81. *
  82. * @param page 参数集
  83. * @return 用户集合
  84. */
  85. @PostMapping("/findBillWay")
  86. @ApiOperation(value="分页查询无车运单信息", notes="分页查询无车运单信息")
  87. @LoginRequired
  88. public RespR findBillWay(Page page, NoCarWayBill noCarWayBill) {
  89. try {
  90. setTimeDue(noCarWayBill);
  91. RespR respR = new RespR(noCarBillWayService.findByPageAndWayBill(page, noCarWayBill));
  92. return respR;
  93. }catch (Exception e){
  94. e.printStackTrace();
  95. return new RespR(false,e.getMessage());
  96. }
  97. }
  98. /**
  99. * 重新获取发票并更新状态
  100. *
  101. * @return 用户集合
  102. */
  103. @PostMapping("/updateStatus")
  104. @ApiOperation(value="重新获取发票并更新状态", notes="重新获取发票并更新状态")
  105. @LoginRequired
  106. public RespR updateStatus() {
  107. try {
  108. delGetInvoce(0);
  109. delGetInvoce(1);
  110. return new RespR("更新成功");
  111. }catch (Exception e){
  112. e.printStackTrace();
  113. return new RespR(false,e.getMessage());
  114. }
  115. }
  116. public void delGetInvoce(Integer historyFlag){
  117. NoCarWayBill carWayBill = new NoCarWayBill();
  118. carWayBill.setHisFlag(historyFlag);
  119. carWayBill.setBillwayStatus(2);
  120. List<NoCarWayBill> noCarWayBillsMdEnd = noCarWaybillMapper.selectByHisFlagAndBillStatus(carWayBill);
  121. if(noCarWayBillsMdEnd!=null && noCarWayBillsMdEnd.size()>0){
  122. noCarWayBillsMdEnd.stream().forEach(noCarWayBill -> {
  123. noCarService.getInvoiceByWayBillNumReal(noCarWayBill,true);
  124. });
  125. }
  126. }
  127. /**
  128. * 分页查询异常运单信息
  129. *
  130. * @param page 参数集
  131. * @return 用户集合
  132. */
  133. @PostMapping("/findBillWayException")
  134. @ApiOperation(value="分页查询异常运单信息", notes="分页查询异常运单信息")
  135. @LoginRequired
  136. public RespR findBillWayException(Page page, NoCarWayBill noCarWayBill) {
  137. try {
  138. setTimeDue(noCarWayBill);
  139. RespR respR = new RespR(noCarBillWayService.findByPageAndWayBillException(page, noCarWayBill));
  140. return respR;
  141. }catch (Exception e){
  142. e.printStackTrace();
  143. return new RespR(false,e.getMessage());
  144. }
  145. }
  146. /**
  147. * 分页查询无车运单信息
  148. *
  149. * @param page 参数集
  150. * @return 用户集合
  151. */
  152. @PostMapping("/findNocarInvoices")
  153. @ApiOperation(value="分页查询无车发票信息", notes="分页查询无车发票信息")
  154. @LoginRequired
  155. public RespR findNocarInvoices(Page page, BillInvoice billInvoice) {
  156. try {
  157. if(!StringUtils.isEmpty(billInvoice.getInvoiceMakeTime()) && !"null".equals(billInvoice.getInvoiceMakeTime())){
  158. String [] res =billInvoice.getInvoiceMakeTime().split(",");
  159. billInvoice.setInvoiceMakeStart(res[0]);
  160. billInvoice.setInvoiceMakeEnd(res[1]);
  161. }
  162. RespR respR = new RespR(nocarInvoiceService.findByPageAndInvoice(page, billInvoice));
  163. return respR;
  164. }catch (Exception e){
  165. e.printStackTrace();
  166. return new RespR(false,e.getMessage());
  167. }
  168. }
  169. /**
  170. * 批量运单导入
  171. *
  172. * @param file 参数集
  173. * @return
  174. */
  175. @PostMapping("/batchImprotBillWay")
  176. @ApiOperation(value="批量运单导入", notes="批量运单导入")
  177. @LoginRequired
  178. public RespR batchImprotBillWay(@RequestParam("file") MultipartFile file) {
  179. try {
  180. ImportParams params = new ImportParams();
  181. params.setTitleRows(1);
  182. params.setHeadRows(1);
  183. params.setKeyIndex(1);
  184. List<NoCarWayBill> list = ExcelImportUtil.importExcel(file.getInputStream(), NoCarWayBill.class,params);
  185. RespR respR = noCarBillWayService.batchBillWayStart(list);
  186. return respR;
  187. }catch (Exception e){
  188. e.printStackTrace();
  189. return new RespR(false,e.getMessage());
  190. }
  191. }
  192. /**
  193. * 分页查询无车计费信息
  194. *
  195. * @param page 参数集
  196. * @return 用户集合
  197. */
  198. @PostMapping("/findNocarCalculateInfo")
  199. @ApiOperation(value="分页查询无车计费信息", notes="分页查询无车计费信息")
  200. @LoginRequired
  201. public RespR findNocarCalculateInfo(Page page, NoCarCalculateInfor carCalculateInfor) {
  202. try {
  203. setTimeDue1(carCalculateInfor);
  204. RespR respR = new RespR(noCarCalculateInfoService.findByPageAndCalculateInfor(page, carCalculateInfor));
  205. return respR;
  206. }catch (Exception e){
  207. e.printStackTrace();
  208. return new RespR(false,e.getMessage());
  209. }
  210. }
  211. public void setTimeDue1(NoCarCalculateInfor carCalculateInfor){
  212. if(!StringUtils.isEmpty(carCalculateInfor.getInvoiceMakeTime()) && !"null".equals(carCalculateInfor.getInvoiceMakeTime())){
  213. String [] res = carCalculateInfor.getInvoiceMakeTime().split(",");
  214. carCalculateInfor.setInvoiceMakeStart(res[0]);
  215. carCalculateInfor.setInvoiceMakeEnd(res[1]);
  216. }else{
  217. carCalculateInfor.setInvoiceMakeTime(null);
  218. }
  219. if(!StringUtils.isEmpty(carCalculateInfor.getCalculateTime()) && !"null".equals(carCalculateInfor.getCalculateTime())){
  220. String [] res = carCalculateInfor.getCalculateTime().split(",");
  221. carCalculateInfor.setCalculateStart(res[0]);
  222. carCalculateInfor.setCalculateEnd(res[1]);
  223. }else{
  224. carCalculateInfor.setCalculateTime(null);
  225. }
  226. }
  227. }