| | |
| | | package com.zy.asrs.service.impl; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.baomidou.mybatisplus.mapper.Wrapper; |
| | | import com.core.common.*; |
| | | import com.core.common.BaseRes; |
| | | import com.core.common.Cools; |
| | | import com.core.common.DateUtils; |
| | | import com.core.common.R; |
| | | import com.core.exception.CoolException; |
| | | import com.sun.org.apache.xpath.internal.operations.Or; |
| | | import com.zy.asrs.entity.*; |
| | | import com.zy.asrs.entity.param.*; |
| | | import com.zy.asrs.entity.param.CombParam; |
| | | import com.zy.asrs.entity.param.MobileAdjustNewParam; |
| | | import com.zy.asrs.entity.param.MobileAdjustParam; |
| | | import com.zy.asrs.entity.param.OffSaleParam; |
| | | import com.zy.asrs.mapper.ManLocDetlMapper; |
| | | import com.zy.asrs.service.*; |
| | | import com.zy.asrs.utils.MatUtils; |
| | | import com.zy.asrs.utils.SaasUtils; |
| | | import com.zy.common.CodeRes; |
| | | import com.zy.common.constant.MesConstant; |
| | | import com.zy.common.entity.Parameter; |
| | | import com.zy.common.model.DetlDto; |
| | | import com.zy.common.model.MesCombParam; |
| | | import com.zy.common.service.CommonService; |
| | | import com.zy.common.utils.HttpHandler; |
| | | import com.zy.common.utils.Synchro; |
| | | import com.zy.system.entity.User; |
| | | import com.zy.system.service.SaasLogService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.Iterator; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 移动端服务核心类 |
| | |
| | | private LocInPrintMatService locInPrintMatService; |
| | | |
| | | @Autowired |
| | | private LocOutPrintMatService locOutPrintMatService; |
| | | |
| | | @Autowired |
| | | private LocOwnerService locOwnerService; |
| | | @Autowired |
| | | private PlaService plaService; |
| | | @Autowired |
| | | private PlaQtyService plaQtyService; |
| | | @Autowired |
| | | private SaasLogService saasLogService; |
| | | |
| | | |
| | | |
| | |
| | | |
| | | @Override |
| | | public R manDetlOriginOut(JSONObject json, User user) { |
| | | Date now = new Date(); |
| | | JSONArray combMats = json.getJSONArray("combMats"); |
| | | List<MatPrint> matPrintList=new ArrayList<>(); |
| | | List<Long> ids=new ArrayList<>(); |
| | | for (int i = 0; i < combMats.size(); i++) { |
| | | MatPrint jsonOriginDetl = combMats.getObject(i, MatPrint.class); |
| | | MatPrint matPrintNow = combMats.getObject(i, MatPrint.class); |
| | | if (!ids.contains(matPrintNow.getIndex())){ |
| | | ids.add(matPrintNow.getIndex()); |
| | | matPrintList.add(matPrintNow); |
| | | } |
| | | } |
| | | for (MatPrint jsonOriginDetl:matPrintList) { |
| | | Double parseLong = jsonOriginDetl.getAnfme(); |
| | | Long ownerId = Long.parseLong(jsonOriginDetl.getOwner()); |
| | | jsonOriginDetl.setOwnerId(ownerId); |
| | |
| | | if (manLocDetl.getAnfme() > parseLong){ |
| | | BigDecimal num = anfme.subtract(outAnfme); |
| | | manLocDetl.setAnfme(num.doubleValue()); |
| | | manLocDetl.setUpdateBy(user.getId()); |
| | | manLocDetl.setModiTime(now); |
| | | if (!manLocDetlService.update(manLocDetl,manLocDetlWrapper)) { |
| | | return R.error("物料信息下架失败"); |
| | | } |
| | |
| | | } |
| | | } |
| | | } |
| | | for (MatPrint jsonOriginDetl:matPrintList) { |
| | | //增加打印档案 |
| | | LocOutPrintMat locOutPrintMat = new LocOutPrintMat(now, user.getId(), jsonOriginDetl.getMatnr(), jsonOriginDetl.getBatch(), jsonOriginDetl.getAnfme(), jsonOriginDetl.getLocNo(), jsonOriginDetl.getMaktx()); |
| | | locOutPrintMat.setOwnerId(jsonOriginDetl.getOwnerId()); |
| | | locOutPrintMatService.insert(locOutPrintMat); |
| | | } |
| | | return R.ok(); |
| | | } |
| | | |
| | | @Override |
| | | public void plaPakin(String locNo, String batch, String packageNo) { |
| | | Pla pla = plaService.selectByBatchAndPackageNo(batch, packageNo); |
| | | if(!pla.getLocNo().equals(locNo)){ |
| | | throw new CoolException("该物料入库的库位错误"); |
| | | } |
| | | if("已入库".equals(pla.getStatus())){ |
| | | throw new CoolException("该物料已入库"); |
| | | } |
| | | pla.setStatus("已入库"); |
| | | pla.setModifyTime(new Date()); |
| | | plaService.updateById(pla); |
| | | SaasUtils.insertLog(0,locNo,batch+","+packageNo,pla.getWeightAnfme(),null); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional |
| | | public void plaPakout(String locNo, String batch, String packageNo, String orderNo, String orderDetlId, String wrkNo, Double anfme) { |
| | | Pla pla = plaService.selectByBatchAndPackageNo(batch, packageNo); |
| | | |
| | | ManPakOut manPakOut = manPakOutService.selectById(wrkNo); |
| | | |
| | | PlaQty plaQty = plaQtyService.selectById(orderDetlId); |
| | | |
| | | //更新拣货单信息 |
| | | if(manPakOut.getCount() + anfme > manPakOut.getAnfme()){ |
| | | throw new CoolException("拣货重量大于拣货单所需拣货重量,请重新分配拣货重量"); |
| | | } |
| | | if(manPakOut.getStatus() == 1){ |
| | | throw new CoolException("该拣料单已出库"); |
| | | } |
| | | manPakOut.setCount(manPakOut.getCount() + anfme); |
| | | if (manPakOut.getAnfme().equals(manPakOut.getCount())){ |
| | | manPakOut.setStatus(1); |
| | | manPakOutService.updateById(manPakOut); |
| | | } |
| | | |
| | | //更新pla明细 |
| | | pla.setWeightAnfme(pla.getWeightAnfme() - anfme); |
| | | pla.setQtyAnfme(pla.getQtyAnfme() - anfme); |
| | | if(pla.getWeightAnfme() <= 0){ |
| | | pla.setStatus("全部出库"); |
| | | }else { |
| | | pla.setStatus("部分出库"); |
| | | } |
| | | plaService.updateById(pla); |
| | | SaasUtils.insertLog(1,locNo,batch+","+packageNo,anfme,null); |
| | | |
| | | } |
| | | } |