¶Ô±ÈÐÂÎļþ |
| | |
| | | package org.jeecg.modules.eam.controller; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.Arrays; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.apache.shiro.SecurityUtils; |
| | | import org.jeecg.common.api.vo.Result; |
| | | import org.jeecg.common.aspect.annotation.AutoLog; |
| | | import org.jeecg.common.exception.JeecgBootException; |
| | | import org.jeecg.common.system.query.QueryGenerator; |
| | | import org.jeecg.common.system.vo.LoginUser; |
| | | import org.jeecg.modules.eam.constant.BusinessCodeConst; |
| | | import org.jeecg.modules.eam.entity.EamSparePartInventory; |
| | | import org.jeecg.modules.eam.entity.EamSparePartReceive; |
| | | import org.jeecg.modules.eam.entity.EamSparePartReceiveDetail; |
| | | import org.jeecg.modules.eam.entity.EamSparePartRequisition; |
| | | import org.jeecg.modules.eam.service.IEamSparePartInventoryService; |
| | | import org.jeecg.modules.eam.service.IEamSparePartReceiveDetailService; |
| | | import org.jeecg.modules.eam.service.IEamSparePartReceiveService; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.jeecg.common.system.base.controller.JeecgController; |
| | | |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.servlet.ModelAndView; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | |
| | | /** |
| | | * @Description: å¤åå¤ä»¶é¢ç¨å |
| | | * @Author: Lius |
| | | * @Date: 2025-03-19 |
| | | * @Version: V1.0 |
| | | */ |
| | | @Slf4j |
| | | @Api(tags = "å¤åå¤ä»¶é¢ç¨å") |
| | | @RestController |
| | | @RequestMapping("/eam/eamSparePartReceive") |
| | | public class EamSparePartReceiveController extends JeecgController<EamSparePartReceive, IEamSparePartReceiveService> { |
| | | |
| | | @Resource |
| | | private IEamSparePartReceiveService eamSparePartReceiveService; |
| | | |
| | | @Resource |
| | | private IEamSparePartReceiveDetailService sparePartReceiveDetailService; |
| | | |
| | | @Resource |
| | | private IEamSparePartInventoryService sparePartInventoryService; |
| | | |
| | | /** |
| | | * å页å表æ¥è¯¢ |
| | | * |
| | | * @param eamSparePartReceive |
| | | * @param pageNo |
| | | * @param pageSize |
| | | * @param req |
| | | * @return |
| | | */ |
| | | @ApiOperation(value = "å¤åå¤ä»¶é¢ç¨å-å页å表æ¥è¯¢", notes = "å¤åå¤ä»¶é¢ç¨å-å页å表æ¥è¯¢") |
| | | @GetMapping(value = "/list") |
| | | public Result<?> queryPageList(EamSparePartReceive eamSparePartReceive, |
| | | @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, |
| | | @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, |
| | | HttpServletRequest req) { |
| | | // QueryWrapper<EamSparePartReceive> queryWrapper = QueryGenerator.initQueryWrapper(eamSparePartReceive, req.getParameterMap()); |
| | | QueryWrapper<EamSparePartReceive> queryWrapper = new QueryWrapper<>(); |
| | | String receiveCode = eamSparePartReceive.getReceiveCode(); |
| | | if(StringUtils.isNotBlank(receiveCode)){ |
| | | queryWrapper.like("receive_code",receiveCode); |
| | | } |
| | | String receiveStatus = eamSparePartReceive.getReceiveStatus(); |
| | | if(StringUtils.isNotBlank(receiveStatus)){ |
| | | queryWrapper.eq("receive_status",receiveStatus); |
| | | } |
| | | String receiveUser = eamSparePartReceive.getReceiveUser(); |
| | | if(StringUtils.isNotBlank(receiveUser)){ |
| | | queryWrapper.like("receive_user",receiveUser); |
| | | } |
| | | queryWrapper.orderByDesc("create_time"); |
| | | Page<EamSparePartReceive> page = new Page<EamSparePartReceive>(pageNo, pageSize); |
| | | IPage<EamSparePartReceive> pageList = eamSparePartReceiveService.page(page, queryWrapper); |
| | | for (EamSparePartReceive record : pageList.getRecords()) { |
| | | List<EamSparePartReceiveDetail> details = sparePartReceiveDetailService.lambdaQuery() |
| | | .eq(EamSparePartReceiveDetail::getSparePartReceiveId, record.getId()).list(); |
| | | record.setSparePartReceiveDetails(details); |
| | | } |
| | | return Result.OK(pageList); |
| | | } |
| | | |
| | | /** |
| | | * æ·»å |
| | | * |
| | | * @param eamSparePartReceive |
| | | * @return |
| | | */ |
| | | @ApiOperation(value = "å¤åå¤ä»¶é¢ç¨å-æ·»å ", notes = "å¤åå¤ä»¶é¢ç¨å-æ·»å ") |
| | | @PostMapping(value = "/add") |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public Result<?> add(@RequestBody EamSparePartReceive eamSparePartReceive) { |
| | | eamSparePartReceive.setReceiveStatus(BusinessCodeConst.receive_status_1); |
| | | LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); |
| | | String realName = user.getRealname(); |
| | | eamSparePartReceive.setReceiveUser(realName); |
| | | eamSparePartReceiveService.save(eamSparePartReceive); |
| | | List<EamSparePartReceiveDetail> sparePartReceiveDetails = eamSparePartReceive.getSparePartReceiveDetails(); |
| | | for (EamSparePartReceiveDetail sparePartReceiveDetail : sparePartReceiveDetails) { |
| | | sparePartReceiveDetail.setSparePartReceiveId(eamSparePartReceive.getId()); |
| | | sparePartReceiveDetailService.saveOrUpdate(sparePartReceiveDetail); |
| | | } |
| | | return Result.OK("æ·»å æåï¼"); |
| | | } |
| | | |
| | | /** |
| | | * ç¼è¾ |
| | | * |
| | | * @param eamSparePartReceive |
| | | * @return |
| | | */ |
| | | @ApiOperation(value = "å¤åå¤ä»¶é¢ç¨å-ç¼è¾", notes = "å¤åå¤ä»¶é¢ç¨å-ç¼è¾") |
| | | @RequestMapping(value = "/edit", method = {RequestMethod.PUT, RequestMethod.POST}) |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public Result<?> edit(@RequestBody EamSparePartReceive eamSparePartReceive) { |
| | | eamSparePartReceiveService.updateById(eamSparePartReceive); |
| | | List<EamSparePartReceiveDetail> details = sparePartReceiveDetailService.lambdaQuery().eq(EamSparePartReceiveDetail::getSparePartReceiveId, eamSparePartReceive.getId()).list(); |
| | | for (EamSparePartReceiveDetail detail : details) { |
| | | sparePartReceiveDetailService.removeById(detail); |
| | | } |
| | | List<EamSparePartReceiveDetail> sparePartReceiveDetails = eamSparePartReceive.getSparePartReceiveDetails(); |
| | | for (EamSparePartReceiveDetail sparePartReceiveDetail : sparePartReceiveDetails) { |
| | | sparePartReceiveDetail.setSparePartReceiveId(eamSparePartReceive.getId()); |
| | | sparePartReceiveDetailService.saveOrUpdate(sparePartReceiveDetail); |
| | | } |
| | | return Result.OK("ç¼è¾æå!"); |
| | | } |
| | | |
| | | /** |
| | | * éè¿idå é¤ |
| | | * |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @ApiOperation(value = "å¤åå¤ä»¶é¢ç¨å-éè¿idå é¤", notes = "å¤åå¤ä»¶é¢ç¨å-éè¿idå é¤") |
| | | @DeleteMapping(value = "/delete") |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public Result<?> delete(@RequestParam(name = "id", required = true) String id) { |
| | | List<EamSparePartReceiveDetail> details = sparePartReceiveDetailService.lambdaQuery() |
| | | .eq(EamSparePartReceiveDetail::getSparePartReceiveId,id).list(); |
| | | for (EamSparePartReceiveDetail detail : details) { |
| | | sparePartReceiveDetailService.removeById(detail); |
| | | } |
| | | eamSparePartReceiveService.removeById(id); |
| | | return Result.OK("å 餿å!"); |
| | | } |
| | | |
| | | /** |
| | | * æ¹éå é¤ |
| | | * |
| | | * @param ids |
| | | * @return |
| | | */ |
| | | @ApiOperation(value = "å¤åå¤ä»¶é¢ç¨å-æ¹éå é¤", notes = "å¤åå¤ä»¶é¢ç¨å-æ¹éå é¤") |
| | | @DeleteMapping(value = "/deleteBatch") |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public Result<?> deleteBatch(@RequestParam(name = "ids", required = true) String ids) { |
| | | List<String> strings = Arrays.asList(ids.split(",")); |
| | | for (String s : strings) { |
| | | List<EamSparePartReceiveDetail> details = sparePartReceiveDetailService.lambdaQuery() |
| | | .eq(EamSparePartReceiveDetail::getSparePartReceiveId,s).list(); |
| | | for (EamSparePartReceiveDetail detail : details) { |
| | | sparePartReceiveDetailService.removeById(detail); |
| | | } |
| | | } |
| | | this.eamSparePartReceiveService.removeByIds(Arrays.asList(ids.split(","))); |
| | | return Result.OK("æ¹éå 餿åï¼"); |
| | | } |
| | | |
| | | /** |
| | | * éè¿idæ¥è¯¢ |
| | | * |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @ApiOperation(value = "å¤åå¤ä»¶é¢ç¨å-éè¿idæ¥è¯¢", notes = "å¤åå¤ä»¶é¢ç¨å-éè¿idæ¥è¯¢") |
| | | @GetMapping(value = "/queryById") |
| | | public Result<?> queryById(@RequestParam(name = "id", required = true) String id) { |
| | | EamSparePartReceive eamSparePartReceive = eamSparePartReceiveService.getById(id); |
| | | return Result.OK(eamSparePartReceive); |
| | | } |
| | | |
| | | /** |
| | | * æäº¤ |
| | | * |
| | | * @return |
| | | */ |
| | | @AutoLog(value = "å¤ä»¶é¢ç¨-æäº¤") |
| | | @ApiOperation(value = "å¤ä»¶é¢ç¨-æäº¤", notes = "å¤ä»¶é¢ç¨-æäº¤") |
| | | @PostMapping(value = "/submit") |
| | | public Result<?> submitSparePartReceive(@RequestBody EamSparePartReceive eamSparePartReceive) { |
| | | eamSparePartReceive.setReceiveStatus(BusinessCodeConst.receive_status_2); |
| | | boolean b = eamSparePartReceiveService.updateById(eamSparePartReceive); |
| | | if (!b) { |
| | | return Result.error("æäº¤å¤±è´¥ï¼"); |
| | | } |
| | | return Result.OK("æäº¤æå!"); |
| | | } |
| | | |
| | | /** |
| | | * 确认 |
| | | * |
| | | * @return |
| | | */ |
| | | @AutoLog(value = "å¤ä»¶é¢ç¨-确认") |
| | | @ApiOperation(value = "å¤ä»¶é¢ç¨-确认", notes = "å¤ä»¶é¢ç¨-确认") |
| | | @PostMapping(value = "/confirm") |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public Result<?> confirmSparePartReceive(@RequestBody EamSparePartReceive eamSparePartReceive) { |
| | | LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); |
| | | if (sysUser == null) { |
| | | throw new JeecgBootException("å½åç¨æ·æ æ³ç¡®è®¤å¤ä»¶é¢ç¨ï¼"); |
| | | } |
| | | List<EamSparePartReceiveDetail> details = sparePartReceiveDetailService.lambdaQuery().eq(EamSparePartReceiveDetail::getSparePartReceiveId, eamSparePartReceive.getId()).list(); |
| | | for (EamSparePartReceiveDetail detail : details) { |
| | | EamSparePartInventory eamSparePartInventory = new EamSparePartInventory(); |
| | | eamSparePartInventory.setSparePartId(detail.getPartId()); |
| | | eamSparePartInventory.setInventory(detail.getReceiveNum().negate()); |
| | | eamSparePartInventory.setSparePartIntoType("2");//åºåæ¥æºç±»å 1.å
¥åº 2.颿åºåº 3.å½è¿å
¥åº |
| | | sparePartInventoryService.save(eamSparePartInventory); |
| | | } |
| | | eamSparePartReceive.setApprovalUser(sysUser.getRealname()); |
| | | eamSparePartReceive.setApprovalTime(new Date()); |
| | | eamSparePartReceive.setReceiveStatus(BusinessCodeConst.receive_status_3); |
| | | boolean b = eamSparePartReceiveService.updateById(eamSparePartReceive); |
| | | if (!b) { |
| | | return Result.error("确认失败ï¼"); |
| | | } |
| | | return Result.OK("确认æå!"); |
| | | } |
| | | |
| | | /** |
| | | * å½è¿ |
| | | * |
| | | * @return |
| | | */ |
| | | @AutoLog(value = "å¤ä»¶é¢ç¨-å½è¿") |
| | | @ApiOperation(value = "å¤ä»¶é¢ç¨-å½è¿", notes = "å¤ä»¶é¢ç¨-å½è¿") |
| | | @PostMapping(value = "/return") |
| | | public Result<?> returnSparePartReceive(@RequestBody EamSparePartReceive eamSparePartReceive) { |
| | | eamSparePartReceive.setReceiveStatus(BusinessCodeConst.receive_status_4); |
| | | boolean b = eamSparePartReceiveService.updateById(eamSparePartReceive); |
| | | if (!b) { |
| | | return Result.error("å½è¿å¤±è´¥ï¼"); |
| | | } |
| | | return Result.OK("å½è¿æå!"); |
| | | } |
| | | |
| | | /** |
| | | * å½è¿ç¡®è®¤ |
| | | * |
| | | * @return |
| | | */ |
| | | @AutoLog(value = "å¤ä»¶é¢ç¨-å½è¿ç¡®è®¤") |
| | | @ApiOperation(value = "å¤ä»¶é¢ç¨-å½è¿ç¡®è®¤", notes = "å¤ä»¶é¢ç¨-å½è¿ç¡®è®¤") |
| | | @PostMapping(value = "/returnConfirm") |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public Result<?> returnConfirmSparePartReceive(@RequestBody EamSparePartReceive eamSparePartReceive) { |
| | | LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); |
| | | if (sysUser == null) { |
| | | throw new JeecgBootException("å½åç¨æ·æ æ³ç¡®è®¤å¤ä»¶å½è¿ï¼"); |
| | | } |
| | | List<EamSparePartReceiveDetail> details = sparePartReceiveDetailService.lambdaQuery().eq(EamSparePartReceiveDetail::getSparePartReceiveId, eamSparePartReceive.getId()).list(); |
| | | for (EamSparePartReceiveDetail detail : details) { |
| | | EamSparePartInventory eamSparePartInventory = new EamSparePartInventory(); |
| | | eamSparePartInventory.setSparePartId(detail.getPartId()); |
| | | eamSparePartInventory.setInventory(detail.getReceiveNum()); |
| | | eamSparePartInventory.setSparePartIntoType("3");//åºåæ¥æºç±»å 1.å
¥åº 2.颿åºåº 3.å½è¿å
¥åº |
| | | sparePartInventoryService.save(eamSparePartInventory); |
| | | } |
| | | eamSparePartReceive.setReceiveStatus(BusinessCodeConst.receive_status_5); |
| | | boolean b = eamSparePartReceiveService.updateById(eamSparePartReceive); |
| | | if (!b) { |
| | | return Result.error("å½è¿ç¡®è®¤å¤±è´¥ï¼"); |
| | | } |
| | | return Result.OK("å½è¿ç¡®è®¤æå!"); |
| | | } |
| | | |
| | | /** |
| | | * 导åºexcel |
| | | * |
| | | * @param request |
| | | * @param eamSparePartReceive |
| | | */ |
| | | @RequestMapping(value = "/exportXls") |
| | | public ModelAndView exportXls(HttpServletRequest request, EamSparePartReceive eamSparePartReceive) { |
| | | return super.exportXls(request, eamSparePartReceive, EamSparePartReceive.class, "å¤åå¤ä»¶é¢ç¨å"); |
| | | } |
| | | |
| | | /** |
| | | * éè¿excel导å
¥æ°æ® |
| | | * |
| | | * @param request |
| | | * @param response |
| | | * @return |
| | | */ |
| | | @RequestMapping(value = "/importExcel", method = RequestMethod.POST) |
| | | public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) { |
| | | return super.importExcel(request, response, EamSparePartReceive.class); |
| | | } |
| | | |
| | | } |