UserWageController.java 82 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988
  1. package cn.com.lzt.userwage.controller;
  2. import cn.com.lzt.arrangeduty.dto.ProjectDepartDto;
  3. import cn.com.lzt.common.dto.VisibleUserDto;
  4. import cn.com.lzt.common.service.DataPermissionServiceI;
  5. import cn.com.lzt.common.util.UserUtil;
  6. import cn.com.lzt.dialogDeal.service.UserDepartOrgDealServiceI;
  7. import cn.com.lzt.dingattendanceinfo.entity.DingAttendanceinfoEntity;
  8. import cn.com.lzt.useroptions.entity.TBusUserOptionsEntity;
  9. import cn.com.lzt.useroptions.service.TBusUserOptionsServiceI;
  10. import cn.com.lzt.userwage.dto.UserWageDetaillsDto;
  11. import cn.com.lzt.userwage.dto.UserWageDto;
  12. import cn.com.lzt.userwage.dto.UserWagePaperDto;
  13. import cn.com.lzt.userwage.dto.UserWageViewDto;
  14. import cn.com.lzt.userwage.entity.UserWageEntity;
  15. import cn.com.lzt.userwage.entity.UserwagePage;
  16. import cn.com.lzt.userwage.service.UserWageServiceI;
  17. import cn.com.lzt.userwagestrategyhistory.entity.UserWagestrategyHistoryEntity;
  18. import org.apache.commons.collections.CollectionUtils;
  19. import org.apache.commons.lang.StringUtils;
  20. import org.apache.ibatis.annotations.Param;
  21. import org.apache.log4j.Logger;
  22. import org.apache.poi.hssf.usermodel.HSSFWorkbook;
  23. import org.apache.poi.ss.usermodel.Workbook;
  24. import org.jeecgframework.core.beanvalidator.BeanValidators;
  25. import org.jeecgframework.core.common.controller.BaseController;
  26. import org.jeecgframework.core.common.exception.BusinessException;
  27. import org.jeecgframework.core.common.model.json.AjaxJson;
  28. import org.jeecgframework.core.common.model.json.DataGrid;
  29. import org.jeecgframework.core.constant.Globals;
  30. import org.jeecgframework.core.util.*;
  31. import org.jeecgframework.minidao.pojo.MiniDaoPage;
  32. import org.jeecgframework.poi.excel.ExcelExportUtil;
  33. import org.jeecgframework.poi.excel.ExcelImportUtil;
  34. import org.jeecgframework.poi.excel.annotation.Excel;
  35. import org.jeecgframework.poi.excel.entity.ExportParams;
  36. import org.jeecgframework.poi.excel.entity.ImportParams;
  37. import org.jeecgframework.poi.excel.entity.params.ExcelExportEntity;
  38. import org.jeecgframework.poi.excel.entity.vo.NormalExcelConstants;
  39. import org.jeecgframework.tag.core.easyui.TagUtil;
  40. import org.jeecgframework.web.system.pojo.base.TSBaseUser;
  41. import org.jeecgframework.web.system.pojo.base.TSDepart;
  42. import org.jeecgframework.web.system.pojo.base.TSUser;
  43. import org.jeecgframework.web.system.pojo.base.TSUserOrg;
  44. import org.jeecgframework.web.system.service.SystemService;
  45. import org.springframework.beans.factory.annotation.Autowired;
  46. import org.springframework.http.HttpHeaders;
  47. import org.springframework.http.HttpStatus;
  48. import org.springframework.http.MediaType;
  49. import org.springframework.http.ResponseEntity;
  50. import org.springframework.stereotype.Controller;
  51. import org.springframework.ui.ModelMap;
  52. import org.springframework.web.bind.annotation.*;
  53. import org.springframework.web.multipart.MultipartFile;
  54. import org.springframework.web.multipart.MultipartHttpServletRequest;
  55. import org.springframework.web.servlet.ModelAndView;
  56. import org.springframework.web.util.UriComponentsBuilder;
  57. import javax.servlet.ServletOutputStream;
  58. import javax.servlet.http.HttpServletRequest;
  59. import javax.servlet.http.HttpServletResponse;
  60. import javax.servlet.http.HttpSession;
  61. import javax.validation.ConstraintViolation;
  62. import javax.validation.Validator;
  63. import java.beans.PropertyDescriptor;
  64. import java.io.IOException;
  65. import java.io.UnsupportedEncodingException;
  66. import java.lang.reflect.Field;
  67. import java.lang.reflect.InvocationTargetException;
  68. import java.lang.reflect.Method;
  69. import java.math.BigDecimal;
  70. import java.net.URI;
  71. import java.text.ParseException;
  72. import java.util.*;
  73. /**
  74. * @Title: Controller
  75. * @Description: 员工工资核算表
  76. * @author onlineGenerator
  77. * @date 2017-10-26 18:36:30
  78. * @version V1.0
  79. *
  80. */
  81. @Controller
  82. @RequestMapping("/userWageController")
  83. public class UserWageController extends BaseController {
  84. /**
  85. * Logger for this class
  86. */
  87. private static final Logger logger = Logger.getLogger(UserWageController.class);
  88. @Autowired
  89. private UserWageServiceI userWageService;
  90. @Autowired
  91. private SystemService systemService;
  92. @Autowired
  93. private Validator validator;
  94. @Autowired
  95. private DataPermissionServiceI dataPermissionService;
  96. @Autowired
  97. private UserDepartOrgDealServiceI userDepartOrgDealService;
  98. @Autowired
  99. private TBusUserOptionsServiceI userOptionsService;
  100. /**
  101. * 得到上个月的年月
  102. * @return
  103. */
  104. private String getMonthlys(){
  105. Calendar cal = Calendar.getInstance();
  106. int year = cal.get(Calendar.YEAR);
  107. int month = cal.get(Calendar.MONTH);
  108. if(month < 10){
  109. if(month == 0){
  110. year = year - 1;
  111. month = 12;
  112. }else{
  113. // month = Integer.valueOf(0+""+month);
  114. return year + "-" + 0 + "" + month;
  115. }
  116. }
  117. return year+"-"+month;
  118. }
  119. /**
  120. * 员工工资核算表列表 页面跳转
  121. *
  122. * @return
  123. */
  124. @RequestMapping(params = "list")
  125. public ModelAndView list(HttpServletRequest request) {
  126. HttpSession session = ContextHolderUtils.getSession();
  127. TSUser tuser = (TSUser)session.getAttribute("LOCAL_CLINET_USER");
  128. String departid = "";
  129. String departname = "";
  130. try {
  131. TBusUserOptionsEntity options = userOptionsService.getOptionsByUserID(tuser.getId(), Globals.USER_OPTIONS_TYPE_PROJECT, false);
  132. if(options != null) {
  133. departid = options.getOptionId();
  134. departname = options.getOptionName();
  135. }
  136. } catch (Exception e) {
  137. e.printStackTrace();
  138. org.jeecgframework.core.util.LogUtil.error(e.getMessage());
  139. }
  140. if (oConvertUtils.isNotEmpty(departid)) {
  141. request.setAttribute("departid", departid);
  142. request.setAttribute("departname", departname);
  143. }
  144. request.setAttribute("monthlys", getMonthlys());
  145. return new ModelAndView("cn/com/lzt/userwage/userWageList");
  146. }
  147. /**
  148. * 员工工资核算表列表 页面跳转
  149. *
  150. * @return
  151. */
  152. @RequestMapping(params = "listView")
  153. public ModelAndView listView(HttpServletRequest request) {
  154. String orgid = request.getParameter("orgid");
  155. String monthly = request.getParameter("monthly");
  156. if(oConvertUtils.isNotEmpty(monthly)){
  157. request.setAttribute("monthlys", monthly);
  158. request.setAttribute("orgid", orgid);
  159. }else{
  160. request.setAttribute("monthlys", getMonthlys());
  161. }
  162. return new ModelAndView("cn/com/lzt/userwage/userWageViewList");
  163. }
  164. @RequestMapping(params = "logrp")
  165. public ModelAndView logrp(@Param("id") String id,HttpServletRequest request){
  166. if(StringUtils.isNotEmpty(id)){
  167. UserWageEntity userWage = systemService.get(UserWageEntity.class, id);
  168. TSBaseUser tsBaseUser = systemService.get(TSBaseUser.class, userWage.getUserid());
  169. request.setAttribute("realname", tsBaseUser.getRealName());
  170. if(userWage != null){
  171. //systemService.get
  172. StringBuffer hql = new StringBuffer("from UserWagestrategyHistoryEntity where userid =? and strategyMonth = ? ");
  173. List<UserWagestrategyHistoryEntity> userList = systemService.findHql(hql.toString(),userWage.getUserid(),userWage.getMonthly());
  174. //List<UserWagestrategyHistoryEntity> userList = systemService.findListbySql("select * from t_bus_user_wagestrategy_history where userid = '"+userWage.getUserid()+"' and strategy_month = '"+userWage.getMonthly()+"'");
  175. if(!userList.isEmpty() && userList.size() > 0){
  176. // System.out.println(JSONObject.toJSONString(userList.get(0)));
  177. request.setAttribute("userwh", userList.get(0));
  178. }else{
  179. request.setAttribute("userwh",new UserWagestrategyHistoryEntity());
  180. }
  181. }
  182. }
  183. return new ModelAndView("cn/com/lzt/userwage/userwagestrategy-view");
  184. }
  185. @RequestMapping(params = "goview")
  186. public ModelAndView goView(@Param("belongUnitname") String belongUnitname,@Param("id") String id,@Param("monthly")String monthly,@Param("type")String type, HttpServletRequest request){
  187. request.setAttribute("id", id);
  188. TSDepart depart = systemService.get(TSDepart.class, id);
  189. if(depart != null) {
  190. request.setAttribute("belongUnitname",depart.getDepartname());
  191. }
  192. request.setAttribute("monthly", monthly);
  193. request.setAttribute("monthlys",monthly);
  194. request.setAttribute("type",type);
  195. return new ModelAndView("cn/com/lzt/userwage/userWageEditList");
  196. }
  197. /**
  198. * 直接打开工资编辑
  199. * @param belongUnitname
  200. * @param id
  201. * @param monthly
  202. * @param type
  203. * @param request
  204. * @return
  205. */
  206. @RequestMapping(params = "editList")
  207. public ModelAndView editList(@Param("belongUnitname") String belongUnitname,@Param("id") String id,@Param("monthly")String monthly,@Param("type")String type, HttpServletRequest request){
  208. // request.setAttribute("id", id);
  209. // TSDepart depart = systemService.get(TSDepart.class, id);
  210. // if(depart != null) {
  211. // request.setAttribute("belongUnitname",depart.getDepartname());
  212. // }
  213. // request.setAttribute("monthly", monthly);
  214. // request.setAttribute("monthlys",monthly);
  215. // request.setAttribute("type",type);
  216. return new ModelAndView("cn/com/lzt/userwage/userWageEditList");
  217. }
  218. /**
  219. * 所有项目(部门)选择弹窗页面跳转路径
  220. * 列表页弹窗
  221. * @author liujie
  222. * 2017-12-13
  223. * @param request
  224. * @return
  225. */
  226. @RequestMapping(params = "projectDepartTableAll")
  227. public ModelAndView projectDepartTableAll(HttpServletRequest request) {
  228. //return new ModelAndView("cn/com/lzt/arrangeduty/dutyMealTable");
  229. ModelAndView mv = new ModelAndView("cn/com/lzt/userwage/projectDepartTableAll");
  230. String ids = oConvertUtils.getString(request.getParameter("ids"));
  231. mv.addObject("ids", ids);
  232. return mv;
  233. }
  234. /**
  235. * 项目(部门)选择弹窗列表数据
  236. * @author liujie
  237. * 2017-11-15
  238. * @param projectDepartDto
  239. * @param request
  240. * @param response
  241. * @param dataGrid
  242. */
  243. @RequestMapping(params = "projectDepartDatagridAll")
  244. public void projectDepartDatagridAll(ProjectDepartDto projectDepartDto, HttpServletRequest request, HttpServletResponse response, DataGrid dataGrid) {
  245. TSUser tSUser=ResourceUtil.getSessionUser();
  246. List<ProjectDepartDto> projectDepartDtoList=userWageService.getProjectDepartAll(projectDepartDto,tSUser.getId());
  247. dataGrid.setResults(projectDepartDtoList);
  248. TagUtil.datagrid(response, dataGrid);
  249. }
  250. /**
  251. * 员工工资核算表列表 页面跳转
  252. *
  253. * @return
  254. */
  255. @RequestMapping(params = "listDetails")
  256. public ModelAndView listDetails(@Param("realname") String realname,@Param("belongBank") String belongBank,@Param("pid") String pid,@Param("monthly")String monthly,HttpServletRequest request) {
  257. request.setAttribute("monthlys", getMonthlys());
  258. request.setAttribute("monthly", monthly);
  259. request.setAttribute("orgid", pid);
  260. request.setAttribute("realname", realname);
  261. request.setAttribute("belongBank", belongBank);
  262. return new ModelAndView("cn/com/lzt/userwage/userWageDetailsList");
  263. }
  264. /**
  265. * 员工月度工资明细表格
  266. *
  267. * @param request
  268. * @param response
  269. * @param dataGrid
  270. * @throws ParseException
  271. */
  272. @RequestMapping(params = "datagrid")
  273. public void datagrid(UserWageDto userWage,HttpServletRequest request, HttpServletResponse response, DataGrid dataGrid) throws ParseException {
  274. String monthlys = request.getParameter("monthlys");
  275. String monthly = request.getParameter("monthly");
  276. String realname = request.getParameter("realname");
  277. String belongBank = request.getParameter("belongBank");
  278. String orgIds = request.getParameter("orgIds");
  279. String orgId = request.getParameter("orgid");
  280. String type = request.getParameter("type");
  281. if(oConvertUtils.isEmpty(monthlys) && oConvertUtils.isEmpty(monthly)){
  282. dataGrid.setResults(new ArrayList<UserWageDto>());
  283. dataGrid.setFooter("");
  284. TagUtil.datagrid(response, dataGrid);
  285. return;
  286. }
  287. // if(oConvertUtils.isEmpty(orgIds) && oConvertUtils.isEmpty(orgIds)){
  288. // dataGrid.setResults(new ArrayList<UserWageDto>());
  289. // dataGrid.setFooter("");
  290. // TagUtil.datagrid(response, dataGrid);
  291. // return;
  292. // }
  293. if(realname != null) {
  294. userWage.setRealname(realname);
  295. }
  296. if(belongBank != null) {
  297. userWage.setBelongBank(belongBank);
  298. }
  299. MiniDaoPage<UserWageDto> list = null;
  300. if(oConvertUtils.isNotEmpty(monthlys) || oConvertUtils.isNotEmpty(monthly)){
  301. if(StringUtils.isEmpty(orgIds)&&StringUtils.isNotEmpty(orgId)){
  302. List<String> orgIdList = extractIdListByComma(orgId);
  303. // 获取 当前组织机构的用户信息
  304. if (!CollectionUtils.isEmpty(orgIdList)) {
  305. if(oConvertUtils.isNotEmpty(type) && "1".equals(type)){
  306. userWage.setOrgIdList(orgIdList);
  307. }else{
  308. String or = orgIdList.get(0);
  309. List<String> ChildIdList = userDepartOrgDealService.getChildIdByProjectDepartId(or);
  310. userWage.setOrgIdList(ChildIdList);
  311. }
  312. }
  313. }else{
  314. if(StringUtils.isNotEmpty(orgIds)){
  315. List<String> orgIdList = extractIdListByComma(orgIds);
  316. // 获取 当前组织机构的用户信息
  317. if (!CollectionUtils.isEmpty(orgIdList)) {
  318. String or = orgIdList.get(0);
  319. List<String> ChildIdList = userDepartOrgDealService.getChildIdByProjectDepartId(or);
  320. userWage.setOrgIdList(ChildIdList);
  321. }
  322. }
  323. }
  324. if(StringUtils.isNotEmpty(monthlys)){
  325. userWage.setMonthly(monthlys);
  326. }else{
  327. if(StringUtils.isNotEmpty(monthly)){
  328. request.setAttribute("monthlys", monthly);
  329. userWage.setMonthly(monthly);
  330. }else{
  331. request.setAttribute("monthlys", getMonthlys());
  332. userWage.setMonthly(getMonthlys());
  333. }
  334. //userWage.setMonthly(sim.format(sim.parse("2017-10")));
  335. }
  336. String authSql = JeecgDataAutorUtils.loadDataSearchConditonSQLString();
  337. VisibleUserDto dto = dataPermissionService.getVisibleUserList();// 获取当前用户可见的userid列表
  338. if(dto != null){
  339. if(dto.getFlag().value().equalsIgnoreCase("ALL")){
  340. list = userWageService.getPagedEntities(userWage,null,null,dataGrid.getPage(), dataGrid.getRows(), authSql);
  341. // map = userWageService.getMoneySUM(userWage,null,moth);
  342. }else if(dto.getFlag().value().equalsIgnoreCase("NONE")){
  343. // 获取当前登录用户
  344. HttpSession session = ContextHolderUtils.getSession();
  345. TSUser user = (TSUser)session.getAttribute("LOCAL_CLINET_USER");
  346. List<String> uidList = new ArrayList<String>();
  347. uidList.add(user.getId());
  348. list = userWageService.getPagedEntities(userWage,uidList,null,dataGrid.getPage(), dataGrid.getRows(), authSql);
  349. // map = userWageService.getMoneySUM(userWage,uidList,moth);
  350. }else if(dto.getFlag().value().equalsIgnoreCase("PART")){
  351. List<String> useridList = dto.getUseridList();
  352. if(useridList != null && useridList.size() > 0){
  353. list = userWageService.getPagedEntities(userWage,useridList,null,dataGrid.getPage(), dataGrid.getRows(), authSql);
  354. // map = userWageService.getMoneySUM(userWage,useridList,moth);
  355. }
  356. }
  357. }
  358. // 为了提高效率,人事部门不做工资权限限制. 20170628 xzx
  359. // UserWageDto> list = userWageService.getAll(userWage,authSql);
  360. if(list != null && !list.getResults().isEmpty()){
  361. for (Iterator iterator = list.getResults().iterator(); iterator.hasNext();) {
  362. UserWageDto userWageDto = (UserWageDto) iterator.next();
  363. if (oConvertUtils.isEmpty(userWageDto.getId())) {
  364. userWageDto.setId("temp"+UUIDGenerator.generate());
  365. }
  366. if(StringUtils.isNotEmpty(userWage.getStatus())){
  367. if(StringUtils.isEmpty(userWageDto.getMonthly())){
  368. iterator.remove();
  369. }
  370. }
  371. if(StringUtils.isEmpty(userWageDto.getMonthly())){
  372. userWageDto.setBelongUnitName(getBybelongId(userWageDto.getUserids()));
  373. }
  374. }
  375. Collections.sort(list.getResults());
  376. dataGrid.setResults(list.getResults());
  377. dataGrid.setTotal(list.getTotal());
  378. }
  379. // List<UserWageDto> list = new ArrayList<UserWageDto>();
  380. // Map<String,Integer> map = new HashMap<String,Integer>();
  381. // if(dto.getFlag().value().equalsIgnoreCase("ALL")){
  382. // list = userWageService.getAllEntities(userWage,null,null,authSql);
  383. // map = userWageService.getMoneySUM(userWage,null,null);
  384. // }else if(dto.getFlag().value().equalsIgnoreCase("NONE")){
  385. // // 获取当前登录用户
  386. // HttpSession session = ContextHolderUtils.getSession();
  387. // TSUser user = (TSUser)session.getAttribute("LOCAL_CLINET_USER");
  388. // List<String> uidList = new ArrayList<String>();
  389. // uidList.add(user.getId());
  390. // list = userWageService.getAllEntities(userWage,uidList,null,authSql);
  391. // map = userWageService.getMoneySUM(userWage,uidList,null);
  392. // }else if(dto.getFlag().value().equalsIgnoreCase("PART")){
  393. // List<String> useridList = dto.getUseridList();
  394. // if(useridList != null && useridList.size() > 0){
  395. // list = userWageService.getAllEntities(userWage,useridList,null,authSql);
  396. // map = userWageService.getMoneySUM(userWage,useridList,null);
  397. // }
  398. // }
  399. Map<String,BigDecimal> map = new HashMap<String,BigDecimal>();
  400. //代码层计算合计,不通过sql计算
  401. try {
  402. calcuSumMap(map,list.getResults());
  403. } catch (Exception e) {
  404. e.printStackTrace();
  405. }
  406. StringBuffer str = new StringBuffer();
  407. for(String key : map.keySet()) {
  408. String value = map.get(key) == null ? "0.00" : map.get(key).toString();
  409. str.append(key).append(":").append(value).append(",");
  410. }
  411. // //List<UserWageDto> list = userWageService.getAllEntities(userWage,authSql);
  412. // dataGrid.setResults(list);
  413. // //Map<String,Integer> map = userWageService.getMoneySUM(userWage,null);
  414. //
  415. // StringBuffer str = new StringBuffer();
  416. // str.append("basicWage:"+(String.valueOf(map.get("basic_wage")).equalsIgnoreCase("null")?"0.00":String.valueOf(map.get("basic_wage")))+",");
  417. // str.append("dutiesAllowance:"+(String.valueOf(map.get("duties_allowance")).equalsIgnoreCase("null")?"0.00":String.valueOf(map.get("duties_allowance")))+",");
  418. // str.append("certificateSubsidy:"+(String.valueOf(map.get("certificate_subsidy")).equalsIgnoreCase("null")?"0.00":String.valueOf(map.get("certificate_subsidy")))+",");
  419. // str.append("trafficSubsidy:"+(String.valueOf(map.get("traffic_subsidy")).equalsIgnoreCase("null")?"0.00":String.valueOf(map.get("traffic_subsidy")))+",");
  420. // str.append("megathermalSubsidy:"+(String.valueOf(map.get("megathermal_subsidy")).equalsIgnoreCase("null")?"0.00":String.valueOf(map.get("megathermal_subsidy")))+",");
  421. // str.append("onlyChildCost:"+(String.valueOf(map.get("only_child_cost")).equalsIgnoreCase("null")?"0.00":String.valueOf(map.get("only_child_cost")))+",");
  422. // str.append("otherSubsidy:"+(String.valueOf(map.get("other_subsidy")).equalsIgnoreCase("null")?"0.00":String.valueOf(map.get("other_subsidy")))+",");
  423. // str.append("bonus:"+(String.valueOf(map.get("bonus")).equalsIgnoreCase("null")?"0.00":String.valueOf(map.get("bonus")))+",");
  424. // str.append("projectPerformance:"+(String.valueOf(map.get("project_performance")).equalsIgnoreCase("null")?"0.00":String.valueOf(map.get("project_performance")))+",");
  425. // str.append("mealsSubsidyDay:"+(String.valueOf(map.get("meals_subsidy_day")).equalsIgnoreCase("null")?"0.00":String.valueOf(map.get("meals_subsidy_day")))+",");
  426. // str.append("mealsSubsidyNight:"+(String.valueOf(map.get("meals_subsidy_night")).equalsIgnoreCase("null")?"0.00":String.valueOf(map.get("meals_subsidy_night")))+",");
  427. // str.append("mealsSubsidy:"+(String.valueOf(map.get("meals_subsidy")).equalsIgnoreCase("null")?"0.00":String.valueOf(map.get("meals_subsidy")))+",");
  428. // str.append("overtimepayTimeout:"+(String.valueOf(map.get("overtimepay_timeout")).equalsIgnoreCase("null")?"0.00":String.valueOf(map.get("overtimepay_timeout")))+",");
  429. // str.append("overtimepayFixed:"+(String.valueOf(map.get("overtimepay_fixed")).equalsIgnoreCase("null")?"0.00":String.valueOf(map.get("overtimepay_fixed")))+",");
  430. // str.append("duty:"+(String.valueOf(map.get("duty")).equalsIgnoreCase("null")?"0.00":String.valueOf(map.get("duty")))+",");
  431. // str.append("specialOvertime:"+(String.valueOf(map.get("special_overtime")).equalsIgnoreCase("null")?"0.00":String.valueOf(map.get("special_overtime")))+",");
  432. // str.append("sickLeaveDebit:"+(String.valueOf(map.get("sick_leave_debit")).equalsIgnoreCase("null")?"0.00":String.valueOf(map.get("sick_leave_debit")))+",");
  433. // str.append("thingLeaveDebit:"+(String.valueOf(map.get("thing_leave_debit")).equalsIgnoreCase("null")?"0.00":String.valueOf(map.get("thing_leave_debit")))+",");
  434. // str.append("absenceDebit:"+(String.valueOf(map.get("absence_debit")).equalsIgnoreCase("null")?"0.00":String.valueOf(map.get("absence_debit")))+",");
  435. // str.append("paymentSubsidy:"+(String.valueOf(map.get("payment_subsidy")).equalsIgnoreCase("null")?"0.00":String.valueOf(map.get("payment_subsidy")))+",");
  436. // str.append("socialSecurityDebit:"+(String.valueOf(map.get("social_security_debit")).equalsIgnoreCase("null")?"0.00":String.valueOf(map.get("social_security_debit")))+",");
  437. // str.append("providentFundDebit:"+(String.valueOf(map.get("provident_fund_debit")).equalsIgnoreCase("null")?"0.00":String.valueOf(map.get("provident_fund_debit")))+",");
  438. // str.append("preTaxMone:"+(String.valueOf(map.get("pre_tax_mone")).equalsIgnoreCase("null")?"0.00":String.valueOf(map.get("pre_tax_mone")))+",");
  439. // str.append("otherDebit:"+(String.valueOf(map.get("other_debit")).equalsIgnoreCase("null")?"0.00":String.valueOf(map.get("other_debit")))+",");
  440. // str.append("reissue:"+(String.valueOf(map.get("reissue")).equalsIgnoreCase("null")?"0.00":String.valueOf(map.get("reissue")))+",");
  441. // str.append("taxMoney:"+(String.valueOf(map.get("tax_money")).equalsIgnoreCase("null")?"0.00":String.valueOf(map.get("tax_money")))+",");
  442. // str.append("actualMoney:"+(String.valueOf(map.get("actual_money")).equalsIgnoreCase("null")?"0.00":String.valueOf(map.get("actual_money"))));
  443. // dataGrid.setFooter(str.toString());
  444. // }
  445. dataGrid.setFooter(str.toString());
  446. }
  447. if(list == null || list.getResults() == null || list.getResults().size() == 0){
  448. dataGrid.setResults(new ArrayList<UserWageDto>());
  449. dataGrid.setFooter("");
  450. }
  451. TagUtil.datagrid(response, dataGrid);
  452. }
  453. /**
  454. * 月度工资一览的表格数据
  455. *
  456. * @param request
  457. * @param response
  458. * @param dataGrid
  459. */
  460. @RequestMapping(params = "datagrid1")
  461. public void datagrid1(UserWageViewDto userWage,HttpServletRequest request, HttpServletResponse response, DataGrid dataGrid) {
  462. String monthlys = request.getParameter("monthlys");
  463. if(oConvertUtils.isNotEmpty(monthlys)){
  464. String orgIds = request.getParameter("orgIds");
  465. List<String> orgIdList = extractIdListByComma(orgIds);
  466. // 获取 当前组织机构的用户信息
  467. if (!CollectionUtils.isEmpty(orgIdList)) {
  468. String or = orgIdList.get(0);
  469. List<String> ChildIdList = userDepartOrgDealService.getChildIdByProjectDepartId(or);
  470. userWage.setOrgIdList(ChildIdList);
  471. }
  472. userWage.setMonthly(monthlys);
  473. String authSql = JeecgDataAutorUtils.loadDataSearchConditonSQLString();
  474. VisibleUserDto dto = dataPermissionService.getVisibleUserList();// 获取当前用户可见的userid列表
  475. if(dto != null){
  476. MiniDaoPage<UserWageViewDto> list = new MiniDaoPage<UserWageViewDto>();
  477. Map<String,Integer> map = new HashMap<String,Integer>();
  478. list = userWageService.getViewEntities(userWage,null,dataGrid.getPage(), dataGrid.getRows(), authSql);
  479. map = userWageService.getMoneyViewSUM(userWage,null);
  480. // if(dto.getFlag().value().equalsIgnoreCase("ALL")){
  481. // list = userWageService.getViewEntities(userWage,null,dataGrid.getPage(), dataGrid.getRows(), authSql);
  482. // map = userWageService.getMoneyViewSUM(userWage,null);
  483. // }else if(dto.getFlag().value().equalsIgnoreCase("NONE")){
  484. // // 获取当前登录用户
  485. // HttpSession session = ContextHolderUtils.getSession();
  486. // TSUser user = (TSUser)session.getAttribute("LOCAL_CLINET_USER");
  487. // List<String> uidList = new ArrayList<String>();
  488. // uidList.add(user.getId());
  489. // list = userWageService.getViewEntities(userWage,uidList,dataGrid.getPage(), dataGrid.getRows(), authSql);
  490. // map = userWageService.getMoneyViewSUM(userWage,uidList);
  491. // }else if(dto.getFlag().value().equalsIgnoreCase("PART")){
  492. // List<String> useridList = dto.getUseridList();
  493. // if(useridList != null && useridList.size() > 0){
  494. // list = userWageService.getViewEntities(userWage,useridList,dataGrid.getPage(), dataGrid.getRows(), authSql);
  495. // map = userWageService.getMoneyViewSUM(userWage,useridList);
  496. // }
  497. // }
  498. //MiniDaoPage<UserWageViewDto> list = userWageService.getViewEntities(userWage, dataGrid.getPage(), dataGrid.getRows(), authSql);
  499. dataGrid.setResults(list.getResults());
  500. //Map<String,Integer> map = userWageService.getMoneyViewSUM(userWage);
  501. StringBuffer str = new StringBuffer();
  502. str.append("sumcount:"+(String.valueOf(map.get("sumcount")).equalsIgnoreCase("null")?"0.00":String.valueOf(map.get("sumcount")))+",");
  503. str.append("basicWage:"+(String.valueOf(map.get("basic_wage")).equalsIgnoreCase("null")?"0.00":String.valueOf(map.get("basic_wage")))+",");
  504. str.append("dutiesAllowance:"+(String.valueOf(map.get("duties_allowance")).equalsIgnoreCase("null")?"0.00":String.valueOf(map.get("duties_allowance")))+",");
  505. str.append("certificateSubsidy:"+(String.valueOf(map.get("certificate_subsidy")).equalsIgnoreCase("null")?"0.00":String.valueOf(map.get("certificate_subsidy")))+",");
  506. str.append("projectPerformance:"+(String.valueOf(map.get("project_performance")).equalsIgnoreCase("null")?"0.00":String.valueOf(map.get("project_performance")))+",");
  507. str.append("mealsSubsidy:"+(String.valueOf(map.get("meals_subsidy")).equalsIgnoreCase("null")?"0.00":String.valueOf(map.get("meals_subsidy")))+",");
  508. str.append("specialOvertime:"+(String.valueOf(map.get("special_overtime")).equalsIgnoreCase("null")?"0.00":String.valueOf(map.get("special_overtime")))+",");
  509. str.append("absenceDebit:"+(String.valueOf(map.get("absence_debit")).equalsIgnoreCase("null")?"0.00":String.valueOf(map.get("absence_debit")))+",");
  510. str.append("paymentSubsidy:"+(String.valueOf(map.get("payment_subsidy")).equalsIgnoreCase("null")?"0.00":String.valueOf(map.get("payment_subsidy")))+",");
  511. str.append("deductions:"+(String.valueOf(map.get("deductions")).equalsIgnoreCase("null")?"0.00":String.valueOf(map.get("deductions")))+",");
  512. str.append("comDeductions:"+(String.valueOf(map.get("comDeductions")).equalsIgnoreCase("null")?"0.00":String.valueOf(map.get("comDeductions")))+",");
  513. str.append("comCost:"+(String.valueOf(map.get("comCost")).equalsIgnoreCase("null")?"0.00":String.valueOf(map.get("comCost")))+",");
  514. str.append("preTaxMone:"+(String.valueOf(map.get("pre_tax_mone")).equalsIgnoreCase("null")?"0.00":String.valueOf(map.get("pre_tax_mone")))+",");
  515. str.append("daikouDebit:"+(String.valueOf(map.get("daikouDebit")).equalsIgnoreCase("null")?"0.00":String.valueOf(map.get("daikouDebit")))+",");
  516. str.append("otherDebit:"+(String.valueOf(map.get("other_debit")).equalsIgnoreCase("null")?"0.00":String.valueOf(map.get("other_debit")))+",");
  517. str.append("reissue:"+(String.valueOf(map.get("reissue")).equalsIgnoreCase("null")?"0.00":String.valueOf(map.get("reissue")))+",");
  518. str.append("taxMoney:"+(String.valueOf(map.get("tax_money")).equalsIgnoreCase("null")?"0.00":String.valueOf(map.get("tax_money")))+",");
  519. str.append("actualMoney:"+(String.valueOf(map.get("actual_money")).equalsIgnoreCase("null")?"0.00":String.valueOf(map.get("actual_money"))));
  520. dataGrid.setFooter(str.toString());
  521. }
  522. }else{
  523. dataGrid.setResults(new ArrayList<UserWageViewDto>());
  524. dataGrid.setFooter("");
  525. }
  526. TagUtil.datagrid(response, dataGrid);
  527. }
  528. /**
  529. * easyui AJAX请求数据
  530. *
  531. * @param request
  532. * @param response
  533. * @param dataGrid
  534. * @throws ParseException
  535. */
  536. @RequestMapping(params = "datagrid2")
  537. public void datagrid2(UserWageDto userWage,HttpServletRequest request, HttpServletResponse response, DataGrid dataGrid) throws ParseException {
  538. String monthlys = request.getParameter("monthlys");
  539. if(StringUtils.isNotEmpty(monthlys)){
  540. String orgIds = request.getParameter("orgIds");
  541. if(StringUtils.isNotEmpty(orgIds)){
  542. List<String> orgIdList = extractIdListByComma(orgIds);
  543. // 获取 当前组织机构的用户信息
  544. if (!CollectionUtils.isEmpty(orgIdList)) {
  545. String or = orgIdList.get(0);
  546. List<String> ChildIdList = userDepartOrgDealService.getChildIdByProjectDepartId(or);
  547. if(!ChildIdList.isEmpty()){
  548. List<String> ch = new ArrayList<String>();
  549. for (String str : ChildIdList) {
  550. ch.add(str);
  551. }
  552. ChildIdList = ch;
  553. }
  554. userWage.setOrgIdList(ChildIdList);
  555. }
  556. if(orgIdList != null && orgIdList.size()>0 && orgIdList.get(0)!=null &&orgIdList.get(0).length()>0) {
  557. }
  558. HttpSession session = ContextHolderUtils.getSession();
  559. TSUser tuser = (TSUser)session.getAttribute("LOCAL_CLINET_USER");
  560. try {
  561. userOptionsService.saveUserOptions(tuser.getId(), orgIdList.get(0), Globals.USER_OPTIONS_TYPE_PROJECT);
  562. } catch (Exception e) {
  563. e.printStackTrace();
  564. org.jeecgframework.core.util.LogUtil.error(e.getMessage());
  565. }
  566. }/*else{
  567. TSUser tSUser=ResourceUtil.getSessionUser();
  568. StringBuffer hql = new StringBuffer("from TSUserOrg where tsUser.id = :userid and status=0");
  569. List<TSUserOrg> tsList = systemService.getSession().createQuery(hql.toString()).setParameter("userid", tSUser.getId()).list();
  570. if(!tsList.isEmpty()){
  571. for (TSUserOrg tsUserOrg : tsList) {
  572. List<String> ChildIdList = userDepartOrgDealService.getChildIdByProjectDepartId(tsUserOrg.getTsDepart().getId());
  573. if(!ChildIdList.isEmpty()){
  574. List<String> ch = new ArrayList<String>();
  575. for (String str : ChildIdList) {
  576. if(!str.equals(tsUserOrg.getTsDepart().getId())){
  577. ch.add(str);
  578. }
  579. }
  580. ChildIdList = ch;
  581. }
  582. userWage.setOrgIdList(ChildIdList);
  583. }
  584. }
  585. }*/
  586. String moth = "";
  587. String [] mothl = monthlys.split("-");
  588. if("01".equals(mothl[1])){
  589. moth = Integer.valueOf(mothl[0])-1+"-12-01 00:00:00";
  590. }else{
  591. //moth = mothl[0]+"-"+(Integer.valueOf(mothl[1])-1)+"-01 00:00:00";
  592. moth = mothl[0] + "-" + "0" + (Integer.valueOf(mothl[1]) - 1) + "-01 00:00:00";
  593. }
  594. if(StringUtils.isNotEmpty(monthlys)){
  595. userWage.setMonthly(monthlys);
  596. }/*else{
  597. Calendar cal = Calendar.getInstance();
  598. int year = cal.get(Calendar.YEAR);
  599. int month = cal.get(Calendar.MONTH );
  600. if(month < 10){
  601. month = Integer.valueOf(0+""+month);
  602. }
  603. monthlys = year+"-"+month;
  604. request.setAttribute("monthlys", year+"-"+month);
  605. userWage.setMonthly(year+"-"+month);
  606. }*/
  607. String authSql = JeecgDataAutorUtils.loadDataSearchConditonSQLString();
  608. VisibleUserDto dto = dataPermissionService.getVisibleUserList();// 获取当前用户可见的userid列表
  609. if(dto != null){
  610. List<UserWageDto> list = new ArrayList<UserWageDto>();
  611. Map<String,BigDecimal> map = new HashMap<String,BigDecimal>();
  612. if(dto.getFlag().value().equalsIgnoreCase("ALL")){
  613. list = userWageService.getAllEntities(userWage,null,moth,authSql);
  614. // map = userWageService.getMoneySUM(userWage,null,moth);
  615. }else if(dto.getFlag().value().equalsIgnoreCase("NONE")){
  616. // 获取当前登录用户
  617. HttpSession session = ContextHolderUtils.getSession();
  618. TSUser user = (TSUser)session.getAttribute("LOCAL_CLINET_USER");
  619. List<String> uidList = new ArrayList<String>();
  620. uidList.add(user.getId());
  621. list = userWageService.getAllEntities(userWage,uidList,moth,authSql);
  622. // map = userWageService.getMoneySUM(userWage,uidList,moth);
  623. }else if(dto.getFlag().value().equalsIgnoreCase("PART")){
  624. List<String> useridList = dto.getUseridList();
  625. if(useridList != null && useridList.size() > 0){
  626. list = userWageService.getAllEntities(userWage,useridList,moth,authSql);
  627. // map = userWageService.getMoneySUM(userWage,useridList,moth);
  628. }
  629. }
  630. //List<UserWageDto> list = userWageService.getAll(userWage,authSql);
  631. if(!list.isEmpty()){
  632. for (Iterator iterator = list.iterator(); iterator.hasNext();) {
  633. UserWageDto userWageDto = (UserWageDto) iterator.next();
  634. if (oConvertUtils.isEmpty(userWageDto.getId())) {
  635. userWageDto.setId("temp"+UUIDGenerator.generate());
  636. }
  637. if(StringUtils.isNotEmpty(userWage.getStatus())){
  638. if(StringUtils.isEmpty(userWageDto.getMonthly())){
  639. iterator.remove();
  640. }
  641. }
  642. if(StringUtils.isEmpty(userWageDto.getMonthly())){
  643. userWageDto.setBelongUnitName(getBybelongId(userWageDto.getUserids()));
  644. }
  645. }
  646. /*for (UserWageDto us : list) {
  647. }*/
  648. }
  649. Collections.sort(list);
  650. dataGrid.setResults(list);
  651. //代码层计算合计,不通过sql计算
  652. try {
  653. calcuSumMap(map,list);
  654. } catch (Exception e) {
  655. e.printStackTrace();
  656. }
  657. StringBuffer str = new StringBuffer();
  658. for(String key : map.keySet()) {
  659. String value = map.get(key) == null ? "0.00" : map.get(key).toString();
  660. str.append(key).append(":").append(value).append(",");
  661. }
  662. // str.append("basicWage:"+(String.valueOf(map.get("basicWage")).equalsIgnoreCase("null")?"0.00":String.valueOf(map.get("basicWage")))+",");
  663. // str.append("dutiesAllowance:"+(String.valueOf(map.get("dutiesAllowance")).equalsIgnoreCase("null")?"0.00":String.valueOf(map.get("dutiesAllowance")))+",");
  664. // str.append("certificateSubsidy:"+(String.valueOf(map.get("certificateSubsidy")).equalsIgnoreCase("null")?"0.00":String.valueOf(map.get("certificateSubsidy")))+",");
  665. // str.append("trafficSubsidy:"+(String.valueOf(map.get("trafficSubsidy")).equalsIgnoreCase("null")?"0.00":String.valueOf(map.get("trafficSubsidy")))+",");
  666. // str.append("megathermalSubsidy:"+(String.valueOf(map.get("megathermalSubsidy")).equalsIgnoreCase("null")?"0.00":String.valueOf(map.get("megathermalSubsidy")))+",");
  667. // str.append("onlyChildCost:"+(String.valueOf(map.get("onlyChildCost")).equalsIgnoreCase("null")?"0.00":String.valueOf(map.get("onlyChildCost")))+",");
  668. // str.append("otherSubsidy:"+(String.valueOf(map.get("otherSubsidy")).equalsIgnoreCase("null")?"0.00":String.valueOf(map.get("otherSubsidy")))+",");
  669. // str.append("bonus:"+(String.valueOf(map.get("bonus")).equalsIgnoreCase("null")?"0.00":String.valueOf(map.get("bonus")))+",");
  670. // str.append("projectPerformance:"+(String.valueOf(map.get("projectPerformance")).equalsIgnoreCase("null")?"0.00":String.valueOf(map.get("projectPerformance")))+",");
  671. // str.append("mealsSubsidyDay:"+(String.valueOf(map.get("mealsSubsidyDay")).equalsIgnoreCase("null")?"0.00":String.valueOf(map.get("mealsSubsidyDay")))+",");
  672. // str.append("mealsSubsidyNight:"+(String.valueOf(map.get("mealsSubsidyNight")).equalsIgnoreCase("null")?"0.00":String.valueOf(map.get("mealsSubsidyNight")))+",");
  673. // str.append("mealsSubsidy:"+(String.valueOf(map.get("mealsSubsidy")).equalsIgnoreCase("null")?"0.00":String.valueOf(map.get("mealsSubsidy")))+",");
  674. // str.append("overtimepayTimeout:"+(String.valueOf(map.get("overtimepayTimeout")).equalsIgnoreCase("null")?"0.00":String.valueOf(map.get("overtimepayTimeout")))+",");
  675. // str.append("overtimepayFixed:"+(String.valueOf(map.get("overtimepayFixed")).equalsIgnoreCase("null")?"0.00":String.valueOf(map.get("overtimepayFixed")))+",");
  676. // str.append("duty:"+(String.valueOf(map.get("duty")).equalsIgnoreCase("null")?"0.00":String.valueOf(map.get("duty")))+",");
  677. // str.append("specialOvertime:"+(String.valueOf(map.get("specialOvertime")).equalsIgnoreCase("null")?"0.00":String.valueOf(map.get("specialOvertime")))+",");
  678. // str.append("sickLeaveDebit:"+(String.valueOf(map.get("sickLeaveDebit")).equalsIgnoreCase("null")?"0.00":String.valueOf(map.get("sickLeaveDebit")))+",");
  679. // str.append("thingLeaveDebit:"+(String.valueOf(map.get("thingLeaveDebit")).equalsIgnoreCase("null")?"0.00":String.valueOf(map.get("thingLeaveDebit")))+",");
  680. // str.append("absenceDebit:"+(String.valueOf(map.get("absenceDebit")).equalsIgnoreCase("null")?"0.00":String.valueOf(map.get("absenceDebit")))+",");
  681. // str.append("paymentSubsidy:"+(String.valueOf(map.get("paymentSubsidy")).equalsIgnoreCase("null")?"0.00":String.valueOf(map.get("paymentSubsidy")))+",");
  682. // str.append("socialSecurityDebit:"+(String.valueOf(map.get("socialSecurityDebit")).equalsIgnoreCase("null")?"0.00":String.valueOf(map.get("socialSecurityDebit")))+",");
  683. // str.append("providentFundDebit:"+(String.valueOf(map.get("providentFundDebit")).equalsIgnoreCase("null")?"0.00":String.valueOf(map.get("providentFundDebit")))+",");
  684. // str.append("preTaxMone:"+(String.valueOf(map.get("preTaxMone")).equalsIgnoreCase("null")?"0.00":String.valueOf(map.get("preTaxMone")))+",");
  685. // str.append("otherDebit:"+(String.valueOf(map.get("otherDebit")).equalsIgnoreCase("null")?"0.00":String.valueOf(map.get("otherDebit")))+",");
  686. // str.append("reissue:"+(String.valueOf(map.get("reissue")).equalsIgnoreCase("null")?"0.00":String.valueOf(map.get("reissue")))+",");
  687. // str.append("taxMoney:"+(String.valueOf(map.get("taxMoney")).equalsIgnoreCase("null")?"0.00":String.valueOf(map.get("taxMoney")))+",");
  688. // str.append("actualMoney:"+(String.valueOf(map.get("actualMoney")).equalsIgnoreCase("null")?"0.00":String.valueOf(map.get("actualMoney"))));
  689. dataGrid.setFooter(str.toString());
  690. }
  691. }else{
  692. dataGrid.setResults(new ArrayList<UserWageDto>());
  693. dataGrid.setFooter("");
  694. }
  695. TagUtil.datagrid(response, dataGrid);
  696. }
  697. private void calcuSumMap(Map<String, BigDecimal> map, List<UserWageDto> list) throws Exception {
  698. if(map == null || list == null || list.isEmpty()) {
  699. return;
  700. }
  701. for(UserWageDto dto : list) {
  702. for(Field field : dto.getClass().getDeclaredFields()) {
  703. sumMapItem(dto,map, field);
  704. }
  705. }
  706. }
  707. private Method getGetMethod (UserWageDto dto, Field field) throws NoSuchMethodException, SecurityException {
  708. byte[] meth = field.getName().getBytes();
  709. meth[0] = (byte)((char)meth[0]-'a'+'A');
  710. return (Method)dto.getClass().getMethod("get" + new String(meth));
  711. }
  712. private void sumMapItem(UserWageDto dto, Map<String, BigDecimal> map, Field field)throws Exception {
  713. if(dto == null || map == null) {
  714. return;
  715. }
  716. BigDecimal mapValue = map.get(field.getName());
  717. BigDecimal dtoValue = null;
  718. if("class java.math.BigDecimal".equals(field.getGenericType().toString())){
  719. dtoValue = (BigDecimal)getGetMethod(dto, field).invoke(dto);
  720. }else if("class java.lang.Integer".equals(field.getGenericType().toString())){
  721. dtoValue = new BigDecimal((Integer)getGetMethod(dto, field).invoke(dto));
  722. }else if("class java.lang.Double".equals(field.getGenericType().toString())){
  723. dtoValue = new BigDecimal((Double)getGetMethod(dto, field).invoke(dto));
  724. }
  725. if(dtoValue == null) {
  726. dtoValue = BigDecimal.ZERO;
  727. }
  728. if(mapValue == null) {
  729. map.put(field.getName(), dtoValue);
  730. }else {
  731. mapValue = mapValue.add(dtoValue);
  732. map.put(field.getName(), mapValue);
  733. }
  734. }
  735. /**
  736. * 通过人查询所属项目
  737. * @param userid
  738. * @return
  739. */
  740. private String getBybelongId(String userid){
  741. String temp = "";
  742. StringBuffer hql = new StringBuffer("from TSUserOrg where tsUser.id = :userid and ifpluralism = 0 and status=0");
  743. List<TSUserOrg> tsList = systemService.getSession().createQuery(hql.toString()).setParameter("userid", userid).list();
  744. if(!tsList.isEmpty()){
  745. TSUserOrg uo = tsList.get(0);
  746. TSDepart tsDepart = uo.getTsDepart();
  747. if("1".equals(tsDepart.getOrgType()) || "3".equals(tsDepart.getOrgType()) || "4".equals(tsDepart.getOrgType()) || "5".equals(tsDepart.getOrgType())){
  748. temp = tsDepart.getId();
  749. }else if("2".equals(tsDepart.getOrgType()) && "1".equals(tsDepart.getTSPDepart().getOrgType())){
  750. temp = tsDepart.getId();
  751. }else{
  752. temp = selectById(tsDepart.getId());
  753. }
  754. temp = systemService.get(TSDepart.class, temp).getDepartname();
  755. }
  756. return temp;
  757. }
  758. private String selectById(String id){
  759. String temp = "";
  760. TSDepart tsDepart =systemService.getEntity(TSDepart.class,id);
  761. if("3".equals(tsDepart.getOrgType()) || "5".equals(tsDepart.getOrgType())){
  762. temp = tsDepart.getId();
  763. }else{
  764. if(tsDepart.getTSPDepart() != null){
  765. selectById(tsDepart.getTSPDepart().getId());
  766. temp = tsDepart.getTSPDepart().getId();
  767. }
  768. }
  769. return temp;
  770. }
  771. /**
  772. * 删除员工工资核算表
  773. *
  774. * @return
  775. */
  776. @RequestMapping(params = "doDel")
  777. @ResponseBody
  778. public AjaxJson doDel(UserWageEntity userWage, HttpServletRequest request) {
  779. String message = null;
  780. AjaxJson j = new AjaxJson();
  781. userWage = systemService.getEntity(UserWageEntity.class, userWage.getId());
  782. message = "员工工资核算表删除成功";
  783. try{
  784. userWageService.delete(userWage);
  785. systemService.addLog(message, Globals.Log_Type_DEL, Globals.Log_Leavel_INFO);
  786. }catch(Exception e){
  787. e.printStackTrace();
  788. message = "员工工资核算表删除失败";
  789. throw new BusinessException(e.getMessage());
  790. }
  791. j.setMsg(message);
  792. return j;
  793. }
  794. /**
  795. * 批量删除员工工资核算表
  796. *
  797. * @return
  798. */
  799. @RequestMapping(params = "doBatchDel")
  800. @ResponseBody
  801. public AjaxJson doBatchDel(String ids,HttpServletRequest request){
  802. String message = null;
  803. AjaxJson j = new AjaxJson();
  804. message = "员工工资核算表删除成功";
  805. try{
  806. for(String id:ids.split(",")){
  807. UserWageEntity userWage = systemService.getEntity(UserWageEntity.class,
  808. id
  809. );
  810. userWageService.delete(userWage);
  811. systemService.addLog(message, Globals.Log_Type_DEL, Globals.Log_Leavel_INFO);
  812. }
  813. }catch(Exception e){
  814. e.printStackTrace();
  815. message = "员工工资核算表删除失败";
  816. throw new BusinessException(e.getMessage());
  817. }
  818. j.setMsg(message);
  819. return j;
  820. }
  821. /**
  822. * 添加员工工资核算表
  823. *
  824. * @return
  825. */
  826. @RequestMapping(params = "doAdd")
  827. @ResponseBody
  828. public AjaxJson doAdd(UserWageEntity userWage, HttpServletRequest request) {
  829. String message = null;
  830. AjaxJson j = new AjaxJson();
  831. message = "员工工资核算表添加成功";
  832. try{
  833. userWageService.save(userWage);
  834. systemService.addLog(message, Globals.Log_Type_INSERT, Globals.Log_Leavel_INFO);
  835. }catch(Exception e){
  836. e.printStackTrace();
  837. message = "员工工资核算表添加失败";
  838. throw new BusinessException(e.getMessage());
  839. }
  840. j.setMsg(message);
  841. return j;
  842. }
  843. /**
  844. * 更新员工工资核算表
  845. *
  846. * @return
  847. */
  848. @RequestMapping(params = "doUpdate")
  849. @ResponseBody
  850. public AjaxJson doUpdate(UserWageEntity userWage, HttpServletRequest request) {
  851. String message = null;
  852. AjaxJson j = new AjaxJson();
  853. message = "员工工资核算表更新成功";
  854. UserWageEntity t = userWageService.get(UserWageEntity.class, userWage.getId());
  855. try {
  856. MyBeanUtils.copyBeanNotNull2Bean(userWage, t);
  857. userWageService.saveOrUpdate(t);
  858. systemService.addLog(message, Globals.Log_Type_UPDATE, Globals.Log_Leavel_INFO);
  859. } catch (Exception e) {
  860. e.printStackTrace();
  861. message = "员工工资核算表更新失败";
  862. throw new BusinessException(e.getMessage());
  863. }
  864. j.setMsg(message);
  865. return j;
  866. }
  867. /**
  868. * 员工工资核算表新增页面跳转
  869. *
  870. * @return
  871. */
  872. @RequestMapping(params = "goAdd")
  873. public ModelAndView goAdd(UserWageEntity userWage, HttpServletRequest req) {
  874. if (StringUtil.isNotEmpty(userWage.getId())) {
  875. userWage = userWageService.getEntity(UserWageEntity.class, userWage.getId());
  876. req.setAttribute("userWagePage", userWage);
  877. }
  878. return new ModelAndView("cn/com/lzt/userwage/userWage-add");
  879. }
  880. /**
  881. * 员工工资核算表编辑页面跳转
  882. *
  883. * @return
  884. */
  885. @RequestMapping(params = "goUpdate")
  886. public ModelAndView goUpdate(UserWageEntity userWage, HttpServletRequest req) {
  887. if (StringUtil.isNotEmpty(userWage.getId())) {
  888. userWage = userWageService.getEntity(UserWageEntity.class, userWage.getId());
  889. req.setAttribute("userWagePage", userWage);
  890. }
  891. return new ModelAndView("cn/com/lzt/userwage/userWage-update");
  892. }
  893. /**
  894. * 导入功能跳转
  895. *
  896. * @return
  897. */
  898. @RequestMapping(params = "upload")
  899. public ModelAndView upload(HttpServletRequest req) {
  900. req.setAttribute("controller_name","userWageController");
  901. return new ModelAndView("common/upload/pub_excel_upload");
  902. }
  903. /**
  904. * 员工工资条
  905. * 导出excel
  906. *
  907. * @param request
  908. * @param response
  909. */
  910. @RequestMapping(params = "exportWagePaperXls")
  911. public String exportWagePaperXls(UserWageDto userWage,HttpServletRequest request,HttpServletResponse response
  912. , DataGrid dataGrid,ModelMap modelMap) {
  913. String filename = "员工工资条";
  914. List<UserWageDto> list = new ArrayList<UserWageDto>();
  915. String orgIds = request.getParameter("orgIds");
  916. String monthlys = request.getParameter("monthlys");
  917. TSDepart depart = systemService.get(TSDepart.class, orgIds);
  918. if(depart != null) {
  919. filename = depart.getDepartname();
  920. }
  921. // String departname = request.getParameter("departname");
  922. // if(departname != null && departname.length()>0) {
  923. // filename = departname;
  924. // }
  925. if(monthlys != null && monthlys.length()>0) {
  926. filename = filename + "(" + monthlys + ")";
  927. }
  928. if(StringUtils.isNotEmpty(orgIds) && StringUtils.isNotEmpty(monthlys)){
  929. String monthly = request.getParameter("monthly");
  930. String orgId = request.getParameter("orgid");
  931. String type = request.getParameter("type");
  932. if(StringUtils.isEmpty(orgIds)&&StringUtils.isNotEmpty(orgId)){
  933. List<String> orgIdList = extractIdListByComma(orgId);
  934. // 获取 当前组织机构的用户信息
  935. if (!CollectionUtils.isEmpty(orgIdList)) {
  936. if(oConvertUtils.isNotEmpty(type) && "1".equals(type)){
  937. userWage.setOrgIdList(orgIdList);
  938. }else{
  939. String or = orgIdList.get(0);
  940. List<String> ChildIdList = userDepartOrgDealService.getChildIdByProjectDepartId(or);
  941. userWage.setOrgIdList(ChildIdList);
  942. }
  943. }
  944. }else{
  945. if(StringUtils.isNotEmpty(orgIds)){
  946. List<String> orgIdList = extractIdListByComma(orgIds);
  947. // 获取 当前组织机构的用户信息
  948. if (!CollectionUtils.isEmpty(orgIdList)) {
  949. String or = orgIdList.get(0);
  950. List<String> ChildIdList = userDepartOrgDealService.getChildIdByProjectDepartId(or);
  951. userWage.setOrgIdList(ChildIdList);
  952. }
  953. }
  954. }
  955. String moth = "";
  956. String [] mothl = monthlys.split("-");
  957. if("01".equals(mothl[1])){
  958. moth = Integer.valueOf(mothl[0])-1+"-12-01";
  959. }else{
  960. moth = monthlys+"-01 00:00:00";
  961. }
  962. if(StringUtils.isNotEmpty(monthlys)){
  963. userWage.setMonthly(monthlys);
  964. }else{
  965. if(StringUtils.isNotEmpty(monthly)){
  966. request.setAttribute("monthlys", monthly);
  967. userWage.setMonthly(monthly);
  968. }else{
  969. request.setAttribute("monthlys", getMonthlys());
  970. userWage.setMonthly(getMonthlys());
  971. }
  972. }
  973. String authSql = JeecgDataAutorUtils.loadDataSearchConditonSQLString();
  974. VisibleUserDto dto = dataPermissionService.getVisibleUserList();// 获取当前用户可见的userid列表
  975. if(dto != null){
  976. if(dto.getFlag().value().equalsIgnoreCase("ALL")){
  977. list = userWageService.getAllEntities(userWage,null,moth,authSql);
  978. }else if(dto.getFlag().value().equalsIgnoreCase("NONE")){
  979. // 获取当前登录用户
  980. HttpSession session = ContextHolderUtils.getSession();
  981. TSUser user = (TSUser)session.getAttribute("LOCAL_CLINET_USER");
  982. List<String> uidList = new ArrayList<String>();
  983. uidList.add(user.getId());
  984. list = userWageService.getAllEntities(userWage,uidList,moth,authSql);
  985. }else if(dto.getFlag().value().equalsIgnoreCase("PART")){
  986. List<String> uidList = dto.getUseridList();
  987. if(uidList != null && uidList.size() > 0){
  988. list = userWageService.getAllEntities(userWage,uidList,moth,authSql);
  989. }
  990. }
  991. }
  992. }
  993. // long s = System.currentTimeMillis();
  994. // getDingAttendanceinfoEntitiesWithCache();
  995. // long e = System.currentTimeMillis();
  996. // System.out.println("ding: " + (e-s)/1000 +"s");
  997. //
  998. // getDingAttendanceinfoEntitiesWithJDBC();
  999. //
  1000. // long e2 = System.currentTimeMillis();
  1001. // System.out.println("jdbc: " +(e2-e)/1000 + " s");
  1002. Collections.sort(list);
  1003. List<UserWagePaperDto> paperList = new ArrayList<>();
  1004. try {
  1005. creatWagePaper(list, paperList);
  1006. } catch (Exception e) {
  1007. org.jeecgframework.core.util.LogUtil.error(e.getMessage());
  1008. }
  1009. modelMap.put(NormalExcelConstants.FILE_NAME,filename);
  1010. modelMap.put(NormalExcelConstants.CLASS,UserWagePaperDto.class);
  1011. modelMap.put(NormalExcelConstants.PARAMS,new ExportParams("员工工资核算列表", "导出人:"+ResourceUtil.getSessionUser().getRealName(),
  1012. "导出信息"));
  1013. modelMap.put(NormalExcelConstants.DATA_LIST,paperList);
  1014. return NormalExcelConstants.JEECG_EXCEL_VIEW;
  1015. }
  1016. private void getDingAttendanceinfoEntitiesWithJDBC() {
  1017. // HashMap<String, Object> hm = hm_cache.get("getDingAttendanceinfoEntitiesWithCache");
  1018. // Date curdate = dto.getYmdDate();
  1019. // String strDateFormat = "yyyy-MM";
  1020. // SimpleDateFormat sdf = new SimpleDateFormat(strDateFormat);
  1021. // Calendar calendar = Calendar.getInstance();
  1022. // calendar.setTime(curdate);
  1023. // calendar.add(Calendar.DATE, 2);
  1024. // Date tomdate = calendar.getTime();
  1025. // if(hm == null) {
  1026. HashMap<String, Object> hm = new HashMap<>();
  1027. // hm_cache.put("getDingAttendanceinfoEntitiesWithCache", hm);
  1028. //
  1029. // CriteriaQuery cq = new CriteriaQuery(DingAttendanceinfoEntity.class);
  1030. // cq.like("attendanceTime", sdf.format(curdate)+"%");
  1031. // cq.add();
  1032. // cq.between("attendanceTime", curdate, tomdate);
  1033. // cq.add();
  1034. // cq.addOrder("attendanceTime", SortDirection.asc);
  1035. String hql = "select id,user_id, attendance_time from t_bus_ding_attendanceinfo "
  1036. + "where attendance_time like '2019-08%'";
  1037. List<Map<String, Object>> mapList=new ArrayList<Map<String, Object>>();
  1038. mapList = systemService.findForJdbc(hql, null);
  1039. //getListByCriteriaQuery(cq, false);
  1040. for(Map<String, Object> map : mapList) {
  1041. DingAttendanceinfoEntity entity = new DingAttendanceinfoEntity();
  1042. entity.setId(map.get("id").toString());
  1043. entity.setUserId(map.get("user_id").toString());
  1044. entity.setAttendanceTime((Date)map.get("attendance_time"));
  1045. String userInEntity = entity.getUserId();
  1046. if(hm.containsKey(userInEntity)) {
  1047. List<DingAttendanceinfoEntity> entitylist = (List<DingAttendanceinfoEntity>)hm.get(userInEntity);
  1048. entitylist.add(entity);
  1049. }else {
  1050. List<DingAttendanceinfoEntity> newlist = new ArrayList<>();
  1051. newlist.add(entity);
  1052. hm.put(userInEntity, newlist);
  1053. }
  1054. }
  1055. // }
  1056. //
  1057. // List<DingAttendanceinfoEntity> allList = (List<DingAttendanceinfoEntity>)hm.get(dto.getUserid());
  1058. // if(allList == null) {
  1059. // return new ArrayList<DingAttendanceinfoEntity>();
  1060. // }
  1061. // List<DingAttendanceinfoEntity> selectList = new ArrayList<>();
  1062. // for(DingAttendanceinfoEntity attInAll : allList) {
  1063. // Date attendanceTime = attInAll.getAttendanceTime();
  1064. // if(attendanceTime.after(curdate) && attendanceTime.before(tomdate)) {
  1065. // selectList.add(attInAll);
  1066. // }
  1067. // }
  1068. // return selectList;
  1069. }
  1070. /**
  1071. * @return
  1072. */
  1073. private void getDingAttendanceinfoEntitiesWithCache() {
  1074. // HashMap<String, Object> hm = hm_cache.get("getDingAttendanceinfoEntitiesWithCache");
  1075. // Date curdate = dto.getYmdDate();
  1076. // String strDateFormat = "yyyy-MM";
  1077. // SimpleDateFormat sdf = new SimpleDateFormat(strDateFormat);
  1078. // Calendar calendar = Calendar.getInstance();
  1079. // calendar.setTime(curdate);
  1080. // calendar.add(Calendar.DATE, 2);
  1081. // Date tomdate = calendar.getTime();
  1082. // if(hm == null) {
  1083. HashMap<String, Object> hm = new HashMap<>();
  1084. // hm_cache.put("getDingAttendanceinfoEntitiesWithCache", hm);
  1085. //
  1086. // CriteriaQuery cq = new CriteriaQuery(DingAttendanceinfoEntity.class);
  1087. // cq.like("attendanceTime", sdf.format(curdate)+"%");
  1088. // cq.add();
  1089. // cq.between("attendanceTime", curdate, tomdate);
  1090. // cq.add();
  1091. // cq.addOrder("attendanceTime", SortDirection.asc);
  1092. String hql = "from DingAttendanceinfoEntity where attendanceTime like '2019-08%'";
  1093. List<DingAttendanceinfoEntity> entitiesFromDB = systemService.findHql(hql);
  1094. //getListByCriteriaQuery(cq, false);
  1095. for(DingAttendanceinfoEntity entity : entitiesFromDB) {
  1096. String userInEntity = entity.getUserId();
  1097. if(hm.containsKey(userInEntity)) {
  1098. List<DingAttendanceinfoEntity> entitylist = (List<DingAttendanceinfoEntity>)hm.get(userInEntity);
  1099. entitylist.add(entity);
  1100. }else {
  1101. List<DingAttendanceinfoEntity> newlist = new ArrayList<>();
  1102. newlist.add(entity);
  1103. hm.put(userInEntity, newlist);
  1104. }
  1105. }
  1106. // }
  1107. //
  1108. // List<DingAttendanceinfoEntity> allList = (List<DingAttendanceinfoEntity>)hm.get(dto.getUserid());
  1109. // if(allList == null) {
  1110. // return new ArrayList<DingAttendanceinfoEntity>();
  1111. // }
  1112. // List<DingAttendanceinfoEntity> selectList = new ArrayList<>();
  1113. // for(DingAttendanceinfoEntity attInAll : allList) {
  1114. // Date attendanceTime = attInAll.getAttendanceTime();
  1115. // if(attendanceTime.after(curdate) && attendanceTime.before(tomdate)) {
  1116. // selectList.add(attInAll);
  1117. // }
  1118. // }
  1119. // return selectList;
  1120. }
  1121. /**
  1122. * @param list
  1123. * @param paperList
  1124. * @throws InvocationTargetException
  1125. * @throws IllegalArgumentException
  1126. * @throws IllegalAccessException
  1127. */
  1128. private void creatWagePaper(List<UserWageDto> list, List<UserWagePaperDto> paperList) throws Exception {
  1129. for(int i=0 ; i < list.size() ; i++) {
  1130. UserWageDto dto = list.get(i);
  1131. UserWagePaperDto papertitle = new UserWagePaperDto();
  1132. UserWagePaperDto paperitem = new UserWagePaperDto();
  1133. Field[] fields = UserWagePaperDto.class.getDeclaredFields();
  1134. for(int j=0 ; j<fields.length ; j++) {
  1135. Field f = fields[j];
  1136. Excel ann = f.getAnnotation(Excel.class);
  1137. if(ann != null) {
  1138. PropertyDescriptor paperpd = new PropertyDescriptor(f.getName(), UserWagePaperDto.class);
  1139. Method wM = paperpd.getWriteMethod();//获得写方法
  1140. wM.invoke(papertitle, ann.name());
  1141. PropertyDescriptor dtopd = new PropertyDescriptor(f.getName(), UserWageDto.class);
  1142. Method rM = dtopd.getReadMethod();//读方法
  1143. Object v = rM.invoke(dto);
  1144. String str = "";
  1145. if(v != null) {
  1146. str = v.toString();
  1147. }
  1148. wM.invoke(paperitem, str);
  1149. }
  1150. }
  1151. if(i>0) {
  1152. paperList.add(papertitle);
  1153. }
  1154. paperList.add(paperitem);
  1155. }
  1156. }
  1157. /**
  1158. * 员工工资核算
  1159. * 导出excel
  1160. *
  1161. * @param request
  1162. * @param response
  1163. */
  1164. @RequestMapping(params = "exportXls")
  1165. public String exportXls(UserWageDto userWage,HttpServletRequest request,HttpServletResponse response
  1166. , DataGrid dataGrid,ModelMap modelMap) {
  1167. String filename = "员工工资核算";
  1168. List<UserWageDto> list = new ArrayList<UserWageDto>();
  1169. String orgIds = request.getParameter("orgIds");
  1170. String monthlys = request.getParameter("monthlys");
  1171. TSDepart depart = systemService.get(TSDepart.class, orgIds);
  1172. if(depart != null) {
  1173. filename = depart.getDepartname();
  1174. }
  1175. // String departname = request.getParameter("departname");
  1176. // if(departname != null && departname.length()>0) {
  1177. // filename = departname;
  1178. // }
  1179. if(monthlys != null && monthlys.length()>0) {
  1180. filename = filename + "(" + monthlys + ")";
  1181. }
  1182. if(StringUtils.isNotEmpty(orgIds) && StringUtils.isNotEmpty(monthlys)){
  1183. String monthly = request.getParameter("monthly");
  1184. String orgId = request.getParameter("orgid");
  1185. String type = request.getParameter("type");
  1186. if(StringUtils.isEmpty(orgIds)&&StringUtils.isNotEmpty(orgId)){
  1187. List<String> orgIdList = extractIdListByComma(orgId);
  1188. // 获取 当前组织机构的用户信息
  1189. if (!CollectionUtils.isEmpty(orgIdList)) {
  1190. if(oConvertUtils.isNotEmpty(type) && "1".equals(type)){
  1191. userWage.setOrgIdList(orgIdList);
  1192. }else{
  1193. String or = orgIdList.get(0);
  1194. List<String> ChildIdList = userDepartOrgDealService.getChildIdByProjectDepartId(or);
  1195. userWage.setOrgIdList(ChildIdList);
  1196. }
  1197. }
  1198. }else{
  1199. if(StringUtils.isNotEmpty(orgIds)){
  1200. List<String> orgIdList = extractIdListByComma(orgIds);
  1201. // 获取 当前组织机构的用户信息
  1202. if (!CollectionUtils.isEmpty(orgIdList)) {
  1203. String or = orgIdList.get(0);
  1204. List<String> ChildIdList = userDepartOrgDealService.getChildIdByProjectDepartId(or);
  1205. userWage.setOrgIdList(ChildIdList);
  1206. }
  1207. }
  1208. }
  1209. String moth = "";
  1210. String [] mothl = monthlys.split("-");
  1211. if("01".equals(mothl[1])){
  1212. moth = Integer.valueOf(mothl[0])-1+"-12-01";
  1213. }else{
  1214. moth = monthlys+"-01 00:00:00";
  1215. }
  1216. if(StringUtils.isNotEmpty(monthlys)){
  1217. userWage.setMonthly(monthlys);
  1218. }else{
  1219. if(StringUtils.isNotEmpty(monthly)){
  1220. request.setAttribute("monthlys", monthly);
  1221. userWage.setMonthly(monthly);
  1222. }else{
  1223. request.setAttribute("monthlys", getMonthlys());
  1224. userWage.setMonthly(getMonthlys());
  1225. }
  1226. }
  1227. String authSql = JeecgDataAutorUtils.loadDataSearchConditonSQLString();
  1228. VisibleUserDto dto = dataPermissionService.getVisibleUserList();// 获取当前用户可见的userid列表
  1229. if(dto != null){
  1230. if(dto.getFlag().value().equalsIgnoreCase("ALL")){
  1231. list = userWageService.getAllEntities(userWage,null,moth,authSql);
  1232. }else if(dto.getFlag().value().equalsIgnoreCase("NONE")){
  1233. // 获取当前登录用户
  1234. HttpSession session = ContextHolderUtils.getSession();
  1235. TSUser user = (TSUser)session.getAttribute("LOCAL_CLINET_USER");
  1236. List<String> uidList = new ArrayList<String>();
  1237. uidList.add(user.getId());
  1238. list = userWageService.getAllEntities(userWage,uidList,moth,authSql);
  1239. }else if(dto.getFlag().value().equalsIgnoreCase("PART")){
  1240. List<String> uidList = dto.getUseridList();
  1241. if(uidList != null && uidList.size() > 0){
  1242. list = userWageService.getAllEntities(userWage,uidList,moth,authSql);
  1243. }
  1244. }
  1245. }
  1246. }
  1247. Collections.sort(list);
  1248. modelMap.put(NormalExcelConstants.FILE_NAME,filename);
  1249. modelMap.put(NormalExcelConstants.CLASS,UserWageDto.class);
  1250. modelMap.put(NormalExcelConstants.PARAMS,new ExportParams("员工工资核算列表", "导出人:"+ResourceUtil.getSessionUser().getRealName(),
  1251. "导出信息"));
  1252. modelMap.put(NormalExcelConstants.DATA_LIST,list);
  1253. return NormalExcelConstants.JEECG_EXCEL_VIEW;
  1254. }
  1255. /**
  1256. * 月度工资一览导出
  1257. *
  1258. * @param request
  1259. * @param response
  1260. */
  1261. @RequestMapping(params = "exportXls1")
  1262. public String exportXls1(UserWageViewDto userWage,HttpServletRequest request,HttpServletResponse response
  1263. , DataGrid dataGrid,ModelMap modelMap) {
  1264. MiniDaoPage<UserWageViewDto> list = new MiniDaoPage<UserWageViewDto>();
  1265. String monthlys = request.getParameter("monthlys");
  1266. // String departname = request.getParameter("departname");
  1267. String orgIds = request.getParameter("orgIds");
  1268. String filename = "员工月度工资一览";
  1269. TSDepart depart = systemService.get(TSDepart.class, orgIds);
  1270. if(depart != null) {
  1271. filename = depart.getDepartname();
  1272. }
  1273. if(monthlys != null && monthlys.length()>0) {
  1274. filename = filename + "(" + monthlys + ")";
  1275. }
  1276. if(StringUtils.isNotEmpty(monthlys)){
  1277. List<String> orgIdList = extractIdListByComma(orgIds);
  1278. // 获取 当前组织机构的用户信息
  1279. if (!CollectionUtils.isEmpty(orgIdList)) {
  1280. String or = orgIdList.get(0);
  1281. List<String> ChildIdList = userDepartOrgDealService.getChildIdByProjectDepartId(or);
  1282. userWage.setOrgIdList(ChildIdList);
  1283. }
  1284. userWage.setMonthly(monthlys);
  1285. String authSql = JeecgDataAutorUtils.loadDataSearchConditonSQLString();
  1286. VisibleUserDto dto = dataPermissionService.getVisibleUserList();// 获取当前用户可见的userid列表
  1287. if(dto != null){
  1288. if(dto.getFlag().value().equalsIgnoreCase("ALL")){
  1289. list = userWageService.getViewEntities(userWage,null,dataGrid.getPage(), dataGrid.getRows(), authSql);
  1290. }else if(dto.getFlag().value().equalsIgnoreCase("NONE")){
  1291. // 获取当前登录用户
  1292. HttpSession session = ContextHolderUtils.getSession();
  1293. TSUser user = (TSUser)session.getAttribute("LOCAL_CLINET_USER");
  1294. List<String> uidList = new ArrayList<String>();
  1295. uidList.add(user.getId());
  1296. list = userWageService.getViewEntities(userWage,uidList,dataGrid.getPage(), dataGrid.getRows(), authSql);
  1297. }else if(dto.getFlag().value().equalsIgnoreCase("PART")){
  1298. List<String> useridList = dto.getUseridList();
  1299. if(useridList != null && useridList.size() > 0){
  1300. list = userWageService.getViewEntities(userWage,useridList,dataGrid.getPage(), dataGrid.getRows(), authSql);
  1301. }
  1302. }
  1303. //MiniDaoPage<UserWageViewDto> list = userWageService.getViewEntities(userWage, dataGrid.getPage(), dataGrid.getRows(), authSql);
  1304. //List<UserWageDto> list = userWageService.getAllEntities(userWage,authSql);
  1305. }
  1306. }
  1307. modelMap.put(NormalExcelConstants.FILE_NAME,filename);
  1308. modelMap.put(NormalExcelConstants.CLASS,UserWageViewDto.class);
  1309. modelMap.put(NormalExcelConstants.PARAMS,new ExportParams("员工月度工资一览列表", "导出人:"+ResourceUtil.getSessionUser().getRealName(),
  1310. "导出信息"));
  1311. if(list.getResults() == null){
  1312. modelMap.put(NormalExcelConstants.DATA_LIST,new ArrayList<>());
  1313. }else{
  1314. modelMap.put(NormalExcelConstants.DATA_LIST,list.getResults());
  1315. }
  1316. return NormalExcelConstants.JEECG_EXCEL_VIEW;
  1317. }
  1318. /**
  1319. * 月度工资详细
  1320. *
  1321. * @param request
  1322. * @param response
  1323. */
  1324. @RequestMapping(params = "exportXlsDetailByProject")
  1325. public String exportXlsDetailByProject(@Param("orgId") String orgId
  1326. ,@Param("monthly")String monthly,@Param("type")String type,HttpServletRequest request,HttpServletResponse response
  1327. , DataGrid dataGrid,ModelMap modelMap) {
  1328. String filename = "美都环卫全体员工工资详细";
  1329. UserWageDto userWage = new UserWageDto();
  1330. if(StringUtils.isNotEmpty(orgId)){
  1331. TSDepart depart = systemService.get(TSDepart.class, orgId);
  1332. if(depart != null) {
  1333. filename = depart.getDepartname();
  1334. }
  1335. }
  1336. // if(StringUtils.isNotEmpty(orgId) && departname != null && departname.length()>0) {
  1337. // filename = departname;
  1338. // }
  1339. filename = filename.replaceAll(",", "");
  1340. if(monthly != null && monthly.length()>0) {
  1341. filename = filename + "(" + monthly + ")";
  1342. }
  1343. if(StringUtils.isNotEmpty(orgId)){
  1344. List<String> orgIdList = extractIdListByComma(orgId);
  1345. // 获取 当前组织机构的用户信息
  1346. if (!CollectionUtils.isEmpty(orgIdList)) {
  1347. if(oConvertUtils.isNotEmpty(type) && "1".equals(type)){
  1348. userWage.setOrgIdList(orgIdList);
  1349. }else{
  1350. String or = orgIdList.get(0);
  1351. List<String> ChildIdList = userDepartOrgDealService.getChildIdByProjectDepartId(or);
  1352. userWage.setOrgIdList(ChildIdList);
  1353. }
  1354. }
  1355. }
  1356. if(StringUtils.isNotEmpty(monthly)){
  1357. userWage.setMonthly(monthly);
  1358. }
  1359. String authSql = JeecgDataAutorUtils.loadDataSearchConditonSQLString();
  1360. VisibleUserDto dto = dataPermissionService.getVisibleUserList();// 获取当前用户可见的userid列表
  1361. if(dto != null){
  1362. List<UserWageDto> list = new ArrayList<UserWageDto>();
  1363. if(dto.getFlag().value().equalsIgnoreCase("ALL")){
  1364. list = userWageService.getAllEntities(userWage,null,null,authSql);
  1365. }else if(dto.getFlag().value().equalsIgnoreCase("NONE")){
  1366. // 获取当前登录用户
  1367. HttpSession session = ContextHolderUtils.getSession();
  1368. TSUser user = (TSUser)session.getAttribute("LOCAL_CLINET_USER");
  1369. List<String> uidList = new ArrayList<String>();
  1370. uidList.add(user.getId());
  1371. list = userWageService.getAllEntities(userWage,uidList,null,authSql);
  1372. }else if(dto.getFlag().value().equalsIgnoreCase("PART")){
  1373. List<String> useridList = dto.getUseridList();
  1374. if(useridList != null && useridList.size() > 0){
  1375. list = userWageService.getAllEntities(userWage,useridList,null,authSql);
  1376. }
  1377. }
  1378. Collections.sort(list);
  1379. modelMap.put(NormalExcelConstants.FILE_NAME,filename);
  1380. modelMap.put(NormalExcelConstants.CLASS,UserWageDto.class);
  1381. modelMap.put(NormalExcelConstants.PARAMS,new ExportParams("员工工资详细列表", "导出人:"+ResourceUtil.getSessionUser().getRealName(),
  1382. "导出信息"));
  1383. modelMap.put(NormalExcelConstants.DATA_LIST,list);
  1384. }
  1385. return NormalExcelConstants.JEECG_EXCEL_VIEW;
  1386. }
  1387. /**
  1388. * 月度工资详细
  1389. *
  1390. * @param request
  1391. * @param response
  1392. */
  1393. @RequestMapping(params = "exportXls2")
  1394. public String exportXls2(UserWageDto userWage,HttpServletRequest request,HttpServletResponse response
  1395. , DataGrid dataGrid,ModelMap modelMap) {
  1396. String monthlys = request.getParameter("monthlys");
  1397. String monthly = request.getParameter("monthly");
  1398. String orgIds = request.getParameter("orgIds");
  1399. String orgId = request.getParameter("orgid");
  1400. String type = request.getParameter("type");
  1401. // String departname = request.getParameter("departname");
  1402. String filename = "员工工资详细";
  1403. // if(departname != null && departname.length()>0) {
  1404. // filename = departname;
  1405. // }
  1406. if(monthlys != null && monthlys.length()>0) {
  1407. filename = filename + "(" + monthlys + ")";
  1408. }
  1409. if(StringUtils.isEmpty(orgIds)&&StringUtils.isNotEmpty(orgId)){
  1410. List<String> orgIdList = extractIdListByComma(orgId);
  1411. // 获取 当前组织机构的用户信息
  1412. if (!CollectionUtils.isEmpty(orgIdList)) {
  1413. if(oConvertUtils.isNotEmpty(type) && "1".equals(type)){
  1414. userWage.setOrgIdList(orgIdList);
  1415. }else{
  1416. String or = orgIdList.get(0);
  1417. List<String> ChildIdList = userDepartOrgDealService.getChildIdByProjectDepartId(or);
  1418. userWage.setOrgIdList(ChildIdList);
  1419. }
  1420. }
  1421. }else{
  1422. if(StringUtils.isNotEmpty(orgIds)){
  1423. List<String> orgIdList = extractIdListByComma(orgIds);
  1424. // 获取 当前组织机构的用户信息
  1425. if (!CollectionUtils.isEmpty(orgIdList)) {
  1426. String or = orgIdList.get(0);
  1427. List<String> ChildIdList = userDepartOrgDealService.getChildIdByProjectDepartId(or);
  1428. userWage.setOrgIdList(ChildIdList);
  1429. }
  1430. }
  1431. }
  1432. if(StringUtils.isNotEmpty(monthlys)){
  1433. userWage.setMonthly(monthlys);
  1434. }else{
  1435. if(StringUtils.isNotEmpty(monthly)){
  1436. request.setAttribute("monthlys", monthly);
  1437. userWage.setMonthly(monthly);
  1438. }else{
  1439. request.setAttribute("monthlys", getMonthlys());
  1440. userWage.setMonthly(getMonthlys());
  1441. }
  1442. //userWage.setMonthly(sim.format(sim.parse("2017-10")));
  1443. }
  1444. String authSql = JeecgDataAutorUtils.loadDataSearchConditonSQLString();
  1445. VisibleUserDto dto = dataPermissionService.getVisibleUserList();// 获取当前用户可见的userid列表
  1446. if(dto != null){
  1447. List<UserWageDto> list = new ArrayList<UserWageDto>();
  1448. if(dto.getFlag().value().equalsIgnoreCase("ALL")){
  1449. list = userWageService.getAllEntities(userWage,null,null,authSql);
  1450. }else if(dto.getFlag().value().equalsIgnoreCase("NONE")){
  1451. // 获取当前登录用户
  1452. HttpSession session = ContextHolderUtils.getSession();
  1453. TSUser user = (TSUser)session.getAttribute("LOCAL_CLINET_USER");
  1454. List<String> uidList = new ArrayList<String>();
  1455. uidList.add(user.getId());
  1456. list = userWageService.getAllEntities(userWage,uidList,null,authSql);
  1457. }else if(dto.getFlag().value().equalsIgnoreCase("PART")){
  1458. List<String> useridList = dto.getUseridList();
  1459. if(useridList != null && useridList.size() > 0){
  1460. list = userWageService.getAllEntities(userWage,useridList,null,authSql);
  1461. }
  1462. }
  1463. Collections.sort(list);
  1464. modelMap.put(NormalExcelConstants.FILE_NAME,filename);
  1465. modelMap.put(NormalExcelConstants.CLASS,UserWageDto.class);
  1466. modelMap.put(NormalExcelConstants.PARAMS,new ExportParams("员工工资详细列表", "导出人:"+ResourceUtil.getSessionUser().getRealName(),
  1467. "导出信息"));
  1468. modelMap.put(NormalExcelConstants.DATA_LIST,list);
  1469. }
  1470. return NormalExcelConstants.JEECG_EXCEL_VIEW;
  1471. }
  1472. /**
  1473. * 月度工资明细
  1474. * 人事使用
  1475. *
  1476. * @param request
  1477. * @param response
  1478. * @throws Exception
  1479. */
  1480. @RequestMapping(params = "exportXls3")
  1481. public String exportXls3(UserWageDto userWage,HttpServletRequest request,HttpServletResponse response
  1482. , DataGrid dataGrid,ModelMap modelMap) throws Exception {
  1483. String monthlys = request.getParameter("monthlys");
  1484. String monthly = request.getParameter("monthly");
  1485. String orgIds = request.getParameter("orgIds");
  1486. String orgId = request.getParameter("orgid");
  1487. String type = request.getParameter("type");
  1488. String departname = request.getParameter("departname");
  1489. String filename = "员工工资明细";
  1490. if(departname != null && departname.length()>0) {
  1491. filename = departname;
  1492. }
  1493. if(monthlys != null && monthlys.length()>0) {
  1494. filename = filename + "(" + monthlys + ")";
  1495. }
  1496. if(StringUtils.isEmpty(orgIds)&&StringUtils.isNotEmpty(orgId)){
  1497. List<String> orgIdList = extractIdListByComma(orgId);
  1498. // 获取 当前组织机构的用户信息
  1499. if (!CollectionUtils.isEmpty(orgIdList)) {
  1500. if(oConvertUtils.isNotEmpty(type) && "1".equals(type)){
  1501. userWage.setOrgIdList(orgIdList);
  1502. }else{
  1503. String or = orgIdList.get(0);
  1504. List<String> ChildIdList = userDepartOrgDealService.getChildIdByProjectDepartId(or);
  1505. userWage.setOrgIdList(ChildIdList);
  1506. }
  1507. }
  1508. }else{
  1509. if(StringUtils.isNotEmpty(orgIds)){
  1510. List<String> orgIdList = extractIdListByComma(orgIds);
  1511. // 获取 当前组织机构的用户信息
  1512. if (!CollectionUtils.isEmpty(orgIdList)) {
  1513. String or = orgIdList.get(0);
  1514. List<String> ChildIdList = userDepartOrgDealService.getChildIdByProjectDepartId(or);
  1515. userWage.setOrgIdList(ChildIdList);
  1516. }
  1517. }
  1518. }
  1519. if(StringUtils.isNotEmpty(monthlys)){
  1520. userWage.setMonthly(monthlys);
  1521. }else{
  1522. if(StringUtils.isNotEmpty(monthly)){
  1523. request.setAttribute("monthlys", monthly);
  1524. userWage.setMonthly(monthly);
  1525. }else{
  1526. request.setAttribute("monthlys", getMonthlys());
  1527. userWage.setMonthly(getMonthlys());
  1528. }
  1529. //userWage.setMonthly(sim.format(sim.parse("2017-10")));
  1530. }
  1531. String authSql = JeecgDataAutorUtils.loadDataSearchConditonSQLString();
  1532. // VisibleUserDto dto = dataPermissionService.getVisibleUserList();// 获取当前用户可见的userid列表
  1533. //
  1534. // HashMap<String, String> permKeyMap = null; //通过map来过滤
  1535. // if(dto != null){
  1536. List<UserWageDto> list = new ArrayList<UserWageDto>();
  1537. // permKeyMap = new HashMap<String, String>();
  1538. List<UserWageDetaillsDto> listDetail = new ArrayList<UserWageDetaillsDto>();
  1539. // 取得所有的数据,然后在业务层过滤,效率会提高一些
  1540. list = userWageService.getAllEntities(userWage,null,null,authSql);
  1541. UserWageDetaillsDto dto2 = null;
  1542. for (UserWageDto userWageDto : list) {
  1543. dto2 = new UserWageDetaillsDto();
  1544. MyBeanUtils.copyBeanNotNull2Bean(userWageDto,dto2);
  1545. listDetail.add(dto2);
  1546. }
  1547. // if(dto.getFlag().value().equalsIgnoreCase("ALL")){
  1548. // UserWageDetaillsDto dto2 = null;
  1549. // for (UserWageDto userWageDto : list) {
  1550. // dto2 = new UserWageDetaillsDto();
  1551. // MyBeanUtils.copyBeanNotNull2Bean(userWageDto,dto2);
  1552. // listDetail.add(dto2);
  1553. // }
  1554. // }else if(dto.getFlag().value().equalsIgnoreCase("NONE")){
  1555. // // 获取当前登录用户
  1556. // HttpSession session = ContextHolderUtils.getSession();
  1557. // TSUser user = (TSUser)session.getAttribute("LOCAL_CLINET_USER");
  1558. // permKeyMap.put(user.getId(), null);
  1559. // UserWageDetaillsDto dto2 = null;
  1560. // for (UserWageDto userWageDto : list) {
  1561. // if(permKeyMap.containsKey(userWageDto.getUserid())) {
  1562. // dto2 = new UserWageDetaillsDto();
  1563. // MyBeanUtils.copyBeanNotNull2Bean(userWageDto,dto2);
  1564. // listDetail.add(dto2);
  1565. // }
  1566. // }
  1567. // }else if(dto.getFlag().value().equalsIgnoreCase("PART")){
  1568. // List<String> useridList = dto.getUseridList();
  1569. // if(useridList != null && useridList.size() > 0){
  1570. // for(String userid : useridList) {
  1571. // permKeyMap.put(userid, null);
  1572. // }
  1573. // UserWageDetaillsDto dto2 = null;
  1574. // for (UserWageDto userWageDto : list) {
  1575. // if(permKeyMap.containsKey(userWageDto.getUserid())) {
  1576. // dto2 = new UserWageDetaillsDto();
  1577. // MyBeanUtils.copyBeanNotNull2Bean(userWageDto,dto2);
  1578. // listDetail.add(dto2);
  1579. // }
  1580. // }
  1581. // }
  1582. // }
  1583. Collections.sort(listDetail);
  1584. modelMap.put(NormalExcelConstants.FILE_NAME,filename);
  1585. modelMap.put(NormalExcelConstants.CLASS,UserWageDetaillsDto.class);
  1586. modelMap.put(NormalExcelConstants.PARAMS,new ExportParams("员工工资明细列表", "导出人:"+ResourceUtil.getSessionUser().getRealName(),
  1587. "导出信息"));
  1588. modelMap.put(NormalExcelConstants.DATA_LIST,listDetail);
  1589. // }
  1590. return NormalExcelConstants.JEECG_EXCEL_VIEW;
  1591. }
  1592. /**
  1593. * 导出excel 使模板
  1594. *
  1595. * @param request
  1596. * @param response
  1597. */
  1598. @RequestMapping(params = "exportXlsByT")
  1599. public String exportXlsByT(UserWageEntity userWage,HttpServletRequest request,HttpServletResponse response
  1600. , DataGrid dataGrid,ModelMap modelMap) {
  1601. modelMap.put(NormalExcelConstants.FILE_NAME,"员工工资核算表");
  1602. modelMap.put(NormalExcelConstants.CLASS,UserWageEntity.class);
  1603. modelMap.put(NormalExcelConstants.PARAMS,new ExportParams("员工工资核算表列表", "导出人:"+ResourceUtil.getSessionUser().getRealName(),
  1604. "导出信息"));
  1605. modelMap.put(NormalExcelConstants.DATA_LIST,new ArrayList());
  1606. return NormalExcelConstants.JEECG_EXCEL_VIEW;
  1607. }
  1608. @SuppressWarnings("unchecked")
  1609. @RequestMapping(params = "importExcel", method = RequestMethod.POST)
  1610. @ResponseBody
  1611. public AjaxJson importExcel(HttpServletRequest request, HttpServletResponse response) {
  1612. AjaxJson j = new AjaxJson();
  1613. MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
  1614. Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
  1615. for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
  1616. MultipartFile file = entity.getValue();// 获取上传文件对象
  1617. ImportParams params = new ImportParams();
  1618. params.setTitleRows(2);
  1619. params.setHeadRows(1);
  1620. params.setNeedSave(true);
  1621. try {
  1622. List<UserWageEntity> listUserWageEntitys = ExcelImportUtil.importExcel(file.getInputStream(),UserWageEntity.class,params);
  1623. for (UserWageEntity userWage : listUserWageEntitys) {
  1624. userWageService.save(userWage);
  1625. }
  1626. j.setMsg("文件导入成功!");
  1627. } catch (Exception e) {
  1628. j.setMsg("文件导入失败!");
  1629. logger.error(ExceptionUtil.getExceptionMessage(e));
  1630. }finally{
  1631. try {
  1632. file.getInputStream().close();
  1633. } catch (IOException e) {
  1634. e.printStackTrace();
  1635. }
  1636. }
  1637. }
  1638. return j;
  1639. }
  1640. @RequestMapping(method = RequestMethod.GET)
  1641. @ResponseBody
  1642. public List<UserWageEntity> list() {
  1643. List<UserWageEntity> listUserWages=userWageService.getList(UserWageEntity.class);
  1644. return listUserWages;
  1645. }
  1646. @RequestMapping(value = "/{id}", method = RequestMethod.GET)
  1647. @ResponseBody
  1648. public ResponseEntity<?> get(@PathVariable("id") String id) {
  1649. UserWageEntity task = userWageService.get(UserWageEntity.class, id);
  1650. if (task == null) {
  1651. return new ResponseEntity(HttpStatus.NOT_FOUND);
  1652. }
  1653. return new ResponseEntity(task, HttpStatus.OK);
  1654. }
  1655. @RequestMapping(method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE)
  1656. @ResponseBody
  1657. public ResponseEntity<?> create(@RequestBody UserWageEntity userWage, UriComponentsBuilder uriBuilder) {
  1658. //调用JSR303 Bean Validator进行校验,如果出错返回含400错误码及json格式的错误信息.
  1659. Set<ConstraintViolation<UserWageEntity>> failures = validator.validate(userWage);
  1660. if (!failures.isEmpty()) {
  1661. return new ResponseEntity(BeanValidators.extractPropertyAndMessage(failures), HttpStatus.BAD_REQUEST);
  1662. }
  1663. //保存
  1664. try{
  1665. userWageService.save(userWage);
  1666. } catch (Exception e) {
  1667. e.printStackTrace();
  1668. return new ResponseEntity(HttpStatus.NO_CONTENT);
  1669. }
  1670. //按照Restful风格约定,创建指向新任务的url, 也可以直接返回id或对象.
  1671. String id = userWage.getId();
  1672. URI uri = uriBuilder.path("/rest/userWageController/" + id).build().toUri();
  1673. HttpHeaders headers = new HttpHeaders();
  1674. headers.setLocation(uri);
  1675. return new ResponseEntity(headers, HttpStatus.CREATED);
  1676. }
  1677. @RequestMapping(value = "/{id}", method = RequestMethod.PUT, consumes = MediaType.APPLICATION_JSON_VALUE)
  1678. public ResponseEntity<?> update(@RequestBody UserWageEntity userWage) {
  1679. //调用JSR303 Bean Validator进行校验,如果出错返回含400错误码及json格式的错误信息.
  1680. Set<ConstraintViolation<UserWageEntity>> failures = validator.validate(userWage);
  1681. if (!failures.isEmpty()) {
  1682. return new ResponseEntity(BeanValidators.extractPropertyAndMessage(failures), HttpStatus.BAD_REQUEST);
  1683. }
  1684. //保存
  1685. try{
  1686. userWageService.saveOrUpdate(userWage);
  1687. } catch (Exception e) {
  1688. e.printStackTrace();
  1689. return new ResponseEntity(HttpStatus.NO_CONTENT);
  1690. }
  1691. //按Restful约定,返回204状态码, 无内容. 也可以返回200状态码.
  1692. return new ResponseEntity(HttpStatus.NO_CONTENT);
  1693. }
  1694. @RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
  1695. @ResponseStatus(HttpStatus.NO_CONTENT)
  1696. public void delete(@PathVariable("id") String id) {
  1697. userWageService.deleteEntityById(UserWageEntity.class, id);
  1698. }
  1699. /**
  1700. * 保存新增/更新的行数据
  1701. * @param page
  1702. * @return
  1703. * @throws Exception
  1704. */
  1705. @RequestMapping(params = "saveRows")
  1706. @ResponseBody
  1707. public AjaxJson saveRows(UserwagePage page) throws Exception{
  1708. List<UserWageEntity> demos=page.getUserWageList();
  1709. AjaxJson j = userWageService.addOrEdit(demos);
  1710. return j;
  1711. }
  1712. /**
  1713. * 工资进行上报
  1714. * @param request
  1715. * @param status
  1716. * @return
  1717. */
  1718. @RequestMapping(params="updateStatus")
  1719. @ResponseBody
  1720. public AjaxJson updateStatus(HttpServletRequest request,boolean status){
  1721. String ids = request.getParameter("ids");
  1722. List<String> idList = extractIdListByComma(ids);
  1723. AjaxJson j = userWageService.updateStatus(idList, status);
  1724. return j;
  1725. }
  1726. @RequestMapping(params = "budgetlist")
  1727. public ModelAndView budgetlist(HttpServletRequest request) {
  1728. // String orgid = request.getParameter("orgid");
  1729. // String monthly = request.getParameter("monthly");
  1730. // if(oConvertUtils.isNotEmpty(monthly)){
  1731. // request.setAttribute("monthlys", monthly);
  1732. // request.setAttribute("orgid", orgid);
  1733. // }else{
  1734. // request.setAttribute("monthlys", getMonthlys());
  1735. // }
  1736. return new ModelAndView("cn/com/lzt/userwage/userWageViewBudgetList");
  1737. }
  1738. @RequestMapping(params = "datagridbudget")
  1739. public void datagridbudget(UserWageViewDto userWage,HttpServletRequest request, HttpServletResponse response, DataGrid dataGrid) {
  1740. List<Map<String,Object>> retList = getWageAndBudgetList(userWage);
  1741. dataGrid.setResults(retList);
  1742. TagUtil.datagrid(response, dataGrid);
  1743. }
  1744. private List<Map<String,Object>> getWageAndBudgetList(UserWageViewDto userWage) {
  1745. List<Map<String,Object>> retList = new ArrayList<Map<String,Object>>();
  1746. String year = userWage.getMonthly().substring(0,4);
  1747. int monthInt = Integer.valueOf(userWage.getMonthly().substring(5));
  1748. String month = "month"+monthInt;
  1749. String qrySql = "select '"+userWage.getMonthly()+"' as yearmonth, \n" +
  1750. " wage.*,\n" +
  1751. " IFNULL(budget.projovertimebudget,0) as projovertimebudget,\n" +
  1752. " IFNULL(budget.govovertimebudget,0) as govovertimebudget,\n" +
  1753. " IFNULL(budget.ondutybudget,0) as ondutybudget\n" +
  1754. "from (\n" +
  1755. " SELECT \n" +
  1756. " sum(c.overtimepay_timeout+c.special_overtime) as projovertime, \n" +
  1757. " sum(c.duty) as onduty, \n" +
  1758. " sum(c.overtimepay_Fixed) as govovertime, \n" +
  1759. " d.id as departid,\n" +
  1760. " d.departname AS departname\n" +
  1761. " FROM\n" +
  1762. " t_bus_user_wage c\n" +
  1763. " LEFT JOIN t_s_base_user u ON c.userid = u.id\n" +
  1764. " LEFT JOIN t_s_depart d ON d.id = c.pjt_id\n" +
  1765. " WHERE u.delete_flag = '0' \n" +
  1766. " and monthly =? \n" +
  1767. " group BY\n" +
  1768. " d.id) wage\n" +
  1769. "left join (\n" +
  1770. " select \n" +
  1771. " depart_id as departid,\n" +
  1772. " dep_name as departname ,\n" +
  1773. " sum(case when budget_type = 'code1' then "+month+" else 0 end) as projovertimebudget ,\n" +
  1774. " sum(case when budget_type = 'code2' then "+month+" else 0 end ) as govovertimebudget ,\n" +
  1775. " sum(case when budget_type = 'code3' or budget_type = 'code4' then "+month+" else 0 end ) as ondutybudget \n" +
  1776. " from t_b_overtime_budget\n" +
  1777. " where years =? \n" +
  1778. " group by depart_id ) budget on budget.departid = wage.departid "
  1779. + "left join t_s_depart t on t.id = wage.departid "
  1780. + "where t.org_type in ('3','5') ";
  1781. if(StringUtils.isNotEmpty(userWage.getPjtId())) {
  1782. qrySql +=" and wage.departid = '"+userWage.getPjtId()+"' order by CONVERT(wage.departname using gbk)";
  1783. }else {
  1784. qrySql +=" order by CONVERT(wage.departname using gbk)";
  1785. }
  1786. retList = systemService.findForJdbc(qrySql, userWage.getMonthly(),year);
  1787. return retList;
  1788. }
  1789. @RequestMapping(params = "exportXlsBudget")
  1790. public void exportXlsBudget(UserWageViewDto userWage,HttpServletRequest request,HttpServletResponse response
  1791. , DataGrid dataGrid,ModelMap modelMap) {
  1792. List<Map<String,Object>> retList = getWageAndBudgetList(userWage);
  1793. String codedFileName = "加班预算执行表";
  1794. Workbook workbook = null;
  1795. List<ExcelExportEntity> entityList = new ArrayList<ExcelExportEntity>();
  1796. ExcelExportEntity head1 = new ExcelExportEntity("项目管理处", "departname", 30);
  1797. entityList.add(head1);
  1798. ExcelExportEntity head2 = new ExcelExportEntity("工资月度", "yearmonth", 15);
  1799. entityList.add(head2);
  1800. ExcelExportEntity head3 = new ExcelExportEntity("项目加班费预算", "projovertimebudget", 15);
  1801. entityList.add(head3);
  1802. ExcelExportEntity head4 = new ExcelExportEntity("项目加班费发生额", "projovertime", 15);
  1803. entityList.add(head4);
  1804. ExcelExportEntity head5 = new ExcelExportEntity("国定加班费预算", "govovertimebudget", 15);
  1805. entityList.add(head5);
  1806. ExcelExportEntity head6 = new ExcelExportEntity("国定加班费发生额", "govovertime", 15);
  1807. entityList.add(head6);
  1808. ExcelExportEntity head7 = new ExcelExportEntity("值班费预算", "ondutybudget", 15);
  1809. entityList.add(head7);
  1810. ExcelExportEntity head8 = new ExcelExportEntity("值班费发生额", "onduty", 15);
  1811. entityList.add(head8);
  1812. List<Map<String, Object>> resultData = retList;
  1813. workbook = ExcelExportUtil.exportExcel(workbook,
  1814. new ExportParams("加班预算执行表", "导出人:" + ResourceUtil.getSessionUser().getRealName(), "加班预算执行表"),
  1815. entityList, resultData);
  1816. if (workbook instanceof HSSFWorkbook) {
  1817. codedFileName +=".xls";
  1818. } else {
  1819. codedFileName +=".xlsx";
  1820. }
  1821. try {
  1822. //IE
  1823. if (request.getHeader("USER-AGENT").toLowerCase().indexOf("msie") > 0
  1824. || request.getHeader("USER-AGENT").toLowerCase().indexOf("rv:11.0") > 0){
  1825. codedFileName = java.net.URLEncoder.encode(codedFileName, "UTF8");
  1826. } else {
  1827. codedFileName = new String(codedFileName.getBytes("UTF-8"), "ISO-8859-1");
  1828. }
  1829. response.setHeader("content-disposition", "attachment;filename=" + codedFileName);
  1830. ServletOutputStream out = response.getOutputStream();
  1831. workbook.write(out);
  1832. out.flush();
  1833. } catch (UnsupportedEncodingException e) {
  1834. logger.error(e.getMessage());
  1835. } catch (IOException e) {
  1836. logger.error(e.getMessage());
  1837. }
  1838. }
  1839. /**
  1840. * 一线员工未排班,不能修改工资条
  1841. * */
  1842. @RequestMapping(params = "checkRowEdit")
  1843. @ResponseBody
  1844. public AjaxJson checkRowEdit(UserwagePage page) throws Exception{
  1845. AjaxJson j = new AjaxJson();
  1846. List<UserWageEntity> userwages=page.getUserWageList();
  1847. String usernames = "";
  1848. for (UserWageEntity userWage : userwages) {
  1849. userWage = systemService.get(UserWageEntity.class,userWage.getId());
  1850. String userid = userWage.getUserid();
  1851. String deptid = userWage.getPjtId();
  1852. String month = userWage.getMonthly();
  1853. if(!UserUtil.isProjectUser(userid))
  1854. continue;
  1855. //查看是否排班
  1856. String arrangeSql = "select count(*) from t_bus_projarrange_detail where userid =? and yearmonth =? and pid = ?";
  1857. Map<String,Object> arrangeCountRet = systemService.findOneForJdbc(arrangeSql, userid,month,deptid);
  1858. int count = Integer.valueOf(arrangeCountRet.get("count(*)").toString());
  1859. if(count == 0) {
  1860. usernames += systemService.get(TSUser.class, userid).getRealName()+"<br>";
  1861. }
  1862. }
  1863. if(StringUtils.isNotEmpty(usernames)) {
  1864. j.setSuccess(false);
  1865. j.setMsg("以下员工未排班,不能修改工资:<br>"+usernames);
  1866. }
  1867. return j;
  1868. }
  1869. }