| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197 |
- package cn.com.goldenwater.dcproj.controller.tacplan;
- import cn.com.goldenwater.dcproj.dao.OlBisInspOrgDao;
- import cn.com.goldenwater.dcproj.dto.TacProvincePlanDictDto;
- import cn.com.goldenwater.dcproj.model.OlBisInspOrg;
- import cn.com.goldenwater.dcproj.model.TacProvincePlanDict;
- import cn.com.goldenwater.dcproj.model.TacProvincePlanProcess;
- import cn.com.goldenwater.dcproj.param.TacProvincePlanDictParam;
- import cn.com.goldenwater.dcproj.param.TacProvincePlanProcessParam;
- import cn.com.goldenwater.dcproj.service.TacProvincePlanDictService;
- import cn.com.goldenwater.core.web.BaseController;
- import cn.com.goldenwater.core.web.BaseResponse;
- import cn.com.goldenwater.dcproj.service.TacProvincePlanProcessService;
- import cn.com.goldenwater.target.CheckException;
- import cn.com.goldenwater.id.util.UuidUtil;
- import io.swagger.annotations.Api;
- import io.swagger.annotations.ApiOperation;
- import io.swagger.annotations.ApiParam;
- import org.apache.commons.lang3.StringUtils;
- import com.github.pagehelper.PageInfo;
- import org.slf4j.Logger;
- import org.slf4j.LoggerFactory;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.web.bind.annotation.PathVariable;
- import org.springframework.web.bind.annotation.RequestBody;
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.bind.annotation.RequestMethod;
- import org.springframework.web.bind.annotation.RestController;
- import java.util.ArrayList;
- import java.util.Date;
- import java.util.List;
- /**
- * @author lune
- * @date 2020-5-28
- */
- @Api(value = "TAC 省级稽察流程字典管理",tags="TAC 省级稽察流程字典管理")
- @RestController
- @RequestMapping("/tac/province/plan/dict")
- public class TacProvincePlanDictController extends BaseController {
- private Logger logger = LoggerFactory.getLogger(getClass());
- @Autowired
- private TacProvincePlanDictService tacProvincePlanDictService;
- @Autowired
- private OlBisInspOrgDao olBisInspOrgDao;
- @Autowired
- private TacProvincePlanProcessService tacProvincePlanProcessService;
- @ApiOperation(value = "添加/修改省级稽察流程字典")
- @RequestMapping(value = "", method = RequestMethod.POST)
- public BaseResponse<TacProvincePlanDict> insert(@ApiParam(name = "tacProvincePlanDict", value = "TacProvincePlanDict", required = true) @RequestBody TacProvincePlanDict tacProvincePlanDict) {
- OlBisInspOrg olBisInspOrg=olBisInspOrgDao.get(getCurrentOrgId());
- tacProvincePlanDict.setOrgId(getCurrentOrgId());
- tacProvincePlanDict.setPersId(getCurrentPersId());
- tacProvincePlanDict.setUptm(new Date());
- tacProvincePlanDict.setAdCode(olBisInspOrg.getRlcode());
- tacProvincePlanDict.setOrgName(olBisInspOrg.getOrgNm());
- TacProvincePlanDictParam planDictParam=new TacProvincePlanDictParam();
- planDictParam.setOrgId(getCurrentOrgId());
- planDictParam.setAdCode(olBisInspOrg.getRlcode());
- if(StringUtils.isBlank(tacProvincePlanDict.getId())) {
- int nextNo=tacProvincePlanDictService.getMaxNextNo(planDictParam)+1;
- String uuid = UuidUtil.uuid(); // 生成uuid
- tacProvincePlanDict.setId(uuid);
- tacProvincePlanDict.setUptm(new Date());
- tacProvincePlanDict.setSortNo(nextNo);
- tacProvincePlanDict.setDataStat("0");
- tacProvincePlanDict.setState("0");
- tacProvincePlanDictService.insert(tacProvincePlanDict);
- }else{
- TacProvincePlanDict provincePlanDict=tacProvincePlanDictService.get(tacProvincePlanDict.getId());
- //前端传入当前阶段排序值与数据库中当前阶段排序值对比,若一致,则无需查重,若不一致,则查询是否重复
- if(tacProvincePlanDict.getSortNo()!=provincePlanDict.getSortNo()){
- planDictParam.setSortNo(tacProvincePlanDict.getSortNo());
- provincePlanDict=tacProvincePlanDictService.getBy(planDictParam);
- if(provincePlanDict!=null){
- return buildFailResponse("序号不能重复!!");
- }
- }
- tacProvincePlanDictService.update(tacProvincePlanDict);
- }
- return buildSuccessResponse(tacProvincePlanDict);
- }
- @ApiOperation(value = "根据ID删除省级稽察流程字典")
- @RequestMapping(value = "/del/{id}", method = RequestMethod.GET)
- public BaseResponse delete(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) {
- int ret = tacProvincePlanDictService.delete(id);
- return buildSuccessResponse();
- }
- @ApiOperation(value = "根据ID获取省级稽察流程字典(单表)")
- @RequestMapping(value = "/{id}", method = RequestMethod.GET)
- public BaseResponse<TacProvincePlanDict> get(@ApiParam(name = "id", value = "id", required = true) @PathVariable String id) {
- TacProvincePlanDict tacProvincePlanDict = tacProvincePlanDictService.get(id);
- return buildSuccessResponse(tacProvincePlanDict);
- }
- @ApiOperation(value = "根据ID获取省级稽察流程字典(单表,包含下一步列表)")
- @RequestMapping(value = "/edit", method = RequestMethod.GET)
- public BaseResponse<TacProvincePlanDictDto> edit() {
- OlBisInspOrg olBisInspOrg=olBisInspOrgDao.get(getCurrentOrgId());
- TacProvincePlanDictDto tacProvincePlanDictDto = new TacProvincePlanDictDto();
- TacProvincePlanDictParam tacProvincePlanDictParam=new TacProvincePlanDictParam();
- tacProvincePlanDictParam.setOrgId(getCurrentOrgId());
- int sortNo=tacProvincePlanProcessService.getMaxSortNo(getCurrentOrgId(),olBisInspOrg.getRlcode());
- if(sortNo==0){//初始数据
- TacProvincePlanDict tacProvincePlanDict=new TacProvincePlanDict();
- tacProvincePlanDict.setId("0");
- tacProvincePlanDict.setProcessName("开始");
- List<TacProvincePlanDict> tacProvincePlanDictList=new ArrayList<>();
- tacProvincePlanDictList.add(tacProvincePlanDict);
- tacProvincePlanDictDto.setPrvTacProvincePlanDictList(tacProvincePlanDictList);
- tacProvincePlanDictDto.setNowTacProvincePlanDictList(tacProvincePlanDictService.findList(tacProvincePlanDictParam));
- tacProvincePlanDictDto.setNextAddList(notAddList(tacProvincePlanDictParam));
- return buildSuccessResponse(tacProvincePlanDictDto);
- }else {//存在节点
- TacProvincePlanProcessParam tacProvincePlanProcessParam = new TacProvincePlanProcessParam();
- tacProvincePlanProcessParam.setSortNo(sortNo);
- tacProvincePlanProcessParam.setOrgId(getCurrentOrgId());
- tacProvincePlanProcessParam.setAdCode(olBisInspOrg.getRlcode());
- TacProvincePlanProcess tacProvincePlanProcess = tacProvincePlanProcessService.getBy(tacProvincePlanProcessParam);
- if("1".equals(tacProvincePlanProcess.getNextId())){//机构流程已经添加完成
- throw new CheckException("机构流程已经添加完成!!如需更改请前往审核流程编辑末端节点!!");
- }
- if (tacProvincePlanProcess != null) {//添加上级节点
- TacProvincePlanDict tacProvincePlanDict=new TacProvincePlanDict();
- tacProvincePlanDict.setId(tacProvincePlanProcess.getNowId());
- tacProvincePlanDict.setProcessName(tacProvincePlanProcess.getNowStep());
- List<TacProvincePlanDict> tacProvincePlanDictList=new ArrayList<>();
- tacProvincePlanDictList.add(tacProvincePlanDict);
- tacProvincePlanDictDto.setPrvTacProvincePlanDictList(tacProvincePlanDictList);
- tacProvincePlanDictParam.setId(tacProvincePlanProcess.getNextId());
- tacProvincePlanDictDto.setNowTacProvincePlanDictList(tacProvincePlanDictService.findList(tacProvincePlanDictParam));
- tacProvincePlanDictDto.setNextAddList(notAddList(tacProvincePlanDictParam));
- return buildSuccessResponse(tacProvincePlanDictDto);
- }
- }
- return buildFailResponse("数据查询存在问题,请联系管理员!!");
- }
- @ApiOperation(value = "获取省级稽察流程字典(列表所有)")
- @RequestMapping(value = "/list", method = RequestMethod.POST)
- public BaseResponse<List<TacProvincePlanDict>> list(@ApiParam(name = "tacProvincePlanDictParam", value = "tacProvincePlanDictParam", required = true) @RequestBody TacProvincePlanDictParam tacProvincePlanDictParam) {
- if(StringUtils.isBlank(tacProvincePlanDictParam.getOrgId())){
- tacProvincePlanDictParam.setOrgId(getCurrentOrgId());
- }
- List<TacProvincePlanDict> tacProvincePlanDictList = tacProvincePlanDictService.findList(tacProvincePlanDictParam);
- return buildSuccessResponse(tacProvincePlanDictList);
- }
- @ApiOperation(value = "获取省级稽察流程字典(列表所有)")
- @RequestMapping(value = "/noAddlist", method = RequestMethod.POST)
- public BaseResponse<List<TacProvincePlanDict>> noAddlist(@ApiParam(name = "tacProvincePlanDictParam", value = "tacProvincePlanDictParam", required = true) @RequestBody TacProvincePlanDictParam tacProvincePlanDictParam) {
- return buildSuccessResponse(notAddList(tacProvincePlanDictParam));
- }
- private List<TacProvincePlanDict> notAddList(TacProvincePlanDictParam tacProvincePlanDictParam ){
- tacProvincePlanDictParam.setOrgId(getCurrentOrgId());
- TacProvincePlanProcessParam planProcessParam=new TacProvincePlanProcessParam();
- planProcessParam.setOrgId(getCurrentOrgId());
- planProcessParam.setNextId("1");//是否已经结束
- List<TacProvincePlanProcess> planProcesses=tacProvincePlanProcessService.findList(planProcessParam);
- if(planProcesses==null || planProcesses.size()==0){
- List<TacProvincePlanDict> notAddList=tacProvincePlanDictService.findNotAddList(tacProvincePlanDictParam);
- TacProvincePlanDict tacProvincePlanDict=new TacProvincePlanDict();
- tacProvincePlanDict.setId("1");
- tacProvincePlanDict.setProcessName("结束");
- notAddList.add(tacProvincePlanDict);
- return notAddList;
- }
- return null;
- }
- @ApiOperation(value = "获取省级稽察流程字典(列表--分页)")
- @RequestMapping(value = "/page", method = RequestMethod.POST)
- public BaseResponse<PageInfo<TacProvincePlanDict>> page(@ApiParam(name = "tacProvincePlanDictParam", value = "tacProvincePlanDictParam", required = true) @RequestBody TacProvincePlanDictParam tacProvincePlanDictParam) {
- PageInfo<TacProvincePlanDict> tacProvincePlanDictList = tacProvincePlanDictService.findPageInfo(tacProvincePlanDictParam);
- return buildSuccessResponse(tacProvincePlanDictList);
- }
- }
|