package com.palmnest.webapp.controller.backstage;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.palmnest.application.AppConstants;
import com.palmnest.application.CodeConstants;
import com.palmnest.application.bean.AppResultDto;
import com.palmnest.application.bean.Page;
import com.palmnest.application.core.util.AppResultUtil;
import com.palmnest.application.core.util.PropertiesKit;
import com.palmnest.application.core.util.PushMessageHelper;
import com.palmnest.application.core.util.StringUtil;
import com.palmnest.application.dto.CommonDto;
import com.palmnest.application.dto.WebPageResultDto;
import com.palmnest.application.dto.input.EnterUpdateInputDto;
import com.palmnest.application.dto.output.EnterEvaluateDto;
import com.palmnest.application.dto.output.WatermenterDto;
import com.palmnest.model.EnterpriseAudit;
import com.palmnest.model.EnterpriseInfo;
import com.palmnest.model.User;
import com.palmnest.model.VirArchModel;
import com.palmnest.model.emig.BillOperationRecodes;
import com.palmnest.model.emig.EmigrationSettle;
import com.palmnest.model.estateserve.WxUser;
import com.palmnest.model.property.TbOrganization;
import com.palmnest.model.property.VirtualArchitecture;
import com.palmnest.service.OrganizationManager;
import com.palmnest.service.UserManager;
import com.palmnest.service.estateserve.*;
import com.palmnest.service.wechat.WeChatApiManager;
import com.palmnest.webapp.controller.BaseFormController;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ExtendedModelMap;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.InputStream;
import java.text.SimpleDateFormat;
import java.util.*;

/**
 * 企业入驻PC端控制器
 *
 * @author longmeizhen
 */
@Slf4j
@Controller
@RequestMapping(value = "/admin/enter/*")
public class EnterpriseController extends BaseFormController {

	@Autowired
	private VirArchModelManager         virArchModelManager;
	@Autowired
	private EnterpriseManager           enterpriseManager;
	@Autowired
	private WatermeterManager           watermeterManager;
	@Autowired
	private UserManager                 userManager;
	@Autowired
	private EnterpriseAuditManager      enterpriseAuditManager;
	@Autowired
	private OrganizationManager         organizationManager;
	@Autowired
	private EmigrationManager           emigrationManager;
	@Autowired
	private VirtUserManager             virtUserManager;
	@Autowired
	private ScWxuserManager             scWxuserManager;
	@Autowired
	private VirtualArchManager          virtualArchManager;
	@Autowired
	private BillOperationRecodesManager billOperationRecodesManager;
	@Autowired
	private WeChatApiManager            weChatApiManager;

	/**
	 * 访问企业入驻配置模板
	 *
	 * @param request
	 * @param response
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(value = "jumpVirModel")
	public ModelAndView jumpVirModel(HttpServletRequest request, HttpServletResponse response) throws Exception {
		Model                model            = new ExtendedModelMap();
		List<TbOrganization> organizationList = getUserRelationOrgList(request);
		model.addAttribute("orgs", organizationList);
		return new ModelAndView("admin/enter/enterSetting", model.asMap());
	}

	/**
	 * 获取企业入驻配置模板
	 *
	 * @param request
	 * @param response
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(value = "getVirModel")
	@ResponseBody
	public AppResultDto getVirModel(HttpServletRequest request, HttpServletResponse response) throws Exception {
		int  type = 0;
		User user = (User) request.getSession().getAttribute("UserCache");
		if (StringUtils.isNotEmpty(request.getParameter("type"))) {
			type = Integer.parseInt(request.getParameter("type"));
		}
		String orgId = request.getParameter("orgId");
		if (!StringUtil.isNotEmpty(orgId)) {
			orgId = getUserManageOrgIds(user);
		}
		List<VirArchModel> virModelList = virArchModelManager.getVirArchModelByType(type, orgId);
		return AppResultUtil.createSuccesDto(virModelList);
	}

	/**
	 * 保存修改企业入驻配置模板
	 *
	 * @param virArchModel
	 * @param request
	 * @param response
	 * @throws Exception
	 */
	@RequestMapping(value = "saveVirModel")
	@ResponseBody
	public AppResultDto saveVirModel(@ModelAttribute("virArchModel") VirArchModel virArchModel, HttpServletRequest request, HttpServletResponse response) throws Exception {
		JSONObject json    = new JSONObject();
		String     id      = request.getParameter("id");
		String     content = request.getParameter("content");
		String     type    = request.getParameter("type");
		String     orgId   = request.getParameter("orgId");
		if (virArchModel.getId() != null) {
			id = virArchModel.getId().toString();
			type = String.valueOf(virArchModel.getType());
			content = virArchModel.getContent();
		}
		if (StringUtils.isEmpty(type)) {
			return AppResultUtil.createErrorDto("100", "传输数据有误");
		} else {
			User user = (User) request.getSession().getAttribute("UserCache");//----------联调时需放开注释
			try {
				if (StringUtils.isNotEmpty(id)) {//修改企业入驻模板
					VirArchModel virModel = virArchModelManager.get(Integer.parseInt(id));
					virArchModel.setModifier(Integer.parseInt(user.getId().toString()));
					virArchModel.setModifyTime(new Date());
					virArchModel.setCreateTime(virModel.getCreateTime());
					virArchModel.setCreator(virModel.getCreator());
					virArchModel.setType(Integer.parseInt(type));
					virArchModel.setContent(content);
					virArchModel.setIsEnabled(virModel.getIsEnabled());
					virArchModelManager.updateModel(virArchModel);
				} else {//新增企业入驻模板
					virArchModel.setCreateTime(new Date());
					virArchModel.setCreator(Integer.parseInt(user.getId().toString()));
					virArchModel.setIsEnabled("1");
					virArchModel.setType(Integer.parseInt(type));
					virArchModel.setContent(content);
					virArchModel.setOrgId(Integer.parseInt(orgId));
					virArchModel = virArchModelManager.save(virArchModel);
				}
				return AppResultUtil.createSuccesDto(virArchModel);
			} catch (Exception e) {
				log.error(e.getMessage());
				return AppResultUtil.createErrorDto("100", "修改企业入驻信息失败：" + e.getMessage());
			}
		}

	}

