package com.glxp.api.controller.inout; import cn.hutool.core.util.StrUtil; import com.glxp.api.annotation.AuthRuleAnnotation; import com.glxp.api.common.enums.ResultEnum; import com.glxp.api.common.res.BaseResponse; import com.glxp.api.common.util.ResultVOUtils; import com.glxp.api.controller.BaseController; import com.glxp.api.entity.inout.IoCodeLostEntity; import com.glxp.api.entity.inout.IoCodeTempEntity; import com.glxp.api.service.inout.IoCodeLostService; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RestController; import javax.annotation.Resource; import java.util.Date; @RestController public class IoCodeLostController extends BaseController { @Resource IoCodeLostService codeLostService; @AuthRuleAnnotation("") @PostMapping("warehouse/inout/saveTabCode") public BaseResponse saveCode(@RequestBody IoCodeTempEntity codeTempEntity) { if (StrUtil.isNotEmpty(codeTempEntity.getSerialNo()) && codeTempEntity.getSerialNo().length() > 20) { return ResultVOUtils.error(500, "无效条码!序列号超出最大范围,不予缓存"); } if (StrUtil.isNotEmpty(codeTempEntity.getBatchNo()) && codeTempEntity.getBatchNo().length() > 20) { return ResultVOUtils.error(500, "无效条码!批次号超出最大范围,不予缓存"); } if (StrUtil.isBlank(codeTempEntity.getSerialNo()) && StrUtil.isBlank(codeTempEntity.getBatchNo())) { return ResultVOUtils.error(500, "批次号不能为空!,不予缓存"); } if (StrUtil.isNotEmpty(codeTempEntity.getSerialNo())) { return ResultVOUtils.error(500, "有序列号不予缓存"); } IoCodeLostEntity codeLostEntity = codeLostService.findByCode(codeTempEntity.getCode()); IoCodeLostEntity insertEntity = null; if (codeLostEntity == null) { insertEntity = new IoCodeLostEntity(); insertEntity.setCreateTime(new Date()); } else { insertEntity = codeLostEntity; } insertEntity.setCode(codeTempEntity.getCode()); insertEntity.setBatchNo(codeTempEntity.getBatchNo()); insertEntity.setProduceDate(codeTempEntity.getProduceDate()); insertEntity.setExpireDate(codeTempEntity.getExpireDate()); insertEntity.setSerialNo(codeTempEntity.getSerialNo()); insertEntity.setSupId(codeTempEntity.getSupId()); insertEntity.setUpdateTime(new Date()); if (codeLostEntity != null) { codeLostService.update(insertEntity); } else { codeLostService.insert(insertEntity); } return ResultVOUtils.success("修改成功!"); } //获取验收单据业务详情 @AuthRuleAnnotation("") @GetMapping("/warehouse/inout/getTabCode") public BaseResponse getTabCode(String code) { if (StrUtil.isBlank(code)) { return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL); } IoCodeLostEntity codeLostEntity = codeLostService.findByCode(code); if (codeLostEntity == null) return ResultVOUtils.error(500, "未缓存!"); return ResultVOUtils.success(codeLostEntity); } }