| | |
| | | |
| | | 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.baomidou.mybatisplus.mapper.Wrapper; |
| | | import com.baomidou.mybatisplus.plugins.Page; |
| | | 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.zy.asrs.entity.LocDetl; |
| | | import com.zy.asrs.entity.MatCode; |
| | | import com.core.common.*; |
| | | import com.zy.asrs.entity.*; |
| | | import com.zy.asrs.entity.param.OrderInspectionRollParam; |
| | | import com.zy.asrs.entity.param.OrderMesXGHYParam; |
| | | import com.zy.asrs.entity.param.QualityGroupListParam; |
| | | import com.zy.asrs.entity.result.OrderPakoutDetailVo; |
| | | import com.zy.asrs.mapper.LocDetlMapper; |
| | | import com.zy.asrs.service.ApiLogService; |
| | | import com.zy.asrs.service.LocDetlService; |
| | | import com.zy.asrs.service.MatCodeService; |
| | | import com.zy.asrs.utils.VersionUtils; |
| | | import com.zy.asrs.service.ManLocDetlService; |
| | | import com.zy.asrs.service.MatService; |
| | | import com.zy.common.utils.HttpHandler; |
| | | import com.zy.common.web.BaseController; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | |
| | | |
| | | @Autowired |
| | | private LocDetlService locDetlService; |
| | | |
| | | @Autowired |
| | | private LocDetlMapper locDetlMapper; |
| | | @Autowired |
| | | private MatService matService; |
| | | @Autowired |
| | | private ApiLogService apiLogService; |
| | | @Autowired |
| | | private SnowflakeIdWorker snowflakeIdWorker; |
| | | |
| | | @Value("${srXghyMes.qualityFinishedCheckoutUrl}") |
| | | private String qualityFinishedCheckoutUrl; |
| | | @Value("${srXghyMes.qualityFinishedCheckout}") |
| | | private String qualityFinishedCheckout; |
| | | |
| | | @Value("${srXghyMes.productInventoryUrl}") |
| | | private String productInventoryUrl; |
| | | @Value("${srXghyMes.productInventory}") |
| | | private String productInventory; |
| | | |
| | | @RequestMapping(value = "/locDetl/update") |
| | | public R update1() { |
| | |
| | | param.remove("modi_time"); |
| | | } |
| | | } |
| | | return R.ok(locDetlService.getStockOut(toPage(curr, limit, param, LocDetl.class))); |
| | | Page<LocDetl> stockOut = locDetlService.getStockOut(toPage(curr, limit, param, LocDetl.class)); |
| | | if (stockOut.getRecords().size()==0){ |
| | | stockOut = locDetlService.getStockOut(toPage(1, limit, param, LocDetl.class)); |
| | | } |
| | | return R.ok(stockOut); |
| | | } |
| | | |
| | | @RequestMapping(value = "/locDetl/list/auth") |
| | | @RequestMapping(value = "/unqualified/stock/out/list/auth") |
| | | @ManagerAuth |
| | | public R stockOutListUnqualified(@RequestParam(defaultValue = "1")Integer curr, |
| | | @RequestParam(defaultValue = "10")Integer limit, |
| | | @RequestParam Map<String, Object> param){ |
| | | param.put("danger",2); |
| | | if (!Cools.isEmpty(param.get("modi_time"))){ |
| | | String val = String.valueOf(param.get("modi_time")); |
| | | if (val.contains(RANGE_TIME_LINK)) { |
| | | String[] dates = val.split(RANGE_TIME_LINK); |
| | | param.put("startTime", DateUtils.convert(dates[0])); |
| | | param.put("endTime", DateUtils.convert(dates[1])); |
| | | param.remove("modi_time"); |
| | | } |
| | | } |
| | | Page<LocDetl> stockOut = locDetlService.getStockOut(toPage(curr, limit, param, LocDetl.class)); |
| | | if (stockOut.getRecords().size()==0){ |
| | | stockOut = locDetlService.getStockOut(toPage(1, limit, param, LocDetl.class)); |
| | | } |
| | | return R.ok(stockOut); |
| | | } |
| | | |
| | | @RequestMapping(value = "/locDetl/list/auth")// /locDetl/list/auth 接口问题 |
| | | @ManagerAuth |
| | | public R list(@RequestParam(defaultValue = "1")Integer curr, |
| | | @RequestParam(defaultValue = "10")Integer limit, |
| | |
| | | @RequestParam(required = false)String orderByType, |
| | | @RequestParam(required = false)String condition, |
| | | @RequestParam Map<String, Object> param){ |
| | | excludeTrash(param); |
| | | // String row = ""; |
| | | EntityWrapper<LocDetl> wrapper = new EntityWrapper<>(); |
| | | // if (param.get("row") != null) { |
| | | // String chooseRow = (String) param.get("row"); |
| | | // if (chooseRow.length() == 1) { |
| | | // row = "0" + chooseRow; |
| | | // param.remove("row"); |
| | | // }else { |
| | | // row = chooseRow; |
| | | // param.remove("row"); |
| | | // } |
| | | // } |
| | | excludeTrash(param); |
| | | convert(param, wrapper); |
| | | allLike(LocDetl.class, param.keySet(), wrapper, condition); |
| | | if (!Cools.isEmpty(orderByField)){wrapper.orderBy(humpToLine(orderByField), "asc".equals(orderByType));} |
| | | // if (!row.equals("")){ |
| | | // wrapper.and() |
| | | // .where("loc_no like '" +row +"%'"); |
| | | // } |
| | | return R.ok(locDetlService.selectPage(new Page<>(curr, limit), wrapper)); |
| | | } |
| | | |
| | | |
| | | private <T> void convert(Map<String, Object> map, EntityWrapper<T> wrapper){ |
| | | for (Map.Entry<String, Object> entry : map.entrySet()){ |
| | |
| | | @RequestMapping(value = "/locDetl/update/auth") |
| | | @ManagerAuth(memo = "库位明细修改") |
| | | public R update(LocDetl locDetl){ |
| | | if (Cools.isEmpty(locDetl) || null==locDetl.getMatnr()){ |
| | | if (Cools.isEmpty(locDetl) || null==locDetl.getBatch()){ |
| | | return R.error(); |
| | | } |
| | | locDetl.setModiUser(getUserId()); |
| | | locDetl.setModiTime(new Date()); |
| | | locDetlService.updateById(locDetl); |
| | | LocDetl locDetl1 = locDetlService.selectOne(new EntityWrapper<LocDetl>().eq("loc_no", locDetl.getLocNo()).eq("batch", locDetl.getBatch())); |
| | | if (Cools.isEmpty(locDetl1) ){ |
| | | return R.error(); |
| | | } |
| | | locDetl1.setModiUser(getUserId()); |
| | | locDetl1.setModiTime(new Date()); |
| | | locDetl1.setDanger(locDetl.getDanger()); |
| | | locDetlService.update(locDetl1,new EntityWrapper<LocDetl>().eq("loc_no", locDetl.getLocNo()).eq("batch", locDetl.getBatch())); |
| | | // locDetlService.updateById(locDetl1); |
| | | return R.ok(); |
| | | } |
| | | |
| | |
| | | List<String> fields = JSONObject.parseArray(param.getJSONArray("fields").toJSONString(), String.class); |
| | | EntityWrapper<LocDetl> wrapper = new EntityWrapper<>(); |
| | | Map<String, Object> map = excludeTrash(param.getJSONObject("locDetl")); |
| | | String row = ""; |
| | | if (map.get("row") != null) { |
| | | String chooseRow = (String) map.get("row"); |
| | | if (chooseRow.length() == 1) { |
| | | row = "0" + chooseRow; |
| | | map.remove("row"); |
| | | }else { |
| | | row = chooseRow; |
| | | map.remove("row"); |
| | | } |
| | | } |
| | | convert(map, wrapper); |
| | | if (!row.equals("")){ |
| | | wrapper.and() |
| | | .where("loc_no like '" +row +"%'"); |
| | | } |
| | | List<LocDetl> list = locDetlService.selectList(wrapper); |
| | | return R.ok(exportSupport(list, fields)); |
| | | } |
| | |
| | | return R.ok(); |
| | | } |
| | | |
| | | |
| | | @Autowired |
| | | private MatCodeService matCodeService; |
| | | |
| | | @RequestMapping(value = "/locDetl/statis/auth") |
| | | @ManagerAuth |
| | | public R statis(@RequestParam(defaultValue = "1")Integer curr, |
| | |
| | | @RequestParam Map<String, Object> param) { |
| | | Page<LocDetl> stockStatis = locDetlService.getStockStatis(toPage(curr, limit, param, LocDetl.class)); |
| | | for (LocDetl locDetl : stockStatis.getRecords()) { |
| | | MatCode matCode = matCodeService.selectById(locDetl.getMatnr()); |
| | | if (matCode != null) { |
| | | VersionUtils.setLocDetl(locDetl, matCode); |
| | | Mat mat = matService.selectByMatnr(locDetl.getMatnr()); |
| | | if (mat != null) { |
| | | locDetl.sync(mat); |
| | | } |
| | | } |
| | | return R.ok().add(stockStatis); |
| | |
| | | public void statisExport(HttpServletResponse response) throws IOException { |
| | | List<LocDetl> excel = LocDetlMapper.getStockStatisExcel(); |
| | | for (LocDetl locDetl : excel) { |
| | | MatCode matCode = matCodeService.selectById(locDetl.getMatnr()); |
| | | if (matCode != null) { |
| | | VersionUtils.setLocDetl(locDetl, matCode); |
| | | Mat mat = matService.selectByMatnr(locDetl.getMatnr()); |
| | | if (mat != null) { |
| | | locDetl.sync(mat); |
| | | } |
| | | } |
| | | response.setContentType("application/vnd.ms-excel"); |
| | |
| | | .doWrite(excel); |
| | | } |
| | | |
| | | /** |
| | | * 获取库存总数 |
| | | * @return |
| | | */ |
| | | @RequestMapping("/locDetl/count") |
| | | public R getAllCount(){ |
| | | Integer sum = locDetlService.sum(); |
| | | return R.ok(sum); |
| | | } |
| | | |
| | | @RequestMapping(value = "/actual/shipment/locDetl/report/auth") |
| | | @ManagerAuth(memo = "卷号是否合格手动校验") |
| | | public R actualShipmentLocDetl(@RequestParam String model) { |
| | | Long userId = null; |
| | | try { |
| | | userId = getUserId(); |
| | | if (Cools.isEmpty(userId)) { |
| | | return R.error("用户异常").add("用户异常"); |
| | | } |
| | | } catch (Exception e){ |
| | | return R.error("用户异常").add("用户异常"); |
| | | } |
| | | List<LocDetl> locDetlList = locDetlService.selectList(new EntityWrapper<LocDetl>().eq("model", model)); |
| | | // OrderInspectionRollParam orderInspectionRollParam = new OrderInspectionRollParam(model); |
| | | String response = ""; |
| | | boolean success = false; |
| | | Map<String, Object> params = new HashMap<>(); |
| | | params.put("batchNo", model); |
| | | try { |
| | | response = new HttpHandler.Builder() |
| | | .setUri(qualityFinishedCheckoutUrl) |
| | | .setPath(qualityFinishedCheckout) |
| | | .setParams(params) |
| | | .setUseFormUrlEncoded(true) |
| | | .build() |
| | | .doPost(); |
| | | JSONObject jsonObject = JSON.parseObject(response); |
| | | if (jsonObject.getBoolean("state")) { |
| | | String value = jsonObject.getString("value"); |
| | | if (value.equals("合格")){ |
| | | for (LocDetl locDetl : locDetlList) { |
| | | locDetl.setDanger(1); |
| | | locDetlService.updateById(locDetl); |
| | | } |
| | | } else if (value.equals("不合格")){ |
| | | for (LocDetl locDetl : locDetlList) { |
| | | locDetl.setDanger(2); |
| | | locDetlService.updateById(locDetl); |
| | | } |
| | | } else { |
| | | for (LocDetl locDetl : locDetlList) { |
| | | locDetl.setDanger(0); |
| | | locDetlService.updateById(locDetl); |
| | | } |
| | | } |
| | | success = true; |
| | | } else { |
| | | return R.error("查询卷号是否合格失败"); |
| | | } |
| | | } catch (Exception e) { |
| | | return R.error("查询卷号是否合格失败"+e.getMessage()); |
| | | } finally { |
| | | try { |
| | | // 保存接口日志 |
| | | apiLogService.save( |
| | | "查询卷号是否合格", |
| | | qualityFinishedCheckoutUrl+"/"+qualityFinishedCheckout, |
| | | null, |
| | | "127.0.0.1", |
| | | JSON.toJSONString(params), |
| | | response, |
| | | success |
| | | ); |
| | | } catch (Exception e) { } |
| | | } |
| | | return R.error("上报失败").add("上报失败"); |
| | | } |
| | | |
| | | @RequestMapping(value = "/synchronize/mes/locDetl/report/auth") |
| | | @ManagerAuth(memo = "同步库存至MES") |
| | | public R synchronizeLocDetlMes() { |
| | | List<LocDetl> locDetlList = locDetlService.selectList(new EntityWrapper<LocDetl>()); |
| | | if (locDetlList.isEmpty()) { |
| | | return R.error("库存为空!!!"); |
| | | } |
| | | |
| | | OrderMesXGHYParam orderMesXGHYParam = new OrderMesXGHYParam(locDetlList,"in","成品入库"); |
| | | orderMesXGHYParam.setBarcode(String.valueOf(snowflakeIdWorker.nextId())); |
| | | orderMesXGHYParam.setPalletizingNo(1); |
| | | |
| | | |
| | | String response = ""; |
| | | boolean success = false; |
| | | try { |
| | | response = new HttpHandler.Builder() |
| | | .setUri(productInventoryUrl) |
| | | .setPath(productInventory) |
| | | .setJson(JSON.toJSONString(orderMesXGHYParam)) |
| | | .build() |
| | | .doPost(); |
| | | JSONObject jsonObject = JSON.parseObject(response); |
| | | if (jsonObject.getBoolean("state")) { |
| | | success = true; |
| | | } else { |
| | | return R.error("同步库存至MES"); |
| | | } |
| | | } catch (Exception e) { |
| | | return R.error("同步库存至MES"+e.getMessage()); |
| | | } finally { |
| | | try { |
| | | // 保存接口日志 |
| | | apiLogService.save( |
| | | "同步库存至MES", |
| | | productInventoryUrl+"/"+productInventory, |
| | | null, |
| | | "127.0.0.1", |
| | | JSON.toJSONString(orderMesXGHYParam), |
| | | response, |
| | | success |
| | | ); |
| | | } catch (Exception e) { } |
| | | } |
| | | return R.error("上报失败").add("上报失败"); |
| | | } |
| | | |
| | | } |