| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435 |
- package platform.modules.build.web;
- import com.github.pagehelper.PageInfo;
- import org.apache.commons.lang3.StringUtils;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Controller;
- import org.springframework.ui.ModelMap;
- import org.springframework.web.bind.annotation.*;
- import platform.common.Constant;
- import platform.common.annotation.OperationLog;
- import platform.common.base.controller.BaseController;
- import platform.common.base.model.DictionaryItem;
- import platform.common.base.service.DictionaryItemService;
- import platform.common.util.ShiroUtils;
- import platform.modules.build.DTO.CompanyDto;
- import platform.modules.build.DTO.CompanyFeeDto;
- import platform.modules.build.DTO.MaintenanceDto;
- import platform.modules.build.entity.BuildInfo;
- import platform.modules.build.entity.Company;
- import platform.modules.build.entity.Maintenance;
- import platform.modules.build.service.BuildInfoService;
- import platform.modules.build.service.CompanyContactService;
- import platform.modules.build.service.CompanyService;
- import platform.modules.build.service.MaintenanceService;
- import platform.modules.company.service.CompanyBuildingStreetService;
- import platform.modules.company.service.CompanyInfoManageService;
- import platform.modules.government.dto.NotifyDto;
- import platform.modules.government.entity.BuildType;
- import platform.modules.government.entity.Notify;
- import platform.modules.government.entity.Street;
- import platform.modules.government.entity.User;
- import platform.modules.government.service.BuildTypeService;
- import platform.modules.government.service.NotifyService;
- import platform.modules.government.service.StreetService;
- import platform.modules.government.service.UserService;
- import platform.modules.sys.web.ResponseMessage;
- import java.util.List;
- /**
- * 企业信息Controller
- *
- * @author lhf
- * @version 2017-10-26
- */
- @Controller
- @RequestMapping(value = "/build/company")
- public class CompanyController extends BaseController {
- @Autowired
- private CompanyService companyService;
- @Autowired
- private MaintenanceService maintenanceService;
- @Autowired
- private NotifyService notifyService;
- @Autowired
- private BuildTypeService buildTypeService;
- @Autowired
- private BuildInfoService buildInfoService;
- @Autowired
- private StreetService streetService;
- @Autowired
- private CompanyContactService companyContactService;
- @Autowired
- private CompanyBuildingStreetService companyBuildingStreetService;
- @Autowired
- private DictionaryItemService dictionaryItemService;
- @Autowired
- private UserService userService;
- @GetMapping(value = "/list")
- public String list(
- @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
- String keyword, ModelMap modelMap, String item_selected) throws Exception {
- try {
- log.debug("分页查询公司列表参数! pageNum = {}, keyword = {}", pageNum, keyword);
- PageInfo<Company> pageInfo = companyService.findPage(pageNum, PAGESIZE, keyword, null, new CompanyDto());
- log.info("分页查询公司列表结果! pageInfo = {}", pageInfo);
- modelMap.put("pageInfo", pageInfo);
- modelMap.put("keyword", keyword);
- modelMap.put("item_selected", item_selected);
- } catch (Exception e) {
- e.printStackTrace();
- }
- return BASE_BUILD_PATH + "company_list";
- }
- /**
- * 跳转到公司添加页面
- *
- * @return
- */
- @GetMapping(value = "/add")
- public String add(ModelMap modelMap) {
- modelMap.put("companyTypeList", buildTypeService.findList(Constant.DictType.COMPANY));
- log.info("跳转到公司添加页面!");
- return BASE_BUILD_PATH + "company_add";
- }
- /**
- * 添加公司
- *
- * @param content
- * @return
- */
- @OperationLog(value = "添加公司")
- @ResponseBody
- @PostMapping(value = "/save")
- public ModelMap saveCompany(Company content) throws Exception {
- ModelMap messagesMap = new ModelMap();
- if (IsTooFrequently()) {
- messagesMap.put("status", FAILURE);
- messagesMap.put("message", "操作过于频繁,请稍后再试!");
- return messagesMap;
- }
- log.debug("添加公司参数! content = {}", content);
- Boolean flag = companyService.saveCompany(content);
- if (flag) {
- log.info("添加公司成功! content = {}", content.getId());
- messagesMap.put("status", SUCCESS);
- messagesMap.put("message", "添加成功!");
- return messagesMap;
- }
- messagesMap.put("status", FAILURE);
- messagesMap.put("message", "添加失败!");
- return messagesMap;
- }
- /**
- * 跳转到公司编辑页面
- *
- * @return
- */
- @GetMapping(value = "/edit/{id}")
- public String edit(@PathVariable("id") int id, ModelMap modelMap) {
- Company company = companyService.findById(id);
- log.info("跳转到公司编辑页面!id = {}", id);
- modelMap.put("company", company);
- if (null != company) {
- company.setCompanyContacts(companyContactService.findByCompanyId(id));
- }
- modelMap.put("companyTypeList", buildTypeService.findList(Constant.DictType.COMPANY));
- return BASE_BUILD_PATH + "company_edit";
- }
- /**
- * 跳转到公司查看页面
- *
- * @return
- */
- @GetMapping(value = "/check/{id}")
- public String check(@PathVariable("id") int id, ModelMap modelMap) {
- Company company = companyService.findById(id);
- log.info("跳转到公司查看页面!id = {}", id);
- BuildType buildType = buildTypeService.findById(company.getType_id());
- if (null != buildType) {
- company.setType_name(buildType.getType());
- }
- if (null != company) {
- company.setCompanyContacts(companyContactService.findByCompanyId(id));
- }
- modelMap.put("company", company);
- return BASE_BUILD_PATH + "company_check";
- }
- /**
- * 更新公司信息
- *
- * @param id id
- * @return
- */
- @OperationLog(value = "编辑公司")
- @ResponseBody
- @PutMapping(value = "/updateCompany/{id}")
- public ResponseMessage updateCompany(@PathVariable("id") int id, Company content) throws Exception {
- ModelMap messagesMap = new ModelMap();
- log.debug("编辑公司参数! id= {}, content = {}", id, content);
- if (IsTooFrequently()) {
- return ResponseMessage.success("操作过于频繁,请稍后再试!");
- }
- Company u = companyService.findById(id);
- if (null == u) {
- log.info("编辑公司不存在! id = {}", id);
- return ResponseMessage.error("编辑公司不存在!");
- }
- Boolean flag = companyService.updateCompany(content);
- if (flag) {
- log.info("编辑公司成功! id= {}, content = {}", id, content);
- return ResponseMessage.success("编辑成功");
- }
- return ResponseMessage.error("编辑失败!");
- }
- /**
- * 批量删除
- *
- * @param ids
- * @return
- */
- @OperationLog(value = "批量删除")
- @ResponseBody
- @PutMapping(value = "/deleteBatch")
- public ResponseMessage deleteBatch(@RequestParam(value = "ids[]") String[] ids) throws Exception {
- if (null == ids) {
- log.info("批量删除公司不存在! ids = {}", ids);
- return ResponseMessage.success("批量删除公司不存在");
- }
- for (String id : ids) {
- Company company = new Company();
- company.setId(Integer.parseInt(id));
- company.setDel_flag(true);
- companyService.updateCompany(company);
- }
- return ResponseMessage.success("删除成功");
- }
- /**
- * 启用
- *
- * @param ids
- * @return
- */
- @OperationLog(value = "启用")
- @ResponseBody
- @PutMapping(value = "/startBatch")
- public ResponseMessage startBatch(@RequestParam(value = "ids[]") String[] ids) throws Exception {
- if (IsTooFrequently()) {
- return ResponseMessage.success("操作过于频繁,请稍后再试!");
- }
- if (null == ids) {
- log.info("批量启用公司不存在! ids = {}", ids);
- return ResponseMessage.success("批量启用公司不存在");
- }
- for (String id : ids) {
- Company company = new Company();
- company.setId(Integer.parseInt(id));
- company.setIs_start(true);
- companyService.updateSelective(company);
- }
- return ResponseMessage.success("启用成功");
- }
- /**
- * 禁用
- *
- * @param ids
- * @return
- */
- @OperationLog(value = "禁用")
- @ResponseBody
- @PutMapping(value = "/stopBatch")
- public ResponseMessage stopBatch(@RequestParam(value = "ids[]") String[] ids) throws Exception {
- if (IsTooFrequently()) {
- return ResponseMessage.success("操作过于频繁,请稍后再试!");
- }
- if (null == ids) {
- log.info("批量启用公司不存在! ids = {}", ids);
- return ResponseMessage.success("批量启用公司不存在");
- }
- for (String id : ids) {
- Company company = new Company();
- company.setId(Integer.parseInt(id));
- company.setIs_start(false);
- companyService.updateSelective(company);
- }
- return ResponseMessage.success("禁用成功");
- }
- /**
- * 检验公司名是否存在
- *
- * @param company_name
- * @return
- */
- @ResponseBody
- @GetMapping(value = "/isExist")
- public Boolean isExist(String company_name, String id) throws Exception {
- boolean flag = true;
- log.debug("检验公司名是否存在参数! id= {}, companyname= {}", id, company_name);
- Company record = companyService.findByCompanyName(company_name);
- if (null != record) {
- if (StringUtils.isBlank(id)) {
- flag = false;
- } else {
- if (record.getId() != (Integer.parseInt(id))) {
- flag = false;
- }
- }
- }
- log.info("检验公司名是否存在结果! flag = {}", flag);
- return flag;
- }
- /**
- * 企业PC端费用查询
- *
- * @param pageNum
- * @param modelMap
- * @return
- * @throws Exception
- */
- @GetMapping(value = "/feeList")
- public String feeList(
- @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
- String fee_type, String status, ModelMap modelMap) throws Exception {
- try {
- log.debug("分页查询公司列表参数! pageNum = {}, status = {}, fee_type = {}", pageNum, status, fee_type);
- PageInfo<CompanyFeeDto> pageInfo = companyService.findCompanyFeePage(pageNum, PAGESIZE, status, fee_type);
- log.info("分页查询公司列表结果! pageInfo = {}", pageInfo);
- modelMap.put("pageInfo", pageInfo);
- modelMap.put("fee_type", fee_type);
- modelMap.put("status", status);
- } catch (Exception e) {
- e.printStackTrace();
- }
- return BASE_BUILD_PATH + "company_fee_list";
- }
- /**
- * 企业PC端首页
- *
- * @param modelMap
- * @return
- */
- @GetMapping(value = "/index")
- public String index(ModelMap modelMap) {
- try {
- Integer company_id = ShiroUtils.getUserEntity().getCompany_id();
- //费用提醒,获取未缴费费用
- int feeCount = 5;
- CompanyFeeDto companyFeeDto = new CompanyFeeDto(company_id, feeCount, 0);
- List<CompanyFeeDto> feeList = companyService.findLatestCompnayFee(companyFeeDto);
- modelMap.put("feeList", feeList);
- //通知公告
- int notifyCount = 5;
- NotifyDto notifyDto = new NotifyDto();
- notifyDto.setCompany_id(company_id);
- notifyDto.setCount(notifyCount);
- // todo
- List<Notify> latestNotifyList = notifyService.findNotifyList(notifyDto);
- modelMap.put("latestNotifyList", latestNotifyList);
- //维修跟踪
- int maintenanceCount = 5;
- MaintenanceDto maintenanceDto = new MaintenanceDto(null, company_id, maintenanceCount);
- List<Maintenance> maintenanceList = maintenanceService.findLatestMaintenance(maintenanceDto);
- modelMap.put("maintenanceList", maintenanceList);
- } catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- return BASE_BUILD_PATH + "companyIndex";
- }
- /**
- * 企业PC端账号信息
- *
- * @param modelMap
- * @return
- */
- @GetMapping(value = "/companyInfo")
- public String companyInfo(ModelMap modelMap) {
- Integer company_id = ShiroUtils.getUserEntity().getCompany_id();
- Company company = companyService.findById(company_id);
- if (null != company) {
- if (null != company.getBuild_id()) {
- BuildInfo buildInfo = buildInfoService.findById(company.getBuild_id());
- if (null != buildInfo) {
- company.setBuild_name(buildInfo.getName());
- }
- }
- Street street = streetService.findById(company.getStreet_id());
- if (null != street) {
- company.setStreet_name(street.getName());
- }
- company.setCompanyContacts(companyContactService.findByCompanyId(company_id));
- company.setBuildingStreets(companyBuildingStreetService.findByCompanyId(company_id));
- }
- modelMap.put("company", company);
- List<Street> streetList = streetService.findList();
- modelMap.addAttribute("streetList", streetList);
- if (null != company.getStreet_id()) {
- modelMap.addAttribute("buildList", buildInfoService.findListByStreet(company.getStreet_id()));
- }
- //查询企业性质
- List<DictionaryItem> companyTypeList = dictionaryItemService.findListByTypeName(Constant.DictionaryType.COMPANY_TYPE);
- modelMap.put("companyTypeList", companyTypeList);
- //查询币种单位数据
- List<DictionaryItem> itemList = dictionaryItemService.findListByTypeName(Constant.DictionaryType.CURRENCY_UNIT);
- modelMap.put("itemList", itemList);
- //查询行业类型
- List<DictionaryItem> industryTypeList = dictionaryItemService.findListByTypeName(Constant.DictionaryType.INDUSTRY_TYPE);
- modelMap.put("industryTypeList", industryTypeList);
- User user = ShiroUtils.getUserEntity();
- user.setFist_login(2);
- userService.updateSelective(user);
- return BASE_BUILD_PATH + "companyInfo";
- }
- /**
- * 企业PC端用户账号信息
- *
- * @param modelMap
- * @return
- */
- @GetMapping(value = "/companyUserInfo")
- public String companyUserInfo(ModelMap modelMap) {
- User user = ShiroUtils.getUserEntity();
- modelMap.put("user", user);
- return BASE_COMPANY_PATH + "accountInfo/companyUserInfo";
- }
- }
|