| | |
| | | |
| | | import com.alibaba.excel.EasyExcel; |
| | | import com.alibaba.excel.write.style.column.LongestMatchColumnWidthStyleStrategy; |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | |
| | | import com.core.annotations.ManagerAuth; |
| | | import com.core.common.*; |
| | | import com.core.exception.CoolException; |
| | | import com.zy.asrs.entity.Mat; |
| | | import com.zy.asrs.entity.MatPrint; |
| | | import com.zy.asrs.entity.OrderDetl; |
| | | import com.zy.asrs.entity.*; |
| | | import com.zy.asrs.entity.param.EmptyPlateOutParam; |
| | | import com.zy.asrs.entity.result.KeyValueVo; |
| | | import com.zy.asrs.service.ApiLogService; |
| | | import com.zy.asrs.service.MatService; |
| | | import com.zy.asrs.utils.MatExcelListener; |
| | | import com.zy.common.CodeRes; |
| | | import com.zy.common.config.AdminInterceptor; |
| | | import com.zy.common.entity.MatExcel; |
| | | import com.zy.common.utils.BarcodeUtils; |
| | | import com.zy.common.utils.HttpHandler; |
| | | import com.zy.common.utils.QrCode; |
| | | import com.zy.common.web.BaseController; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | |
| | | private MatService matService; |
| | | @Autowired |
| | | private SnowflakeIdWorker snowflakeIdWorker; |
| | | @Value("${mes.address.url}") |
| | | private String url; |
| | | @Value("${mes.address.cxaddress}") |
| | | private String cxaddress; |
| | | @Autowired |
| | | private ApiLogService apiLogService; |
| | | |
| | | @RequestMapping(value = "/mat/auto/matnr/auth") |
| | | public R autoMatnr(){ |
| | |
| | | public R pdaSearch(@RequestParam(required = false)String condition){ |
| | | EntityWrapper<Mat> wrapper = new EntityWrapper<>(); |
| | | if (!Cools.isEmpty(condition)) { |
| | | wrapper.like("matnr", condition).or().like("maktx", condition); |
| | | // wrapper.like("matnr", condition).or().like("maktx", condition); |
| | | wrapper.like("matnr", condition).or().like("specs", condition); |
| | | } |
| | | wrapper.orderBy("create_time", false); |
| | | List<Mat> mats = matService.selectList(wrapper); |
| | |
| | | return R.ok(matService.selectById(String.valueOf(id))); |
| | | } |
| | | |
| | | @RequestMapping(value = "/matCode/auth0") |
| | | @RequestMapping(value = "/mat/auth") |
| | | @ManagerAuth |
| | | public R find(@RequestParam("matnr") String matnr) { |
| | | return R.ok(matService.selectOne(new EntityWrapper<Mat>().eq("matnr", matnr))); |
| | | Mat mat = matService.selectOne(new EntityWrapper<Mat>().eq("matnr", matnr)); |
| | | if(Cools.isEmpty(mat)){ |
| | | LinkedHashMap<String,Object> map = new LinkedHashMap<>(); |
| | | LinkedHashMap<String,Object> YongHuCanShu=new LinkedHashMap<>(); |
| | | YongHuCanShu.put("QianMingId",""); |
| | | map.put("YongHuCanShu",YongHuCanShu); |
| | | LinkedHashMap<String,Object> QiTaCanShu=new LinkedHashMap<>(); |
| | | QiTaCanShu.put("GnBm","bopp_TM302D12"); |
| | | QiTaCanShu.put("pagesize",50); |
| | | QiTaCanShu.put("pageindex",1); |
| | | QiTaCanShu.put("Operation","1"); |
| | | |
| | | List<LinkedHashMap<String,Object>> XhJiHes=new ArrayList<>(); |
| | | LinkedHashMap<String,Object> XhJiHe=new LinkedHashMap<>(); |
| | | XhJiHe.put("Xh1","1"); |
| | | XhJiHe.put("Xh2",2); |
| | | XhJiHes.add(XhJiHe); |
| | | QiTaCanShu.put("XhJiHe",XhJiHes); |
| | | QiTaCanShu.put("条件一"," and t1.tm_xj like ##"+"%"+matnr+"%"+"##"); |
| | | map.put("QiTaCanShu",QiTaCanShu); |
| | | |
| | | |
| | | HashMap<String,Object>hashMap=new HashMap<String,Object>(); |
| | | hashMap.put("Quanjucanshu","%7B%22XiTongCanShu%22%3A%7B%22xt_id%22%3A%2230077%22%2C%22xt_bm%22%3A%22undefined%22%2C%22xt_yhid%22%3A%22156%22%2C%22xt_yhms%22%3A%22%E7%B3%BB%E7%BB%9F%E7%AE%A1%E7%90%86%E5%91%98%22%2C%22xt_yhbm%22%3A%22admin%22%2C%22xt_qyms%22%3A%221%22%2C%22xt_qyjc%22%3A%221%22%2C%22xt_jsms%22%3A%22%E7%AE%A1%E7%90%86%E5%91%98%22%2C%22xt_yuyan%22%3A%22%22%7D%2C%22NeiBuCanShu%22%3A%7B%7D%7D"); |
| | | |
| | | String jsonString = JSON.toJSONString(map); |
| | | HashMap<String,Object>CanShuJi=new HashMap<String,Object>(); |
| | | CanShuJi.put("CanShuJi",jsonString); |
| | | System.out.println(JSON.toJSONString(CanShuJi)); |
| | | String response = ""; |
| | | boolean success = false; |
| | | try { |
| | | response = new HttpHandler.Builder() |
| | | .setHeaders(hashMap) |
| | | .setUri(url) |
| | | .setPath(cxaddress) |
| | | .setParams(CanShuJi) |
| | | .build() |
| | | .doPost(); |
| | | JSONObject jsonObject = JSON.parseObject(response); |
| | | if (jsonObject.getString("BianHao").equals("0000")) { |
| | | Object jieGuo = jsonObject.get("JieGuo"); |
| | | JSONObject jsonString1 = JSON.parseObject(jieGuo.toString()); |
| | | JSONObject jsonString2 = JSON.parseObject(jsonString1.get("peizhidingyicanshu").toString()); |
| | | JSONArray sqlyujujg = JSON.parseArray(jsonString2.get("sqlyujujg").toString()); |
| | | JSONObject jsonString3 = JSON.parseObject(sqlyujujg.get(0).toString()); |
| | | //添加物料档案 |
| | | Mat mat1=new Mat(); |
| | | mat1.setMatnr(jsonString3.getString("生产批号")); |
| | | mat1.setMaktx(jsonString3.getString("产品名称")); |
| | | mat1.setSpecs(jsonString3.getString("产品规格")); |
| | | mat1.setUnit(jsonString3.getString("单位")); |
| | | mat1.setModel(jsonString3.getString("制单人")); |
| | | mat1.setColor(jsonString3.getString("状态")); |
| | | mat1.setPrice(jsonString3.getDouble("生产数量")); |
| | | mat1.setSku(jsonString3.getString("生产批号")); |
| | | mat1.setOrigin(jsonString3.getString("胶量")); |
| | | mat1.setBarcode(jsonString3.getString("条码")); |
| | | mat1.setManu(jsonString3.getString("质量状态")); |
| | | matService.insert(mat1); |
| | | mat=mat1; |
| | | success=true; |
| | | |
| | | } else { |
| | | throw new CoolException("wms请求mes查询物料信息失败"); |
| | | } |
| | | } catch (Exception e) { |
| | | return R.error(e.getMessage()); |
| | | } finally { |
| | | try { |
| | | // 保存接口日志 |
| | | apiLogService.save( |
| | | "wms请求mes查询物料信息", |
| | | url+"/"+cxaddress, |
| | | null, |
| | | "127.0.0.1", |
| | | JSON.toJSONString(map), |
| | | response, |
| | | success |
| | | ); |
| | | } catch (Exception e) { |
| | | R.error(e.toString()); |
| | | } |
| | | } |
| | | } |
| | | return R.ok(mat); |
| | | } |
| | | |
| | | @RequestMapping(value = "/mat/list/auth") |
| | |
| | | if (Cools.isEmpty(tagId)) { |
| | | tagId = getOriginTag().getId(); |
| | | } |
| | | return R.ok(matService.getPage(new Page<>(curr, limit) |
| | | return R.ok(matService.getPage2(new Page<>(curr, limit) |
| | | , String.valueOf(tagId) |
| | | , param.get("matnr") |
| | | , param.get("maktx")) |
| | | , param.get("maktx") |
| | | , param.get("specs")) |
| | | ); |
| | | |
| | | } |
| | |
| | | return R.ok(); |
| | | } |
| | | |
| | | @RequestMapping(value = "/mat/turn/over/list/auth") |
| | | @ManagerAuth |
| | | public R turnOverList(@RequestParam(defaultValue = "1")Integer curr, |
| | | @RequestParam(defaultValue = "10")Integer limit, |
| | | @RequestParam Map<String, Object> param){ |
| | | return R.ok(matService.getMatTurnPage(toPage(curr, limit, param, Mat.class))); |
| | | } |
| | | |
| | | @RequestMapping("/mat/turn/over/take/site") |
| | | @ManagerAuth() |
| | | public R availableTakeSite(@RequestParam(required = false) String matnr){ |
| | | List<Map<String, Object>> result = new ArrayList<>(); |
| | | List<Mat> mats = matService.selectByMatnrLink(matnr); |
| | | for (Mat mat : mats) { |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("siteId", mat.getId()); |
| | | map.put("desc", mat.getMatnr()); |
| | | result.add(map); |
| | | } |
| | | return R.ok().add(result); |
| | | } |
| | | |
| | | @RequestMapping(value = "/mat/export/auth") |
| | | @ManagerAuth |
| | | public R export(@RequestBody JSONObject param){ |
| | |
| | | return R.ok(); |
| | | } |
| | | OrderDetl orderDetl = new OrderDetl(); |
| | | orderDetl.sync(orderDetl); |
| | | orderDetl.sync(mat); |
| | | orderDetl.setAnfme(0.0D); |
| | | return R.ok().add(orderDetl); |
| | | } |
| | |
| | | for (Mat mat : mats) { |
| | | KeyValueVo vo = new KeyValueVo(); |
| | | vo.setName(mat.getMatnr() + " - " + mat.getMaktx()); |
| | | vo.setValue(mat.getId()); |
| | | vo.setValue(mat.getMatnr()); |
| | | valueVos.add(vo); |
| | | } |
| | | return R.ok().add(valueVos); |