| | |
| | | package com.product.administration.service; |
| | | |
| | | import cn.hutool.core.date.DateUnit; |
| | | import cn.hutool.core.date.DateUtil; |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.google.errorprone.annotations.Var; |
| | | import com.google.zxing.BarcodeFormat; |
| | | import com.google.zxing.EncodeHintType; |
| | | import com.google.zxing.MultiFormatWriter; |
| | | import com.google.zxing.WriterException; |
| | | import com.google.zxing.common.BitMatrix; |
| | | import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel; |
| | | import com.product.administration.config.CmnConst; |
| | | import com.product.administration.config.SystemCode; |
| | | import com.product.administration.service.ide.IConferenceManagerService; |
| | |
| | | import com.product.core.dao.BaseDao; |
| | | import com.product.core.entity.DataTableEntity; |
| | | import com.product.core.entity.FieldSetEntity; |
| | | import com.product.core.entity.RequestParameterEntity; |
| | | import com.product.core.exception.BaseException; |
| | | import com.product.core.permission.PermissionService; |
| | | import com.product.core.service.support.AbstractBaseService; |
| | | import com.product.core.service.support.QueryFilterService; |
| | | import com.product.core.spring.context.SpringMVCContextHolder; |
| | | import com.product.core.transfer.Transactional; |
| | | import com.product.core.util.QuickResponUtil; |
| | | import com.product.core.websocket.service.WebsocketMesssageServiceThread; |
| | | import com.product.module.sys.entity.SystemUser; |
| | | import com.product.util.BaseUtil; |
| | | import org.apache.poi.hssf.usermodel.HSSFCellStyle; |
| | | import org.omg.CORBA.OBJ_ADAPTER; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.imageio.ImageIO; |
| | | import java.awt.image.BufferedImage; |
| | | import java.io.File; |
| | | import java.io.IOException; |
| | | import java.text.DecimalFormat; |
| | | import java.text.Format; |
| | | import java.text.ParseException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | |
| | |
| | | String filter=" meeting_room = '"+fieldSetEntity.getString("meeting_room")+"' and DATE_FORMAT(start_time,\"%Y-%m-%d\") ='"+meeting_date+"'"; |
| | | DataTableEntity product_oa_conference_apply = baseDao.listTable("product_oa_conference_apply", filter, new Object[]{}); |
| | | for (int i1 = 0; i1 < product_oa_conference_apply.getRows(); i1++) { |
| | | FieldSetEntity fieldSetEntity1 = product_oa_conference_apply.getData().get(i); |
| | | FieldSetEntity fieldSetEntity1 = product_oa_conference_apply.getFieldSetEntity(i1); |
| | | Date date = new Date(); |
| | | if(date.before(fieldSetEntity1.getDate("start_time"))){ |
| | | fieldSetEntity1.setValue("status","未开始"); |
| | |
| | | }else { |
| | | fieldSetEntity1.setValue("status","会议中"); |
| | | } |
| | | |
| | | baseDao.executeUpdate("update product_oa_conference_apply set status='"+fieldSetEntity1.getString("status")+"' where uuid='"+fieldSetEntity1.getString("uuid")+"'"); |
| | | } |
| | | baseDao.update(product_oa_conference_apply); |
| | | //构造所需要的格式 |
| | | if(!list.contains(fieldSetEntity.getValue("room_name").toString())){ |
| | | HashMap<String,Object> hashMap=new HashMap<>(); |
| | |
| | | param.add(meeting_room); |
| | | param.add(meeting_date); |
| | | StringBuilder sb=new StringBuilder(); |
| | | sb.append(" SELECT b.uuid,b.start_time,b.end_time,b.meeting_topic,b.status, "); |
| | | sb.append(" SELECT b.uuid,b.start_time,b.end_time,b.meeting_topic,b.status,b.record_man as record_man_uuid, "); |
| | | sb.append(" (select user_name from product_sys_users where user_id=b.record_man) as record_man,"); |
| | | sb.append(" (select user_name from product_sys_users where user_id=b.record_master) as record_master,"); |
| | | sb.append(" CONCAT(DATE_FORMAT(b.start_time,\"%H-%i-%S\"),'~',DATE_FORMAT(b.end_time,\"%H-%i-%S\")) as time_quantum,"); |
| | |
| | | sb.append(" SELECT T1.*, "); |
| | | sb.append(" SUBSTRING_INDEX( SUBSTRING_INDEX( T1.meeting_resource, ',', T2.digit + 1 ), ',',- 1 ) AS type "); |
| | | sb.append(" FROM product_oa_conference_apply T1 "); |
| | | sb.append(" 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(" 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 )"); |
| | | sb.append(" WHERE t1.meeting_room = ? "); |
| | | sb.append(" and DATE_FORMAT(t1.start_time,\"%Y-%m-%d\")=? "); |
| | | sb.append(" WHERE T1.meeting_room = ? "); |
| | | sb.append(" and DATE_FORMAT(T1.start_time,\"%Y-%m-%d\")=? "); |
| | | sb.append(" ) a"); |
| | | sb.append(" LEFT JOIN product_sys_dict t ON a.type = t.dict_value "); |
| | | sb.append(" AND t.dict_name = '会议室资源'"); |
| | |
| | | MapValues.put("start_time",start_time_date); |
| | | MapValues.put("end_time",end_time_date); |
| | | } |
| | | |
| | | Date date = new Date(); |
| | | //是否能够取消 |
| | | if(date.before(fieldSetEntity.getDate("start_time"))){ |
| | | MapValues.put("isCancel",true); |
| | | } |
| | | //是否执行开启功能 |
| | | if(date.before(fieldSetEntity.getDate("start_time")) && fieldSetEntity.getString("status").equals("已取消")){ |
| | | MapValues.put("isStart",true); |
| | | } |
| | | dataList.add(MapValues); |
| | | } |
| | | return dataList; |
| | |
| | | |
| | | } |
| | | |
| | | @Override |
| | | @Transactional |
| | | public HashMap saveOrUpdateMeetingInfo(FieldSetEntity fse) throws BaseException { |
| | | |
| | | Date start_time_date = fse.getDate("start_time"); |
| | | SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | String format = dateFormat.format(start_time_date); |
| | | |
| | | |
| | | String filter=" DATE_FORMAT(start_time,\"%Y-%m-%d\") ='"+format.split(" ")[0]+"'"; |
| | | |
| | | DataTableEntity dataTableEntity = baseDao.listTable("product_oa_conference_apply",filter,new Object[]{}); |
| | | boolean flag=true; |
| | | for (int i = 0; i < dataTableEntity.getRows(); i++) { |
| | | FieldSetEntity fieldSetEntity = dataTableEntity.getData().get(i); |
| | | Date start_time = fse.getDate("start_time"); |
| | | Date end_time = fse.getDate("end_time"); |
| | | Date start_time1 =fieldSetEntity.getDate("start_time"); |
| | | Date end_time1 = fieldSetEntity.getDate("end_time"); |
| | | if(start_time1.before(start_time) && end_time1.after(start_time)){ |
| | | flag=false; |
| | | } |
| | | if(start_time1.before(end_time) && end_time1.after(end_time)){ |
| | | flag=false; |
| | | } |
| | | |
| | | if(start_time1.after(start_time) && end_time1.before(end_time)){ |
| | | flag=false; |
| | | } |
| | | |
| | | } |
| | | HashMap<String,Object> hashMap=new HashMap<>(); |
| | | BaseUtil.createCreatorAndCreationTime(SpringMVCContextHolder.getCurrentUser(), fse); |
| | | if(flag==false){ |
| | | hashMap.put("code","200"); |
| | | hashMap.put("msg","此时间段已被占用"); |
| | | hashMap.put("status","sucess"); |
| | | }else { |
| | | if(ObjectUtil.isNotEmpty(fse.getValue("uuid"))){ |
| | | baseDao.update(fse); |
| | | }else { |
| | | baseDao.add(fse); |
| | | } |
| | | hashMap.put("code","200"); |
| | | hashMap.put("msg","成功"); |
| | | hashMap.put("status","sucess"); |
| | | } |
| | | return hashMap; |
| | | } |
| | | |
| | | @Override |
| | | public BitMatrix getQrCode(String content) throws BaseException, WriterException, IOException { |
| | | |
| | | //二维码的宽高 |
| | | int width = 200; |
| | | int height = 200; |
| | | |
| | | //其他参数,如字符集编码 |
| | | Map<EncodeHintType, Object> hints = new HashMap<EncodeHintType, Object>(); |
| | | hints.put(EncodeHintType.CHARACTER_SET, "UTF-8"); |
| | | //容错级别为H |
| | | hints.put(EncodeHintType.ERROR_CORRECTION , ErrorCorrectionLevel.H); |
| | | //白边的宽度,可取0~4 |
| | | hints.put(EncodeHintType.MARGIN , 0); |
| | | |
| | | BitMatrix bitMatrix = null; |
| | | try { |
| | | |
| | | bitMatrix = new MultiFormatWriter().encode(content, |
| | | BarcodeFormat.QR_CODE, width, height, hints); |
| | | |
| | | } catch (WriterException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | return bitMatrix; |
| | | } |
| | | |
| | | @Override |
| | | public void CancelAndStart(FieldSetEntity fse) throws BaseException { |
| | | |
| | | String uuid = fse.getString("uuid"); |
| | | String filter=" uuid='"+uuid+"'"; |
| | | DataTableEntity product_oa_conference_apply = baseDao.listTable("product_oa_conference_apply", filter, new Object[]{}); |
| | | if(product_oa_conference_apply.getRows()!=0){ |
| | | FieldSetEntity fieldSetEntity = product_oa_conference_apply.getFieldSetEntity(0); |
| | | if(fieldSetEntity.getString("status").equals("已取消")){ |
| | | fieldSetEntity.setValue("status","已启用"); |
| | | }else { |
| | | fieldSetEntity.setValue("status","已取消"); |
| | | } |
| | | baseDao.update(fieldSetEntity); |
| | | } |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public String ConferenceSign(FieldSetEntity fse) throws BaseException, ParseException { |
| | | |
| | | |
| | | JSONObject jsonObject = new JSONObject(); |
| | | if(!StringUtils.isEmpty(fse.getString("uuid"))&&!StringUtils.isEmpty(fse.getString("date"))){ |
| | | String uuid = fse.getString("uuid"); |
| | | String date = fse.getString("date"); |
| | | SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | Date parseDate = dateFormat.parse(date); |
| | | long between = DateUtil.between(parseDate, new Date(), DateUnit.SECOND); |
| | | |
| | | if(between>20){ |
| | | jsonObject.put("code","200"); |
| | | jsonObject.put("msg","二维码已失效"); |
| | | jsonObject.put("status","fail"); |
| | | |
| | | }else { |
| | | |
| | | SystemUser currentUser = SpringMVCContextHolder.getCurrentUser(); |
| | | FieldSetEntity fieldSetEntity = new FieldSetEntity(); |
| | | fieldSetEntity.setTableName("product_oa_conference_sign"); |
| | | fieldSetEntity.setValue("sign_user",currentUser.getUser_name()); |
| | | fieldSetEntity.setValue("user_id",currentUser.getUser_id()); |
| | | fieldSetEntity.setValue("org_level_uuid","00000000-0000-0000-0000-000000000000"); |
| | | fieldSetEntity.setValue("organization",currentUser.getDept_uuid()); |
| | | fieldSetEntity.setValue("organization_name",currentUser.getCurrentDept().getString("org_level_name")); |
| | | fieldSetEntity.setValue("sign_date",new Date()); |
| | | fieldSetEntity.setValue("sign_status","已签到"); |
| | | fieldSetEntity.setValue("meeting_uuid",uuid); |
| | | |
| | | BaseUtil.createCreatorAndCreationTime(SpringMVCContextHolder.getCurrentUser(), fse); |
| | | baseDao.add(fieldSetEntity); |
| | | jsonObject.put("code","200"); |
| | | jsonObject.put("msg","签到成功"); |
| | | jsonObject.put("status","sucess"); |
| | | } |
| | | } |
| | | |
| | | return jsonObject.toString(); |
| | | } |
| | | |
| | | @Override |
| | | public HashMap getSignInfo(FieldSetEntity fse) throws BaseException { |
| | | |
| | | String meeting_uuid = fse.getString("meeting_uuid"); |
| | | List<Object> params=new ArrayList<>(); |
| | | params.add(meeting_uuid); |
| | | params.add(meeting_uuid); |
| | | |
| | | StringBuilder sb=new StringBuilder(); |
| | | sb.append(" SELECT c.* FROM ( "); |
| | | sb.append(" SELECT b.staff_id,b.uuid as meeting_uuid,f.show_name,l.uuid as dept_uuid,l.org_level_name,n.sign_status "); |
| | | sb.append(" FROM (" ); |
| | | sb.append(" SELECT y.*, "); |
| | | sb.append(" SUBSTRING_INDEX( SUBSTRING_INDEX( participator, ',', n ), ',', - 1 ) AS staff_id"); |
| | | sb.append(" FROM product_oa_conference_apply y, "); |
| | | sb.append(" ( SELECT @rownum := @rownum + 1 AS n FROM ( SELECT @rownum := 0 ) r, product_oa_conference_apply ) x "); |
| | | sb.append(" WHERE 1 = 1 "); |
| | | sb.append(" AND n <= ( LENGTH( participator ) - LENGTH( REPLACE ( participator, ',', '' ) ) + 1 )"); |
| | | sb.append(" and y.uuid= ? "); |
| | | sb.append(" )b "); |
| | | sb.append(" LEFT JOIN product_sys_staffs f on b.staff_id=f.user_id "); |
| | | sb.append(" LEFT JOIN product_sys_org_levels l on f.dept_uuid=l.uuid "); |
| | | sb.append(" LEFT JOIN product_oa_conference_sign n on b.staff_id=n.user_id and n.meeting_uuid=? "); |
| | | sb.append(" )c"); |
| | | |
| | | DataTableEntity dataTableEntity = baseDao.listTable(sb.toString(),params.toArray()); |
| | | List<HashMap> listDate=new ArrayList<>(); |
| | | List<HashMap> listDateSign=new ArrayList<>(); |
| | | List<HashMap> listDateNoSign=new ArrayList<>(); |
| | | |
| | | List<String> list=new ArrayList(); |
| | | |
| | | int sign_count=0; |
| | | int sign_all=0; |
| | | int sign_down=0; |
| | | HashMap<String,Object> hashMapResult=new HashMap<>(); |
| | | for (int i = 0; i < dataTableEntity.getRows(); i++) { |
| | | FieldSetEntity fieldSetEntity = dataTableEntity.getFieldSetEntity(i); |
| | | |
| | | if(!list.contains(fieldSetEntity.getString("org_level_name"))){ |
| | | HashMap<String,Object> hashMap=new HashMap<>(); |
| | | hashMap.put("dept_uuid",fieldSetEntity.getString("dept_uuid")); |
| | | hashMap.put("org_level_name",fieldSetEntity.getString("org_level_name")); |
| | | list.add(fieldSetEntity.getString("org_level_name")); |
| | | listDate.add(hashMap); |
| | | } |
| | | |
| | | fieldSetEntity.setValue("parent",fieldSetEntity.getString("dept_uuid")); |
| | | HashMap<String,Object> hashMap=new HashMap<>(); |
| | | for (int j = 0; j < fieldSetEntity.getValues().keySet().size(); j++) { |
| | | hashMap.put(fieldSetEntity.getValues().keySet().toArray()[j].toString(),fieldSetEntity.getValue(fieldSetEntity.getValues().keySet().toArray()[j].toString())); |
| | | |
| | | } |
| | | listDate.add(hashMap); |
| | | |
| | | } |
| | | sign_all=listDate.size(); |
| | | List<String> list1=new ArrayList(); |
| | | List<String> list2=new ArrayList(); |
| | | for (int j = 0; j < listDate.size(); j++) { |
| | | if(ObjectUtil.isNotEmpty(listDate.get(j).get("sign_status"))&&listDate.get(j).get("sign_status").equals("已签到")){ |
| | | if(!list1.contains(listDate.get(j).get("org_level_name"))){ |
| | | list1.add(listDate.get(j).get("org_level_name").toString()); |
| | | HashMap<String,Object> hashMap=new HashMap<>(); |
| | | hashMap.put("dept_uuid",listDate.get(j).get("dept_uuid")); |
| | | hashMap.put("org_level_name",listDate.get(j).get("org_level_name")); |
| | | listDateSign.add(hashMap); |
| | | } |
| | | sign_count++; |
| | | //避免重复添加部门 |
| | | if(listDate.get(j).size()!=2){ |
| | | listDateSign.add(listDate.get(j)); |
| | | } |
| | | |
| | | }else { |
| | | if(!list2.contains(listDate.get(j).get("org_level_name"))){ |
| | | list2.add(listDate.get(j).get("org_level_name").toString()); |
| | | HashMap<String,Object> hashMap=new HashMap<>(); |
| | | hashMap.put("dept_uuid",listDate.get(j).get("dept_uuid")); |
| | | hashMap.put("org_level_name",listDate.get(j).get("org_level_name")); |
| | | listDateNoSign.add(hashMap); |
| | | } |
| | | //避免重复添加部门 |
| | | if(listDate.get(j).size()!=2){ |
| | | listDateNoSign.add(listDate.get(j)); |
| | | } |
| | | |
| | | |
| | | } |
| | | } |
| | | sign_down=sign_all-sign_count; |
| | | hashMapResult.put("sign_down",sign_count); |
| | | hashMapResult.put("no_sign",sign_down); |
| | | hashMapResult.put("listDateNoSign",listDateNoSign); |
| | | hashMapResult.put("listDateSign",listDateSign); |
| | | return hashMapResult; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 会议室使用情况 |