AreaManagerController.java 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372
  1. package platform.modules.government.web;
  2. import com.github.pagehelper.PageInfo;
  3. import org.springframework.beans.factory.annotation.Autowired;
  4. import org.springframework.beans.factory.annotation.Value;
  5. import org.springframework.stereotype.Controller;
  6. import org.springframework.ui.ModelMap;
  7. import org.springframework.util.CollectionUtils;
  8. import org.springframework.web.bind.annotation.*;
  9. import org.springframework.web.multipart.MultipartFile;
  10. import platform.common.Constant;
  11. import platform.common.annotation.OperationLog;
  12. import platform.common.base.controller.BaseController;
  13. import platform.common.base.service.DictionaryItemService;
  14. import platform.common.exception.BaseException;
  15. import platform.common.util.ShiroUtils;
  16. import platform.modules.build.entity.Company;
  17. import platform.modules.build.entity.CompanyContact;
  18. import platform.modules.build.service.CompanyContactService;
  19. import platform.modules.build.service.CompanyService;
  20. import platform.modules.carrier.entity.Contract;
  21. import platform.modules.carrier.service.IcContractService;
  22. import platform.modules.carrier.service.ParkService;
  23. import platform.modules.company.dto.ProcessNodeDto;
  24. import platform.modules.company.dto.StockLandApprovalDto;
  25. import platform.modules.company.entity.*;
  26. import platform.modules.company.service.*;
  27. import platform.modules.government.dto.SearchCondition;
  28. import platform.modules.government.entity.FileDown;
  29. import platform.modules.sys.entity.Approval;
  30. import platform.modules.sys.entity.Group;
  31. import platform.modules.sys.entity.UserGroup;
  32. import platform.modules.sys.service.ApprovalService;
  33. import platform.modules.sys.service.GroupService;
  34. import platform.modules.sys.service.UserGroupService;
  35. import platform.modules.sys.web.ResponseMessage;
  36. import javax.servlet.http.HttpServletRequest;
  37. import java.io.Serializable;
  38. import java.util.Arrays;
  39. import java.util.List;
  40. import java.util.Objects;
  41. /**
  42. * @author jiangjz
  43. * @ClassName: AreaMangerController
  44. * @Description: TODO(存量用地)
  45. * @date 2018年3月21日 上午11:17:43
  46. */
  47. @Controller
  48. @RequestMapping("/areaManager/")
  49. public class AreaManagerController extends BaseController {
  50. @Autowired
  51. private StockLandService stockLandService;
  52. @Autowired
  53. private StockLandMaterialService stockLandMaterialService;
  54. @Autowired
  55. CompanyService companyService;
  56. @Autowired
  57. ApprovalService approvalService;
  58. @Autowired
  59. ProcessFeedbackService processFeedbackService;
  60. @Autowired
  61. private CompanyContactService companyContactService;
  62. @Autowired
  63. private GroupService groupService;
  64. @Autowired
  65. private UserGroupService userGroupService;
  66. @Autowired
  67. private StockLandApproveService stockLandApproveService;
  68. @Autowired
  69. private ProjectApplicationCompanyInfoService projectApplicationCompanyInfoService;
  70. @Autowired
  71. private DictionaryItemService dictionaryItemService;
  72. @Autowired
  73. private ParkService parkService;
  74. @Autowired
  75. private IcContractService icContractService;
  76. @Autowired
  77. private StockLandOutParkService stockLandOutParkService;
  78. @Value("${repositoryPath}")
  79. private String baseFolderPath;
  80. /**
  81. * @param @return
  82. * @return String 返回类型
  83. * @Title: index
  84. * @Description: TODO(待审核页面)
  85. * @author jiangjz
  86. */
  87. @OperationLog(value = "查看存量用地审核列表")
  88. @RequestMapping("index")
  89. public String index(@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum, SearchCondition condition, StockLand searchCondition, String keyword, ModelMap modelMap) {
  90. try {
  91. PageInfo<StockLand> pageInfo = stockLandService.findPageInfo(pageNum, PAGESIZE, condition);
  92. modelMap.put("pageInfo", pageInfo);
  93. modelMap.put("searchCondition", searchCondition == null ? new StockLand() : searchCondition);
  94. modelMap.put("keyword", keyword);
  95. stockLandService.getDictInfo(modelMap);
  96. } catch (Exception e) {
  97. e.printStackTrace();
  98. }
  99. return "/admin/government/areaManager/index";
  100. }
  101. /**
  102. * @param @param id
  103. * @param @param modelMap
  104. * @param @return
  105. * @return String 返回类型
  106. * @Title: details
  107. * @Description: TODO(待审核详情)
  108. * @author jiangjz
  109. */
  110. @OperationLog(value = "查看存量用地审核详情")
  111. @RequestMapping("details")
  112. public String details(@RequestParam(value = "id", defaultValue = "") Integer id, ModelMap modelMap) {
  113. StockLand landApply = stockLandService.findLandApplyById(id);
  114. modelMap.put("landApply", landApply);
  115. stockLandMaterialService.getApplyMaterials(landApply, modelMap);
  116. modelMap.put("fileUrl", setFileUrl());
  117. /*List<ProcessNodeDto> processNodes = stockLandService.getProcessNodes(landApply, false);
  118. modelMap.put("processNodesList", processNodes);*/
  119. /*Integer companyId = landApply.getCompany_id();
  120. Company companyInfo = new Company();
  121. if (null != companyId) {
  122. companyInfo = companyService.findById(companyId);
  123. }*/
  124. List<Approval> approvalList = approvalService.getApprovalList(id);
  125. //流程信息
  126. modelMap.put("approvalList", approvalList);
  127. //企业信息
  128. ProjectApplicationCompanyInfo companyInfo = projectApplicationCompanyInfoService.findByApplyIdAndType(id, Constant.DictionaryType.STOCKLAND);
  129. if (companyInfo == null) {
  130. Company company = companyService.getCompanyInfo(landApply.getCompany_id());
  131. if (Objects.equals(company.getIndustry_code(), "Empty")) {
  132. company.setIndustry_code(company.getIndustry_name());
  133. } else {
  134. company.setIndustry_code(dictionaryItemService.findNameByTypeAndValue(Constant.DictionaryType.INDUSTRY_TYPE, company.getIndustry_code()));
  135. }
  136. modelMap.put("companyInfo", company);
  137. } else {
  138. if (Objects.equals(companyInfo.getIndustry_code(), "Empty")) {
  139. companyInfo.setIndustry_code(companyInfo.getIndustry_name());
  140. } else {
  141. companyInfo.setIndustry_code(dictionaryItemService.findNameByTypeAndValue(Constant.DictionaryType.INDUSTRY_TYPE, companyInfo.getIndustry_code()));
  142. }
  143. modelMap.put("companyInfo", companyInfo);
  144. }
  145. //modelMap.put("companyInfo", companyInfo == null ? new Company() : companyInfo);
  146. //工作小组可以看到进程反馈
  147. if (Arrays.asList(stockLandService.findUserIdByGroupName(Constant.XTGZXZ).split(",")).contains(String.valueOf(ShiroUtils.getUserId()))) {
  148. List<ProcessFeedback> feedbackList = processFeedbackService.findFeedbacksByTypeAndApplyId(Constant.DictionaryType.STOCKLAND, id);
  149. modelMap.put("feedbackList", feedbackList); //进程反馈信息
  150. }
  151. //判断登录人是否协调工作小组的人 是就显示打印按钮
  152. int currentId = ShiroUtils.getUserId();
  153. Group group = groupService.findByName(Constant.GroupName.UNITEDWORKGROUP, null);
  154. List<UserGroup> userGroups = userGroupService.findByGroupId(group.getId());
  155. StringBuffer sb = new StringBuffer("");
  156. for (UserGroup userGroup : userGroups) {
  157. if (Objects.equals(userGroup.getUser_id(), currentId)) {
  158. modelMap.put("isGroup", "1");
  159. }
  160. }
  161. if (landApply.getApply_type().equals(Constant.LandApplyType.RENT)) {
  162. modelMap.put("isRent", true);
  163. //如果是租住管理 获取本街道的所有园区
  164. modelMap.put("parkList", parkService.findParkListByStreetId(ShiroUtils.getStreetId()));
  165. if (Objects.equals(landApply.getIs_in_park(), "1")) {
  166. Contract contract = icContractService.getDeatailById(landApply.getContract_id());
  167. if (contract == null) {
  168. modelMap.put("contract", new Contract());
  169. } else {
  170. modelMap.put("contract", contract);
  171. }
  172. } else if (Objects.equals(landApply.getIs_in_park(), "0")) {
  173. StockLandOutPark stockLandOutPark = stockLandOutParkService.findById(landApply.getContract_id());
  174. if (stockLandOutPark == null) {
  175. modelMap.put("stockLandOutPark", new StockLandOutPark());
  176. } else {
  177. modelMap.put("stockLandOutPark", stockLandOutPark);
  178. }
  179. }
  180. }
  181. return "/admin/government/areaManager/details";
  182. }
  183. /**
  184. * @param @param id
  185. * @param @param modelMap
  186. * @param @return
  187. * @return String 返回类型
  188. * @Title: details
  189. * @Description: TODO(待审核详情)
  190. * @author jiangjz
  191. */
  192. @OperationLog(value = "打印存量用地申请单据")
  193. @GetMapping(value = "print/{id}")
  194. public String print(@PathVariable("id") Integer id, ModelMap modelMap) {
  195. StockLand landApply = stockLandService.findLandApplyById(id);
  196. modelMap.put("landApply", landApply);
  197. Integer companyId = landApply.getCompany_id();
  198. /*Company companyInfo = new Company();
  199. if (null != companyId) {
  200. companyInfo = companyService.findById(companyId);
  201. }*/
  202. List<Approval> approvalList = approvalService.getApprovalList(id);
  203. //流程信息
  204. modelMap.put("approvalList", approvalList);
  205. //modelMap.put("companyInfo", companyInfo == null ? new Company() : companyInfo);
  206. //企业信息
  207. ProjectApplicationCompanyInfo companyInfo = projectApplicationCompanyInfoService.findByApplyIdAndType(id, Constant.DictionaryType.STOCKLAND);
  208. modelMap.put("companyInfo", companyInfo == null ? companyService.getCompanyInfo(landApply.getCompany_id()) : companyInfo);
  209. //工作小组可以看到进程反馈
  210. if (Arrays.asList(stockLandService.findUserIdByGroupName(Constant.XTGZXZ).split(",")).contains(ShiroUtils.getUserId())) {
  211. List<ProcessFeedback> feedbackList = processFeedbackService.findFeedbacksByTypeAndApplyId(Constant.DictionaryType.STOCKLAND, id);
  212. modelMap.put("feedbackList", feedbackList); //进程反馈信息
  213. }
  214. List<CompanyContact> contacts = companyContactService.findByCompanyId(companyId);
  215. CompanyContact contact = new CompanyContact();
  216. if (!CollectionUtils.isEmpty(contacts)) {
  217. contact = contacts.get(contacts.size() - 1);
  218. }
  219. modelMap.put("contact", contact);
  220. return "/admin/government/areaManager/print";
  221. }
  222. /**
  223. * @param @param id
  224. * @param @param modelMap
  225. * @param @return
  226. * @return String 返回类型
  227. * @Title: approval
  228. * @Description: TODO(审核页面)
  229. * @author jiangjz
  230. */
  231. @RequestMapping("approval")
  232. public String approval(@RequestParam(value = "id") int id, ModelMap modelMap) {
  233. StockLand landApply = stockLandService.findLandApplyById(id);
  234. modelMap.put("landApply", landApply);
  235. stockLandMaterialService.getApplyMaterials(landApply, modelMap);
  236. modelMap.put("fileUrl", setFileUrl());
  237. /*List<ProcessNodeDto> processNodes = stockLandService.getProcessNodes(landApply, false);
  238. modelMap.put("processNodesList", processNodes);*/
  239. Integer companyId = landApply.getCompany_id();
  240. /*Company companyInfo = new Company();
  241. if (null != companyId) {
  242. companyInfo = companyService.findById(companyId);
  243. }*/
  244. List<Approval> approvalList = approvalService.getApprovalList(id);
  245. //流程信息
  246. modelMap.put("approvalList", approvalList);
  247. //modelMap.put("companyInfo", companyInfo == null ? new Company() : companyInfo);
  248. //企业信息
  249. ProjectApplicationCompanyInfo companyInfo = projectApplicationCompanyInfoService.findByApplyIdAndType(id, Constant.DictionaryType.STOCKLAND);
  250. if (companyInfo == null) {
  251. Company company = companyService.getCompanyInfo(landApply.getCompany_id());
  252. if (Objects.equals(company.getIndustry_code(), "Empty")) {
  253. company.setIndustry_code(company.getIndustry_name());
  254. } else {
  255. company.setIndustry_code(dictionaryItemService.findNameByTypeAndValue(Constant.DictionaryType.INDUSTRY_TYPE, company.getIndustry_code()));
  256. }
  257. modelMap.put("companyInfo", company);
  258. } else {
  259. if (Objects.equals(companyInfo.getIndustry_code(), "Empty")) {
  260. companyInfo.setIndustry_code(companyInfo.getIndustry_name());
  261. } else {
  262. companyInfo.setIndustry_code(dictionaryItemService.findNameByTypeAndValue(Constant.DictionaryType.INDUSTRY_TYPE, companyInfo.getIndustry_code()));
  263. }
  264. modelMap.put("companyInfo", companyInfo);
  265. }
  266. //工作小组可以看到进程反馈
  267. if (Arrays.asList(stockLandService.findUserIdByGroupName(Constant.XTGZXZ).split(",")).contains(ShiroUtils.getUserId())) {
  268. List<ProcessFeedback> feedbackList = processFeedbackService.findFeedbacksByTypeAndApplyId(Constant.DictionaryType.STOCKLAND, id);
  269. modelMap.put("feedbackList", feedbackList); //进程反馈信息
  270. }
  271. return "/admin/government/areaManager/approval";
  272. }
  273. /**
  274. * 提交
  275. *
  276. * @param approval
  277. * @param apply_type
  278. * @param apply
  279. * @return
  280. */
  281. @OperationLog(value = "审核存量用地申请")
  282. @ResponseBody
  283. @RequestMapping("submit")
  284. public ResponseMessage submit(StockLandApprovalDto approval, Integer apply_type, StockLand apply, String departmentIds) {
  285. try {
  286. if (IsTooFrequently()) {
  287. return ResponseMessage.error("操作过于频繁,请稍后再试!");
  288. }
  289. //判断当前是否是审核人
  290. if (!stockLandApproveService.isCurrChecker(approval.getApply_id(), approval)) {
  291. return ResponseMessage.error("用户不是单据当前审核人!单据已被审核或撤回!");
  292. }
  293. return stockLandService.submit(approval, apply_type, apply, departmentIds);
  294. } catch (BaseException e) {
  295. e.printStackTrace();
  296. return ResponseMessage.error(e.getMessage());
  297. } catch (Exception e) {
  298. e.printStackTrace();
  299. return ResponseMessage.error("审核失败!");
  300. }
  301. }
  302. /**
  303. * 附件上传
  304. *
  305. * @param file
  306. * @param id
  307. * @return
  308. */
  309. @ResponseBody
  310. @RequestMapping("fileUpload")
  311. public Serializable fileUpload(@RequestParam(value = "files", required = false) MultipartFile file, int id) {
  312. try {
  313. stockLandService.fileUpload(id, file, baseFolderPath);
  314. return ResponseMessage.success("上传文件成功!");
  315. } catch (Exception e) {
  316. e.printStackTrace();
  317. return ResponseMessage.error("上传文件失败!");
  318. }
  319. }
  320. /*************************************************待审核结束********************************************************/
  321. /*************************************************已审核开始********************************************************/
  322. @OperationLog(value = "查看存量用地审核列表")
  323. @RequestMapping(value = "index1")
  324. public String index1(@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum, SearchCondition condition, StockLand searchCondition, String keyword, ModelMap modelMap) {
  325. PageInfo<StockLand> pageInfo = stockLandService.findApprovalPageInfo(pageNum, PAGESIZE, condition);
  326. modelMap.put("searchCondition", new StockLand());
  327. stockLandService.getDictInfo(modelMap);
  328. modelMap.put("pageInfo", pageInfo);
  329. modelMap.put("keyword", keyword);
  330. modelMap.put("searchCondition", searchCondition == null ? new StockLand() : searchCondition);
  331. return "/admin/government/areaManager/index1";
  332. }
  333. }