	/**
	 * 跳转企业入驻待处理列表
	 *
	 * @param request
	 * @param response
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(value = "jumpEnterpriseList")
	public ModelAndView jumpEnterpriseList(HttpServletRequest request, HttpServletResponse response) throws Exception {
		Model                model            = new ExtendedModelMap();
		List<TbOrganization> organizationList = getUserRelationOrgList(request);
		model.addAttribute("orgs", organizationList);
		return new ModelAndView("admin/enter/entryApplication", model.asMap());//entryApplication
	}

	/**
	 * 获取企业入驻待处理列表
	 *
	 * @param request
	 * @param response
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(value = "getEnterpriseList")
	@ResponseBody
	public WebPageResultDto getEnterpriseList(HttpServletRequest request, HttpServletResponse response) {

		Map<String, Object> params = new HashMap<String, Object>();
		int                 pageNo = 1;
		if (StringUtils.isNotBlank(request.getParameter("pageNo"))) {
			pageNo = Integer.parseInt(request.getParameter("pageNo"));
		}

		int pageSize = 10;
		if (StringUtils.isNotBlank(request.getParameter("pageSize"))) {
			pageSize = Integer.parseInt(request.getParameter("pageSize"));
		}

		User   user   = (User) request.getSession().getAttribute("UserCache");//----------联调时需放开注释
		String userId = String.valueOf(user.getId());//app用户id

		String virName = request.getParameter("virName");//企业名称
		if (StringUtils.isNotEmpty(virName)) {
			virName = virName.trim();
			params.put("virName", virName);
		}
		String applyName = request.getParameter("applyName");//申请人
		if (StringUtils.isNotEmpty(applyName)) {
			applyName = applyName.trim();
			params.put("applyName", applyName);
		}
		String status = request.getParameter("status");//状态 1-待审核;2-通过;3拒绝;
		if (StringUtils.isNotBlank(status)) {
			params.put("status", status);
		}
		String applyTime = request.getParameter("applyTime");//申请时间
		if (StringUtils.isNotEmpty(applyTime)) {
			applyTime = applyTime.trim();
			params.put("applyTime", applyTime);
		}
		String isHisList = request.getParameter("isHisList");
		if (StringUtils.isNotBlank(isHisList)) {
			params.put("isHisList", isHisList);
		}
		//企业入驻
		String type = request.getParameter("type");
		if (StringUtils.isNotBlank(type)) {
			params.put("type", type);
		}

		String orgId = request.getParameter("orgId");
		if (StringUtils.isBlank(orgId)) {
			orgId = getUserManageOrgIds(user);
		}
		params.put("orgId", orgId);

		try {
			Map<String, Object> map = new HashMap<String, Object>();
			//如果该用户是没有权限的就返回空
//			Page page=enterpriseManager.getEnterListByType(type, userId, virName, pageSize, pageNo, Integer.parseInt(isHisList));
			Page             page = enterpriseManager.getEnterList(params, pageNo, pageSize);
			WebPageResultDto dto  = new WebPageResultDto();
			if (page != null) {
				map.put("entList", page.getItems());
				dto.setCount(page.getTotalCount());
			} else {
				map.put("entList", null);
				dto.setCount(Long.parseLong("0"));
			}
			map.put("virName", virName);
			dto = new WebPageResultDto(AppConstants.SUCCESS_CODE, "成功", page.getItems());
			dto.setCount(page.getTotalCount());
			return dto;

		} catch (Exception e) {
			log.error(e.getMessage());
			e.printStackTrace();
			return new WebPageResultDto("100", "查询列表失败:" + e.getMessage(), null);
		}


	}


	/**
	 * 获取企业入驻待处理单详情
	 *
	 * @param request
	 * @param response
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(value = "getEnterpriseInfo")
	@ResponseBody
	public AppResultDto getEnterpriseInfo(HttpServletRequest request, HttpServletResponse response) {
		String enterId = request.getParameter("enterId");
		String type    = request.getParameter("type");
		try {
			EnterEvaluateDto enterInfo = enterpriseManager.getEnterEvaluateInfo(enterId, type);
			if (enterInfo != null) {
//				EnterpriseDto  dto=enterpriseManager.getEnterInfo(enterId);
//				EnterPcOutPutDto dto=enterpriseManager.getEnterInfoByPC(enterId);
				return AppResultUtil.createSuccesDto(enterInfo);
			} else {
				return AppResultUtil.createErrorDto("100", "获取企业入驻单据失败");
			}
		} catch (Exception e) {
			log.error(e.getMessage());
			return AppResultUtil.createErrorDto("100", "获取企业入驻详情失败：" + e.getMessage());
		}
	}

	/**
	 * 企业入驻待处理单审核(不用)
	 *
	 * @param request
	 * @param response
	 * @return
	 * @throws Exception
	 */
//	@RequestMapping(value = "optionEnterpriseOrder")
	@ResponseBody
	public AppResultDto optionEnterpriseOrder(HttpServletRequest request, HttpServletResponse response) {
		String enterId   = request.getParameter("enterId");
		String userId    = request.getParameter("userId");//审核人
		String optionMsg = request.getParameter("optionMsg");//审核信息
		String status    = request.getParameter("status");//2-通过 3-不通过

		EnterpriseInfo enterpriseInfo = enterpriseManager.get(Integer.parseInt(enterId));
		enterpriseInfo.setModifier(Integer.parseInt(userId));
		enterpriseInfo.setRemark(optionMsg);
		enterpriseInfo.setStatus(status);

		try {
			enterpriseManager.save(enterpriseInfo);
			return AppResultUtil.createSuccesDto();
		} catch (Exception e) {
			log.error(e.getMessage());
			return AppResultUtil.createErrorDto("100", "获取企业入驻详情失败：" + e.getMessage());
		}
	}

