|
|
@ -23,11 +23,14 @@ import org.dromara.common.log.annotation.Log; |
|
|
import org.dromara.common.log.enums.BusinessType; |
|
|
import org.dromara.common.log.enums.BusinessType; |
|
|
import org.dromara.system.domain.vo.SysDeptVo; |
|
|
import org.dromara.system.domain.vo.SysDeptVo; |
|
|
import org.dromara.system.service.ISysDeptService; |
|
|
import org.dromara.system.service.ISysDeptService; |
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
import org.springframework.validation.annotation.Validated; |
|
|
import org.springframework.validation.annotation.Validated; |
|
|
import org.springframework.web.bind.annotation.*; |
|
|
import org.springframework.web.bind.annotation.*; |
|
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
import java.util.ArrayList; |
|
|
import java.util.List; |
|
|
import java.util.List; |
|
|
|
|
|
import java.util.Map; |
|
|
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
@Slf4j |
|
|
@Slf4j |
|
|
@SaIgnore |
|
|
@SaIgnore |
|
|
@ -244,6 +247,7 @@ public class LongGangInterfaceController { |
|
|
*/ |
|
|
*/ |
|
|
@SaIgnore |
|
|
@SaIgnore |
|
|
@RepeatSubmit() |
|
|
@RepeatSubmit() |
|
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
@Log(title = "外部接口-绑定计划", businessType = BusinessType.OTHER) |
|
|
@Log(title = "外部接口-绑定计划", businessType = BusinessType.OTHER) |
|
|
@PostMapping("/plan/bindPlan") |
|
|
@PostMapping("/plan/bindPlan") |
|
|
public R<Void> bindPlan( |
|
|
public R<Void> bindPlan( |
|
|
@ -261,34 +265,24 @@ public class LongGangInterfaceController { |
|
|
return R.fail("新计划流水号不能为空"); |
|
|
return R.fail("新计划流水号不能为空"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// ========== 3. 批量查询绑定列表中的计划,校验是否均存在 ==========
|
|
|
// ========== 3. 逐个查询绑定计划(outSerialNo + channelNo 唯一确定一条计划) ==========
|
|
|
List<String> bindOutSerialNos = bo.getBindOutSerialNos(); |
|
|
List<String> bindOutSerialNos = bo.getBindOutSerialNos(); |
|
|
List<String> missingSerialNos = new ArrayList<>(); |
|
|
List<String> missingSerialNos = new ArrayList<>(); |
|
|
|
|
|
List<EfcodeCpPlanVo> boundPlans = new ArrayList<>(); |
|
|
|
|
|
List<String> oldTaskIds = new ArrayList<>(); |
|
|
for (String serialNo : bindOutSerialNos) { |
|
|
for (String serialNo : bindOutSerialNos) { |
|
|
EfcodeCpPlanBo queryBo = new EfcodeCpPlanBo(); |
|
|
EfcodeCpPlanVo plan = outEfcodeCpPlanService.queryByOutSerialNoAndChannelNo(serialNo, channelNo); |
|
|
queryBo.setOutSerialNo(serialNo); |
|
|
if (plan == null) { |
|
|
queryBo.setChannelNo(channelNo); |
|
|
|
|
|
List<EfcodeCpPlanVo> found = outEfcodeCpPlanService.queryList(queryBo); |
|
|
|
|
|
if (found.isEmpty()) { |
|
|
|
|
|
missingSerialNos.add(serialNo); |
|
|
missingSerialNos.add(serialNo); |
|
|
|
|
|
} else { |
|
|
|
|
|
boundPlans.add(plan); |
|
|
|
|
|
oldTaskIds.add(plan.getTaskId()); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
if (!missingSerialNos.isEmpty()) { |
|
|
if (!missingSerialNos.isEmpty()) { |
|
|
return R.fail("以下计划流水号不存在: " + String.join(", ", missingSerialNos)); |
|
|
return R.fail("以下计划流水号不存在: " + String.join(", ", missingSerialNos)); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// ========== 4. 查询绑定计划,取第一条的执法单位信息 ==========
|
|
|
|
|
|
List<EfcodeCpPlanVo> boundPlans = new ArrayList<>(); |
|
|
|
|
|
for (String serialNo : bindOutSerialNos) { |
|
|
|
|
|
EfcodeCpPlanBo q = new EfcodeCpPlanBo(); |
|
|
|
|
|
q.setOutSerialNo(serialNo); |
|
|
|
|
|
q.setChannelNo(channelNo); |
|
|
|
|
|
boundPlans.addAll(outEfcodeCpPlanService.queryList(q)); |
|
|
|
|
|
} |
|
|
|
|
|
if (boundPlans.isEmpty()) { |
|
|
|
|
|
return R.fail("绑定计划不存在"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// ========== 5. 直接生成新任务(基于企业信息 + 绑定计划的执法单位) ==========
|
|
|
// ========== 5. 直接生成新任务(基于企业信息 + 绑定计划的执法单位) ==========
|
|
|
EfcodeCpTaskBo taskBo = new EfcodeCpTaskBo(); |
|
|
EfcodeCpTaskBo taskBo = new EfcodeCpTaskBo(); |
|
|
taskBo.setTaskName(bo.getEnterpriseName() + " - 执法检查任务"); |
|
|
taskBo.setTaskName(bo.getEnterpriseName() + " - 执法检查任务"); |
|
|
@ -298,14 +292,21 @@ public class LongGangInterfaceController { |
|
|
outEfcodeCpTaskService.insertByBo(taskBo); |
|
|
outEfcodeCpTaskService.insertByBo(taskBo); |
|
|
String taskId = taskBo.getId(); |
|
|
String taskId = taskBo.getId(); |
|
|
|
|
|
|
|
|
// ========== 6. 将新任务ID回写到所有绑定的计划 ==========
|
|
|
// ========== 7. 将新任务ID批量回写到所有绑定的计划(轻量级更新,不触发 checkDuplicate/syncPlanUsers) ==========
|
|
|
EfcodeCpPlanBo taskUpdateBo = new EfcodeCpPlanBo(); |
|
|
List<String> boundPlanIds = boundPlans.stream() |
|
|
taskUpdateBo.setTaskId(taskId); |
|
|
.map(EfcodeCpPlanVo::getId) |
|
|
taskUpdateBo.setIsUnion(1L); |
|
|
.collect(Collectors.toList()); |
|
|
taskUpdateBo.setReserveStatus(3L); |
|
|
outEfcodeCpPlanService.updateTaskBinding(boundPlanIds, taskId, 1L, 3L); |
|
|
for (EfcodeCpPlanVo boundPlan : boundPlans) { |
|
|
|
|
|
taskUpdateBo.setId(boundPlan.getId()); |
|
|
// ========== 8. 检查旧任务是否还有其他计划关联,若无则删除 ==========
|
|
|
outEfcodeCpPlanService.updateByBo(taskUpdateBo); |
|
|
for (String oldTaskId : oldTaskIds) { |
|
|
|
|
|
EfcodeCpPlanBo checkQuery = new EfcodeCpPlanBo(); |
|
|
|
|
|
checkQuery.setTaskId(oldTaskId); |
|
|
|
|
|
List<EfcodeCpPlanVo> remainingPlans = outEfcodeCpPlanService.queryList(checkQuery); |
|
|
|
|
|
if (remainingPlans.isEmpty()) { |
|
|
|
|
|
outEfcodeCpTaskService.deleteWithValidByIds(List.of(oldTaskId), false); |
|
|
|
|
|
log.info("[外部接口] 绑定计划-旧任务无其他计划关联,已删除, oldTaskId={}", oldTaskId); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
log.info("[外部接口] 绑定计划, appKey={}, channelNo={}, outSerialNo={}, taskId={}, bindCount={}, enterprise={}", |
|
|
log.info("[外部接口] 绑定计划, appKey={}, channelNo={}, outSerialNo={}, taskId={}, bindCount={}, enterprise={}", |
|
|
|