| | |
| | | sb.append(" SELECT DISTINCT a.uuid,a.start_time,a.end_time,a.meeting_topic,a.record_man,a.record_master,a.status,t.dict_label "); |
| | | sb.append(" FROM ("); |
| | | sb.append(" SELECT T1.*, "); |
| | | sb.append(" SUBSTRING_INDEX( SUBSTRING_INDEX( T1.meeting_resource, ',', T2.digit + 1 ), ',',- 1 ) AS type "); |
| | | sb.append(UnifySQLFunction.substringIndexFuntion(UnifySQLFunction.substringIndexFuntion("T1.meeting_resource", "','", "T2.digit + 1"), "','", "-1")).append(" AS type "); |
| | | sb.append(" FROM product_oa_conference_apply T1 "); |
| | | sb.append(" LEFT JOIN ( SELECT 0 AS digit UNION ALL SELECT 1 UNION ALL SELECT 2 UNION ALL SELECT 3 UNION ALL SELECT 4 UNION ALL SELECT 5 ) T2"); |
| | | sb.append(" ON T2.digit < ( length( T1.meeting_resource )- length( REPLACE ( T1.meeting_resource, ',', '' ))+ 1 )"); |
| | |
| | | filter.append(" ) "); |
| | | } |
| | | } |
| | | DataTableEntity dt = baseDao.listTable(fse.getTableName(), filter.toString(), new Object[]{}, null, "ifnull(updated_utc_datetime,created_utc_datetime) desc", fse.getInteger(CmnConst.PAGESIZE), fse.getInteger(CmnConst.CPAGE), false); |
| | | DataTableEntity dt = baseDao.listTable(fse.getTableName(), filter.toString(), new Object[]{}, null, |
| | | UnifySQLFunction.ifnullRepalce("IFNULL(updated_utc_datetime,created_utc_datetime) DESC"), |
| | | fse.getInteger(CmnConst.PAGESIZE), fse.getInteger(CmnConst.CPAGE), false); |
| | | baseDao.loadPromptData(dt); |
| | | return dt; |
| | | } |
| | |
| | | public DataTableEntity listModel(FieldSetEntity fse) { |
| | | String curUserID = SpringMVCContextHolder.getCurrentUserId(); |
| | | StringBuilder sql = new StringBuilder(256); |
| | | sql.append("\nselect uuid,name,date_format(created_utc_datetime,'%Y-%m-%d %H:%i:%s') created_utc_datetime,created_by,type from ("); |
| | | sql.append("\n select uuid,name,created_utc_datetime,created_by,0 as type from product_oa_cooperates_template where created_by=? and created_by<>1"); |
| | | sql.append("\n union all"); |
| | | sql.append("\n select uuid,name,created_utc_datetime,created_by,1 as type from product_oa_cooperates_template where find_in_set(?,share_user)>0 and created_by<>1 and created_by<>?"); |
| | | sql.append("\n union all"); |
| | | sql.append("\n select uuid,name,created_utc_datetime,created_by,2 as type from product_oa_cooperates_template where created_by=1"); |
| | | sql.append("\nselect uuid,name,created_utc_datetime,created_by,type from ("); |
| | | sql.append("\n select uuid,name,created_utc_datetime,created_by,0 as type from product_oa_cooperates_template where created_by=? and created_by<>1"); |
| | | sql.append("\n union all"); |
| | | sql.append("\n select uuid,name,created_utc_datetime,created_by,1 as type from product_oa_cooperates_template where find_in_set(?,share_user)>0 and created_by<>1 and created_by<>?"); |
| | | sql.append("\n union all"); |
| | | sql.append("\n select uuid,name,created_utc_datetime,created_by,2 as type from product_oa_cooperates_template where created_by=1"); |
| | | sql.append("\n) t"); |
| | | sql.append("\norder by created_utc_datetime desc"); |
| | | return baseDao.listTable(sql.toString(), new Object[]{curUserID, curUserID, curUserID}); |
| | |
| | | import com.product.quartz.service.impl.SysJobService; |
| | | import com.product.util.BaseUtil; |
| | | import com.product.util.SystemParamReplace; |
| | | import com.product.util.UnifySQLFunction; |
| | | |
| | | import org.apache.commons.codec.binary.Base64; |
| | | import org.quartz.SchedulerException; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | sql.append("\n select org_level_code from product_sys_staffs sc inner join product_sys_org_levels d on sc.dept_uuid=d.uuid and sc.is_dept_manage=1 and user_id=?"); |
| | | sql.append("\n ) o on s.tricode like concat(o.org_level_code,'%')"); |
| | | sql.append("\n union all"); |
| | | sql.append("\n select ? from dual"); |
| | | sql.append("\n ").append(UnifySQLFunction.dualFunction("?")); |
| | | sql.append("\n) u on concat(',',i.receiver,',') like concat('%,',u.user_id,',%')"); |
| | | sql.append("\nwhere early_warning_uuid is not null"); |
| | | |
| | |
| | | import com.product.core.service.support.AbstractBaseService; |
| | | import com.product.core.spring.context.SpringMVCContextHolder; |
| | | import com.product.module.sys.entity.SystemUser; |
| | | import com.product.util.UnifySQLFunction; |
| | | |
| | | /** |
| | | * 打卡记录 |
| | |
| | | |
| | | //获取使用到的设置规则 |
| | | StringBuilder sbPunchTime=new StringBuilder(); |
| | | sbPunchTime.append(" SELECT c.* "); |
| | | sbPunchTime.append(" FROM ( "); |
| | | sbPunchTime.append(" SELECT d.* "); |
| | | sbPunchTime.append(" FROM product_oa_punch_time d "); |
| | | sbPunchTime.append(" left JOIN product_oa_punch_record b "); |
| | | sbPunchTime.append(" on d.punch_site_uuid=b.punch_congfig_uuid and d.created_by=? where d.punch_site_uuid= ? "); |
| | | sbPunchTime.append(" ) c "); |
| | | sbPunchTime.append(" where c.uuid in ( "); |
| | | sbPunchTime.append(" SELECT DISTINCT uuid "); |
| | | sbPunchTime.append(" FROM product_oa_punch_time "); |
| | | sbPunchTime.append(" where LOCATE(?, concat(attendance_object,','))>0 "); |
| | | sbPunchTime.append(" ) "); |
| | | sbPunchTime.append("\nSELECT c.* "); |
| | | sbPunchTime.append("\nFROM ( "); |
| | | sbPunchTime.append("\n SELECT d.* "); |
| | | sbPunchTime.append("\n FROM product_oa_punch_time d "); |
| | | sbPunchTime.append("\n left JOIN product_oa_punch_record b "); |
| | | sbPunchTime.append("\n on d.punch_site_uuid=b.punch_congfig_uuid and d.created_by=? where d.punch_site_uuid= ? "); |
| | | sbPunchTime.append("\n) c "); |
| | | sbPunchTime.append("\nwhere c.uuid in ( "); |
| | | sbPunchTime.append("\n SELECT DISTINCT uuid "); |
| | | sbPunchTime.append("\n FROM product_oa_punch_time "); |
| | | sbPunchTime.append("\n where ").append(UnifySQLFunction.locateFunction("?", "concat(attendance_object,',')")).append(" >0 "); |
| | | sbPunchTime.append("\n) "); |
| | | DataTableEntity dataTableEntity = baseDao.listTable(sbPunchTime.toString(), param1.toArray()); |
| | | |
| | | |
| | |
| | | param2.add(sign_date); |
| | | |
| | | StringBuilder sbReplenish=new StringBuilder(); |
| | | sbReplenish.append(" SELECT T1.id,T1.uuid,T1.created_by,T1.applicant,T1.replenish_date,T1.reason,"); |
| | | sbReplenish.append(" SUBSTRING_INDEX( SUBSTRING_INDEX( T1.replacement_card_type, ',', T2.digit + 1 ), ',',- 1 ) AS type "); |
| | | sbReplenish.append(" FROM (select * from product_oa_replenish_punch where flow_flag=2) T1 "); |
| | | sbReplenish.append(" JOIN ( SELECT 0 AS digit UNION ALL SELECT 1 UNION ALL SELECT 2 UNION ALL SELECT 3 ) T2"); |
| | | sbReplenish.append(" ON T2.digit < ( length( T1.replacement_card_type )- length( REPLACE ( T1.replacement_card_type, ',', '' ))+ 1 )"); |
| | | sbReplenish.append(" where t1.created_by=? "); |
| | | sbReplenish.append(" and DATE_FORMAT( t1.replenish_date, '%Y-%m-%d' )=? "); |
| | | sbReplenish.append("\nSELECT"); |
| | | sbReplenish.append("\n T1.id,T1.uuid,T1.created_by,T1.applicant,T1.replenish_date,T1.reason,"); |
| | | sbReplenish.append("\n ").append(UnifySQLFunction.substringIndexFuntion(UnifySQLFunction.substringIndexFuntion("T1.replacement_card_type", ",", "T2.digit + 1"), ",", "- 1")).append(" AS type "); |
| | | sbReplenish.append("\nFROM ("); |
| | | sbReplenish.append("\n select * from product_oa_replenish_punch where flow_flag=2"); |
| | | sbReplenish.append("\n) T1 "); |
| | | sbReplenish.append("\nJOIN ( SELECT 0 AS digit UNION ALL SELECT 1 UNION ALL SELECT 2 UNION ALL SELECT 3 ) T2"); |
| | | sbReplenish.append("\nON T2.digit < ( length( T1.replacement_card_type )- length( REPLACE ( T1.replacement_card_type, ',', '' ))+ 1 )"); |
| | | sbReplenish.append("\nwhere t1.created_by=? "); |
| | | sbReplenish.append("\nand DATE_FORMAT( t1.replenish_date, '%Y-%m-%d' )=? "); |
| | | DataTableEntity dataTableEntity1 = baseDao.listTable(sbReplenish.toString(), param2.toArray()); |
| | | if(dataTableEntity1.getRows()!=0){ |
| | | |
| | |
| | | package com.product.administration.service; |
| | | |
| | | import java.sql.SQLException; |
| | | import java.time.LocalDate; |
| | | import java.util.*; |
| | | import java.time.YearMonth; |
| | |
| | | import com.product.administration.util.WorkDayUtil; |
| | | import com.product.common.lang.DateUtils; |
| | | import com.product.common.lang.StringUtils; |
| | | import com.product.core.connection.ConnectionManager; |
| | | import com.product.core.dao.BaseDao; |
| | | import com.product.core.entity.DataTableEntity; |
| | | import com.product.core.entity.FieldSetEntity; |
| | |
| | | /*=================*/ |
| | | sb.append("\n SELECT *"); |
| | | sb.append("\n FROM ("); |
| | | sb.append("\n SELECT ").append(UnifySQLFunction.dateAdd("t.month_start", "d.day", "DAY")).append(" punch_date"); |
| | | sb.append("\n SELECT ").append(UnifySQLFunction.calculateTimeFunction("t.month_start", true, "d.day", "DAY")).append(" punch_date"); |
| | | sb.append("\n FROM (SELECT ? month_start) t"); |
| | | param.add(yearAndMonth+"-01"); |
| | | sb.append("\n INNER JOIN ("); |
| | |
| | | sb.append("\n WHERE t1.punch_date<=?"); |
| | | param.add(day); |
| | | /*==================*/ |
| | | sb.append(") a "); |
| | | sb.append("\n) a "); |
| | | sb.append(" LEFT JOIN (SELECT * FROM product_oa_ask_for_leave WHERE user_id=? and flow_flag=2) b "); |
| | | param.add(user_id); |
| | | sb.append(" on ").append(UnifySQLFunction.dateFormat("a.punch_date", "yyyy-MM-dd")).append(">= ").append(UnifySQLFunction.dateFormat("b.start_time", "yyyy-MM-dd")).append(" and ").append(UnifySQLFunction.dateFormat("a.punch_date", "yyyy-MM-dd")).append("<= ").append(UnifySQLFunction.dateFormat("b.end_time", "yyyy-MM-dd")).append(" "); |
| | |
| | | ArrayList<String> param = new ArrayList<>(); |
| | | |
| | | StringBuilder sb=new StringBuilder(); |
| | | sb.append(" SELECT "); |
| | | sb.append(" b.user_id,( SELECT user_name FROM product_sys_users WHERE user_id = b.user_id ) created_by, "); |
| | | sb.append(" ( SELECT org_level_name FROM product_sys_org_levels WHERE uuid = dept_uuid ) dept_uuid, "); |
| | | sb.append(" "+dayOfWork+" dayOfWork,workDayOfMonth,lateCome,leaveEarly,total_hours,askForLeave,("+dayOfWork+" - workDayOfMonth-askForLeave) absenteeism "); |
| | | sb.append(" FROM(SELECT b.created_by,b.workDayOfMonth+bb.replenish_date workDayOfMonth,b.dept_uuid,b.lateCome1 lateCome,b.leaveEarly2 leaveEarly FROM "); |
| | | sb.append(" (SELECT a.created_by,COUNT( day_of_month ) workDayOfMonth,a.dept_uuid, "); |
| | | sb.append(" COUNT(IF( result1 like '%迟到%', TRUE, NULL )) lateCome1,"); |
| | | sb.append(" COUNT(IF( result3 like '%迟到%', TRUE, NULL )) lateCome2,"); |
| | | sb.append(" COUNT(IF( result2 like '%早退%', TRUE, NULL )) leaveEarly1, "); |
| | | sb.append(" COUNT(IF( result4 like '%早退%', TRUE, NULL )) leaveEarly2 "); |
| | | sb.append(" FROM(SELECT d.created_by,d.dept_uuid,DATE_FORMAT( d.punch_time, '%Y-%m-%d' ) day_of_month,punch_type1 result1,punch_type2 result2,punch_type3 result3,punch_type4 result4 "); |
| | | sb.append(" FROM product_oa_punch_record_v d "); |
| | | sb.append(" LEFT JOIN product_oa_punch_time e ON e.attendance_object like CONCAT('%',d.created_by,'%') "); |
| | | sb.append(" where DATE_FORMAT( d.punch_time, '%Y-%m' )=? "); |
| | | sb.append("\nSELECT "); |
| | | sb.append("\n b.user_id,( SELECT user_name FROM product_sys_users WHERE user_id = b.user_id ) created_by, "); |
| | | sb.append("\n ( SELECT org_level_name FROM product_sys_org_levels WHERE uuid = dept_uuid ) dept_uuid, "); |
| | | sb.append("\n "+dayOfWork+" dayOfWork,workDayOfMonth,lateCome,leaveEarly,total_hours,askForLeave,("+dayOfWork+" - workDayOfMonth-askForLeave) absenteeism "); |
| | | sb.append("\nFROM("); |
| | | sb.append("\n SELECT b.created_by,b.workDayOfMonth+bb.replenish_date workDayOfMonth,b.dept_uuid,b.lateCome1 lateCome,b.leaveEarly2 leaveEarly"); |
| | | sb.append("\n FROM ("); |
| | | sb.append("\n SELECT a.created_by,COUNT( day_of_month ) workDayOfMonth,a.dept_uuid, "); |
| | | sb.append("\n COUNT(").append(UnifySQLFunction.ifFunction("result1 like '%迟到%'", "TRUE", "NULL")).append(") lateCome1,"); |
| | | sb.append("\n COUNT(").append(UnifySQLFunction.ifFunction("result3 like '%迟到%'", "TRUE", "NULL")).append(") lateCome2,"); |
| | | sb.append("\n COUNT(").append(UnifySQLFunction.ifFunction("result2 like '%早退%'", "TRUE", "NULL")).append(") leaveEarly1,"); |
| | | sb.append("\n COUNT(").append(UnifySQLFunction.ifFunction("result4 like '%早退%'", "TRUE", "NULL")).append(") leaveEarly2"); |
| | | sb.append("\n FROM("); |
| | | sb.append("\n SELECT d.created_by,d.dept_uuid,d.punch_time AS day_of_month,punch_type1 result1,punch_type2 result2,punch_type3 result3,punch_type4 result4 "); |
| | | sb.append("\n FROM product_oa_punch_record_v d "); |
| | | sb.append("\n LEFT JOIN product_oa_punch_time e ON e.attendance_object LIKE CONCAT('%',d.created_by,'%') "); |
| | | sb.append("\n WHERE ").append(UnifySQLFunction.timeFunction("d.punch_time", "year_and_month")).append(" =? "); |
| | | param.add(yearAndMonth); |
| | | sb.append(" AND DATE_FORMAT( d.punch_time, '%Y-%m-%d' ) NOT IN ( SELECT date_holiday FROM product_sys_company_holiday )) a "); |
| | | sb.append(" GROUP BY a.created_by,a.dept_uuid ) b "); |
| | | |
| | | sb.append(" LEFT JOIN (SELECT applicant,COUNT( 1 ) replenish_date FROM "); |
| | | sb.append(" (SELECT applicant,DATE_FORMAT(replenish_date, '%Y-%m-%d') replenish_date FROM product_oa_replenish_punch a "); |
| | | sb.append(" LEFT JOIN product_oa_punch_record_v b on DATE_FORMAT(a.replenish_date, '%Y-%m-%d')=b.punch_time and a.applicant=b.created_by "); |
| | | sb.append(" where b.created_by is null and DATE_FORMAT(replenish_date, '%Y-%m')=? GROUP BY DATE_FORMAT(replenish_date, '%Y-%m-%d'),applicant)a "); |
| | | sb.append("\n AND ").append(UnifySQLFunction.timeFunction("d.punch_time", "year_month_day")).append(" NOT IN ( SELECT ").append(UnifySQLFunction.timeFunction("date_holiday", "year_month_day")).append(" FROM product_sys_company_holiday )"); |
| | | sb.append("\n ) a "); |
| | | sb.append("\n GROUP BY a.created_by,a.dept_uuid"); |
| | | sb.append("\n ) b "); |
| | | sb.append("\n LEFT JOIN ("); |
| | | sb.append("\n SELECT applicant,COUNT( 1 ) replenish_date"); |
| | | sb.append("\n FROM ("); |
| | | sb.append("\n SELECT applicant,DATE_FORMAT(replenish_date, '%Y-%m-%d') replenish_date "); |
| | | sb.append("\n FROM product_oa_replenish_punch a "); |
| | | sb.append("\n LEFT JOIN product_oa_punch_record_v b on DATE_FORMAT(a.replenish_date, '%Y-%m-%d')=b.punch_time and a.applicant=b.created_by "); |
| | | sb.append("\n WHERE b.created_by is null and DATE_FORMAT(replenish_date, '%Y-%m')=? "); |
| | | sb.append("\n GROUP BY DATE_FORMAT(replenish_date, '%Y-%m-%d'),applicant"); |
| | | sb.append("\n )a "); |
| | | param.add(yearAndMonth); |
| | | sb.append(" GROUP BY applicant,DATE_FORMAT(replenish_date, '%Y-%m')) bb on b.created_by=bb.applicant "); |
| | | sb.append(" ) a "); |
| | | sb.append(" RIGHT JOIN (SELECT user_id,sum( duration ) total_hours FROM product_oa_work_overtime o "); |
| | | sb.append(" LEFT JOIN product_oa_work_overtime_sub b ON o.uuid = b.main_uuid AND DATE_FORMAT( b.start_time, '%Y-%m' )=? "); |
| | | sb.append("\n GROUP BY applicant,DATE_FORMAT(replenish_date, '%Y-%m')) bb on b.created_by=bb.applicant "); |
| | | sb.append("\n) a "); |
| | | sb.append("\nRIGHT JOIN ("); |
| | | sb.append("\n SELECT user_id,sum( duration ) total_hours"); |
| | | sb.append("\n FROM product_oa_work_overtime o "); |
| | | sb.append("\n LEFT JOIN product_oa_work_overtime_sub b ON o.uuid = b.main_uuid AND DATE_FORMAT( b.start_time, '%Y-%m' )=? "); |
| | | param.add(yearAndMonth); |
| | | sb.append(" GROUP BY o.user_id ) b ON a.created_by = b.user_id "); |
| | | sb.append(" LEFT JOIN "); |
| | | sb.append("(SELECT a.created_by,sum(askForLeave) askForLeave FROM (SELECT a.created_by,a.askForLeave-COUNT(1) askForLeave FROM "); |
| | | sb.append(" (SELECT created_by,DATEDIFF(if(DATE_FORMAT(end_time, '%Y-%m-%d')<=?,DATE_FORMAT(end_time, '%Y-%m-%d'),?), if(DATE_FORMAT(start_time, '%Y-%m-%d' )>=?,DATE_FORMAT(start_time, '%Y-%m-%d' ),?))+1 askForLeave,start_time,end_time "); |
| | | sb.append(" FROM product_oa_ask_for_leave a where (DATE_FORMAT( start_time, '%Y-%m' )=? or DATE_FORMAT( end_time, '%Y-%m' )=?) AND flow_flag = 2 ) a "); |
| | | sb.append("\n GROUP BY o.user_id"); |
| | | sb.append("\n) b ON a.created_by = b.user_id "); |
| | | sb.append("\nLEFT JOIN ("); |
| | | sb.append("\n SELECT a.created_by,sum(askForLeave) askForLeave"); |
| | | sb.append("\n FROM ("); |
| | | sb.append("\n SELECT a.created_by,a.askForLeave-COUNT(1) askForLeave"); |
| | | sb.append("\n FROM ("); |
| | | sb.append("\n SELECT"); |
| | | sb.append("\n created_by,start_time,end_time,("); |
| | | sb.append("\n ").append(UnifySQLFunction.dateDiffFunction(UnifySQLFunction.ifFunction("DATE_FORMAT(end_time, '%Y-%m-%d')<=?", "DATE_FORMAT(end_time, '%Y-%m-%d')", "?"), |
| | | UnifySQLFunction.ifFunction("DATE_FORMAT(start_time, '%Y-%m-%d')>=?", "DATE_FORMAT(start_time, '%Y-%m-%d')", "?"))); |
| | | sb.append("\n )+1 askForLeave "); |
| | | sb.append("\n FROM product_oa_ask_for_leave a"); |
| | | sb.append("\n WHERE (DATE_FORMAT( start_time, '%Y-%m' )=? or DATE_FORMAT( end_time, '%Y-%m' )=?) AND flow_flag = 2 "); |
| | | sb.append("\n ) a "); |
| | | param.add(String.valueOf(monthEndDate)); |
| | | param.add(String.valueOf(monthEndDate)); |
| | | param.add(yearAndMonth+"-01"); |
| | |
| | | |
| | | param.add(yearAndMonth); |
| | | param.add(yearAndMonth); |
| | | sb.append(" LEFT JOIN product_sys_company_holiday b on b.date_holiday<= a.end_time and b.date_holiday>=a.start_time and DATE_FORMAT(b.date_holiday, '%Y-%m')=?"); |
| | | sb.append(" GROUP BY a.created_by,a.askForLeave) a GROUP BY created_by )"); |
| | | sb.append("\n LEFT JOIN product_sys_company_holiday b on b.date_holiday<= a.end_time and b.date_holiday>=a.start_time and DATE_FORMAT(b.date_holiday, '%Y-%m')=?"); |
| | | sb.append("\n GROUP BY a.created_by,a.askForLeave"); |
| | | sb.append("\n ) a GROUP BY created_by "); |
| | | sb.append("\n) c ON b.user_id = c.created_by "); |
| | | sb.append("\nORDER BY dept_uuid,a.created_by"); |
| | | param.add(yearAndMonth); |
| | | |
| | | sb.append(" c ON b.user_id = c.created_by "); |
| | | sb.append(" ORDER BY dept_uuid,a.created_by"); |
| | | |
| | | DataTableEntity dataTableEntityReport = baseDao.listTable(sb.toString(), param.toArray()); |
| | | DataTableEntity dataTableEntityReport = baseDao.listTable(UnifySQLFunction.timeFunctionReplace("multiple", sb.toString()), param.toArray()); |
| | | for (int i = 0; i <dataTableEntityReport.getRows() ; i++) { |
| | | FieldSetEntity fs = dataTableEntityReport.getFieldSetEntity(i); |
| | | if (StringUtils.isEmpty(fs.getString("dept_uuid"))){ |
| | | FieldSetEntity org_level_name = baseDao.getFieldSetEntityBySQL("SELECT org_level_name FROM `product_sys_staffs` a LEFT JOIN product_sys_org_levels b on a.dept_uuid=b.uuid where a.user_id=?", new String[]{fs.getString("user_id")}, false); |
| | | FieldSetEntity org_level_name = baseDao.getFieldSetEntityBySQL("SELECT org_level_name FROM product_sys_staffs a LEFT JOIN product_sys_org_levels b on a.dept_uuid=b.uuid where a.user_id=?", new String[]{fs.getString("user_id")}, false); |
| | | fs.setValue("dept_uuid",org_level_name.getString("org_level_name")); |
| | | } |
| | | } |