	/**
	 * 跳转企业入驻历史列表
	 *
	 * @param request
	 * @param response
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(value = "jumpEnterList")
	public ModelAndView jumpEnterList(HttpServletRequest request, HttpServletResponse response) throws Exception {
		return new ModelAndView("admin/enter/enterHistory");
	}

//	/**
//	 * 获取企业入驻历史列表
//	 * @param request
//	 * @param response
//	 * @return
//	 * @throws Exception
//	 */
//	@RequestMapping(value = "getEnterList")
//	@ResponseBody
//	public WebPageResultDto getEnterList(HttpServletRequest request,HttpServletResponse response) throws Exception{
//		JSONObject json=new JSONObject();
//		int pageNo=1;
//		if(StringUtils.isNotBlank(request.getParameter("page"))){
//			pageNo=Integer.parseInt(request.getParameter("page"));
//		}
//		int pageSize=10;
//		if(StringUtils.isNotBlank(request.getParameter("limit"))){
//			pageSize=Integer.parseInt(request.getParameter("limit"));
//		}
//		String floorId=request.getParameter("floorId");
//		String roomId=request.getParameter("roomId");
//		String virName=request.getParameter("virName");
//		User user = (User) request.getSession().getAttribute("UserCache");//----------联调时需放开注释
//		String userId=String.valueOf(user.getId());//app用户id
//		try {
//			String isSupervisor=enterpriseManager.isHavePower(userId,2001);
//			String isCustService=enterpriseManager.isHavePower(userId,2002);
//			String isProgramme=enterpriseManager.isHavePower(userId,2003);
//			if("1".equals(isSupervisor)){//如果有客服主管的权限，则显示他负责楼层的全部企业入驻待处理数据
//				String floorIds=enterpriseManager.getPowerFloor(Integer.parseInt(userId),2001);//查询客服主管
//				Page page=enterpriseManager.getEnterHisListByUser(virName,0,Integer.parseInt(userId),floorIds,pageSize,pageNo,1);
//				WebPageResultDto dto = new WebPageResultDto(AppConstants.SUCCESS_CODE, "成功", page.getItems());
//				dto.setCount(page.getTotalCount());
//				return dto;
//			}else if("1".equals(isCustService)){
//				String floorIds=enterpriseManager.getPowerFloor(Integer.parseInt(userId),2002);//查询客服
//				Page page=enterpriseManager.getEnterHisListByUser(virName,1,Integer.parseInt(userId),floorIds,pageSize,pageNo,1);
//				WebPageResultDto dto = new WebPageResultDto(AppConstants.SUCCESS_CODE, "成功", page.getItems());
//				dto.setCount(page.getTotalCount());
//				return dto;
//			}else if("1".equals(isProgramme)){
//				String floorIds=enterpriseManager.getPowerFloor(Integer.parseInt(userId),2003);//查询工程人员
//				Page page=enterpriseManager.getEnterHisListByUser(virName,2,Integer.parseInt(userId),floorIds,pageSize,pageNo,1);
//				WebPageResultDto dto = new WebPageResultDto(AppConstants.SUCCESS_CODE, "成功", page.getItems());
//				dto.setCount(page.getTotalCount());
//				return dto;
//			}else{
//				return new WebPageResultDto("100", "没有权限",null);
//			}
//			
//		} catch (Exception e) {
//			log.error(e.getMessage());
//			return new WebPageResultDto("100", "查询列表失败:"+e.getMessage(),null);
//		}
//	}


	/**
	 * 提交水电表信息
	 *
	 * @param request
	 * @param response
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(value = "submitWater")
	@ResponseBody
	public AppResultDto submitWater(HttpServletRequest request, HttpServletResponse response) throws Exception {
		try {
			User                 user        = (User) request.getSession().getAttribute("UserCache");//----------联调时需放开注释
			String               userId      = String.valueOf(user.getId());
			String               enterId     = request.getParameter("enterId");
			String               wateDtoList = request.getParameter("wateDtoList");
			List<WatermenterDto> wateList    = JSON.parseArray(wateDtoList, WatermenterDto.class);
			String               code        = watermeterManager.saveWaterInfo(wateList, Integer.parseInt(enterId), Integer.parseInt(userId));
			if ("200".equals(code)) {
				AppResultDto dto = AppResultUtil.createSuccesDto();
				if ("200".equals(dto.getCode())) {
					//推送水电表信息给微信用户
//					watermeterManager.sendWechat(enterId,wateList);

				}
				return dto;
			} else {
				return AppResultUtil.createErrorDto("100", "提交水电表信息失败");
			}

		} catch (Exception e) {
			log.error(e.getMessage());
			return AppResultUtil.createErrorDto("100", "提交水电表信息失败：" + e.getMessage());
		}
	}

//	@RequestMapping(value = "submitWater")
//	@ResponseBody
//	public AppResultDto submitWater(@ModelAttribute("watermentInputDto") WatermentInputDto watermentInputDto,HttpServletRequest request,HttpServletResponse response) throws Exception{
//		try {
//			String code=watermeterManager.saveWaterInfo(watermentInputDto);
//			if("200".equals(code)){
//				return AppResultUtil.createSuccesDto();
//			}else{
//				return AppResultUtil.createErrorDto("100","提交水电表信息失败");
//			}
//			
//		} catch (Exception e) {
//			log.error(e.getMessage());
//			return AppResultUtil.createErrorDto("100","提交水电表信息失败："+e.getMessage());
//		}
//	}


	/**
	 * 根据企业入驻单获取水电表信息
	 *
	 * @param request
	 * @param response
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(value = "getWaterList")
	@ResponseBody
	public AppResultDto getWaterList(HttpServletRequest request, HttpServletResponse response) throws Exception {
		Map<String, Object>  map       = new HashMap<String, Object>();
		List<WatermenterDto> waterList = new ArrayList<WatermenterDto>();
		int                  sourseId  = Integer.parseInt(request.getParameter("enterId"));//获取来源单据ID(企业入驻单据ID)
		try {
			//根据企业入驻单据ID查询水电表信息，1代表企业入驻，2代表企业迁出，
			//floorId,roomId为空代表直接查询这个企业入驻单据下所有的水电表信息,如果有值代表查单个的楼层或者房间的水电表信息
			EnterpriseInfo enterInfo = enterpriseManager.get(sourseId);
			if (enterInfo != null && StringUtils.isNotEmpty(enterInfo.getState())) {
				int state = Integer.parseInt(enterInfo.getState());
				waterList = watermeterManager.getWatermeterList(sourseId, state, "", "");
			}
			map.put("wateList", waterList);
			TbOrganization orgInfo = organizationManager.getOrganizationById(Integer.parseInt(enterInfo.getOrgId()));
			map.put("orgName", orgInfo.getName());
			map.put("floorAndRoom", enterpriseManager.getFloorAndRooms(enterInfo));
			return AppResultUtil.createSuccesDto(map);
		} catch (Exception e) {
			e.printStackTrace();
			log.error(e.getMessage());
			return AppResultUtil.createErrorDto("100", "获取企业入驻历史列表失败：" + e.getMessage());
		}
	}

	/**
	 * 上传图片，返回地址
	 *
	 * @param request
	 * @param response
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(value = "uploadImage")
	@ResponseBody
	public AppResultDto uploadImage(HttpServletRequest request, HttpServletResponse response) throws Exception {
		Map<String, Object> data = new HashMap<String, Object>();
		try {
			data = enterpriseManager.uploadImage(request);
			return AppResultUtil.createSuccesDto(data);
		} catch (Exception e) {
			log.error(e.getMessage());
			return AppResultUtil.createErrorDto("100", "上传图片失败：" + e.getMessage());
		}


	}


	/**
	 * 修改企业入驻
	 *
	 * @return
	 */
	@RequestMapping(value = "updateEnterInfo")
	@ResponseBody
	public AppResultDto updateEnterInfo(@RequestBody EnterUpdateInputDto enterUpdateInputDto, HttpServletRequest request, HttpServletResponse response) {
		//获取里面的对象
		try {
			AppResultDto dto = enterpriseManager.updateEnterInfoDto(enterUpdateInputDto);
			return AppResultUtil.createSuccesDto(dto);
		} catch (Exception e) {
			e.printStackTrace();
			log.error(e.getMessage());
			return AppResultUtil.createErrorDto("100", "操作失败：" + e.getMessage());
		}
	}

