| | |
| | | package org.jeecg.modules.eam.controller; |
| | | |
| | | import cn.hutool.core.collection.CollectionUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | 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.system.base.controller.JeecgController; |
| | | import org.jeecg.common.util.TranslateDictTextUtils; |
| | | import org.jeecg.modules.eam.constant.TechnicalStatusChangeOrderStatusEnum; |
| | | import org.jeecg.modules.eam.constant.TechnicalStatusEvaluationOrderChangeStatusEnum; |
| | | import org.jeecg.modules.eam.entity.EamTechnicalStatusChange; |
| | | import org.jeecg.modules.eam.entity.EamTechnicalStatusChangeDetail; |
| | | import org.jeecg.modules.eam.request.EamTechnicalStatusChangeQuery; |
| | | import org.jeecg.modules.eam.request.EamTechnicalStatusChangeRequest; |
| | | import org.jeecg.modules.eam.service.IEamTechnicalStatusChangeService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | |
| | | /** |
| | | * @Description: 技术状态变更申请 |
| | |
| | | public class EamTechnicalStatusChangeController extends JeecgController<EamTechnicalStatusChange, IEamTechnicalStatusChangeService> { |
| | | @Autowired |
| | | private IEamTechnicalStatusChangeService eamTechnicalStatusChangeService; |
| | | @Autowired |
| | | private ObjectMapper objectMapper; |
| | | @Autowired |
| | | private TranslateDictTextUtils translateDictTextUtils; |
| | | |
| | | /** |
| | | * 分页列表查询 |
| | |
| | | * @param query |
| | | * @param pageNo |
| | | * @param pageSize |
| | | * @param req |
| | | * @return |
| | | */ |
| | | @ApiOperation(value="技术状态变更申请-分页列表查询", notes="技术状态变更申请-分页列表查询") |
| | | @GetMapping(value = "/list") |
| | | public Result<?> queryPageList(EamTechnicalStatusChangeQuery query, |
| | | @RequestParam(name="pageNo", defaultValue="1") Integer pageNo, |
| | | @RequestParam(name="pageSize", defaultValue="10") Integer pageSize, |
| | | HttpServletRequest req) { |
| | | @RequestParam(name="pageSize", defaultValue="10") Integer pageSize) { |
| | | Page<EamTechnicalStatusChange> page = new Page<EamTechnicalStatusChange>(pageNo, pageSize); |
| | | IPage<EamTechnicalStatusChange> pageList = eamTechnicalStatusChangeService.queryPageList(page, query); |
| | | return Result.OK(pageList); |
| | |
| | | public Result<?> add(@RequestBody EamTechnicalStatusChangeRequest request) { |
| | | if (request == null) { |
| | | return Result.error("添加的对象不能为空!"); |
| | | } |
| | | if(CollectionUtil.isEmpty(request.getTableDetailList())) { |
| | | return Result.error("设备明细不能为空!"); |
| | | } |
| | | boolean b = eamTechnicalStatusChangeService.addEamTechnicalStatusChange(request); |
| | | if (!b) { |
| | |
| | | if (entity == null) { |
| | | return Result.error("要作废的数据不存在,请刷新重试!"); |
| | | } |
| | | if (!TechnicalStatusEvaluationOrderChangeStatusEnum.WAIT_SUBMIT.name().equals(entity.getChangeStatus())) { |
| | | if (!TechnicalStatusChangeOrderStatusEnum.WAIT_SUBMIT.name().equals(entity.getChangeStatus())) { |
| | | return Result.error("该状态的数据不允许进行作废!"); |
| | | } |
| | | entity.setChangeStatus(TechnicalStatusChangeOrderStatusEnum.ABOLISH.name()); |
| | |
| | | @GetMapping(value = "/queryById") |
| | | public Result<?> queryById(@RequestParam(name="id",required=true) String id) { |
| | | EamTechnicalStatusChange eamTechnicalStatusChange = eamTechnicalStatusChangeService.getById(id); |
| | | return Result.OK(eamTechnicalStatusChange); |
| | | if (eamTechnicalStatusChange == null) { |
| | | return Result.error("未找到对应数据"); |
| | | } |
| | | try { |
| | | String json = objectMapper.writeValueAsString(eamTechnicalStatusChange); |
| | | JSONObject item = JSONObject.parseObject(json, Feature.OrderedField); |
| | | translateDictTextUtils.translateField("designer", eamTechnicalStatusChange.getDesigner(), item, "sys_user,realname,username"); |
| | | translateDictTextUtils.translateField("factoryOrgCode", eamTechnicalStatusChange.getFactoryOrgCode(), item, "eam_base_factory,factory_name,org_code"); |
| | | return Result.OK(item); |
| | | } catch (JsonProcessingException e) { |
| | | return Result.error("数据转译失败!"); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 验收 |
| | | * @param request |
| | | * @return |
| | | */ |
| | | @ApiOperation(value = "技术状态变更申请明细-验收", notes = "技术状态变更申请明细-验收") |
| | | @PostMapping(value = "/acceptance") |
| | | public Result<?> acceptance(@RequestBody EamTechnicalStatusChangeDetail request) { |
| | | if (request == null) { |
| | | return Result.error("验收结果对象不能为空!"); |
| | | } |
| | | boolean b = eamTechnicalStatusChangeService.acceptance(request); |
| | | if (!b) { |
| | | return Result.error("操作失败!"); |
| | | } |
| | | return Result.OK("操作成功!"); |
| | | } |
| | | |
| | | } |