Forráskód Böngészése

修改mes接口记录

wukai 3 napja
szülő
commit
f966b02ff2

+ 39 - 24
jjt-biz/src/main/java/com/jjt/biz/controller/ApiThirdController.java

@@ -13,6 +13,7 @@ import com.jjt.wkEmp.service.ITwinWkEmpRotaService;
 import com.jjt.wkEmp.service.ITwinWkEmpSyncService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
+import javafx.util.Pair;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.web.bind.annotation.*;
 
@@ -46,27 +47,6 @@ public class ApiThirdController extends BaseController {
         if (vo == null) {
             return AjaxResult.error("请求参数不能为空");
         }
-        if (vo.getDate() == null) {
-            return AjaxResult.error("日期不能为空");
-        }
-        if (StringUtils.isEmpty(vo.getId())) {
-            return AjaxResult.error("员工号不能为空");
-        }
-        if (StringUtils.isEmpty(vo.getName())) {
-            return AjaxResult.error("员工姓名不能为空");
-        }
-        if (StringUtils.isEmpty(vo.getTeam())) {
-            return AjaxResult.error("班组不能为空");
-        }
-        if (vo.getIn() == null) {
-            return AjaxResult.error("上班时间不能为空");
-        }
-        if (vo.getOut() == null) {
-            return AjaxResult.error("下班时间不能为空");
-        }
-        if (vo.getDevices() == null || vo.getDevices().isEmpty()) {
-            return AjaxResult.error("机台号不能为空");
-        }
 
         TwinWkEmpSync sync = new TwinWkEmpSync();
         Date s = new Date();
@@ -77,17 +57,52 @@ public class ApiThirdController extends BaseController {
             String jsonString = objectMapper.writeValueAsString(vo);
             sync.setContent(jsonString);
             syncService.insertTwinWkEmpSync(sync);
-            rotaService.sync(vo);
+            Pair<Boolean, String> pair = checkParams(vo);
+            if (pair.getKey()) {
+                rotaService.sync(vo);
+                sync.setStatus("Y");
+            } else {
+                sync.setStatus("N");
+            }
             Date e = new Date();
             long time = e.getTime() - s.getTime();
             sync.setTime(time);
-            sync.setStatus("Y");
+            sync.setRemark(pair.getValue());
             syncService.updateTwinWkEmpSync(sync);
+            if (pair.getKey()) {
+                return AjaxResult.success();
+            } else {
+                return AjaxResult.error(pair.getValue());
+            }
         } catch (Exception e) {
             log.error("员工排班同步失败", e);
             return AjaxResult.error(e.getMessage());
         }
-        return AjaxResult.success();
+    }
+
+    private Pair<Boolean, String> checkParams(KnittingEmpVO vo) {
+        if (vo.getDate() == null) {
+            return new Pair<>(false, "日期不能为空");
+        }
+        if (StringUtils.isEmpty(vo.getId())) {
+            return new Pair<>(false, "员工号不能为空");
+        }
+        if (StringUtils.isEmpty(vo.getName())) {
+            return new Pair<>(false, "员工姓名不能为空");
+        }
+        if (StringUtils.isEmpty(vo.getTeam())) {
+            return new Pair<>(false, "班组不能为空");
+        }
+        if (vo.getIn() == null) {
+            return new Pair<>(false, "上班时间不能为空");
+        }
+        if (vo.getOut() == null) {
+            return new Pair<>(false, "下班时间不能为空");
+        }
+        if (vo.getDevices() == null || vo.getDevices().isEmpty()) {
+            return new Pair<>(false, "机台号不能为空");
+        }
+        return new Pair<>(true, null);
     }
 
     @ApiOperation("经编车间员工月度工资")