	/**
	 * 获取客服人员
	 * 获取管理该楼层下的客服人员(有入驻工程分配权限的)
	 *
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping(value = "getCustomerService")
	@ResponseBody
	public AppResultDto getCustomerService(HttpServletRequest request, HttpServletResponse response) {
		Map<String, Object>       map         = new HashMap<String, Object>();
		String                    enterId     = request.getParameter("enterId");
		String                    type        = request.getParameter("type");
		List<Map<String, Object>> list        = new ArrayList<Map<String, Object>>();
		List<Map<String, Object>> custlist    = new ArrayList<Map<String, Object>>();
		EnterpriseInfo            enterInfo   = enterpriseManager.get(Integer.parseInt(enterId));
		String                    floorId     = enterInfo.getFloorIds();
		List<CommonDto>           serviceDto  = new ArrayList<CommonDto>();
		List<CommonDto>           customerDto = new ArrayList<CommonDto>();
		try {
			if ("1".equals(enterInfo.getState())) {//企业入驻
				if ("0".equals(type)) {
					list = enterpriseManager.getPower(floorId, Integer.parseInt(CodeConstants.ENTERCUSMANAGE_PERMISSION));//查询客服主管
					for (int i = 0; i < list.size(); i++) {
						Map<String, Object> cusMap = list.get(i);
						serviceDto.add(new CommonDto(Long.valueOf(cusMap.get("usId").toString()), cusMap.get("userName").toString()));
					}
					custlist = enterpriseManager.getPower(floorId, Integer.parseInt(CodeConstants.ENTERCUS_PERMISSION));//查询客服
					for (int i = 0; i < custlist.size(); i++) {
						Map<String, Object> cusMap = custlist.get(i);
						customerDto.add(new CommonDto(Long.valueOf(cusMap.get("usId").toString()), cusMap.get("userName").toString()));
					}
				} else if ("1".equals(type)) {
					list = enterpriseManager.getPower(floorId, Integer.parseInt(CodeConstants.ENTERCUSMANAGE_PERMISSION));//查询客服主管
					for (int i = 0; i < list.size(); i++) {
						Map<String, Object> cusMap = list.get(i);
						serviceDto.add(new CommonDto(Long.valueOf(cusMap.get("usId").toString()), cusMap.get("userName").toString()));
					}
				} else if ("2".equals(type)) {
					custlist = enterpriseManager.getPower(floorId, Integer.parseInt(CodeConstants.ENTERCUS_PERMISSION));//查询客服
					for (int i = 0; i < custlist.size(); i++) {
						Map<String, Object> cusMap = custlist.get(i);
						customerDto.add(new CommonDto(Long.valueOf(cusMap.get("usId").toString()), cusMap.get("userName").toString()));
					}
				}
			} else if ("2".equals(enterInfo.getState())) {//企业迁出
				if ("0".equals(type)) {
					list = enterpriseManager.getPower(floorId, Integer.parseInt(CodeConstants.EMIGCUSMANAGE_PERMISSION));//查询客服主管
					for (int i = 0; i < list.size(); i++) {
						Map<String, Object> cusMap = list.get(i);
						serviceDto.add(new CommonDto(Long.valueOf(cusMap.get("usId").toString()), cusMap.get("userName").toString()));
					}
					custlist = enterpriseManager.getPower(floorId, Integer.parseInt(CodeConstants.EMIGCUS_PERMISSION));//查询客服
					for (int i = 0; i < custlist.size(); i++) {
						Map<String, Object> cusMap = custlist.get(i);
						customerDto.add(new CommonDto(Long.valueOf(cusMap.get("usId").toString()), cusMap.get("userName").toString()));
					}
				} else if ("1".equals(type)) {
					list = enterpriseManager.getPower(floorId, Integer.parseInt(CodeConstants.EMIGCUSMANAGE_PERMISSION));//查询客服主管
					for (int i = 0; i < list.size(); i++) {
						Map<String, Object> cusMap = list.get(i);
						serviceDto.add(new CommonDto(Long.valueOf(cusMap.get("usId").toString()), cusMap.get("userName").toString()));
					}
				} else if ("2".equals(type)) {
					custlist = enterpriseManager.getPower(floorId, Integer.parseInt(CodeConstants.EMIGCUS_PERMISSION));//查询客服
					for (int i = 0; i < custlist.size(); i++) {
						Map<String, Object> cusMap = custlist.get(i);
						customerDto.add(new CommonDto(Long.valueOf(cusMap.get("usId").toString()), cusMap.get("userName").toString()));
					}
				}
			}

			map.put("custlist", customerDto);
			map.put("list", serviceDto);
			return AppResultUtil.createSuccesDto(map);
		} catch (Exception e) {
			e.printStackTrace();
			log.error(e.getMessage());
			return AppResultUtil.createErrorDto("100", "操作失败：" + e.getMessage());
		}
	}

	/**
	 * 企业入驻/迁出审核操作
	 *
	 * @param request
	 * @param response
	 * @return
	 */
//	@RequestMapping(value="setEnterReason")
	@RequestMapping(value = "optionEnterpriseOrder")
	@ResponseBody
	public AppResultDto setEnterReason(HttpServletRequest request, HttpServletResponse response) {
		String reason    = request.getParameter("optionMsg");
		String enterId   = request.getParameter("enterId");
		String resonType = request.getParameter("status");//2通过3拒绝
		String type      = request.getParameter("type");//1企业入驻 2企业迁出

		String signingTime    = request.getParameter("signingTime");//签约日期
		String contExpireTime = request.getParameter("contExpireTime");//合同到期日期

		User            user   = (User) request.getSession().getAttribute("UserCache");//----------联调时需放开注释
		EnterpriseAudit audit  = new EnterpriseAudit();
		String          userId = String.valueOf(user.getId());
		try {
			EnterpriseInfo enterInfo = enterpriseManager.get(Integer.parseInt(enterId));

			int operationType = 0;
			if ("3".equals(resonType)) {//拒绝
				operationType = CodeConstants.BREAK;
			} else if ("2".equals(resonType)) {//通过
				operationType = CodeConstants.PASS;
			}
			BillOperationRecodes billRecodes = billOperationRecodesManager.getRecodeBySourId(Long.parseLong(enterInfo.getId().toString()), Integer.parseInt(enterInfo.getState()), operationType);
			if (billRecodes != null) {
				return AppResultUtil.createCommonDto(CodeConstants.USEED_CODE, "该单据已有用户操作.", enterInfo.getId().toString());
			}

			List<VirtualArchitecture> virList = virtualArchManager.getVirByRoomId(enterInfo.getRoomIds());
			if (virList != null && virList.size() > 0 && "1".equals(enterInfo.getState())) {
				return AppResultUtil.createErrorDto(AppConstants.BILL_EXISTENT, "单据已被操作，不允许再操作");
			}
			audit = enterpriseManager.saveEnterAudit(reason, userId, enterId, resonType, type, signingTime, contExpireTime);
			AppResultDto dto = AppResultUtil.createSuccesDto(audit);
			try {
				if (audit != null) {
					if ("200".equals(dto.getCode())) {
						String virName      = enterInfo.getVirName();
						String floorAndRoom = enterpriseManager.getFloorAndRooms(enterInfo);
						if (StringUtils.isNotEmpty(floorAndRoom)) {
							floorAndRoom = floorAndRoom.substring(0, floorAndRoom.length() - 1);
						}

						int    type2     = 0;
						int    code      = 0;
						String operation = "";
						String describe  = "";
						String content   = "";
						String enter     = "enter";
						if ("1".equals(enterInfo.getState())) {//企业入驻
							type2 = CodeConstants.ENTER;
							if ("3".equals(resonType)) {//拒绝
								code = CodeConstants.BREAK;
								operation = "拒绝";
								describe = "该企业入驻单据被拒绝";
								content = "抱歉，你的" + virName + "入驻申请未通过，未通过原因为" + audit.getContent() + "！";
							} else if ("2".equals(resonType)) {//通过
								code = CodeConstants.PASS;
								operation = "通过";
								describe = "该企业入驻单据被通过";
								content = "恭喜，你的" + virName + "入驻申请已经通过啦！";
							}
						} else if ("2".equals(enterInfo.getState())) {//企业迁出
							type2 = CodeConstants.EMIG;
							enter = "emig";
							if ("3".equals(resonType)) {//拒绝
								code = CodeConstants.BREAK;
								operation = "拒绝";
								describe = "该企业迁出被拒绝";
								content = "抱歉，你的" + virName + "迁出申请未通过，未通过原因为" + audit.getContent() + "！";
							} else if ("2".equals(resonType)) {//通过
								code = CodeConstants.PASS;
								operation = "通过";
								describe = "该企业迁出单据被通过";
								content = "你好，你的" + virName + "迁出申请已通过审核！";
							}
						}

						String host           = PropertiesKit.readPropertiesValue("hostUrl", "wechat.properties");
						String wxVirDetailUrl = PropertiesKit.readPropertiesValue("wxVirDetailUrl", "wechat.properties");
						String url            = host + wxVirDetailUrl.replaceAll("@id", enterId).replaceAll("enter", enter);
						content += "<a href=\"" + url + "\">查看详情>></a>";
						billOperationRecodesManager.saveRecode(Long.parseLong(enterId), type2, code, Long.parseLong(userId), operation, describe);//保存操作记录
						String wxUserId = String.valueOf(enterInfo.getCreator());

						if (enterInfo.getState() == "2" && enterInfo.getEmigNewWay() == "2") {
							List<User> users       = new ArrayList<User>();
							User       creatorUser = userManager.getUser(enterInfo.getCreator() + "");
							users.add(creatorUser);
							//如果是app端发起的迁出申请 审核通过或拒绝后进行app推送
							PushMessageHelper helper=new PushMessageHelper();
							helper.pushMessage(Long.parseLong(enterId), CodeConstants.AUDIT_PUSH_CODE, users, "企业迁出审核结果通知", content);
						} else {
							WxUser wxUser = scWxuserManager.getScWxuserByWxUserId(enterInfo.getCreator());
							if (wxUser != null) {
								//微信客服消息推送
								weChatApiManager.sendServiceWithOpenId(wxUser.getDevelopId(), Integer.parseInt(wxUserId), content);
							}
						}
					/*if("2".equals(enterInfo.getEmigNewWay())){//如果是app端发起的，需要给企业负责人发消息
						List<VirtUserInfo> virUserList=virtUserManager.getVirtUserByVirtId(enterInfo.getVirId());
						if(virUserList!=null&&virUserList.size()>0){
							for(int i=0;i<virUserList.size();i++){
								VirtUserInfo virUser=virUserList.get(i);
								int virUserId=virUser.getUserId();
								WxUser wxUser=scWxuserManager.getScWxuserByUserId(virUserId);
								wxUserId=wxUserId+wxUser.getId()+",";
							}
						}
					}else{
						wxUserId=String.valueOf(enterInfo.getCreator());
					}*/
//					enterpriseManager.sendWechat(virName, floorAndRoom, reason, Integer.parseInt(enterInfo.getState()),Integer.parseInt(resonType), wxUserId);
					
					/*if("1".equals(enterInfo.getState())){//企业入驻
						enterInfo=enterpriseManager.get(Integer.parseInt(enterId));
						if(StringUtils.isNotBlank(enterInfo.getStatus())){//如果通过了，推送微信模板给发起人推送评价模板
							if("3".equals(enterInfo.getStatus())){
								enterpriseManager.sendWechatByOk(enterInfo,wxUserId);
							}
						}
					}*/
					}
				}
			} catch (Exception e) {
				e.printStackTrace();
				log.error("消息推送失败!" + e.getMessage());
			}
			return dto;
//			return AppResultUtil.createErrorDto("100","操作失败");

		} catch (Exception e) {
			e.printStackTrace();
			log.error(e.getMessage());
			return AppResultUtil.createErrorDto("100", "操作失败" + e.getMessage());
		}
	}

