package com.product.administration.controller;

import com.product.administration.config.CmnConst;
import com.product.administration.config.SystemCode;
import com.product.administration.service.CooperatesService;
import com.product.administration.service.ide.ICooperatesService;
import com.product.common.lang.StringUtils;
import com.product.core.config.CoreConst;
import com.product.core.controller.support.AbstractBaseController;
import com.product.core.entity.DataTableEntity;
import com.product.core.entity.FieldSetEntity;
import com.product.core.entity.RequestParameterEntity;
import com.product.core.exception.BaseException;
import com.product.core.spring.context.SpringMVCContextHolder;
import com.product.module.sys.version.ApiVersion;
import com.product.tool.flow.service.FlowCoordinationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;

/**
 * Copyright LX
 *
 * @Title: CooperateController
 * @Project: product-server
 * @date: 2021骞�03鏈�23鏃� 14:53
 * @author: ZhouJie
 * @Description: 鍗忓悓鍔炲叕
 */
@RequestMapping("/api/cooperates")
@RestController
public class CooperateController extends AbstractBaseController {

	@Autowired
	CooperatesService cooperatesService;
	@Autowired
	public FlowCoordinationService flowCoordinationService;
	/**
	 * @Date: 2020-03-23 18:00
	 * @Author: ZhouJie
	 * @Description: 鏌ヨ鍗忓悓鍔炲叕鍒楄〃
	 */
	@RequestMapping(value = "/list-cooperates/{version}", method = RequestMethod.POST)
	public String getCooperatesList(HttpServletRequest request) {
		try {
			// 鑾峰彇鍙傛暟
			FieldSetEntity fse = null;
			Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA);
			if (bean != null) {
				RequestParameterEntity reqp = (RequestParameterEntity) bean;
				fse = reqp.getFormData();
			}
			// 鍒ゆ柇鍙傛暟鏄惁涓虹┖
			if (bean == null || fse == null) {
				SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_FORM_NODATA.getValue(),
						SystemCode.SYSTEM_FORM_NODATA.getText());
				return this.error(SystemCode.SYSTEM_FORM_NODATA.getValue(), SystemCode.SYSTEM_FORM_NODATA.getText());
			}
			// 鍒ゆ柇琛ㄥ悕鏄惁姝e父
			if (!CmnConst.PRODUCT_OA_COOPERATES.equals(fse.getTableName())) {
				SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_TABLE_NODATA.getValue(),
						SystemCode.SYSTEM_TABLE_NODATA.getText());
				return this.error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText());
			}
			// 鍒ゆ柇鍒嗛〉鍙傛暟
			if (fse.getString(CmnConst.PAGESIZE) == null || fse.getString(CmnConst.CPAGE) == null) {
				return this.error(SystemCode.SYSTEM_CPAGES_NOT_NULL.getValue(),
						SystemCode.SYSTEM_CPAGES_NOT_NULL.getText());
			}
			DataTableEntity dt = cooperatesService.getCooperateList(fse);
			return OK_List(dt);
		} catch (BaseException e) {
			e.printStackTrace();
			SpringMVCContextHolder.getSystemLogger().error(e);
			return this.error(e);
		} catch (Exception e) {
			e.printStackTrace();
			SpringMVCContextHolder.getSystemLogger().error(e);
			return this.error(SystemCode.SYSTEM_GET_COOPERATES_LIST_FAIL.getValue(),
					SystemCode.SYSTEM_GET_COOPERATES_LIST_FAIL.getText());
		}
	}

	/**
	 * @Date: 2020-03-23 17:32
	 * @Author: ZhouJie
	 * @Description: 鍗忓悓鍔炲叕璇︽儏鏌ヨ
	 */
	@RequestMapping(value = "/find-cooperate/{version}", method = RequestMethod.POST)
	@ApiVersion(1)
	public String getCooperateInfo(HttpServletRequest request) {
		try {
			// 鑾峰彇鍙傛暟
			FieldSetEntity fse = null;
			Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA);
			if (bean != null) {
				RequestParameterEntity reqp = (RequestParameterEntity) bean;
				fse = reqp.getFormData();
			}
			// 鍒ゆ柇鍙傛暟鏄惁涓虹┖
			if (bean == null || fse == null) {
				SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_FORM_NODATA.getValue(),
						SystemCode.SYSTEM_FORM_NODATA.getText());
				return this.error(SystemCode.SYSTEM_FORM_NODATA.getValue(), SystemCode.SYSTEM_FORM_NODATA.getText());
			}
			// 鍒ゆ柇琛ㄥ悕鏄惁姝e父
			if (!CmnConst.PRODUCT_OA_COOPERATES.equals(fse.getTableName())) {
				SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_TABLE_NODATA.getValue(),
						SystemCode.SYSTEM_TABLE_NODATA.getText());
				return this.error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText());
			}
			// 鍒ゆ柇uuid鏄惁涓虹┖
			if (com.alibaba.druid.util.StringUtils.isEmpty(fse.getString("uuid"))) {
				SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_TABLE_NODATA.getValue(),
						SystemCode.SYSTEM_TABLE_NODATA.getText());
				return this.error(SystemCode.SYSTEM_FORM_COUNT.getValue(), SystemCode.SYSTEM_FORM_COUNT.getText());
			}
			return cooperatesService.getCooperateInfo(fse);
		} catch (BaseException e) {
			e.printStackTrace();
			SpringMVCContextHolder.getSystemLogger().error(e);
			return this.error(e);
		} catch (Exception e) {
			e.printStackTrace();
			SpringMVCContextHolder.getSystemLogger().error(e);
			return this.error(SystemCode.SYSTEM_GET_COOPERATES_INFO_FAIL.getValue(),
					SystemCode.SYSTEM_GET_COOPERATES_INFO_FAIL.getText());
		}
	}

	/**
	 * @Date: 2020-04-16 15:06
	 * @Author: zm
	 * @Description: 鍙戝竷鍗忓悓鍔炲叕
	 */
	@RequestMapping(value = "/release-cooperate/{version}", method = RequestMethod.POST)
	public String releaseCooperate(HttpServletRequest request) {
		try {
			// 鑾峰彇鍙傛暟
			FieldSetEntity fse = null;
			Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA);
			if (bean != null) {
				RequestParameterEntity reqp = (RequestParameterEntity) bean;
				fse = reqp.getFormData();
			}
			// 鍒ゆ柇鍙傛暟鏄惁涓虹┖
			if (bean == null || fse == null) {
				SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_FORM_NODATA.getValue(),
						SystemCode.SYSTEM_FORM_NODATA.getText());
				return this.error(SystemCode.SYSTEM_FORM_NODATA.getValue(), SystemCode.SYSTEM_FORM_NODATA.getText());
			}
			// 鍒ゆ柇琛ㄥ悕鏄惁姝e父
			if (!CmnConst.PRODUCT_OA_COOPERATES.equals(fse.getTableName())) {
				SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_TABLE_NODATA.getValue(),
						SystemCode.SYSTEM_TABLE_NODATA.getText());
				return this.error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText());
			}
			fse.setValue("type",4);
			cooperatesService.sendCooperate(fse);
			return OK();
		} catch (BaseException e) {
			e.printStackTrace();
			SpringMVCContextHolder.getSystemLogger().error(e);
			return this.error(e);
		} catch (Exception e) {
			e.printStackTrace();
			SpringMVCContextHolder.getSystemLogger().error(e);
			return this.error(SystemCode.SYSTEM_ADD_COOPERATES_FAIL.getValue(),
					SystemCode.SYSTEM_ADD_COOPERATES_FAIL.getText());
		}
	}

	/**
	 * @Date: 2020-03-23 15:06
	 * @Author: ZhouJie
	 * @Description: 鏂板鍗忓悓鍔炲叕
	 */
	@RequestMapping(value = "/add-cooperate/{version}", method = RequestMethod.POST)
	public String addCooperate(HttpServletRequest request) {
		try {
			// 鑾峰彇鍙傛暟
			FieldSetEntity fse = null;
			Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA);
			if (bean != null) {
				RequestParameterEntity reqp = (RequestParameterEntity) bean;
				fse = reqp.getFormData();
			}
			// 鍒ゆ柇鍙傛暟鏄惁涓虹┖
			if (bean == null || fse == null) {
				SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_FORM_NODATA.getValue(),
						SystemCode.SYSTEM_FORM_NODATA.getText());
				return this.error(SystemCode.SYSTEM_FORM_NODATA.getValue(), SystemCode.SYSTEM_FORM_NODATA.getText());
			}
			// 鍒ゆ柇琛ㄥ悕鏄惁姝e父
			if (!CmnConst.PRODUCT_OA_COOPERATES.equals(fse.getTableName())) {
				SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_TABLE_NODATA.getValue(),
						SystemCode.SYSTEM_TABLE_NODATA.getText());
				return this.error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText());
			}
			ICooperatesService service = (ICooperatesService) getProxyInstance(
					cooperatesService);
			String uuid = service.addCooperate(fse);
			if (!StringUtils.isEmpty(uuid)) {
				return OK_Add(uuid);
			}
			SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_ADD_COOPERATES_FAIL.getValue(),
					SystemCode.SYSTEM_ADD_COOPERATES_FAIL.getText());
			return error(SystemCode.SYSTEM_ADD_COOPERATES_FAIL.getValue(),
					SystemCode.SYSTEM_ADD_COOPERATES_FAIL.getText());
		} catch (BaseException e) {
			e.printStackTrace();
			SpringMVCContextHolder.getSystemLogger().error(e);
			return this.error(e);
		} catch (Exception e) {
			e.printStackTrace();
			SpringMVCContextHolder.getSystemLogger().error(e);
			return this.error(SystemCode.SYSTEM_ADD_COOPERATES_FAIL.getValue(),
					SystemCode.SYSTEM_ADD_COOPERATES_FAIL.getText());
		}
	}

	/**
	 * @Date: 2020-03-23 16:31
	 * @Author: ZhouJie
	 * @Description: 淇敼鍗忓悓
	 */
	@RequestMapping(value = "/update-cooperate/{version}", method = RequestMethod.POST)
	@ApiVersion(1)
	public String updateCooperate(HttpServletRequest request) {
		try {
			// 鑾峰彇鍙傛暟
			FieldSetEntity fse = null;
			Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA);
			if (bean != null) {
				RequestParameterEntity reqp = (RequestParameterEntity) bean;
				fse = reqp.getFormData();
			}
			// 鍒ゆ柇鍙傛暟鏄惁涓虹┖
			if (bean == null || fse == null) {
				SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_FORM_NODATA.getValue(),
						SystemCode.SYSTEM_FORM_NODATA.getText());
				return this.error(SystemCode.SYSTEM_FORM_NODATA.getValue(), SystemCode.SYSTEM_FORM_NODATA.getText());
			}
			// 鍒ゆ柇琛ㄥ悕鏄惁姝e父
			if (!CmnConst.PRODUCT_OA_COOPERATES.equals(fse.getTableName())) {
				SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_TABLE_NODATA.getValue(),
						SystemCode.SYSTEM_TABLE_NODATA.getText());
				return this.error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText());
			}
			// 鍒ゆ柇uuid鏄惁涓虹┖
			if (com.alibaba.druid.util.StringUtils.isEmpty(fse.getString("uuid"))) {
				SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_FORM_COUNT.getValue(),
						SystemCode.SYSTEM_FORM_COUNT.getText());
				return this.error(SystemCode.SYSTEM_FORM_COUNT.getValue(), SystemCode.SYSTEM_FORM_COUNT.getText());
			}
			ICooperatesService service = (ICooperatesService) getProxyInstance(
					cooperatesService);
			boolean succ = service.updateCooperate(fse);
			if (succ) {
				return OK();
			}
			SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_UPDATE_COOPERATES_FAIL.getValue(),
					SystemCode.SYSTEM_UPDATE_COOPERATES_FAIL.getText());
			return error(SystemCode.SYSTEM_UPDATE_COOPERATES_FAIL.getValue(),
					SystemCode.SYSTEM_UPDATE_COOPERATES_FAIL.getText());
		} catch (BaseException e) {
			e.printStackTrace();
			SpringMVCContextHolder.getSystemLogger().error(e);
			return this.error(e);
		} catch (Exception e) {
			e.printStackTrace();
			SpringMVCContextHolder.getSystemLogger().error(e);
			return this.error(SystemCode.SYSTEM_UPDATE_COOPERATES_FAIL.getValue(),
					SystemCode.SYSTEM_UPDATE_COOPERATES_FAIL.getText());
		}
	}

	/**
	 * @Date: 2020-03-23 17:13
	 * @Author: ZhouJie
	 * @Description: 鍒犻櫎鍗忓悓
	 */
	@RequestMapping(value = "/delete-cooperate/{version}", method = RequestMethod.POST)
	@ApiVersion(1)
	public String deleteCooperate(HttpServletRequest request) {
		try {
			// 鑾峰彇鍙傛暟
			FieldSetEntity fse = null;
			Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA);
			if (bean != null) {
				RequestParameterEntity reqp = (RequestParameterEntity) bean;
				fse = reqp.getFormData();
			}
			// 鍒ゆ柇鍙傛暟鏄惁涓虹┖
			if (bean == null || fse == null) {
				SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_FORM_NODATA.getValue(),
						SystemCode.SYSTEM_FORM_NODATA.getText());
				return this.error(SystemCode.SYSTEM_FORM_NODATA.getValue(), SystemCode.SYSTEM_FORM_NODATA.getText());
			}
			// 鍒ゆ柇琛ㄥ悕鏄惁姝e父
			if (!CmnConst.PRODUCT_OA_COOPERATES.equals(fse.getTableName())) {
				SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_TABLE_NODATA.getValue(),
						SystemCode.SYSTEM_TABLE_NODATA.getText());
				return this.error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText());
			}
			// 鍒ゆ柇uuid鏄惁涓虹┖
			if (com.alibaba.druid.util.StringUtils.isEmpty(fse.getString("uuid"))) {
				SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_FORM_COUNT.getValue(),
						SystemCode.SYSTEM_FORM_COUNT.getText());
				return this.error(SystemCode.SYSTEM_FORM_COUNT.getValue(), SystemCode.SYSTEM_FORM_COUNT.getText());
			}
			ICooperatesService service = (ICooperatesService) getProxyInstance(
					cooperatesService);
			boolean success = service.deleteCooperate(fse);
			if (success) {
				return OK();
			}
			SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_DELETE_COOPERATES_FAIL.getValue(),
					SystemCode.SYSTEM_DELETE_COOPERATES_FAIL.getText());
			return error(SystemCode.SYSTEM_DELETE_COOPERATES_FAIL.getValue(),
					SystemCode.SYSTEM_DELETE_COOPERATES_FAIL.getText());
		} catch (BaseException e) {
			e.printStackTrace();
			SpringMVCContextHolder.getSystemLogger().error(e);
			return this.error(e);
		} catch (Exception e) {
			e.printStackTrace();
			SpringMVCContextHolder.getSystemLogger().error(e);
			return this.error(SystemCode.SYSTEM_DELETE_COOPERATES_FAIL.getValue(),
					SystemCode.SYSTEM_DELETE_COOPERATES_FAIL.getText());
		}
	}
	/**
	 * @Date: 2020-04-01 16:06
	 * @Author: ZhouJie
	 * @Description: 鍗忓悓鍔炲叕閫佸姙
	 */
	@RequestMapping(value = "/send-cooperate/{version}", method = RequestMethod.POST)
	public String sendCooperate(HttpServletRequest request) {
		try {
			// 鑾峰彇鍙傛暟
			FieldSetEntity fse = null;
			Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA);
			if (bean != null) {
				RequestParameterEntity reqp = (RequestParameterEntity) bean;
				fse = reqp.getFormData();
			}
			// 鍒ゆ柇鍙傛暟鏄惁涓虹┖
			if (bean == null || fse == null) {
				SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_FORM_NODATA.getValue(),
						SystemCode.SYSTEM_FORM_NODATA.getText());
				return this.error(SystemCode.SYSTEM_FORM_NODATA.getValue(), SystemCode.SYSTEM_FORM_NODATA.getText());
			}
			// 鍒ゆ柇琛ㄥ悕鏄惁姝e父
			if (!CmnConst.PRODUCT_OA_COOPERATES.equals(fse.getTableName())) {
				SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_TABLE_NODATA.getValue(),
						SystemCode.SYSTEM_TABLE_NODATA.getText());
				return this.error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText());
			}
			cooperatesService.sendCooperate(fse);

			return OK();
		} catch (BaseException e) {
			e.printStackTrace();
			SpringMVCContextHolder.getSystemLogger().error(e);
			return this.error(e);
		} catch (Exception e) {
			e.printStackTrace();
			SpringMVCContextHolder.getSystemLogger().error(e);
			return this.error(SystemCode.SYSTEM_SEND_COOPERATES_FAIL.getValue(),
					SystemCode.SYSTEM_SEND_COOPERATES_FAIL.getText());
		}
	}
	/**
	 * @Date: 2020-04-01 16:06
	 * @Author: ZhouJie
	 * @Description: 鍗忓悓鍔炲叕鎾ゅ洖鎴栬€呬腑姝� type 5涓 6 鎾ゅ洖
	 */
	@RequestMapping(value = "/recession-stop-cooperate/{version}", method = RequestMethod.POST)
	public String recessionOrStopCooperate(HttpServletRequest request) {
		try {
			// 鑾峰彇鍙傛暟
			FieldSetEntity fse = null;
			Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA);
			if (bean != null) {
				RequestParameterEntity reqp = (RequestParameterEntity) bean;
				fse = reqp.getFormData();
			}
			// 鍒ゆ柇鍙傛暟鏄惁涓虹┖
			if (bean == null || fse == null) {
				SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_FORM_NODATA.getValue(),
						SystemCode.SYSTEM_FORM_NODATA.getText());
				return this.error(SystemCode.SYSTEM_FORM_NODATA.getValue(), SystemCode.SYSTEM_FORM_NODATA.getText());
			}
			// 鍒ゆ柇琛ㄥ悕鏄惁姝e父
			if (!CmnConst.PRODUCT_OA_COOPERATES.equals(fse.getTableName())) {
				SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_TABLE_NODATA.getValue(),
						SystemCode.SYSTEM_TABLE_NODATA.getText());
				return this.error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText());
			}
			flowCoordinationService.saveCoordinationStartFlow(fse);
			return OK();
		} catch (BaseException e) {
			e.printStackTrace();
			SpringMVCContextHolder.getSystemLogger().error(e);
			return this.error(e);
		} catch (Exception e) {
			e.printStackTrace();
			SpringMVCContextHolder.getSystemLogger().error(e);
			return this.error(SystemCode.SYSTEM_SEND_COOPERATES_FAIL.getValue(),
					SystemCode.SYSTEM_SEND_COOPERATES_FAIL.getText());
		}
	}
	/**
	 * @description: 鏆傚瓨寰呭姙
	 * @author: ZhouJie
	 * @date: 2021-05-26 16:44
	 */
	@RequestMapping(value = "/save-todo/{version}", method = RequestMethod.POST)
	public String saveTodo(HttpServletRequest request) {
		try {
			// 鑾峰彇鍙傛暟
			FieldSetEntity fse = null;
			Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA);
			if (bean != null) {
				RequestParameterEntity reqp = (RequestParameterEntity) bean;
				fse = reqp.getFormData();
			}
			// 鍒ゆ柇鍙傛暟鏄惁涓虹┖
			if (bean == null || fse == null) {
				SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_FORM_NODATA.getValue(),
						SystemCode.SYSTEM_FORM_NODATA.getText());
				return this.error(SystemCode.SYSTEM_FORM_NODATA.getValue(), SystemCode.SYSTEM_FORM_NODATA.getText());
			}
			// 鍒ゆ柇琛ㄥ悕鏄惁姝e父
			if (!CmnConst.PRODUCT_OA_COOPERATE_FLOW_NODE.equals(fse.getTableName())) {
				SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_TABLE_NODATA.getValue(),
						SystemCode.SYSTEM_TABLE_NODATA.getText());
				return this.error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText());
			}
			cooperatesService.saveTodo(fse);
			return OK();
		} catch (BaseException e) {
			e.printStackTrace();
			SpringMVCContextHolder.getSystemLogger().error(e);
			return this.error(e);
		} catch (Exception e) {
			e.printStackTrace();
			SpringMVCContextHolder.getSystemLogger().error(e);
			return this.error(SystemCode.SYSTEM_SEND_COOPERATE_TODO_FAIL.getValue(),
					SystemCode.SYSTEM_SEND_COOPERATE_TODO_FAIL.getText());
		}
	}
	/**
	 * @description: 鍗忓悓琛ュ厖姝f枃
	 * @author: ZhouJie
	 * @date: 2021-06-02 17:23
	 */
	@RequestMapping(value = "/add-supply/{version}", method = RequestMethod.POST)
	public String addSupplyText(HttpServletRequest request) {
		try {
			// 鑾峰彇鍙傛暟
			FieldSetEntity fse = null;
			Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA);
			if (bean != null) {
				RequestParameterEntity reqp = (RequestParameterEntity) bean;
				fse = reqp.getFormData();
			}
			// 鍒ゆ柇鍙傛暟鏄惁涓虹┖
			if (bean == null || fse == null) {
				SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_FORM_NODATA.getValue(),
						SystemCode.SYSTEM_FORM_NODATA.getText());
				return this.error(SystemCode.SYSTEM_FORM_NODATA.getValue(), SystemCode.SYSTEM_FORM_NODATA.getText());
			}
			// 鍒ゆ柇琛ㄥ悕鏄惁姝e父
			if (!CmnConst.PRODUCT_OA_COOPERATE_SUB.equals(fse.getTableName())) {
				SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_TABLE_NODATA.getValue(),
						SystemCode.SYSTEM_TABLE_NODATA.getText());
				return this.error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText());
			}
			ICooperatesService service = (ICooperatesService) getProxyInstance(
					cooperatesService);
			String uuid = service.addSupplyText(fse);
			if (!StringUtils.isEmpty(uuid)) {
				return OK_Add(uuid);
			}
			SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_AND_COOPERATE_SUPPLY_FAIL.getValue(),
					SystemCode.SYSTEM_AND_COOPERATE_SUPPLY_FAIL.getText());
			return error(SystemCode.SYSTEM_AND_COOPERATE_SUPPLY_FAIL.getValue(),
					SystemCode.SYSTEM_AND_COOPERATE_SUPPLY_FAIL.getText());
		} catch (BaseException e) {
			e.printStackTrace();
			SpringMVCContextHolder.getSystemLogger().error(e);
			return this.error(e);
		} catch (Exception e) {
			e.printStackTrace();
			SpringMVCContextHolder.getSystemLogger().error(e);
			return this.error(SystemCode.SYSTEM_AND_COOPERATE_SUPPLY_FAIL.getValue(),
					SystemCode.SYSTEM_AND_COOPERATE_SUPPLY_FAIL.getText());
		}
	}
	/**
	 * @description: 鍗忓悓琛ュ厖姝f枃鍒犻櫎
	 * @author: ZhouJie
	 * @date: 2021-06-02 17:23
	 */
	@PostMapping("/delete-supply/{version}")
	@ApiVersion(1)
	public String delSupplyText(HttpServletRequest request) {
		try {
			// 鑾峰彇鍙傛暟
			FieldSetEntity fse = null;
			Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA);
			if (bean != null) {
				RequestParameterEntity reqp = (RequestParameterEntity) bean;
				fse = reqp.getFormData();
			}
			// 鍒ゆ柇鍙傛暟鏄惁涓虹┖
			if (bean == null || fse == null) {
				SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_FORM_NODATA.getValue(),
						SystemCode.SYSTEM_FORM_NODATA.getText());
				return this.error(SystemCode.SYSTEM_FORM_NODATA.getValue(), SystemCode.SYSTEM_FORM_NODATA.getText());
			}
			// 鍒ゆ柇琛ㄥ悕鏄惁姝e父
			if (!CmnConst.PRODUCT_OA_COOPERATE_SUB.equals(fse.getTableName())) {
				SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_TABLE_NODATA.getValue(),
						SystemCode.SYSTEM_TABLE_NODATA.getText());
				return this.error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText());
			}
			ICooperatesService service = (ICooperatesService) getProxyInstance(
					cooperatesService);
			boolean success = service.delSupplyText(fse);
			if (success) {
				return OK();
			}
			SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_AND_COOPERATE_SUPPLY_FAIL.getValue(),
					SystemCode.SYSTEM_AND_COOPERATE_SUPPLY_FAIL.getText());
			return error(SystemCode.SYSTEM_AND_COOPERATE_SUPPLY_FAIL.getValue(),
					SystemCode.SYSTEM_AND_COOPERATE_SUPPLY_FAIL.getText());
		} catch (BaseException e) {
			e.printStackTrace();
			SpringMVCContextHolder.getSystemLogger().error(e);
			return this.error(e);
		} catch (Exception e) {
			e.printStackTrace();
			SpringMVCContextHolder.getSystemLogger().error(e);
			return this.error(SystemCode.SYSTEM_AND_COOPERATE_SUPPLY_FAIL.getValue(),
					SystemCode.SYSTEM_AND_COOPERATE_SUPPLY_FAIL.getText());
		}
	}
	/**
	 * @description: 鍗忓悓鍔炲叕鍌姙
	 * @author: ZhouJie
	 * @date: 2021-06-03 17:03
	 */
	@RequestMapping(value = "/send-urge/{version}", method = RequestMethod.POST)
	public String urging(HttpServletRequest request) {
		try {
			// 鑾峰彇鍙傛暟
			FieldSetEntity fse = null;
			Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA);
			if (bean != null) {
				RequestParameterEntity reqp = (RequestParameterEntity) bean;
				fse = reqp.getFormData();
			}
			// 鍒ゆ柇鍙傛暟鏄惁涓虹┖
			if (bean == null || fse == null) {
				SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_FORM_NODATA.getValue(),
						SystemCode.SYSTEM_FORM_NODATA.getText());
				return this.error(SystemCode.SYSTEM_FORM_NODATA.getValue(), SystemCode.SYSTEM_FORM_NODATA.getText());
			}
			// 鍒ゆ柇琛ㄥ悕鏄惁姝e父
			if (!CmnConst.PRODUCT_OA_COOPERATES.equals(fse.getTableName())) {
				SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_TABLE_NODATA.getValue(),
						SystemCode.SYSTEM_TABLE_NODATA.getText());
				return this.error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText());
			}
			cooperatesService.urging(fse);
			return OK();
		} catch (BaseException e) {
			e.printStackTrace();
			SpringMVCContextHolder.getSystemLogger().error(e);
			return this.error(e);
		} catch (Exception e) {
			e.printStackTrace();
			SpringMVCContextHolder.getSystemLogger().error(e);
			return this.error(SystemCode.SYSTEM_URGING_FAIL.getValue(),
					SystemCode.SYSTEM_URGING_FAIL.getText());
		}
	}
	/**
	 * @description: 娑堟伅鐘舵€佹敼涓衡€滃凡鏀舵湭鍔炩€�
	 * @author: ZhouJie
	 * @date: 2021-06-11 10:59
	 */
	@RequestMapping(value = "/modify-state/{version}", method = RequestMethod.POST)
	public String modifyState(HttpServletRequest request) {
		try {
			FieldSetEntity fse=null;
			Object bean=request.getAttribute(CoreConst.API_POST_REQUEST_DATA);
			if(bean != null){
				RequestParameterEntity reqp=(RequestParameterEntity)bean;
				fse = reqp.getFormData();
			}
			//鍒ゆ柇鍙傛暟鏄惁涓虹┖
			if(bean == null || fse == null) {
				SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_FORM_NODATA.getValue(), SystemCode.SYSTEM_FORM_NODATA.getText());
				return this.error(SystemCode.SYSTEM_FORM_NODATA.getValue(), SystemCode.SYSTEM_FORM_NODATA.getText());
			}
			//鍒ゆ柇琛ㄥ悕鏄惁姝e父
			if (!CmnConst.PRODUCT_OA_COOPERATE_FLOW_NODE.equals(fse.getTableName())) {
				SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), com.product.core.websocket.config.SystemCode.SYSTEM_MESSAGE_ACQUIRE_PARAM_FAIL.getText());
				return this.error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText());
			}
			boolean sucess = cooperatesService.modifyState(fse.getUUID());
			if (sucess) {
				return OK();
			}
			SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_READ_NEWS_FAIL.getValue(), SystemCode.SYSTEM_READ_NEWS_FAIL.getText());
			return error(SystemCode.SYSTEM_READ_NEWS_FAIL.getValue(), SystemCode.SYSTEM_READ_NEWS_FAIL.getText());
		} catch (BaseException e) {
			e.printStackTrace();
			return error(e);
		} catch (Exception e) {
			e.printStackTrace();
			return this.error(SystemCode.SYSTEM_READ_NEWS_FAIL.getValue(),SystemCode.SYSTEM_READ_NEWS_FAIL.getText());
		}
	}

	/**
	 * @description: 娑堟伅鐘舵€佹敼涓衡€滃凡鏀舵湭鍔炩€�
	 * @author: ZhouJie
	 * @date: 2021-06-11 10:59
	 */
	@RequestMapping(value = "/user-list/{version}", method = RequestMethod.POST)
	public String getNowUserList(HttpServletRequest request) {
		try {
			FieldSetEntity fse=null;
			Object bean=request.getAttribute(CoreConst.API_POST_REQUEST_DATA);
			if(bean != null){
				RequestParameterEntity reqp=(RequestParameterEntity)bean;
				fse = reqp.getFormData();
			}
			//鍒ゆ柇鍙傛暟鏄惁涓虹┖
			if(bean == null || fse == null) {
				SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_FORM_NODATA.getValue(), SystemCode.SYSTEM_FORM_NODATA.getText());
				return this.error(SystemCode.SYSTEM_FORM_NODATA.getValue(), SystemCode.SYSTEM_FORM_NODATA.getText());
			}
			//鍒ゆ柇琛ㄥ悕鏄惁姝e父
			if (!CmnConst.PRODUCT_OA_COOPERATES.equals(fse.getTableName())) {
				SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), com.product.core.websocket.config.SystemCode.SYSTEM_MESSAGE_ACQUIRE_PARAM_FAIL.getText());
				return this.error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText());
			}
			DataTableEntity dt = cooperatesService.getNowUserList(fse);
			return OK_List(dt);
		} catch (BaseException e) {
			e.printStackTrace();
			return error(e);
		} catch (Exception e) {
			e.printStackTrace();
			return this.error(SystemCode.SYSTEM_GET_COOPERATES_LIST_FAIL.getValue(),SystemCode.SYSTEM_GET_COOPERATES_LIST_FAIL.getText());
		}
	}


}