| | |
| | | package com.zy.asrs.controller; |
| | | |
| | | 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.annotations.ManagerAuth; |
| | | import com.core.common.BaseRes; |
| | | import com.core.common.Cools; |
| | | import com.core.common.R; |
| | | import com.core.exception.CoolException; |
| | | import com.zy.asrs.entity.*; |
| | | import com.zy.asrs.entity.param.CombParam; |
| | | import com.zy.asrs.entity.param.MobileAdjustParam; |
| | | import com.zy.asrs.entity.param.OffSaleParam; |
| | | import com.zy.asrs.entity.param.*; |
| | | import com.zy.asrs.entity.result.MobileAdjustResult; |
| | | import com.zy.asrs.mapper.ManLocDetlMapper; |
| | | import com.zy.asrs.service.*; |
| | | import com.zy.common.model.LocDto; |
| | | import com.zy.common.model.TaskDto; |
| | | import com.zy.asrs.utils.SaasUtils; |
| | | import com.zy.common.model.WrkDto; |
| | | import com.zy.common.web.BaseController; |
| | | import com.zy.system.entity.User; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.text.ParseException; |
| | | import java.util.*; |
| | | |
| | | /** |
| | |
| | | private PackService packService; |
| | | @Autowired |
| | | private ManLocDetlMapper manLocDetlMapper; |
| | | @Autowired |
| | | private PlaService plaService; |
| | | @Autowired |
| | | private NodeService nodeService; |
| | | @Autowired |
| | | private OpenService openService; |
| | | |
| | | |
| | | // 商品上架 |
| | |
| | | return R.ok(); |
| | | } |
| | | List<OrderDetl> orderDetls = orderService.selectWorkingDetls(order.getId()); |
| | | if (Cools.isEmpty(orderDetls)) { |
| | | ArrayList<OrderDetl> orderDetls2 = new ArrayList<>(); |
| | | for (OrderDetl orderDetl : orderDetls){ |
| | | orderDetl.setAnfme(new BigDecimal(orderDetl.getAnfme()).setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue()); |
| | | orderDetl.setWorkQty(new BigDecimal(orderDetl.getWorkQty()).setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue()); |
| | | orderDetl.setQty(new BigDecimal(orderDetl.getQty()).setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue()); |
| | | orderDetls2.add(orderDetl); |
| | | } |
| | | if (Cools.isEmpty(orderDetls) || Cools.isEmpty(orderDetls2)) { |
| | | return R.ok(); |
| | | } |
| | | return R.ok().add(orderDetls); |
| | | return R.ok().add(orderDetls2); |
| | | } |
| | | |
| | | @RequestMapping("/comb/auth") |
| | |
| | | return R.ok("盘点成功"); |
| | | } |
| | | |
| | | @RequestMapping("/adjustNew/auth") |
| | | @ManagerAuth(memo = "pda盘点") |
| | | public R adjustNew(@RequestBody MobileAdjustNewParam combParam){ |
| | | mobileService.adjustNew(combParam, getUserId()); |
| | | return R.ok("盘点成功"); |
| | | } |
| | | |
| | | @PostMapping("/order/out/pakout/auth") |
| | | @ManagerAuth(memo = "订单出库") |
| | | public synchronized R pakoutByOrder(@RequestBody JSONObject param) { |
| | |
| | | |
| | | //平库pda上架 |
| | | @RequestMapping("/manDetl/in") |
| | | @ManagerAuth(memo = "订单上架") |
| | | public R manDetlAdd(@RequestBody JSONObject json){ |
| | | if (json == null){ |
| | | return R.error("传入数据为空"); |
| | | } |
| | | return mobileService.manDetlIn(json); |
| | | return mobileService.manDetlIn(json, getUser()); |
| | | } |
| | | |
| | | //平库pda下架 |
| | | @RequestMapping("/manDetl/out") |
| | | @ManagerAuth(memo = "订单下架") |
| | | public R manDetlDelete(@RequestBody JSONObject json){ |
| | | if (json == null){ |
| | | return R.error("传入数据为空"); |
| | | } |
| | | return mobileService.manDetlOut(json); |
| | | return mobileService.manDetlOut(json , getUser()); |
| | | } |
| | | |
| | | @RequestMapping("/manDetl/in/barcode") |
| | | @ManagerAuth(memo = "订单上架(托盘码)") |
| | | public R manDetlAddbarcode(@RequestBody JSONObject json){ |
| | | if (json == null){ |
| | | return R.error("传入数据为空"); |
| | | } |
| | | return mobileService.manDetlInBarcode(json,getUser()); |
| | | } |
| | | |
| | | @RequestMapping("/manDetl/in/origin") |
| | | @ManagerAuth(memo = "平库上架") |
| | | public R manDetlIn(@RequestBody JSONObject json){ |
| | | if (json == null){ |
| | | return R.error("传入数据为空"); |
| | | } |
| | | return mobileService.manDetlOrigin(json,getUser()); |
| | | } |
| | | |
| | | @RequestMapping("/manDetl/in/no/origin") |
| | | @ManagerAuth(memo = "平库上架") |
| | | public R manDetlInNo(@RequestBody JSONObject json){ |
| | | if (json == null){ |
| | | return R.error("传入数据为空"); |
| | | } |
| | | return mobileService.manDetlOrigInNo(json,getUser()); |
| | | } |
| | | |
| | | // @RequestMapping("/manDetl/out/origin") |
| | | // @ManagerAuth(memo = "平库下架") |
| | | // public R manDetlout(@RequestBody JSONObject json){ |
| | | // if (json == null){ |
| | | // return R.error("传入数据为空"); |
| | | // } |
| | | // return mobileService.manDetlOriginOut(json,getUser()); |
| | | // } |
| | | |
| | | @RequestMapping("/manDetl/out/origin") |
| | | @ManagerAuth(memo = "平库下架") |
| | | public R manDetlout2(@RequestBody JSONObject json){ |
| | | if (json == null){ |
| | | return R.error("传入数据为空"); |
| | | } |
| | | return mobileService.manDetlOriginOut(json,getUser()); |
| | | } |
| | | |
| | | @RequestMapping("/plaDetl/packin/v1") |
| | | //@ManagerAuth(memo="pla入库") |
| | | @Transactional |
| | | public R plaPackIn(@RequestBody JSONObject json) throws ParseException { |
| | | String locNo = json.get("locNo").toString(); |
| | | JSONArray jsonArray = JSONArray.parseArray(json.getJSONArray("pla").toJSONString()); |
| | | //判断此次入库是否达到库存上限 |
| | | if(!mobileService.checkMaximum(locNo,jsonArray.size())){ |
| | | return R.error("当前入库包数已超过库存上限"); |
| | | } |
| | | for (Object o : jsonArray){ |
| | | JSONObject jsonObject = (JSONObject)o; |
| | | String brand = jsonObject.get("brand").toString(); |
| | | String batch = jsonObject.get("batch").toString(); |
| | | Integer packageNo = Integer.parseInt(jsonObject.get("packageNo").toString()); |
| | | if(Cools.isEmpty(locNo) || Cools.isEmpty(batch) || Cools.isEmpty(packageNo)){ |
| | | return R.error("有参数为空,无法入库"); |
| | | } |
| | | //测试 |
| | | if(true){ |
| | | User user = new User(); |
| | | user.setUsername("test"); |
| | | mobileService.plaPakin(brand,locNo,batch,packageNo,user); |
| | | } |
| | | } |
| | | //入库成功后上报ERP |
| | | //openService.pakinReportErp(json); |
| | | return R.ok("入库成功"); |
| | | } |
| | | |
| | | @RequestMapping("/plaDetl/packin/v11") |
| | | @ManagerAuth(memo="pla入库") |
| | | @Transactional |
| | | public R plaPackInTestErp(@RequestBody JSONObject json) throws ParseException { |
| | | String locNo = json.get("locNo").toString(); |
| | | JSONArray jsonArray = JSONArray.parseArray(json.getJSONArray("pla").toJSONString()); |
| | | for (Object o : jsonArray){ |
| | | JSONObject jsonObject = (JSONObject)o; |
| | | String brand = jsonObject.get("brand").toString(); |
| | | String batch = jsonObject.get("batch").toString(); |
| | | Integer packageNo = Integer.parseInt(jsonObject.get("packageNo").toString()); |
| | | if(Cools.isEmpty(locNo) || Cools.isEmpty(batch) || Cools.isEmpty(packageNo)){ |
| | | return R.error("有参数为空,无法入库"); |
| | | } |
| | | //测试 |
| | | if(false){ |
| | | User user = new User(); |
| | | user.setUsername("test"); |
| | | mobileService.plaPakin(brand,locNo,batch,packageNo,user); |
| | | json.put("user",user.getUsername()); |
| | | }else { |
| | | mobileService.plaPakin(brand,locNo,batch,packageNo,getUser()); |
| | | json.put("user",getUser().getUsername()); |
| | | } |
| | | } |
| | | //入库成功后上报ERP |
| | | openService.pakinReportErp(json); |
| | | return R.ok("入库成功"); |
| | | } |
| | | |
| | | @RequestMapping("/plaDetl/packout1/v1") |
| | | // @ManagerAuth(memo="pla出库") |
| | | public R plaPackOut1(@RequestBody JSONObject json){ |
| | | String locNo = json.get("locNo").toString(); |
| | | String brand = json.get("brand").toString(); |
| | | String batch = json.get("batch").toString(); |
| | | Integer packageNo = Integer.parseInt(json.get("packageNo").toString()); |
| | | String orderNo = json.get("orderNo").toString(); |
| | | String orderDetlId = json.get("orderDetlId").toString(); |
| | | String wrkNo = json.get("wrkNo").toString(); |
| | | Double anfme = Double.parseDouble(json.get("anfme").toString()); |
| | | boolean isReplace = Cools.eq(json.get("replace").toString(),"y"); |
| | | |
| | | if(Cools.isEmpty(locNo) || Cools.isEmpty(batch) || Cools.isEmpty(packageNo)){ |
| | | return R.error("有参数为空,无法入库"); |
| | | } |
| | | |
| | | mobileService.plaPakout(brand,locNo,batch,packageNo,orderNo,orderDetlId,wrkNo,anfme,isReplace); |
| | | return R.ok(); |
| | | } |
| | | |
| | | @RequestMapping("/plaDetl/packout/v1") |
| | | // @ManagerAuth(memo="pla出库") |
| | | public R plaPackOut(@RequestBody JSONObject json){ |
| | | String locNo = json.get("locNo").toString(); |
| | | String brand = json.get("brand").toString(); |
| | | String batch = json.get("batch").toString(); |
| | | Integer packageNo = Integer.parseInt(json.get("packageNo").toString()); |
| | | String orderNo = json.get("orderNo").toString(); |
| | | String plaQtyId = json.get("orderDetlId").toString(); |
| | | String wrkNo = json.get("wrkNo").toString(); |
| | | Double anfme = Double.parseDouble(json.get("anfme").toString()); |
| | | boolean isReplace = !Cools.isEmpty(json.get("replace")) && Cools.eq(json.get("replace").toString(),"y"); |
| | | |
| | | if(Cools.isEmpty(locNo) || Cools.isEmpty(batch) || Cools.isEmpty(packageNo)){ |
| | | return R.error("有参数为空,无法入库"); |
| | | } |
| | | |
| | | mobileService.plaPakout(brand,locNo,batch,packageNo,orderNo,plaQtyId,wrkNo,anfme,isReplace); |
| | | return R.ok(); |
| | | } |
| | | |
| | | /* |
| | | 无订单拣货出库 |
| | | */ |
| | | @RequestMapping("/plaDetl/packout/noOrder/v1") |
| | | //@ManagerAuth(memo="pla手动出库") |
| | | public R plaPackOutWithoutOrder(@RequestBody List<PlaParam> params){ |
| | | |
| | | for (PlaParam param : params){ |
| | | mobileService.plaPackOutWithoutOrder(param.getBrand(),param.getBatch(),param.getPackageNo(),param.getAnfme()); |
| | | } |
| | | |
| | | return R.ok(); |
| | | } |
| | | |
| | | |
| | | @RequestMapping("/plaDetl/check/v1") |
| | | public R plaDetlCheck(@RequestBody JSONObject json){ |
| | | String brand = json.get("brand").toString(); |
| | | String batch = json.get("batch").toString(); |
| | | Integer packageNo = Integer.parseInt(json.get("packageNo").toString()); |
| | | Integer type = Integer.parseInt(json.get("type").toString()); |
| | | if(Cools.isEmpty(batch) || Cools.isEmpty(packageNo)){ |
| | | return R.error("有参数为空,无法入库"); |
| | | } |
| | | |
| | | Pla pla = plaService.selectByBatchAndPackageNo(batch, packageNo,brand); |
| | | if ((Cools.isEmpty(pla))){ |
| | | return R.error("该包物料未录入,无法查询到相关信息").add(pla); |
| | | } |
| | | if(!(Cools.eq(pla.getStatus(), GlobleParameter.PLA_STATUS_0) || Cools.eq(pla.getStatus(), GlobleParameter.PLA_STATUS_00)) && type != 2){ |
| | | return R.error("该包物料的状态为" + pla.getStatus() +",无法进行入库操作").add(pla); |
| | | } |
| | | return R.ok(pla); |
| | | } |
| | | |
| | | /* |
| | | pla移库 |
| | | */ |
| | | @RequestMapping("/plaDetl/move/v1") |
| | | @ManagerAuth |
| | | public R plaDetlMove(@RequestBody PlaMoveParam param){ |
| | | |
| | | String locNo = param.getLocNo(); |
| | | |
| | | Node node = nodeService.selectByUuid(locNo); |
| | | if(Cools.isEmpty(node)){ |
| | | throw new CoolException("库位信息不正确"); |
| | | } |
| | | |
| | | List<PlaMoveParam.PlaMove> plas = param.getPlas(); |
| | | //判断此次入库是否达到库存上限 |
| | | if(!mobileService.checkMaximum(locNo,plas.size())){ |
| | | return R.error("当前入库包数已超过库存上限"); |
| | | } |
| | | |
| | | param.getPlas().forEach(p -> { |
| | | String brand = p.getBrand(); |
| | | String batch = p.getBatch(); |
| | | Integer packageNo = p.getPackageNo(); |
| | | if(Cools.isEmpty(batch) || Cools.isEmpty(packageNo)){ |
| | | throw new CoolException("有参数为空,无法入库"); |
| | | } |
| | | Pla pla = plaService.selectByBatchAndPackageNo(batch, packageNo,brand); |
| | | if ((Cools.isEmpty(pla))){ |
| | | throw new CoolException("该包物料未录入,无法查询到相关信息"); |
| | | } |
| | | if(!Cools.eq(pla.getStatus(),GlobleParameter.PLA_STATUS_1) && !Cools.eq(pla.getStatus(),GlobleParameter.PLA_STATUS_3)){ |
| | | throw new CoolException("该包物料的状态为" + pla.getStatus() +",无法进行入库操作"); |
| | | } |
| | | |
| | | String sourceLocNo = pla.getLocNo(); |
| | | pla.setLocNo(locNo); |
| | | pla.setStash(node.getParentName()); |
| | | pla.setModifyTime(new Date()); |
| | | |
| | | plaService.updateById(pla); |
| | | SaasUtils.insertLog(2,sourceLocNo,pla.getBrand(),pla.getWeightAnfme(),getUser().getUsername(), |
| | | locNo,pla.getBatch(),pla.getPackageNo(),pla.getOwner(),pla.getWorkshop(),null); |
| | | |
| | | }); |
| | | |
| | | return R.ok("移库成功"); |
| | | } |
| | | |
| | | /* |
| | | 根据拣货单出库 ------> 获取拣货单 |
| | | */ |
| | | @RequestMapping("/manpakout/check/v1") |
| | | public R getManPakout (@RequestBody JSONObject json){ |
| | | |
| | | String orderNo = json.get("orderNo").toString(); |
| | | |
| | | return R.ok(mobileService.getManPakoutByOrderNo(orderNo)); |
| | | } |
| | | |
| | | @RequestMapping("/manpakout/pakout/v1") |
| | | public R pakout(@RequestBody JSONObject json){ |
| | | |
| | | String batch = json.get("batch").toString(); |
| | | Integer packageNo = Integer.parseInt(json.get("packageNo").toString()); |
| | | String orderNo = json.get("orderNo").toString(); |
| | | |
| | | |
| | | |
| | | return R.ok(); |
| | | } |
| | | @RequestMapping("select/mat/information/v1") |
| | | @ManagerAuth |
| | | public R pdaSelectInformation(@RequestParam String barcode){ |
| | | List<Pla> locDetls = mobileService.pdaSelectInfmt(barcode); |
| | | return R.ok(locDetls); |
| | | } |
| | | |
| | | |
| | | public static void main(String[] args) { |
| | | // String aa = "[{\"batch\":\"2023090304\",\"packageNo\":\"8\"},{\"batch\":\"2023090304\",\"packageNo\":\"8\"}]"; |
| | | // JSONArray jsonArray = JSON.parseArray(aa); |
| | | // Object o = jsonArray.get(0); |
| | | // System.out.println(o.toString()); |
| | | // JSONObject jsonObject = (JSONObject)o; |
| | | // System.out.println(jsonObject); |
| | | |
| | | String s = "2024010502"; |
| | | System.out.println(s.substring(8,10)); |
| | | |
| | | Object s1 = "8"; |
| | | System.out.println(Integer.parseInt(s1.toString())); |
| | | } |
| | | |
| | | } |