	/**
	 * 判断该单据的按钮是是否允许操作
	 *
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping(value = "isPowerButton")
	@ResponseBody
	public AppResultDto isPowerButton(HttpServletRequest request, HttpServletResponse response) {
		String enterId = request.getParameter("enterId");
		String type    = request.getParameter("type");//1通过0拒绝
		User   user    = (User) request.getSession().getAttribute("UserCache");//----------联调时需放开注释
		String userId  = String.valueOf(user.getId());
		try {
			EnterpriseInfo enter = enterpriseManager.get(Integer.parseInt(enterId));
			if ("1".equals(enter.getState())) {
				if ("1".equals(type)) {//当点击通过按钮的时候判断按钮是否允许操作()
					String isCustService = enterpriseManager.isHavePower(userId, Integer.parseInt(CodeConstants.ENTERCUS_PERMISSION));
					if ("1".equals(isCustService)) {//有客服权限

						if ("".equals(enter.getCustomerService())) {
							return AppResultUtil.createSuccesDto("跟进客服不允许为空.", "2");
						}
						if ("".equals(enter.getEngPerson())) {
							return AppResultUtil.createSuccesDto("跟进工程人员不允许为空.", "2");
						}
						List<WatermenterDto> wateList = watermeterManager.getWatermeterList(enter.getId(), 1, "", "");
						if (wateList == null || wateList.size() <= 0) {
							return AppResultUtil.createSuccesDto("水电表信息不允许为空.", "2");
						}
						if (!userId.equals(enter.getCustomerService())) {
							return AppResultUtil.createSuccesDto("您不是跟进客服，无法操作.", "2");
						}
						return AppResultUtil.createSuccesDto("1");//有权限
					} else {
						return AppResultUtil.createSuccesDto("没有分配客服权限.", "2");//没权限
					}
				} else {//当点击拒绝按钮的时候判断按钮是否允许操作
					String isCustService = enterpriseManager.isHavePower(userId, Integer.parseInt(CodeConstants.ENTERCUS_PERMISSION));
					String isSupervisor  = enterpriseManager.isHavePower(userId, Integer.parseInt(CodeConstants.ENTERCUSMANAGE_PERMISSION));
					if ("1".equals(isCustService) || "".equals(isSupervisor)) {//有客服权限
						return AppResultUtil.createSuccesDto("1");
					} else {
						return AppResultUtil.createSuccesDto("您没有该操作的权限.", "2");
					}
				}
			} else if ("2".equals(enter.getState())) {
				if ("1".equals(type)) {//当点击通过按钮的时候判断按钮是否允许操作()
					String isCustService = enterpriseManager.isHavePower(userId, Integer.parseInt(CodeConstants.EMIGCUS_PERMISSION));
					if ("1".equals(isCustService)) {//有客服权限

						if ("".equals(enter.getCustomerService())) {
							return AppResultUtil.createSuccesDto("跟进客服不允许为空.", "2");
						}
						if ("".equals(enter.getEngPerson())) {
							return AppResultUtil.createSuccesDto("跟进工程人员不允许为空.", "2");
						}
						List<WatermenterDto> wateList = watermeterManager.getWatermeterList(enter.getId(), 2, "", "");
						if (wateList == null || wateList.size() <= 0) {
							return AppResultUtil.createSuccesDto("水电表信息不允许为空.", "2");
						}
						EmigrationSettle esInfo = emigrationManager.getEmigrationSettle(enter.getId());
						if (esInfo == null) {
							return AppResultUtil.createCommonDto("100", "结算表不允许为空.", "2");
						}
						if (!userId.equals(enter.getCustomerService())) {
							return AppResultUtil.createSuccesDto("您不是跟进客服，无法操作.", "2");
						}
						return AppResultUtil.createSuccesDto("1");//有权限
					} else {
						return AppResultUtil.createSuccesDto("没有分配客服权限.", "2");//没权限
					}
				} else {//当点击拒绝按钮的时候判断按钮是否允许操作
					String isCustService = enterpriseManager.isHavePower(userId, Integer.parseInt(CodeConstants.EMIGCUS_PERMISSION));
					String isSupervisor  = enterpriseManager.isHavePower(userId, Integer.parseInt(CodeConstants.EMIGCUSMANAGE_PERMISSION));
					if ("1".equals(isCustService) || "".equals(isSupervisor)) {//有客服权限
						return AppResultUtil.createSuccesDto("1");
					} else {
						return AppResultUtil.createSuccesDto("您没有该操作的权限.", "2");
					}
				}
			}
			return AppResultUtil.createSuccesDto("0");//无权限

		} catch (Exception e) {
			e.printStackTrace();
			log.error(e.getMessage());
			return AppResultUtil.createErrorDto("100", "操作失败：" + e.getMessage());
		}


	}


	/**
	 * @param request
	 * @return 查找对应维修类型下的人员
	 */
	@RequestMapping(value = "/getRepairTypeUser")
	@ResponseBody
	public AppResultDto getRepairTypeUser(HttpServletRequest request, HttpServletResponse response) {
		String                    enterId       = request.getParameter("enterId");
		List<Map<String, Object>> engPersonList = new ArrayList<Map<String, Object>>();
		List<CommonDto>           engPsersonDto = new ArrayList<CommonDto>();
		try {
			EnterpriseInfo enterInfo = enterpriseManager.get(Integer.parseInt(enterId));

			if (enterInfo != null) {
				String floorIds = enterInfo.getFloorIds();
				if ("1".equals(enterInfo.getState())) {//企业入驻
					engPersonList = enterpriseManager.getPower(Integer.parseInt(CodeConstants.ENTERENG_PERMISSION));
				} else if ("2".equals(enterInfo.getState())) {//企业迁出
					engPersonList = enterpriseManager.getPower(Integer.parseInt(CodeConstants.EMIGENG_PERMISSION));
				}
				for (int i = 0; i < engPersonList.size(); i++) {
					Map<String, Object> cusMap = engPersonList.get(i);
					engPsersonDto.add(new CommonDto(Long.valueOf(cusMap.get("usId").toString()), cusMap.get("userName").toString()));
				}

			}
			return AppResultUtil.createSuccesDto(engPsersonDto);
		} catch (Exception e) {
			log.error(e.getMessage());
			return AppResultUtil.createErrorDto("100", "获取工程人员失败：" + e.getMessage());
		}

	}

