package cn.huge.module.cases.controller; import cn.huge.base.common.utils.DateUtils; import cn.huge.base.common.utils.ReturnFailUtils; import cn.huge.base.common.utils.ReturnSucUtils; import cn.huge.module.cases.service.CaseInfoService; import cn.huge.module.common.utils.CaseIdUtils; import cn.huge.module.common.utils.CaseNoUtils; import cn.huge.module.common.utils.CommonIdUtils; import cn.huge.module.common.utils.JudicIdUtils; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import javax.servlet.http.HttpServletRequest; import java.util.Date; /** * @title: 公共参数-案号工具接口api * @description: 公共参数-案号工具接口api * @company: hugeinfo * @author: liyj * @time: 2022-04-29 10:12:39 * @version: 1.0.0 */ @Slf4j @RestController @RequestMapping("/common/api/caseNoUtils") public class CaseNoUtilsController { @Autowired(required = false) private HttpServletRequest request; @Autowired private CaseInfoService caseInfoService; /** * 生成新的调解案号 * @url {ctx}/common/api/caseNoUtils/createCaseNo * @param custId 客户编号 * @return Object */ @GetMapping("/createCaseNo") public Object createCaseNo(@RequestParam(value = "custId") String custId) { try { if (CaseNoUtils.CASE_NO_FALG){ int year = DateUtils.getYear(new Date()); String caseNoPrefix = "(" + year + ")粤云调"; String newCaseNo = caseInfoService.getNewCaseNo(caseNoPrefix, custId); if(StringUtils.isBlank(newCaseNo)){ newCaseNo = "0"; } String numStr = newCaseNo.replace(caseNoPrefix, "").replace("号", ""); int num = Integer.parseInt(numStr); CaseNoUtils.CASE_NO_SIGN = num; CaseNoUtils.CASE_NO_FALG = false; } return ReturnSucUtils.getRepInfo(CaseNoUtils.getCaseNo()); } catch (Exception e) { return ReturnFailUtils.getRepInfo(); } } /** * 从startNo(包括startNo)开始生成新的调解案号 * @url {ctx}/common/api/caseNoUtils/createByStartNo * @return Object */ @GetMapping("/createByStartNo") public Object createByStartNo(@RequestParam(value = "startNo") int startNo) { try { CaseNoUtils.CASE_NO_SIGN = startNo-1; CaseNoUtils.CASE_NO_FALG = false; return ReturnSucUtils.getRepInfo(); } catch (Exception e) { return ReturnFailUtils.getRepInfo(); } } }