AddSalaryEditHandler.java 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  1. /**
  2. *
  3. */
  4. package com.kingdee.shr.customer.gtiit.rpt;
  5. import java.sql.SQLException;
  6. import java.util.ArrayList;
  7. import java.util.List;
  8. import java.util.stream.Collectors;
  9. import javax.servlet.http.HttpServletRequest;
  10. import javax.servlet.http.HttpServletResponse;
  11. import org.springframework.ui.ModelMap;
  12. import com.kingdee.bos.BOSException;
  13. import com.kingdee.bos.Context;
  14. import com.kingdee.eas.framework.CoreBaseInfo;
  15. import com.kingdee.eas.util.app.DbUtil;
  16. import com.kingdee.jdbc.rowset.IRowSet;
  17. import com.kingdee.shr.base.syssetting.context.SHRContext;
  18. import com.kingdee.shr.base.syssetting.exception.SHRWebException;
  19. import com.kingdee.shr.base.syssetting.exception.ShrWebBizException;
  20. import com.kingdee.shr.base.syssetting.web.handler.DEPCustomBillEditHandler;
  21. /**
  22. * @author ISSUSER 工资单薪酬项目新增保存校验
  23. */
  24. public class AddSalaryEditHandler extends DEPCustomBillEditHandler {
  25. Context ctx = SHRContext.getInstance().getContext();
  26. @Override
  27. public String saveAction(HttpServletRequest request, HttpServletResponse response, ModelMap modeMap)
  28. throws SHRWebException {
  29. CoreBaseInfo model = (CoreBaseInfo) request.getAttribute("dynamic_model");
  30. String depidentifying = model.getString("depidentifying");
  31. List<String> columnList = getColumn();
  32. List<String> list = getFiled();
  33. List<String> determineFieldsList = determineFields();
  34. if (list.contains(depidentifying)) {
  35. // 判断是否是中文环境
  36. if (ctx.getLocale().toString().equalsIgnoreCase("zh_CN")
  37. || ctx.getLocale().toString().equalsIgnoreCase("l2")
  38. || ctx.getLocale().toString().equalsIgnoreCase("L2")) {
  39. throw new ShrWebBizException("该dep标识已经在单据中存在");
  40. } else {
  41. throw new ShrWebBizException("The dep identifier already exists in the document");
  42. }
  43. }
  44. // String depFile = "cf" + depidentifying.toLowerCase();
  45. // if (!columnList.contains(depFile) && !columnList.contains(depFile + "_l1")) {
  46. // // 判断是否是中文环境
  47. // if (ctx.getLocale().toString().equalsIgnoreCase("zh_CN")
  48. // || ctx.getLocale().toString().equalsIgnoreCase("l2")
  49. // || ctx.getLocale().toString().equalsIgnoreCase("L2")) {
  50. // throw new ShrWebBizException("dep里面没有该字段,请先在dep里面创建字段");
  51. // } else {
  52. // throw new ShrWebBizException(
  53. // "This field is not available in the dep. Please create a field in the dep first");
  54. // }
  55. // }
  56. if (determineFieldsList.contains(depidentifying.toLowerCase())) {
  57. if (ctx.getLocale().toString().equalsIgnoreCase("zh_CN")
  58. || ctx.getLocale().toString().equalsIgnoreCase("l2")
  59. || ctx.getLocale().toString().equalsIgnoreCase("L2")) {
  60. throw new ShrWebBizException("dep已存在该字段标识");
  61. } else {
  62. throw new ShrWebBizException("The field identifier already exists in dep");
  63. }
  64. }
  65. return super.saveAction(request, response, modeMap);
  66. }
  67. /**
  68. * 查询工资单薪酬项目新增单据里面的 dep字段
  69. */
  70. public List<String> getFiled() {
  71. List<String> list = new ArrayList<>();
  72. String sql = "select* from CT_CUS_AddSalaryproject";
  73. try {
  74. IRowSet rs = DbUtil.executeQuery(ctx, sql);
  75. while (rs.next()) {
  76. list.add(rs.getString("cfdepidentifying"));
  77. }
  78. } catch (BOSException e) {
  79. e.printStackTrace();
  80. } catch (SQLException e) {
  81. e.printStackTrace();
  82. }
  83. return list;
  84. }
  85. /**
  86. * 查询工资单套打里面的所有字段
  87. *
  88. */
  89. public List<String> getColumn() {
  90. List<String> list = new ArrayList<>();
  91. String sql = "SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'CT_SAL_WagesChromatography'";
  92. try {
  93. IRowSet rs = DbUtil.executeQuery(ctx, sql);
  94. while (rs.next()) {
  95. // 转换为小写
  96. list.add(rs.getString("COLUMN_NAME").toLowerCase());
  97. }
  98. } catch (BOSException e) {
  99. e.printStackTrace();
  100. } catch (SQLException e) {
  101. e.printStackTrace();
  102. }
  103. return list;
  104. }
  105. /***
  106. * 存储已经定死的字段
  107. */
  108. public List<String> determineFields() {
  109. List<String> filedList = new ArrayList<>();
  110. filedList.add("ynssd");
  111. filedList.add("yfzj");
  112. filedList.add("deductionsfortaxRMB");
  113. filedList.add("deductionsfortax");
  114. filedList.add("Note");
  115. filedList.add("DeductionafterTax");
  116. filedList.add("PaymentafterTax");
  117. filedList.add("SalaryAdvance");
  118. filedList.add("UtilityCost");
  119. filedList.add("Rent");
  120. filedList.add("GrossSalary");
  121. filedList.add("rentorutility");
  122. filedList.add("Utilityfee");
  123. filedList.add("OtherDeduction");
  124. filedList.add("OtherRefund");
  125. filedList.add("UnpaidLeaveDeduction");
  126. filedList.add("UGSubsidyUG");
  127. filedList.add("AdmissionSubsidy");
  128. filedList.add("TaxableOtherBenefit");
  129. filedList.add("TaxableCommercial");
  130. filedList.add("TotalDeductionBeforeTax");
  131. filedList.add("DeductionBeforeTax");
  132. filedList.add("TotalAllowance");
  133. filedList.add("TeachersDayAllowance");
  134. filedList.add("TutoringAllowance2");
  135. filedList.add("TutoringAllowance");
  136. filedList.add("GrossWage2");
  137. filedList.add("DailyWage");
  138. filedList.add("leaveallowance");
  139. filedList.add("severancepay");
  140. filedList.add("annualleave");
  141. filedList.add("ERHousing");
  142. filedList.add("ERMedicalins");
  143. filedList.add("ERSocialins");
  144. filedList.add("TotalTax");
  145. filedList.add("SeveranceTax");
  146. filedList.add("NonResident");
  147. filedList.add("BonusTax1");
  148. filedList.add("AnnualBonus2");
  149. filedList.add("ForeignerAnnual");
  150. filedList.add("AnnualBonus1");
  151. filedList.add("Specialexpense");
  152. filedList.add("TaxableItem");
  153. filedList.add("PensionAllowance");
  154. filedList.add("HouseAllowance");
  155. filedList.add("CommunicationAllowance");
  156. filedList.add("OTPayment");
  157. filedList.add("HolidayOTPayment");
  158. filedList.add("TaxExemption");
  159. filedList.add("shifanetPayment");
  160. filedList.add("netPaymentnumber");
  161. filedList.add("socialinsuranceplanRMB");
  162. filedList.add("socialinsuranceplanRMBCode");
  163. filedList.add("IndividualIncomeTaxRMB");
  164. filedList.add("IndividualIncomeTaxRMBCode");
  165. filedList.add("HousingfundRMB");
  166. filedList.add("HousingfundRMBCode");
  167. filedList.add("MedicalinsuranceRMB");
  168. filedList.add("MedicalinsuranceRMBCode");
  169. filedList.add("SocialinsuranceRMB");
  170. filedList.add("SocialinsuranceRMBCode");
  171. filedList.add("SubsidyRMB");
  172. filedList.add("SubsidyRMBCode");
  173. filedList.add("WeekendOTPaymentRMB");
  174. filedList.add("WeekendOTPaymentRMBCode");
  175. filedList.add("WorkdayOTPaymentRMB");
  176. filedList.add("WorkdayOTPaymentRMBCode");
  177. filedList.add("PositionAllowanceRMB");
  178. filedList.add("PositionAllowanceRMBCode");
  179. filedList.add("netpaymentRMB");
  180. filedList.add("netpaymentRMBCode");
  181. filedList.add("YTDtaxRMB");
  182. filedList.add("YTDtaxRMBCode");
  183. filedList.add("YTDgrossRMB");
  184. filedList.add("YTDgrossRMBCode");
  185. filedList.add("HourlyRateRMB");
  186. filedList.add("HourlyRateRMBCode");
  187. filedList.add("ServiceTaxRMB");
  188. filedList.add("ServiceTaxRMBCode");
  189. filedList.add("PaymentbeforeRMB");
  190. filedList.add("PaymentbeforeRMBCode");
  191. filedList.add("GrossWageRMB");
  192. filedList.add("GrossWageRMBCode");
  193. filedList.add("MonthRMB");
  194. filedList.add("MonthRMBCode");
  195. filedList.add("paymentcurrency");
  196. filedList.add("insuranceplanCode");
  197. filedList.add("insuranceplan");
  198. filedList.add("insuranceplanId");
  199. filedList.add("individualIncomeTax");
  200. filedList.add("individualIncomeTaxCode");
  201. filedList.add("individualIncomeTaxId");
  202. filedList.add("housingfund");
  203. filedList.add("housingfundCode");
  204. filedList.add("housingfundId");
  205. filedList.add("medicalCode");
  206. filedList.add("medicalId");
  207. filedList.add("medical");
  208. filedList.add("socialinsurance");
  209. filedList.add("socialinsuranceCode");
  210. filedList.add("socialinsuranceId");
  211. filedList.add("subsidyId");
  212. filedList.add("subsidyCode");
  213. filedList.add("subsidyamount");
  214. filedList.add("weekendOTPaymentId");
  215. filedList.add("weekendOTPaymentCode");
  216. filedList.add("weekendOTPayment");
  217. filedList.add("workdayOTPaymentCode");
  218. filedList.add("workdayOTPaymentId");
  219. filedList.add("workdayOTPayment");
  220. filedList.add("allowanceCode");
  221. filedList.add("allowanceId");
  222. filedList.add("allowancecmount");
  223. filedList.add("settlementcyle");
  224. filedList.add("Nationalits");
  225. filedList.add("cuueryName");
  226. filedList.add("currencyId");
  227. filedList.add("MonthlysalaryCode");
  228. filedList.add("GrossWageCode");
  229. filedList.add("PaymentbeforeCode");
  230. filedList.add("grossincomeCode");
  231. filedList.add("ServiceTaxCode");
  232. filedList.add("YTDtaxCode");
  233. filedList.add("netpaymentCode");
  234. filedList.add("HourlyRateCode");
  235. filedList.add("WorkingHoursCode");
  236. filedList.add("AttendanceCode");
  237. filedList.add("department");
  238. filedList.add("peronid");
  239. filedList.add("Attendancecount");
  240. filedList.add("WorkingHourscount");
  241. filedList.add("WorkingHours");
  242. filedList.add("HourlyRateamount");
  243. filedList.add("HourlyRate");
  244. filedList.add("netpaymentamount");
  245. filedList.add("YTDnetpayment");
  246. filedList.add("YTDtaxamount");
  247. filedList.add("YTDtax");
  248. filedList.add("grossincome");
  249. filedList.add("ytdgrossincome");
  250. filedList.add("ServiceTaxamount");
  251. filedList.add("ServiceTax");
  252. filedList.add("beforeamcount");
  253. filedList.add("PaymentbeforeTax");
  254. filedList.add("grossamount");
  255. filedList.add("GrossWage");
  256. filedList.add("amount");
  257. filedList.add("Monthlysalary");
  258. filedList.add("Nationali");
  259. filedList.add("Attendancedays");
  260. // 将list元素都转换成小写
  261. List<String> lowerCaseList = filedList.stream().map(String::toLowerCase).collect(Collectors.toList());
  262. return lowerCaseList;
  263. }
  264. }