You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

134 lines
5.1 KiB
Java

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

package com.api.mobilemode.web.mobile.browser;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.api.fna.service.impl.BudgetfeeTypeBrowserService;
import com.api.fna.util.FnaConstant;
import com.api.mobilemode.web.mobile.ActionMapping;
import com.api.mobilemode.web.mobile.BaseMobileAction;
import com.cloudstore.dev.api.service.Service_DevTable;
import com.weaver.formmodel.mobile.utils.BrowserUtil;
import com.weaver.formmodel.util.StringHelper;
import weaver.general.Util;
import weaver.hrm.company.DepartmentComInfo;
import weaver.hrm.company.SubCompanyComInfo;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
/**
* 公用系统浏览框action
* 从commonbrowser中分离用于处理常用需个性化处理的公用系统浏览框
*/
public class SystemBrowserAction extends BaseMobileAction {
private static final long serialVersionUID = 393862748977092668L;
// 部门浏览框id
private static final String[] DEPT_IDS = {"4", "57", "167", "168"};
// 分部浏览框id
private static final String[] SUBCOMPANY_IDS = {"164", "194", "169", "170"};
private static final String DEPT_FIELD = "19135";
public SystemBrowserAction(HttpServletRequest request,
HttpServletResponse response) {
super(request, response);
}
/**
* 通过browserid获取浏览框数据列表数据返回dataKey树形数据返回节点信息
* @return
*/
@ActionMapping(name = "getData")
public JSONObject getData() {// 22:报销费用类型, 4:部门, 57:多部门, 167:分权单部门, 168:分权多部门, 164:分部, 194:多分部, 169:分权单分部, 170:分权多分部
String browserId = Util.null2String(getParameter("browserId"));
JSONObject apidatas = new JSONObject();
String fieldid = Util.null2String(pageParam.get("fieldid"));
if (DEPT_FIELD.equals(fieldid)){
pageParam.put("fromModule","model");
pageParam.put("isFromMode","1");
pageParam.put("modeId","147");
pageParam.put("isbill","1");
}
apidatas.putAll(JSONObject.parseObject(JSON.toJSONString(BrowserUtil.getDataBySysApiService(browserId, pageParam, user))));
boolean isSubCompany = Arrays.asList(SUBCOMPANY_IDS).contains(browserId);
if (Arrays.asList(DEPT_IDS).contains(browserId) || isSubCompany) {// 分部 or 部门
String selectedIds = Util.null2String(getParameter("selectedIds"));
if (selectedIds.length() > 0) {
DepartmentComInfo departmentComInfo = new DepartmentComInfo();
SubCompanyComInfo subCompanyComInfo = new SubCompanyComInfo();
JSONArray selArr = new JSONArray();
Arrays.asList(selectedIds.split(",")).forEach(id -> {
String name = isSubCompany ? subCompanyComInfo.getSubCompanyname(id) : departmentComInfo.getDepartmentname(id);// 分部/部门名称
if (StringHelper.isNotEmpty(name)) {
JSONObject dept = new JSONObject();
dept.put("id", id);
dept.put("name", name);
selArr.add(dept);
}
});
apidatas.put("sel_datas", selArr);
}
}
if ("1".equals(getParameter("list"))) {
//获取列表
String dataKey = Util.null2String(apidatas.get("datas"));
String pageSize = Util.null2String(getParameter("pageSize"));
String current = Util.null2String(getParameter("current"));
return executeWithSession(() -> {
JSONObject datas = new JSONObject();
Service_DevTable devTableService = new Service_DevTable();
String dataTable = devTableService.datas(this.getRequest(), this.getResponse(), dataKey, pageSize, "", "", "", current, "1");
datas.putAll(JSON.parseObject(dataTable));
datas.put("sel_datas", apidatas.get("sel_datas"));
return datas;
});
}
return apidatas;
}
/**
* 通过dataKey获取分页列表数据
* @return
*/
@ActionMapping(name = "getListData")
public JSONObject getListData() {
String dataKey = Util.null2String(getParameter("dataKey"));
String pageSize = Util.null2String(getParameter("pageSize"));
String min = Util.null2String(getParameter("min"));
String max = Util.null2String(getParameter("max"));
String current = Util.null2String(getParameter("current"));
return executeWithSession(() -> {
JSONObject apidatas = new JSONObject();
Service_DevTable devTableService = new Service_DevTable();
String dataTable = devTableService.datas(this.getRequest(), this.getResponse(), dataKey, pageSize, "", min, max, current, "1");
apidatas.putAll(JSON.parseObject(dataTable));
return apidatas;
});
}
/**
* 更新报销费用浏览框最近信息
*/
@ActionMapping(name = "updateBudgetfeeTypeUsed")
public JSONObject updateBudgetfeeTypeUsed() {
Map<String, Object> apidatas = new HashMap<String, Object>();
Map<String, Object> params = new HashMap<>();
params.putAll(pageParam);
if (user == null) {
apidatas.put(FnaConstant.FNA_RESULT_DATA, null);
} else {
apidatas = new BudgetfeeTypeBrowserService().updateBudgetfeeTypeUsed(user, params);
}
return JSONObject.parseObject(JSON.toJSONString(apidatas));
}
}