ExpenseAccountController.java 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  1. package com.goafanti.expenseAccount.controller;
  2. import com.goafanti.common.bo.Result;
  3. import com.goafanti.common.constant.ErrorConstants;
  4. import com.goafanti.common.controller.CertifyApiController;
  5. import com.goafanti.common.utils.ParamUtils;
  6. import com.goafanti.common.utils.excel.NewExcelUtil;
  7. import com.goafanti.core.shiro.token.TokenManager;
  8. import com.goafanti.expenseAccount.bo.*;
  9. import com.goafanti.expenseAccount.service.ExpenseAccountService;
  10. import org.springframework.beans.factory.annotation.Autowired;
  11. import org.springframework.beans.factory.annotation.Value;
  12. import org.springframework.validation.BindingResult;
  13. import org.springframework.validation.annotation.Validated;
  14. import org.springframework.web.bind.annotation.RequestMapping;
  15. import org.springframework.web.bind.annotation.RequestMethod;
  16. import org.springframework.web.bind.annotation.RestController;
  17. import java.util.List;
  18. @RestController
  19. @RequestMapping("/api/admin/expenseAccount")
  20. public class ExpenseAccountController extends CertifyApiController {
  21. @Autowired
  22. private ExpenseAccountService expenseAccountService;
  23. @Value(value = "${upload.path}")
  24. private final String uploadPath = null;
  25. /**
  26. * 新增私有报销帐号
  27. * @param in
  28. * @return
  29. */
  30. @RequestMapping(value = "/add",method = RequestMethod.POST)
  31. public Result add(@Validated InputExpenseAccount in , BindingResult bindingResult){
  32. Result res =new Result();
  33. if (bindingResult.hasErrors()) {
  34. String param=bindingResult.getFieldError().getField();
  35. res.getError().add(buildError(ParamUtils.getParamMsg(in,param),ParamUtils.getParamName(in,param)));
  36. return res;
  37. }
  38. in.setAid(TokenManager.getAdminId());
  39. res.setData(expenseAccountService.add(in));
  40. return res;
  41. }
  42. /**
  43. * 新增私有报销帐号
  44. * @param in updateType=1时,作为修改类型。会删除所有子项
  45. * @return
  46. */
  47. @RequestMapping(value = "/update",method = RequestMethod.POST)
  48. public Result update( InputExpenseAccount in ){
  49. Result res =new Result();
  50. in.setAid(TokenManager.getAdminId());
  51. //只修改状态
  52. if (in.getUpdateType()==1){
  53. res.setData(expenseAccountService.updateType(in));
  54. }else {
  55. //抵扣单借支单必须指定
  56. if (in.getType()==5){
  57. if (in.getDebitId()==null){
  58. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"抵扣单借支单"));
  59. return res;
  60. }
  61. //不是第三方付款和抵扣的时候必须选择报销帐号
  62. }
  63. // else if (in.getType()!=3&&in.getType()!=5){
  64. // if (in.getEaaid()==null){
  65. // res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"报销帐号"));
  66. // return res;
  67. // }
  68. // }
  69. res.setData(expenseAccountService.update(in));
  70. }
  71. return res;
  72. }
  73. /**
  74. * 报销列表
  75. * @param in
  76. * @return
  77. */
  78. @RequestMapping(value = "/pageList",method = RequestMethod.GET)
  79. public Result pageList(InputPageListBo in ){
  80. Result res =new Result();
  81. res.setData(expenseAccountService.pageList(in));
  82. return res;
  83. }
  84. /**
  85. * 判断当前是否存在草稿
  86. * @param in
  87. * @return
  88. */
  89. @RequestMapping(value = "/selectByPrid",method = RequestMethod.GET)
  90. public Result selectByPrid(InputExpenseAccount in ){
  91. Result res =new Result();
  92. res.setData(expenseAccountService.selectByPrid(in));
  93. return res;
  94. }
  95. /**
  96. * 报销列表
  97. * @param id
  98. * @return
  99. */
  100. @RequestMapping(value = "/selectById",method = RequestMethod.GET)
  101. public Result selectById(Integer id ){
  102. Result res =new Result();
  103. res.setData(expenseAccountService.selectById(id));
  104. return res;
  105. }
  106. /**
  107. * 报销列表
  108. * @param checkNo
  109. * @return
  110. */
  111. @RequestMapping(value = "/selectByCheckNo",method = RequestMethod.GET)
  112. public Result selectByCheckNo(String checkNo ){
  113. Result res =new Result();
  114. res.setData(expenseAccountService.selectByCheckNo(checkNo));
  115. return res;
  116. }
  117. /**
  118. * 新增报销详情
  119. * @param in
  120. * @return
  121. */
  122. @RequestMapping(value = "/details/add",method = RequestMethod.POST)
  123. public Result addDetails(@Validated InputExpenseAccountDetails in , BindingResult bindingResult){
  124. Result res =new Result();
  125. if (bindingResult.hasErrors()) {
  126. String param=bindingResult.getFieldError().getField();
  127. System.out.println(param);
  128. res.getError().add(buildError(ParamUtils.getParamMsg(in,param),ParamUtils.getParamName(in,param)));
  129. return res;
  130. }
  131. res.setData(expenseAccountService.addDetails(in));
  132. return res;
  133. }
  134. /**
  135. * 删除报销详情
  136. * @param id
  137. * @return
  138. */
  139. @RequestMapping(value = "/details/delete",method = RequestMethod.GET)
  140. public Result deleteDetails(Integer id){
  141. Result res =new Result();
  142. res.setData(expenseAccountService.deleteDetails(id));
  143. return res;
  144. }
  145. /**
  146. * 删除报销详情
  147. * @param eaid
  148. * @return
  149. */
  150. @RequestMapping(value = "/details/list",method = RequestMethod.GET)
  151. public Result detailsList(Integer eaid){
  152. Result res =new Result();
  153. res.setData(expenseAccountService.detailsList(eaid));
  154. return res;
  155. }
  156. @RequestMapping(value = "/log/list",method = RequestMethod.GET)
  157. public Result logList(Integer eaid){
  158. Result res =new Result();
  159. if (eaid==null){
  160. res.getError().add(buildErrorMessageParams(ErrorConstants.PARAM_EMPTY_ERROR,"报销编号"));
  161. return res;
  162. }
  163. res.setData(expenseAccountService.logList(eaid));
  164. return res;
  165. }
  166. /**
  167. * 报销审核
  168. * @param in
  169. * @param bindingResult
  170. * @return
  171. */
  172. @RequestMapping(value = "/examine",method = RequestMethod.POST)
  173. public Result examine(InputExpenseAccount in,BindingResult bindingResult){
  174. Result res =new Result();
  175. if (bindingResult.hasErrors()) {
  176. String param=bindingResult.getFieldError().getField();
  177. res.getError().add(buildError(ParamUtils.getParamMsg(in,param),ParamUtils.getParamName(in,param)));
  178. return res;
  179. }
  180. res.setData(expenseAccountService.updateExamine(in));
  181. return res;
  182. }
  183. /**
  184. * 获取借支列表
  185. * @return
  186. */
  187. @RequestMapping(value = "/selectDebitOrder",method = RequestMethod.GET)
  188. public Result selectDebitOrder(String depId,Integer id){
  189. Result res=new Result();
  190. if (depId==null){
  191. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"抵扣部门"));
  192. return res;
  193. }
  194. res.setData(expenseAccountService.selectDebitOrder(depId,id));
  195. return res;
  196. }
  197. /**
  198. * 获取后台统计数据
  199. * @return
  200. */
  201. @RequestMapping(value = "/statistics",method = RequestMethod.GET)
  202. public Result statistics(String name,String depId,String startTime,String endTime){
  203. Result res=new Result();
  204. res.setData(expenseAccountService.statistics( name, depId, startTime, endTime));
  205. return res;
  206. }
  207. @RequestMapping(value = "/statistics/evict",method = RequestMethod.GET)
  208. public Result statisticsEvict(String name,String depId,String startTime,String endTime){
  209. Result res=new Result();
  210. expenseAccountService.statisticsEvict( name, depId, startTime, endTime);
  211. return res.data(1);
  212. }
  213. /**
  214. * 获取后台统计数据
  215. * @return
  216. */
  217. @RequestMapping(value = "/statistics/export",method = RequestMethod.GET)
  218. public Result statisticsExport(String name,String depId,String startTime,String endTime){
  219. List<OutExpenseAccountStatistics> list = expenseAccountService.statistics( name, depId, startTime, endTime);
  220. NewExcelUtil<OutExpenseAccountStatistics> newExcelUtil=new NewExcelUtil<>(OutExpenseAccountStatistics.class);
  221. return newExcelUtil.exportExcel(list,"报销统计",uploadPath);
  222. }
  223. @RequestMapping(value = "/merge",method = RequestMethod.GET)
  224. public Result merge(String ids){
  225. Result res =new Result();
  226. if (ids==null){
  227. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"合并编号"));
  228. return res;
  229. }
  230. return res.data(expenseAccountService.pushMerge(ids));
  231. }
  232. /**
  233. * 主报销详情
  234. * @param id
  235. * @return
  236. */
  237. @RequestMapping(value = "/mainExpense",method = RequestMethod.GET)
  238. public Result mainExpense(Integer id){
  239. Result res =new Result();
  240. if (id==null){
  241. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"合并编号"));
  242. return res;
  243. }
  244. return res.data(expenseAccountService.mainExpense(id));
  245. }
  246. /**
  247. * 修改主报销
  248. * @param in
  249. * @return
  250. */
  251. @RequestMapping(value = "/updateMain",method = RequestMethod.GET)
  252. public Result updateMain(MainExpenseAccount in){
  253. Result res =new Result();
  254. if (in.getId()==null){
  255. res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"编号"));
  256. return res;
  257. }
  258. return res.data(expenseAccountService.updateMain(in));
  259. }
  260. }