| | |
| | | import com.core.common.DateUtils; |
| | | import com.core.common.R; |
| | | import com.zy.asrs.entity.LocDetl; |
| | | import com.zy.asrs.entity.MatCode; |
| | | import com.zy.asrs.entity.Mat; |
| | | import com.zy.asrs.mapper.LocDetlMapper; |
| | | import com.zy.asrs.service.LocDetlService; |
| | | import com.zy.asrs.service.MatCodeService; |
| | | import com.zy.asrs.utils.VersionUtils; |
| | | import com.zy.asrs.service.MatService; |
| | | import com.zy.common.utils.RoleUtils; |
| | | import com.zy.common.web.BaseController; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | |
| | | |
| | | @Autowired |
| | | private LocDetlService locDetlService; |
| | | |
| | | @Autowired |
| | | private LocDetlMapper locDetlMapper; |
| | | @Autowired |
| | | private MatService matService; |
| | | |
| | | @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 = "/stock/out/crn/list/auth") |
| | | @ManagerAuth |
| | | public R crnStockOutList(@RequestParam(defaultValue = "1") Integer curr, |
| | | @RequestParam(defaultValue = "10") Integer limit, |
| | | @RequestParam Map<String, Object> param){ |
| | | 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"); |
| | | } |
| | | } |
| | | param.remove("curr"); |
| | | param.remove("limit"); |
| | | EntityWrapper<LocDetl> wrapper = new EntityWrapper<>(); |
| | | convert(param, wrapper); |
| | | wrapper.addFilter("LEFT(loc_no,2)>=1 and LEFT(loc_no,2)<=16"); |
| | | // Page<LocDetl> stockOut = locDetlService.getStockOut(toPage(curr, limit, param, LocDetl.class)); |
| | | Page<LocDetl> locDetlPage = locDetlService.selectPage(new Page<>(curr, limit), wrapper); |
| | | if (locDetlPage.getRecords().size()==0){ |
| | | locDetlPage = locDetlService.selectPage(new Page<>(1, limit), wrapper); |
| | | } |
| | | return R.ok(locDetlPage); |
| | | } |
| | | |
| | | @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); |
| | | // 不同继承角色显示不同库信息 |
| | | RoleUtils.addRoleWrapperByLocNo(getUserId(),wrapper); |
| | | 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()){ |
| | |
| | | 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(){ |
| | | Double sum = locDetlService.sum(); |
| | | return R.ok(sum); |
| | | } |
| | | |
| | | /** |
| | | * 获取库存总数 |
| | | * @return |
| | | */ |
| | | @RequestMapping("/locDetl/matnr/count") |
| | | public R getCount(@RequestBody Map<String, String> param){ |
| | | String matnr = param.get("matnr"); |
| | | Double sum = 0.0; |
| | | if (Cools.isEmpty(matnr)){ |
| | | sum = locDetlService.sum(); |
| | | }else { |
| | | sum = locDetlService.getSumAnfme(matnr); |
| | | } |
| | | |
| | | return R.ok(sum); |
| | | } |
| | | |
| | | } |