| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512 |
- package cn.com.lzt.userwage.service.impl;
- import java.io.Serializable;
- import java.math.BigDecimal;
- import java.util.ArrayList;
- import java.util.HashMap;
- import java.util.List;
- import java.util.Map;
- import java.util.UUID;
- import org.apache.commons.collections.CollectionUtils;
- import org.apache.commons.lang3.StringUtils;
- import org.jeecgframework.core.common.model.json.AjaxJson;
- import org.jeecgframework.core.common.service.impl.CommonServiceImpl;
- import org.jeecgframework.core.constant.Globals;
- import org.jeecgframework.core.util.ApplicationContextUtil;
- import org.jeecgframework.core.util.JeecgDataAutorUtils;
- import org.jeecgframework.core.util.MyBeanUtils;
- import org.jeecgframework.core.util.MyClassLoader;
- import org.jeecgframework.core.util.StringUtil;
- import org.jeecgframework.minidao.pojo.MiniDaoPage;
- import org.jeecgframework.web.cgform.enhance.CgformEnhanceJavaInter;
- import org.jeecgframework.web.system.pojo.base.TSDepart;
- 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.stereotype.Service;
- import org.springframework.transaction.annotation.Transactional;
- import cn.com.lzt.arrangeduty.dto.ProjectDepartDto;
- import cn.com.lzt.userwage.dao.UserNewWageMinidaoDao;
- import cn.com.lzt.userwage.dto.UserNewWageDto;
- import cn.com.lzt.userwage.dto.UserWageViewDto;
- import cn.com.lzt.userwage.entity.UserNewWageEntity;
- import cn.com.lzt.userwage.service.UserNewWageServiceI;
- @Service("userNewWageService")
- @Transactional
- public class UserNewWageServiceImpl extends CommonServiceImpl implements UserNewWageServiceI {
- @Autowired
- UserNewWageMinidaoDao userWageMinidaoDao;
-
- @Autowired
- SystemService systemService;
-
- public void delete(UserNewWageEntity entity) throws Exception{
- super.delete(entity);
- //执行删除操作增强业务
- this.doDelBus(entity);
- }
-
- public Serializable save(UserNewWageEntity entity) throws Exception{
- Serializable t = super.save(entity);
- //执行新增操作增强业务
- this.doAddBus(entity);
- return t;
- }
-
- public void saveOrUpdate(UserNewWageEntity entity) throws Exception{
- super.saveOrUpdate(entity);
- //执行更新操作增强业务
- this.doUpdateBus(entity);
- }
-
- /**
- * 新增操作增强业务
- * @param t
- * @return
- */
- private void doAddBus(UserNewWageEntity t) throws Exception{
- //-----------------sql增强 start----------------------------
- //-----------------sql增强 end------------------------------
-
- //-----------------java增强 start---------------------------
- //-----------------java增强 end-----------------------------
- }
- /**
- * 更新操作增强业务
- * @param t
- * @return
- */
- private void doUpdateBus(UserNewWageEntity t) throws Exception{
- //-----------------sql增强 start----------------------------
- //-----------------sql增强 end------------------------------
-
- //-----------------java增强 start---------------------------
- //-----------------java增强 end-----------------------------
- }
- /**
- * 删除操作增强业务
- * @param id
- * @return
- */
- private void doDelBus(UserNewWageEntity t) throws Exception{
- //-----------------sql增强 start----------------------------
- //-----------------sql增强 end------------------------------
-
- //-----------------java增强 start---------------------------
- //-----------------java增强 end-----------------------------
- }
-
- private Map<String,Object> populationMap(UserNewWageEntity t){
- Map<String,Object> map = new HashMap<String,Object>();
- map.put("id", t.getId());
- map.put("userid", t.getUserid());
- map.put("belong_unitid", t.getBelongUnitid());
- map.put("dutiesid", t.getDutiesid());
- map.put("monthly", t.getMonthly());
- map.put("basic_wage", t.getBasicWage());
- map.put("duties_allowance", t.getDutiesAllowance());
- map.put("certificate_subsidy", t.getCertificateSubsidy());
- map.put("traffic_subsidy", t.getTrafficSubsidy());
- map.put("megathermal_subsidy", t.getMegathermalSubsidy());
- map.put("only_child_cost", t.getOnlyChildCost());
- // map.put("other_subsidy", t.getOtherSubsidy());
- map.put("bonus", t.getBonus());
- // map.put("project_performance", t.getProjectPerformance());
- map.put("meals_subsidy_day", t.getMealsSubsidyDay());
- map.put("meals_subsidy_night", t.getMealsSubsidyNight());
- map.put("meals_subsidy", t.getMealsSubsidy());
- map.put("overtimepay_timeout", t.getOvertimepayTimeout());
- map.put("overtimepay_fixed", t.getOvertimepayFixed());
- map.put("duty", t.getDuty());
- map.put("special_overtime", t.getSpecialOvertime());
- map.put("sick_leave_debit", t.getSickLeaveDebit());
- map.put("thing_leave_debit", t.getThingLeaveDebit());
- map.put("absence_debit", t.getAbsenceDebit());
- map.put("payment_subsidy", t.getPaymentSubsidy());
- map.put("social_security_debit", t.getSocialSecurityDebit());
- map.put("provident_fund_debit", t.getProvidentFundDebit());
- map.put("pre_tax_mone", t.getPreTaxMone());
- map.put("other_debit", t.getOtherDebit());
- map.put("daikou_debit", t.getDaikouDebit());
- map.put("reissue",t.getReissue());
- map.put("tax_money", t.getTaxMoney());
- map.put("actual_money", t.getActualMoney());
- map.put("status", t.getStatus());
- map.put("remark", t.getRemark());
- return map;
- }
-
- /**
- * 替换sql中的变量
- * @param sql
- * @param t
- * @return
- */
- public String replaceVal(String sql,UserNewWageEntity t){
- sql = sql.replace("#{id}",String.valueOf(t.getId()));
- sql = sql.replace("#{userid}",String.valueOf(t.getUserid()));
- sql = sql.replace("#{belong_unitid}",String.valueOf(t.getBelongUnitid()));
- sql = sql.replace("#{dutiesid}",String.valueOf(t.getDutiesid()));
- sql = sql.replace("#{monthly}",String.valueOf(t.getMonthly()));
- sql = sql.replace("#{basic_wage}",String.valueOf(t.getBasicWage()));
- sql = sql.replace("#{duties_allowance}",String.valueOf(t.getDutiesAllowance()));
- sql = sql.replace("#{certificate_subsidy}",String.valueOf(t.getCertificateSubsidy()));
- sql = sql.replace("#{traffic_subsidy}",String.valueOf(t.getTrafficSubsidy()));
- sql = sql.replace("#{megathermal_subsidy}",String.valueOf(t.getMegathermalSubsidy()));
- sql = sql.replace("#{only_child_cost}",String.valueOf(t.getOnlyChildCost()));
- // sql = sql.replace("#{other_subsidy}",String.valueOf(t.getOtherSubsidy()));
- sql = sql.replace("#{bonus}",String.valueOf(t.getBonus()));
- // sql = sql.replace("#{project_performance}",String.valueOf(t.getProjectPerformance()));
- sql = sql.replace("#{meals_subsidy_day}",String.valueOf(t.getMealsSubsidyDay()));
- sql = sql.replace("#{meals_subsidy_night}",String.valueOf(t.getMealsSubsidyNight()));
- sql = sql.replace("#{meals_subsidy}",String.valueOf(t.getMealsSubsidy()));
- sql = sql.replace("#{overtimepay_timeout}",String.valueOf(t.getOvertimepayTimeout()));
- sql = sql.replace("#{overtimepay_fixed}",String.valueOf(t.getOvertimepayFixed()));
- sql = sql.replace("#{duty}",String.valueOf(t.getDuty()));
- sql = sql.replace("#{special_overtime}",String.valueOf(t.getSpecialOvertime()));
- sql = sql.replace("#{sick_leave_debit}",String.valueOf(t.getSickLeaveDebit()));
- sql = sql.replace("#{thing_leave_debit}",String.valueOf(t.getThingLeaveDebit()));
- sql = sql.replace("#{absence_debit}",String.valueOf(t.getAbsenceDebit()));
- sql = sql.replace("#{payment_subsidy}",String.valueOf(t.getPaymentSubsidy()));
- sql = sql.replace("#{social_security_debit}",String.valueOf(t.getSocialSecurityDebit()));
- sql = sql.replace("#{provident_fund_debit}",String.valueOf(t.getProvidentFundDebit()));
- sql = sql.replace("#{pre_tax_mone}",String.valueOf(t.getPreTaxMone()));
- sql = sql.replace("#{other_debit}",String.valueOf(t.getOtherDebit()));
- sql = sql.replace("#{daikou_debit}",String.valueOf(t.getDaikouDebit()));
- sql = sql.replace("#{tax_money}",String.valueOf(t.getTaxMoney()));
- sql = sql.replace("#{actual_money}",String.valueOf(t.getActualMoney()));
- sql = sql.replace("#{reissue}",String.valueOf(t.getReissue()));
- sql = sql.replace("#{status}",String.valueOf(t.getStatus()));
- sql = sql.replace("#{remark}",String.valueOf(t.getRemark()));
- sql = sql.replace("#{UUID}",UUID.randomUUID().toString());
- return sql;
- }
-
- /**
- * 执行JAVA增强
- */
- private void executeJavaExtend(String cgJavaType,String cgJavaValue,Map<String,Object> data) throws Exception {
- if(StringUtil.isNotEmpty(cgJavaValue)){
- Object obj = null;
- try {
- if("class".equals(cgJavaType)){
- //因新增时已经校验了实例化是否可以成功,所以这块就不需要再做一次判断
- obj = MyClassLoader.getClassByScn(cgJavaValue).newInstance();
- }else if("spring".equals(cgJavaType)){
- obj = ApplicationContextUtil.getContext().getBean(cgJavaValue);
- }
- if(obj instanceof CgformEnhanceJavaInter){
- CgformEnhanceJavaInter javaInter = (CgformEnhanceJavaInter) obj;
- javaInter.execute("t_bus_user_wage",data);
- }
- } catch (Exception e) {
- e.printStackTrace();
- throw new Exception("执行JAVA增强出现异常!");
- }
- }
- }
- @Override
- public List<UserNewWageDto> getAllEntities(UserNewWageDto userWageDto,List<String> uidList,String moth,String authSql) {
- return userWageMinidaoDao.getAllEntities(userWageDto,uidList,moth,authSql);
- }
-
- @Override
- public MiniDaoPage<UserNewWageDto> getPagedEntities(UserNewWageDto userWageDto,List<String> uidList,String moth,int page, int rows, String authSql) {
- return userWageMinidaoDao.getPagedEntities(userWageDto,uidList,moth,page, rows,authSql);
- }
-
- @Override
- public List<UserNewWageDto> getAll(UserNewWageDto userWageDto,List<String> uidList,String moth,String authSql) {
- return userWageMinidaoDao.getAll(userWageDto,uidList,moth,authSql);
- }
-
- @Override
- public MiniDaoPage<UserWageViewDto> getViewEntities(UserWageViewDto userWageViewDto,List<String> uidList,int page, int rows,String authSql) {
- return userWageMinidaoDao.getViewEntities(userWageViewDto,uidList, page, rows, authSql);
- }
- @Override
- public Map<String, Integer> getMoneySUM(UserNewWageDto userWageDto,List<String> uidList,String moth) {
- return userWageMinidaoDao.getMoneySUM(userWageDto,uidList,moth);
- }
-
- @Override
- public BigDecimal getMoney(UserNewWageEntity userWageDto) {
- // if("ff8080816275ac02016283c8b3a30025".equals(userWageDto.getUserid())) {
- // System.out.println("ff8080816275ac02016283c8b3a30025");
- // }
- BigDecimal big = new BigDecimal(userWageDto.getBasicWage().toString());
- if(userWageDto.getDutiesAllowance() != null){
- big = big.add(userWageDto.getDutiesAllowance());
- }
- if(userWageDto.getCertificateSubsidy() != null){
- big = big.add(userWageDto.getCertificateSubsidy());
- }
- if(userWageDto.getTrafficSubsidy()!= null){
- big = big.add(userWageDto.getTrafficSubsidy());
- }
- if(userWageDto.getMegathermalSubsidy()!= null){
- big = big.add(userWageDto.getMegathermalSubsidy());
- }
- if(userWageDto.getOnlyChildCost()!= null){
- big = big.add(userWageDto.getOnlyChildCost());
- }
- // if(userWageDto.getOtherSubsidy()!= null){
- // big = big.add(userWageDto.getOtherSubsidy());
- // }
- if(userWageDto.getDuty()!= null){
- big = big.add(userWageDto.getDuty());
- }
- // if(userWageDto.getProjectPerformance()!= null){
- // big = big.add(userWageDto.getProjectPerformance());
- // }
- if(userWageDto.getMealsSubsidyDay()!= null){
- big = big.add(userWageDto.getMealsSubsidyDay());
- }
- if(userWageDto.getMealsSubsidyNight()!= null){
- big = big.add(userWageDto.getMealsSubsidyNight());
- }
-
- // // 奖金和项目绩效计入应发 zy 20180425
- if(userWageDto.getBonus()!= null){
- big = big.add(userWageDto.getBonus());
- }
-
- // if(userWageDto.getProjectPerformance()!= null){
- // big = big.add(userWageDto.getProjectPerformance());
- // }
-
- if(userWageDto.getMealsSubsidy()!= null){
- big = big.add(userWageDto.getMealsSubsidy());
- }
- if(userWageDto.getOvertimepayTimeout()!= null){
- big = big.add(userWageDto.getOvertimepayTimeout());
- }
- if(userWageDto.getOvertimepayFixed()!= null){
- big = big.add(userWageDto.getOvertimepayFixed());
- }
- /* if(userWageDto.getDuty()!= null){
- big = big.add(userWageDto.getDuty());
- }*/
- if(userWageDto.getSpecialOvertime()!= null){
- big = big.add(userWageDto.getSpecialOvertime());
- }
- if(userWageDto.getSickLeaveDebit()!= null){
- big = big.subtract(userWageDto.getSickLeaveDebit());
- }
-
-
- if(userWageDto.getThingLeaveDebit()!= null){
- big = big.subtract(userWageDto.getThingLeaveDebit());
- }
- if(userWageDto.getAbsenceDebit()!= null){
- big = big.subtract(userWageDto.getAbsenceDebit());
- }
- /*if(userWageDto.getSocialSecurityDebit()!= null){
- big = big.subtract(userWageDto.getSocialSecurityDebit());
- }
- if(userWageDto.getProvidentFundDebit()!= null){
- big = big.subtract(userWageDto.getProvidentFundDebit());
- }*/
- if(userWageDto.getOtherDebit()!= null){
- big = big.subtract(userWageDto.getOtherDebit());
- }
- if(userWageDto.getDaikouDebit()!= null){
- big = big.subtract(userWageDto.getDaikouDebit());
- }
- if(userWageDto.getReissue()!= null){
- big = big.add(userWageDto.getReissue());
- }
- if(userWageDto.getPaymentSubsidy()!= null){
- big = big.add(userWageDto.getPaymentSubsidy());
- }
- return big;
- }
- /**
- * 保存新增/更新的行数据
- */
- @Override
- public AjaxJson addOrEdit(List<UserNewWageEntity> entitys) throws Exception {
- String message = null;
- AjaxJson j = new AjaxJson();
- if(CollectionUtils.isNotEmpty(entitys)){
- for(UserNewWageEntity jeecgDemo:entitys){
- if (StringUtil.isNotEmpty(jeecgDemo.getId())) {
- UserNewWageEntity t =systemService.get(UserNewWageEntity.class, jeecgDemo.getId());
- try {
- message = "员工工资核算: " + jeecgDemo.getUserid() + "被更新成功";
- MyBeanUtils.copyBeanNotNull2Bean(jeecgDemo, t);
-
- // t.setPreTaxMone(this.getMoney(t));
- t.recalculatePreTaxMoney();
- t.recalculateActualMoney();
- t.recalculateComCost();
- // if(StringUtils.isNotEmpty(t.getPreTaxMone().toString())){
- // t.setActualMoney(t.getPreTaxMone().subtract(t.getTaxMoney()));
- // }else{
- // t.setActualMoney(t.getPreTaxMone());
- // }
- //
- // if(t.getSocialSecurityDebit()!= null && t.getSocialSecurityDebit().intValue() > 0){
- // t.setActualMoney(t.getActualMoney().subtract(t.getSocialSecurityDebit()));
- // }
- // if(t.getProvidentFundDebit()!= null && t.getProvidentFundDebit().intValue() > 0){
- // t.setActualMoney(t.getActualMoney().subtract(t.getProvidentFundDebit()));
- // }
- //
- this.saveOrUpdate(t);
- systemService.addLog(message, Globals.Log_Type_UPDATE, Globals.Log_Leavel_INFO);
- } catch (Exception e) {
- e.printStackTrace();
- }
- } else {
- try {
- message = "JeecgDemo例子: " + jeecgDemo.getUserid() + "被添加成功";
- //jeecgDemo.setStatus("0");
- jeecgDemo.recalculatePreTaxMoney();
- jeecgDemo.recalculateActualMoney();
- jeecgDemo.recalculateComCost();
- this.save(jeecgDemo);
- systemService.addLog(message, Globals.Log_Type_INSERT, Globals.Log_Leavel_INFO);
- } catch (Exception e) {
- e.printStackTrace();
- }
-
- }
- }
- }
- return j;
- }
- @Override
- public Map<String, Integer> getMoneyViewSUM(UserWageViewDto userWageiewDto,List<String> uidList) {
- return userWageMinidaoDao.getMoneyViewSUM(userWageiewDto,uidList);
- }
- /**
- * 工资进行确认和上报
- */
- @Override
- public AjaxJson updateStatus(List<String> idList,boolean status) {
- String message = null;
- AjaxJson j = new AjaxJson();
- if(CollectionUtils.isNotEmpty(idList)){
- for (String id : idList) {
- UserNewWageEntity t =systemService.get(UserNewWageEntity.class, id);
- if(t != null){
- j.setSuccess(true);
- if(status){
- message = t.getMonthly()+",员工id为:"+t.getUserid()+"的工资进行了上报";
- t.setStatus("1");
- }else{
- message = t.getMonthly()+",员工id为:"+t.getUserid()+"的工资进行了确认";
- t.setStatus("2");
- }
- systemService.saveOrUpdate(t);
- systemService.addLog(message, Globals.Log_Type_INSERT, Globals.Log_Leavel_INFO);
- }
- }
- }
- return j;
- }
- @Override
- public List<UserNewWageEntity> getByuserid(String userid, String monthly) {
- return userWageMinidaoDao.getByuserid(userid, monthly);
- }
- @Override
- public List<ProjectDepartDto> getProjectDepartAll(ProjectDepartDto projectDepartDto,String userid) {
- List<ProjectDepartDto> projectDepartDtoList = new ArrayList<ProjectDepartDto>();
- if(StringUtils.isNotEmpty(userid)){
- List<TSUserOrg> ts = this.getSession().createQuery("from TSUserOrg where tsUser.id = :userId and status = 0").setParameter("userId",userid).list();
- if(!ts.isEmpty()){
- boolean temp = false;
- for (TSUserOrg tsUserOrg : ts) {
- TSDepart tss = get(TSDepart.class, tsUserOrg.getTsDepart().getId());
- if(tss != null && tss.getTSPDepart() != null){
- if("1".equals(tss.getTSPDepart().getOrgType())&&"2".equals(tss.getOrgType()) || "4".equals(tss.getOrgType())){
- temp = true;
- break;
- }
- }else{
- if("1".equals(tss.getOrgType())){
- temp = true;
- break;
- }
- }
- }
-
- if(temp){
- List<TSDepart> tsDepartsList = this.getSession().createQuery("from TSDepart where parentdepartid is null").list();
- List<String> idList = null;
- if(!tsDepartsList.isEmpty()){
- idList=new ArrayList<String>();
- for (TSDepart idTSDepart : tsDepartsList) {
- List<TSDepart> dt = this.getSession().createQuery("from TSDepart where parentdepartid = :parentdepartid and orgType = 2").setParameter("parentdepartid", idTSDepart.getId()).list();
- if(!dt.isEmpty()){
- for (TSDepart tsDepart : dt) {
- idList.add(tsDepart.getId());
- }
- }
- }
- projectDepartDto.getDepartIdList().addAll(idList);
- }
-
- List<String> orgTypeList=new ArrayList<String>();
- orgTypeList.add(Globals.org_type_3);
- orgTypeList.add(Globals.org_type_5);
- projectDepartDto.getOrgTypeList().addAll(orgTypeList);
-
- String authSql = JeecgDataAutorUtils.loadDataSearchConditonSQLString();
- projectDepartDtoList=userWageMinidaoDao.getProjectDepartAll(projectDepartDto, authSql);
- }else{
- List<String> idList=new ArrayList<String>();
- for (TSUserOrg tsUserOrg : ts) {
- TSDepart tss = get(TSDepart.class, tsUserOrg.getTsDepart().getId());
- idList.add(selectById(tss.getId()));
- }
- projectDepartDto.getDepartIdList().addAll(idList);
-
- String authSql = JeecgDataAutorUtils.loadDataSearchConditonSQLString();
- projectDepartDtoList=userWageMinidaoDao.getProjectDepartAll(projectDepartDto, authSql);
- }
- }
- }
- return projectDepartDtoList;
- }
-
- 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());
- }
- }
- return temp;
- }
- /* (non-Javadoc)
- * @see cn.com.lzt.userwage.service.UserNewWageServiceI#getManagerWagePagedEntities(cn.com.lzt.userwage.dto.UserNewWageDto, java.util.List, java.lang.String, int, int, java.lang.String)
- */
- @Override
- public MiniDaoPage<UserNewWageDto> getManagerWagePagedEntities(UserNewWageDto userWageDto, List<String> uidList, String moth, int page, int rows, String authSql) {
- return userWageMinidaoDao.getManagerWagePagedEntities(userWageDto,uidList,moth,page, rows,authSql);
- }
- /* (non-Javadoc)
- * @see cn.com.lzt.userwage.service.UserNewWageServiceI#getAllManagerNewWageEntities(cn.com.lzt.userwage.dto.UserNewWageDto, java.util.List, java.lang.String, java.lang.String)
- */
- @Override
- public List<UserNewWageDto> getAllManagerNewWageEntities(UserNewWageDto userWageDto, List<String> uidList, String moth, String authSql) {
- return userWageMinidaoDao.getAllManagerNewWageEntities(userWageDto, uidList, moth, authSql);
- }
- }
|