shicf
2025-08-04 f60cf23a76972c0e0c7a437b17f37e1237e7d8d9
src/main/java/com/product/mobile/core/service/SignInService.java
@@ -17,7 +17,8 @@
import com.product.mobile.core.config.MobileCoreCode;
import com.product.mobile.core.config.MobileCoreConst;
import com.product.module.sys.entity.SystemUser;
import com.product.util.BaseUtil;
import com.product.util.baidu.map.CoordinateTransformUtil;
import com.product.util.baidu.map.CoordinateTransformUtil.Coordinate;
import cn.hutool.core.date.DateUtil;
@@ -79,7 +80,7 @@
               t=4;
               rule=config.getString("afternoon_work_off");
            }else {//上班
               if(check(record,"1")) {
               if(check(record,1)!=null) {
                  throw new BaseException(MobileCoreCode.SIGN_IN_REPEAT_FAIL);
               }
               fse.setValue("punch_type","1");
@@ -101,14 +102,14 @@
            }else {//上班
               //上班卡,比上午下班早,记上午上班卡
               if(dataCompareTo(fse.getDate("punch_time"),config.getDate("morning_work_off")) ) {
                  if(check(record,"1")) {
                  if(check(record,1)!=null) {
                     throw new BaseException(MobileCoreCode.SIGN_IN_REPEAT_FAIL);
                  }
                  fse.setValue("punch_type","1");
                  t=1;
                  rule=config.getString("morning_work");
               }else {//记下午上班卡
                  if(check(record,"3")) {
                  if(check(record,3)!=null) {
                     throw new BaseException(MobileCoreCode.SIGN_IN_REPEAT_FAIL);
                  }
                  fse.setValue("punch_type","3");
@@ -124,6 +125,14 @@
         rule=rule.substring(10);
         rule=DateUtil.formatDate(new Date())+rule;
      }
      if(t%2==0) {
         ///如下是下班卡,并且当天已经打过了,只是去修改最后打卡时间,不是新增一条打卡记录
         String uuid=check(record,t);
         if(uuid!=null) {
            fse.setValue("uuid", uuid);
         }
      }
      long resutl=signinResult(DateUtil.parse(rule),fse.getDate("punch_time"),t);
      if(resutl>0) {
         fse.setValue("sign_in_result", 0);//迟到
@@ -158,13 +167,13 @@
   }
   
   //上班时间不能重复打卡
   private boolean check(DataTableEntity record,String type) {
   private String check(DataTableEntity record,int type) {
      for(int i=0;i<record.getRows();i++) {
         if(type.equals( record.getFieldSetEntity(i).getString("punch_type"))) {
            return true;
         if(type==record.getFieldSetEntity(i).getInteger("punch_type").intValue()) {
            return record.getFieldSetEntity(i).getString("uuid");
         }
      }
      return false;
      return null;
   }
   /**
@@ -207,5 +216,23 @@
       sql.append(" a left join product_oa_punch_time b on b.punch_site_uuid=a.uuid where a.org_level_uuid=?");
       return baseDao.listTable(sql.toString(), new String[] {org_level_uuid});
    }
    /**
     *坐标转换
     * @param type转换类型
     * @param lng 经度
     * @param lat 纬度
     * @return
     */
    public FieldSetEntity coordinateTransform(int type,double lng,double lat) {
       FieldSetEntity newCoord=new FieldSetEntity();
       newCoord.setTableName("product_oa_punch_time");
       Coordinate nc=CoordinateTransformUtil.toConvert(type, lng, lat);
       if(nc!=null) {
          newCoord.setValue("longitude", nc.longitude);
          newCoord.setValue("latitude", nc.latitude);
       }
       return newCoord;
    }
}