From 96c2e1b2442fa35b2a819e6c7e4ee524651828b2 Mon Sep 17 00:00:00 2001 From: cheng <1821349743@qq.com> Date: 星期日, 25 八月 2024 14:15:32 +0800 Subject: [PATCH] 获取表达输入性控件 --- src/main/java/com/product/mobile/core/service/SignInService.java | 136 +++++++++++++++++++++++++++++++++++++++------ 1 files changed, 117 insertions(+), 19 deletions(-) diff --git a/src/main/java/com/product/mobile/core/service/SignInService.java b/src/main/java/com/product/mobile/core/service/SignInService.java index 95026ea..f410bc1 100644 --- a/src/main/java/com/product/mobile/core/service/SignInService.java +++ b/src/main/java/com/product/mobile/core/service/SignInService.java @@ -3,6 +3,7 @@ import java.text.SimpleDateFormat; import java.util.Date; +import com.product.core.transfer.Transactional; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -30,26 +31,127 @@ public BaseDao baseDao; /** * 鍏堟煡鍑哄巻鍙叉墦鍗¤褰� - * @param cpage - * @param pagesize * @return * @throws BaseException */ + @Transactional public boolean signIn(FieldSetEntity fse) throws BaseException{ - fse.setTableName(MobileCoreConst.TABLE_PUNCH_RECORD); SystemUser user=SpringMVCContextHolder.getCurrentUser(); Date d = new Date(); - DataTableEntity dt=signInList(fse); - if(user!=null) { - fse.setValue(MobileCoreConst.ORG_LEVEL_UUID, user.getOrg_level_uuid()); - fse.setValue(MobileCoreConst.DEPT_UUID, user.getDept_uuid()); - fse.setValue(MobileCoreConst.CREATED_UTC_DATETIME, d); - } - fse.setValue(MobileCoreConst.FIELD_PUNCH_TYPE,1);//鎵嬫満鎵撳崱 + //鑾峰彇褰撳墠鏃堕棿鎵撳崱璁板綍 + FieldSetEntity fs_record=signInList(); + //鑾峰彇鎵撳崱璁剧疆 + FieldSetEntity fs_time = baseDao.getFieldSetByFilter(MobileCoreConst.TABLE_PUNCH_TIME, "punch_site_uuid=?", new Object[]{fse.getString("punch_congfig_uuid")}, false); + if (!StringUtils.isEmpty(fs_time.getString("morning_work_off"))&&!StringUtils.isEmpty(fs_time.getString("afternoon_work"))){ + //鍥涙鎵撳崱淇濆瓨瑙勫垯 + if (FieldSetEntity.isEmpty(fs_record)){ + //鏈煡璇㈠埌鎵撳紑璁板綍鏂板缓鎵撳崱璁板綍 + if(user!=null) { + fse.setValue(MobileCoreConst.ORG_LEVEL_UUID, user.getOrg_level_uuid()); + fse.setValue(MobileCoreConst.DEPT_UUID, user.getDept_uuid()); + fse.setValue(MobileCoreConst.CREATED_BY, user.getUser_id()); + fse.setValue(MobileCoreConst.CREATED_UTC_DATETIME, d); + } + fse.setValue(MobileCoreConst.FIELD_PUNCH_TYPE,1);//鎵嬫満鎵撳崱 + if (!StringUtils.isEmpty(fse.getDate("punch_time_one"))){ + if (dataCompareTo(fse.getDate("punch_time_one"),fs_time.getDate("morning_work_off"))){ + fse.setValue("punch_time_one",fse.getDate("punch_time_one")); + fse.setValue("punch_range_one",fse.getString("punch_range_one")); + }else { + fse.setValue("punch_time_three",fse.getDate("punch_time_one")); + fse.setValue("punch_range_three",fse.getString("punch_range_one")); + fse.setValue("punch_time_one",null); + fse.setValue("punch_range_one",null); + } + } + if (!StringUtils.isEmpty(fse.getDate("punch_time_four"))){ + if (dataCompareTo(fse.getDate("punch_time_four"),fs_time.getDate("afternoon_work_off"))){ + fse.setValue("punch_time_two",fse.getDate("punch_time_four")); + fse.setValue("punch_range_two",fse.getString("punch_range_four")); + }else { + fse.setValue("punch_time_two",null); + fse.setValue("punch_range_two",null); + fse.setValue("punch_time_four",fse.getDate("punch_time_four")); + fse.setValue("punch_range_four",fse.getString("punch_range_four")); + } + } + fse.setTableName(MobileCoreConst.TABLE_PUNCH_RECORD); + return baseDao.saveFieldSetEntity(fse); + } + else { + //鏌ヨ鍒板凡鏈夋墦寮�璁板綍鏂板缓鎵撳崱璁板綍 + if (!StringUtils.isEmpty(fse.getDate("punch_time_one"))){ + //鍒ゆ柇涓婄彮鎵撳崱鎵撳崱瑙勫垯锛�1銆佷笂鍗堜笂鐝湭鎵撳崱 2銆佹湭瓒呰繃涓婂崍涓嬬彮鏃堕棿 3銆佷笂鍗堟湭鎵撲笅鐝崱 鍒欎负涓婂崍涓婄彮鍗″惁鍒欎负涓嬪崍涓婄彮鍗� + if(dataCompareTo(fse.getDate("punch_time_one"),fs_time.getDate("morning_work_off")) + &&StringUtils.isEmpty(fs_record.getString("punch_time_one")) + &&StringUtils.isEmpty(fs_record.getString("punch_time_two"))){ + fs_record.setValue("punch_time_one", fse.getDate("punch_time_one")); + fs_record.setValue("punch_range_one", fse.getString("punch_range_one")); + }else { + fs_record.setValue("punch_time_three", fse.getDate("punch_time_one")); + fs_record.setValue("punch_range_three", fse.getString("punch_range_one")); + } + } + //鍒ゆ柇涓嬬彮鎵撳崱鐝墦鍗¤鍒欙細1銆佷笂鍗堜笅鐝湭鎵撳崱 2銆佹湭瓒呰繃涓婂崍涓嬬彮鏃堕棿 3銆佷笅鍗堝崍鏈墦涓婄彮鍗� 鍒欎负涓婂崍涓嬬彮鍗″惁鍒欎负涓嬪崍涓嬬彮鍗� + if (!StringUtils.isEmpty(fse.getDate("punch_time_four"))){ + if(dataCompareTo(fse.getDate("punch_time_four"),fs_time.getDate("afternoon_work_off")) + &&StringUtils.isEmpty(fs_record.getDate("punch_time_two")) + &&StringUtils.isEmpty(fs_record.getDate("punch_time_three"))){ + fs_record.setValue("punch_time_two", fse.getDate("punch_time_four")); + fs_record.setValue("punch_range_two", fse.getString("punch_range_four")); + }else { + fs_record.setValue("punch_time_four", fse.getDate("punch_time_four")); + fs_record.setValue("punch_range_four", fse.getString("punch_range_four")); + } + } + return baseDao.saveFieldSetEntity(fs_record); + } + }else { + //涓ゆ鎵撳崱淇濆瓨瑙勫垯 + if (FieldSetEntity.isEmpty(fs_record)){ + //鏈煡璇㈠埌鎵撳紑璁板綍鏂板缓鎵撳崱璁板綍 + if(user!=null) { + fse.setValue(MobileCoreConst.ORG_LEVEL_UUID, user.getOrg_level_uuid()); + fse.setValue(MobileCoreConst.DEPT_UUID, user.getDept_uuid()); + fse.setValue(MobileCoreConst.CREATED_UTC_DATETIME, d); + fse.setValue(MobileCoreConst.CREATED_BY, user.getUser_id()); + } + fse.setValue(MobileCoreConst.FIELD_PUNCH_TYPE,1);//鎵嬫満鎵撳崱 + fse.setTableName(MobileCoreConst.TABLE_PUNCH_RECORD); + return baseDao.saveFieldSetEntity(fse); + }else { + //鏌ヨ鍒板凡鏈夋墦寮�璁板綍鏂板缓鎵撳崱璁板綍 + if (!StringUtils.isEmpty(fse.getString("punch_time_one"))){ + fs_record.setValue("punch_time_one",fse.getDate("punch_time_one")); + fs_record.setValue("punch_range_one",fse.getString("punch_range_one")); - return baseDao.saveFieldSetEntity(fse); - } + } + if (!StringUtils.isEmpty(fse.getString("punch_time_four"))){ + fs_record.setValue("punch_time_four",fse.getDate("punch_time_four")); + fs_record.setValue("punch_range_four",fse.getString("punch_range_four")); + } + + return baseDao.saveFieldSetEntity(fs_record); + } + + } + } + + /** + * 灏嗕袱涓椂闂村緱鏃跺垎绉掕繘琛屽姣攖rue鍒欎负鍓嶈�呮棭 鍚﹀垯灏辨槸涓�鏍锋椂闂存垨鑰呭悗鑰呮棭 + * @param a + * @param b + * @return + */ + private boolean dataCompareTo(Date a,Date b){ + a.setTime(a.getTime() % (24 * 60 * 60 * 1000)); // 璁剧疆date2涓哄綋澶╃殑00:00:00 + b.setTime(b.getTime() % (24 * 60 * 60 * 1000)); // 璁剧疆date2涓哄綋澶╃殑00:00:00 + if (a.compareTo(b) < 0) { + return true; + } + return false; + } /** * 鏌ュ嚭鎸囧畾鏃ユ湡鎵撳崱璁板綍 * @param cpage @@ -57,16 +159,12 @@ * @return * @throws BaseException */ - public DataTableEntity signInList(FieldSetEntity fse) throws BaseException{ + public FieldSetEntity signInList() throws BaseException{ SystemUser user=SpringMVCContextHolder.getCurrentUser(); Date d = new Date(); String str = sdf.format(d); //灏嗘棩鏈熻浆鎹负瀛楃涓蹭笖鏍煎紡鎸夌収涔嬪墠鍒跺畾鐨� - StringBuilder sql=new StringBuilder(); - sql.append("select * from ").append(MobileCoreConst.TABLE_PUNCH_RECORD) - .append(" where created_by=? and DATE_FORMAT(created_utc_datetime,'%Y-%m-%d')=? "); - - DataTableEntity dt=baseDao.listTable(sql.toString(), new Object[] {user.getUser_id(),str}); - return dt; + FieldSetEntity fs = baseDao.getFieldSetByFilter(MobileCoreConst.TABLE_PUNCH_RECORD, "created_by=? and DATE_FORMAT(created_utc_datetime,'%Y-%m-%d')=?", new Object[]{user.getUser_id(), str}, false); + return fs; } /** * 鏌ヨ鍏徃瀹氫箟鐨勮�冨嫟鐐� -- Gitblit v1.9.2