| | |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.baomidou.mybatisplus.mapper.Wrapper; |
| | | import com.baomidou.mybatisplus.plugins.Page; |
| | | import com.core.common.DateUtils; |
| | | import com.zy.common.web.BaseController; |
| | | import com.zy.ints.entity.WaitMatchk; |
| | | import com.zy.ints.service.WaitMatchkService; |
| | | import com.core.annotations.ManagerAuth; |
| | | import com.core.common.BaseRes; |
| | | import com.core.common.Cools; |
| | | import com.core.common.DateUtils; |
| | | import com.core.common.R; |
| | | import com.core.controller.AbstractBaseController; |
| | | 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.IoComplete; |
| | | import com.zy.ints.entity.WaitMatchk; |
| | | import com.zy.ints.service.IoCompleteService; |
| | | 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.*; |
| | |
| | | |
| | | @Autowired |
| | | private WaitMatchkService waitMatchkService; |
| | | @Autowired |
| | | private WaitMatchkLogService waitMatchkLogService; |
| | | @Autowired |
| | | private LocMastService locMastService; |
| | | @Autowired |
| | | private LocDetlService locDetlService; |
| | | @Autowired |
| | | private MatCodeService matCodeService; |
| | | @Autowired |
| | | private IoCompleteService ioCompleteService; |
| | | |
| | | //盘点通知档 |
| | | |
| | |
| | | @RequestParam(defaultValue = "10")Integer limit, |
| | | @RequestParam(required = false)String orderByField, |
| | | @RequestParam(required = false)String orderByType, |
| | | @RequestParam(required = false)String condition, |
| | | @RequestParam Map<String, Object> param){ |
| | | EntityWrapper<WaitMatchk> wrapper = new EntityWrapper<>(); |
| | | excludeTrash(param); |
| | | convert(param, wrapper); |
| | | allLike(WaitMatchk.class, param.keySet(), wrapper, condition); |
| | | if (!Cools.isEmpty(orderByField)){wrapper.orderBy(humpToLine(orderByField), "asc".equals(orderByType));} |
| | | return R.ok(waitMatchkService.selectPage(new Page<>(curr, limit), wrapper)); |
| | | } |
| | |
| | | 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){ |
| | | waitMatchkService.delete(new EntityWrapper<>(entity)); |
| | | 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()+"]"); |
| | | } |
| | | |
| | | //盘点结果插入回报档 |
| | | IoComplete ioComplete = new IoComplete(); |
| | | ioComplete.setBillNo(entity.getBillNo()); |
| | | ioComplete.setSeqNo(entity.getSeqNo()); |
| | | ioComplete.setTaskType(4); //盘亏 |
| | | ioComplete.setLocNo(entity.getLocNo()); |
| | | ioComplete.setMatNo(entity.getMatNo()); |
| | | ioComplete.setMatName(locDetl.getMatName()); |
| | | ioComplete.setZpallet(locDetl.getZpallet()); |
| | | ioComplete.setQty(locDetl.getQty()); |
| | | ioComplete.setUpdStatus(0); |
| | | ioComplete.setModiUser(getUserId()); |
| | | ioComplete.setModiTime(now); |
| | | ioComplete.setAppeUser(getUserId()); |
| | | ioComplete.setAppeTime(now); |
| | | if(!ioCompleteService.insert(ioComplete)){ |
| | | throw new CoolException("插入回报档出错[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()+"]"); |
| | | } |
| | | |
| | | //盘点结果插入回报档 |
| | | Double qty = 0D; |
| | | int type = 0; |
| | | if(entity.getCheckQty()>locDetl.getQty()){//盘盈 |
| | | qty = entity.getCheckQty() - locDetl.getQty(); |
| | | type = 3; |
| | | } else { //盘亏 |
| | | qty = locDetl.getQty() - entity.getCheckQty(); |
| | | type = 4; |
| | | } |
| | | IoComplete ioComplete = new IoComplete(); |
| | | ioComplete.setBillNo(entity.getBillNo()); |
| | | ioComplete.setSeqNo(entity.getSeqNo()); |
| | | ioComplete.setTaskType(type); |
| | | ioComplete.setLocNo(entity.getLocNo()); |
| | | ioComplete.setMatNo(entity.getMatNo()); |
| | | ioComplete.setMatName(locDetl.getMatName()); |
| | | ioComplete.setZpallet(locDetl.getZpallet()); |
| | | ioComplete.setQty(qty); |
| | | ioComplete.setUpdStatus(0); |
| | | ioComplete.setModiUser(getUserId()); |
| | | ioComplete.setModiTime(now); |
| | | ioComplete.setAppeUser(getUserId()); |
| | | ioComplete.setAppeTime(now); |
| | | if(!ioCompleteService.insert(ioComplete)){ |
| | | 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()+"]"); |
| | | } |
| | | |
| | | //盘点结果插入回报档 |
| | | IoComplete ioComplete = new IoComplete(); |
| | | ioComplete.setBillNo(entity.getBillNo()); |
| | | ioComplete.setSeqNo(entity.getSeqNo()); |
| | | ioComplete.setTaskType(3); //盘盈 |
| | | ioComplete.setLocNo(entity.getLocNo()); |
| | | ioComplete.setMatNo(entity.getMatNo()); |
| | | ioComplete.setMatName(one.getMatName()); |
| | | ioComplete.setZpallet(one.getZpallet()); |
| | | ioComplete.setQty(entity.getCheckQty()); |
| | | ioComplete.setUpdStatus(0); |
| | | ioComplete.setModiUser(getUserId()); |
| | | ioComplete.setModiTime(now); |
| | | ioComplete.setAppeUser(getUserId()); |
| | | ioComplete.setAppeTime(now); |
| | | if(!ioCompleteService.insert(ioComplete)){ |
| | | 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(); |
| | | } |