| | |
| | | import com.alibaba.excel.EasyExcel; |
| | | import com.alibaba.excel.write.style.column.LongestMatchColumnWidthStyleStrategy; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.baomidou.mybatisplus.mapper.Wrapper; |
| | | import com.baomidou.mybatisplus.plugins.Page; |
| | | import com.core.annotations.ManagerAuth; |
| | | import com.core.common.Cools; |
| | | import com.core.common.DateUtils; |
| | | import com.core.common.R; |
| | | import com.core.common.SnowflakeIdWorker; |
| | | import com.core.exception.CoolException; |
| | | import com.zy.asrs.entity.*; |
| | | import com.zy.asrs.entity.param.GlobleParameter; |
| | | import com.zy.asrs.entity.result.KeyValueVo; |
| | | import com.zy.asrs.service.*; |
| | | import com.zy.asrs.utils.PlaExcelListener; |
| | | import com.zy.asrs.utils.SaasUtils; |
| | | import com.zy.common.CodeRes; |
| | | import com.zy.common.entity.PlaExcel; |
| | | import com.zy.common.web.BaseController; |
| | | import lombok.Synchronized; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.IOException; |
| | | import java.net.URLEncoder; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.*; |
| | | |
| | | @RestController |
| | | @Slf4j |
| | | public class PlaController extends BaseController { |
| | | |
| | | @Autowired |
| | |
| | | private OrderDetlService orderDetlService; |
| | | @Autowired |
| | | private PlaLogService plaLogService; |
| | | @Autowired |
| | | private MatService matService; |
| | | @Autowired |
| | | private SnowflakeIdWorker snowflakeIdWorker; |
| | | |
| | | |
| | | @RequestMapping(value = "/pla/list/auth") |
| | | @ManagerAuth |
| | |
| | | @RequestParam Map<String, Object> param){ |
| | | excludeTrash(param); |
| | | EntityWrapper<Pla> wrapper = new EntityWrapper<>(); |
| | | |
| | | if(!Cools.isEmpty(param.get("brand"))){ |
| | | wrapper.eq("brand",param.get("brand")); |
| | | param.remove("brand"); |
| | | } |
| | | // 没有选择的时候默认不显示已出库的物料 |
| | | if (Cools.isEmpty(param.get("status"))) { |
| | | wrapper.ne("status", "全部出库"); |
| | | } |
| | | |
| | | if (!Cools.isEmpty(param.get("batch")) && param.get("batch").toString().contains(",")){ |
| | | String[] batchs = param.get("batch").toString().split(","); |
| | | wrapper.in("batch",batchs); |
| | | param.remove("batch"); |
| | | } |
| | | |
| | | convert(param, wrapper); |
| | | wrapper.orderBy("modify_time",false); |
| | | wrapper.orderBy("batch",true).orderBy("package_no" ,true); |
| | | allLike(Pla.class, param.keySet(), wrapper, condition); |
| | | return R.ok(plaService.selectPage(new Page<>(curr, limit), wrapper)); |
| | | } |
| | |
| | | BeanUtils.copyProperties(plaSave,plaLog); |
| | | plaLog.setId(null); |
| | | plaLog.setCreateTime(new Date()); |
| | | plaLog.setModifyUser(getUser().getUsername()); |
| | | plaLogService.insert(plaLog); |
| | | |
| | | }); |
| | |
| | | public R delete(@RequestBody List<Pla> plas) { |
| | | System.out.println(plas.toString()); |
| | | plas.forEach(pla -> { |
| | | if(!pla.getStatus().equals(GlobleParameter.PLA_STATUS_00) || pla.getStatus().equals(GlobleParameter.PLA_STATUS_0)){ |
| | | throw new CoolException("非待入库的数据无法被删除"); |
| | | if(!pla.getStatus().equals(GlobleParameter.PLA_STATUS_00) && !pla.getStatus().equals(GlobleParameter.PLA_STATUS_0) && !pla.getStatus().equals(GlobleParameter.PLA_STATUS_1)){ |
| | | throw new CoolException("已入库的数据无法被删除"); |
| | | } |
| | | Pla plaSave = plaService.selectById(pla.getId()); |
| | | pla.setModifyTime(new Date()); |
| | |
| | | BeanUtils.copyProperties(plaSave,plaLog); |
| | | plaLog.setId(null); |
| | | plaLog.setCreateTime(new Date()); |
| | | plaLog.setModifyUser(getUser().getUsername()); |
| | | plaLogService.insert(plaLog); |
| | | |
| | | }); |
| | |
| | | for (Pla pla : plas){ |
| | | |
| | | if(pla.getStockFreeze() == 0){ |
| | | throw new CoolException("库存已被冻结,请重新选择库存"); |
| | | // throw new CoolException("库存已被冻结,请重新选择库存"); |
| | | System.out.println(pla.getStockFreezeBy() + "," + getUser().getUsername()); |
| | | if(!Cools.eq(pla.getStockFreezeBy(),getUser().getUsername())){ |
| | | throw new CoolException("该库存已被其他用户冻结,请重新选择"); |
| | | } |
| | | } |
| | | |
| | | allOrderWeight += pla.getOrderWeight(); |
| | |
| | | plaService.updateById(pla); |
| | | plaQtyService.insert(plaQty); |
| | | //生成拣货单 |
| | | addPakOUT(plaQty); |
| | | addPakOUT(plaQty,getUserId()); |
| | | |
| | | }; |
| | | |
| | |
| | | pla.setModifyTime(new Date()); |
| | | pla.setWeightAnfme(0.0); |
| | | plaService.updateById(pla); |
| | | SaasUtils.insertLog(1,pla.getLocNo(),pla.getBatch()+","+pla.getPackageNo(),anfme,getUser().getUsername()); |
| | | SaasUtils.insertLog(1,pla.getLocNo(),pla.getBrand(),anfme,getUser().getUsername(), |
| | | null,pla.getBatch(),pla.getPackageNo(),pla.getOwner(),pla.getWorkshop(),null); |
| | | }); |
| | | |
| | | return R.ok(); |
| | |
| | | } |
| | | for (Pla pla : plas){ |
| | | if (pla.getStockFreeze() == 0){ |
| | | throw new CoolException("库存已被冻结!"); |
| | | continue; |
| | | // throw new CoolException("库存已被冻结!"); |
| | | } |
| | | pla.setStockFreeze(0); |
| | | pla.setStockFreezeBy(getUser().getUsername()); |
| | |
| | | } |
| | | for (Pla pla : plas){ |
| | | if (pla.getStockFreeze() == 1){ |
| | | throw new CoolException("库位未冻结,无需解冻"); |
| | | continue; |
| | | // throw new CoolException("库位未冻结,无需解冻"); |
| | | } |
| | | if(!Cools.eq(pla.getStockFreezeBy(),getUser().getUsername())){ |
| | | throw new CoolException("无法解冻其他用户冻结的库位"); |
| | |
| | | |
| | | } |
| | | return R.ok("解除冻结成功"); |
| | | } |
| | | |
| | | @RequestMapping(value = "/matMaktxQuery/auth") |
| | | @ManagerAuth |
| | | public R queryMat(String condition) { |
| | | EntityWrapper<Mat> wrapper = new EntityWrapper<>(); |
| | | wrapper.like("maktx", condition); |
| | | Page<Mat> page = matService.selectPage(new Page<>(0, 10), wrapper); |
| | | List<Map<String, Object>> result = new ArrayList<>(); |
| | | for (Mat mat : page.getRecords()){ |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("id", mat.getMaktx()); |
| | | map.put("value", mat.getMaktx()); |
| | | result.add(map); |
| | | } |
| | | return R.ok(result); |
| | | } |
| | | |
| | | @RequestMapping(value = "/pla/statis/auth") |
| | | @ManagerAuth |
| | | public R statis(@RequestParam(defaultValue = "1")Integer curr, |
| | | @RequestParam(defaultValue = "10")Integer limit, |
| | | @RequestParam Map<String, Object> param) { |
| | | |
| | | Page<Pla> stockStatis = plaService.getStockStatisAll(toPage(curr, limit, param, Pla.class)); |
| | | |
| | | return R.ok().add(stockStatis); |
| | | } |
| | | |
| | | /** |
| | |
| | | try { |
| | | EasyExcel.read(file.getInputStream(), PlaExcel.class, listener).sheet().doRead(); |
| | | }catch (Exception e){ |
| | | throw new CoolException("导入的数据格式错误,原因:" + e.getMessage()); |
| | | e.printStackTrace(); |
| | | int index = listener.getIndex() - 1; |
| | | throw new CoolException("导入的数据格式错误,原因:" + e.getMessage() + ",第" + index + ",数据格式不对"); |
| | | } |
| | | log.info("导入修改信息输出:" + listener.getRecordLog()); |
| | | return R.ok("成功同步"+listener.getTotal()+"条pla物料数据"); |
| | | } |
| | | |
| | | // // 打印 |
| | | // @RequestMapping(value = "/pla/print/auth") |
| | | // @ManagerAuth(memo = "pla编码打印") |
| | | // public R matCodePrint(@RequestParam(value = "param[]") String[] param) { |
| | | // if(Cools.isEmpty(param)) { |
| | | // return R.parse(CodeRes.EMPTY); |
| | | // } |
| | | // List<MatPrint> res = new ArrayList<>(); |
| | | // for (String matnr : param){ |
| | | // Mat mat = matService.selectByMatnr(matnr); |
| | | // // 打印数据注入 |
| | | // MatPrint print = new MatPrint(); |
| | | // print.setMatnr(mat.getMatnr()); |
| | | // print.setBarcode(mat.getBarcode()); |
| | | // print.setMaktx(mat.getMaktx()); |
| | | // print.setSpecs(mat.getSpecs()); |
| | | // print.setUnit(mat.getUnit()); |
| | | // print.setMemo(mat.getMemo()); |
| | | // res.add(print); |
| | | // } |
| | | // return R.ok().add(res); |
| | | // } |
| | | // 打印 |
| | | @RequestMapping(value = "/pla/print/auth") |
| | | @ManagerAuth(memo = "pla编码打印") |
| | | public R matCodePrint(@RequestBody List<Pla> plas) { |
| | | if(Cools.isEmpty(plas)) { |
| | | return R.parse(CodeRes.EMPTY); |
| | | } |
| | | List<Pla> res = new ArrayList<>(); |
| | | for (Pla pla : plas){ |
| | | res.add(pla); |
| | | } |
| | | return R.ok().add(res); |
| | | } |
| | | |
| | | /*************************************** xm-select ***********************************************/ |
| | | |
| | | // xm-select 搜索批号 |
| | | @RequestMapping("/pla/batch/all/get/kv") |
| | | @ManagerAuth |
| | | public R getMatDataKV(@RequestParam(required = false) String condition) { |
| | | Wrapper<Pla> wrapper = new EntityWrapper<Pla>().setSqlSelect("batch") |
| | | .andNew().like("batch", condition) |
| | | .groupBy("batch") |
| | | .orderBy("batch",false); |
| | | List<Pla> plas = plaService.selectPage(new Page<Pla>(1, 30), wrapper).getRecords(); |
| | | List<KeyValueVo> valueVos = new ArrayList<>(); |
| | | for (Pla pla : plas) { |
| | | KeyValueVo vo = new KeyValueVo(); |
| | | vo.setName(pla.getBatch()); |
| | | vo.setValue(pla.getBatch()); |
| | | valueVos.add(vo); |
| | | } |
| | | return R.ok().add(valueVos); |
| | | } |
| | | |
| | | private <T> void convert(Map<String, Object> map, EntityWrapper<T> wrapper){ |
| | | for (Map.Entry<String, Object> entry : map.entrySet()){ |
| | |
| | | } |
| | | } |
| | | |
| | | private R addPakOUT(PlaQty plaQty){ |
| | | @Synchronized |
| | | private R addPakOUT(PlaQty plaQty,Long userId){ |
| | | ManPakOut manPakOut=new ManPakOut(); |
| | | manPakOut.setWrkNo(plaQty.getOrderNo()+"-"+System.currentTimeMillis()); |
| | | manPakOut.setWrkNo(plaQty.getOrderNo()+"-"+String.valueOf(snowflakeIdWorker.nextId())); |
| | | manPakOut.setWrkSts((long)1); |
| | | manPakOut.setAnfme(plaQty.getOrderWeight()); |
| | | manPakOut.setMaktx(plaQty.getBrand()); |
| | | manPakOut.setLocNo(plaQty.getLocNo()); |
| | | manPakOut.setBatch(plaQty.getBatch()); |
| | | manPakOut.setBarcode(plaQty.getPackageNo()); |
| | | manPakOut.setBarcode(plaQty.getPackageNo() + ""); |
| | | manPakOut.setUuid(String.valueOf(System.currentTimeMillis())); |
| | | manPakOut.setCreateTime(new Date()); |
| | | manPakOut.setUpdateTime(new Date()); |
| | |
| | | manPakOut.setStatus(0); |
| | | manPakOut.setDocId(plaQty.getOrderDetlId()); |
| | | manPakOut.setNodeId(plaQty.getId()); |
| | | manPakOut.setCustName(plaQty.getCustomer()); |
| | | manPakOut.setCreateBy(userId); |
| | | //预计发货时间 |
| | | manPakOut.setSpecs(plaQty.getPakoutTime()); |
| | | //manPakOut.setNodeId(plaQty.getOrderDetlId()); |
| | | manPakOutService.insert(manPakOut); |
| | | return R.ok(); |