	/**
	 * @param request
	 * @return 根据维修单编码获取维修列表
	 */
	@RequestMapping(value = "/getRepairNumberList")
	@ResponseBody
	public AppResultDto getRepairNumberList(HttpServletRequest request, HttpServletResponse response) {
		String enterId      = request.getParameter("enterId");
		String repairNumber = "";
		if (StringUtils.isNotEmpty(enterId)) {
			EnterpriseInfo enterInfo = enterpriseManager.get(Integer.parseInt(enterId));
			repairNumber = enterInfo.getRepairNumber();
		}
		List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
		if (StringUtils.isNotEmpty(repairNumber)) {
			try {
				list = enterpriseManager.getRepairNumberList(repairNumber);
				if (list != null && list.size() > 0) {
					return AppResultUtil.createSuccesDto(list);
				} else {
					return AppResultUtil.createSuccesDto("维修单为空", list);
				}

			} catch (Exception e) {
				e.printStackTrace();
				log.error(e.getMessage());
				return AppResultUtil.createErrorDto("100", "获取维修列表失败：" + e.getMessage());
			}
		}
		return AppResultUtil.createSuccesDto("维修单为空", list);
	}


	/**
	 * @param request
	 * @return 修改维修单编码
	 */
	@RequestMapping(value = "/updateEnterRpairCode")
	@ResponseBody
	public AppResultDto updateEnterRpairCode(HttpServletRequest request, HttpServletResponse response) {
		String repairNumber = request.getParameter("repairCode");
		String enterId      = request.getParameter("enterId");
		if (StringUtils.isNotEmpty(enterId)) {
			try {
				EnterpriseInfo info = enterpriseManager.get(Integer.parseInt(enterId));
				info.setRepairNumber(repairNumber);
				enterpriseManager.updateModel(info);
				return AppResultUtil.createSuccesDto();
			} catch (Exception e) {
				e.printStackTrace();
				log.error(e.getMessage());
				return AppResultUtil.createErrorDto("100", "获取维修列表失败：" + e.getMessage());
			}
		}
		return AppResultUtil.createErrorDto("100", "获取维修列表失败");
	}


