package com.artfess.cqlt.controller; import cn.hutool.core.util.NumberUtil; import com.artfess.base.annotation.ApiGroup; import com.artfess.base.constants.ApiGroupConsts; import com.artfess.base.controller.BaseController; import com.artfess.base.model.CommonResult; import com.artfess.base.query.PageList; import com.artfess.base.query.QueryFilter; import com.artfess.cqlt.manager.QfOperationKpiDManager; import com.artfess.cqlt.model.QfOperationKpiD; import com.artfess.cqlt.model.QfOperationKpiM; import com.artfess.i18n.util.I18nUtil; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; import lombok.extern.slf4j.Slf4j; import org.apache.poi.ss.formula.functions.T; import org.springframework.context.i18n.LocaleContextHolder; import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import java.math.BigDecimal; import java.util.Arrays; /** * 运营--KPI数据填报主表 前端控制器 * * @author min.wu * @company 阿特菲斯信息技术有限公司 * @since 2023-02-14 */ @Slf4j @RestController @Api(tags = "运营--KPI数据填报详情") @RequestMapping("/qf/operation/kpiDetail/") @ApiGroup(group = {ApiGroupConsts.GROUP_BIZ}) public class QfOperationKpiDController extends BaseController { @PostMapping("/batchSave") @ApiOperation("批量添加实体的接口") public CommonResult batchSave(@ApiParam(name = "model", value = "实体信息") @RequestBody QfOperationKpiM t) { boolean result = baseService.batchSave(t); if (!result) { return new CommonResult(false, I18nUtil.getMessage("option.fail", LocaleContextHolder.getLocale()), null); } return new CommonResult(true, I18nUtil.getMessage("option.success", LocaleContextHolder.getLocale()), null); } @PutMapping("/batchUpdate") @ApiOperation("批量更新实体") public CommonResult batchUpdate(@ApiParam(name = "model", value = "实体信息") @RequestBody QfOperationKpiM t) { boolean result = baseService.batchUpdate(t); if (!result) { return new CommonResult(false, I18nUtil.getMessage("option.fail", LocaleContextHolder.getLocale()), null); } return new CommonResult(true, I18nUtil.getMessage("option.success", LocaleContextHolder.getLocale()), null); } @Override @DeleteMapping("/{id}") @ApiOperation("根据id删除") public CommonResult deleteById(@ApiParam(name = "id", value = "实体id") @PathVariable String id) { boolean result = baseService.removeById(id); if (!result) { return new CommonResult(false, I18nUtil.getMessage("delete.fail", LocaleContextHolder.getLocale()), null); } return new CommonResult(true, I18nUtil.getMessage("option.success", LocaleContextHolder.getLocale()), null); } @Override @DeleteMapping("/") @ApiOperation("根据id集合批量删除") public CommonResult deleteByIds(@ApiParam(name = "ids", value = "实体集合") @RequestParam String... ids) { boolean result = baseService.removeByIds(Arrays.asList(ids)); if (!result) { return new CommonResult(false, I18nUtil.getMessage("delete.fail", LocaleContextHolder.getLocale()), null); } return new CommonResult(true, I18nUtil.getMessage("option.success", LocaleContextHolder.getLocale()), null); } @Override @PostMapping(value = "/query", produces = {"application/json; charset=utf-8"}) @ApiOperation("分页查询结果") public PageList query(@ApiParam(name = "queryFilter", value = "分页查询信息") @RequestBody QueryFilter queryFilter) { PageList query = baseService.query(queryFilter); query.getRows().forEach(detail -> { if (null != detail.getTrExfiAct()) { detail.setTrExfiAct(NumberUtil.roundDown(detail.getTrExfiAct().multiply(new BigDecimal(100)), 2)); } if (null != detail.getOee24ExEpdmAct()) { detail.setOee24ExEpdmAct(NumberUtil.roundDown(detail.getOee24ExEpdmAct().multiply(new BigDecimal(100)), 2)); } if (null != detail.getQrExEpdmAct()) { detail.setQrExEpdmAct(NumberUtil.roundDown(detail.getQrExEpdmAct().multiply(new BigDecimal(100)), 2)); } }); return query; } }