package cn.huge.module.mediate.controller.client; import cn.huge.base.common.constant.GzAreaEnum; 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.mediate.service.CaseInfoService; import cn.huge.module.mediate.service.JudicInfoService; import cn.huge.module.mediate.utils.*; 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.text.SimpleDateFormat; import java.util.Date; /** * @title: 公共参数-id工具接口api-mediate服务专用 * @description: 公共参数-id工具接口api-mediate服务专用 * @company: hugeinfo * @author: liyj * @time: 2022-04-29 10:12:39 * @version: 1.0.0 */ @Slf4j @RestController @RequestMapping("/api/client/mediateUtils") public class MediateUtilsController { @Autowired(required = false) private HttpServletRequest request; @Autowired private CaseInfoService caseInfoService; @Autowired private JudicInfoService judicInfoService; /** * 公共id-获取时间Id,后四位常量 * @url {ctx}/api/client/mediateUtils/getNewTimeId * @return Object */ @GetMapping("/getNewTimeId") public Object getNewTimeId() { try { return ReturnSucUtils.getRepInfo(MediateIdUtils.getNewTimeId()); } catch (Exception e) { return ReturnFailUtils.getRepInfo(); } } /** * 案件id-获取时间Id,后四位常量 * @url {ctx}/api/client/mediateUtils/getNewTimeCaseId * @return Object */ @GetMapping("/getNewTimeCaseId") public Object getNewTimeCaseId() { try { return ReturnSucUtils.getRepInfo(CaseIdUtils.getNewTimeId()); } catch (Exception e) { return ReturnFailUtils.getRepInfo(); } } /** * 生成新的调解案号 * @url {ctx}/api/client/mediateUtils/createCaseNo * @param area 区 * @return Object */ @GetMapping("/createCaseNo") public Object createCaseNo(@RequestParam(value = "area") String area) { try { if (CaseNoUtils.getFlag(area)){ int year = DateUtils.getYear(new Date()); String caseNoLogo = caseInfoService.getCaseNoLogo(area); if (StringUtils.isEmpty(caseNoLogo)){ caseNoLogo = caseInfoService.getCaseNoLogo(GzAreaEnum.GZEnum_0.getIndex()); } String caseNoPrefix = "(" + year + ")"+caseNoLogo; String newCaseNo = caseInfoService.getNewCaseNo(caseNoPrefix); if(StringUtils.isBlank(newCaseNo)){ newCaseNo = "0"; } String numStr = newCaseNo.replace(caseNoPrefix, "").replace("号", ""); int num = Integer.parseInt(numStr); CaseNoUtils.setCount(area, num); CaseNoUtils.setFlag(area, false); } return ReturnSucUtils.getRepInfo(CaseNoUtils.getCaseNo(area)); } catch (Exception e) { return ReturnFailUtils.getRepInfo(); } } /** * 从startNo(包括startNo)开始生成新的调解案号 * @url {ctx}/common/api/caseNoUtils/setCaseNoByStartNo * @return Object */ @GetMapping("/setCaseNoByStartNo") public Object setCaseNoByStartNo(@RequestParam(value = "area") String area, @RequestParam(value = "startNo") int startNo) { try { CaseNoUtils.setCount(area, startNo-1); CaseNoUtils.setFlag(area, false); return ReturnSucUtils.getRepInfo(); } catch (Exception e) { return ReturnFailUtils.getRepInfo(); } } /** * 生成新的事项编号 * @url {ctx}/common/api/caseNoUtils/createCaseRef * @return Object */ @GetMapping("/createCaseRef") public Object createCaseRef() { try { return ReturnSucUtils.getRepInfo(CaseRefUtils.getCaseRef()); } catch (Exception e) { return ReturnFailUtils.getRepInfo(); } } /** * 司法确认id-获取时间Id,后四位常量 * @url {ctx}/api/client/mediateUtils/getNewTimeJudicId * @return Object */ @GetMapping("/getNewTimeJudicId") public Object getNewTimeJudicId() { try { return ReturnSucUtils.getRepInfo(JudicIdUtils.getNewTimeId()); } catch (Exception e) { return ReturnFailUtils.getRepInfo(); } } /** * 生成新的调解案号 * @url {ctx}/api/client/mediateUtils/createJudicNo * @param custId 客户编号 * @return Object */ @GetMapping("/createJudicNo") public Object createJudicNo(@RequestParam(value = "custId") String custId) { try { if (JudicNoUtils.JUDIC_NO_FALG){ int year = DateUtils.getYear(new Date()); String judicNoPrefix = "(" + year + ")司法确认"; String newJudicNo = judicInfoService.getNewJudicNo(judicNoPrefix, custId); if(StringUtils.isBlank(newJudicNo)){ newJudicNo = "0"; } String numStr = newJudicNo.replace(judicNoPrefix, "").replace("号", ""); int num = Integer.parseInt(numStr); JudicNoUtils.JUDIC_NO_SIGN = num; JudicNoUtils.JUDIC_NO_FALG = false; } return ReturnSucUtils.getRepInfo(JudicNoUtils.getJudicNo()); } catch (Exception e) { return ReturnFailUtils.getRepInfo(); } } /** * 从startNo(包括startNo)开始生成新的司法确认号 * @url {ctx}/api/client/mediateUtils/setJudicByStartNo * @return Object */ @GetMapping("/setJudicByStartNo") public Object setJudicByStartNo(@RequestParam(value = "startNo") int startNo) { try { JudicNoUtils.JUDIC_NO_SIGN = startNo-1; JudicNoUtils.JUDIC_NO_FALG = false; return ReturnSucUtils.getRepInfo(); } catch (Exception e) { return ReturnFailUtils.getRepInfo(); } } }