自动化立体仓库 - WMS系统
dubin
昨天 071db78d02b68f71f855d54bdac44417147a2787
src/main/java/com/zy/asrs/service/impl/MatBarcodeServiceImpl.java
@@ -1,18 +1,21 @@
package com.zy.asrs.service.impl;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.core.common.Cools;
import com.core.exception.CoolException;
import com.zy.asrs.entity.HalfBarcode;
import com.zy.asrs.entity.Mat;
import com.zy.asrs.entity.MatBarcode;
import com.zy.asrs.entity.WaitPakin;
import com.zy.asrs.mapper.MatBarcodeMapper;
import com.zy.asrs.service.HalfBarcodeService;
import com.zy.asrs.service.MatBarcodeService;
import com.zy.asrs.service.MatService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@Service("MatBarcodeService")
public class MatBarcodeServiceImpl extends ServiceImpl<MatBarcodeMapper, MatBarcode> implements MatBarcodeService {
@@ -22,6 +25,8 @@
    private MatBarcodeService matBarcodeService;
    @Autowired
    private MatService matService;
    @Autowired
    private HalfBarcodeService halfBarcodeService;
    @Override
    public MatBarcode selectbyMatnr(String matnr) {
        return this.baseMapper.selectByMatnr(matnr);
@@ -30,6 +35,18 @@
    @Override
    public void deleteMatBarcode(List<MatBarcode> list) {
        for (MatBarcode matBarcode : list) {
            //对模具的规格做处理得到厚度
            Integer thickness = 0;
            if (!Cools.isEmpty(matBarcode.getSpecs())){
                String[] split = matBarcode.getSpecs().split("\\*");
                thickness = Integer.parseInt(split[1]);
            }
            HalfBarcode halfBarcode = halfBarcodeService.selectByZpallet(matBarcode.getZpallet());
            halfBarcode.setAnfme(halfBarcode.getAnfme() - 1);
            halfBarcode.setPrice(halfBarcode.getPrice() + thickness);
            if (!halfBarcodeService.half(halfBarcode)){
                throw new CoolException("更新半托信息失败");
            }
            matBarcodeMapper.deleteByMatnr(matBarcode.getMatnr());
        }
    }
@@ -46,6 +63,43 @@
        }
        if (mat.getColor().equals("报废")){
            throw new CoolException("该物料已报废,请勿绑定");
        }
        HalfBarcode halfBarcode = halfBarcodeService.selectByZpallet(waitPakin.getBarcode());
        //对模具的规格做处理得到厚度
        Integer thickness = 0;
        if (!Cools.isEmpty(mat.getSpecs())){
            String[] split = mat.getSpecs().split("\\*");
            thickness = Integer.parseInt(split[1]);
        }
        if (halfBarcode == null){
            HalfBarcode hb = new HalfBarcode();
            hb.setZpallet(waitPakin.getBarcode());
            hb.setSpecs(waitPakin.getBarcode().substring(0,1));
            hb.setAnfme(1);
            if (Integer.parseInt(waitPakin.getBarcode().substring(0,1))==6){
                hb.setPrice(2650 - thickness);
            }else if(Integer.parseInt(waitPakin.getBarcode().substring(0,1))==7){
                hb.setPrice(1750 - thickness);
            }else if(Integer.parseInt(waitPakin.getBarcode().substring(0,1))==8){
                hb.setPrice(800 - thickness);
            }
            if (!halfBarcodeService.insert(hb)){
                throw new CoolException("更新半托信息失败");
            }
        }else {
            if (Integer.parseInt(waitPakin.getBarcode().substring(0,1))==6){
                halfBarcode.setAnfme(halfBarcode.getAnfme() + 1);
                halfBarcode.setPrice(2650 - thickness);
            }else if(Integer.parseInt(waitPakin.getBarcode().substring(0,1))==7){
                halfBarcode.setAnfme(halfBarcode.getAnfme() + 1);
                halfBarcode.setPrice(1750 - thickness);
            }else if(Integer.parseInt(waitPakin.getBarcode().substring(0,1))==8){
                halfBarcode.setAnfme(halfBarcode.getAnfme() + 1);
                halfBarcode.setPrice(800 - thickness);
            }
            if (!halfBarcodeService.half(halfBarcode)){
                throw new CoolException("更新半托信息失败");
            }
        }
        MatBarcode mb=new MatBarcode();
        mb.setZpallet(waitPakin.getBarcode());
@@ -71,6 +125,43 @@
        if (mat.getColor().equals("报废")){
            throw new CoolException("该物料已报废,请勿绑定");
        }
        HalfBarcode halfBarcode = halfBarcodeService.selectByZpallet(mat.getUnit());
        //对模具的规格做处理得到厚度
        Integer thickness = 0;
        if (!Cools.isEmpty(mat.getSpecs())){
            String[] split = mat.getSpecs().split("\\*");
            thickness = Integer.parseInt(split[1]);
        }
        if (halfBarcode == null){
            HalfBarcode hb = new HalfBarcode();
            hb.setZpallet(mat.getUnit());
            hb.setSpecs(mat.getUnit().substring(0,1));
            hb.setAnfme(1);
            if (Integer.parseInt(mat.getUnit().substring(0,1))==6){
                hb.setPrice(2650 - thickness);
            }else if(Integer.parseInt(mat.getUnit().substring(0,1))==7){
                hb.setPrice(1750 - thickness);
            }else if(Integer.parseInt(mat.getUnit().substring(0,1))==8){
                hb.setPrice(800 - thickness);
            }
            if (!halfBarcodeService.insert(hb)){
                throw new CoolException("更新半托信息失败");
            }
        }else {
            if (Integer.parseInt(mat.getUnit().substring(0,1))==6){
                halfBarcode.setAnfme(halfBarcode.getAnfme() + 1);
                halfBarcode.setPrice(halfBarcode.getPrice()- thickness);
            }else if(Integer.parseInt(mat.getUnit().substring(0,1))==7){
                halfBarcode.setAnfme(halfBarcode.getAnfme() + 1);
                halfBarcode.setPrice(halfBarcode.getPrice()- thickness);
            }else if(Integer.parseInt(mat.getUnit().substring(0,1))==8){
                halfBarcode.setAnfme(halfBarcode.getAnfme() + 1);
                halfBarcode.setPrice(halfBarcode.getPrice()- thickness);
            }
            if (!halfBarcodeService.half(halfBarcode)){
                throw new CoolException("更新半托信息失败");
            }
        }
        MatBarcode mb=new MatBarcode();
        mb.setZpallet(mat.getUnit());
        mb.setMatnr(mat.getMatnr());
@@ -81,4 +172,13 @@
            throw new CoolException("物料托盘绑定失败");
        }
    }
    @Override
    public String page(Map<String, Object> param) {
        Integer pageNo = Integer.valueOf(param.get("curr").toString());
        Integer pageSize = Integer.valueOf(param.get("limit").toString());
        String barcode = (String) param.get("zpallet");
        Integer spec = Integer.valueOf(param.get("spec").toString());
        return matBarcodeMapper.page(pageNo,pageSize,barcode,spec);
    }
}