	/**
	 * @param request
	 * @return 修改客服及工程
	 */
	@RequestMapping(value = "/updateEnterPeson")
	@ResponseBody
	public AppResultDto updateEnterPeson(HttpServletRequest request, HttpServletResponse response) {
		String type    = request.getParameter("type");
		String pesonId = request.getParameter("pesonId");
		String enterId = request.getParameter("enterId");
		User   user    = (User) request.getSession().getAttribute("UserCache");//----------联调时需放开注释
		if (StringUtils.isNotEmpty(enterId)) {
			try {
				EnterpriseInfo info = enterpriseManager.get(Integer.parseInt(enterId));
				if ("1".equals(type)) {
					info.setCustomerService(pesonId);
					info.setStatus("1");
				} else if ("2".equals(type)) {
					if (StringUtils.isNotEmpty(info.getCustomerService())) {
						info.setEngPerson(pesonId);
						info.setStatus("2");
					} else {
						return AppResultUtil.createErrorDto("100", "跟进客服不允许为空");
					}
				}
				enterpriseManager.updateModel(info);
				AppResultDto dto = AppResultUtil.createSuccesDto();
				if ("200".equals(dto.getCode())) {

					int    type1     = 0;
					int    code      = 0;
					String operation = "";
					String describe  = "";
					if ("1".equals(type)) {//跟进客服
						code = CodeConstants.SUBMIT_CUS;
						operation = "修改跟进客服";
						if ("1".equals(info.getState())) {
							type1 = CodeConstants.ENTER;
							describe = "企业入驻修改跟进客服";
						} else if ("2".equals(info.getState())) {
							type1 = CodeConstants.EMIG;
							describe = "企业迁出修改跟进客服";
						}
					} else if ("2".equals(type)) {//跟进工程
						code = CodeConstants.SUBMIT_ENG;
						operation = "修改跟进工程";
						if ("1".equals(info.getState())) {
							type1 = CodeConstants.ENTER;
							describe = "企业入驻修改跟进工程";
						} else if ("2".equals(info.getState())) {
							type1 = CodeConstants.EMIG;
							describe = "企业迁出修改跟进工程";
						}
					}

					billOperationRecodesManager.saveRecode(Long.parseLong(enterId), type1, code, Long.parseLong(user.getId().toString()), operation, describe);

					enterpriseManager.sendUpdateEnterMessage(info, pesonId);
				}
				return dto;
			} catch (Exception e) {
				e.printStackTrace();
				log.error(e.getMessage());
				return AppResultUtil.createErrorDto("100", "修改企业入驻单的跟进客服或跟进工程人员失败：" + e.getMessage());
			}
		}
		return AppResultUtil.createErrorDto("100", "修改企业入驻单的跟进客服或跟进工程人员失败");
	}


