¶Ô±ÈÐÂÎļþ |
| | |
| | | package org.jeecg.modules.eam.controller; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.alibaba.fastjson.parser.Feature; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.fasterxml.jackson.core.JsonProcessingException; |
| | | import com.fasterxml.jackson.databind.ObjectMapper; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | 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.util.TranslateDictTextUtils; |
| | | import org.jeecg.modules.eam.constant.BusinessCodeConst; |
| | | import org.jeecg.modules.eam.constant.EquipmentScrapStatusEnum; |
| | | import org.jeecg.modules.eam.entity.EamEquipmentScrap; |
| | | import org.jeecg.modules.eam.request.EamEquipmentScrapQuery; |
| | | import org.jeecg.modules.eam.request.EamEquipmentScrapRequest; |
| | | import org.jeecg.modules.eam.service.IEamEquipmentScrapService; |
| | | import org.jeecg.modules.system.service.ISysBusinessCodeRuleService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @Description: è®¾å¤æ¥åº(转让) |
| | | * @Author: jeecg-boot |
| | | * @Date: 2025-05-15 |
| | | * @Version: V1.0 |
| | | */ |
| | | @Slf4j |
| | | @Api(tags = "è®¾å¤æ¥åº(转让)") |
| | | @RestController |
| | | @RequestMapping("/eam/eamEquipmentScrap") |
| | | public class EamEquipmentScrapController extends JeecgController<EamEquipmentScrap, IEamEquipmentScrapService> { |
| | | @Autowired |
| | | private IEamEquipmentScrapService eamEquipmentScrapService; |
| | | @Autowired |
| | | private ISysBusinessCodeRuleService businessCodeRuleService; |
| | | @Autowired |
| | | private ObjectMapper objectMapper; |
| | | @Autowired |
| | | private TranslateDictTextUtils translateDictTextUtils; |
| | | |
| | | /** |
| | | * å页å表æ¥è¯¢ |
| | | * |
| | | * @param eamEquipmentScrap |
| | | * @param pageNo |
| | | * @param pageSize |
| | | * @param req |
| | | * @return |
| | | */ |
| | | @AutoLog(value = "è®¾å¤æ¥åº(转让)-å页å表æ¥è¯¢") |
| | | @ApiOperation(value = "è®¾å¤æ¥åº(转让)-å页å表æ¥è¯¢", notes = "è®¾å¤æ¥åº(转让)-å页å表æ¥è¯¢") |
| | | @GetMapping(value = "/list") |
| | | public Result<?> queryPageList(EamEquipmentScrapQuery query, |
| | | @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, |
| | | @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, |
| | | HttpServletRequest req) { |
| | | Page<EamEquipmentScrap> page = new Page<EamEquipmentScrap>(pageNo, pageSize); |
| | | IPage<EamEquipmentScrap> pageList = eamEquipmentScrapService.queryPageList(page, query); |
| | | return Result.OK(pageList); |
| | | } |
| | | |
| | | /** |
| | | * æ·»å |
| | | * |
| | | * @param request |
| | | * @return |
| | | */ |
| | | @AutoLog(value = "è®¾å¤æ¥åº(转让)-æ·»å ") |
| | | @ApiOperation(value = "è®¾å¤æ¥åº(转让)-æ·»å ", notes = "è®¾å¤æ¥åº(转让)-æ·»å ") |
| | | @PostMapping(value = "/add") |
| | | public Result<?> add(@RequestBody EamEquipmentScrap request) { |
| | | if (request == null) { |
| | | return Result.error("æ·»å ç对象ä¸è½ä¸ºç©ºï¼"); |
| | | } |
| | | request.setCode(businessCodeRuleService.generateBusinessCodeSeq(BusinessCodeConst.SCRAP_CODE_RULE)); |
| | | request.setScrapStatus(EquipmentScrapStatusEnum.WAIT_SUBMIT.name()); |
| | | request.setDelFlag(CommonConstant.DEL_FLAG_0); |
| | | boolean b = eamEquipmentScrapService.addScrap(request); |
| | | if (!b) { |
| | | return Result.error("æ·»å 失败ï¼"); |
| | | } |
| | | return Result.OK("æ·»å æåï¼"); |
| | | } |
| | | |
| | | /** |
| | | * ç¼è¾ |
| | | * |
| | | * @param request |
| | | * @return |
| | | */ |
| | | @AutoLog(value = "è®¾å¤æ¥åº(转让)-ç¼è¾") |
| | | @ApiOperation(value = "è®¾å¤æ¥åº(转让)-ç¼è¾", notes = "è®¾å¤æ¥åº(转让)-ç¼è¾") |
| | | @RequestMapping(value = "/edit", method = {RequestMethod.PUT, RequestMethod.POST}) |
| | | public Result<?> edit(@RequestBody EamEquipmentScrap request) { |
| | | if (request == null) { |
| | | return Result.error("ç¼è¾ç对象ä¸è½ä¸ºç©ºï¼"); |
| | | } |
| | | boolean b = eamEquipmentScrapService.editScrap(request); |
| | | if (!b) { |
| | | return Result.error("ç¼è¾å¤±è´¥ï¼"); |
| | | } |
| | | return Result.OK("ç¼è¾æå!"); |
| | | } |
| | | |
| | | /** |
| | | * éè¿idå é¤ |
| | | * |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @AutoLog(value = "è®¾å¤æ¥åº(转让)-éè¿idå é¤") |
| | | @ApiOperation(value = "è®¾å¤æ¥åº(转让)-éè¿idå é¤", notes = "è®¾å¤æ¥åº(转让)-éè¿idå é¤") |
| | | @DeleteMapping(value = "/delete") |
| | | public Result<?> delete(@RequestParam(name = "id", required = true) String id) { |
| | | EamEquipmentScrap entity = eamEquipmentScrapService.getById(id); |
| | | if (entity != null) { |
| | | entity.setDelFlag(CommonConstant.DEL_FLAG_1); |
| | | eamEquipmentScrapService.updateById(entity); |
| | | } |
| | | return Result.OK("å 餿å!"); |
| | | } |
| | | |
| | | /** |
| | | * æ¹éå é¤ |
| | | * |
| | | * @param ids |
| | | * @return |
| | | */ |
| | | @AutoLog(value = "è®¾å¤æ¥åº(转让)-æ¹éå é¤") |
| | | @ApiOperation(value = "è®¾å¤æ¥åº(转让)-æ¹éå é¤", notes = "è®¾å¤æ¥åº(转让)-æ¹éå é¤") |
| | | @DeleteMapping(value = "/deleteBatch") |
| | | public Result<?> deleteBatch(@RequestParam(name = "ids", required = true) String ids) { |
| | | this.eamEquipmentScrapService.removeByIds(Arrays.asList(ids.split(","))); |
| | | List<String> list = Arrays.asList(ids.split(",")); |
| | | list.forEach(id -> { |
| | | EamEquipmentScrap entity = eamEquipmentScrapService.getById(id); |
| | | if (entity != null) { |
| | | entity.setDelFlag(CommonConstant.DEL_FLAG_1); |
| | | eamEquipmentScrapService.updateById(entity); |
| | | } |
| | | }); |
| | | return Result.OK("æ¹éå 餿åï¼"); |
| | | } |
| | | |
| | | /** |
| | | * éè¿idæ¥è¯¢ |
| | | * |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @AutoLog(value = "è®¾å¤æ¥åº(转让)-éè¿idæ¥è¯¢") |
| | | @ApiOperation(value = "è®¾å¤æ¥åº(转让)-éè¿idæ¥è¯¢", notes = "è®¾å¤æ¥åº(转让)-éè¿idæ¥è¯¢") |
| | | @GetMapping(value = "/queryById") |
| | | public Result<?> queryById(@RequestParam(name = "id", required = true) String id) { |
| | | EamEquipmentScrap eamEquipmentScrap = eamEquipmentScrapService.getById(id); |
| | | if (eamEquipmentScrap == null) { |
| | | return Result.error("æªæ¾å°å¯¹åºæ°æ®"); |
| | | } |
| | | try { |
| | | String json = objectMapper.writeValueAsString(eamEquipmentScrap); |
| | | JSONObject item = JSONObject.parseObject(json, Feature.OrderedField); |
| | | translateDictTextUtils.translateField("reportUser", eamEquipmentScrap.getReportUser(), item, "sys_user,realname,username"); |
| | | return Result.OK(item); |
| | | } catch (JsonProcessingException e) { |
| | | return Result.error("æ°æ®è½¬è¯å¤±è´¥ï¼"); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * æäº¤ |
| | | * |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @AutoLog(value = "è®¾å¤æ¥åº(转让)-æäº¤") |
| | | @ApiOperation(value = "è®¾å¤æ¥åº(转让)-æäº¤", notes = "è®¾å¤æ¥åº(转让)-æäº¤") |
| | | @GetMapping(value = "/submit") |
| | | public Result<?> submit(@RequestParam(name = "id", required = true) String id) { |
| | | boolean b = eamEquipmentScrapService.submit(id); |
| | | if (!b) { |
| | | return Result.error("æä½å¤±è´¥ï¼"); |
| | | } |
| | | return Result.OK("æä½æå!"); |
| | | } |
| | | |
| | | /** |
| | | * å®¡æ¹æµ |
| | | * |
| | | * @param request |
| | | * @return |
| | | */ |
| | | @AutoLog(value = "è®¾å¤æ¥åº(转让)-å®¡æ¹æµ") |
| | | @ApiOperation(value = "è®¾å¤æ¥åº(转让)-å®¡æ¹æµ", notes = "è®¾å¤æ¥åº(转让)-å®¡æ¹æµ") |
| | | @RequestMapping(value = "/approval", method = {RequestMethod.PUT, RequestMethod.POST}) |
| | | public Result<?> approval(@RequestBody EamEquipmentScrapRequest request) { |
| | | if (request == null) { |
| | | return Result.error("æ·»å ç对象ä¸è½ä¸ºç©ºï¼"); |
| | | } |
| | | EamEquipmentScrap entity = eamEquipmentScrapService.approval(request); |
| | | if (entity == null) { |
| | | return Result.error("æä½å¤±è´¥ï¼"); |
| | | } |
| | | return Result.OK("æä½æå!"); |
| | | } |
| | | } |