自动化立体仓库 - WMS系统
#
18516761980
2021-09-14 35ce7aaef10e30006bcef381d19302c0928c1194
src/main/java/com/zy/ints/controller/WaitMatchkController.java
@@ -10,22 +10,36 @@
import com.core.common.Cools;
import com.core.common.DateUtils;
import com.core.common.R;
import com.core.exception.CoolException;
import com.zy.asrs.entity.LocDetl;
import com.zy.asrs.entity.LocMast;
import com.zy.asrs.entity.MatCode;
import com.zy.asrs.service.LocDetlService;
import com.zy.asrs.service.LocMastService;
import com.zy.asrs.service.MatCodeService;
import com.zy.common.web.BaseController;
import com.zy.ints.entity.WaitMatchk;
import com.zy.ints.service.WaitMatchkLogService;
import com.zy.ints.service.WaitMatchkService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
@RestController
public class WaitMatchkController extends BaseController {
    @Autowired
    private WaitMatchkService waitMatchkService;
    @Autowired
    private WaitMatchkLogService waitMatchkLogService;
    @Autowired
    private LocMastService locMastService;
    @Autowired
    private LocDetlService locDetlService;
    @Autowired
    private MatCodeService matCodeService;
    //盘点通知档
@@ -81,16 +95,102 @@
        return R.ok();
    }
    /**
     * 删除盘点通知档,删除前转历史档
     * @param param
     * @return
     */
    @RequestMapping(value = "/waitMatchk/delete/auth")
    @ManagerAuth
    @Transactional
    public R delete(@RequestParam String param){
        List<WaitMatchk> list = JSONArray.parseArray(param, WaitMatchk.class);
        if (Cools.isEmpty(list)){
            return R.error();
        }
        for (WaitMatchk entity : list){
            boolean res =  waitMatchkLogService.save(entity.getBillNo(),entity.getLocNo(),entity.getMatNo());
            if(!res){
                throw new CoolException("转历史档出错[locNo:"+entity.getLocNo()+"],[matNo:"+entity.getMatNo()+"]");
            }else {
            waitMatchkService.delete(new EntityWrapper<>(entity));
        }
        }
        return R.ok();
    }
    /**
     * 审核盘点单据
     * @param param
     * @return
     */
    @RequestMapping(value = "/waitMatchk/verify/auth")
    @ManagerAuth
    @Transactional
    public R verify(@RequestParam String param){
        List<WaitMatchk> list = JSONArray.parseArray(param, WaitMatchk.class);
        if (Cools.isEmpty(list)){
            return R.error();
        }
        Date now = new Date();
        for (WaitMatchk entity : list){
            LocMast locMast = locMastService.selectOne(new EntityWrapper<LocMast>().eq("loc_no",entity.getLocNo()));
            if(null != locMast && locMast.getLocSts().equals("F")){
                Wrapper<LocDetl> wrapperDetl = new EntityWrapper<LocDetl>().eq("loc_no",entity.getLocNo()).eq("mat_no",entity.getMatNo());
                LocDetl locDetl = locDetlService.selectOne(wrapperDetl);
                if(null != locDetl) {//更新数量,删除明细
                    if(entity.getCheckQty().equals(0)){
                        if(!locDetlService.delete(wrapperDetl)){
                            throw new CoolException("删除数量为0明细出错[locNo:"+locDetl.getLocNo()+"],[matNo:"+locDetl.getMatNo()+"]");
                        }
                    }else{
                        if(!entity.getCheckQty().equals(locDetl.getQty())){ //库存数量与盘点数量相同不用更新
                            locDetl.setQty(entity.getCheckQty());
                            if(!locDetlService.update(locDetl,wrapperDetl)){
                                throw new CoolException("更新库存明细出错[locNo:"+locDetl.getLocNo()+"],[matNo:"+locDetl.getMatNo()+"]");
                            }
                        }
                    }
                } else {//插入明细
                    LocDetl one = new LocDetl();
                    one.setLocNo(entity.getLocNo());
                    one.setMatNo(entity.getMatNo());
                    one.setQty(entity.getCheckQty());
                    one.setModiUser(getUserId());
                    one.setModiTime(now);
                    one.setAppeUser(getUserId());
                    one.setAppeTime(now);
                    WaitMatchk waitMatchk = waitMatchkService.selectOne(new EntityWrapper<WaitMatchk>().eq("loc_no",entity.getLocNo()));
                    if(null != waitMatchk){
                        one.setZpallet(waitMatchk.getZpallet());
                    }
                    MatCode matCode = matCodeService.selectOne(new EntityWrapper<MatCode>().eq("mat_no",entity.getMatNo()));
                    if(null != matCode) {
                        one.setMatName(matCode.getMatName());
                        one.setUnit(matCode.getUnit());
                        one.setSpecs(matCode.getSpecs());
                        one.setSize(matCode.getSize());
                        one.setColor(matCode.getColor());
                    } else {
                        throw new CoolException("新增明细物料编码不存在出错[matNo:"+entity.getMatNo()+"]");
                    }
                    if(!locDetlService.insert(one)){
                        throw new CoolException("插入库存明细出错[locNo:"+entity.getLocNo()+"],[matNo:"+entity.getMatNo()+"]");
                    }
                }
                entity.setVerifyStatus(1);
                entity.setVerifyUser(getUserId());
                entity.setModiTime(now);
                Wrapper<WaitMatchk> wrapper = new EntityWrapper<WaitMatchk>().eq("loc_no",entity.getLocNo()).eq("mat_no",entity.getMatNo());
                waitMatchkService.update(entity,wrapper);
            } else {
                throw new CoolException("库位非在库状态:" + locMast.getLocNo());
            }
        }
        return R.ok();
    }