Quellcode durchsuchen

添加PDA补码接口

zhifei vor 1 Jahr
Ursprung
Commit
c3265dc571

+ 7 - 5
warewms-system/src/main/java/com/warewms/hailiang/contoller/RetroactiveNowController.java

@@ -11,10 +11,7 @@ import com.warewms.hailiang.domain.RetroactiveNow;
 import com.warewms.hailiang.service.DeviceLogService;
 import com.warewms.hailiang.service.RetroactiveNowService;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -52,8 +49,13 @@ public class RetroactiveNowController {
         return R.ok(retroactiveNowService.selectTheOneByParameter(retroactiveNow));
     }
 
+    /**
+     * PDA补码接口
+     * @param retroactiveNow
+     * @return
+     */
     @PostMapping("/pda/complement")
-    public R complement(RetroactiveNow retroactiveNow){
+    public R complement(@RequestBody RetroactiveNow retroactiveNow){
         return retroactiveNowService.complement(retroactiveNow);
     }
 }

+ 44 - 21
warewms-system/src/main/java/com/warewms/hailiang/service/impl/RetroactiveNowServiceImpl.java

@@ -7,8 +7,11 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.warewms.common.core.domain.R;
 import com.warewms.common.core.domain.base.page.PageDomain;
 import com.warewms.common.core.domain.base.page.TableDataInfo;
+import com.warewms.common.core.domain.model.LoginUser;
 import com.warewms.common.exception.ServiceException;
+import com.warewms.common.utils.SecurityUtils;
 import com.warewms.common.utils.StringUtils;
+import com.warewms.hailiang.MES.MesService;
 import com.warewms.hailiang.domain.RetroactiveHistory;
 import com.warewms.hailiang.domain.RetroactiveNow;
 import com.warewms.hailiang.mapper.RetroactiveHistoryMapper;
@@ -39,6 +42,9 @@ public class RetroactiveNowServiceImpl extends ServiceImpl<RetroactiveNowMapper,
     @Autowired
     private RetroactiveHistoryMapper retroactiveHistoryMapper;
 
+    @Autowired
+    private MesService mesService;
+
     @Override
     public TableDataInfo<RetroactiveNow> getList(RetroactiveNow retroactiveNow, PageDomain pageDomain, List<String> inStatus) {
         Map<String, Object> params = retroactiveNow.getParams();
@@ -75,16 +81,7 @@ public class RetroactiveNowServiceImpl extends ServiceImpl<RetroactiveNowMapper,
     @Override
     @Transactional
     public int updateData(RetroactiveNow retroactiveNow) {
-        RetroactiveNow baseData = retroactiveNowMapper.selectOne(new LambdaQueryWrapper<RetroactiveNow>()
-                .eq(StringUtils.isNotEmpty(retroactiveNow.getBatchNo()), RetroactiveNow::getBatchNo, retroactiveNow.getBatchNo())
-                .eq(StringUtils.isNotEmpty(retroactiveNow.getLotNo()), RetroactiveNow::getLotNo, retroactiveNow.getLotNo())
-        );
-        if (ObjectUtil.isNull(baseData)) {
-            throw new ServiceException("数据库中不存在该批次号或托盘号," + retroactiveNow.getBatchNo() + "," + retroactiveNow.getLotNo());
-        }
-        if (baseData.getStatus().equals(retroactiveNow.getStatus())) {
-            throw new ServiceException("数据库存在该状态相同批次号或托盘号的数据");
-        }
+        RetroactiveNow baseData = confirmTheDataByIndex(retroactiveNow);
         baseData.setStatus(retroactiveNow.getStatus());
         baseData.setDeviceId(retroactiveNow.getDeviceId());
         baseData.setUpdateBy("system");
@@ -98,16 +95,7 @@ public class RetroactiveNowServiceImpl extends ServiceImpl<RetroactiveNowMapper,
     @Override
     @Transactional
     public int finishProduce(RetroactiveNow retroactiveNow) {
-        RetroactiveNow baseData = retroactiveNowMapper.selectOne(new LambdaQueryWrapper<RetroactiveNow>()
-                .eq(StringUtils.isNotEmpty(retroactiveNow.getBatchNo()), RetroactiveNow::getBatchNo, retroactiveNow.getBatchNo())
-                .eq(StringUtils.isNotEmpty(retroactiveNow.getLotNo()), RetroactiveNow::getLotNo, retroactiveNow.getLotNo())
-        );
-        if (ObjectUtil.isNull(baseData)) {
-            throw new ServiceException("数据库中不存在该批次号或托盘号," + retroactiveNow.getBatchNo() + "," + retroactiveNow.getLotNo());
-        }
-        if (baseData.getStatus().equals(retroactiveNow.getStatus())) {
-            throw new ServiceException("数据库存在该状态相同批次号或托盘号的数据");
-        }
+        RetroactiveNow baseData = confirmTheDataByIndex(retroactiveNow);
         baseData.setStatus(retroactiveNow.getStatus());
         baseData.setDeviceId(retroactiveNow.getDeviceId());
         baseData.setUpdateBy("system");
@@ -118,8 +106,43 @@ public class RetroactiveNowServiceImpl extends ServiceImpl<RetroactiveNowMapper,
     }
 
     @Override
+    @Transactional
     public R complement(RetroactiveNow retroactiveNow) {
-        return null;
+        RetroactiveNow baseData = confirmTheDataByIndex(retroactiveNow);
+        if ("2".equals(baseData.getStatus())){
+            mesService.getBatchNoResult(retroactiveNow.getBatchNo(), true);
+        }
+        if ("3".equals(baseData.getStatus())){
+            mesService.processFeedback(retroactiveNow.getBatchNo(),"1");
+        }
+        if ("4".equals(baseData.getStatus())){
+            mesService.processFeedback(retroactiveNow.getBatchNo(),"2");
+        }
+        LoginUser loginUser = SecurityUtils.getLoginUser();
+        baseData.setStatus(retroactiveNow.getStatus());
+        baseData.setDeviceId("PDA");
+        baseData.setUpdateBy(loginUser.getUsername());
+        baseData.setRemark("PDA手动补码");
+        retroactiveNowMapper.updateById(baseData);
+        baseData.setCreateBy(loginUser.getUsername());
+        RetroactiveHistory retroactiveHistory = BeanUtil.copyProperties(baseData, RetroactiveHistory.class);
+        retroactiveHistory.setCreateTime(baseData.getUpdateTime());
+        retroactiveHistoryMapper.insert(retroactiveHistory);
+        return R.ok();
+    }
+
+    private RetroactiveNow confirmTheDataByIndex(RetroactiveNow retroactiveNow) {
+        RetroactiveNow baseData = retroactiveNowMapper.selectOne(new LambdaQueryWrapper<RetroactiveNow>()
+                .eq(StringUtils.isNotEmpty(retroactiveNow.getBatchNo()), RetroactiveNow::getBatchNo, retroactiveNow.getBatchNo())
+                .eq(StringUtils.isNotEmpty(retroactiveNow.getLotNo()), RetroactiveNow::getLotNo, retroactiveNow.getLotNo())
+        );
+        if (ObjectUtil.isNull(baseData)) {
+            throw new ServiceException("数据库中不存在该批次号或托盘号," + retroactiveNow.getBatchNo() + "," + retroactiveNow.getLotNo());
+        }
+        if (baseData.getStatus().equals(retroactiveNow.getStatus())) {
+            throw new ServiceException("数据库存在该状态相同批次号或托盘号的数据");
+        }
+        return baseData;
     }
 }