TimepieceSchemeBillEditHandlerEx.java 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628
  1. package com.kingdee.shr.compensation.web.handler.timepiece.bill;
  2. import com.kingdee.bos.BOSException;
  3. import com.kingdee.bos.Context;
  4. import com.kingdee.bos.metadata.entity.EntityViewInfo;
  5. import com.kingdee.bos.metadata.entity.FilterInfo;
  6. import com.kingdee.bos.metadata.entity.FilterItemInfo;
  7. import com.kingdee.bos.metadata.entity.SelectorItemCollection;
  8. import com.kingdee.bos.metadata.entity.SelectorItemInfo;
  9. import com.kingdee.bos.metadata.query.util.CompareType;
  10. import com.kingdee.eas.common.EASBizException;
  11. import com.kingdee.eas.custom.calcdailypay.IInspectionRate;
  12. import com.kingdee.eas.custom.calcdailypay.InspectionRateCollection;
  13. import com.kingdee.eas.custom.calcdailypay.InspectionRateFactory;
  14. import com.kingdee.eas.custom.calcdailypay.InspectionRateInfo;
  15. import com.kingdee.eas.framework.CoreBaseCollection;
  16. import com.kingdee.eas.framework.CoreBaseInfo;
  17. import com.kingdee.eas.util.ToolUtils;
  18. import com.kingdee.eas.util.app.DbUtil;
  19. import com.kingdee.jdbc.rowset.IRowSet;
  20. import com.kingdee.shr.base.syssetting.context.SHRContext;
  21. import com.kingdee.shr.base.syssetting.exception.SHRWebException;
  22. import com.kingdee.shr.compensation.app.integrate.*;
  23. import com.kingdee.shr.compensation.exception.ExceptionHandle;
  24. import com.kingdee.shr.base.syssetting.web.json.JSONUtils;
  25. import java.math.BigDecimal;
  26. import java.sql.SQLException;
  27. import java.text.ParseException;
  28. import java.text.SimpleDateFormat;
  29. import java.util.ArrayList;
  30. import java.util.Arrays;
  31. import java.util.Collections;
  32. import java.util.Date;
  33. import java.util.HashMap;
  34. import java.util.HashSet;
  35. import java.util.List;
  36. import java.util.Map;
  37. import java.util.Set;
  38. import javax.servlet.http.HttpServletRequest;
  39. import javax.servlet.http.HttpServletResponse;
  40. import org.apache.commons.lang3.ObjectUtils;
  41. import org.apache.commons.lang3.StringUtils;
  42. import org.slf4j.Logger;
  43. import org.slf4j.LoggerFactory;
  44. import org.springframework.ui.ModelMap;
  45. /**
  46. * 提报单拓展
  47. * @author coyle
  48. * 20250520
  49. */
  50. public class TimepieceSchemeBillEditHandlerEx extends TimepieceSchemeBillEditHandler {
  51. private static Logger logger = LoggerFactory.getLogger(TimepieceSchemeBillEditHandlerEx.class);
  52. private static SimpleDateFormat SDF = new SimpleDateFormat("yyyy-MM-dd");
  53. //完成率
  54. private static String COMRATE = "MQ005";
  55. //岗位类型
  56. private static String JOBTYPE = "MQ004";
  57. //技能等级 SKILLLEVEL
  58. private static String SKILLLEVEL = "MQ003";
  59. //是否现场作业 On site
  60. private static String ONSITE = "MQ007";
  61. //班组任职 Team app
  62. private static String TEAMAPP = "MQ007";
  63. //工资序列 Salary seq
  64. private static String SALARYSEQ = "MQ007";
  65. private static String[] ITEMNUMS = {COMRATE,JOBTYPE,SKILLLEVEL,ONSITE,TEAMAPP,SALARYSEQ};
  66. private static Map<String,String> FEILDS = new HashMap();
  67. public TimepieceSchemeBillEditHandlerEx() throws BOSException {
  68. Context ctx = SHRContext.getInstance().getContext();
  69. CalSubmitItemCollection subColl = CalSubmitItemFactory.getLocalInstance(ctx)
  70. .getCalSubmitItemCollection("SELECT ID,FieldSn,number where number in (" + ToolUtils.aryToStr(ITEMNUMS) + ")");
  71. if (subColl != null && subColl.size() > 0) {
  72. for (int i =0 ;i<subColl.size();i++) {
  73. CalSubmitItemInfo itemInfo = subColl.get(i);
  74. if (itemInfo != null) {
  75. String columnName = "S" + itemInfo.getFieldSn();
  76. FEILDS.put(itemInfo.getNumber() , columnName);
  77. }
  78. }
  79. }
  80. }
  81. protected void beforeSave(HttpServletRequest request, HttpServletResponse response, CoreBaseInfo model)
  82. throws SHRWebException {
  83. super.beforeSave(request, response, model);
  84. Context ctx = SHRContext.getInstance().getContext();
  85. BatchSubmitShemeBillInfo info = (BatchSubmitShemeBillInfo) model;
  86. BatchSubmitShemeBillEntryCollection entry = info.getEntry();
  87. String billId = "";
  88. if(ObjectUtils.allNotNull(info.getId())) {
  89. billId = info.getId().toString();
  90. }
  91. //拉取mes点检率数据
  92. exeDataOnDay( request,billId,entry);
  93. //先重置点检率标识
  94. reductionInspectionRate( ctx, info);
  95. //更新点检率数据
  96. updateInspectionRate(request, ctx, info);
  97. }
  98. /**
  99. * 从中间表获取mes数据
  100. */
  101. private HashMap<String,HashMap> getMesData(HttpServletRequest request,Context ctx ,HashSet<String> selectPerson,DateRange dateRange) {
  102. HashMap<String,HashMap> checkMap = new HashMap();
  103. Set<String> checkbillIds = new HashSet();
  104. SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
  105. try {
  106. String sql = " select fid ,CFComrate, cfpersonId, cfpositiontype , cfskillLevel , cfonSite , cfteamApp , cfsalarysEq ,"
  107. + " cfbizDate "
  108. + " from CT_CAL_InspectionRate where cfpersonid in "
  109. + "( "
  110. + ToolUtils.aryToStr(selectPerson,true)
  111. + " ) "
  112. + " and cfbizDate >= '"
  113. + dateFormat.format(dateRange.getMinDate())
  114. + "' and cfbizDate <= '"
  115. + dateFormat.format(dateRange.getMaxDate())
  116. +"'" ;
  117. IRowSet rst = DbUtil.executeQuery(ctx, sql);
  118. while( rst.next() ) {
  119. //点检率id存入
  120. String checkbillId = rst.getString("fid");
  121. checkbillIds.add(checkbillId);
  122. String pId = rst.getString("cfPersonId");
  123. Date bizDate = rst.getDate("cfbizDate");
  124. String eDate = SDF.format(bizDate);
  125. String key = pId+"_"+eDate;
  126. HashMap<String,String> valMap = new HashMap();
  127. BigDecimal comrate = rst.getBigDecimal("CFComrate");
  128. valMap.put(FEILDS.get(COMRATE), comrate.toString());
  129. //
  130. valMap.put(FEILDS.get(JOBTYPE), rst.getString("cfpositiontype"));
  131. valMap.put(FEILDS.get(SKILLLEVEL), rst.getString("cfskillLevel"));
  132. valMap.put(FEILDS.get(ONSITE), rst.getString("cfonSite"));
  133. valMap.put(FEILDS.get(TEAMAPP), rst.getString("cfteamApp"));
  134. valMap.put(FEILDS.get(SALARYSEQ), rst.getString("cfsalarysEq"));
  135. checkMap.put(key, valMap);
  136. }
  137. request.setAttribute("checkbillIds", checkbillIds);
  138. }catch(BOSException e){
  139. e.printStackTrace();
  140. } catch (SQLException e) {
  141. e.printStackTrace();
  142. }
  143. return checkMap;
  144. }
  145. /**
  146. * 数据处理
  147. * 校验对应的某一天已存在数据/mes数据获取等
  148. * @param billId
  149. * @param entrys
  150. * @throws SHRWebException
  151. */
  152. public void exeDataOnDay(HttpServletRequest request,String billId,BatchSubmitShemeBillEntryCollection entrys) throws SHRWebException {
  153. Context ctx = SHRContext.getInstance().getContext();
  154. Map<String, Set<String>> personDateMap = new HashMap<>();
  155. //
  156. HashSet<String> selectPerson = new HashSet();
  157. HashSet<String> selectDate = new HashSet();
  158. for (int i = 0; i < entrys.size(); i++) {
  159. BatchSubmitShemeBillEntryInfo entry = entrys.get(i);
  160. String personId = entry.getPerson().getId().toString();
  161. selectPerson.add(personId);
  162. Date effectDate = entry.getEffectDate();
  163. // 增加对 effectDate 为 null 的检查
  164. if (effectDate == null) {
  165. throw new IllegalArgumentException("分录中发生日期不能为空,请检查");
  166. }
  167. String formattedEffectDate = SDF.format(effectDate);
  168. selectDate.add(formattedEffectDate);
  169. // 使用 computeIfAbsent 减少冗余代码,并增加重复检查
  170. personDateMap.computeIfAbsent(personId, k -> new HashSet<>());
  171. if (!personDateMap.get(personId).add(formattedEffectDate)) {
  172. // 如果 add 方法返回 false,说明该日期已经存在,抛出异常
  173. throw new IllegalArgumentException("分录中" + entry.getPerson().getName() + ",有当日重复提报的数据,请检查");
  174. }
  175. }
  176. if (personDateMap.isEmpty()) {
  177. return;
  178. }
  179. // 找出最大日期与最小日期
  180. DateRange dateRange = findMinMaxDate(selectDate);
  181. //校验重复
  182. verifiOneData(ctx, billId, selectPerson, dateRange, personDateMap);
  183. //校验完后进行mes数据填充;
  184. //获取mes数据
  185. HashMap<String, HashMap> mesData = getMesData(request,ctx, selectPerson, dateRange);
  186. setMesData( request, entrys, mesData);
  187. }
  188. /**
  189. * 校验当天是否有重复数据
  190. * @param ctx
  191. * @param billId
  192. * @param selectPerson
  193. * @param dateRange
  194. * @param personDateMap
  195. * @throws SHRWebException
  196. */
  197. public void verifiOneData(Context ctx ,String billId,HashSet<String> selectPerson,DateRange dateRange,Map<String, Set<String>> personDateMap) throws SHRWebException {
  198. HashMap<String,String> dataMap = new HashMap();
  199. try {
  200. IBatchSubmitShemeBillEntry entryIns = BatchSubmitShemeBillEntryFactory.getLocalInstance(ctx);
  201. FilterInfo filter = new FilterInfo();
  202. filter.getFilterItems().add(new FilterItemInfo("person", selectPerson, CompareType.INCLUDE));
  203. filter.getFilterItems().add(new FilterItemInfo("bill.id", billId , CompareType.NOTEQUALS ));
  204. filter.getFilterItems().add(new FilterItemInfo("effectDate", dateRange.getMaxDate() , CompareType.LESS_EQUALS));
  205. filter.getFilterItems().add(new FilterItemInfo("effectDate", dateRange.getMinDate() , CompareType.GREATER_EQUALS ));
  206. EntityViewInfo viewInfo = new EntityViewInfo();
  207. SelectorItemCollection selector = viewInfo.getSelector();
  208. selector.add(new SelectorItemInfo("person.id"));
  209. selector.add(new SelectorItemInfo("person.name"));
  210. selector.add(new SelectorItemInfo("bill.number"));
  211. selector.add(new SelectorItemInfo("effectDate"));
  212. viewInfo.setFilter(filter);
  213. BatchSubmitShemeBillEntryCollection entryCol = entryIns.getBatchSubmitShemeBillEntryCollection(viewInfo);
  214. for(int i = 0;i<entryCol.size();i++) {
  215. BatchSubmitShemeBillEntryInfo entryInfo = entryCol.get(i);
  216. Date effectDate = entryInfo.getEffectDate();
  217. String personId = entryInfo.getPerson().getId().toString();
  218. Set<String> pAndDate = personDateMap.get(personId);
  219. if(pAndDate.contains(SDF.format(effectDate))) {
  220. String personName = entryInfo.getPerson().getName().toString();
  221. BatchSubmitShemeBillInfo billInfo = entryInfo.getBill();
  222. String billNo = billInfo.getNumber();
  223. dataMap.put(personName, billNo);
  224. }
  225. }
  226. } catch (BOSException e) {
  227. e.printStackTrace();
  228. }
  229. //如果dataMap不为空则循环dataMap的数据组成字符串并抛出异常,"存在哪些人,单据编码为:****"
  230. if(!dataMap.isEmpty()) {
  231. String errorMsg = "存在以下当日重复提报人员,姓名与单据编码为:";
  232. for(String personName : dataMap.keySet()) {
  233. String billNo = dataMap.get(personName);
  234. errorMsg += personName + ":" + billNo + " ";
  235. }
  236. throw new SHRWebException(errorMsg);
  237. }
  238. }
  239. /**
  240. * 设置点检率数据
  241. * @param request
  242. * @param entrys
  243. */
  244. public void setMesData(HttpServletRequest request, BatchSubmitShemeBillEntryCollection entrys,
  245. HashMap<String, HashMap> mesData) {
  246. int assignedRows = 0; // 新增:统计实际赋值的行数
  247. for (int i = 0; i < entrys.size(); i++) {
  248. BatchSubmitShemeBillEntryInfo entry = entrys.get(i);
  249. String pId = entry.getPerson().getId().toString();
  250. Date effectDate = entry.getEffectDate();
  251. String eDate = SDF.format(effectDate);
  252. String key = pId + "_" + eDate;
  253. HashMap valMap = mesData.get(key);
  254. if (ObjectUtils.isEmpty(valMap)) {
  255. continue;
  256. }
  257. boolean isRowAssigned = false; // 标记当前行是否被赋值
  258. for (String field : FEILDS.keySet()) {
  259. String sVal = FEILDS.get(field);
  260. if (entry.containsKey(sVal)) {
  261. entry.put(sVal, valMap.get(sVal));
  262. isRowAssigned = true; // 当前行至少有一个字段被赋值
  263. }
  264. }
  265. if (isRowAssigned) {
  266. assignedRows++; // 只有实际赋值的行才计数
  267. }
  268. }
  269. // 将统计结果存入 request
  270. request.setAttribute("assignedRowsCount", assignedRows);
  271. }
  272. /**
  273. * handler校验,先不启用
  274. * @param request
  275. * @param response
  276. * @param modelMap
  277. * @throws SHRWebException
  278. */
  279. public void hasDataOnDayAction(HttpServletRequest request, HttpServletResponse response, ModelMap modelMap)
  280. throws SHRWebException {
  281. Context ctx = SHRContext.getInstance().getContext();
  282. // 获取人员 //格式为[pseron1:2025-04-03,person2:2025-04-03],需要转为map
  283. String proposers = request.getParameter("proposers");
  284. if (proposers == null || proposers.isEmpty()) {
  285. return;
  286. }
  287. String[] personArr = proposers.split(",");
  288. HashSet<String> selectPerson = new HashSet();
  289. HashSet<String> selectData = new HashSet();
  290. Map<String, Set<String>> personDateMap = new HashMap<>();
  291. for (int i = 0; i< personArr.length;i++) {
  292. String personIds = personArr[i];
  293. String[] parts = personIds.split(":");
  294. if (parts.length == 2) {
  295. String personId = parts[0].trim();
  296. String date = parts[1].trim();
  297. selectPerson.add(personId);
  298. selectData.add(date);
  299. personDateMap.computeIfAbsent(personId, k -> new HashSet<>()).add(date);
  300. }
  301. }
  302. if (personDateMap.isEmpty()) {
  303. return;
  304. }
  305. HashMap<String,String> dataMap = new HashMap();
  306. // 找出最大日期与最小日期
  307. DateRange dateRange = findMinMaxDate(selectData);
  308. IBatchSubmitShemeBillEntry entryIns;
  309. try {
  310. entryIns = BatchSubmitShemeBillEntryFactory.getLocalInstance(ctx);
  311. FilterInfo filter = new FilterInfo();
  312. filter.getFilterItems().add(new FilterItemInfo("proposer", selectPerson, CompareType.INCLUDE));
  313. filter.getFilterItems().add(new FilterItemInfo("effectDate", dateRange.getMaxDate() , CompareType.LESS_EQUALS));
  314. filter.getFilterItems().add(new FilterItemInfo("effectDate", dateRange.getMinDate() , CompareType.GREATER_EQUALS ));
  315. EntityViewInfo viewInfo = new EntityViewInfo();
  316. viewInfo.setFilter(filter);
  317. BatchSubmitShemeBillEntryCollection entryCol = entryIns.getBatchSubmitShemeBillEntryCollection(viewInfo);
  318. for(int i = 0;i<entryCol.size();i++) {
  319. BatchSubmitShemeBillEntryInfo entryInfo = entryCol.get(i);
  320. Date effectDate = entryInfo.getEffectDate();
  321. String personId = entryInfo.getPerson().getId().toString();
  322. Set<String> pAndDate = personDateMap.get(personId);
  323. if(pAndDate.contains(SDF.format(effectDate))) {
  324. String personName = entryInfo.getPerson().getName().toString();
  325. BatchSubmitShemeBillInfo billInfo = entryInfo.getBill();
  326. String billNo = billInfo.getNumber();
  327. dataMap.put(personName, billNo);
  328. }
  329. }
  330. } catch (BOSException e) {
  331. e.printStackTrace();
  332. }
  333. Map resultMap = new HashMap();
  334. JSONUtils.SUCCESS( resultMap );
  335. }
  336. private DateRange findMinMaxDate(HashSet<String> subDate) {
  337. if (subDate == null || subDate.isEmpty()) {
  338. return null;
  339. }
  340. List<Date> dates = new ArrayList<>();
  341. SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
  342. for (String dateString : subDate) {
  343. try {
  344. dates.add(dateFormat.parse(dateString.trim()));
  345. } catch (ParseException e) {
  346. // 处理日期格式不正确的情况
  347. e.printStackTrace();
  348. return null; // 如果有日期格式不正确,直接返回 null
  349. }
  350. }
  351. if (dates.isEmpty()) {
  352. return null;
  353. }
  354. Date minDate = Collections.min(dates);
  355. Date maxDate = Collections.max(dates);
  356. return new DateRange(minDate, maxDate);
  357. }
  358. // 定义一个辅助类来存储日期范围
  359. private static class DateRange {
  360. private final Date minDate;
  361. private final Date maxDate;
  362. public DateRange(Date minDate, Date maxDate) {
  363. this.minDate = minDate;
  364. this.maxDate = maxDate;
  365. }
  366. public Date getMinDate() {
  367. return minDate;
  368. }
  369. public Date getMaxDate() {
  370. return maxDate;
  371. }
  372. }
  373. protected void afterSave(HttpServletRequest request, HttpServletResponse response, CoreBaseInfo model)
  374. throws SHRWebException {
  375. super.afterSave(request, response, model);
  376. Context ctx = SHRContext.getInstance().getContext();
  377. BatchSubmitShemeBillInfo info = (BatchSubmitShemeBillInfo) model;
  378. BatchSubmitShemeBillEntryCollection entry = info.getEntry();
  379. }
  380. /**
  381. * 更新点检率
  382. * @param request
  383. * @param ctx
  384. * @param info
  385. */
  386. private static void updateInspectionRate(HttpServletRequest request, Context ctx, BatchSubmitShemeBillInfo info) {
  387. //更新点检率数据
  388. Set<String> checkbillIds = (Set<String> ) request.getAttribute("checkbillIds");
  389. FilterInfo filter = new FilterInfo();
  390. filter.getFilterItems().add(new FilterItemInfo("id", checkbillIds, CompareType.INCLUDE));
  391. EntityViewInfo viewInfo = new EntityViewInfo( ) ;
  392. viewInfo.setFilter(filter);
  393. SelectorItemCollection selector = viewInfo.getSelector();
  394. selector.add(new SelectorItemInfo("detailNum"));
  395. selector.add(new SelectorItemInfo("isSubDetail"));
  396. try {
  397. IInspectionRate spIns = InspectionRateFactory.getLocalInstance(ctx);
  398. InspectionRateCollection inspectionRateCollection = spIns.getInspectionRateCollection(viewInfo);
  399. CoreBaseCollection cCol = new CoreBaseCollection();
  400. for(int i = 0;i<inspectionRateCollection.size();i++){
  401. InspectionRateInfo inspectionRateInfo = inspectionRateCollection.get(i);
  402. inspectionRateInfo.setDetailNum(info.getNumber());
  403. inspectionRateInfo.setIsSubDetail(true);
  404. cCol.add(inspectionRateInfo);
  405. }
  406. spIns.updateBatchData(cCol);
  407. } catch (BOSException e) {
  408. throw new RuntimeException(e);
  409. } catch (EASBizException e) {
  410. throw new RuntimeException(e);
  411. }
  412. }
  413. // public void getDataOnDay(String billId,BatchSubmitShemeBillEntryCollection entrys) throws SHRWebException {
  414. // Context ctx = SHRContext.getInstance().getContext();
  415. // Map<String, Set<String>> personDateMap = new HashMap<>();
  416. // //
  417. // HashSet<String> selectPerson = new HashSet();
  418. // HashSet<String> selectDate = new HashSet();
  419. // for (int i = 0; i < entrys.size(); i++) {
  420. // BatchSubmitShemeBillEntryInfo entry = entrys.get(i);
  421. // String personId = entry.getPerson().getId().toString();
  422. // selectPerson.add(personId);
  423. // Date effectDate = entry.getEffectDate();
  424. //
  425. // String formattedEffectDate = SDF.format(effectDate);
  426. // selectDate.add(formattedEffectDate);
  427. // // 使用 computeIfAbsent 减少冗余代码,并增加重复检查
  428. // personDateMap.computeIfAbsent(personId, k -> new HashSet<>());
  429. // if (!personDateMap.get(personId).add(formattedEffectDate)) {
  430. // // 如果 add 方法返回 false,说明该日期已经存在,抛出异常
  431. // throw new IllegalArgumentException("分录中" + entry.getPerson().getName() + ",有当日重复提报的数据,请检查");
  432. // }
  433. // }
  434. //
  435. // if (personDateMap.isEmpty()) {
  436. // return;
  437. // }
  438. // // 找出最大日期与最小日期
  439. // DateRange dateRange = findMinMaxDate(selectDate);
  440. // //校验重复
  441. // verifiOneData(ctx, billId, selectPerson, dateRange, personDateMap);
  442. // //获取mes数据
  443. // HashMap<String, HashMap> mesData = getMesData(ctx, selectPerson, dateRange);
  444. // setMesData(ctx, billId, entrys, mesData);
  445. // }
  446. public String saveAction(HttpServletRequest request, HttpServletResponse response, ModelMap modelMap)
  447. throws SHRWebException {
  448. try {
  449. BatchSubmitShemeBillInfo model = (BatchSubmitShemeBillInfo) request.getAttribute("dynamic_model");
  450. this.doFieldPermFilterSave(request, model);
  451. this.doSave(request, response, model);
  452. this.afterSave(request, response, model);
  453. this.saveAttachment(request, response, model);
  454. Object responseData = this.generateResponseDataAfterSave(request, response, model);
  455. Map resultMap = new HashMap();
  456. resultMap.put("responseData", responseData);
  457. resultMap.put("assignedRowsCount", request.getAttribute("assignedRowsCount"));
  458. this.writeSuccessData(resultMap);
  459. } catch (Exception var6) {
  460. ExceptionHandle.handleException(var6);
  461. }
  462. return null;
  463. }
  464. /**
  465. * 重置点检率标识
  466. * 将点检率中是否提报标记还原为false;
  467. * @param ctx
  468. * @param info
  469. */
  470. private static void reductionInspectionRate(Context ctx, BatchSubmitShemeBillInfo info) {
  471. //更新点检率数据
  472. String subNum = info.getNumber();
  473. if(StringUtils.isEmpty(subNum)){
  474. return;
  475. }
  476. FilterInfo filter = new FilterInfo();
  477. filter.getFilterItems().add(new FilterItemInfo("detailNum", subNum, CompareType.EQUALS));
  478. EntityViewInfo viewInfo = new EntityViewInfo( ) ;
  479. viewInfo.setFilter(filter);
  480. SelectorItemCollection selector = viewInfo.getSelector();
  481. selector.add(new SelectorItemInfo("detailNum"));
  482. selector.add(new SelectorItemInfo("isSubDetail"));
  483. try {
  484. IInspectionRate spIns = InspectionRateFactory.getLocalInstance(ctx);
  485. InspectionRateCollection inspectionRateCollection = spIns.getInspectionRateCollection(viewInfo);
  486. CoreBaseCollection cCol = new CoreBaseCollection();
  487. for(int i = 0;i<inspectionRateCollection.size();i++){
  488. InspectionRateInfo inspectionRateInfo = inspectionRateCollection.get(i);
  489. inspectionRateInfo.setDetailNum("");
  490. inspectionRateInfo.setIsSubDetail(false);
  491. cCol.add(inspectionRateInfo);
  492. }
  493. spIns.updateBatchData(cCol);
  494. } catch (BOSException e) {
  495. throw new RuntimeException(e);
  496. } catch (EASBizException e) {
  497. throw new RuntimeException(e);
  498. }
  499. }
  500. /**
  501. * 删除单据
  502. */
  503. @Override
  504. public String deleteAction(HttpServletRequest request, HttpServletResponse response, ModelMap modelMap) throws SHRWebException {
  505. String returnStr = super.deleteAction(request, response, modelMap);
  506. reductionAllInsRate(request);
  507. return returnStr ;
  508. }
  509. /**
  510. * 重置所有点检率
  511. * @param request
  512. * @throws SHRWebException
  513. */
  514. private void reductionAllInsRate (HttpServletRequest request) throws SHRWebException {
  515. String billId = getBillId(request);
  516. String[] ids = billId.split(",");
  517. //ids转为list集合
  518. List<String> idList = Arrays.asList(ids);
  519. Context ctx = SHRContext.getInstance().getContext();
  520. FilterInfo filter = new FilterInfo();
  521. filter.getFilterItems().add(new FilterItemInfo("id", ToolUtils.aryToStr(idList,false), CompareType.INCLUDE));
  522. EntityViewInfo viewInfo = new EntityViewInfo( ) ;
  523. viewInfo.setFilter(filter);
  524. SelectorItemCollection selector = viewInfo.getSelector();
  525. selector.add(new SelectorItemInfo("number"));
  526. try {
  527. IBatchSubmitShemeBill subIns = BatchSubmitShemeBillFactory.getLocalInstance(ctx);
  528. BatchSubmitShemeBillCollection subCol = subIns.getBatchSubmitShemeBillCollection(viewInfo);
  529. for(int i = 0;i<subCol.size();i++){
  530. BatchSubmitShemeBillInfo subInfo = subCol.get(i);
  531. reductionInspectionRate(ctx, subInfo);
  532. }
  533. } catch (BOSException e) {
  534. throw new RuntimeException(e);
  535. }
  536. }
  537. }