¶Ô±ÈÐÂÎļþ |
| | |
| | | package org.jeecg.modules.tms.controller; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; |
| | | import com.baomidou.mybatisplus.core.toolkit.StringUtils; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.shiro.SecurityUtils; |
| | | import org.jeecg.common.api.vo.Result; |
| | | import org.jeecg.common.aspect.annotation.AutoLog; |
| | | import org.jeecg.common.system.query.QueryGenerator; |
| | | import org.jeecg.common.system.vo.LoginUser; |
| | | import org.jeecg.modules.system.service.ISysBusinessCodeRuleService; |
| | | import org.jeecg.modules.tms.entity.BaseTools; |
| | | import org.jeecg.modules.tms.entity.ToolsStocktakingBound; |
| | | import org.jeecg.modules.tms.entity.ToolsStocktakingBoundDetail; |
| | | import org.jeecg.modules.tms.entity.dto.LossBoundFlowDto; |
| | | import org.jeecg.modules.tms.entity.dto.StocktakingBoundFlowDto; |
| | | import org.jeecg.modules.tms.entity.vo.ToolsStocktakingVo; |
| | | import org.jeecg.modules.tms.enums.OutBillStatus; |
| | | import org.jeecg.modules.tms.mapper.ToolsStocktakingBoundMapper; |
| | | import org.jeecg.modules.tms.service.IToolsStocktakingBoundDetailService; |
| | | import org.jeecg.modules.tms.service.IToolsStocktakingBoundService; |
| | | import org.jeecgframework.poi.excel.ExcelImportUtil; |
| | | import org.jeecgframework.poi.excel.entity.ImportParams; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | import org.springframework.web.multipart.MultipartHttpServletRequest; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.IOException; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * @Description: çç¹å表 |
| | | * @Author: houjie |
| | | * @Date: 2025-05-16 |
| | | * @Version: V1.0 |
| | | */ |
| | | @Api(tags = "çç¹å表") |
| | | @RestController |
| | | @RequestMapping("/tms/toolsStocktakingBound") |
| | | @Slf4j |
| | | public class ToolsStocktakingBoundController { |
| | | @Autowired |
| | | private IToolsStocktakingBoundService toolsStocktakingBoundService; |
| | | @Autowired |
| | | private IToolsStocktakingBoundDetailService toolsStocktakingBoundDetailService; |
| | | @Autowired |
| | | private ToolsStocktakingBoundMapper toolsStocktakingBoundMapper; |
| | | |
| | | @Autowired |
| | | private ISysBusinessCodeRuleService businessCodeRuleService; |
| | | |
| | | /** |
| | | * å页å表æ¥è¯¢ |
| | | * |
| | | * @param toolsStocktakingBound |
| | | * @param pageNo |
| | | * @param pageSize |
| | | * @param req |
| | | * @return |
| | | */ |
| | | //@AutoLog(value = "çç¹å表-å页å表æ¥è¯¢") |
| | | @ApiOperation(value = "çç¹å表-å页å表æ¥è¯¢", notes = "çç¹å表-å页å表æ¥è¯¢") |
| | | @GetMapping(value = "/list") |
| | | public Result<IPage<ToolsStocktakingBound>> queryPageList(ToolsStocktakingBound toolsStocktakingBound, |
| | | @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, |
| | | @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, |
| | | HttpServletRequest req) { |
| | | QueryWrapper<ToolsStocktakingBound> queryWrapper = QueryGenerator.initQueryWrapper(toolsStocktakingBound, req.getParameterMap()); |
| | | Page<ToolsStocktakingBound> page = new Page<ToolsStocktakingBound>(pageNo, pageSize); |
| | | IPage<ToolsStocktakingBound> pageList = toolsStocktakingBoundService.page(page, queryWrapper); |
| | | return Result.OK(pageList); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * æ·»å |
| | | * |
| | | * @param toolsStocktakingBound |
| | | * @return |
| | | */ |
| | | @AutoLog(value = "tms_stocktaking_bound-æ·»å ") |
| | | @ApiOperation(value = "tms_stocktaking_bound-æ·»å ", notes = "tms_stocktaking_bound-æ·»å ") |
| | | @PostMapping(value = "/add") |
| | | @Transactional(rollbackFor = {Exception.class}) |
| | | public Result<String> add(@RequestBody ToolsStocktakingBound toolsStocktakingBound) { |
| | | toolsStocktakingBound.setApprovalStatus(OutBillStatus.DRAFT.getValue()); |
| | | LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); |
| | | if (sysUser != null) { |
| | | toolsStocktakingBound.setHandler(sysUser.getId()); |
| | | } |
| | | toolsStocktakingBound.setOrderCode(businessCodeRuleService.generateBusinessCodeSeq("stocktakingBound")); |
| | | //æ ¡éªç©æå¨åææå¨è½¬åºåä¸åå¨ |
| | | List<ToolsStocktakingBoundDetail> toolsStocktakingBoundDetailList = toolsStocktakingBound.getToolsStocktakingBoundDetailList(); |
| | | |
| | | toolsStocktakingBoundService.save(toolsStocktakingBound); |
| | | for (int i = 0; i < toolsStocktakingBoundDetailList.size(); i++) { |
| | | ToolsStocktakingBoundDetail toolsStocktakingBoundDetail = toolsStocktakingBoundDetailList.get(i); |
| | | toolsStocktakingBoundDetail.setAvailableQuantity(toolsStocktakingBoundDetail.getBookQuantity()); |
| | | toolsStocktakingBoundDetail.setPracticalQuantity(toolsStocktakingBoundDetail.getPracticalQuantity()); |
| | | toolsStocktakingBoundDetail.setSurplusDeficit(toolsStocktakingBoundDetail.getSurplusDeficit()); |
| | | toolsStocktakingBoundDetail.setStocktakingDate(toolsStocktakingBoundDetail.getStocktakingDate()); |
| | | toolsStocktakingBoundDetail.setRemark(toolsStocktakingBoundDetail.getRemark()); |
| | | toolsStocktakingBoundDetail.setToolId(toolsStocktakingBoundDetail.getToolId()); |
| | | toolsStocktakingBoundDetail.setToolCode(toolsStocktakingBoundDetail.getToolCode()); |
| | | toolsStocktakingBoundDetail.setStocktakingBoundId(toolsStocktakingBound.getId()); |
| | | toolsStocktakingBoundDetailService.save(toolsStocktakingBoundDetail); |
| | | } |
| | | return Result.OK(); |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | | @ApiOperation(value = "å·¥å
·çç¹æç»-éè¿ä¸»è¡¨IDæ¥è¯¢", notes = "å·¥å
·çç¹æç»-éè¿ä¸»è¡¨IDæ¥è¯¢") |
| | | @GetMapping(value = "/listToolsStocktakingBoundControllerDetailsByMainId") |
| | | public Result<IPage<ToolsStocktakingBoundDetail>> listToolsStocktakingBoundControllerDetailsByMainId(BaseTools baseTools, |
| | | @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, |
| | | @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, |
| | | HttpServletRequest req) { |
| | | Map<String, String[]> parameterMap = req.getParameterMap(); |
| | | Page<ToolsStocktakingBoundDetail> page = new Page<ToolsStocktakingBoundDetail>(pageNo, pageSize); |
| | | IPage<ToolsStocktakingBoundDetail> pageList = toolsStocktakingBoundDetailService.selectByMainId(page, parameterMap); |
| | | |
| | | return Result.OK(pageList); |
| | | } |
| | | |
| | | |
| | | @AutoLog(value = "tms_stocktaking_bound-æäº¤çç¹å") |
| | | @ApiOperation(value = "tms_stocktaking_bound-æäº¤çç¹å", notes = "tms_stocktaking_bound-æäº¤çç¹å") |
| | | @GetMapping(value = "/submit") |
| | | public Result<String> submit(@RequestParam(name = "id") String id) { |
| | | |
| | | |
| | | toolsStocktakingBoundService.submintOrder(id); |
| | | return Result.OK("æäº¤æå"); |
| | | } |
| | | |
| | | /** |
| | | * å®¡æ¹æµç¨ |
| | | * @param stocktakingBoundFlowDto |
| | | * @return |
| | | */ |
| | | @AutoLog(value = "å®¡æ¹æµç¨") |
| | | @ApiOperation(value = "æ¥æå-å®¡æ¹æµç¨", notes = "æ¥æå-å®¡æ¹æµç¨") |
| | | @PostMapping("/approval") |
| | | public Result<?> approval(@RequestBody StocktakingBoundFlowDto stocktakingBoundFlowDto) { |
| | | toolsStocktakingBoundService.approvalProcess(stocktakingBoundFlowDto); |
| | | return Result.OK("æä½æå"); |
| | | } |
| | | /** |
| | | * ç¼è¾ |
| | | * |
| | | * @param toolsStocktakingBound |
| | | * @return |
| | | */ |
| | | @AutoLog(value = "çç¹å表-ç¼è¾") |
| | | @ApiOperation(value = "çç¹å表-ç¼è¾", notes = "çç¹å表-ç¼è¾") |
| | | @RequestMapping(value = "/edit", method = {RequestMethod.PUT, RequestMethod.POST}) |
| | | @Transactional(rollbackFor = {Exception.class}) |
| | | public Result<String> edit(@RequestBody ToolsStocktakingBound toolsStocktakingBound) { |
| | | if (toolsStocktakingBound == null || StringUtils.isBlank(toolsStocktakingBound.getId())) { |
| | | return Result.error("åæ°é误"); |
| | | } |
| | | |
| | | toolsStocktakingBoundDetailService.remove(new LambdaQueryWrapper<ToolsStocktakingBoundDetail>() |
| | | .eq(ToolsStocktakingBoundDetail::getStocktakingBoundId, toolsStocktakingBound.getId())); |
| | | |
| | | ToolsStocktakingBound stocktakingBound = new ToolsStocktakingBound(); |
| | | BeanUtils.copyProperties(stocktakingBound, toolsStocktakingBound); |
| | | toolsStocktakingBoundMapper.updateById(stocktakingBound); |
| | | |
| | | |
| | | List<ToolsStocktakingBoundDetail> detailList = toolsStocktakingBound.getToolsStocktakingBoundDetailList(); |
| | | if (CollectionUtils.isEmpty(detailList)) { |
| | | return Result.error("æç»ä¸è½ä¸ºç©º"); |
| | | } |
| | | |
| | | detailList.forEach(item -> item.setStocktakingBoundId(stocktakingBound.getId())); |
| | | toolsStocktakingBoundDetailService.saveBatch(detailList); |
| | | |
| | | return Result.OK("ç¼è¾æå"); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * éè¿idå é¤ |
| | | * |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @AutoLog(value = "çç¹å表-éè¿idå é¤") |
| | | @ApiOperation(value = "çç¹å表-éè¿idå é¤", notes = "çç¹å表-éè¿idå é¤") |
| | | @DeleteMapping(value = "/delete") |
| | | public Result<String> delete(@RequestParam(name = "id", required = true) String id) { |
| | | toolsStocktakingBoundService.delMain(id); |
| | | return Result.OK("å 餿å!"); |
| | | } |
| | | |
| | | /** |
| | | * æ¹éå é¤ |
| | | * |
| | | * @param ids |
| | | * @return |
| | | */ |
| | | @AutoLog(value = "çç¹å表-æ¹éå é¤") |
| | | @ApiOperation(value = "çç¹å表-æ¹éå é¤", notes = "çç¹å表-æ¹éå é¤") |
| | | |
| | | @DeleteMapping(value = "/deleteBatch") |
| | | public Result<String> deleteBatch(@RequestParam(name = "ids", required = true) String ids) { |
| | | this.toolsStocktakingBoundService.delBatchMain(Arrays.asList(ids.split(","))); |
| | | return Result.OK("æ¹éå 餿åï¼"); |
| | | } |
| | | |
| | | /** |
| | | * éè¿idæ¥è¯¢ |
| | | * |
| | | * @param id |
| | | * @return |
| | | */ |
| | | //@AutoLog(value = "çç¹å表-éè¿idæ¥è¯¢") |
| | | @ApiOperation(value = "çç¹å表-éè¿idæ¥è¯¢", notes = "çç¹å表-éè¿idæ¥è¯¢") |
| | | @GetMapping(value = "/queryById") |
| | | public Result<ToolsStocktakingBound> queryById(@RequestParam(name = "id", required = true) String id) { |
| | | ToolsStocktakingBound toolsStocktakingBound = toolsStocktakingBoundService.getById(id); |
| | | if (toolsStocktakingBound == null) { |
| | | return Result.error("æªæ¾å°å¯¹åºæ°æ®"); |
| | | } |
| | | return Result.OK(toolsStocktakingBound); |
| | | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * éè¿excel导å
¥æ°æ® |
| | | * |
| | | * @param request |
| | | * @param response |
| | | * @return |
| | | */ |
| | | @RequestMapping(value = "/importExcel", method = RequestMethod.POST) |
| | | public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) { |
| | | MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request; |
| | | Map<String, MultipartFile> fileMap = multipartRequest.getFileMap(); |
| | | for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) { |
| | | // è·åä¸ä¼ æä»¶å¯¹è±¡ |
| | | MultipartFile file = entity.getValue(); |
| | | ImportParams params = new ImportParams(); |
| | | params.setTitleRows(2); |
| | | params.setHeadRows(1); |
| | | params.setNeedSave(true); |
| | | try { |
| | | List<ToolsStocktakingVo> list = ExcelImportUtil.importExcel(file.getInputStream(), ToolsStocktakingVo.class, params); |
| | | for (ToolsStocktakingVo page : list) { |
| | | ToolsStocktakingBound po = new ToolsStocktakingBound(); |
| | | BeanUtils.copyProperties(page, po); |
| | | toolsStocktakingBoundService.saveMain(po, page.getToolsStocktakingBoundDetailList()); |
| | | } |
| | | return Result.OK("æä»¶å¯¼å
¥æåï¼æ°æ®è¡æ°:" + list.size()); |
| | | } catch (Exception e) { |
| | | log.error(e.getMessage(), e); |
| | | return Result.error("æä»¶å¯¼å
¥å¤±è´¥:" + e.getMessage()); |
| | | } finally { |
| | | try { |
| | | file.getInputStream().close(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | | return Result.OK("æä»¶å¯¼å
¥å¤±è´¥ï¼"); |
| | | } |
| | | |
| | | } |