| | |
| | | package com.zy.asrs.controller; |
| | | |
| | | |
| | | import com.alibaba.excel.EasyExcel; |
| | | import com.alibaba.excel.write.style.column.LongestMatchColumnWidthStyleStrategy; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.baomidou.mybatisplus.mapper.Wrapper; |
| | |
| | | import com.zy.asrs.entity.param.MatnrDto; |
| | | import com.zy.asrs.entity.param.OrderCheckParam; |
| | | import com.zy.asrs.entity.param.OrderDomainParam; |
| | | import com.zy.asrs.entity.result.KeyValueVo; |
| | | import com.zy.asrs.service.*; |
| | | import com.zy.common.CodeRes; |
| | | import com.zy.common.config.AdminInterceptor; |
| | |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.imageio.ImageIO; |
| | | import javax.servlet.ServletOutputStream; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.awt.image.BufferedImage; |
| | | import java.io.IOException; |
| | | import java.net.URLEncoder; |
| | | import java.util.*; |
| | | |
| | | @RestController |
| | |
| | | |
| | | @Autowired |
| | | private ManLocDetlService manLocDetlService; |
| | | |
| | | @Autowired |
| | | private LocCheckTrimService locCheckTrimService; |
| | | |
| | | @RequestMapping(value = "/orderCheck/nav/list/auth") |
| | | @ManagerAuth |
| | |
| | | locCheck.setAnfme(manLocDetl.getAnfme()); |
| | | locCheck.setRealAnfme(0.0); |
| | | locCheck.setDiffAnfme(0.0); |
| | | locCheck.setExamine(0); |
| | | locCheck.setOwner(manLocDetl.getOwner()); |
| | | locCheck.setPayment(manLocDetl.getPayment()); |
| | | locCheck.setCreateTime(now); |
| | | locCheck.setUpdateTime(now); |
| | | locCheck.setOrderNo(param.getOrderNo()); |
| | |
| | | return R.ok(); |
| | | } |
| | | |
| | | @RequestMapping("/orderCheck/create/loc/auth") |
| | | @ManagerAuth |
| | | public R autolocCreate(@RequestBody CheckDTO checkDTO){ |
| | | Double prec = Double.valueOf(checkDTO.getPrec()); |
| | | List<CheckDTO.data> data = checkDTO.getData(); |
| | | EntityWrapper<ManLocDetl> manLocDetlEntityWrapper = new EntityWrapper<>(); |
| | | int count = manLocDetlService.selectCount(manLocDetlEntityWrapper); |
| | | List<ManLocDetl> countLocDetl = new ArrayList<>(); |
| | | double precDpuble = prec / 100; |
| | | count = (int)(count * precDpuble); |
| | | if (checkDTO.getData() == null){ |
| | | countLocDetl = locCheckService.getCountLocDetl(count); |
| | | }else { |
| | | for (CheckDTO.data a :data){ |
| | | String locno = a.getValue(); |
| | | EntityWrapper<ManLocDetl> manLocDetlEntityWrapper2 = new EntityWrapper<>(); |
| | | manLocDetlEntityWrapper2.eq("loc_no",locno); |
| | | int countfor = manLocDetlService.selectCount(manLocDetlEntityWrapper2); |
| | | countfor = (countfor * precDpuble)>1? Math.round((float)(countfor * precDpuble)) : 1 ; |
| | | for (ManLocDetl manLocDetl: locCheckService.getLocCountLocDetl(countfor,a.getValue())){ |
| | | countLocDetl.add(manLocDetl); |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | | return R.ok().add(countLocDetl); |
| | | } |
| | | |
| | | @RequestMapping("/orderCheck/create/owner/auth") |
| | | @ManagerAuth |
| | | public R autoOwnerlocCreate(@RequestBody CheckDTO checkDTO){ |
| | | Double prec = Double.valueOf(checkDTO.getPrec()); |
| | | List<CheckDTO.data> data = checkDTO.getData(); |
| | | EntityWrapper<ManLocDetl> manLocDetlEntityWrapper = new EntityWrapper<>(); |
| | | int count = manLocDetlService.selectCount(manLocDetlEntityWrapper); |
| | | List<ManLocDetl> countLocDetl = new ArrayList<>(); |
| | | double precDpuble = prec / 100; |
| | | count = (int)(count * precDpuble); |
| | | if (checkDTO.getData() == null){ |
| | | countLocDetl = locCheckService.getCountLocDetl(count); |
| | | }else { |
| | | for (CheckDTO.data a :data){ |
| | | String owner = a.getValue(); |
| | | EntityWrapper<ManLocDetl> manLocDetlEntityWrapper2 = new EntityWrapper<>(); |
| | | manLocDetlEntityWrapper2.eq("owner",owner); |
| | | int countfor = manLocDetlService.selectCount(manLocDetlEntityWrapper2); |
| | | countfor = (countfor * precDpuble)>1? Math.round((float)(countfor * precDpuble)) : 1 ; |
| | | for (ManLocDetl manLocDetl: locCheckService.getOwnerCountLocDetl(countfor,a.getValue())){ |
| | | countLocDetl.add(manLocDetl); |
| | | } |
| | | } |
| | | } |
| | | |
| | | return R.ok().add(countLocDetl); |
| | | } |
| | | |
| | | @RequestMapping(value = "/orderCheck/mxamine") |
| | | public R mxamine(@RequestBody LocCheck locCheck){ //审核 |
| | | locCheck.setDiffAnfme(locCheck.getRealAnfme() - locCheck.getAnfme()); |
| | | locCheck.setExamine(1); |
| | | locCheck.setType(2); |
| | | if (!locCheckService.updateById(locCheck)){ |
| | | return R.error("状态更新失败"); |
| | | } |
| | | EntityWrapper<ManLocDetl> manLocDetlEntityWrapper = new EntityWrapper<>(); |
| | | manLocDetlEntityWrapper.eq("loc_no",locCheck.getLocNo()); |
| | | manLocDetlEntityWrapper.eq("matnr",locCheck.getMatnr()); |
| | | ManLocDetl manLocDetl = new ManLocDetl(); |
| | | manLocDetl.setAnfme(locCheck.getRealAnfme()); |
| | | if (!manLocDetlService.update(manLocDetl,manLocDetlEntityWrapper)){ |
| | | return R.error("更新平库库存失败"); |
| | | } |
| | | |
| | | Date now = new Date(); |
| | | Long userId = getUserId(); |
| | | LocCheckTrim locCheckTrim = new LocCheckTrim(); |
| | | locCheckTrim.setLocNo(locCheck.getLocNo()); |
| | | locCheckTrim.setMaktx(locCheck.getMaktx()); |
| | | locCheckTrim.setType(locCheck.getType()); |
| | | locCheckTrim.setExamine(locCheck.getExamine()); |
| | | locCheckTrim.setMatnr(locCheck.getMatnr()); |
| | | locCheckTrim.setAnfme(locCheck.getAnfme()); |
| | | locCheckTrim.setRealAnfme(locCheck.getRealAnfme()); |
| | | locCheckTrim.setDiffAnfme(locCheck.getDiffAnfme()); |
| | | locCheckTrim.setCreateTime(now); |
| | | locCheckTrim.setCreateBy(userId); |
| | | locCheckTrim.setOrderNo(locCheck.getOrderNo()); |
| | | if (!locCheckTrimService.insert(locCheckTrim)){ |
| | | return R.error("历史档插入失败"); |
| | | } |
| | | |
| | | |
| | | |
| | | return R.ok("审核完成!"); |
| | | } |
| | | @RequestMapping(value = "/orderCheck/all/get/loc") |
| | | public R mxamine(){ |
| | | List<String> list = locCheckService.getLocCount(); |
| | | List<KeyValueVo> keyValueVoList = new ArrayList<>(); |
| | | for (int i=0;i<list.size();i++){ |
| | | KeyValueVo vo = new KeyValueVo(); |
| | | vo.setName(list.get(i)); |
| | | vo.setValue(list.get(i)); |
| | | keyValueVoList.add(vo); |
| | | } |
| | | return R.ok(keyValueVoList); |
| | | |
| | | } |
| | | |
| | | @RequestMapping(value = "/orderCheck/all/get/owner") |
| | | public R mxamineOwner(){ |
| | | List<LocOwner> list = locCheckService.getOwnerCount(); |
| | | List<KeyValueVo> keyValueVoList = new ArrayList<>(); |
| | | for (LocOwner basLocOwner: list){ |
| | | KeyValueVo vo = new KeyValueVo(); |
| | | vo.setName(basLocOwner.getOwner()); |
| | | vo.setValue(basLocOwner.getId()); |
| | | keyValueVoList.add(vo); |
| | | } |
| | | return R.ok(keyValueVoList); |
| | | |
| | | } |
| | | |
| | | @RequestMapping(value = "/orderCheck/printExport/auth") |
| | | // @ManagerAuth(memo = "盘点单导出") |
| | | public void export(HttpServletResponse response,@RequestParam String orderNo) throws IOException { |
| | | //从数据库查询数据 |
| | | EntityWrapper<LocCheck> locCheckEntityWrapper = new EntityWrapper<>(); |
| | | locCheckEntityWrapper.eq("order_no",orderNo); |
| | | List<LocCheck> list = locCheckService.selectList(locCheckEntityWrapper); |
| | | for (LocCheck locCheck:list){ |
| | | locCheck.setRealAnfme(null); |
| | | } |
| | | |
| | | response.setContentType("application/vnd.ms-excel"); |
| | | response.setCharacterEncoding("utf-8"); |
| | | String fileName = URLEncoder.encode("盘点单", "UTF-8"); |
| | | response.setHeader("Content-disposition", "attachment;filename=" + fileName+ orderNo + ".xlsx"); |
| | | Set<String> includeColumnFiledNames = new HashSet<String>(); |
| | | includeColumnFiledNames.add("orderNo"); |
| | | includeColumnFiledNames.add("matnr"); |
| | | includeColumnFiledNames.add("maktx"); |
| | | includeColumnFiledNames.add("locNo"); |
| | | includeColumnFiledNames.add("anfme"); |
| | | includeColumnFiledNames.add("owner"); |
| | | includeColumnFiledNames.add("payment"); |
| | | includeColumnFiledNames.add("createTime"); |
| | | includeColumnFiledNames.add("realAnfme"); |
| | | EasyExcel.write(response.getOutputStream(), LocCheck.class) |
| | | .registerWriteHandler(new LongestMatchColumnWidthStyleStrategy()) |
| | | .includeColumnFiledNames(includeColumnFiledNames) |
| | | .sheet("表1") |
| | | .doWrite(list); |
| | | } |
| | | |
| | | |
| | | } |