package com.yc.api.controller;
|
|
import com.alibaba.fastjson.JSON;
|
import com.google.gson.JsonObject;
|
import com.yc.action.BaseAction;
|
import com.yc.action.grid.GridUtils;
|
import com.yc.action.grid.TreeGridDTO;
|
import com.yc.action.new38action.Type38action;
|
import com.yc.action.panval.DocNavigation;
|
import com.yc.action.upload.AttachmentAction;
|
import com.yc.action.upload.PostBeanInfo;
|
import com.yc.api.bean.*;
|
import com.yc.api.service.ApiServiceIfc;
|
import com.yc.api.utils.FileUtil;
|
import com.yc.entity.AttachmentConfig;
|
import com.yc.entity.UserAccountEntity;
|
import com.yc.exception.ApplicationException;
|
import com.yc.exception.CallBackMessage;
|
import com.yc.factory.FactoryBean;
|
import com.yc.ionic.action.LinksBean;
|
import com.yc.ionic.schedule.ZipUtil;
|
import com.yc.multiData.SpObserver;
|
import com.yc.sdk.password.action.ChangePassword;
|
import com.yc.sdk.shopping.action.VerificationCodes;
|
import com.yc.sdk.shopping.action.api.InvitationCode;
|
import com.yc.service.BaseService;
|
import com.yc.service.build.top.BuildTopIfc;
|
import com.yc.service.grid.GridServiceIfc;
|
import com.yc.service.sqlformat.entity.SqlFormatEntity;
|
import com.yc.service.sqlformat.utils.SqlFormatUtils;
|
import com.yc.service.user.UserAccountServiceIfc;
|
import com.yc.utils.EncodeUtil;
|
import com.yc.utils.SessionKey;
|
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.lang3.StringUtils;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.dao.EmptyResultDataAccessException;
|
import org.springframework.data.redis.core.RedisTemplate;
|
import org.springframework.jdbc.support.rowset.SqlRowSet;
|
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
import org.springframework.stereotype.Controller;
|
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.context.request.async.WebAsyncTask;
|
|
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletResponse;
|
import java.io.File;
|
import java.io.IOException;
|
import java.net.URLDecoder;
|
import java.sql.SQLException;
|
import java.util.ArrayList;
|
import java.util.HashMap;
|
import java.util.List;
|
import java.util.Map;
|
import java.util.concurrent.Callable;
|
import java.util.concurrent.TimeUnit;
|
|
import static java.util.stream.Collectors.toList;
|
|
@Controller
|
public class ApiController extends BaseAction {
|
|
@Autowired
|
GridServiceIfc gridService;
|
@Autowired
|
RedisTemplate redisTemplate;
|
@Autowired
|
ThreadPoolTaskExecutor threadPoolExecutor;
|
@Autowired
|
ApiServiceIfc apiServiceIfc;
|
private static String sysfunclink = "b.[origformid] " +
|
",b.[origformtype] " +
|
",b.[sortid] " +
|
",b.[linklabel] " +
|
",b.[linkformid] " +
|
",b.[linkformtype] " +
|
",b.[linkdescribe] " +
|
",b.[linkmode] " +
|
",b.[hotkey] " +
|
",b.[spfield] " +
|
",b.[close_origform] " +
|
",b.[origfields] " +
|
",b.[linkfields] " +
|
",b.[orighdfields] " +
|
",b.[linkhdfields] " +
|
",b.[efilter] " +
|
",b.[warnmessage] " +
|
",b.[self_datafields] " +
|
",b.[link_datafields] " +
|
",b.[firstrecord_editmode] " +
|
",b.[return_one_record] " +
|
",b.[numfieldid] " +
|
",b.[locksqlwhere] " +
|
",b.[showbutton] " +
|
",b.[returndataset] " +
|
",b.[refresh_origform] " +
|
",b.[numfieldid_origform] " +
|
",b.[noshowspmessage] " +
|
",b.[linkformdisplayfields]" +
|
",b.[ftlockconditionflag] " +
|
",b.[groupname] " +
|
",b.[navigateyn] " +
|
",b.[editstatus] " +
|
",b.[isshowpwdedit] " +
|
",b.[selectchecker] " +
|
",b.[returncurchecker] " +
|
",b.[returncurcheckername] " +
|
",b.[smallimagefilename] " +
|
",b.[smallimagefilepath] " +
|
",b.[ft] " +
|
",b.[ftformtype] " +
|
",b.[fk] " +
|
",b.[seekgroupid] " +
|
",b.[spremissfield] " +
|
",b.[dpremissfield] " +
|
",b.[fkefilter] " +
|
",b.[isautosaved] " +
|
",b.[showitemexpression] " +
|
",b.[linkscope] ";
|
|
private static String gformFilter = "[formid] " +
|
",[statisid] " +
|
",[fieldid] " +
|
",[fieldname] " +
|
",[ft] " +
|
",[ftformtype] " +
|
",[emptyrefdata] " +
|
",[fk] " +
|
",[seekgroupid] " +
|
",[spremissfield] " +
|
",[dpremissfield] " +
|
",[efilter] " +
|
",[return_one_record]" +
|
",[numfieldid] " +
|
",[visible] " +
|
",[hidelabel] " +
|
",[controltype] " +
|
",[rowno] " +
|
",[colno] " +
|
",[lengthnum] " +
|
",[heightnum] " +
|
",[initvalue] " +
|
",[compsingle] " +
|
",[sqlscript] " +
|
",[memo] ";
|
private static String sysmasterdetail = "[formid] " +
|
",[detailformid] " +
|
",[masterfield] " +
|
",[masterkeys] " +
|
",[detailkeys] " +
|
",[mastersumfields] " +
|
",[detailsumfields] " +
|
",[detailreadonly] " +
|
",[detailmemo] " +
|
",[sequenceid] " +
|
",[gridheight] ";
|
|
private static String systreeset = "[formid] " +
|
",[formtype] " +
|
",[treeformid] " +
|
",[treeName] " +
|
",[SortID] " +
|
",[keyfield] " +
|
",[parentfield] " +
|
",[nodeid] " +
|
",[listfield] " +
|
",[displayfield] " +
|
",[separatedst] " +
|
",[treefield] " +
|
",[autocodefield] " +
|
",[treefilterstr] " +
|
",[authcheck] " +
|
",[allowdrag] " +
|
",[defNodeTypeFilter] " +
|
",[startnodetypefilter]" +
|
",[treewidth]";
|
|
private static String TabPageFormid = "[mainformid] " +
|
",[mainformname] " +
|
",[FormGroupID] " +
|
",[FormGroupName] " +
|
",[SortBy] " +
|
",[formid] " +
|
",[formname] " +
|
",[formtype] " +
|
",[LabelName] " +
|
",[FT] " +
|
",[FTName] " +
|
",[FK] " +
|
",[SeekGroupID] " +
|
",[GridHeight] " +
|
",[GroupID] " +
|
",[GroupName] " +
|
",[TabID] " +
|
",[TabName] " +
|
",[TabHeight] " +
|
",[isStartupCollapsed]";
|
private static String table3 =
|
"a.[buttonID] ," +
|
"a.[ButtonName] ," +
|
"a.[formid] ," +
|
"a.[headflag] ," +
|
"a.[fieldid] ," +
|
"a.[docitem] ," +
|
"a.[ProcName] ," +
|
"a.[Memo] ," +
|
"a.[isShowPwdEdit] ," +
|
"a.[editStatus] ," +
|
"a.[SelectChecker] ," +
|
"a.[ReturnCurChecker] ," +
|
"a.[ReturnCurCheckerName] ," +
|
"a.[FT] ," +
|
"a.[FTFormType] ," +
|
"a.[FK] ," +
|
"a.[SeekGroupID] ," +
|
"a.[sPremissField] ," +
|
"a.[dPremissField] ," +
|
"a.[FKeFilter] ," +
|
"a.[isAutoSaved] ," +
|
"a.[showItemExpression] ," +
|
"a.[isInspection] ," +
|
"a.[isExchangeDataWithHost]," +
|
"a.[UrlShowLocation] ," +
|
"a.[ExternalURL], " +
|
"b.[IconPath],b.[isReturnToLastPage] \n ";
|
|
private String getDataType = "set nocount on select\n" +
|
"col.COLUMN_NAME as ColumnName,\n" +
|
"col.DATA_TYPE as DataType,\n" +
|
"col.CHARACTER_OCTET_LENGTH as DataLength\n" +
|
"--col.IS_NULLABLE as IsNullable,\n" +
|
"--ccu.CONSTRAINT_NAME as IsPrimaryKey,\n" +
|
"--de.value as Description\n" +
|
"from INFORMATION_SCHEMA.COLUMNS col\n" +
|
"left join INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE ccu\n" +
|
"on ccu.TABLE_NAME=col.TABLE_NAME\n" +
|
"and ccu.COLUMN_NAME=col.COLUMN_NAME\n" +
|
"and ccu.CONSTRAINT_NAME like 'PK_%'\n" +
|
"left join ::fn_listextendedproperty (NULL, 'user', 'dbo', 'table', ?,'column', default) as de\n" +
|
"on col.COLUMN_NAME = de.objname COLLATE Chinese_PRC_CI_AS\n" +
|
"where col.TABLE_NAME=?";
|
|
/**
|
* 出库扫序列号,检验是否与当前单据匹配
|
* 1,如果不存在则返回错误,提示所扫的物料不在当前出库单
|
* 2,如果有一个或多个结果,则返回给前端选择
|
*/
|
@RequestMapping(value = "/qr/ScanSerialNumberOut.do")
|
@ResponseBody
|
public Object scanSerialNumberOut(@RequestBody SerialNumberEntity entity, HttpServletRequest request) {
|
CallBackMessage callBackMessage = new CallBackMessage();
|
try {
|
SpObserver.setDBtoInstance("_" + request.getSession().getAttribute(SessionKey.DATA_BASE_ID));
|
if (StringUtils.isBlank(entity.getDocCode())) {
|
throw new ApplicationException("单号不能为空");
|
}
|
if (StringUtils.isBlank(entity.getSerialNumber())) {
|
throw new ApplicationException("序列号不能为空");
|
}
|
if (entity.getFormid() == null || entity.getFormid().intValue() == 0) {
|
throw new ApplicationException("功能号不能为空");
|
}
|
if (entity.getFormType() == null || entity.getFormType().intValue() == 0) {
|
throw new ApplicationException("功能类型不能为空");
|
}
|
final Map map = apiServiceIfc.getMatCodeBySerialNumberOut(entity);
|
|
if (GridUtils.prossRowSetDataType_Int(map, "state") == 0) {
|
if (GridUtils.prossRowSetDataType_Int(map, "Status") == 2) {
|
throw new ApplicationException(String.format("该序列号【%s】已经出库,不允许重复出库", entity.getSerialNumber()));
|
}
|
//表示序列号对应的物料存在于当前单据
|
map.remove("state");
|
callBackMessage.sendSuccessMessageByDefault();
|
callBackMessage.setInfo(map);
|
} else {
|
//表示序列号对应的物料不存在于当前单据,拿错物料
|
callBackMessage.sendErrorMessage("所扫物料不属于当前单据");
|
map.remove("state");
|
callBackMessage.setInfo(map);
|
}
|
return callBackMessage.toJSONObject();
|
} catch (EmptyResultDataAccessException ex) {
|
callBackMessage.sendErrorMessage(String.format("序列号【%s】不存在于当前库存,请检查", entity.getSerialNumber()));
|
return callBackMessage.toJSONObject();
|
} catch (Exception e) {
|
callBackMessage.sendErrorMessage(e.getMessage());
|
return callBackMessage.toJSONObject();
|
} finally {
|
SpObserver.setDBtoInstance();
|
}
|
|
}
|
|
/**
|
* 入库扫序列号,检验是否与当前单据匹配
|
* 1,如果不存在则返回错误,提示所扫的物料不在当前出库单
|
* 2,如果有一个或多个结果,则返回给前端选择
|
*/
|
@RequestMapping(value = "/qr/ScanSerialNumberIn.do")
|
@ResponseBody
|
public Object scanSerialNumberIn(@RequestBody SerialNumberEntity entity, HttpServletRequest request) {
|
CallBackMessage callBackMessage = new CallBackMessage();
|
try {
|
SpObserver.setDBtoInstance("_" + request.getSession().getAttribute(SessionKey.DATA_BASE_ID));
|
if (StringUtils.isBlank(entity.getDocCode())) {
|
throw new ApplicationException("单号不能为空");
|
}
|
if (StringUtils.isBlank(entity.getSerialNumber())) {
|
throw new ApplicationException("序列号不能为空");
|
}
|
if (entity.getFormid() == null || entity.getFormid().intValue() == 0) {
|
throw new ApplicationException("功能号不能为空");
|
}
|
if (entity.getFormType() == null || entity.getFormType().intValue() == 0) {
|
throw new ApplicationException("功能类型不能为空");
|
}
|
if (StringUtils.isBlank(entity.getMatCode())) {
|
throw new ApplicationException("物料编号不能为空");
|
}
|
Map map = apiServiceIfc.getMatCodeBySerialNumberIn(entity);
|
if (GridUtils.prossRowSetDataType_Int(map, "state") == 0) {
|
//表示序列号对应的物料存在于当前单据
|
map.remove("state");
|
callBackMessage.sendSuccessMessageByDefault();
|
callBackMessage.setInfo(map);
|
} else {
|
//表示序列号已入库,弹出提示,不能录入
|
throw new ApplicationException(String.format("该序列号【%s】已经存在,不允许重复入库", entity.getSerialNumber()));
|
}
|
return callBackMessage.toJSONObject();
|
} catch (Exception e) {
|
callBackMessage.sendErrorMessage(e.getMessage());
|
return callBackMessage.toJSONObject();
|
} finally {
|
SpObserver.setDBtoInstance();
|
}
|
|
}
|
|
/**
|
* 显示当前单据已扫的序列号列表
|
*/
|
@RequestMapping(value = "/qr/showSerialNumberInfo.do")
|
@ResponseBody
|
public Object showSerialNumberInfo(@RequestBody SerialNumberEntity entity, HttpServletRequest request) {
|
CallBackMessage callBackMessage = new CallBackMessage();
|
try {
|
SpObserver.setDBtoInstance("_" + request.getSession().getAttribute(SessionKey.DATA_BASE_ID));
|
if (StringUtils.isBlank(entity.getDocCode())) {
|
throw new ApplicationException("单号不能为空");
|
}
|
if (entity.getFormid() == null || entity.getFormid().intValue() == 0) {
|
throw new ApplicationException("功能号不能为空");
|
}
|
if (entity.getFormType() == null || entity.getFormType().intValue() == 0) {
|
throw new ApplicationException("功能类型不能为空");
|
}
|
final List<T110503Entity> t110503Entities = apiServiceIfc.showSerialNumberList(entity);
|
callBackMessage.setInfo(t110503Entities);
|
callBackMessage.sendSuccessMessageByDefault();
|
return callBackMessage.toJSONObject();
|
} catch (Exception e) {
|
callBackMessage.sendErrorMessage(e.getMessage());
|
return callBackMessage.toJSONObject();
|
} finally {
|
SpObserver.setDBtoInstance();
|
}
|
|
}
|
|
/**
|
* 取功能号在9801,9802的设置
|
*/
|
@RequestMapping(value = "/formSetting.do", method = RequestMethod.GET)
|
public void get9802Info(String formid, HttpServletRequest request, HttpServletResponse response) {
|
String dbid = request.getSession().getAttribute(SessionKey.DATA_BASE_ID) + "";
|
try {
|
SpObserver.setDBtoInstance("_" + dbid);
|
if (formid == null || "".equals(formid)) {
|
CallBackMessage callBackMessage = new CallBackMessage();
|
callBackMessage.sendErrorMessage("formid不能为空");
|
this.printJson(response, callBackMessage.toString());
|
return;
|
}
|
|
int int_formid = 0;
|
int formType = 0;
|
String[] content = formid.split(";");
|
try {
|
int_formid = Integer.parseInt(content[0]);
|
if (content.length == 2) {
|
formType = Integer.parseInt(content[1]);
|
}
|
} catch (Exception e) {
|
CallBackMessage callBackMessage = new CallBackMessage();
|
callBackMessage.sendErrorMessage(e.getMessage());
|
this.printJson(response, callBackMessage.toString());
|
return;
|
}
|
Map<String, Object> map = new HashMap<String, Object>();
|
if (formType == 0) {
|
try {
|
formType = gridService.getWindowTypeByGform(int_formid);
|
} catch (Exception e) {
|
CallBackMessage callBackMessage = new CallBackMessage();
|
callBackMessage.sendErrorMessage(int_formid + "在9810查找不到窗体类型信息" + e.getMessage());
|
this.printJson(response, callBackMessage.toString());
|
return;
|
}
|
}
|
map.put("formType", formType);
|
//主从表表名
|
String hdTable = "";//主表
|
String dtTable = "";//从表
|
Map<String, Object> gform = gridService.getSimpleJdbcTemplate().queryForMap(gridService.getGET_GFORM().toLowerCase(), int_formid);
|
map.put("9801", gform);
|
hdTable = GridUtils.prossRowSetDataType_String(gform, "hdtable");
|
dtTable = GridUtils.prossRowSetDataType_String(gform, "dttable");
|
|
map.put("9802", gridService.getSimpleJdbcTemplate().queryForList("set nocount on ; select " + gridService.getGET_GFIELD().toLowerCase() + " from gfield where formid=? order by statisid asc", int_formid));
|
|
//自定义时间查询
|
map.put("9816", gridService.getSimpleJdbcTemplate().queryForList("set nocount on select datefield,begindatestr,enddatestr,docstate,ShowAllNopost,dateLimitYn,MonthRangeYN,selfdocYn,hidescrapYn from _sysdatefilter where formid=? ", int_formid));
|
//功能链接 by19-74 去掉,修改为通过另外接口直接把处理好的数据返回
|
//map.put("9842", gridService.getSimpleJdbcTemplate().queryForList("select " + sysfunclink + " from _sysfunclink where origformid=? order by sortid asc ", formid));
|
map.put("9842", "[]");
|
|
if (formType == 497 || formType == 499 || formType == 15 || formType == 17 || formType == 9 || formType == 496 || formType == 498 || formType == 8 || formType == 16 || formType == 5) {
|
//单据状态值
|
|
map.put("9815", gridService.getSimpleJdbcTemplate().queryForList("set nocount on select dictvalue,interValue from _sysdict where dictid=(select DocStatusName from gform where formid=?)", int_formid));
|
|
//单据表头过滤设置
|
|
map.put("9743", gridService.getSimpleJdbcTemplate().queryForList("set nocount on select " + gformFilter + " from gformFilter where formid=? order by StatisID asc ", int_formid));
|
|
//OA按钮设置
|
|
map.put("9881", gridService.getSimpleJdbcTemplate().queryForList("set nocount on select " + table3 + " from gfieldApprovedButton a left join t111634 b on a.ButtonName=b.ButtonName where a.formid=? order by a.[docitem] asc", int_formid));
|
|
}
|
|
|
//3表设置
|
if (formType == 15 || formType == 77) {
|
|
map.put("9825", gridService.getSimpleJdbcTemplate().queryForList("set nocount on select " + sysmasterdetail + " from _sysmasterdetail where formid=?", int_formid));
|
}
|
//树设置
|
if (formType == 2 || formType == 3 || formType == 4 || formType == 20 ||
|
formType == 301 || formType == 302 || formType == 304 || formType == 238 ||
|
formType == 30) {
|
final List<Map<String, Object>> list = gridService.getSimpleJdbcTemplate().queryForList("set nocount on select " + systreeset + " from _systreeset where formid=?", int_formid);
|
map.put("9824", list);
|
if (list != null && list.size() > 0) {
|
//增加树过滤条件
|
final SqlFormatEntity sqlFormatByEntity = SqlFormatUtils.createSQLFormatByEntity(list.get(0), 9824);
|
map.put("treefilterstr", sqlFormatByEntity);
|
}
|
}
|
//496多表设置
|
if (formType == 497 || formType == 499 || formType == 496 || formType == 498) {
|
|
map.put("9771", gridService.getSimpleJdbcTemplate().queryForList("set nocount on select " + TabPageFormid + " from _sys_TabPageFormid where mainformid=? and Actived=1 order by TabID asc ,SortBy asc ", int_formid));
|
|
}
|
//表字段的数据类型信息(int ,varchar....)
|
if (formType != 18 && formType != 19 && formType != 38) {//18,19,38查询类型,不需要取数据类型
|
if (!"".equals(hdTable))
|
map.put(hdTable, gridService.getSimpleJdbcTemplate().queryForList(getDataType, hdTable, hdTable));
|
if (!"".equals(dtTable))
|
map.put(dtTable, gridService.getSimpleJdbcTemplate().queryForList(getDataType, dtTable, dtTable));
|
}
|
if (formType == 38) {
|
final Type38action type38action = (Type38action) FactoryBean.getBean("type38action");
|
map.put("queryList", type38action.get38TypeInfo(request, response, int_formid));
|
}
|
this.printJson(response, GridUtils.toJson(map));
|
} catch (Exception e) {
|
this.printJson(response, "{\"error\":\"" + this.getErrorMsg(e) + "\"}");
|
} finally {
|
SpObserver.setDBtoInstance();
|
}
|
}
|
|
/**
|
* 获取流程跟踪信息
|
*/
|
@RequestMapping(value = "/processTrack.do", method = RequestMethod.GET)
|
public void getprocess(int formid, String doccode, HttpServletRequest request, HttpServletResponse response) {// 修改待办事宜为已读状
|
List<?> list = null;
|
String dbid = request.getSession().getAttribute(SessionKey.DATA_BASE_ID) + "";
|
try {
|
SpObserver.setDBtoInstance("_" + dbid);
|
|
list = gridService.getSimpleJdbcTemplate().queryForList("set nocount on select doccode,id,username,inserttime,nextcheckercode,nextcheckername,curstatus,msg from spickorderlog with (nolock) where doccode=? and formid=? order by doccode,inserttime asc", doccode.replace("'", ""), formid);
|
|
this.printJson(response, GridUtils.toJson(list));
|
} catch (Exception e) {
|
this.printJson(response, "{\"error\":\"" + this.getErrorMsg(e) + "\"}");
|
} finally {
|
SpObserver.setDBtoInstance();
|
}
|
}
|
/**
|
*
|
* APP 用户注册
|
*/
|
// @RequestMapping(value="/reg.do", method = RequestMethod.POST)
|
// public @ResponseBody Map register(@RequestBody RegisterUser user, HttpServletRequest request, HttpServletResponse response) {//
|
// //1验证手机
|
//
|
// }
|
|
/***
|
*用在多表中取得子功能号的列表数据,用在点击功能链接时替换参数
|
* @param info
|
* @param request
|
* @param response
|
* @return
|
*/
|
@RequestMapping(value = "/getFormList.do", method = RequestMethod.POST)
|
public @ResponseBody
|
List<Map<String, Object>> getFormList(@RequestBody FristForm info, HttpServletRequest request, HttpServletResponse response) {
|
String dbid = request.getSession().getAttribute(SessionKey.DATA_BASE_ID) + "";
|
try {
|
SpObserver.setDBtoInstance("_" + dbid);
|
//通过功能号和类型取得对应的表名
|
TreeGridDTO dto = new TreeGridDTO();
|
dto.dbid = dbid;
|
this.getTableName(Integer.parseInt(info.getFormid()), info.getFormtype(), dto);
|
|
String sql = "set nocount on select " + info.getFields() + " from " + dto.table + " where " + info.getWhere();
|
|
return gridService.getJdbcTemplate().queryForList(sql);
|
} catch (Exception ex) {
|
this.printJson(response, "{\"error\":\"" + this.getErrorMsg(ex) + "\"}");
|
} finally {
|
SpObserver.setDBtoInstance();
|
}
|
return null;
|
}
|
|
@RequestMapping(value = "/api/upPortraitV2.do", method = RequestMethod.POST)
|
@CrossOrigin
|
public @ResponseBody
|
Object uploadPortraitV2(HttpServletRequest request, HttpServletResponse response) {
|
CallBackMessage callBackMessage = new CallBackMessage();
|
try {
|
AttachmentAction attachmentAction = (AttachmentAction) FactoryBean.getBean("attachmentAction");
|
PostBeanInfo postBeanInfo = attachmentAction.prossParameter(request);
|
SpObserver.setDBtoInstance("_" + postBeanInfo.getDbid());
|
postBeanInfo.setFormid(0);
|
postBeanInfo.setFieldid("");
|
Object result = attachmentAction.doPostAttachmentV2(postBeanInfo, request, response);
|
if (result instanceof Map) {
|
//TODO 更新用户表相关字段
|
ApiServiceIfc apiServiceIfc = (ApiServiceIfc) FactoryBean.getBean("apiService");
|
int count = apiServiceIfc.uploadPortrait(postBeanInfo.getUsercode(), ((Map) result).get("uuid") + "");
|
if (count > 0) {
|
return result;
|
} else {
|
throw new ApplicationException("更新用户头像失败");
|
}
|
} else if (result instanceof JsonObject) {
|
return result;
|
}
|
} catch (Exception ex) {
|
callBackMessage.sendErrorMessage(this.getErrorMsg(ex));
|
return callBackMessage;
|
} finally {
|
SpObserver.setDBtoInstance();
|
}
|
return null;
|
}
|
|
/***
|
*上传用户头像
|
* @param request
|
* @param response
|
* @return
|
*/
|
@RequestMapping(value = "/api/upPortrait.do", method = RequestMethod.POST)
|
public @ResponseBody
|
List<Map<String, Object>> uploadPortrait(HttpServletRequest request, HttpServletResponse response) {
|
String dbid = request.getSession().getAttribute(SessionKey.DATA_BASE_ID) + "";
|
try {
|
SpObserver.setDBtoInstance("_" + dbid);
|
AttachmentAction attachmentAction = (AttachmentAction) FactoryBean.getBean("attachmentAction");
|
request.setAttribute("formid", 0);
|
request.setAttribute("type", 0);
|
Object result = attachmentAction.doPostAttachment(request, response);
|
if (result instanceof Map) {
|
//TODO 更新用户表相关字段
|
String userCode = (String) request.getSession().getAttribute(SessionKey.HRCODE);
|
ApiServiceIfc apiServiceIfc = (ApiServiceIfc) FactoryBean.getBean("apiService");
|
int count = apiServiceIfc.uploadPortrait(userCode, ((Map) result).get("uuid") + "");
|
if (count > 0) {
|
printJson(response, GridUtils.toJson(result));
|
} else {
|
throw new ApplicationException("更新用户头像失败");
|
}
|
} else if (result instanceof JsonObject) {
|
printJson(response, result.toString());
|
}
|
} catch (Exception ex) {
|
this.printJson(response, "{\"error\":\"" + this.getErrorMsg(ex) + "\"}");
|
} finally {
|
SpObserver.setDBtoInstance();
|
}
|
return null;
|
}
|
|
/***
|
* Ionic APP更新调用接口,下载更新包,新版本用这个接口
|
* @param json
|
* @param request
|
* @param response
|
*/
|
@Deprecated
|
@RequestMapping(value = "/app/getZip.do", method = RequestMethod.POST)
|
public void chcpUpdateZip(@RequestBody ChcpInfo json, HttpServletRequest request, HttpServletResponse response) {
|
//creatFileToZip(json, response);
|
}
|
|
/***
|
* Ionic APP更新调用接口,下载更新包
|
* @param json
|
* @param request
|
* @param response
|
*/
|
@Deprecated
|
@RequestMapping(value = "/v", method = RequestMethod.POST)
|
public void chcpUpdate(@RequestBody ChcpInfo json, HttpServletRequest request, HttpServletResponse response) {
|
//creatFileToZip(json, response);
|
|
}
|
|
public void creatFileToZip(@RequestBody ChcpInfo json, HttpServletResponse response) {
|
//String dbid = request.getSession().getAttribute(SessionKey.DATA_BASE_ID) + "";
|
//pc生成app页面所在的路径
|
String webUrl = AttachmentConfig.get("Ionic.webUrl");
|
//app下载更新包所在的路径
|
String appUrl = AttachmentConfig.get("Ionic.PageUrl");
|
|
try {
|
//文件的根目录
|
String webRoot = webUrl + json.dbname + File.separator + "ionic_chcp" + File.separator + "www" + File.separator;
|
long timestamp = System.currentTimeMillis();
|
String tempRoot = appUrl + json.dbname + File.separator + json.dbname + "_" + timestamp;
|
List<String> others = json.other;
|
|
// 第一次下载时直接下载已存在的;
|
if (json.frist == 1) {
|
//基础包
|
String zip = appUrl + json.dbname + File.separator + json.dbname + ".zip";
|
File file = new File(zip);
|
//存在则直接下载
|
if (file.exists()) {
|
FileUtil.downloadFile(file, response, false);
|
} else {//生成基础包再下载
|
extracted(others, webRoot, tempRoot, json, timestamp, appUrl + json.dbname + File.separator, response);
|
}
|
} else {
|
extracted(others, webRoot, tempRoot, json, timestamp, appUrl + json.dbname + File.separator, response);
|
}
|
|
} finally {
|
// SpObserver.setDBtoInstance();
|
}
|
}
|
|
private void extracted(List<String> others, String webRoot, String appRoot, ChcpInfo json, long timestamp, String appBaseUrl, HttpServletResponse response) {
|
try {
|
if (json.frist == 0) {
|
//1,处理other里面的文件
|
for (String str : others) {
|
//copy单文件到对应目录的文件
|
FileUtils.copyFile(new File(webRoot + str), new File(appRoot + File.separator + str));
|
}
|
//----增加把chcp.json,chcp.manifest 二个文件也copy过去,保持当前的状态,而不是每次下载基础包都是
|
//用最新的版本做比对,之前存在着取了最新的版本,丢失了中间更新的部分页面,导致需要更新的功能号页面,得不到更新,是旧的或是找不到页面的情况
|
FileUtils.copyFile(new File(webRoot + "chcp.json"), new File(appRoot + File.separator + "chcp.json"));
|
FileUtils.copyFile(new File(webRoot + "chcp.manifest"), new File(appRoot + File.separator + "chcp.manifest"));
|
//----
|
//2,处理formids,这里需要根据formid,dbid组装路径来copy目录下面的文件
|
if (!"".equals(json.formids) && json.frist == 0) {
|
String[] formids = json.formids.split(";");
|
int total = formids.length;
|
String from = null;
|
String to = null;
|
System.out.println(json.dbname + "->" + timestamp + "--需要处理formids-:【" + json.formids.toString() + "】");
|
//-----把相关信息写到数据库,用作跟踪调试
|
// BaseService baseService=(BaseService) FactoryBean.getBean("BaseService");
|
// try {
|
// SpObserver.setDBtoDemo();
|
// baseService.getSimpleJdbcTemplate().queryForObject("set nocount on \n insert into appinfo(dbName,info,[timestamps],usercode) values (?,?,?,?);", Integer.class, json.dbname, GridUtils.toJson(json), timestamp,json.usercode);
|
// }catch (Exception e){
|
// e.printStackTrace();
|
// }finally {
|
// SpObserver.setDBtoInstance();
|
// }
|
//------
|
for (int i = 0; i < total; i++) {
|
from = webRoot + "app" + File.separator + json.dbid + File.separator + formids[i];
|
to = appRoot + File.separator + "app" + File.separator + json.dbid + File.separator;
|
FileUtils.copyDirectoryToDirectory(new File(from), new File(to));
|
}
|
}
|
String zipName = json.dbname + "_" + timestamp + ".zip";
|
String appPath = appBaseUrl + json.dbname + "_" + timestamp;
|
zipAndDownload(appPath, appBaseUrl, zipName, response, true);
|
} else {//新增全新下载,把整个目录copy过来生成zip包
|
File[] files = new File(webRoot).listFiles();
|
String appPath = appBaseUrl + json.dbname;
|
if (files != null) {
|
for (File file : files) {
|
if (file.isDirectory()) {
|
FileUtils.copyDirectoryToDirectory(file, new File(appBaseUrl + File.separator + json.dbname));
|
} else {
|
FileUtils.copyFileToDirectory(file, new File(appPath));
|
}
|
}
|
}
|
String zipName = json.dbname + ".zip";
|
zipAndDownload(appPath, appBaseUrl, zipName, response, false);
|
}
|
|
} catch (IOException e) {
|
e.printStackTrace();
|
}
|
}
|
|
public static void zipAndDownload(String appPath, String appRoot, String zip, HttpServletResponse response, boolean isDelete) {
|
try {
|
|
ZipUtil.zip(appPath, null, null);
|
File file = new File(appRoot);
|
if (file.exists()) {//存在则直接下载
|
FileUtil.downloadFile(file, response, isDelete);
|
}
|
} catch (Exception e) {
|
e.printStackTrace();
|
}
|
}
|
|
/**
|
* 清除个人格线cookie数据
|
*/
|
@RequestMapping(value = "/grid/clearCookie.do")
|
public @ResponseBody
|
Object clearCookie(Integer formid, String cookieType, HttpServletRequest request, HttpServletResponse response) {
|
CallBackMessage callBackMessage = new CallBackMessage();
|
String dbid = request.getSession().getAttribute(SessionKey.DATA_BASE_ID) + "";
|
String userCode = request.getSession().getAttribute(SessionKey.USERCODE) + "";
|
try {
|
SpObserver.setDBtoInstance("_" + dbid);
|
if (formid == null || formid == 0) {
|
throw new ApplicationException("功能号不能为空");
|
}
|
apiServiceIfc.clearCookie(userCode, formid, cookieType);
|
callBackMessage.sendSuccessMessageByDefault();
|
return callBackMessage.toJSONObject();
|
} catch (Exception ex) {
|
callBackMessage.sendErrorMessage(this.getErrorMsg(ex));
|
return callBackMessage.toJSONObject();
|
} finally {
|
SpObserver.setDBtoInstance();
|
}
|
}
|
|
/**
|
* 保存格线cookie
|
*/
|
@RequestMapping(value = "/grid/cookie.do", method = RequestMethod.POST)
|
public @ResponseBody
|
WebAsyncTask GridCookie(CookieEntity cookieEntity, HttpServletRequest request, HttpServletResponse response) {
|
String dbid = request.getSession().getAttribute(SessionKey.DATA_BASE_ID) + "";
|
String userCode = request.getSession().getAttribute(SessionKey.USERCODE) + "";
|
CallBackMessage callBackMessage = new CallBackMessage();
|
if (StringUtils.isNotBlank(request.getParameter("_pop_json"))) {
|
cookieEntity = JSON.parseObject(request.getParameter("_pop_json"), CookieEntity.class);
|
}
|
Callable<Object> callable = new GridCookiesCallable(cookieEntity, userCode, dbid, gridService);
|
//定义超时15秒
|
WebAsyncTask asyncTask = new WebAsyncTask(TimeUnit.SECONDS.toMillis(15), threadPoolExecutor, callable);
|
asyncTask.onCompletion(
|
() -> log.info("执行成功")
|
);
|
asyncTask.onError(
|
(Callable<Object>) () -> {
|
log.info("执行出错");
|
callBackMessage.sendErrorMessage("执行出错,请重新操作");
|
return callBackMessage.toJSONObject();
|
}
|
);
|
asyncTask.onTimeout(
|
(Callable<Object>) () -> {
|
log.info("执行超时");
|
callBackMessage.sendErrorMessage("执行超时,请重新操作");
|
return callBackMessage.toJSONObject();
|
}
|
);
|
return asyncTask;
|
}
|
|
/**
|
* 取功能号对应的自动编号信息
|
*/
|
@RequestMapping(value = "/autocodeInfo.do", method = RequestMethod.GET)
|
public @ResponseBody
|
Map<String, Object> getAutoCodeInfo(String formid, HttpServletRequest request, HttpServletResponse response) {
|
String dbid = request.getSession().getAttribute(SessionKey.DATA_BASE_ID) + "";
|
try {
|
SpObserver.setDBtoInstance("_" + dbid);
|
|
String sql = "set nocount on select g.formid,g.codelength,g.preFixcode,g.precodetype,c.Formtype,c.Curcode,c.Fieldid from gform g,_sysautocode c where g.formid=c.formid and g.formid=?";
|
|
return gridService.getJdbcTemplate().queryForMap(sql, new Object[]{formid});
|
} catch (Exception ex) {
|
this.printJson(response, "{\"error\":\"" + this.getErrorMsg(ex) + "\"}");
|
} finally {
|
SpObserver.setDBtoInstance();
|
}
|
return null;
|
}
|
|
/**
|
* 取回符合条件的功能链接
|
*
|
* @param bean
|
* @param request
|
* @param response
|
* @return
|
*/
|
@RequestMapping(value = "/getFunLinksV2.do", method = RequestMethod.POST)
|
public @ResponseBody
|
Object getFunLinksV2(@RequestBody LinksBean bean, HttpServletRequest request,
|
HttpServletResponse response) {
|
Map map = new HashMap();
|
try {
|
Object object = this.getFunLinks(bean, request, response);
|
//增加单号导航
|
List docNavList = new ArrayList();
|
//有单号才执行
|
if (StringUtils.isNotBlank(bean.getDoccode()) && (bean.getFormtype() == 5 || bean.getFormtype() == 8 || (bean.getFormtype() == 16 && bean.getIsMutType() == 0) || bean.getFormtype() == 496 || bean.getFormtype() == 498)) {
|
DocNavigation docNavigation = (DocNavigation) FactoryBean.getBean("docNavigation");
|
docNavList = docNavigation.getDocNavigation(bean.getFormid(), bean.getDoccode(), request, response);
|
}
|
map.put("links", object);
|
map.put("docNav", docNavList);
|
} catch (Exception ex) {
|
this.printJson(response, "{\"error\":\"" + this.getErrorMsg(ex) + "\"}");
|
}
|
return map;
|
}
|
|
/**
|
* 取回符合条件的功能链接
|
*
|
* @param bean
|
* @param request
|
* @param response
|
* @return
|
*/
|
@RequestMapping(value = "/getFunLinks.do", method = RequestMethod.POST)
|
public @ResponseBody
|
Object getFunLinks(@RequestBody LinksBean bean, HttpServletRequest request,
|
HttpServletResponse response) {
|
|
try {
|
SpObserver.setDBtoInstance("_" + request.getSession().getAttribute(SessionKey.DATA_BASE_ID));
|
List<Map<String, Object>> list = null;//所有功能链接集合
|
BaseService baseService = (BaseService) FactoryBean.getBean("BaseService");
|
String sql = "set nocount on select " + sysfunclink +
|
",a.largImagePath from _sysfunclink b left join _sysMenu a on b.linkformid=cast(a.formid as varchar(20)) where b.origformid=? and b.origformtype=? order by b.sortid asc \n";
|
//496多表
|
if (bean.getFormtype() == 496 || bean.getFormtype() == 498) {
|
sql = "set nocount on \n select " + sysfunclink +
|
" ,c.largImagePath from _sysFuncLink b left join _sysMenu c on b.linkformid=cast(c.formid as varchar(20)) \n" +
|
"where exists(select 1 from _sys_TabPageFormid a where a.mainformid = ? \n" +
|
" and a.formid = b.origformid \n" +
|
" and ((a.mainformid = a.formid and b.origformtype = 496) \n" +
|
" or (a.mainformid <> a.formid and a.formtype = b.origformtype ))\n" +
|
" )\n" +
|
" order by b.origformid asc ,b.sortid asc \n";
|
list = baseService.getSimpleJdbcTemplate().queryForList(sql, bean.getFormid());
|
} else {
|
list = baseService.getSimpleJdbcTemplate().queryForList(sql, bean.getFormid(), bean.getFormtype());
|
|
}
|
List<Map<String, Object>> result = new ArrayList<>();
|
BuildTopIfc buildTopIfc = (BuildTopIfc) FactoryBean.getBean("BuildTopImpl");
|
String tempFormid = null;
|
if (list != null && list.size() > 0) {
|
for (int k = 0; k < list.size(); k++) {
|
Map<String, Object> tempMap = list.get(k);
|
String formid = tempMap.get("origformid") + "";
|
if (tempFormid != null) {
|
if (tempFormid.equalsIgnoreCase(formid))
|
continue;
|
}
|
tempFormid = formid;
|
final List<Map<String, Object>> tempList = list.stream().filter(x -> (x.get("origformid") != null && formid.equals(x.get("origformid") + ""))).collect(toList());//处理同一个功能号里所有表达式的数据
|
final List<Map<String, Object>> collectNotitemexpression = list.stream().filter(x ->
|
(x.get("origformid") != null && formid.equals(x.get("origformid") + ""))
|
&& (x.get("showitemexpression") == null || "".equals(x.get("showitemexpression")))
|
&& (//处理editstatus有值的情况
|
StringUtils.isBlank(bean.getDoccode())//新单
|
&& (x.get("editstatus") != null && StringUtils.isNotBlank(x.get("editstatus") + "") ? ((";" + x.get("editstatus") + ";").contains(";0;")) : true)
|
)
|
).collect(toList());//没有表达式的数据
|
|
Map<String, Object> map = buildTopIfc.buildFuncLinkExpression_APPV2(Integer.parseInt(formid), Integer.parseInt(tempMap.get("origformtype") + ""), bean.getDoccode(), request, request.getSession(), tempList);
|
if (map != null) {//有结果
|
for (Map.Entry<String, Object> entry : map.entrySet()) {
|
if ("1".equals(entry.getValue() + "")) {//取值为1,表示有权限,(没有表达式的也在里面设置为1)
|
String[] key = entry.getKey().split("_");
|
result.addAll(
|
tempList.stream().filter(obj -> (obj.get("sortid") + "").equals(key[1] + "") && (obj.get("linkformid") + "").equals(key[0] + "")).collect(toList()
|
));
|
}
|
}
|
|
} else {//条件不成立,返回null,则取没有表达式的链接
|
result.addAll(collectNotitemexpression);
|
}
|
}
|
}
|
return result;
|
} catch (Exception ex) {
|
this.printJson(response, "{\"error\":\"" + this.getErrorMsg(ex) + "\"}");
|
} finally {
|
SpObserver.setDBtoInstance();
|
}
|
return null;
|
}
|
|
/**
|
* 9802设置不感应,但可能数据库存在有字段
|
* 获取表的字段和数据类型,因为存在,表示要在页面显示出来,但在新增,修改时需要过滤
|
*
|
* @param tablename
|
* @param request
|
* @param response
|
* @return
|
*/
|
@RequestMapping(value = "/api/getColumnsInfo.do", method = RequestMethod.GET)
|
public @ResponseBody
|
Object getColumnsInfo(String tablename, HttpServletRequest request,
|
HttpServletResponse response) {
|
|
List<Map<String, Object>> list = null;
|
try {
|
SpObserver.setDBtoInstance("_" + request.getSession().getAttribute(SessionKey.DATA_BASE_ID));
|
list = gridService.getSimpleJdbcTemplate().queryForList("set nocount on ; select column_name ,data_type from INFORMATION_SCHEMA.columns where table_name=?", tablename);
|
return list;
|
} catch (Exception ex) {
|
this.printJson(response, "{\"error\":\"" + this.getErrorMsg(ex) + "\"}");
|
} finally {
|
SpObserver.setDBtoInstance();
|
}
|
return null;
|
}
|
|
/**
|
* 取22类型存储过程参数列表
|
*/
|
@RequestMapping(value = "/get22ParamInfo.do", method = RequestMethod.POST)
|
public @ResponseBody
|
String getPrimKey(@RequestParam String formid,
|
HttpServletRequest request, HttpServletResponse response) {// 修改待办事宜为已读状态
|
try {
|
String dbid = request.getSession().getAttribute(SessionKey.DATA_BASE_ID) + "";
|
SpObserver.setDBtoInstance("_" + dbid);
|
String cols = this.gridService.getSimpleJdbcTemplate().queryForObject(" select stuff((SELECT ',''' + CONVERT(VARCHAR, isnull(b.fieldid,''))+'''' from gField b where b.isload=1 and b.headflag=0 and \n" +
|
"formid=? and isnull(DataLink,0)=1 order by StatisID asc FOR XML PATH ('')),1,1,'')", String.class, formid);
|
if (cols == null || "".equalsIgnoreCase(cols)) {
|
throw new ApplicationException(formid + "在9802字段列表为空,请在9802添加参数字段定义或查看字段的【感应】参数是否选上");
|
}
|
return "[" + (cols == null ? "" : cols) + "]";
|
} catch (Exception ex) {
|
this.printJson(response, "{\"error\":\"" + this.getErrorMsg(ex) + "\"}");
|
} finally {
|
SpObserver.setDBtoInstance();
|
}
|
return null;
|
}
|
|
/**
|
* 修改密码,通过手机验证码和新密码修改密码
|
*/
|
@SuppressWarnings("unchecked")
|
@RequestMapping(value = "/api/forgotPwd.do", method = RequestMethod.POST)
|
public void changePwd(@RequestBody PwdBean json, HttpServletRequest request, HttpServletResponse response) {
|
JsonObject rightJson = new JsonObject();
|
JsonObject errJson = new JsonObject();
|
if (json.getTel() == null || "null".equalsIgnoreCase(json.getTel()) || "".equalsIgnoreCase(json.getTel())) {
|
errJson.addProperty("error", "手机号不能为空");
|
}
|
if (json.getNewPwd() == null || "null".equalsIgnoreCase(json.getNewPwd()) || "".equalsIgnoreCase(json.getNewPwd())) {
|
errJson.addProperty("error", "新密码不能为空");
|
}
|
if (json.getCode() == null || "null".equalsIgnoreCase(json.getCode()) || "".equalsIgnoreCase(json.getCode())) {
|
errJson.addProperty("error", "验证码不能为空");
|
}
|
if (errJson != null && errJson.has("error")) {
|
this.printJson(response, errJson.toString());
|
return;
|
}
|
String tel = EncodeUtil.replaceUrlChar(json.getTel());
|
if (tel.length() > 20) {//表示已加密,需要解密
|
try {
|
tel = ChangePassword.getDecryptPassword(tel);
|
} catch (Exception e) {
|
e.printStackTrace();
|
}
|
}
|
//1,验证手机验证码
|
InvitationCode invitationCode = (InvitationCode) FactoryBean.getBean("invitationCode");
|
boolean flg = invitationCode.verificationCode(response, tel, json.getCode(), rightJson, errJson);
|
if (!flg) {
|
//2,执行修改密码功能
|
|
try {
|
SpObserver.setDBtoDemo();
|
String pwd_str = EncodeUtil.replaceUrlChar(json.getNewPwd());
|
|
if (pwd_str.length() < 30) {//明文,需要加密密码保存
|
pwd_str = ChangePassword.getEncryptPassword(pwd_str);
|
}
|
String result = apiServiceIfc.doUpdateUserPwd(pwd_str, tel);
|
if (result !=null) {
|
redisTemplate.delete(VerificationCodes.getCodeKey(json.getTel()));
|
rightJson.addProperty("status", "密码修改成功!");
|
UserPwdEntity entity=new UserPwdEntity();
|
entity.setTel(tel);
|
entity.setNewPwd(pwd_str);
|
entity.setDbIdList(result);
|
entity.setType("app");//表示由app端调用
|
threadPoolExecutor.execute(new UpdateUserPassWordThread(entity));
|
} else {
|
errJson.addProperty("error", "密码修改出错!");
|
}
|
} catch (Exception e) {
|
e.printStackTrace();
|
errJson.addProperty("info", this.getErrorMsg(e));
|
rightJson.add("error", errJson);
|
} finally {
|
SpObserver.setDBtoInstance();
|
}
|
this.printJson(response, rightJson.toString());
|
}
|
}
|
/**
|
* 接收推送过来的修改密码请求
|
*/
|
@SuppressWarnings("unchecked")
|
@RequestMapping(value = "/open/mutual/updateUserPwd.do", method = RequestMethod.POST)
|
public void updateUserPwd(HttpServletRequest request, HttpServletResponse response) {
|
try{
|
String data = URLDecoder.decode(request.getParameter("data"), "utf-8");
|
UserPwdEntity entity = JSON.parseObject(data, UserPwdEntity.class);
|
SpObserver.setDBtoInstance("_" + entity.getDbId());
|
UserAccountServiceIfc userAccountServiceIfc = (UserAccountServiceIfc) FactoryBean.getBean("UserAccountServiceImpl");
|
final UserAccountEntity userInfoByTelephone = userAccountServiceIfc.getUserInfoByTelephone(entity.getTel());
|
if (userInfoByTelephone != null && StringUtils.isNotBlank(userInfoByTelephone.getUserCode())) {
|
userAccountServiceIfc.savePassword(userInfoByTelephone.getUserCode(), entity.getNewPwd(), userInfoByTelephone.getUserCode());
|
System.out.println("dbid:"+entity.getDbId()+"完成");
|
}
|
}catch(Exception ex){
|
ex.printStackTrace();
|
}finally {
|
SpObserver.setDBtoInstance();
|
}
|
|
}
|
/**
|
* 发手机验证码
|
*/
|
@RequestMapping(value = "/api/sendSms.do", method = RequestMethod.GET)
|
public void sendSms(String tel, HttpServletRequest request, HttpServletResponse response) {
|
//发送验证码到对应手机号
|
//TODO 暂定用标准版的短信账号来发送,以后再转第三方做验证调用时就可以用第三方的短信账号
|
request.setAttribute(SessionKey.SHOPPING_DBID, "82");
|
VerificationCodes verificationCodes = (VerificationCodes) FactoryBean.getBean("verificationCodes");
|
verificationCodes.GenRandomVcode(tel, request, response);
|
}
|
|
/**
|
* 取功能号对应的主键,多个是以;号分隔
|
*/
|
@RequestMapping(value = "/forminfo.do", method = RequestMethod.POST)
|
public @ResponseBody
|
Map<String, String> getPrimKey(@RequestBody FormInfo json, HttpServletRequest request, HttpServletResponse response) {
|
String dbid = request.getSession().getAttribute(SessionKey.DATA_BASE_ID) + "";
|
try {
|
//Gson gson = new Gson();
|
Map<String, String> map = new HashMap<String, String>();
|
// FormInfo json=gson.fromJson(request.getParameter("_pop_json"), new com.google.gson.reflect.TypeToken<FormInfo>() {}.getType());
|
//SpObserver.setDBtoInstance("_" + dbid);
|
// 取到对应功能号的表名
|
//wintype 格式:9@p@1
|
TreeGridDTO dto = new TreeGridDTO();
|
dto.dbid = dbid;
|
this.getTableName(json.getFormid(), json.getWintype(), dto);
|
dto.b497 = json.isB497();
|
dto.b499 = json.isB499();
|
this.setOrderName(dto);
|
dto.orderFiled = json.getFiled();
|
this.getFirstField(dto);//取主键
|
this.setOrderFiled(dto);
|
this.setOrderBy(dto);
|
|
map.put("primeKey", dto.primeKey);
|
map.put("sortCols", dto.sortCols);
|
map.put("sortTypes", dto.sortTypes);
|
map.put("tableName", dto.table);
|
int isView = 0;
|
//多表才执行
|
if (dto.b497 || dto.b499) {
|
try {
|
SpObserver.setDBtoInstance("_" + dto.dbid);
|
String tableType = this.gridService.getSimpleJdbcTemplate().queryForObject("select TABLE_TYPE from information_schema.TABLES where table_name=?", String.class, dto.table);
|
if ("VIEW".equals(tableType)) {
|
//针对496多表子功能号是视图,新增提交时需要把action修改为add
|
isView = 1;
|
}
|
} finally {
|
SpObserver.setDBtoInstance();
|
}
|
}
|
map.put("isView", isView + "");
|
return map;
|
} catch (Exception ex) {
|
this.printJson(response, "{\"error\":\"" + this.getErrorMsg(ex) + "\"}");
|
}
|
return null;
|
}
|
|
private void setOrderFiled(TreeGridDTO dto) {
|
|
}
|
|
private void getFirstField(TreeGridDTO dto) {
|
//1先读表关键功能,如果没有相关的再读表结构
|
|
String keyfields = null;
|
try {
|
SpObserver.setDBtoInstance("_" + dto.dbid);
|
String taleName=dto.table;
|
if(dto.winType==18||dto.winType==19){
|
taleName=dto.table.split("\\|")[0];
|
}
|
keyfields = gridService.getTableKeyFields(taleName);
|
} finally {
|
SpObserver.setDBtoInstance();
|
}
|
if (keyfields == null || "".equalsIgnoreCase(keyfields)) {
|
//2只取主表,主从表情况
|
List<String> keys = null;
|
try {
|
SpObserver.setDBtoInstance("_" + dto.dbid);
|
try {
|
keys = gridService.getPrimaryKey(dto.table);
|
} catch (SQLException e) {
|
// TODO Auto-generated catch block
|
e.printStackTrace();
|
}
|
} finally {
|
SpObserver.setDBtoInstance();
|
}
|
if (keys != null) {
|
for (String str : keys) {
|
if (dto.field == "")
|
dto.field += str;
|
else
|
dto.field += ";" + str;
|
}
|
keys = null;
|
}
|
} else {
|
String[] arry = keyfields.split(";");
|
for (int i = 0; i < arry.length; i++) {
|
if ("".equals(dto.field))
|
dto.field += arry[i].toLowerCase();
|
else
|
dto.field += ";" + arry[i].toLowerCase();
|
|
}
|
arry = null;
|
}
|
dto.primeKey = dto.field;
|
}
|
|
public void getTableName(int formid, String winType, TreeGridDTO dto) {
|
SqlRowSet gform = null;
|
try {
|
SpObserver.setDBtoInstance("_" + dto.dbid);
|
gform = gridService.getGformByFormID(formid);
|
} finally {
|
SpObserver.setDBtoInstance();
|
}
|
String[] temp = winType.split("@p@");
|
dto.winType = Integer.parseInt(temp[0]);
|
dto.conNum = temp.length > 1 ? Integer.parseInt(temp[1]) : 0;
|
if (!gform.wasNull()) {
|
gform.first();
|
dto.HDTable = gform.getString("hdtable");
|
//dto.dataformid=(gform.getString("dataformid")==null||gform.getString("dataformid").length()==0||gform.getString("dataformid").equalsIgnoreCase("0"))?"":(gform.getString("dataformid")+(!this.isDanJun(dto)?"":"|"+gform.getInt("predocstatus")));
|
//dto.tranformid=(gform.getString("dataformid")==null||gform.getString("dataformid").length()==0||gform.getString("dataformid").equalsIgnoreCase("0"))?"":(gform.getString("dataformid"));
|
dto.DTtable = gform.getString("dttable");
|
// dto.frozencols=gform.getInt("frozencols");
|
// dto.formname=gform.getString("formname");
|
// dto.gantt=gform.getBoolean("isGantt");//是否为甘特图类型的功能号
|
// dto.predocstatus=gform.getInt("predocstatus");//确认前状态,为了给格线在确认后不能再修改(新增,修改,删除) by 2013-02-01
|
// dto.rowcopyfields=gform.getString("rowcopyfields");//行复制时排除字段
|
// dto.pageSize=gform.getInt("pageSize");//页记录数
|
// dto.autopaging=gform.getInt("autopaging");//是否分页
|
// dto.optype=gform.getInt("optype");//功能号权限
|
// dto.lockGridSort=gform.getInt("LockGridSort");//冻结列排序
|
// dto.colset=gform.getInt("isShowCell");//是否显示列过滤
|
// dto.mainCol=gform.getString("byGroup");//树分组显示字段
|
// dto.isFilter=gform.getInt("isFilter");//是否打开过滤功能
|
// boolean blactions=gform.getBoolean("addNewRow");//直接增行
|
// try {
|
// dto.postStatusAddNew=gform.getInt("PostStatusGridAddNew");//根据状态值是否可以显示增行按钮,用在OA审核中
|
// }catch(Exception e) {
|
// dto.postStatusAddNew=0;
|
// }
|
// if(blactions) dto.actions="<Actions OnClickButtonAdd=\"AddRowEnd\" />";
|
// dto.defaultRowCount=gform.getInt("DefaultRowCount");//格线默认加载时显示行数
|
// if(!"".equalsIgnoreCase(dto.tolkey)&&(dto.b497||dto.b499)&&dto.PriFormID>0){//是多表的情况 且是第一个子功能号
|
//
|
// SqlRowSet f=null;
|
// try{
|
// SpObserver.setDBtoInstance("_"+dto.dbid);
|
// f=gridService.getGformByFormID(dto.PriFormID);
|
// }finally{
|
// SpObserver.setDBtoInstance();
|
// }
|
// if(!f.wasNull()){
|
// f.first();
|
// dto.rowcopyformids=f.getString("rowcopyformids");//复单时排除功能号
|
// }
|
//
|
// }else{
|
// dto.rowcopyformids=gform.getString("rowcopyformids");//复单时排除功能号
|
// }
|
// if(dto.gridHeight==0) dto.gridHeight=gform.getInt("GridHeight");//表格高度
|
// dto.glcodefield=gform.getString("glcodefield");//会计科目需要的字段
|
// if(!this.isNullOrEmptry(dto.glcodefield)){//格式:主表汇总,明细表汇总|平衡字段|平衡值公式字段
|
// List<Map<String ,Object>> map=null;
|
// try{
|
// SpObserver.setDBtoInstance("_"+dto.dbid);
|
// map=gridService.getSimpleJdbcTemplate().queryForList("select MasterSumFields,DetailSumFields from _sysmasterdetail where FormID=?", dto.formID);
|
// }finally{
|
// SpObserver.setDBtoInstance();
|
// }
|
// if(map.size()>0){
|
// Map<String ,Object> m=map.get(0);
|
// dto.gltotal=m.get("MasterSumFields")+","+m.get("DetailSumFields")+"|"+gform.getString("checkblncfields")+"|"+gform.getString("chkFormula");
|
// m=null;
|
// }
|
// map=null;
|
// }
|
dto.index1 = gform.getString("index1");//列表的排序字段-9类型
|
dto.index2 = gform.getString("index2");//明细表的排序字段-5类型
|
// dto.formdatafilters=gform.getString("formdatafilters")==null?"":this.replaceBlank(gform.getString("formdatafilters"));
|
// dto.ProcGroupafterSavedoc=gform.getString("ProcGroupafterSavedoc")==null?"":this.replaceBlank(gform.getString("ProcGroupafterSavedoc"));
|
// dto.trangroup=gform.getString("transgroupcode")==null?"":gform.getString("transgroupcode");
|
// dto.DealAfterDocSave=gform.getString("DealAfterDocSave")==null?"":this.replaceBlank(gform.getString("DealAfterDocSave"));
|
//
|
// dto.cancelProc=gform.getString("CancelBtnProcName")==null?"":this.replaceBlank(gform.getString("CancelBtnProcName"));
|
//
|
// dto.revokeProc=gform.getString("RevokeBtnProcName")==null?"":this.replaceBlank(gform.getString("RevokeBtnProcName"));
|
//
|
// dto.cancelisSave=gform.getBoolean("CancelIsSave")?1:0;
|
|
if (dto.winType == 0 || (dto.winType == 7 && dto.conNum == 0) || dto.winType == 1 || dto.winType == 5 || (dto.winType == 9 && dto.conNum == 0) || dto.winType == 3 || dto.winType == 4 ||
|
dto.winType == 17 || (dto.winType == 302 && dto.conNum == 0) || dto.winType == 19 ||
|
(dto.winType == 499 && dto.conNum == 0) || (dto.winType == 10 && dto.conNum == 0) ||//dto.winType == 10 &&dto.conNum == 1 修改为dto.conNum == 0 by danaus 2020/1/11 13:53
|
(dto.winType == 497 && dto.conNum == 0) || (dto.winType == 2 && dto.conNum == 0) ||
|
(dto.winType == 20 && dto.conNum == 0) || (dto.winType == 301 && dto.conNum == 0) ||
|
(dto.winType == 30 && dto.conNum == 0) ||
|
(dto.winType == 303 && dto.conNum == 0) || (dto.winType == 304 && dto.conNum == 0) ||
|
(dto.winType == 238 && dto.conNum == 0) || (dto.winType == 302) ||
|
(dto.winType == 15 && (dto.conNum == 0 || dto.conNum == 2))) {
|
dto.table = dto.HDTable;
|
dto.isList = true;
|
} else {
|
dto.table = dto.DTtable;
|
}
|
|
gform = null;
|
|
}
|
|
}
|
|
/**
|
* 根据不同类型决定不同的排序规则
|
* //1,读取9801设置,
|
* //2,根据不同类型再进行不同的设置(单据清单desc,明细 以docitem asc,)
|
* //3,对于不是上面的二种情况不用排序
|
*/
|
private void setOrderBy(TreeGridDTO dto) {
|
String temp = "";
|
if (dto.order == 1 && dto.index1 != null && !dto.index1.isEmpty()) { //9801 主表
|
temp = setSqlOrderBy(dto.index1, " asc");
|
} else if (dto.order == 2 && dto.index2 != null && !dto.index2.isEmpty()) {//明细表
|
temp = setSqlOrderBy(dto.index2, " asc");
|
} else {
|
if (dto.field.isEmpty())
|
temp = dto.orderFiled;
|
else
|
temp = setSqlOrderBy(dto.field, (dto.order == 1 && dto.winType != 2 && dto.winType != 20) ? " desc" : " asc");
|
}
|
dto.field = "";
|
if (!"".equalsIgnoreCase(temp)) {
|
String[] s = temp.replaceAll(",", " ").split("\\s+");//
|
StringBuilder cols = new StringBuilder();
|
StringBuilder types = new StringBuilder();
|
|
for (int j = 0; j < s.length; j += 2) {
|
if (s.length < 2) throw new ApplicationException("【" + temp + "】内容格式不正确【filed1,1,filed2,0....】");
|
if (j > 0) {
|
cols.append(",");
|
types.append(",");
|
}
|
cols.append(s[j].equalsIgnoreCase("_ycid_") ? "id" : s[j]);
|
types.append("asc".equalsIgnoreCase(s[j + 1]) ? "0" : "1");
|
}
|
dto.sortCols = cols.toString();
|
dto.sortTypes = types.toString();
|
|
}
|
|
}
|
|
private String setSqlOrderBy(String index22, String x) {//x为desc,asc
|
StringBuilder temp = new StringBuilder();
|
index22 = index22.replaceAll(";", ",");
|
String[] sorts = index22.split(",");
|
int index = 0;
|
for (String s : sorts) {
|
String[] str = s.split("\\s");
|
if (str.length == 2) {
|
if (index > 0)
|
temp.append(",").append(str[0]).append(" " + str[1]);
|
else
|
temp.append(str[0]).append(" " + str[1]);
|
} else {
|
if (index > 0)
|
temp.append(",").append(str[0]).append(" " + x);
|
else
|
temp.append(str[0]).append(" " + x);
|
}
|
index++;
|
}
|
return temp.toString();
|
}
|
|
/**
|
* 根据类型选用不同的字段作为排序
|
*
|
* @return 1表示清单,2表示明细
|
**/
|
private void setOrderName(TreeGridDTO dto) {
|
|
switch (dto.winType) {
|
case 9:
|
case 15:
|
case 17:
|
case 499:
|
case 497:
|
//case 10:
|
if (dto.conNum == 0) {
|
//isList=t
|
dto.order = 1;
|
} else
|
dto.order = 2;
|
dto.isBill = true;
|
break;
|
case 1:
|
if (dto.b497 || dto.b499) {
|
dto.order = 2;
|
dto.isBill = true;
|
} else
|
dto.order = 1;
|
break;
|
default:
|
dto.order = 1;
|
}
|
}
|
}
|