	/**
	 * 企业入驻提交水电表时入口
	 *
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping(value = "/getWateSizeList")
	@ResponseBody
	public AppResultDto getWateSizeList(HttpServletRequest request, HttpServletResponse response) {
		String enterId = request.getParameter("enterId");
		try {
			if (StringUtils.isNotEmpty(enterId)) {
				EnterpriseInfo info    = enterpriseManager.get(Integer.parseInt(enterId));
				String         roomIds = info.getRoomIds();
				if (StringUtils.isNotEmpty(roomIds)) {
					AppResultDto dto = enterpriseManager.getWateSizeListByRooms(roomIds, info);
					return dto;
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
			log.error(e.getMessage());
			return AppResultUtil.createErrorDto("100", "获取水电表信息失败：" + e.getMessage());
		}
		return AppResultUtil.createErrorDto("100", "获取水电表信息失败");
	}

	/**
	 * 推送水电表信息给发起人
	 *
	 * @param request
	 * @param response
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(value = "sendWaterMessage")
	@ResponseBody
	public AppResultDto sendWaterMessage(HttpServletRequest request, HttpServletResponse response) throws Exception {
		return AppResultUtil.createErrorDto("100", "推送水电表信息失败");
	}

	/**
	 * 修改企业后将推送给对应的步骤的人(跟进客服，跟进工程人员)
	 *
	 * @param request
	 * @param response
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(value = "sendUpdateEnterMessage")
	@ResponseBody
	public AppResultDto sendUpdateEnterMessage(HttpServletRequest request, HttpServletResponse response) throws Exception {
		String enterId = request.getParameter("enterId");
		if (StringUtils.isNotEmpty(enterId)) {
			EnterpriseInfo entInfo = enterpriseManager.get(Integer.parseInt(enterId));
//			String code=
//			if("200".equals(code)){
//				return AppResultUtil.createSuccesDto();
//			}else{
//				return AppResultUtil.createErrorDto("100","修改企业入驻信息推送失败");
//			}
		}

		return AppResultUtil.createErrorDto("100", "修改企业入驻信息推送失败");
	}


	/**
	 * 企业入驻通过或拒绝成功后推送消息给微信发起人
	 *
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping(value = "senRsultMessage")
	@ResponseBody
	public AppResultDto senRsultMessage(HttpServletRequest request, HttpServletResponse response) {
		String           enterId   = request.getParameter("enterId");
		String           resonType = request.getParameter("resonType");//1通过0拒绝
		String           wxUserId  = "";
		SimpleDateFormat sdf       = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
		String           result    = "";
		try {
			if (StringUtils.isNotEmpty(enterId)) {
				EnterpriseInfo enterInfo = enterpriseManager.get(Integer.parseInt(enterId));
				if (enterInfo != null) {
					wxUserId = String.valueOf(enterInfo.getCreator());
					if (StringUtils.isNotEmpty(wxUserId)) {
						String floorAndRoom = enterpriseManager.getFloorAndRooms(enterInfo);
						String virName      = enterInfo.getVirName();
						String time         = sdf.format(enterInfo.getCreateTime());
						if ("1".equals(resonType)) {
//							result=enterpriseManager.sendWechat(wxUserId, "成功", floorAndRoom, virName, time, "成功");
						} else {
//							result=enterpriseManager.sendWechat(wxUserId, "拒绝", floorAndRoom, virName, time, "拒绝");
						}
						if ("success".equals(result)) {
							return AppResultUtil.createSuccesDto();
						}

					}
				}

			}
		} catch (Exception e) {
			e.printStackTrace();
			log.error(e.getMessage());
			return AppResultUtil.createErrorDto("100", "操作失败" + e.getMessage());
		}

		return AppResultUtil.createSuccesDto("没有要推送的数据", null);
	}

	/**
	 * 企业入驻文件上传
	 *
	 * @param request
	 * @return
	 */
	@RequestMapping(value = "uploadFile")
	@ResponseBody
	public AppResultDto uploadFile(HttpServletRequest request, MultipartHttpServletRequest multipartRequest) {

		try {
			String        orgId         = request.getParameter("orgId");
			String        type          = request.getParameter("type");
			MultipartFile multipartFile = multipartRequest.getFile("file");
			//获得文件原始名称
			InputStream stream   = null;
			String      fileExt  = null;
			String      fileName = "";
			if (multipartFile != null) {
				stream = multipartFile.getInputStream();
				fileName = multipartFile.getOriginalFilename();
//				fileName = new String(fileName.getBytes(), "utf-8");
				//文件后缀
				fileExt = StringUtils.isNotEmpty(fileName) ? fileName
						.substring(fileName.lastIndexOf("."))
						: StringUtils.EMPTY;
			}
			VirArchModel virArchModel = enterpriseManager.uploadFile(stream, fileExt, fileName, type, orgId);
			return AppResultUtil.createSuccesDto("上传成功", virArchModel);
		} catch (Exception e) {
			e.printStackTrace();
			log.error(e.getMessage());
			return AppResultUtil.createErrorDto("100", "操作失败" + e.getMessage());
		}
	}

	/**
	 * 企业入驻文件列表
	 *
	 * @param request
	 * @return
	 */
	@RequestMapping(value = "getFileList")
	@ResponseBody
	public AppResultDto getFileList(HttpServletRequest request) {
		String type    = request.getParameter("type");
		String orgId   = request.getParameter("orgId");
		String fileIds = request.getParameter("fileIds");
		if (StringUtils.isNotEmpty(fileIds) && fileIds.indexOf(";") != -1) {
			fileIds = fileIds.replaceAll(";", ",");
		}
		List<Map<String, Object>> list = enterpriseManager.getFileList(type, orgId, fileIds);
		return AppResultUtil.createSuccesDto(list);
	}

	/**
	 * 删除企业入驻文件
	 *
	 * @param request
	 * @return
	 */
	@RequestMapping(value = "deleteFile")
	@ResponseBody
	public AppResultDto deleteFile(HttpServletRequest request) {
		String id = request.getParameter("id");
		return virArchModelManager.delFileById(Integer.parseInt(id));
	}
}
