Ver Fonte

就餐打卡更新。

zhengqiang há 4 anos atrás
pai
commit
3b031c7bbb

+ 12 - 7
common/src/main/java/com/jpsoft/shinestar/modules/base/service/impl/CanteenDiningRecordServiceImpl.java

@@ -12,6 +12,7 @@ import cn.hutool.json.JSONUtil;
 import com.jpsoft.shinestar.modules.base.dao.*;
 import com.jpsoft.shinestar.modules.base.entity.*;
 import com.jpsoft.shinestar.modules.base.service.CanteenDiningRecordService;
+import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.redis.core.ValueOperations;
 import org.springframework.stereotype.Component;
@@ -20,6 +21,7 @@ import com.github.pagehelper.Page;
 import com.jpsoft.shinestar.modules.common.dto.Sort;
 import com.github.pagehelper.PageHelper;
 
+@Slf4j
 @Transactional
 @Component(value="canteenDiningRecordService")
 public class CanteenDiningRecordServiceImpl implements CanteenDiningRecordService {
@@ -171,22 +173,18 @@ public class CanteenDiningRecordServiceImpl implements CanteenDiningRecordServic
 
 	@Override
 	public boolean punchIn(String deviceNo, Long personId, Date recordTime) throws ParseException {
-
-		//1分钟之内只通知一次
-		boolean absent = valueOperations.setIfAbsent("canteen_" + personId, true, 1, TimeUnit.MINUTES);
 		boolean result = false;
 
-		if (absent) {
-
+		try {
+		//1分钟之内只通知一次
+//		boolean absent = valueOperations.setIfAbsent("canteen_" + personId, true, 1, TimeUnit.MINUTES);
 			SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
 			SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
 			Calendar calendar = Calendar.getInstance();
 			String recordDate = sdf.format(recordTime);
 
 			Date now = new Date();
-
 			PersonInfo personInfo = personInfoDAO.get(personId);
-
 			CompanyInfo companyInfo = companyInfoDAO.get(personInfo.getCompanyId());
 
 			Boolean isOutsourcer = false;
@@ -196,6 +194,7 @@ public class CanteenDiningRecordServiceImpl implements CanteenDiningRecordServic
 			}
 
 			DeviceInfo deviceInfo = deviceInfoDAO.findByDeviceNo(deviceNo);
+
 			if (deviceInfo != null) {
 				CanteenDevice canteenDevice = canteenDeviceDAO.findByDeviceId(deviceInfo.getId());
 				if (canteenDevice != null) {
@@ -253,6 +252,7 @@ public class CanteenDiningRecordServiceImpl implements CanteenDiningRecordServic
 //										canteenDiningRecord.setCategoryAmount(canteenDining.getDiningFee());
 //									}
 								}
+
 								int count = canteenDiningRecordDAO.insert(canteenDiningRecord);
 
 								if (count > 0) {
@@ -276,6 +276,11 @@ public class CanteenDiningRecordServiceImpl implements CanteenDiningRecordServic
 					}
 				}
 			}
+
+			log.warn("食堂就餐打卡PersonId={},result={}", personId, result);
+		}
+		catch (Exception ex){
+			log.error(ex.getMessage(), ex);
 		}
 
 		return result;

+ 27 - 0
web/src/main/java/com/jpsoft/shinestar/modules/base/controller/CanteenDiningRecordController.java

@@ -14,6 +14,8 @@ import com.jpsoft.shinestar.modules.sys.service.DataDictionaryService;
 import com.jpsoft.shinestar.modules.sys.service.UserCompanyService;
 import com.jpsoft.shinestar.modules.sys.service.UserService;
 import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
 import io.swagger.annotations.ApiOperation;
 import org.apache.poi.hssf.usermodel.HSSFWorkbook;
 import org.apache.poi.ss.usermodel.Cell;
@@ -23,6 +25,7 @@ import org.apache.poi.ss.usermodel.Workbook;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.format.annotation.DateTimeFormat;
 import org.springframework.web.bind.annotation.*;
 
 import javax.servlet.http.HttpServletRequest;
@@ -996,6 +999,30 @@ public class CanteenDiningRecordController {
         return downloadUrl;
     }
 
+    @PostMapping("punchIn")
+    @ApiOperation(value="食堂就餐打卡测试")
+    @ApiImplicitParams({
+        @ApiImplicitParam(name="deviceNo",value = "设备编号",required = true,paramType = "form"),
+        @ApiImplicitParam(name="personId",value = "人员编号",required = true,paramType = "form"),
+        @ApiImplicitParam(name = "recordTime",value = "考勤时间", required = true,paramType="form")
+    })
+    public MessageResult<String> punchIn(String deviceNo, Long personId,
+                                          @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm") Date recordTime){
+        MessageResult<String> messageResult = new MessageResult<>();
 
+        try {
+            Boolean result = canteenDiningRecordService.punchIn(deviceNo,personId,recordTime);
+
+            //todo 填写具体代码
+            messageResult.setResult(result);
+        }
+        catch (Exception ex){
+            logger.error(ex.getMessage(),ex);
+
+            messageResult.setResult(false);
+            messageResult.setMessage(ex.getMessage());
+        }
 
+        return messageResult;
+    }
 }