Fancy
2024-07-16 e9af4d03a4f64dec62ab180640de9d26d0f2b8d7
fix assy queryByDeviceNo method
2个文件已修改
126 ■■■■ 已修改文件
pms-parent/pms-web-station/src/main/java/com/dy/pmsStation/assemblyStep/AssemblyStepCtrl.java 88 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pms-parent/pms-web-station/src/main/java/com/dy/pmsStation/assemblyStep/AssemblyStepSv.java 38 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pms-parent/pms-web-station/src/main/java/com/dy/pmsStation/assemblyStep/AssemblyStepCtrl.java
@@ -1,6 +1,6 @@
package com.dy.pmsStation.assemblyStep;
import com.alibaba.excel.util.StringUtils;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.dy.common.webUtil.BaseResponse;
import com.dy.common.webUtil.BaseResponseUtils;
import com.dy.pmsGlobal.pojoPlt.PltProductFile;
@@ -19,13 +19,14 @@
import java.util.Map;
/**
 *记录组装各步骤
 * 记录组装各步骤
 */
@Slf4j
@RestController
@RequestMapping(path = "assemblyStep")
public class AssemblyStepCtrl {
    private AssemblyStepSv sv;
    @Autowired
    public void setSv(AssemblyStepSv sv) {
        this.sv = sv;
@@ -33,8 +34,25 @@
    @PostMapping(path = "save")
    public BaseResponse save(@RequestBody @Valid QueryVo vo) {
        log.info("AssemblyStepCtrl.save():"+vo);
        log.info("AssemblyStepCtrl.save():" + vo);
        int count = sv.save(vo);
        if (count <= 0) {
            return BaseResponseUtils.buildFail("数据库存储失败");
        } else {
            return BaseResponseUtils.buildSuccess(true);
        }
    }
    /**
     * 测试或品检都调用这个接口
     *
     * @param vo
     * @return
     */
    @PostMapping(path = "testing")
    public BaseResponse testing(@RequestBody @Valid QueryVo vo) {
        log.info("AssemblyStepCtrl.testing():" + vo);
        int count = sv.testing(vo);
        if (count <= 0) {
            return BaseResponseUtils.buildFail("数据库存储失败");
        } else {
@@ -44,7 +62,7 @@
    @PostMapping(path = "repair")
    public BaseResponse repair(@RequestBody @Valid QueryVo vo) {
        log.info("AssemblyStepCtrl.repair():"+vo);
        log.info("AssemblyStepCtrl.repair():" + vo);
        int count = sv.repair(vo);
        if (count <= 0) {
            return BaseResponseUtils.buildFail("数据库存储失败");
@@ -52,89 +70,81 @@
            return BaseResponseUtils.buildSuccess(true);
        }
    }
    /**
     * 根据节点的查出节点作业指导书
     *
     * @param
     * @return
     */
    @GetMapping(path="getSopByNodeId")
    public BaseResponse<PrProductionNode> getSopByNodeId(String nodeId){
        log.info("AssemblyStepCtrl.getSopByNodeId():"+nodeId);
    @GetMapping(path = "getSopByNodeId")
    public BaseResponse<PrProductionNode> getSopByNodeId(String nodeId) {
        log.info("AssemblyStepCtrl.getSopByNodeId():" + nodeId);
        PrProductionNode result = sv.getSopByNodeId(nodeId);
        return BaseResponseUtils.buildSuccess(result);
    }
    /**
     * 根据产品查出 主要技术参数
     *
     * @param
     * @return
     */
    @GetMapping(path="getParamsByProId")
    public BaseResponse<List<PltProductParams>> getParamsByProId(String proId){
        log.info("AssemblyStepCtrl.getParamsByProId():"+proId);
    @GetMapping(path = "getParamsByProId")
    public BaseResponse<List<PltProductParams>> getParamsByProId(String proId) {
        log.info("AssemblyStepCtrl.getParamsByProId():" + proId);
        List<PltProductParams> result = sv.getParamsByProId(proId);
        return BaseResponseUtils.buildSuccess(result);
    }
    /**
     * 根据产品查出产品文件 主要技术参数
     *
     * @param
     * @return
     */
    @GetMapping(path="getFileByProId")
    public BaseResponse<List<PltProductFile>> getFileByProId(String proId){
        log.info("AssemblyStepCtrl.getFileByProId():"+proId);
    @GetMapping(path = "getFileByProId")
    public BaseResponse<List<PltProductFile>> getFileByProId(String proId) {
        log.info("AssemblyStepCtrl.getFileByProId():" + proId);
        List<PltProductFile> result = sv.getFileByProId(proId);
        return BaseResponseUtils.buildSuccess(result);
    }
    @GetMapping(path = "getQualityItems")
    public BaseResponse<List<PltProductQualityInspectionItems>> getQualityItems(String proId) {
        log.info("AssemblyStepCtrl.getQualityItems():"+proId);
        log.info("AssemblyStepCtrl.getQualityItems():" + proId);
        List<PltProductQualityInspectionItems> result = sv.getQualityItems(proId);
        return BaseResponseUtils.buildSuccess(result);
    }
    @GetMapping(path = "getTestItems")
    public BaseResponse<List<PltProductTestInspectionItems>> getTestItems(String proId) {
        log.info("AssemblyStepCtrl.getTestItems():"+proId);
        log.info("AssemblyStepCtrl.getTestItems():" + proId);
        List<PltProductTestInspectionItems> result = sv.getTestItems(proId);
        return BaseResponseUtils.buildSuccess(result);
    }
    /**
     * 测试或品检都调用这个接口
     * @param vo
     * @return
     */
    @PostMapping(path = "testing")
    public BaseResponse testing(@RequestBody @Valid QueryVo vo) {
        log.info("AssemblyStepCtrl.testing():"+vo);
        int count = sv.testing(vo);
        if (count <= 0) {
            return BaseResponseUtils.buildFail("数据库存储失败");
        } else {
            return BaseResponseUtils.buildSuccess(true);
        }
    }
    @GetMapping(path = "queryByDeviceNo")
    public BaseResponse<Map<String,String>> queryByDeviceNo(String deviceNo) {
        log.info("AssemblyStepCtrl.queryByDeviceNo():"+deviceNo);
        Map<String,String> result = sv.queryByDeviceNo(deviceNo);
        if(StringUtils.isBlank(result.get("proName"))){
            return BaseResponseUtils.buildFail("该编码("+deviceNo +")不是主要物料(系统中管控的其他设备)");
        }else{
    public BaseResponse<Map<String, String>> queryByDeviceNo(String deviceNo) {
        log.info("AssemblyStepCtrl.queryByDeviceNo():" + deviceNo);
        Map<String, String> result = sv.queryByDeviceNo(deviceNo, null);
        if (StringUtils.isBlank(result.get("proName"))) {
            return BaseResponseUtils.buildFail("该编码(" + deviceNo + ")不是主要物料(系统中管控的其他设备)");
        } else {
            return BaseResponseUtils.buildSuccess(result);
        }
    }
    @GetMapping(path = "queryLifeByDeviceNo")
    public BaseResponse<?> queryLifeByDeviceNo(String deviceNo) {
        log.info("AssemblyStepCtrl.queryLifeByDeviceNo():"+deviceNo);
        log.info("AssemblyStepCtrl.queryLifeByDeviceNo():" + deviceNo);
        List<StaDeviceLife> result = sv.queryLifeByDeviceNo(deviceNo);
        return BaseResponseUtils.buildSuccess(result);
    }
    @GetMapping(path = "queryLogByDeviceNo")
    public BaseResponse<?> queryLogByDeviceNo(String deviceNo) {
        log.info("AssemblyStepCtrl.queryLogByDeviceNo():"+deviceNo);
        log.info("AssemblyStepCtrl.queryLogByDeviceNo():" + deviceNo);
        List<StaDeviceProductionLog> result = sv.queryLogByDeviceNo(deviceNo);
        return BaseResponseUtils.buildSuccess(result);
    }
pms-parent/pms-web-station/src/main/java/com/dy/pmsStation/assemblyStep/AssemblyStepSv.java
@@ -155,17 +155,9 @@
                deviceList.add(deviceNo);
            } else {
                //判断是不是是本厂物料,如果是,则添加物料到ex表中
                PltProduct product = null;
                if (StringUtils.isNotEmpty(deviceNo) && deviceNo.length() == 22) {
                    product = productList.stream().filter(p -> deviceNo.startsWith(QrCodeConstant.TypeProduct + p.getCode())).findFirst().orElse(null);
                }
                if(product != null){
                    Map<String, String> map = new HashMap<>();
                    map.put("deviceNo", deviceNo);
                    map.put("proName", product.getName());
                    BigInteger proId = BigInteger.valueOf(product.getId());
                    map.put("proId", proId.toString());
                    materialList.add(map);
                Map<String, String> result = queryByDeviceNo(deviceNo, productList);
                if (StringUtils.isNotBlank(result.get("proName"))) {
                    materialList.add(result);
                }
            }
        });
@@ -334,11 +326,14 @@
        if (workLast == null) {
            throw new RuntimeException("系统中没有该条登录信息");
        }
        StaDeviceLast deviceLast = buildDeviceLast(vo, workLast, vo.deviceNo[0]);
        int count = deviceLast.id == null ? deviceLastDao.insertSelective(deviceLast) :
                deviceLastDao.updateByPrimaryKeySelective(deviceLast);
        saveDeviceProductionLog(deviceLast);
        PrProductionNode node = nodeDao.selectByPrimaryKey(workLast.nodeId);
        if (node.isRecord) {
            saveDeviceLife(deviceLast);
        }
        return count;
    }
@@ -451,20 +446,27 @@
        return fileRestVo.fileWebUrl + file.filePath;
    }
    public Map<String, String> queryByDeviceNo(String deviceNo) {
    public Map<String, String> queryByDeviceNo(String deviceNo,List<PltProduct> productList) {
        Map<String, String> map = new HashMap<>();
        map.put("deviceNo", deviceNo);
        map.put("proName", "");
        map.put("proType", "");
        PltProduct product = productDao.selectByCode(deviceNo.substring(3, 6));
        map.put("proId", "");
        //判断是不是是本厂物料
        if(CollectionUtils.isEmpty(productList)){
            productList = productDao.selectAll(null);
        }
        PltProduct product = null;
        if (StringUtils.isNotEmpty(deviceNo) && deviceNo.length() == 22) {
            product = productList.stream().filter(p -> deviceNo.startsWith(QrCodeConstant.TypeProduct + p.getCode())).findFirst().orElse(null);
        }
        if (product != null) {
            map.put("deviceNo", deviceNo);
            map.put("proName", product.getName());
            map.put("proType", product.getType());
            BigInteger proId = BigInteger.valueOf(product.getId());
            map.put("proId", proId.toString());
        }
        /*else{
            throw new RuntimeException("该编码("+deviceNo +")不是主要物料(系统中管控的其他设备)");
        }*/
        return map;
    }