| | |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.jeecg.common.api.vo.Result; |
| | | import org.jeecg.common.aspect.annotation.AutoLog; |
| | | import org.jeecg.common.constant.CommonConstant; |
| | | import org.jeecg.common.system.base.controller.JeecgController; |
| | | import org.jeecg.common.system.query.QueryGenerator; |
| | | import org.jeecg.modules.eam.constant.BusinessCodeConst; |
| | | import org.jeecg.modules.mes.entity.MesMaterialTransferRequest; |
| | | import org.jeecg.modules.mes.enums.MaterialTransferPublishStatus; |
| | | import org.jeecg.modules.mes.service.IMesMaterialTransferRequestService; |
| | | import org.jeecg.modules.system.service.ISysBusinessCodeRuleService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.servlet.ModelAndView; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.Arrays; |
| | | |
| | | /** |
| | | * @Description: 物料拉动申请 |
| | |
| | | String codeSeq = businessCodeRuleService.generateBusinessCodeSeq(BusinessCodeConst.MATERIAL_TRANSFER_CODE_RULE); |
| | | request.setRequestCode(codeSeq); |
| | | boolean b = mesMaterialTransferRequestService.addMaterialTransferRequest(request); |
| | | if(!b) { |
| | | if (!b) { |
| | | return Result.error("添加失败!"); |
| | | } |
| | | return Result.OK("添加成功!"); |
| | |
| | | */ |
| | | @AutoLog(value = "物料拉动申请-编辑") |
| | | @ApiOperation(value = "物料拉动申请-编辑", notes = "物料拉动申请-编辑") |
| | | //@RequiresPermissions("org.jeecg.modules:mes_material_transfer_request:edit") |
| | | @RequestMapping(value = "/edit", method = {RequestMethod.PUT, RequestMethod.POST}) |
| | | public Result<String> edit(@RequestBody MesMaterialTransferRequest mesMaterialTransferRequest) { |
| | | mesMaterialTransferRequestService.updateById(mesMaterialTransferRequest); |
| | |
| | | */ |
| | | @AutoLog(value = "物料拉动申请-通过id删除") |
| | | @ApiOperation(value = "物料拉动申请-通过id删除", notes = "物料拉动申请-通过id删除") |
| | | //@RequiresPermissions("org.jeecg.modules:mes_material_transfer_request:delete") |
| | | @DeleteMapping(value = "/delete") |
| | | public Result<String> delete(@RequestParam(name = "id", required = true) String id) { |
| | | mesMaterialTransferRequestService.removeById(id); |
| | | return Result.OK("删除成功!"); |
| | | MesMaterialTransferRequest entity = mesMaterialTransferRequestService.getById(id); |
| | | if (entity == null) { |
| | | return Result.error("删除的数据不存在,请刷新重试!"); |
| | | } |
| | | if (!MaterialTransferPublishStatus.WAIT_PUBLISH.name().equals(entity.getPublishStatus())) { |
| | | return Result.error("数据已发布,无法删除!"); |
| | | } |
| | | entity.setDelFlag(CommonConstant.DEL_FLAG_1); |
| | | mesMaterialTransferRequestService.updateById(entity); |
| | | return Result.OK("删除成功!"); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | @AutoLog(value = "物料拉动申请-批量删除") |
| | | @ApiOperation(value = "物料拉动申请-批量删除", notes = "物料拉动申请-批量删除") |
| | | //@RequiresPermissions("org.jeecg.modules:mes_material_transfer_request:deleteBatch") |
| | | @DeleteMapping(value = "/deleteBatch") |
| | | public Result<String> deleteBatch(@RequestParam(name = "ids", required = true) String ids) { |
| | | this.mesMaterialTransferRequestService.removeByIds(Arrays.asList(ids.split(","))); |
| | | if (StringUtils.isBlank(ids)) { |
| | | return Result.error("参数错误!"); |
| | | } |
| | | String[] split = ids.split(","); |
| | | for (String id : split) { |
| | | MesMaterialTransferRequest entity = mesMaterialTransferRequestService.getById(id); |
| | | if (entity == null || !MaterialTransferPublishStatus.WAIT_PUBLISH.name().equals(entity.getPublishStatus())) { |
| | | //不做处理 |
| | | continue; |
| | | } |
| | | entity.setDelFlag(CommonConstant.DEL_FLAG_1); |
| | | mesMaterialTransferRequestService.updateById(entity); |
| | | } |
| | | return Result.OK("批量删除成功!"); |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | /** |
| | | * 导出excel |
| | | * 通过id发布 |
| | | * |
| | | * @param request |
| | | * @param mesMaterialTransferRequest |
| | | * @param id |
| | | * @return |
| | | */ |
| | | //@RequiresPermissions("org.jeecg.modules:mes_material_transfer_request:exportXls") |
| | | @RequestMapping(value = "/exportXls") |
| | | public ModelAndView exportXls(HttpServletRequest request, MesMaterialTransferRequest mesMaterialTransferRequest) { |
| | | return super.exportXls(request, mesMaterialTransferRequest, MesMaterialTransferRequest.class, "物料拉动申请"); |
| | | @AutoLog(value = "物料拉动申请-发布") |
| | | @ApiOperation(value = "物料拉动申请-发布", notes = "物料拉动申请-发布") |
| | | @PutMapping(value = "/publish") |
| | | public Result<String> publish(@RequestParam(name = "id", required = true) String id) { |
| | | boolean b = mesMaterialTransferRequestService.publish(id); |
| | | if (!b) { |
| | | return Result.error("发布失败!"); |
| | | } |
| | | return Result.OK("发布成功!"); |
| | | } |
| | | |
| | | /** |
| | | * 通过excel导入数据 |
| | | * 批量发布 |
| | | * |
| | | * @param request |
| | | * @param response |
| | | * @param ids |
| | | * @return |
| | | */ |
| | | //@RequiresPermissions("mes_material_transfer_request:importExcel") |
| | | @RequestMapping(value = "/importExcel", method = RequestMethod.POST) |
| | | public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) { |
| | | return super.importExcel(request, response, MesMaterialTransferRequest.class); |
| | | @AutoLog(value = "物料拉动申请-批量发布") |
| | | @ApiOperation(value = "物料拉动申请-批量发布", notes = "物料拉动申请-批量发布") |
| | | @PutMapping(value = "/publishBatch") |
| | | public Result<String> publishBatch(@RequestParam(name = "ids", required = true) String ids) { |
| | | if (StringUtils.isBlank(ids)) { |
| | | return Result.error("参数错误!"); |
| | | } |
| | | String[] split = ids.split(","); |
| | | int count = 0; |
| | | for (String id : split) { |
| | | try { |
| | | boolean b = mesMaterialTransferRequestService.publish(id); |
| | | if(b) { |
| | | count++; |
| | | } |
| | | } catch (Exception e) { |
| | | log.error(e.getMessage(), e); |
| | | } |
| | | } |
| | | return Result.OK("成功发布" + count + "条数据!"); |
| | | } |
| | | |
| | | /** |
| | | * 通过id请求WMS |
| | | * |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @AutoLog(value = "物料拉动申请-请求WMS") |
| | | @ApiOperation(value = "物料拉动申请-请求WMS", notes = "物料拉动申请-请求WMS") |
| | | @PutMapping(value = "/request") |
| | | public Result<String> request(@RequestParam(name = "id", required = true) String id) { |
| | | boolean b = mesMaterialTransferRequestService.request(id); |
| | | if (!b) { |
| | | return Result.error("请求失败!"); |
| | | } |
| | | return Result.OK("请求成功!"); |
| | | } |
| | | |
| | | /** |
| | | * 批量请求WMS |
| | | * |
| | | * @param ids |
| | | * @return |
| | | */ |
| | | @AutoLog(value = "物料拉动申请-批量请求WMS") |
| | | @ApiOperation(value = "物料拉动申请-批量请求WMS", notes = "物料拉动申请-批量请求WMS") |
| | | @PutMapping(value = "/requestBatch") |
| | | public Result<String> requestBatch(@RequestParam(name = "ids", required = true) String ids) { |
| | | if (StringUtils.isBlank(ids)) { |
| | | return Result.error("参数错误!"); |
| | | } |
| | | String[] split = ids.split(","); |
| | | int count = 0; |
| | | for (String id : split) { |
| | | try { |
| | | boolean b = mesMaterialTransferRequestService.request(id); |
| | | if(b) { |
| | | count++; |
| | | } |
| | | } catch (Exception e) { |
| | | log.error(e.getMessage(), e); |
| | | } |
| | | } |
| | | return Result.OK("成功请求WMS" + count + "条数据!"); |
| | | } |
| | | |
| | | /* |