提交 | 用户 | age
|
a6a76f
|
1 |
package com.yc.action.panval; |
F |
2 |
|
|
3 |
import com.yc.action.BaseAction; |
|
4 |
import com.yc.exception.CallBackMessage; |
|
5 |
import com.yc.factory.FactoryBean; |
5e6d26
|
6 |
import com.yc.multiData.SpObserver; |
F |
7 |
import com.yc.open.mutual.entity.T120201Entity; |
|
8 |
import com.yc.open.mutual.schedule.DeleteThread; |
|
9 |
import com.yc.open.mutual.service.MutualServiceIfc; |
a6a76f
|
10 |
import com.yc.service.BaseService; |
F |
11 |
import com.yc.service.impl.DBHelper; |
|
12 |
import com.yc.service.panel.SqlDBHelperIfc; |
|
13 |
import com.yc.service.panel.SystemSettingsDao; |
|
14 |
import com.yc.utils.SessionKey; |
2e60c6
|
15 |
import org.apache.commons.lang3.StringUtils; |
5e6d26
|
16 |
import org.springframework.beans.factory.annotation.Autowired; |
F |
17 |
import org.springframework.dao.DataAccessException; |
3a6b5b
|
18 |
import org.springframework.dao.IncorrectResultSizeDataAccessException; |
5e6d26
|
19 |
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; |
F |
20 |
import org.springframework.stereotype.Controller; |
|
21 |
import org.springframework.web.bind.annotation.RequestMapping; |
|
22 |
|
|
23 |
import javax.servlet.http.HttpServletRequest; |
|
24 |
import javax.servlet.http.HttpServletResponse; |
|
25 |
import javax.servlet.http.HttpSession; |
|
26 |
import java.io.IOException; |
|
27 |
import java.io.PrintWriter; |
|
28 |
import java.net.URLDecoder; |
|
29 |
import java.sql.SQLException; |
|
30 |
import java.util.*; |
a6a76f
|
31 |
|
F |
32 |
/** |
|
33 |
* |
|
34 |
* @author pengbei |
|
35 |
* |
|
36 |
*/ |
|
37 |
@Controller |
|
38 |
public class PanelCommitAction extends BaseAction { |
|
39 |
boolean returnIs = false; |
|
40 |
@Autowired |
|
41 |
SystemSettingsDao sDao; |
|
42 |
@Autowired |
|
43 |
SqlDBHelperIfc sDbHelperIfc; |
5e6d26
|
44 |
@Autowired |
F |
45 |
ThreadPoolTaskExecutor threadPoolExecutor; |
|
46 |
@Autowired |
|
47 |
MutualServiceIfc mutualServiceIfc; |
a6a76f
|
48 |
/** |
F |
49 |
* 判断凭证状态 |
|
50 |
* |
|
51 |
* @param request |
|
52 |
* @param response |
|
53 |
* @return void |
|
54 |
* @throws IOException |
|
55 |
* @throws SQLException |
|
56 |
*/ |
|
57 |
@RequestMapping("/panState.do") |
|
58 |
private void state(String docdate, int formid, String periodtype, String companyId, HttpServletRequest request, |
|
59 |
HttpServletResponse response) throws IOException, SQLException { |
|
60 |
response.setContentType("text/html;charset=utf-8"); |
|
61 |
docdate = URLDecoder.decode(docdate, "utf-8"); |
|
62 |
periodtype = URLDecoder.decode(periodtype, "utf-8"); |
|
63 |
companyId = URLDecoder.decode(companyId, "utf-8"); |
|
64 |
PrintWriter out = response.getWriter(); |
|
65 |
String mesString = ((formid != 0) ? "" : "状态检查时功能号没有获得到;pb;0#") |
|
66 |
+ ((!docdate.equals("")) ? "" : "状态检查时docdate确定时间没有得到;pb;0#") |
|
67 |
+ ((!periodtype.equals("")) ? "" : "状态检查时periodtype没有得到;pb;0#"); |
|
68 |
out.print(mesString); |
|
69 |
String docdate1 = docdate.substring(0, docdate.length() - 3); |
|
70 |
try { |
|
71 |
if (mesString.equals("")) {// 确保有参数才去判断底下sql |
|
72 |
returnIs = false; |
|
73 |
|
|
74 |
String sql = "select 'code'=case when dbo.getperiodid(" + formid + ",'" + companyId + "','" + docdate |
|
75 |
+ "')=dbo.getperiodid(+" + formid + ",'" + companyId |
|
76 |
+ "',convert(varchar(10), getdate(),120) ) then 1 else -1 end"; |
|
77 |
if (!returnIs && Integer.parseInt(sDbHelperIfc.getHashMap(sql).get(0).get("code")) == -1) { |
|
78 |
Calendar cal = Calendar.getInstance(); |
|
79 |
String date[] = docdate.split("-"); |
|
80 |
out.print("今天是" + (cal.get(Calendar.MONTH) + 1) + "月" + cal.get(Calendar.DAY_OF_MONTH) + "日," |
|
81 |
+ "您的单据日期是" + date[0] + "年" + date[1] + "月" + date[2] + "日,是否正确?\n\n" |
|
82 |
+ "(点击“确定”继续,点“取消”返回修改);pb;1#\n"); |
|
83 |
// 您是否录入了正确的单据日期,请仔细检查\n"+ |
|
84 |
// "(经系统检查,您所录入的单据日期与系统当前日期不在同一个期间,并请确认该期间是打开状态)\n\n"+ |
|
85 |
// "操作提示:\n"+ |
|
86 |
// "如果要返回修改此单据日期或取消此操作,请按“取消”;\n"+ |
|
87 |
// "如果确定是正确的单据日期,请点击“确定”;;pb;1# |
|
88 |
returnIs = true; |
|
89 |
} |
|
90 |
|
|
91 |
sql = "declare @myPeriodid varchar(10); select @myPeriodid = dbo.getPeriodid(" + formid + ",'" |
|
92 |
+ companyId + "','"// 还有这个参数不能确定@companyid |
|
93 |
+ docdate + "'); select state,periodid from gperiod with (nolock) where companyid ='" |
|
94 |
+ companyId + "' and periodtype ='" + periodtype// 期间类型 |
|
95 |
+ "' and Periodid = @myPeriodid;"; |
|
96 |
List<HashMap<String, String>> staList = sDbHelperIfc.getHashMap(sql); |
|
97 |
String stateStr = ""; |
|
98 |
String periodid = ""; |
|
99 |
if (staList != null && staList.size() > 0) { |
|
100 |
stateStr = staList.get(0).get("state"); |
|
101 |
periodid = staList.get(0).get("periodid"); |
|
102 |
} else { |
|
103 |
out.print("当前单据所属【" + periodtype + "】期间" + docdate1 + "已关闭或未打开,请与相关人员联系。;pb;0#"); |
|
104 |
stateStr = null; |
|
105 |
} |
|
106 |
switch (Integer.parseInt(DBHelper.isNull(stateStr, 3))) { |
|
107 |
case 0: // docdate1修改时间:2015-4-27 14:48:13 |
|
108 |
out.print("当前单据所属【" + periodtype + "】期间" + periodid + "未打开,请与相关人员联系。;pb;0#"); |
|
109 |
break; |
|
110 |
case 2: // docdate1 |
|
111 |
out.print("当前单据所属【" + periodtype + "】期间" + periodid + "已关闭,请与相关人员联系。;pb;0#"); |
|
112 |
break; |
|
113 |
default: |
|
114 |
returnIs = true; |
|
115 |
break; |
|
116 |
} |
|
117 |
|
|
118 |
} |
|
119 |
} catch (Exception e) { |
|
120 |
if (e.getCause() != null) { |
|
121 |
out.print(e.getCause().getMessage() + ";pb;0#"); |
|
122 |
} else { |
|
123 |
out.print(e.getMessage() + ";pb;0#"); |
|
124 |
} |
|
125 |
} |
|
126 |
out.flush(); |
|
127 |
out.close(); |
|
128 |
} |
|
129 |
|
|
130 |
/** |
|
131 |
* 删除单据 |
|
132 |
* |
|
133 |
* @param request |
|
134 |
* @param response |
|
135 |
* @return boolean |
|
136 |
* @throws IOException |
|
137 |
*/ |
|
138 |
@RequestMapping("/panDelete.do") |
|
139 |
public void deleteDoc(String formid, String doccode, HttpServletRequest request, HttpServletResponse response) |
|
140 |
throws IOException, DataAccessException { |
|
141 |
response.setContentType("text/html;charset=utf-8"); |
|
142 |
Map<String, String> env=this.initEnv(request,Integer.parseInt(formid),doccode,false); |
|
143 |
String dbid= (String) request.getSession().getAttribute(SessionKey.DATA_BASE_ID); |
|
144 |
HttpSession session = request.getSession(); |
|
145 |
String userName = session.getAttribute("@username").toString(); |
|
146 |
String userCode = session.getAttribute("@usercode").toString(); |
|
147 |
PrintWriter out = response.getWriter(); |
|
148 |
String msg =PostDeleteDocSql(formid,doccode, |
|
149 |
request.getParameter("docstatus"),dbid, |
|
150 |
request.getParameter("formtype"), |
|
151 |
userName,userCode, |
|
152 |
request.getParameter("no"),env |
|
153 |
); |
|
154 |
out.println(msg); |
|
155 |
out.flush(); |
|
156 |
out.close(); |
|
157 |
} |
|
158 |
|
|
159 |
/** |
|
160 |
*解除和环境绑定,方便其他地方调用 |
|
161 |
* by danaus 2020/10/30 9:41 |
|
162 |
* @param formid |
|
163 |
* @param doccode |
|
164 |
* @param docstatus |
|
165 |
* @param dbid |
|
166 |
* @param formtype |
|
167 |
* @param userName |
|
168 |
* @param userCode |
|
169 |
* @param no |
|
170 |
* @param env |
|
171 |
* @return |
|
172 |
*/ |
|
173 |
public String PostDeleteDocSql(String formid, String doccode,String docstatus,String dbid,String formtype, |
|
174 |
String userName,String userCode,String no,Map<String, String> env) { |
|
175 |
Map<String, Object> map =null; |
2e60c6
|
176 |
CallBackMessage callBackMessage=new CallBackMessage(); |
a6a76f
|
177 |
try { |
F |
178 |
SpObserver.setDBtoInstance("_"+dbid); |
|
179 |
map = sDao.getFormIdInTable(Integer.parseInt(formid)); |
2e60c6
|
180 |
}catch (Exception e){ |
F |
181 |
return callBackMessage.sendErrorMessage(e.getCause() != null ? e.getCause().getMessage():e.getMessage()); |
|
182 |
} |
|
183 |
finally { |
a6a76f
|
184 |
SpObserver.setDBtoInstance(); |
2e60c6
|
185 |
} |
F |
186 |
if(StringUtils.isBlank(doccode)){ |
|
187 |
return callBackMessage.sendErrorMessage("不能删除单号为空的单据!"); |
a6a76f
|
188 |
} |
F |
189 |
env.put("doccode",doccode); |
|
190 |
List<String> listSql=new ArrayList<String>(); |
|
191 |
String HDTable = DBHelper.getValue(map, "hdtable");// 主表 |
|
192 |
String DTTable = DBHelper.getValue(map, "dttable");// 明细表 |
5a1e81
|
193 |
String deletesql = " set nocount on ; \n" |
J |
194 |
+ " exec pSaveRecForDeleted @UserCode='" + userCode |
a6a76f
|
195 |
+ "',@UserName='" + userName + "'," + "@OrgDocCode = '" + doccode + "', @OrgFormID = " + formid |
F |
196 |
+ ",@OrgFormName='" + map.get("formname").toString() + "'," + "@SqlWhere = 'doccode=''" + doccode |
|
197 |
+ "'''\r\n"; |
|
198 |
listSql.add(deletesql); |
|
199 |
String strTi=formtype; |
|
200 |
int formType_int = (strTi != null) ? Integer.parseInt(strTi) : 0;// |
|
201 |
strTi = no; |
|
202 |
int no496 = (strTi != null) ? Integer.parseInt(strTi) : -1;// 针对499相同类型 |
2e60c6
|
203 |
|
a6a76f
|
204 |
try { |
F |
205 |
SpObserver.setDBtoInstance("_"+dbid); |
|
206 |
List<Map<String, Object>> selshandan = sDbHelperIfc.getselectshandan("select 1 from " + HDTable |
|
207 |
+ " where doccode='" + doccode + "' " + (docstatus.equals("") ? "" : "and docstatus=" + docstatus)); |
|
208 |
|
|
209 |
if (selshandan.size() > 0) { |
|
210 |
List<Map<String, Object>> execS = sDbHelperIfc.getHashMapObj("select * from _sys_FormProc where formid=" |
|
211 |
+ formid + " and isnull(inactive,0)=0 and action='delete' and objectType='header'"); |
|
212 |
List<Map<String, Object>> detailList = sDao.getDetailTable(Integer.parseInt(formid), formType_int, no496); |
|
213 |
String exeString = ""; |
|
214 |
for (Map<String, Object> mapExec : execS) { |
|
215 |
exeString = DBHelper.getValue(mapExec, "procname").toLowerCase();// execproc |
|
216 |
// 替换单号,及功能号, 先替换session中的变量 |
|
217 |
exeString = DBHelper.getRep(env, exeString); |
|
218 |
// 添加sql |
|
219 |
//sql += "\r\nexec " + exeString.replaceAll(";", ",");// 执行存储过程 |
5a1e81
|
220 |
listSql.add("\r\n exec " + exeString.replaceAll(";", ",")); |
a6a76f
|
221 |
} |
F |
222 |
int i = 0; |
|
223 |
String sql = " declare @refcode varchar(20), @rowcount int "; |
|
224 |
do { |
|
225 |
// ---by danuas 增加在三表的情况下,删除第三表功能 2013-7-1 |
|
226 |
BaseService base = (BaseService) FactoryBean.getBean("BaseService"); |
|
227 |
try { |
|
228 |
SpObserver.setDBtoInstance("_"+dbid); |
5a1e81
|
229 |
formType_int = base.getJdbcTemplate().queryForObject("select formtype from _sysmenu where formid=?", Integer.class, |
J |
230 |
new Object[]{formid}); |
3a6b5b
|
231 |
}catch (IncorrectResultSizeDataAccessException e) { |
F |
232 |
return callBackMessage.sendErrorMessage("在9810发现有多个"+formid+"定义,不能执行删除"); |
a6a76f
|
233 |
}finally { |
F |
234 |
SpObserver.setDBtoInstance(); |
|
235 |
} |
|
236 |
if (formType_int == 8 || formType_int == 15) { |
|
237 |
try { |
|
238 |
SpObserver.setDBtoInstance("_"+dbid); |
|
239 |
Map<String, Object> m = base.getJdbcTemplate().queryForMap( |
|
240 |
"select DetailFormID,MasterKeys,DetailKeys from _sysmasterdetail where FormID=? and FormID<>DetailFormID", |
|
241 |
formid); |
|
242 |
Map<String, Object> ms = sDao.getFormIdInTable((Integer) m.get("DetailFormID")); |
|
243 |
String tab = DBHelper.getValue(ms, "hdtable"); |
|
244 |
sql += "\r\n delete from " + tab + " where doccode ='" + doccode + "' and " |
|
245 |
+ DBHelper.getValue(m, "DetailKeys") + " in(select " |
|
246 |
+ DBHelper.getValue(m, "MasterKeys") + " from " + DTTable + " where doccode ='" |
|
247 |
+ doccode + "')";// 删除表单 |
|
248 |
} finally { |
|
249 |
SpObserver.setDBtoInstance(); |
|
250 |
} |
|
251 |
} |
|
252 |
// -----end--------- |
|
253 |
if (DTTable != null && !DTTable.equals("")) {// 先删从表 |
|
254 |
sql += "\r\n delete from " + DTTable + " where doccode ='" + doccode + "'";// 删除表单 |
|
255 |
} else { |
|
256 |
if (DTTable.equals("") && (formType_int == 496 || formType_int == 497)) {// 针对496删单问题(从表) |
|
257 |
List<Map<String, Object>> sheMap =null; |
|
258 |
Map<String, Object> rowdelmap =null; |
|
259 |
try { |
|
260 |
SpObserver.setDBtoInstance("_"+dbid); |
|
261 |
sheMap = sDbHelperIfc.getTabPageDetail(formid);// 获取从表的集合。 |
|
262 |
sheMap.remove(0).get(formid); |
|
263 |
rowdelmap = sDbHelperIfc.gethdtable(formid); |
|
264 |
for (int j = 0; j < sheMap.size(); j++) {// 组装从表删除sql语句。 |
|
265 |
Map<String, Object> tmMap = sDbHelperIfc |
|
266 |
.gethdtable(sheMap.get(j).get("formid").toString());// 获取功能号对应的表名 |
|
267 |
boolean bol = sDbHelperIfc.getdocstaut(tmMap.get("hdtable").toString());// 是否是视图表 |
|
268 |
if (!bol) { |
|
269 |
if (rowdelmap.get("rowDelFormids") != null) { |
|
270 |
if (rowdelmap.get("rowDelFormids").toString() |
|
271 |
.indexOf(sheMap.get(j).get("formid").toString()) == -1) |
|
272 |
sql += "\r\n delete from " + tmMap.get("hdtable").toString() |
|
273 |
+ " where doccode ='" + doccode + "'";// 删除表单 |
|
274 |
} else { |
|
275 |
sql += "\r\n delete from " + tmMap.get("hdtable").toString() |
|
276 |
+ " where doccode ='" + doccode + "'";// 删除表单 |
|
277 |
} |
|
278 |
} |
|
279 |
} |
|
280 |
}finally { |
|
281 |
SpObserver.setDBtoInstance(); |
|
282 |
} |
|
283 |
} |
|
284 |
} |
|
285 |
if (detailList != null && i < detailList.size()) { |
|
286 |
DTTable = DBHelper.getValue(detailList.get(i), "hdtable"); |
|
287 |
i++; |
|
288 |
} else { |
|
289 |
DTTable = null; |
|
290 |
} |
|
291 |
} while (DTTable != null); |
|
292 |
if (HDTable != null && !HDTable.equals("")) {// 主表删除 |
|
293 |
sql += insDelHis("删除单据", formid, doccode, HDTable, userName) |
|
294 |
+ " \r\n select @refcode = refcode from " + HDTable + " with (nolock) where doccode ='" |
|
295 |
+ doccode + "' and blclosed = -1 " + "\r\n if isnull(@refcode,'') <> ''\r\nbegin\r\n" |
|
296 |
+ " update " + HDTable |
|
297 |
+ " set cleardoccode = null ,blclosed = 0 where doccode =@refcode and blclosed = 1 " |
|
298 |
+ "\r\n end\r\n delete from " + HDTable + " where doccode ='" + doccode + "' " |
|
299 |
+ (docstatus.equals("") ? "" : ("and docstatus = " + docstatus)) |
5a1e81
|
300 |
+ "\r\n select @rowcount =@@rowcount\r\n if @rowcount = 0 begin raiserror('删除单据 " + doccode |
a6a76f
|
301 |
+ " 出错,或者不存在此单据', 16,1) return end "; |
F |
302 |
} |
|
303 |
// 删除三个对应的表数据(待办事宜, 弹窗提醒,日历管制) 2015-4-14 |
5a1e81
|
304 |
sql += "\r\n begin\r\n delete from _sys_fullcalendar where title like '%" + doccode |
a6a76f
|
305 |
+ "%' or description like '%" + doccode + "%' or fullname like '%" + doccode + "%'";// 日历管制表 |
F |
306 |
sql += " \r\n delete from t219001 where doccode='" + doccode + "'";// 待办事宜表 |
|
307 |
sql += " \r\n delete from spickorderlog where doccode='" + doccode + "'";// 删除流程跟踪 |
|
308 |
sql += " \r\n delete from t112002 where refformid =" + formid +" and refdoccode='"+doccode+"'";// 二维码 by danaus 2020/7/22 16:43 |
|
309 |
sql += " \r\n delete from _sysMessage where messagetxt like '%" + doccode + "%'\r\n end\r\n";// 弹窗提醒表 |
|
310 |
listSql.add(sql); |
|
311 |
try { |
|
312 |
//执行删除单据 |
|
313 |
//sql = deletesql + sql; |
|
314 |
SpObserver.setDBtoInstance("_"+dbid); |
5bdd9a
|
315 |
T120201Entity entity =null; |
F |
316 |
if("120201".equals(formid)) { |
|
317 |
//只针对120201 |
|
318 |
entity = mutualServiceIfc.getT120201ByDistributor(doccode); |
|
319 |
} |
a6a76f
|
320 |
sDbHelperIfc.doSql(listSql); |
5bdd9a
|
321 |
if(entity!=null) { |
F |
322 |
//----增加内部对接推送处理,删除销售订单同时需要把推送到总部的销售订单也要删除 by danaus 2021/6/16 10:47 |
|
323 |
threadPoolExecutor.execute(new DeleteThread(Integer.parseInt(formid), formType_int, entity, dbid)); |
|
324 |
} |
a6a76f
|
325 |
return callBackMessage.sendSuccessMessage("成功"); |
F |
326 |
} catch (DataAccessException e2) { |
5a1e81
|
327 |
e2.printStackTrace(); |
J |
328 |
return callBackMessage.sendErrorMessage(e2.getCause()!=null?e2.getCause().getMessage():e2.getMessage()); |
a6a76f
|
329 |
}catch (Exception e1) { |
5a1e81
|
330 |
e1.printStackTrace(); |
J |
331 |
return callBackMessage.sendErrorMessage(e1.getCause()!=null?e1.getCause().getMessage():e1.getMessage()); |
a6a76f
|
332 |
}finally { |
F |
333 |
SpObserver.setDBtoInstance(); |
|
334 |
} |
|
335 |
} else { |
|
336 |
return callBackMessage.sendErrorMessage("无法删除该单据,请检查该单据的状态是否已被改变或已删除。"); |
|
337 |
} |
|
338 |
} catch (Exception e) { |
5a1e81
|
339 |
e.printStackTrace(); |
3a6b5b
|
340 |
return callBackMessage.sendErrorMessage(e.getCause()!=null?e.getCause().getMessage():e.getMessage()); |
a6a76f
|
341 |
} |
F |
342 |
|
|
343 |
} |
|
344 |
/** |
|
345 |
* 获取单据信息 info按钮 |
|
346 |
* @param request |
|
347 |
* @param response |
|
348 |
* @throws IOException |
|
349 |
*/ |
|
350 |
@RequestMapping("/showInfo.do") |
|
351 |
public void showInfo(HttpServletRequest request, HttpServletResponse response) |
|
352 |
throws IOException { |
|
353 |
response.setContentType("text/html;charset=utf-8"); |
|
354 |
PrintWriter out = response.getWriter(); |
|
355 |
String formid=request.getParameter("formid"); |
|
356 |
String doccode=request.getParameter("doccode"); |
7f7112
|
357 |
String mess="";//"<table>"; |
a6a76f
|
358 |
try { |
F |
359 |
if (formid == null || "".equals(formid)|| "0".equals(formid)) { |
|
360 |
return ; |
|
361 |
} |
|
362 |
if (doccode == null || "".equals(doccode)) { |
|
363 |
return ; |
|
364 |
} |
|
365 |
Map<String, Object> map = sDao.getFormIdInTable(Integer.parseInt(formid)); |
|
366 |
String HDTable = DBHelper.getValue(map, "hdtable");// 主表 |
|
367 |
String sql="select entername,enterdate,modifyname,modifydate,postname,postdate,readerusercodes " |
|
368 |
+ "from "+HDTable+" where doccode='"+doccode+"'"; |
|
369 |
List<Map<String, Object>> linfo = sDbHelperIfc.getHashMapObj(sql); |
|
370 |
if(linfo.size()>0){ |
|
371 |
Map<String, Object> info =linfo.get(0); |
7f7112
|
372 |
mess +="<ul><li >制单人:</li><li>"+DBHelper.getValue(info, "entername")+"</li></ul>"; |
X |
373 |
mess +="<ul><li >制单时间:</li><li>"+valDate(DBHelper.getValue(info, "enterdate"))+"</li></ul>"; |
|
374 |
mess +="<ul><li >最后修改人:</li><li>"+DBHelper.getValue(info, "modifyname")+"</li></ul>"; |
|
375 |
mess +="<ul><li >最后修改时间:</li><li>"+valDate(DBHelper.getValue(info, "modifydate"))+"</li></ul>"; |
|
376 |
mess +="<ul><li >确认人:</li><li>"+DBHelper.getValue(info, "postname")+"</li></ul>"; |
|
377 |
mess +="<ul><li >确认时间:</li><li>"+valDate(DBHelper.getValue(info, "postdate"))+"</li></ul>"; |
|
378 |
mess +="<ul><li >私有权限:</li><li>"+(DBHelper.getValue(info, "readerusercodes")==""?"无":"有")+"</li></ul>"; |
|
379 |
mess +="<ul><li ><a>复制链接</a></li></ul>"; |
|
380 |
// mess +="<tr><td align=\"right\"><font size=\"2\">制单人:</font></td><td><font size=\"2\">"+DBHelper.getValue(info, "entername")+"</font></td></tr>"; |
|
381 |
// mess +="<tr><td align=\"right\"><font size=\"2\">制单时间:</font></td><td><font size=\"2\">"+valDate(DBHelper.getValue(info, "enterdate"))+"</font></td></tr>"; |
|
382 |
// mess +="<tr><td align=\"right\"><font size=\"2\">最后修改人:</font></td><td><font size=\"2\">"+DBHelper.getValue(info, "modifyname")+"</font></td></tr>"; |
|
383 |
// mess +="<tr><td align=\"right\"><font size=\"2\">最后修改时间:</font></td><td><font size=\"2\">"+valDate(DBHelper.getValue(info, "modifydate"))+"</font></td></tr>"; |
|
384 |
// mess +="<tr><td align=\"right\"><font size=\"2\">确认人:</font></td><td><font size=\"2\">"+DBHelper.getValue(info, "postname")+"</font></td></tr>"; |
|
385 |
// mess +="<tr><td align=\"right\"><font size=\"2\">确认时间:</font></td><td><font size=\"2\">"+valDate(DBHelper.getValue(info, "postdate"))+"</font></td></tr>"; |
|
386 |
// mess +="<tr><td align=\"right\"><font size=\"2\">私有权限:</font></td><td><font size=\"2\">"+(DBHelper.getValue(info, "readerusercodes")==""?"无":"有")+"</font></td></tr>"; |
|
387 |
// mess +="<tr><td align=\"center\" colspan=\"2\"><font size=\"2\"><a href=\"javascript:copyLink();\">复制链接</a></font></td></tr>"; |
|
388 |
// mess +="</table>"; |
a6a76f
|
389 |
}else{ |
F |
390 |
mess="未能找到该单据信息!"; |
|
391 |
} |
|
392 |
out.println(mess); |
|
393 |
} catch (Exception e) { |
|
394 |
out.println("此单据加载信息错误!SQL查询出现了错误:【"+e.getCause() != null ? e.getCause().getMessage():e.getMessage()+"】");//+e |
|
395 |
} |
|
396 |
} |
|
397 |
|
|
398 |
/** |
|
399 |
* 作废单据 |
|
400 |
* |
|
401 |
* @param request |
|
402 |
* @param response |
|
403 |
* @param doccode 单据号 |
|
404 |
* @return Boolean |
|
405 |
* @throws IOException |
|
406 |
*/ |
|
407 |
@RequestMapping("/panDiscard.do") |
|
408 |
public void discard(String formid, String doccode, HttpServletRequest request, HttpServletResponse response) throws IOException { |
|
409 |
response.setContentType("text/html;charset=utf-8"); |
|
410 |
Map<String, Object> map = sDao.getFormIdInTable(Integer.parseInt(formid)); |
|
411 |
String HDTable = DBHelper.getValue(map, "hdtable"); |
|
412 |
HttpSession session = request.getSession(); |
|
413 |
String docstatus = request.getParameter("docstatus"); |
|
414 |
String userName = session.getAttribute("@username").toString(); |
|
415 |
PrintWriter out = response.getWriter(); |
|
416 |
int returnNum = 0; |
|
417 |
String sql = ""; |
|
418 |
try { |
|
419 |
sql = insDelHis("作废单据", formid, doccode, HDTable, userName) + " update " + HDTable + " set blScrap = 1 where doccode ='" + doccode + "' "+(docstatus.equals("")?"":("and docstatus = " + docstatus ))+ " and isnull(blscrap,0) = 0 if @@rowcount <> 1 raiserror('无法作废该单据" + doccode + ",或者无这单据' ,16,1) "; |
|
420 |
returnNum = sDbHelperIfc.execSql(sql); // DBHelper.getResult(DBHelper.sql) |
|
421 |
// > 0 ? 1 : 0; |
|
422 |
out.print(returnNum); |
|
423 |
} catch (Exception e) { |
|
424 |
out.print(e.getCause().getMessage()); |
|
425 |
} |
|
426 |
out.flush(); |
|
427 |
out.close(); |
|
428 |
} |
|
429 |
|
|
430 |
/** |
|
431 |
* 添加(删除,作废...)操作 历史信息 |
|
432 |
* |
|
433 |
* @param chuli 事件描述 |
|
434 |
* @param formid 功能号 |
|
435 |
* @param doccode 单号 |
|
436 |
* @param HDTable 主表 |
|
437 |
* @param userName 用户名 |
|
438 |
* @return 处理日志的sql语句 |
|
439 |
* @throws Exception 抛出信息 |
|
440 |
*/ |
|
441 |
public String insDelHis(String chuli, String formid, String doccode, String HDTable, String userName) throws Exception { |
|
442 |
String sql = " insert into gdocmodifylog" + "(DocFormID,EventFormID,DocCode,DocDate, PreDocStatus,PostDocStatus,UserName,Event,EventTime ) " + " select formid ,'" + formid + "',doccode,docdate,docstatus, docstatus , '" + userName + "','" + chuli + "',getdate()" + " from " + HDTable |
|
443 |
+ " with (nolock) " + " where doccode ='" + doccode + "';"; |
|
444 |
return sql; |
|
445 |
} |
|
446 |
|
|
447 |
/** |
|
448 |
* 时间格式处理 |
|
449 |
* @param value |
|
450 |
* @return |
|
451 |
*/ |
|
452 |
public String valDate(String value){ |
|
453 |
try { |
|
454 |
if (value.indexOf(".")!=-1) { |
|
455 |
return value.substring(0, value.indexOf(".")-3); |
|
456 |
} |
|
457 |
} catch (Exception e) { |
|
458 |
return ""; |
|
459 |
} |
|
460 |
return value; |
|
461 |
} |
|
462 |
|
|
463 |
} |