| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988 |
- package cn.com.lzt.userwage.controller;
- import cn.com.lzt.arrangeduty.dto.ProjectDepartDto;
- import cn.com.lzt.common.dto.VisibleUserDto;
- import cn.com.lzt.common.service.DataPermissionServiceI;
- import cn.com.lzt.common.util.UserUtil;
- import cn.com.lzt.dialogDeal.service.UserDepartOrgDealServiceI;
- import cn.com.lzt.dingattendanceinfo.entity.DingAttendanceinfoEntity;
- import cn.com.lzt.useroptions.entity.TBusUserOptionsEntity;
- import cn.com.lzt.useroptions.service.TBusUserOptionsServiceI;
- import cn.com.lzt.userwage.dto.UserWageDetaillsDto;
- import cn.com.lzt.userwage.dto.UserWageDto;
- import cn.com.lzt.userwage.dto.UserWagePaperDto;
- import cn.com.lzt.userwage.dto.UserWageViewDto;
- import cn.com.lzt.userwage.entity.UserWageEntity;
- import cn.com.lzt.userwage.entity.UserwagePage;
- import cn.com.lzt.userwage.service.UserWageServiceI;
- import cn.com.lzt.userwagestrategyhistory.entity.UserWagestrategyHistoryEntity;
- import org.apache.commons.collections.CollectionUtils;
- import org.apache.commons.lang.StringUtils;
- import org.apache.ibatis.annotations.Param;
- import org.apache.log4j.Logger;
- import org.apache.poi.hssf.usermodel.HSSFWorkbook;
- import org.apache.poi.ss.usermodel.Workbook;
- import org.jeecgframework.core.beanvalidator.BeanValidators;
- import org.jeecgframework.core.common.controller.BaseController;
- import org.jeecgframework.core.common.exception.BusinessException;
- import org.jeecgframework.core.common.model.json.AjaxJson;
- import org.jeecgframework.core.common.model.json.DataGrid;
- import org.jeecgframework.core.constant.Globals;
- import org.jeecgframework.core.util.*;
- import org.jeecgframework.minidao.pojo.MiniDaoPage;
- import org.jeecgframework.poi.excel.ExcelExportUtil;
- import org.jeecgframework.poi.excel.ExcelImportUtil;
- import org.jeecgframework.poi.excel.annotation.Excel;
- import org.jeecgframework.poi.excel.entity.ExportParams;
- import org.jeecgframework.poi.excel.entity.ImportParams;
- import org.jeecgframework.poi.excel.entity.params.ExcelExportEntity;
- import org.jeecgframework.poi.excel.entity.vo.NormalExcelConstants;
- import org.jeecgframework.tag.core.easyui.TagUtil;
- import org.jeecgframework.web.system.pojo.base.TSBaseUser;
- import org.jeecgframework.web.system.pojo.base.TSDepart;
- import org.jeecgframework.web.system.pojo.base.TSUser;
- import org.jeecgframework.web.system.pojo.base.TSUserOrg;
- import org.jeecgframework.web.system.service.SystemService;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.http.HttpHeaders;
- import org.springframework.http.HttpStatus;
- import org.springframework.http.MediaType;
- import org.springframework.http.ResponseEntity;
- import org.springframework.stereotype.Controller;
- import org.springframework.ui.ModelMap;
- import org.springframework.web.bind.annotation.*;
- import org.springframework.web.multipart.MultipartFile;
- import org.springframework.web.multipart.MultipartHttpServletRequest;
- import org.springframework.web.servlet.ModelAndView;
- import org.springframework.web.util.UriComponentsBuilder;
- import javax.servlet.ServletOutputStream;
- import javax.servlet.http.HttpServletRequest;
- import javax.servlet.http.HttpServletResponse;
- import javax.servlet.http.HttpSession;
- import javax.validation.ConstraintViolation;
- import javax.validation.Validator;
- import java.beans.PropertyDescriptor;
- import java.io.IOException;
- import java.io.UnsupportedEncodingException;
- import java.lang.reflect.Field;
- import java.lang.reflect.InvocationTargetException;
- import java.lang.reflect.Method;
- import java.math.BigDecimal;
- import java.net.URI;
- import java.text.ParseException;
- import java.util.*;
- /**
- * @Title: Controller
- * @Description: 员工工资核算表
- * @author onlineGenerator
- * @date 2017-10-26 18:36:30
- * @version V1.0
- *
- */
- @Controller
- @RequestMapping("/userWageController")
- public class UserWageController extends BaseController {
- /**
- * Logger for this class
- */
- private static final Logger logger = Logger.getLogger(UserWageController.class);
- @Autowired
- private UserWageServiceI userWageService;
- @Autowired
- private SystemService systemService;
- @Autowired
- private Validator validator;
-
- @Autowired
- private DataPermissionServiceI dataPermissionService;
-
- @Autowired
- private UserDepartOrgDealServiceI userDepartOrgDealService;
-
- @Autowired
- private TBusUserOptionsServiceI userOptionsService;
- /**
- * 得到上个月的年月
- * @return
- */
- private String getMonthlys(){
- Calendar cal = Calendar.getInstance();
- int year = cal.get(Calendar.YEAR);
- int month = cal.get(Calendar.MONTH);
- if(month < 10){
- if(month == 0){
- year = year - 1;
- month = 12;
- }else{
- // month = Integer.valueOf(0+""+month);
- return year + "-" + 0 + "" + month;
- }
- }
- return year+"-"+month;
- }
- /**
- * 员工工资核算表列表 页面跳转
- *
- * @return
- */
- @RequestMapping(params = "list")
- public ModelAndView list(HttpServletRequest request) {
- HttpSession session = ContextHolderUtils.getSession();
- TSUser tuser = (TSUser)session.getAttribute("LOCAL_CLINET_USER");
- String departid = "";
- String departname = "";
-
- try {
- TBusUserOptionsEntity options = userOptionsService.getOptionsByUserID(tuser.getId(), Globals.USER_OPTIONS_TYPE_PROJECT, false);
- if(options != null) {
- departid = options.getOptionId();
- departname = options.getOptionName();
- }
- } catch (Exception e) {
- e.printStackTrace();
- org.jeecgframework.core.util.LogUtil.error(e.getMessage());
- }
-
- if (oConvertUtils.isNotEmpty(departid)) {
- request.setAttribute("departid", departid);
- request.setAttribute("departname", departname);
- }
- request.setAttribute("monthlys", getMonthlys());
- return new ModelAndView("cn/com/lzt/userwage/userWageList");
- }
-
- /**
- * 员工工资核算表列表 页面跳转
- *
- * @return
- */
- @RequestMapping(params = "listView")
- public ModelAndView listView(HttpServletRequest request) {
- String orgid = request.getParameter("orgid");
- String monthly = request.getParameter("monthly");
- if(oConvertUtils.isNotEmpty(monthly)){
- request.setAttribute("monthlys", monthly);
- request.setAttribute("orgid", orgid);
- }else{
- request.setAttribute("monthlys", getMonthlys());
- }
- return new ModelAndView("cn/com/lzt/userwage/userWageViewList");
- }
- @RequestMapping(params = "logrp")
- public ModelAndView logrp(@Param("id") String id,HttpServletRequest request){
- if(StringUtils.isNotEmpty(id)){
- UserWageEntity userWage = systemService.get(UserWageEntity.class, id);
- TSBaseUser tsBaseUser = systemService.get(TSBaseUser.class, userWage.getUserid());
- request.setAttribute("realname", tsBaseUser.getRealName());
- if(userWage != null){
- //systemService.get
- StringBuffer hql = new StringBuffer("from UserWagestrategyHistoryEntity where userid =? and strategyMonth = ? ");
- List<UserWagestrategyHistoryEntity> userList = systemService.findHql(hql.toString(),userWage.getUserid(),userWage.getMonthly());
- //List<UserWagestrategyHistoryEntity> userList = systemService.findListbySql("select * from t_bus_user_wagestrategy_history where userid = '"+userWage.getUserid()+"' and strategy_month = '"+userWage.getMonthly()+"'");
- if(!userList.isEmpty() && userList.size() > 0){
- // System.out.println(JSONObject.toJSONString(userList.get(0)));
- request.setAttribute("userwh", userList.get(0));
- }else{
- request.setAttribute("userwh",new UserWagestrategyHistoryEntity());
- }
- }
- }
- return new ModelAndView("cn/com/lzt/userwage/userwagestrategy-view");
- }
-
- @RequestMapping(params = "goview")
- public ModelAndView goView(@Param("belongUnitname") String belongUnitname,@Param("id") String id,@Param("monthly")String monthly,@Param("type")String type, HttpServletRequest request){
- request.setAttribute("id", id);
- TSDepart depart = systemService.get(TSDepart.class, id);
- if(depart != null) {
- request.setAttribute("belongUnitname",depart.getDepartname());
- }
- request.setAttribute("monthly", monthly);
- request.setAttribute("monthlys",monthly);
- request.setAttribute("type",type);
- return new ModelAndView("cn/com/lzt/userwage/userWageEditList");
- }
-
- /**
- * 直接打开工资编辑
- * @param belongUnitname
- * @param id
- * @param monthly
- * @param type
- * @param request
- * @return
- */
- @RequestMapping(params = "editList")
- public ModelAndView editList(@Param("belongUnitname") String belongUnitname,@Param("id") String id,@Param("monthly")String monthly,@Param("type")String type, HttpServletRequest request){
- // request.setAttribute("id", id);
- // TSDepart depart = systemService.get(TSDepart.class, id);
- // if(depart != null) {
- // request.setAttribute("belongUnitname",depart.getDepartname());
- // }
- // request.setAttribute("monthly", monthly);
- // request.setAttribute("monthlys",monthly);
- // request.setAttribute("type",type);
- return new ModelAndView("cn/com/lzt/userwage/userWageEditList");
- }
-
- /**
- * 所有项目(部门)选择弹窗页面跳转路径
- * 列表页弹窗
- * @author liujie
- * 2017-12-13
- * @param request
- * @return
- */
- @RequestMapping(params = "projectDepartTableAll")
- public ModelAndView projectDepartTableAll(HttpServletRequest request) {
- //return new ModelAndView("cn/com/lzt/arrangeduty/dutyMealTable");
- ModelAndView mv = new ModelAndView("cn/com/lzt/userwage/projectDepartTableAll");
- String ids = oConvertUtils.getString(request.getParameter("ids"));
- mv.addObject("ids", ids);
- return mv;
-
- }
-
- /**
- * 项目(部门)选择弹窗列表数据
- * @author liujie
- * 2017-11-15
- * @param projectDepartDto
- * @param request
- * @param response
- * @param dataGrid
- */
- @RequestMapping(params = "projectDepartDatagridAll")
- public void projectDepartDatagridAll(ProjectDepartDto projectDepartDto, HttpServletRequest request, HttpServletResponse response, DataGrid dataGrid) {
- TSUser tSUser=ResourceUtil.getSessionUser();
- List<ProjectDepartDto> projectDepartDtoList=userWageService.getProjectDepartAll(projectDepartDto,tSUser.getId());
- dataGrid.setResults(projectDepartDtoList);
- TagUtil.datagrid(response, dataGrid);
- }
-
- /**
- * 员工工资核算表列表 页面跳转
- *
- * @return
- */
- @RequestMapping(params = "listDetails")
- public ModelAndView listDetails(@Param("realname") String realname,@Param("belongBank") String belongBank,@Param("pid") String pid,@Param("monthly")String monthly,HttpServletRequest request) {
- request.setAttribute("monthlys", getMonthlys());
- request.setAttribute("monthly", monthly);
- request.setAttribute("orgid", pid);
- request.setAttribute("realname", realname);
- request.setAttribute("belongBank", belongBank);
-
- return new ModelAndView("cn/com/lzt/userwage/userWageDetailsList");
- }
-
- /**
- * 员工月度工资明细表格
- *
- * @param request
- * @param response
- * @param dataGrid
- * @throws ParseException
- */
- @RequestMapping(params = "datagrid")
- public void datagrid(UserWageDto userWage,HttpServletRequest request, HttpServletResponse response, DataGrid dataGrid) throws ParseException {
- String monthlys = request.getParameter("monthlys");
- String monthly = request.getParameter("monthly");
- String realname = request.getParameter("realname");
- String belongBank = request.getParameter("belongBank");
- String orgIds = request.getParameter("orgIds");
- String orgId = request.getParameter("orgid");
- String type = request.getParameter("type");
- if(oConvertUtils.isEmpty(monthlys) && oConvertUtils.isEmpty(monthly)){
- dataGrid.setResults(new ArrayList<UserWageDto>());
- dataGrid.setFooter("");
- TagUtil.datagrid(response, dataGrid);
- return;
- }
- // if(oConvertUtils.isEmpty(orgIds) && oConvertUtils.isEmpty(orgIds)){
- // dataGrid.setResults(new ArrayList<UserWageDto>());
- // dataGrid.setFooter("");
- // TagUtil.datagrid(response, dataGrid);
- // return;
- // }
- if(realname != null) {
- userWage.setRealname(realname);
- }
- if(belongBank != null) {
- userWage.setBelongBank(belongBank);
- }
- MiniDaoPage<UserWageDto> list = null;
- if(oConvertUtils.isNotEmpty(monthlys) || oConvertUtils.isNotEmpty(monthly)){
- if(StringUtils.isEmpty(orgIds)&&StringUtils.isNotEmpty(orgId)){
- List<String> orgIdList = extractIdListByComma(orgId);
- // 获取 当前组织机构的用户信息
- if (!CollectionUtils.isEmpty(orgIdList)) {
- if(oConvertUtils.isNotEmpty(type) && "1".equals(type)){
- userWage.setOrgIdList(orgIdList);
- }else{
- String or = orgIdList.get(0);
- List<String> ChildIdList = userDepartOrgDealService.getChildIdByProjectDepartId(or);
- userWage.setOrgIdList(ChildIdList);
- }
- }
- }else{
- if(StringUtils.isNotEmpty(orgIds)){
- List<String> orgIdList = extractIdListByComma(orgIds);
- // 获取 当前组织机构的用户信息
- if (!CollectionUtils.isEmpty(orgIdList)) {
- String or = orgIdList.get(0);
- List<String> ChildIdList = userDepartOrgDealService.getChildIdByProjectDepartId(or);
- userWage.setOrgIdList(ChildIdList);
- }
- }
- }
-
- if(StringUtils.isNotEmpty(monthlys)){
- userWage.setMonthly(monthlys);
- }else{
- if(StringUtils.isNotEmpty(monthly)){
- request.setAttribute("monthlys", monthly);
- userWage.setMonthly(monthly);
- }else{
- request.setAttribute("monthlys", getMonthlys());
- userWage.setMonthly(getMonthlys());
- }
- //userWage.setMonthly(sim.format(sim.parse("2017-10")));
- }
-
- String authSql = JeecgDataAutorUtils.loadDataSearchConditonSQLString();
-
- VisibleUserDto dto = dataPermissionService.getVisibleUserList();// 获取当前用户可见的userid列表
- if(dto != null){
- if(dto.getFlag().value().equalsIgnoreCase("ALL")){
- list = userWageService.getPagedEntities(userWage,null,null,dataGrid.getPage(), dataGrid.getRows(), authSql);
- // map = userWageService.getMoneySUM(userWage,null,moth);
- }else if(dto.getFlag().value().equalsIgnoreCase("NONE")){
- // 获取当前登录用户
- HttpSession session = ContextHolderUtils.getSession();
- TSUser user = (TSUser)session.getAttribute("LOCAL_CLINET_USER");
- List<String> uidList = new ArrayList<String>();
- uidList.add(user.getId());
- list = userWageService.getPagedEntities(userWage,uidList,null,dataGrid.getPage(), dataGrid.getRows(), authSql);
- // map = userWageService.getMoneySUM(userWage,uidList,moth);
- }else if(dto.getFlag().value().equalsIgnoreCase("PART")){
- List<String> useridList = dto.getUseridList();
- if(useridList != null && useridList.size() > 0){
- list = userWageService.getPagedEntities(userWage,useridList,null,dataGrid.getPage(), dataGrid.getRows(), authSql);
- // map = userWageService.getMoneySUM(userWage,useridList,moth);
- }
- }
- }
- // 为了提高效率,人事部门不做工资权限限制. 20170628 xzx
-
- // UserWageDto> list = userWageService.getAll(userWage,authSql);
- if(list != null && !list.getResults().isEmpty()){
- for (Iterator iterator = list.getResults().iterator(); iterator.hasNext();) {
- UserWageDto userWageDto = (UserWageDto) iterator.next();
- if (oConvertUtils.isEmpty(userWageDto.getId())) {
- userWageDto.setId("temp"+UUIDGenerator.generate());
- }
- if(StringUtils.isNotEmpty(userWage.getStatus())){
- if(StringUtils.isEmpty(userWageDto.getMonthly())){
- iterator.remove();
- }
- }
- if(StringUtils.isEmpty(userWageDto.getMonthly())){
- userWageDto.setBelongUnitName(getBybelongId(userWageDto.getUserids()));
- }
- }
- Collections.sort(list.getResults());
- dataGrid.setResults(list.getResults());
- dataGrid.setTotal(list.getTotal());
- }
- // List<UserWageDto> list = new ArrayList<UserWageDto>();
- // Map<String,Integer> map = new HashMap<String,Integer>();
- // if(dto.getFlag().value().equalsIgnoreCase("ALL")){
- // list = userWageService.getAllEntities(userWage,null,null,authSql);
- // map = userWageService.getMoneySUM(userWage,null,null);
- // }else if(dto.getFlag().value().equalsIgnoreCase("NONE")){
- // // 获取当前登录用户
- // HttpSession session = ContextHolderUtils.getSession();
- // TSUser user = (TSUser)session.getAttribute("LOCAL_CLINET_USER");
- // List<String> uidList = new ArrayList<String>();
- // uidList.add(user.getId());
- // list = userWageService.getAllEntities(userWage,uidList,null,authSql);
- // map = userWageService.getMoneySUM(userWage,uidList,null);
- // }else if(dto.getFlag().value().equalsIgnoreCase("PART")){
- // List<String> useridList = dto.getUseridList();
- // if(useridList != null && useridList.size() > 0){
- // list = userWageService.getAllEntities(userWage,useridList,null,authSql);
- // map = userWageService.getMoneySUM(userWage,useridList,null);
- // }
- // }
- Map<String,BigDecimal> map = new HashMap<String,BigDecimal>();
- //代码层计算合计,不通过sql计算
- try {
- calcuSumMap(map,list.getResults());
- } catch (Exception e) {
- e.printStackTrace();
- }
- StringBuffer str = new StringBuffer();
-
- for(String key : map.keySet()) {
- String value = map.get(key) == null ? "0.00" : map.get(key).toString();
- str.append(key).append(":").append(value).append(",");
- }
-
- // //List<UserWageDto> list = userWageService.getAllEntities(userWage,authSql);
- // dataGrid.setResults(list);
- // //Map<String,Integer> map = userWageService.getMoneySUM(userWage,null);
- //
- // StringBuffer str = new StringBuffer();
- // str.append("basicWage:"+(String.valueOf(map.get("basic_wage")).equalsIgnoreCase("null")?"0.00":String.valueOf(map.get("basic_wage")))+",");
- // str.append("dutiesAllowance:"+(String.valueOf(map.get("duties_allowance")).equalsIgnoreCase("null")?"0.00":String.valueOf(map.get("duties_allowance")))+",");
- // str.append("certificateSubsidy:"+(String.valueOf(map.get("certificate_subsidy")).equalsIgnoreCase("null")?"0.00":String.valueOf(map.get("certificate_subsidy")))+",");
- // str.append("trafficSubsidy:"+(String.valueOf(map.get("traffic_subsidy")).equalsIgnoreCase("null")?"0.00":String.valueOf(map.get("traffic_subsidy")))+",");
- // str.append("megathermalSubsidy:"+(String.valueOf(map.get("megathermal_subsidy")).equalsIgnoreCase("null")?"0.00":String.valueOf(map.get("megathermal_subsidy")))+",");
- // str.append("onlyChildCost:"+(String.valueOf(map.get("only_child_cost")).equalsIgnoreCase("null")?"0.00":String.valueOf(map.get("only_child_cost")))+",");
- // str.append("otherSubsidy:"+(String.valueOf(map.get("other_subsidy")).equalsIgnoreCase("null")?"0.00":String.valueOf(map.get("other_subsidy")))+",");
- // str.append("bonus:"+(String.valueOf(map.get("bonus")).equalsIgnoreCase("null")?"0.00":String.valueOf(map.get("bonus")))+",");
- // str.append("projectPerformance:"+(String.valueOf(map.get("project_performance")).equalsIgnoreCase("null")?"0.00":String.valueOf(map.get("project_performance")))+",");
- // str.append("mealsSubsidyDay:"+(String.valueOf(map.get("meals_subsidy_day")).equalsIgnoreCase("null")?"0.00":String.valueOf(map.get("meals_subsidy_day")))+",");
- // str.append("mealsSubsidyNight:"+(String.valueOf(map.get("meals_subsidy_night")).equalsIgnoreCase("null")?"0.00":String.valueOf(map.get("meals_subsidy_night")))+",");
- // str.append("mealsSubsidy:"+(String.valueOf(map.get("meals_subsidy")).equalsIgnoreCase("null")?"0.00":String.valueOf(map.get("meals_subsidy")))+",");
- // str.append("overtimepayTimeout:"+(String.valueOf(map.get("overtimepay_timeout")).equalsIgnoreCase("null")?"0.00":String.valueOf(map.get("overtimepay_timeout")))+",");
- // str.append("overtimepayFixed:"+(String.valueOf(map.get("overtimepay_fixed")).equalsIgnoreCase("null")?"0.00":String.valueOf(map.get("overtimepay_fixed")))+",");
- // str.append("duty:"+(String.valueOf(map.get("duty")).equalsIgnoreCase("null")?"0.00":String.valueOf(map.get("duty")))+",");
- // str.append("specialOvertime:"+(String.valueOf(map.get("special_overtime")).equalsIgnoreCase("null")?"0.00":String.valueOf(map.get("special_overtime")))+",");
- // str.append("sickLeaveDebit:"+(String.valueOf(map.get("sick_leave_debit")).equalsIgnoreCase("null")?"0.00":String.valueOf(map.get("sick_leave_debit")))+",");
- // str.append("thingLeaveDebit:"+(String.valueOf(map.get("thing_leave_debit")).equalsIgnoreCase("null")?"0.00":String.valueOf(map.get("thing_leave_debit")))+",");
- // str.append("absenceDebit:"+(String.valueOf(map.get("absence_debit")).equalsIgnoreCase("null")?"0.00":String.valueOf(map.get("absence_debit")))+",");
- // str.append("paymentSubsidy:"+(String.valueOf(map.get("payment_subsidy")).equalsIgnoreCase("null")?"0.00":String.valueOf(map.get("payment_subsidy")))+",");
- // str.append("socialSecurityDebit:"+(String.valueOf(map.get("social_security_debit")).equalsIgnoreCase("null")?"0.00":String.valueOf(map.get("social_security_debit")))+",");
- // str.append("providentFundDebit:"+(String.valueOf(map.get("provident_fund_debit")).equalsIgnoreCase("null")?"0.00":String.valueOf(map.get("provident_fund_debit")))+",");
- // str.append("preTaxMone:"+(String.valueOf(map.get("pre_tax_mone")).equalsIgnoreCase("null")?"0.00":String.valueOf(map.get("pre_tax_mone")))+",");
- // str.append("otherDebit:"+(String.valueOf(map.get("other_debit")).equalsIgnoreCase("null")?"0.00":String.valueOf(map.get("other_debit")))+",");
- // str.append("reissue:"+(String.valueOf(map.get("reissue")).equalsIgnoreCase("null")?"0.00":String.valueOf(map.get("reissue")))+",");
- // str.append("taxMoney:"+(String.valueOf(map.get("tax_money")).equalsIgnoreCase("null")?"0.00":String.valueOf(map.get("tax_money")))+",");
- // str.append("actualMoney:"+(String.valueOf(map.get("actual_money")).equalsIgnoreCase("null")?"0.00":String.valueOf(map.get("actual_money"))));
- // dataGrid.setFooter(str.toString());
- // }
- dataGrid.setFooter(str.toString());
- }
- if(list == null || list.getResults() == null || list.getResults().size() == 0){
- dataGrid.setResults(new ArrayList<UserWageDto>());
- dataGrid.setFooter("");
- }
- TagUtil.datagrid(response, dataGrid);
- }
- /**
- * 月度工资一览的表格数据
- *
- * @param request
- * @param response
- * @param dataGrid
- */
- @RequestMapping(params = "datagrid1")
- public void datagrid1(UserWageViewDto userWage,HttpServletRequest request, HttpServletResponse response, DataGrid dataGrid) {
- String monthlys = request.getParameter("monthlys");
- if(oConvertUtils.isNotEmpty(monthlys)){
- String orgIds = request.getParameter("orgIds");
- List<String> orgIdList = extractIdListByComma(orgIds);
- // 获取 当前组织机构的用户信息
- if (!CollectionUtils.isEmpty(orgIdList)) {
- String or = orgIdList.get(0);
- List<String> ChildIdList = userDepartOrgDealService.getChildIdByProjectDepartId(or);
- userWage.setOrgIdList(ChildIdList);
- }
-
- userWage.setMonthly(monthlys);
-
- String authSql = JeecgDataAutorUtils.loadDataSearchConditonSQLString();
-
- VisibleUserDto dto = dataPermissionService.getVisibleUserList();// 获取当前用户可见的userid列表
- if(dto != null){
- MiniDaoPage<UserWageViewDto> list = new MiniDaoPage<UserWageViewDto>();
- Map<String,Integer> map = new HashMap<String,Integer>();
- list = userWageService.getViewEntities(userWage,null,dataGrid.getPage(), dataGrid.getRows(), authSql);
- map = userWageService.getMoneyViewSUM(userWage,null);
- // if(dto.getFlag().value().equalsIgnoreCase("ALL")){
- // list = userWageService.getViewEntities(userWage,null,dataGrid.getPage(), dataGrid.getRows(), authSql);
- // map = userWageService.getMoneyViewSUM(userWage,null);
- // }else if(dto.getFlag().value().equalsIgnoreCase("NONE")){
- // // 获取当前登录用户
- // HttpSession session = ContextHolderUtils.getSession();
- // TSUser user = (TSUser)session.getAttribute("LOCAL_CLINET_USER");
- // List<String> uidList = new ArrayList<String>();
- // uidList.add(user.getId());
- // list = userWageService.getViewEntities(userWage,uidList,dataGrid.getPage(), dataGrid.getRows(), authSql);
- // map = userWageService.getMoneyViewSUM(userWage,uidList);
- // }else if(dto.getFlag().value().equalsIgnoreCase("PART")){
- // List<String> useridList = dto.getUseridList();
- // if(useridList != null && useridList.size() > 0){
- // list = userWageService.getViewEntities(userWage,useridList,dataGrid.getPage(), dataGrid.getRows(), authSql);
- // map = userWageService.getMoneyViewSUM(userWage,useridList);
- // }
- // }
- //MiniDaoPage<UserWageViewDto> list = userWageService.getViewEntities(userWage, dataGrid.getPage(), dataGrid.getRows(), authSql);
- dataGrid.setResults(list.getResults());
- //Map<String,Integer> map = userWageService.getMoneyViewSUM(userWage);
-
- StringBuffer str = new StringBuffer();
- str.append("sumcount:"+(String.valueOf(map.get("sumcount")).equalsIgnoreCase("null")?"0.00":String.valueOf(map.get("sumcount")))+",");
- str.append("basicWage:"+(String.valueOf(map.get("basic_wage")).equalsIgnoreCase("null")?"0.00":String.valueOf(map.get("basic_wage")))+",");
- str.append("dutiesAllowance:"+(String.valueOf(map.get("duties_allowance")).equalsIgnoreCase("null")?"0.00":String.valueOf(map.get("duties_allowance")))+",");
- str.append("certificateSubsidy:"+(String.valueOf(map.get("certificate_subsidy")).equalsIgnoreCase("null")?"0.00":String.valueOf(map.get("certificate_subsidy")))+",");
- str.append("projectPerformance:"+(String.valueOf(map.get("project_performance")).equalsIgnoreCase("null")?"0.00":String.valueOf(map.get("project_performance")))+",");
- str.append("mealsSubsidy:"+(String.valueOf(map.get("meals_subsidy")).equalsIgnoreCase("null")?"0.00":String.valueOf(map.get("meals_subsidy")))+",");
- str.append("specialOvertime:"+(String.valueOf(map.get("special_overtime")).equalsIgnoreCase("null")?"0.00":String.valueOf(map.get("special_overtime")))+",");
- str.append("absenceDebit:"+(String.valueOf(map.get("absence_debit")).equalsIgnoreCase("null")?"0.00":String.valueOf(map.get("absence_debit")))+",");
- str.append("paymentSubsidy:"+(String.valueOf(map.get("payment_subsidy")).equalsIgnoreCase("null")?"0.00":String.valueOf(map.get("payment_subsidy")))+",");
- str.append("deductions:"+(String.valueOf(map.get("deductions")).equalsIgnoreCase("null")?"0.00":String.valueOf(map.get("deductions")))+",");
- str.append("comDeductions:"+(String.valueOf(map.get("comDeductions")).equalsIgnoreCase("null")?"0.00":String.valueOf(map.get("comDeductions")))+",");
- str.append("comCost:"+(String.valueOf(map.get("comCost")).equalsIgnoreCase("null")?"0.00":String.valueOf(map.get("comCost")))+",");
-
- str.append("preTaxMone:"+(String.valueOf(map.get("pre_tax_mone")).equalsIgnoreCase("null")?"0.00":String.valueOf(map.get("pre_tax_mone")))+",");
- str.append("daikouDebit:"+(String.valueOf(map.get("daikouDebit")).equalsIgnoreCase("null")?"0.00":String.valueOf(map.get("daikouDebit")))+",");
- str.append("otherDebit:"+(String.valueOf(map.get("other_debit")).equalsIgnoreCase("null")?"0.00":String.valueOf(map.get("other_debit")))+",");
- str.append("reissue:"+(String.valueOf(map.get("reissue")).equalsIgnoreCase("null")?"0.00":String.valueOf(map.get("reissue")))+",");
- str.append("taxMoney:"+(String.valueOf(map.get("tax_money")).equalsIgnoreCase("null")?"0.00":String.valueOf(map.get("tax_money")))+",");
- str.append("actualMoney:"+(String.valueOf(map.get("actual_money")).equalsIgnoreCase("null")?"0.00":String.valueOf(map.get("actual_money"))));
- dataGrid.setFooter(str.toString());
- }
- }else{
- dataGrid.setResults(new ArrayList<UserWageViewDto>());
- dataGrid.setFooter("");
- }
- TagUtil.datagrid(response, dataGrid);
- }
-
- /**
- * easyui AJAX请求数据
- *
- * @param request
- * @param response
- * @param dataGrid
- * @throws ParseException
- */
- @RequestMapping(params = "datagrid2")
- public void datagrid2(UserWageDto userWage,HttpServletRequest request, HttpServletResponse response, DataGrid dataGrid) throws ParseException {
- String monthlys = request.getParameter("monthlys");
- if(StringUtils.isNotEmpty(monthlys)){
- String orgIds = request.getParameter("orgIds");
- if(StringUtils.isNotEmpty(orgIds)){
- List<String> orgIdList = extractIdListByComma(orgIds);
- // 获取 当前组织机构的用户信息
- if (!CollectionUtils.isEmpty(orgIdList)) {
- String or = orgIdList.get(0);
- List<String> ChildIdList = userDepartOrgDealService.getChildIdByProjectDepartId(or);
- if(!ChildIdList.isEmpty()){
- List<String> ch = new ArrayList<String>();
- for (String str : ChildIdList) {
- ch.add(str);
- }
- ChildIdList = ch;
- }
- userWage.setOrgIdList(ChildIdList);
- }
- if(orgIdList != null && orgIdList.size()>0 && orgIdList.get(0)!=null &&orgIdList.get(0).length()>0) {
-
- }
- HttpSession session = ContextHolderUtils.getSession();
- TSUser tuser = (TSUser)session.getAttribute("LOCAL_CLINET_USER");
- try {
- userOptionsService.saveUserOptions(tuser.getId(), orgIdList.get(0), Globals.USER_OPTIONS_TYPE_PROJECT);
- } catch (Exception e) {
- e.printStackTrace();
- org.jeecgframework.core.util.LogUtil.error(e.getMessage());
- }
-
- }/*else{
- TSUser tSUser=ResourceUtil.getSessionUser();
- StringBuffer hql = new StringBuffer("from TSUserOrg where tsUser.id = :userid and status=0");
- List<TSUserOrg> tsList = systemService.getSession().createQuery(hql.toString()).setParameter("userid", tSUser.getId()).list();
- if(!tsList.isEmpty()){
- for (TSUserOrg tsUserOrg : tsList) {
- List<String> ChildIdList = userDepartOrgDealService.getChildIdByProjectDepartId(tsUserOrg.getTsDepart().getId());
- if(!ChildIdList.isEmpty()){
- List<String> ch = new ArrayList<String>();
- for (String str : ChildIdList) {
- if(!str.equals(tsUserOrg.getTsDepart().getId())){
- ch.add(str);
- }
- }
- ChildIdList = ch;
- }
- userWage.setOrgIdList(ChildIdList);
- }
- }
- }*/
- String moth = "";
-
- String [] mothl = monthlys.split("-");
- if("01".equals(mothl[1])){
- moth = Integer.valueOf(mothl[0])-1+"-12-01 00:00:00";
- }else{
- //moth = mothl[0]+"-"+(Integer.valueOf(mothl[1])-1)+"-01 00:00:00";
- moth = mothl[0] + "-" + "0" + (Integer.valueOf(mothl[1]) - 1) + "-01 00:00:00";
- }
-
- if(StringUtils.isNotEmpty(monthlys)){
- userWage.setMonthly(monthlys);
- }/*else{
- Calendar cal = Calendar.getInstance();
- int year = cal.get(Calendar.YEAR);
- int month = cal.get(Calendar.MONTH );
- if(month < 10){
- month = Integer.valueOf(0+""+month);
- }
- monthlys = year+"-"+month;
- request.setAttribute("monthlys", year+"-"+month);
- userWage.setMonthly(year+"-"+month);
- }*/
-
- String authSql = JeecgDataAutorUtils.loadDataSearchConditonSQLString();
- VisibleUserDto dto = dataPermissionService.getVisibleUserList();// 获取当前用户可见的userid列表
- if(dto != null){
- List<UserWageDto> list = new ArrayList<UserWageDto>();
- Map<String,BigDecimal> map = new HashMap<String,BigDecimal>();
- if(dto.getFlag().value().equalsIgnoreCase("ALL")){
- list = userWageService.getAllEntities(userWage,null,moth,authSql);
- // map = userWageService.getMoneySUM(userWage,null,moth);
- }else if(dto.getFlag().value().equalsIgnoreCase("NONE")){
- // 获取当前登录用户
- HttpSession session = ContextHolderUtils.getSession();
- TSUser user = (TSUser)session.getAttribute("LOCAL_CLINET_USER");
- List<String> uidList = new ArrayList<String>();
- uidList.add(user.getId());
- list = userWageService.getAllEntities(userWage,uidList,moth,authSql);
- // map = userWageService.getMoneySUM(userWage,uidList,moth);
- }else if(dto.getFlag().value().equalsIgnoreCase("PART")){
- List<String> useridList = dto.getUseridList();
- if(useridList != null && useridList.size() > 0){
- list = userWageService.getAllEntities(userWage,useridList,moth,authSql);
- // map = userWageService.getMoneySUM(userWage,useridList,moth);
- }
- }
-
- //List<UserWageDto> list = userWageService.getAll(userWage,authSql);
- if(!list.isEmpty()){
- for (Iterator iterator = list.iterator(); iterator.hasNext();) {
- UserWageDto userWageDto = (UserWageDto) iterator.next();
- if (oConvertUtils.isEmpty(userWageDto.getId())) {
- userWageDto.setId("temp"+UUIDGenerator.generate());
- }
- if(StringUtils.isNotEmpty(userWage.getStatus())){
- if(StringUtils.isEmpty(userWageDto.getMonthly())){
- iterator.remove();
- }
- }
- if(StringUtils.isEmpty(userWageDto.getMonthly())){
- userWageDto.setBelongUnitName(getBybelongId(userWageDto.getUserids()));
- }
- }
- /*for (UserWageDto us : list) {
- }*/
- }
- Collections.sort(list);
- dataGrid.setResults(list);
- //代码层计算合计,不通过sql计算
- try {
- calcuSumMap(map,list);
- } catch (Exception e) {
- e.printStackTrace();
- }
- StringBuffer str = new StringBuffer();
-
- for(String key : map.keySet()) {
- String value = map.get(key) == null ? "0.00" : map.get(key).toString();
- str.append(key).append(":").append(value).append(",");
- }
-
- // str.append("basicWage:"+(String.valueOf(map.get("basicWage")).equalsIgnoreCase("null")?"0.00":String.valueOf(map.get("basicWage")))+",");
- // str.append("dutiesAllowance:"+(String.valueOf(map.get("dutiesAllowance")).equalsIgnoreCase("null")?"0.00":String.valueOf(map.get("dutiesAllowance")))+",");
- // str.append("certificateSubsidy:"+(String.valueOf(map.get("certificateSubsidy")).equalsIgnoreCase("null")?"0.00":String.valueOf(map.get("certificateSubsidy")))+",");
- // str.append("trafficSubsidy:"+(String.valueOf(map.get("trafficSubsidy")).equalsIgnoreCase("null")?"0.00":String.valueOf(map.get("trafficSubsidy")))+",");
- // str.append("megathermalSubsidy:"+(String.valueOf(map.get("megathermalSubsidy")).equalsIgnoreCase("null")?"0.00":String.valueOf(map.get("megathermalSubsidy")))+",");
- // str.append("onlyChildCost:"+(String.valueOf(map.get("onlyChildCost")).equalsIgnoreCase("null")?"0.00":String.valueOf(map.get("onlyChildCost")))+",");
- // str.append("otherSubsidy:"+(String.valueOf(map.get("otherSubsidy")).equalsIgnoreCase("null")?"0.00":String.valueOf(map.get("otherSubsidy")))+",");
- // str.append("bonus:"+(String.valueOf(map.get("bonus")).equalsIgnoreCase("null")?"0.00":String.valueOf(map.get("bonus")))+",");
- // str.append("projectPerformance:"+(String.valueOf(map.get("projectPerformance")).equalsIgnoreCase("null")?"0.00":String.valueOf(map.get("projectPerformance")))+",");
- // str.append("mealsSubsidyDay:"+(String.valueOf(map.get("mealsSubsidyDay")).equalsIgnoreCase("null")?"0.00":String.valueOf(map.get("mealsSubsidyDay")))+",");
- // str.append("mealsSubsidyNight:"+(String.valueOf(map.get("mealsSubsidyNight")).equalsIgnoreCase("null")?"0.00":String.valueOf(map.get("mealsSubsidyNight")))+",");
- // str.append("mealsSubsidy:"+(String.valueOf(map.get("mealsSubsidy")).equalsIgnoreCase("null")?"0.00":String.valueOf(map.get("mealsSubsidy")))+",");
- // str.append("overtimepayTimeout:"+(String.valueOf(map.get("overtimepayTimeout")).equalsIgnoreCase("null")?"0.00":String.valueOf(map.get("overtimepayTimeout")))+",");
- // str.append("overtimepayFixed:"+(String.valueOf(map.get("overtimepayFixed")).equalsIgnoreCase("null")?"0.00":String.valueOf(map.get("overtimepayFixed")))+",");
- // str.append("duty:"+(String.valueOf(map.get("duty")).equalsIgnoreCase("null")?"0.00":String.valueOf(map.get("duty")))+",");
- // str.append("specialOvertime:"+(String.valueOf(map.get("specialOvertime")).equalsIgnoreCase("null")?"0.00":String.valueOf(map.get("specialOvertime")))+",");
- // str.append("sickLeaveDebit:"+(String.valueOf(map.get("sickLeaveDebit")).equalsIgnoreCase("null")?"0.00":String.valueOf(map.get("sickLeaveDebit")))+",");
- // str.append("thingLeaveDebit:"+(String.valueOf(map.get("thingLeaveDebit")).equalsIgnoreCase("null")?"0.00":String.valueOf(map.get("thingLeaveDebit")))+",");
- // str.append("absenceDebit:"+(String.valueOf(map.get("absenceDebit")).equalsIgnoreCase("null")?"0.00":String.valueOf(map.get("absenceDebit")))+",");
- // str.append("paymentSubsidy:"+(String.valueOf(map.get("paymentSubsidy")).equalsIgnoreCase("null")?"0.00":String.valueOf(map.get("paymentSubsidy")))+",");
- // str.append("socialSecurityDebit:"+(String.valueOf(map.get("socialSecurityDebit")).equalsIgnoreCase("null")?"0.00":String.valueOf(map.get("socialSecurityDebit")))+",");
- // str.append("providentFundDebit:"+(String.valueOf(map.get("providentFundDebit")).equalsIgnoreCase("null")?"0.00":String.valueOf(map.get("providentFundDebit")))+",");
- // str.append("preTaxMone:"+(String.valueOf(map.get("preTaxMone")).equalsIgnoreCase("null")?"0.00":String.valueOf(map.get("preTaxMone")))+",");
- // str.append("otherDebit:"+(String.valueOf(map.get("otherDebit")).equalsIgnoreCase("null")?"0.00":String.valueOf(map.get("otherDebit")))+",");
- // str.append("reissue:"+(String.valueOf(map.get("reissue")).equalsIgnoreCase("null")?"0.00":String.valueOf(map.get("reissue")))+",");
- // str.append("taxMoney:"+(String.valueOf(map.get("taxMoney")).equalsIgnoreCase("null")?"0.00":String.valueOf(map.get("taxMoney")))+",");
- // str.append("actualMoney:"+(String.valueOf(map.get("actualMoney")).equalsIgnoreCase("null")?"0.00":String.valueOf(map.get("actualMoney"))));
- dataGrid.setFooter(str.toString());
- }
- }else{
- dataGrid.setResults(new ArrayList<UserWageDto>());
- dataGrid.setFooter("");
- }
- TagUtil.datagrid(response, dataGrid);
-
- }
-
- private void calcuSumMap(Map<String, BigDecimal> map, List<UserWageDto> list) throws Exception {
- if(map == null || list == null || list.isEmpty()) {
- return;
- }
- for(UserWageDto dto : list) {
- for(Field field : dto.getClass().getDeclaredFields()) {
- sumMapItem(dto,map, field);
- }
- }
- }
-
- private Method getGetMethod (UserWageDto dto, Field field) throws NoSuchMethodException, SecurityException {
- byte[] meth = field.getName().getBytes();
- meth[0] = (byte)((char)meth[0]-'a'+'A');
- return (Method)dto.getClass().getMethod("get" + new String(meth));
-
- }
- private void sumMapItem(UserWageDto dto, Map<String, BigDecimal> map, Field field)throws Exception {
- if(dto == null || map == null) {
- return;
- }
- BigDecimal mapValue = map.get(field.getName());
- BigDecimal dtoValue = null;
- if("class java.math.BigDecimal".equals(field.getGenericType().toString())){
- dtoValue = (BigDecimal)getGetMethod(dto, field).invoke(dto);
- }else if("class java.lang.Integer".equals(field.getGenericType().toString())){
- dtoValue = new BigDecimal((Integer)getGetMethod(dto, field).invoke(dto));
- }else if("class java.lang.Double".equals(field.getGenericType().toString())){
- dtoValue = new BigDecimal((Double)getGetMethod(dto, field).invoke(dto));
- }
-
- if(dtoValue == null) {
- dtoValue = BigDecimal.ZERO;
- }
-
- if(mapValue == null) {
- map.put(field.getName(), dtoValue);
- }else {
- mapValue = mapValue.add(dtoValue);
- map.put(field.getName(), mapValue);
- }
-
- }
- /**
- * 通过人查询所属项目
- * @param userid
- * @return
- */
- private String getBybelongId(String userid){
- String temp = "";
- StringBuffer hql = new StringBuffer("from TSUserOrg where tsUser.id = :userid and ifpluralism = 0 and status=0");
- List<TSUserOrg> tsList = systemService.getSession().createQuery(hql.toString()).setParameter("userid", userid).list();
- if(!tsList.isEmpty()){
- TSUserOrg uo = tsList.get(0);
- TSDepart tsDepart = uo.getTsDepart();
- if("1".equals(tsDepart.getOrgType()) || "3".equals(tsDepart.getOrgType()) || "4".equals(tsDepart.getOrgType()) || "5".equals(tsDepart.getOrgType())){
- temp = tsDepart.getId();
- }else if("2".equals(tsDepart.getOrgType()) && "1".equals(tsDepart.getTSPDepart().getOrgType())){
- temp = tsDepart.getId();
- }else{
- temp = selectById(tsDepart.getId());
- }
-
- temp = systemService.get(TSDepart.class, temp).getDepartname();
- }
- return temp;
- }
-
- private String selectById(String id){
- String temp = "";
-
- TSDepart tsDepart =systemService.getEntity(TSDepart.class,id);
- if("3".equals(tsDepart.getOrgType()) || "5".equals(tsDepart.getOrgType())){
- temp = tsDepart.getId();
- }else{
- if(tsDepart.getTSPDepart() != null){
- selectById(tsDepart.getTSPDepart().getId());
- temp = tsDepart.getTSPDepart().getId();
- }
- }
- return temp;
- }
-
- /**
- * 删除员工工资核算表
- *
- * @return
- */
- @RequestMapping(params = "doDel")
- @ResponseBody
- public AjaxJson doDel(UserWageEntity userWage, HttpServletRequest request) {
- String message = null;
- AjaxJson j = new AjaxJson();
- userWage = systemService.getEntity(UserWageEntity.class, userWage.getId());
- message = "员工工资核算表删除成功";
- try{
- userWageService.delete(userWage);
- systemService.addLog(message, Globals.Log_Type_DEL, Globals.Log_Leavel_INFO);
- }catch(Exception e){
- e.printStackTrace();
- message = "员工工资核算表删除失败";
- throw new BusinessException(e.getMessage());
- }
- j.setMsg(message);
- return j;
- }
-
- /**
- * 批量删除员工工资核算表
- *
- * @return
- */
- @RequestMapping(params = "doBatchDel")
- @ResponseBody
- public AjaxJson doBatchDel(String ids,HttpServletRequest request){
- String message = null;
- AjaxJson j = new AjaxJson();
- message = "员工工资核算表删除成功";
- try{
- for(String id:ids.split(",")){
- UserWageEntity userWage = systemService.getEntity(UserWageEntity.class,
- id
- );
- userWageService.delete(userWage);
- systemService.addLog(message, Globals.Log_Type_DEL, Globals.Log_Leavel_INFO);
- }
- }catch(Exception e){
- e.printStackTrace();
- message = "员工工资核算表删除失败";
- throw new BusinessException(e.getMessage());
- }
- j.setMsg(message);
- return j;
- }
- /**
- * 添加员工工资核算表
- *
- * @return
- */
- @RequestMapping(params = "doAdd")
- @ResponseBody
- public AjaxJson doAdd(UserWageEntity userWage, HttpServletRequest request) {
- String message = null;
- AjaxJson j = new AjaxJson();
- message = "员工工资核算表添加成功";
- try{
- userWageService.save(userWage);
- systemService.addLog(message, Globals.Log_Type_INSERT, Globals.Log_Leavel_INFO);
- }catch(Exception e){
- e.printStackTrace();
- message = "员工工资核算表添加失败";
- throw new BusinessException(e.getMessage());
- }
- j.setMsg(message);
- return j;
- }
-
- /**
- * 更新员工工资核算表
- *
- * @return
- */
- @RequestMapping(params = "doUpdate")
- @ResponseBody
- public AjaxJson doUpdate(UserWageEntity userWage, HttpServletRequest request) {
- String message = null;
- AjaxJson j = new AjaxJson();
- message = "员工工资核算表更新成功";
- UserWageEntity t = userWageService.get(UserWageEntity.class, userWage.getId());
- try {
- MyBeanUtils.copyBeanNotNull2Bean(userWage, t);
- userWageService.saveOrUpdate(t);
- systemService.addLog(message, Globals.Log_Type_UPDATE, Globals.Log_Leavel_INFO);
- } catch (Exception e) {
- e.printStackTrace();
- message = "员工工资核算表更新失败";
- throw new BusinessException(e.getMessage());
- }
- j.setMsg(message);
- return j;
- }
-
- /**
- * 员工工资核算表新增页面跳转
- *
- * @return
- */
- @RequestMapping(params = "goAdd")
- public ModelAndView goAdd(UserWageEntity userWage, HttpServletRequest req) {
- if (StringUtil.isNotEmpty(userWage.getId())) {
- userWage = userWageService.getEntity(UserWageEntity.class, userWage.getId());
- req.setAttribute("userWagePage", userWage);
- }
- return new ModelAndView("cn/com/lzt/userwage/userWage-add");
- }
- /**
- * 员工工资核算表编辑页面跳转
- *
- * @return
- */
- @RequestMapping(params = "goUpdate")
- public ModelAndView goUpdate(UserWageEntity userWage, HttpServletRequest req) {
- if (StringUtil.isNotEmpty(userWage.getId())) {
- userWage = userWageService.getEntity(UserWageEntity.class, userWage.getId());
- req.setAttribute("userWagePage", userWage);
- }
- return new ModelAndView("cn/com/lzt/userwage/userWage-update");
- }
-
- /**
- * 导入功能跳转
- *
- * @return
- */
- @RequestMapping(params = "upload")
- public ModelAndView upload(HttpServletRequest req) {
- req.setAttribute("controller_name","userWageController");
- return new ModelAndView("common/upload/pub_excel_upload");
- }
-
- /**
- * 员工工资条
- * 导出excel
- *
- * @param request
- * @param response
- */
- @RequestMapping(params = "exportWagePaperXls")
- public String exportWagePaperXls(UserWageDto userWage,HttpServletRequest request,HttpServletResponse response
- , DataGrid dataGrid,ModelMap modelMap) {
- String filename = "员工工资条";
- List<UserWageDto> list = new ArrayList<UserWageDto>();
- String orgIds = request.getParameter("orgIds");
- String monthlys = request.getParameter("monthlys");
- TSDepart depart = systemService.get(TSDepart.class, orgIds);
- if(depart != null) {
- filename = depart.getDepartname();
- }
- // String departname = request.getParameter("departname");
- // if(departname != null && departname.length()>0) {
- // filename = departname;
- // }
- if(monthlys != null && monthlys.length()>0) {
- filename = filename + "(" + monthlys + ")";
- }
- if(StringUtils.isNotEmpty(orgIds) && StringUtils.isNotEmpty(monthlys)){
- String monthly = request.getParameter("monthly");
-
- String orgId = request.getParameter("orgid");
- String type = request.getParameter("type");
- if(StringUtils.isEmpty(orgIds)&&StringUtils.isNotEmpty(orgId)){
- List<String> orgIdList = extractIdListByComma(orgId);
- // 获取 当前组织机构的用户信息
- if (!CollectionUtils.isEmpty(orgIdList)) {
- if(oConvertUtils.isNotEmpty(type) && "1".equals(type)){
- userWage.setOrgIdList(orgIdList);
- }else{
- String or = orgIdList.get(0);
- List<String> ChildIdList = userDepartOrgDealService.getChildIdByProjectDepartId(or);
- userWage.setOrgIdList(ChildIdList);
- }
- }
- }else{
- if(StringUtils.isNotEmpty(orgIds)){
- List<String> orgIdList = extractIdListByComma(orgIds);
- // 获取 当前组织机构的用户信息
- if (!CollectionUtils.isEmpty(orgIdList)) {
- String or = orgIdList.get(0);
- List<String> ChildIdList = userDepartOrgDealService.getChildIdByProjectDepartId(or);
- userWage.setOrgIdList(ChildIdList);
- }
- }
- }
-
- String moth = "";
-
- String [] mothl = monthlys.split("-");
- if("01".equals(mothl[1])){
- moth = Integer.valueOf(mothl[0])-1+"-12-01";
- }else{
- moth = monthlys+"-01 00:00:00";
- }
-
- if(StringUtils.isNotEmpty(monthlys)){
- userWage.setMonthly(monthlys);
- }else{
- if(StringUtils.isNotEmpty(monthly)){
- request.setAttribute("monthlys", monthly);
- userWage.setMonthly(monthly);
- }else{
- request.setAttribute("monthlys", getMonthlys());
- userWage.setMonthly(getMonthlys());
- }
- }
-
- String authSql = JeecgDataAutorUtils.loadDataSearchConditonSQLString();
-
- VisibleUserDto dto = dataPermissionService.getVisibleUserList();// 获取当前用户可见的userid列表
- if(dto != null){
- if(dto.getFlag().value().equalsIgnoreCase("ALL")){
- list = userWageService.getAllEntities(userWage,null,moth,authSql);
- }else if(dto.getFlag().value().equalsIgnoreCase("NONE")){
- // 获取当前登录用户
- HttpSession session = ContextHolderUtils.getSession();
- TSUser user = (TSUser)session.getAttribute("LOCAL_CLINET_USER");
- List<String> uidList = new ArrayList<String>();
- uidList.add(user.getId());
- list = userWageService.getAllEntities(userWage,uidList,moth,authSql);
- }else if(dto.getFlag().value().equalsIgnoreCase("PART")){
- List<String> uidList = dto.getUseridList();
- if(uidList != null && uidList.size() > 0){
- list = userWageService.getAllEntities(userWage,uidList,moth,authSql);
- }
- }
- }
- }
- // long s = System.currentTimeMillis();
- // getDingAttendanceinfoEntitiesWithCache();
- // long e = System.currentTimeMillis();
- // System.out.println("ding: " + (e-s)/1000 +"s");
- //
- // getDingAttendanceinfoEntitiesWithJDBC();
- //
- // long e2 = System.currentTimeMillis();
- // System.out.println("jdbc: " +(e2-e)/1000 + " s");
- Collections.sort(list);
- List<UserWagePaperDto> paperList = new ArrayList<>();
- try {
- creatWagePaper(list, paperList);
- } catch (Exception e) {
- org.jeecgframework.core.util.LogUtil.error(e.getMessage());
- }
- modelMap.put(NormalExcelConstants.FILE_NAME,filename);
- modelMap.put(NormalExcelConstants.CLASS,UserWagePaperDto.class);
- modelMap.put(NormalExcelConstants.PARAMS,new ExportParams("员工工资核算列表", "导出人:"+ResourceUtil.getSessionUser().getRealName(),
- "导出信息"));
- modelMap.put(NormalExcelConstants.DATA_LIST,paperList);
- return NormalExcelConstants.JEECG_EXCEL_VIEW;
- }
-
- private void getDingAttendanceinfoEntitiesWithJDBC() {
- // HashMap<String, Object> hm = hm_cache.get("getDingAttendanceinfoEntitiesWithCache");
- // Date curdate = dto.getYmdDate();
- // String strDateFormat = "yyyy-MM";
- // SimpleDateFormat sdf = new SimpleDateFormat(strDateFormat);
- // Calendar calendar = Calendar.getInstance();
- // calendar.setTime(curdate);
- // calendar.add(Calendar.DATE, 2);
- // Date tomdate = calendar.getTime();
- // if(hm == null) {
- HashMap<String, Object> hm = new HashMap<>();
- // hm_cache.put("getDingAttendanceinfoEntitiesWithCache", hm);
- //
- // CriteriaQuery cq = new CriteriaQuery(DingAttendanceinfoEntity.class);
- // cq.like("attendanceTime", sdf.format(curdate)+"%");
- // cq.add();
- // cq.between("attendanceTime", curdate, tomdate);
- // cq.add();
- // cq.addOrder("attendanceTime", SortDirection.asc);
- String hql = "select id,user_id, attendance_time from t_bus_ding_attendanceinfo "
- + "where attendance_time like '2019-08%'";
-
- List<Map<String, Object>> mapList=new ArrayList<Map<String, Object>>();
-
- mapList = systemService.findForJdbc(hql, null);
- //getListByCriteriaQuery(cq, false);
- for(Map<String, Object> map : mapList) {
- DingAttendanceinfoEntity entity = new DingAttendanceinfoEntity();
- entity.setId(map.get("id").toString());
- entity.setUserId(map.get("user_id").toString());
- entity.setAttendanceTime((Date)map.get("attendance_time"));
- String userInEntity = entity.getUserId();
- if(hm.containsKey(userInEntity)) {
- List<DingAttendanceinfoEntity> entitylist = (List<DingAttendanceinfoEntity>)hm.get(userInEntity);
- entitylist.add(entity);
- }else {
- List<DingAttendanceinfoEntity> newlist = new ArrayList<>();
- newlist.add(entity);
- hm.put(userInEntity, newlist);
- }
- }
- // }
- //
- // List<DingAttendanceinfoEntity> allList = (List<DingAttendanceinfoEntity>)hm.get(dto.getUserid());
- // if(allList == null) {
- // return new ArrayList<DingAttendanceinfoEntity>();
- // }
- // List<DingAttendanceinfoEntity> selectList = new ArrayList<>();
- // for(DingAttendanceinfoEntity attInAll : allList) {
- // Date attendanceTime = attInAll.getAttendanceTime();
- // if(attendanceTime.after(curdate) && attendanceTime.before(tomdate)) {
- // selectList.add(attInAll);
- // }
- // }
- // return selectList;
- }
-
- /**
- * @return
- */
- private void getDingAttendanceinfoEntitiesWithCache() {
- // HashMap<String, Object> hm = hm_cache.get("getDingAttendanceinfoEntitiesWithCache");
- // Date curdate = dto.getYmdDate();
- // String strDateFormat = "yyyy-MM";
- // SimpleDateFormat sdf = new SimpleDateFormat(strDateFormat);
- // Calendar calendar = Calendar.getInstance();
- // calendar.setTime(curdate);
- // calendar.add(Calendar.DATE, 2);
- // Date tomdate = calendar.getTime();
- // if(hm == null) {
- HashMap<String, Object> hm = new HashMap<>();
- // hm_cache.put("getDingAttendanceinfoEntitiesWithCache", hm);
- //
- // CriteriaQuery cq = new CriteriaQuery(DingAttendanceinfoEntity.class);
- // cq.like("attendanceTime", sdf.format(curdate)+"%");
- // cq.add();
- // cq.between("attendanceTime", curdate, tomdate);
- // cq.add();
- // cq.addOrder("attendanceTime", SortDirection.asc);
- String hql = "from DingAttendanceinfoEntity where attendanceTime like '2019-08%'";
-
- List<DingAttendanceinfoEntity> entitiesFromDB = systemService.findHql(hql);
- //getListByCriteriaQuery(cq, false);
- for(DingAttendanceinfoEntity entity : entitiesFromDB) {
- String userInEntity = entity.getUserId();
- if(hm.containsKey(userInEntity)) {
- List<DingAttendanceinfoEntity> entitylist = (List<DingAttendanceinfoEntity>)hm.get(userInEntity);
- entitylist.add(entity);
- }else {
- List<DingAttendanceinfoEntity> newlist = new ArrayList<>();
- newlist.add(entity);
- hm.put(userInEntity, newlist);
- }
- }
- // }
- //
- // List<DingAttendanceinfoEntity> allList = (List<DingAttendanceinfoEntity>)hm.get(dto.getUserid());
- // if(allList == null) {
- // return new ArrayList<DingAttendanceinfoEntity>();
- // }
- // List<DingAttendanceinfoEntity> selectList = new ArrayList<>();
- // for(DingAttendanceinfoEntity attInAll : allList) {
- // Date attendanceTime = attInAll.getAttendanceTime();
- // if(attendanceTime.after(curdate) && attendanceTime.before(tomdate)) {
- // selectList.add(attInAll);
- // }
- // }
- // return selectList;
- }
- /**
- * @param list
- * @param paperList
- * @throws InvocationTargetException
- * @throws IllegalArgumentException
- * @throws IllegalAccessException
- */
- private void creatWagePaper(List<UserWageDto> list, List<UserWagePaperDto> paperList) throws Exception {
- for(int i=0 ; i < list.size() ; i++) {
- UserWageDto dto = list.get(i);
- UserWagePaperDto papertitle = new UserWagePaperDto();
- UserWagePaperDto paperitem = new UserWagePaperDto();
- Field[] fields = UserWagePaperDto.class.getDeclaredFields();
- for(int j=0 ; j<fields.length ; j++) {
- Field f = fields[j];
- Excel ann = f.getAnnotation(Excel.class);
- if(ann != null) {
- PropertyDescriptor paperpd = new PropertyDescriptor(f.getName(), UserWagePaperDto.class);
- Method wM = paperpd.getWriteMethod();//获得写方法
- wM.invoke(papertitle, ann.name());
-
- PropertyDescriptor dtopd = new PropertyDescriptor(f.getName(), UserWageDto.class);
- Method rM = dtopd.getReadMethod();//读方法
- Object v = rM.invoke(dto);
- String str = "";
- if(v != null) {
- str = v.toString();
- }
-
- wM.invoke(paperitem, str);
- }
- }
- if(i>0) {
- paperList.add(papertitle);
- }
- paperList.add(paperitem);
- }
- }
- /**
- * 员工工资核算
- * 导出excel
- *
- * @param request
- * @param response
- */
- @RequestMapping(params = "exportXls")
- public String exportXls(UserWageDto userWage,HttpServletRequest request,HttpServletResponse response
- , DataGrid dataGrid,ModelMap modelMap) {
- String filename = "员工工资核算";
- List<UserWageDto> list = new ArrayList<UserWageDto>();
- String orgIds = request.getParameter("orgIds");
- String monthlys = request.getParameter("monthlys");
- TSDepart depart = systemService.get(TSDepart.class, orgIds);
- if(depart != null) {
- filename = depart.getDepartname();
- }
- // String departname = request.getParameter("departname");
- // if(departname != null && departname.length()>0) {
- // filename = departname;
- // }
- if(monthlys != null && monthlys.length()>0) {
- filename = filename + "(" + monthlys + ")";
- }
- if(StringUtils.isNotEmpty(orgIds) && StringUtils.isNotEmpty(monthlys)){
- String monthly = request.getParameter("monthly");
-
- String orgId = request.getParameter("orgid");
- String type = request.getParameter("type");
- if(StringUtils.isEmpty(orgIds)&&StringUtils.isNotEmpty(orgId)){
- List<String> orgIdList = extractIdListByComma(orgId);
- // 获取 当前组织机构的用户信息
- if (!CollectionUtils.isEmpty(orgIdList)) {
- if(oConvertUtils.isNotEmpty(type) && "1".equals(type)){
- userWage.setOrgIdList(orgIdList);
- }else{
- String or = orgIdList.get(0);
- List<String> ChildIdList = userDepartOrgDealService.getChildIdByProjectDepartId(or);
- userWage.setOrgIdList(ChildIdList);
- }
- }
- }else{
- if(StringUtils.isNotEmpty(orgIds)){
- List<String> orgIdList = extractIdListByComma(orgIds);
- // 获取 当前组织机构的用户信息
- if (!CollectionUtils.isEmpty(orgIdList)) {
- String or = orgIdList.get(0);
- List<String> ChildIdList = userDepartOrgDealService.getChildIdByProjectDepartId(or);
- userWage.setOrgIdList(ChildIdList);
- }
- }
- }
-
- String moth = "";
-
- String [] mothl = monthlys.split("-");
- if("01".equals(mothl[1])){
- moth = Integer.valueOf(mothl[0])-1+"-12-01";
- }else{
- moth = monthlys+"-01 00:00:00";
- }
-
- if(StringUtils.isNotEmpty(monthlys)){
- userWage.setMonthly(monthlys);
- }else{
- if(StringUtils.isNotEmpty(monthly)){
- request.setAttribute("monthlys", monthly);
- userWage.setMonthly(monthly);
- }else{
- request.setAttribute("monthlys", getMonthlys());
- userWage.setMonthly(getMonthlys());
- }
- }
-
- String authSql = JeecgDataAutorUtils.loadDataSearchConditonSQLString();
-
- VisibleUserDto dto = dataPermissionService.getVisibleUserList();// 获取当前用户可见的userid列表
- if(dto != null){
- if(dto.getFlag().value().equalsIgnoreCase("ALL")){
- list = userWageService.getAllEntities(userWage,null,moth,authSql);
- }else if(dto.getFlag().value().equalsIgnoreCase("NONE")){
- // 获取当前登录用户
- HttpSession session = ContextHolderUtils.getSession();
- TSUser user = (TSUser)session.getAttribute("LOCAL_CLINET_USER");
- List<String> uidList = new ArrayList<String>();
- uidList.add(user.getId());
- list = userWageService.getAllEntities(userWage,uidList,moth,authSql);
- }else if(dto.getFlag().value().equalsIgnoreCase("PART")){
- List<String> uidList = dto.getUseridList();
- if(uidList != null && uidList.size() > 0){
- list = userWageService.getAllEntities(userWage,uidList,moth,authSql);
- }
- }
- }
- }
- Collections.sort(list);
- modelMap.put(NormalExcelConstants.FILE_NAME,filename);
- modelMap.put(NormalExcelConstants.CLASS,UserWageDto.class);
- modelMap.put(NormalExcelConstants.PARAMS,new ExportParams("员工工资核算列表", "导出人:"+ResourceUtil.getSessionUser().getRealName(),
- "导出信息"));
- modelMap.put(NormalExcelConstants.DATA_LIST,list);
- return NormalExcelConstants.JEECG_EXCEL_VIEW;
- }
-
- /**
- * 月度工资一览导出
- *
- * @param request
- * @param response
- */
- @RequestMapping(params = "exportXls1")
- public String exportXls1(UserWageViewDto userWage,HttpServletRequest request,HttpServletResponse response
- , DataGrid dataGrid,ModelMap modelMap) {
- MiniDaoPage<UserWageViewDto> list = new MiniDaoPage<UserWageViewDto>();
- String monthlys = request.getParameter("monthlys");
- // String departname = request.getParameter("departname");
- String orgIds = request.getParameter("orgIds");
- String filename = "员工月度工资一览";
- TSDepart depart = systemService.get(TSDepart.class, orgIds);
- if(depart != null) {
- filename = depart.getDepartname();
- }
- if(monthlys != null && monthlys.length()>0) {
- filename = filename + "(" + monthlys + ")";
- }
- if(StringUtils.isNotEmpty(monthlys)){
-
- List<String> orgIdList = extractIdListByComma(orgIds);
- // 获取 当前组织机构的用户信息
- if (!CollectionUtils.isEmpty(orgIdList)) {
- String or = orgIdList.get(0);
- List<String> ChildIdList = userDepartOrgDealService.getChildIdByProjectDepartId(or);
- userWage.setOrgIdList(ChildIdList);
- }
-
- userWage.setMonthly(monthlys);
-
- String authSql = JeecgDataAutorUtils.loadDataSearchConditonSQLString();
-
- VisibleUserDto dto = dataPermissionService.getVisibleUserList();// 获取当前用户可见的userid列表
- if(dto != null){
- if(dto.getFlag().value().equalsIgnoreCase("ALL")){
- list = userWageService.getViewEntities(userWage,null,dataGrid.getPage(), dataGrid.getRows(), authSql);
- }else if(dto.getFlag().value().equalsIgnoreCase("NONE")){
- // 获取当前登录用户
- HttpSession session = ContextHolderUtils.getSession();
- TSUser user = (TSUser)session.getAttribute("LOCAL_CLINET_USER");
- List<String> uidList = new ArrayList<String>();
- uidList.add(user.getId());
- list = userWageService.getViewEntities(userWage,uidList,dataGrid.getPage(), dataGrid.getRows(), authSql);
- }else if(dto.getFlag().value().equalsIgnoreCase("PART")){
- List<String> useridList = dto.getUseridList();
- if(useridList != null && useridList.size() > 0){
- list = userWageService.getViewEntities(userWage,useridList,dataGrid.getPage(), dataGrid.getRows(), authSql);
- }
- }
- //MiniDaoPage<UserWageViewDto> list = userWageService.getViewEntities(userWage, dataGrid.getPage(), dataGrid.getRows(), authSql);
- //List<UserWageDto> list = userWageService.getAllEntities(userWage,authSql);
- }
- }
- modelMap.put(NormalExcelConstants.FILE_NAME,filename);
- modelMap.put(NormalExcelConstants.CLASS,UserWageViewDto.class);
- modelMap.put(NormalExcelConstants.PARAMS,new ExportParams("员工月度工资一览列表", "导出人:"+ResourceUtil.getSessionUser().getRealName(),
- "导出信息"));
- if(list.getResults() == null){
- modelMap.put(NormalExcelConstants.DATA_LIST,new ArrayList<>());
- }else{
- modelMap.put(NormalExcelConstants.DATA_LIST,list.getResults());
- }
- return NormalExcelConstants.JEECG_EXCEL_VIEW;
- }
-
-
-
- /**
- * 月度工资详细
- *
- * @param request
- * @param response
- */
- @RequestMapping(params = "exportXlsDetailByProject")
- public String exportXlsDetailByProject(@Param("orgId") String orgId
- ,@Param("monthly")String monthly,@Param("type")String type,HttpServletRequest request,HttpServletResponse response
- , DataGrid dataGrid,ModelMap modelMap) {
- String filename = "美都环卫全体员工工资详细";
- UserWageDto userWage = new UserWageDto();
- if(StringUtils.isNotEmpty(orgId)){
- TSDepart depart = systemService.get(TSDepart.class, orgId);
- if(depart != null) {
- filename = depart.getDepartname();
- }
- }
-
- // if(StringUtils.isNotEmpty(orgId) && departname != null && departname.length()>0) {
- // filename = departname;
- // }
- filename = filename.replaceAll(",", "");
- if(monthly != null && monthly.length()>0) {
- filename = filename + "(" + monthly + ")";
- }
- if(StringUtils.isNotEmpty(orgId)){
- List<String> orgIdList = extractIdListByComma(orgId);
- // 获取 当前组织机构的用户信息
- if (!CollectionUtils.isEmpty(orgIdList)) {
- if(oConvertUtils.isNotEmpty(type) && "1".equals(type)){
- userWage.setOrgIdList(orgIdList);
- }else{
- String or = orgIdList.get(0);
- List<String> ChildIdList = userDepartOrgDealService.getChildIdByProjectDepartId(or);
- userWage.setOrgIdList(ChildIdList);
- }
- }
- }
-
- if(StringUtils.isNotEmpty(monthly)){
- userWage.setMonthly(monthly);
- }
-
- String authSql = JeecgDataAutorUtils.loadDataSearchConditonSQLString();
-
- VisibleUserDto dto = dataPermissionService.getVisibleUserList();// 获取当前用户可见的userid列表
- if(dto != null){
- List<UserWageDto> list = new ArrayList<UserWageDto>();
- if(dto.getFlag().value().equalsIgnoreCase("ALL")){
- list = userWageService.getAllEntities(userWage,null,null,authSql);
- }else if(dto.getFlag().value().equalsIgnoreCase("NONE")){
- // 获取当前登录用户
- HttpSession session = ContextHolderUtils.getSession();
- TSUser user = (TSUser)session.getAttribute("LOCAL_CLINET_USER");
- List<String> uidList = new ArrayList<String>();
- uidList.add(user.getId());
- list = userWageService.getAllEntities(userWage,uidList,null,authSql);
- }else if(dto.getFlag().value().equalsIgnoreCase("PART")){
- List<String> useridList = dto.getUseridList();
- if(useridList != null && useridList.size() > 0){
- list = userWageService.getAllEntities(userWage,useridList,null,authSql);
- }
- }
- Collections.sort(list);
- modelMap.put(NormalExcelConstants.FILE_NAME,filename);
- modelMap.put(NormalExcelConstants.CLASS,UserWageDto.class);
- modelMap.put(NormalExcelConstants.PARAMS,new ExportParams("员工工资详细列表", "导出人:"+ResourceUtil.getSessionUser().getRealName(),
- "导出信息"));
- modelMap.put(NormalExcelConstants.DATA_LIST,list);
- }
- return NormalExcelConstants.JEECG_EXCEL_VIEW;
- }
-
- /**
- * 月度工资详细
- *
- * @param request
- * @param response
- */
- @RequestMapping(params = "exportXls2")
- public String exportXls2(UserWageDto userWage,HttpServletRequest request,HttpServletResponse response
- , DataGrid dataGrid,ModelMap modelMap) {
-
- String monthlys = request.getParameter("monthlys");
- String monthly = request.getParameter("monthly");
- String orgIds = request.getParameter("orgIds");
- String orgId = request.getParameter("orgid");
- String type = request.getParameter("type");
- // String departname = request.getParameter("departname");
- String filename = "员工工资详细";
- // if(departname != null && departname.length()>0) {
- // filename = departname;
- // }
- if(monthlys != null && monthlys.length()>0) {
- filename = filename + "(" + monthlys + ")";
- }
- if(StringUtils.isEmpty(orgIds)&&StringUtils.isNotEmpty(orgId)){
- List<String> orgIdList = extractIdListByComma(orgId);
- // 获取 当前组织机构的用户信息
- if (!CollectionUtils.isEmpty(orgIdList)) {
- if(oConvertUtils.isNotEmpty(type) && "1".equals(type)){
- userWage.setOrgIdList(orgIdList);
- }else{
- String or = orgIdList.get(0);
- List<String> ChildIdList = userDepartOrgDealService.getChildIdByProjectDepartId(or);
- userWage.setOrgIdList(ChildIdList);
- }
- }
- }else{
- if(StringUtils.isNotEmpty(orgIds)){
- List<String> orgIdList = extractIdListByComma(orgIds);
- // 获取 当前组织机构的用户信息
- if (!CollectionUtils.isEmpty(orgIdList)) {
- String or = orgIdList.get(0);
- List<String> ChildIdList = userDepartOrgDealService.getChildIdByProjectDepartId(or);
- userWage.setOrgIdList(ChildIdList);
- }
- }
- }
-
- if(StringUtils.isNotEmpty(monthlys)){
- userWage.setMonthly(monthlys);
- }else{
- if(StringUtils.isNotEmpty(monthly)){
- request.setAttribute("monthlys", monthly);
- userWage.setMonthly(monthly);
- }else{
- request.setAttribute("monthlys", getMonthlys());
- userWage.setMonthly(getMonthlys());
- }
- //userWage.setMonthly(sim.format(sim.parse("2017-10")));
- }
-
- String authSql = JeecgDataAutorUtils.loadDataSearchConditonSQLString();
-
- VisibleUserDto dto = dataPermissionService.getVisibleUserList();// 获取当前用户可见的userid列表
- if(dto != null){
- List<UserWageDto> list = new ArrayList<UserWageDto>();
- if(dto.getFlag().value().equalsIgnoreCase("ALL")){
- list = userWageService.getAllEntities(userWage,null,null,authSql);
- }else if(dto.getFlag().value().equalsIgnoreCase("NONE")){
- // 获取当前登录用户
- HttpSession session = ContextHolderUtils.getSession();
- TSUser user = (TSUser)session.getAttribute("LOCAL_CLINET_USER");
- List<String> uidList = new ArrayList<String>();
- uidList.add(user.getId());
- list = userWageService.getAllEntities(userWage,uidList,null,authSql);
- }else if(dto.getFlag().value().equalsIgnoreCase("PART")){
- List<String> useridList = dto.getUseridList();
- if(useridList != null && useridList.size() > 0){
- list = userWageService.getAllEntities(userWage,useridList,null,authSql);
- }
- }
- Collections.sort(list);
- modelMap.put(NormalExcelConstants.FILE_NAME,filename);
- modelMap.put(NormalExcelConstants.CLASS,UserWageDto.class);
- modelMap.put(NormalExcelConstants.PARAMS,new ExportParams("员工工资详细列表", "导出人:"+ResourceUtil.getSessionUser().getRealName(),
- "导出信息"));
- modelMap.put(NormalExcelConstants.DATA_LIST,list);
- }
- return NormalExcelConstants.JEECG_EXCEL_VIEW;
- }
-
- /**
- * 月度工资明细
- * 人事使用
- *
- * @param request
- * @param response
- * @throws Exception
- */
- @RequestMapping(params = "exportXls3")
- public String exportXls3(UserWageDto userWage,HttpServletRequest request,HttpServletResponse response
- , DataGrid dataGrid,ModelMap modelMap) throws Exception {
-
- String monthlys = request.getParameter("monthlys");
- String monthly = request.getParameter("monthly");
- String orgIds = request.getParameter("orgIds");
- String orgId = request.getParameter("orgid");
- String type = request.getParameter("type");
- String departname = request.getParameter("departname");
- String filename = "员工工资明细";
- if(departname != null && departname.length()>0) {
- filename = departname;
- }
- if(monthlys != null && monthlys.length()>0) {
- filename = filename + "(" + monthlys + ")";
- }
- if(StringUtils.isEmpty(orgIds)&&StringUtils.isNotEmpty(orgId)){
- List<String> orgIdList = extractIdListByComma(orgId);
- // 获取 当前组织机构的用户信息
- if (!CollectionUtils.isEmpty(orgIdList)) {
- if(oConvertUtils.isNotEmpty(type) && "1".equals(type)){
- userWage.setOrgIdList(orgIdList);
- }else{
- String or = orgIdList.get(0);
- List<String> ChildIdList = userDepartOrgDealService.getChildIdByProjectDepartId(or);
- userWage.setOrgIdList(ChildIdList);
- }
- }
- }else{
- if(StringUtils.isNotEmpty(orgIds)){
- List<String> orgIdList = extractIdListByComma(orgIds);
- // 获取 当前组织机构的用户信息
- if (!CollectionUtils.isEmpty(orgIdList)) {
- String or = orgIdList.get(0);
- List<String> ChildIdList = userDepartOrgDealService.getChildIdByProjectDepartId(or);
- userWage.setOrgIdList(ChildIdList);
- }
- }
- }
-
- if(StringUtils.isNotEmpty(monthlys)){
- userWage.setMonthly(monthlys);
- }else{
- if(StringUtils.isNotEmpty(monthly)){
- request.setAttribute("monthlys", monthly);
- userWage.setMonthly(monthly);
- }else{
- request.setAttribute("monthlys", getMonthlys());
- userWage.setMonthly(getMonthlys());
- }
- //userWage.setMonthly(sim.format(sim.parse("2017-10")));
- }
-
- String authSql = JeecgDataAutorUtils.loadDataSearchConditonSQLString();
-
- // VisibleUserDto dto = dataPermissionService.getVisibleUserList();// 获取当前用户可见的userid列表
- //
- // HashMap<String, String> permKeyMap = null; //通过map来过滤
- // if(dto != null){
- List<UserWageDto> list = new ArrayList<UserWageDto>();
- // permKeyMap = new HashMap<String, String>();
- List<UserWageDetaillsDto> listDetail = new ArrayList<UserWageDetaillsDto>();
- // 取得所有的数据,然后在业务层过滤,效率会提高一些
- list = userWageService.getAllEntities(userWage,null,null,authSql);
- UserWageDetaillsDto dto2 = null;
- for (UserWageDto userWageDto : list) {
- dto2 = new UserWageDetaillsDto();
- MyBeanUtils.copyBeanNotNull2Bean(userWageDto,dto2);
- listDetail.add(dto2);
- }
- // if(dto.getFlag().value().equalsIgnoreCase("ALL")){
- // UserWageDetaillsDto dto2 = null;
- // for (UserWageDto userWageDto : list) {
- // dto2 = new UserWageDetaillsDto();
- // MyBeanUtils.copyBeanNotNull2Bean(userWageDto,dto2);
- // listDetail.add(dto2);
- // }
- // }else if(dto.getFlag().value().equalsIgnoreCase("NONE")){
- // // 获取当前登录用户
- // HttpSession session = ContextHolderUtils.getSession();
- // TSUser user = (TSUser)session.getAttribute("LOCAL_CLINET_USER");
- // permKeyMap.put(user.getId(), null);
- // UserWageDetaillsDto dto2 = null;
- // for (UserWageDto userWageDto : list) {
- // if(permKeyMap.containsKey(userWageDto.getUserid())) {
- // dto2 = new UserWageDetaillsDto();
- // MyBeanUtils.copyBeanNotNull2Bean(userWageDto,dto2);
- // listDetail.add(dto2);
- // }
- // }
- // }else if(dto.getFlag().value().equalsIgnoreCase("PART")){
- // List<String> useridList = dto.getUseridList();
- // if(useridList != null && useridList.size() > 0){
- // for(String userid : useridList) {
- // permKeyMap.put(userid, null);
- // }
- // UserWageDetaillsDto dto2 = null;
- // for (UserWageDto userWageDto : list) {
- // if(permKeyMap.containsKey(userWageDto.getUserid())) {
- // dto2 = new UserWageDetaillsDto();
- // MyBeanUtils.copyBeanNotNull2Bean(userWageDto,dto2);
- // listDetail.add(dto2);
- // }
- // }
- // }
- // }
-
- Collections.sort(listDetail);
- modelMap.put(NormalExcelConstants.FILE_NAME,filename);
- modelMap.put(NormalExcelConstants.CLASS,UserWageDetaillsDto.class);
- modelMap.put(NormalExcelConstants.PARAMS,new ExportParams("员工工资明细列表", "导出人:"+ResourceUtil.getSessionUser().getRealName(),
- "导出信息"));
- modelMap.put(NormalExcelConstants.DATA_LIST,listDetail);
- // }
- return NormalExcelConstants.JEECG_EXCEL_VIEW;
- }
- /**
- * 导出excel 使模板
- *
- * @param request
- * @param response
- */
- @RequestMapping(params = "exportXlsByT")
- public String exportXlsByT(UserWageEntity userWage,HttpServletRequest request,HttpServletResponse response
- , DataGrid dataGrid,ModelMap modelMap) {
- modelMap.put(NormalExcelConstants.FILE_NAME,"员工工资核算表");
- modelMap.put(NormalExcelConstants.CLASS,UserWageEntity.class);
- modelMap.put(NormalExcelConstants.PARAMS,new ExportParams("员工工资核算表列表", "导出人:"+ResourceUtil.getSessionUser().getRealName(),
- "导出信息"));
- modelMap.put(NormalExcelConstants.DATA_LIST,new ArrayList());
- return NormalExcelConstants.JEECG_EXCEL_VIEW;
- }
-
- @SuppressWarnings("unchecked")
- @RequestMapping(params = "importExcel", method = RequestMethod.POST)
- @ResponseBody
- public AjaxJson importExcel(HttpServletRequest request, HttpServletResponse response) {
- AjaxJson j = new AjaxJson();
-
- MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
- Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
- for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
- MultipartFile file = entity.getValue();// 获取上传文件对象
- ImportParams params = new ImportParams();
- params.setTitleRows(2);
- params.setHeadRows(1);
- params.setNeedSave(true);
- try {
- List<UserWageEntity> listUserWageEntitys = ExcelImportUtil.importExcel(file.getInputStream(),UserWageEntity.class,params);
- for (UserWageEntity userWage : listUserWageEntitys) {
- userWageService.save(userWage);
- }
- j.setMsg("文件导入成功!");
- } catch (Exception e) {
- j.setMsg("文件导入失败!");
- logger.error(ExceptionUtil.getExceptionMessage(e));
- }finally{
- try {
- file.getInputStream().close();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- }
- return j;
- }
-
- @RequestMapping(method = RequestMethod.GET)
- @ResponseBody
- public List<UserWageEntity> list() {
- List<UserWageEntity> listUserWages=userWageService.getList(UserWageEntity.class);
- return listUserWages;
- }
-
- @RequestMapping(value = "/{id}", method = RequestMethod.GET)
- @ResponseBody
- public ResponseEntity<?> get(@PathVariable("id") String id) {
- UserWageEntity task = userWageService.get(UserWageEntity.class, id);
- if (task == null) {
- return new ResponseEntity(HttpStatus.NOT_FOUND);
- }
- return new ResponseEntity(task, HttpStatus.OK);
- }
- @RequestMapping(method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE)
- @ResponseBody
- public ResponseEntity<?> create(@RequestBody UserWageEntity userWage, UriComponentsBuilder uriBuilder) {
- //调用JSR303 Bean Validator进行校验,如果出错返回含400错误码及json格式的错误信息.
- Set<ConstraintViolation<UserWageEntity>> failures = validator.validate(userWage);
- if (!failures.isEmpty()) {
- return new ResponseEntity(BeanValidators.extractPropertyAndMessage(failures), HttpStatus.BAD_REQUEST);
- }
- //保存
- try{
- userWageService.save(userWage);
- } catch (Exception e) {
- e.printStackTrace();
- return new ResponseEntity(HttpStatus.NO_CONTENT);
- }
- //按照Restful风格约定,创建指向新任务的url, 也可以直接返回id或对象.
- String id = userWage.getId();
- URI uri = uriBuilder.path("/rest/userWageController/" + id).build().toUri();
- HttpHeaders headers = new HttpHeaders();
- headers.setLocation(uri);
- return new ResponseEntity(headers, HttpStatus.CREATED);
- }
- @RequestMapping(value = "/{id}", method = RequestMethod.PUT, consumes = MediaType.APPLICATION_JSON_VALUE)
- public ResponseEntity<?> update(@RequestBody UserWageEntity userWage) {
- //调用JSR303 Bean Validator进行校验,如果出错返回含400错误码及json格式的错误信息.
- Set<ConstraintViolation<UserWageEntity>> failures = validator.validate(userWage);
- if (!failures.isEmpty()) {
- return new ResponseEntity(BeanValidators.extractPropertyAndMessage(failures), HttpStatus.BAD_REQUEST);
- }
- //保存
- try{
- userWageService.saveOrUpdate(userWage);
- } catch (Exception e) {
- e.printStackTrace();
- return new ResponseEntity(HttpStatus.NO_CONTENT);
- }
- //按Restful约定,返回204状态码, 无内容. 也可以返回200状态码.
- return new ResponseEntity(HttpStatus.NO_CONTENT);
- }
- @RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
- @ResponseStatus(HttpStatus.NO_CONTENT)
- public void delete(@PathVariable("id") String id) {
- userWageService.deleteEntityById(UserWageEntity.class, id);
- }
-
- /**
- * 保存新增/更新的行数据
- * @param page
- * @return
- * @throws Exception
- */
- @RequestMapping(params = "saveRows")
- @ResponseBody
- public AjaxJson saveRows(UserwagePage page) throws Exception{
- List<UserWageEntity> demos=page.getUserWageList();
- AjaxJson j = userWageService.addOrEdit(demos);
- return j;
- }
-
- /**
- * 工资进行上报
- * @param request
- * @param status
- * @return
- */
- @RequestMapping(params="updateStatus")
- @ResponseBody
- public AjaxJson updateStatus(HttpServletRequest request,boolean status){
- String ids = request.getParameter("ids");
- List<String> idList = extractIdListByComma(ids);
- AjaxJson j = userWageService.updateStatus(idList, status);
- return j;
- }
- @RequestMapping(params = "budgetlist")
- public ModelAndView budgetlist(HttpServletRequest request) {
- // String orgid = request.getParameter("orgid");
- // String monthly = request.getParameter("monthly");
- // if(oConvertUtils.isNotEmpty(monthly)){
- // request.setAttribute("monthlys", monthly);
- // request.setAttribute("orgid", orgid);
- // }else{
- // request.setAttribute("monthlys", getMonthlys());
- // }
- return new ModelAndView("cn/com/lzt/userwage/userWageViewBudgetList");
- }
- @RequestMapping(params = "datagridbudget")
- public void datagridbudget(UserWageViewDto userWage,HttpServletRequest request, HttpServletResponse response, DataGrid dataGrid) {
- List<Map<String,Object>> retList = getWageAndBudgetList(userWage);
- dataGrid.setResults(retList);
- TagUtil.datagrid(response, dataGrid);
- }
- private List<Map<String,Object>> getWageAndBudgetList(UserWageViewDto userWage) {
- List<Map<String,Object>> retList = new ArrayList<Map<String,Object>>();
- String year = userWage.getMonthly().substring(0,4);
- int monthInt = Integer.valueOf(userWage.getMonthly().substring(5));
- String month = "month"+monthInt;
- String qrySql = "select '"+userWage.getMonthly()+"' as yearmonth, \n" +
- " wage.*,\n" +
- " IFNULL(budget.projovertimebudget,0) as projovertimebudget,\n" +
- " IFNULL(budget.govovertimebudget,0) as govovertimebudget,\n" +
- " IFNULL(budget.ondutybudget,0) as ondutybudget\n" +
- "from (\n" +
- " SELECT \n" +
- " sum(c.overtimepay_timeout+c.special_overtime) as projovertime, \n" +
- " sum(c.duty) as onduty, \n" +
- " sum(c.overtimepay_Fixed) as govovertime, \n" +
- " d.id as departid,\n" +
- " d.departname AS departname\n" +
- " FROM\n" +
- " t_bus_user_wage c\n" +
- " LEFT JOIN t_s_base_user u ON c.userid = u.id\n" +
- " LEFT JOIN t_s_depart d ON d.id = c.pjt_id\n" +
- " WHERE u.delete_flag = '0' \n" +
- " and monthly =? \n" +
- " group BY\n" +
- " d.id) wage\n" +
- "left join (\n" +
- " select \n" +
- " depart_id as departid,\n" +
- " dep_name as departname ,\n" +
- " sum(case when budget_type = 'code1' then "+month+" else 0 end) as projovertimebudget ,\n" +
- " sum(case when budget_type = 'code2' then "+month+" else 0 end ) as govovertimebudget ,\n" +
- " sum(case when budget_type = 'code3' or budget_type = 'code4' then "+month+" else 0 end ) as ondutybudget \n" +
- " from t_b_overtime_budget\n" +
- " where years =? \n" +
- " group by depart_id ) budget on budget.departid = wage.departid "
- + "left join t_s_depart t on t.id = wage.departid "
- + "where t.org_type in ('3','5') ";
- if(StringUtils.isNotEmpty(userWage.getPjtId())) {
- qrySql +=" and wage.departid = '"+userWage.getPjtId()+"' order by CONVERT(wage.departname using gbk)";
- }else {
- qrySql +=" order by CONVERT(wage.departname using gbk)";
- }
- retList = systemService.findForJdbc(qrySql, userWage.getMonthly(),year);
- return retList;
- }
-
- @RequestMapping(params = "exportXlsBudget")
- public void exportXlsBudget(UserWageViewDto userWage,HttpServletRequest request,HttpServletResponse response
- , DataGrid dataGrid,ModelMap modelMap) {
- List<Map<String,Object>> retList = getWageAndBudgetList(userWage);
- String codedFileName = "加班预算执行表";
- Workbook workbook = null;
- List<ExcelExportEntity> entityList = new ArrayList<ExcelExportEntity>();
- ExcelExportEntity head1 = new ExcelExportEntity("项目管理处", "departname", 30);
- entityList.add(head1);
- ExcelExportEntity head2 = new ExcelExportEntity("工资月度", "yearmonth", 15);
- entityList.add(head2);
- ExcelExportEntity head3 = new ExcelExportEntity("项目加班费预算", "projovertimebudget", 15);
- entityList.add(head3);
- ExcelExportEntity head4 = new ExcelExportEntity("项目加班费发生额", "projovertime", 15);
- entityList.add(head4);
- ExcelExportEntity head5 = new ExcelExportEntity("国定加班费预算", "govovertimebudget", 15);
- entityList.add(head5);
- ExcelExportEntity head6 = new ExcelExportEntity("国定加班费发生额", "govovertime", 15);
- entityList.add(head6);
- ExcelExportEntity head7 = new ExcelExportEntity("值班费预算", "ondutybudget", 15);
- entityList.add(head7);
- ExcelExportEntity head8 = new ExcelExportEntity("值班费发生额", "onduty", 15);
- entityList.add(head8);
- List<Map<String, Object>> resultData = retList;
- workbook = ExcelExportUtil.exportExcel(workbook,
- new ExportParams("加班预算执行表", "导出人:" + ResourceUtil.getSessionUser().getRealName(), "加班预算执行表"),
- entityList, resultData);
-
- if (workbook instanceof HSSFWorkbook) {
- codedFileName +=".xls";
- } else {
- codedFileName +=".xlsx";
- }
- try {
- //IE
- if (request.getHeader("USER-AGENT").toLowerCase().indexOf("msie") > 0
- || request.getHeader("USER-AGENT").toLowerCase().indexOf("rv:11.0") > 0){
- codedFileName = java.net.URLEncoder.encode(codedFileName, "UTF8");
- } else {
- codedFileName = new String(codedFileName.getBytes("UTF-8"), "ISO-8859-1");
- }
- response.setHeader("content-disposition", "attachment;filename=" + codedFileName);
- ServletOutputStream out = response.getOutputStream();
- workbook.write(out);
- out.flush();
- } catch (UnsupportedEncodingException e) {
- logger.error(e.getMessage());
- } catch (IOException e) {
- logger.error(e.getMessage());
- }
- }
- /**
- * 一线员工未排班,不能修改工资条
- * */
- @RequestMapping(params = "checkRowEdit")
- @ResponseBody
- public AjaxJson checkRowEdit(UserwagePage page) throws Exception{
- AjaxJson j = new AjaxJson();
- List<UserWageEntity> userwages=page.getUserWageList();
- String usernames = "";
- for (UserWageEntity userWage : userwages) {
- userWage = systemService.get(UserWageEntity.class,userWage.getId());
- String userid = userWage.getUserid();
- String deptid = userWage.getPjtId();
- String month = userWage.getMonthly();
- if(!UserUtil.isProjectUser(userid))
- continue;
- //查看是否排班
- String arrangeSql = "select count(*) from t_bus_projarrange_detail where userid =? and yearmonth =? and pid = ?";
- Map<String,Object> arrangeCountRet = systemService.findOneForJdbc(arrangeSql, userid,month,deptid);
- int count = Integer.valueOf(arrangeCountRet.get("count(*)").toString());
- if(count == 0) {
- usernames += systemService.get(TSUser.class, userid).getRealName()+"<br>";
- }
- }
- if(StringUtils.isNotEmpty(usernames)) {
- j.setSuccess(false);
- j.setMsg("以下员工未排班,不能修改工资:<br>"+usernames);
- }
- return j;
- }
-
- }
|