20251030 sql提交
This commit is contained in:
@@ -0,0 +1,127 @@
|
||||
|
||||
package com.jeelowcode.module.biz.controller;
|
||||
|
||||
import cn.hutool.json.JSONObject;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
||||
import com.jeelowcode.core.framework.controller.BaseController;
|
||||
import com.jeelowcode.core.framework.service.IFormService;
|
||||
import com.jeelowcode.framework.exception.JeeLowCodeException;
|
||||
import com.jeelowcode.framework.global.JeeLowCodeBaseConstant;
|
||||
import com.jeelowcode.framework.tenant.annotation.JeeLowCodeTenantIgnore;
|
||||
import com.jeelowcode.framework.utils.adapter.IJeeLowCodeAdapter;
|
||||
import com.jeelowcode.framework.utils.model.JeeLowCodeUser;
|
||||
import com.jeelowcode.framework.utils.model.ResultDataModel;
|
||||
import com.jeelowcode.framework.utils.tool.CollectionUtil;
|
||||
import com.jeelowcode.module.biz.service.IExamPlanService;
|
||||
import com.jeelowcode.module.biz.service.IWorkItemService;
|
||||
import com.jeelowcode.tool.framework.common.pojo.CommonResult;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.AllArgsConstructor;
|
||||
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.RestController;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.jeelowcode.tool.framework.common.pojo.CommonResult.success;
|
||||
|
||||
/**
|
||||
* @author LIFY
|
||||
* @create 2025-09-13
|
||||
* @dedescription:
|
||||
*/
|
||||
@JeeLowCodeTenantIgnore
|
||||
@Tag(name = "低代码框架 - 个性化接口")
|
||||
@RestController
|
||||
@AllArgsConstructor
|
||||
@RequestMapping(JeeLowCodeBaseConstant.REQUEST_URL_START +"/itemIssus")
|
||||
public class ItemIssusController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
private IWorkItemService iWorkItemService;
|
||||
|
||||
private final IJeeLowCodeAdapter jeeLowCodeAdapter;
|
||||
|
||||
@Autowired
|
||||
private IFormService dbFormService;
|
||||
|
||||
@GetMapping({"/addResult"})
|
||||
@ApiOperationSupport(order = 1)
|
||||
@Operation(summary = "下发考试记录数据")
|
||||
public CommonResult<String> savePlanIssus(String tableId, String ids, String userIds) {
|
||||
String[] idArr = ids.split(",");
|
||||
String[] userIdArr = userIds.split(",");
|
||||
if (Objects.isNull(idArr) || idArr.length == 0 || Objects.isNull(userIdArr) || userIdArr.length == 0) {
|
||||
throw new JeeLowCodeException("缺少必要参数");
|
||||
}
|
||||
|
||||
String tableName="lc_item_result";
|
||||
Long dbFormId = dbFormService.getDbFormIdByTableName(tableName);
|
||||
List<Long> userIdList = Arrays.stream(userIdArr).map(Long::parseLong).collect(Collectors.toList());
|
||||
IPage<JeeLowCodeUser> userPage = (IPage<JeeLowCodeUser>) jeeLowCodeAdapter.getUserPageByUserIds(1, 10000, userIdList);
|
||||
|
||||
if (CollectionUtil.isNotEmpty(userPage.getRecords())) {
|
||||
for (int i = 0; i < idArr.length; i++) {
|
||||
ResultDataModel resultDataModel = super.getDataDetail(Long.parseLong(tableId), Long.valueOf(idArr[i]), new HashMap<String, Object>());
|
||||
if (CollectionUtil.isNotEmpty(resultDataModel.getRecords())) {
|
||||
if (resultDataModel.getRecords().get(0).containsKey("jeelowcode_subtable_data")) {
|
||||
HashMap<String, Object> details = (HashMap<String, Object>) resultDataModel.getRecords().get(0).get("jeelowcode_subtable_data");
|
||||
if (details.containsKey("lc_work_item_issus")) {
|
||||
List<HashMap<String, Object>> detail = (List<HashMap<String, Object>>) details.get("lc_work_item_issus");
|
||||
|
||||
List<JSONObject> tasks = new ArrayList<JSONObject>();
|
||||
if(Objects.isNull(detail)) {
|
||||
detail = new ArrayList<HashMap<String, Object>>();
|
||||
}
|
||||
for (JeeLowCodeUser dbuser : userPage.getRecords()) {
|
||||
HashMap<String, Object> user = CollectionUtil.isEmpty(detail) ? null : detail.stream().filter(t -> t.containsKey("userId") && t.get("userId").toString().equals(dbuser.getUserId())).findFirst().orElse(null);
|
||||
if (Objects.isNull(user)) {
|
||||
HashMap<String, Object> newUser = new HashMap<>();
|
||||
newUser.put("chargeId", dbuser.getUserId());
|
||||
newUser.put("chargeName", dbuser.getNickName());
|
||||
newUser.put("deptId", dbuser.getDeptId());
|
||||
newUser.put("deptName", dbuser.getDeptName());
|
||||
newUser.put("workItemId", Long.valueOf(idArr[i]));
|
||||
detail.add(newUser);
|
||||
|
||||
// 组装任务
|
||||
//查询待分发单据 workItemId 从 lc_work_item 根据Id查询数据
|
||||
Map<String, Object> examPlan = iWorkItemService.getWorkItemById(Long.valueOf(idArr[i]));
|
||||
|
||||
HashMap<String, Object> newRecord = new HashMap<>();
|
||||
|
||||
newRecord.put("chargeId", dbuser.getUserId());
|
||||
newRecord.put("chargeName", dbuser.getNickName());
|
||||
newRecord.put("deptName", dbuser.getDeptName());
|
||||
newRecord.put("deptId", dbuser.getDeptId());
|
||||
|
||||
newRecord.put("eDate", examPlan.get("edate"));
|
||||
newRecord.put("resultStatus", 1);
|
||||
newRecord.put("sDate", examPlan.get("sdate"));
|
||||
newRecord.put("itemName", examPlan.get("itemname"));
|
||||
newRecord.put("itemContext", examPlan.get("itemcontext"));
|
||||
newRecord.put("workItemId", examPlan.get("id"));
|
||||
newRecord.put("examRecordStatus", 1);
|
||||
|
||||
newRecord.put("billNo", "SXJG" + System.currentTimeMillis());
|
||||
tasks.add(JSONUtil.parseObj(newRecord));
|
||||
}
|
||||
}
|
||||
resultDataModel.getRecords().get(0).put("lc_work_item_issus", detail);
|
||||
super.editJsonData(Long.valueOf(tableId), JSONUtil.parseObj(resultDataModel.getRecords().get(0)));
|
||||
|
||||
super.addJsonData(dbFormId, tasks);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return success("下发成功");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -38,7 +38,7 @@ public class OutSidePersonController extends BaseController {
|
||||
@ApiOperationSupport(order = 5)
|
||||
@Operation(summary = "引入外协人员")
|
||||
public CommonResult<String> importOutside(String tableId,String ids) {
|
||||
String[] idArr = ids.split(Pattern.quote("|"));
|
||||
String[] idArr = ids.split(Pattern.quote(","));
|
||||
if (Objects.isNull(idArr) || idArr.length == 0) {
|
||||
throw new JeeLowCodeException("缺少必要参数");
|
||||
}
|
||||
|
||||
@@ -0,0 +1,89 @@
|
||||
package com.jeelowcode.module.biz.enhance;
|
||||
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.jeelowcode.core.framework.config.aspect.enhance.model.EnhanceContext;
|
||||
import com.jeelowcode.core.framework.config.aspect.enhance.plugin.AfterAdvicePlugin;
|
||||
import com.jeelowcode.core.framework.controller.BaseController;
|
||||
import com.jeelowcode.core.framework.service.IFormService;
|
||||
import com.jeelowcode.framework.utils.tool.NumberUtil;
|
||||
import com.jeelowcode.module.biz.service.IWorkItemService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 删除前校验
|
||||
*/
|
||||
@Slf4j
|
||||
@Component("afterItemResultEditEnhance")
|
||||
public class AfterItemResultEditEnhance extends BaseController implements AfterAdvicePlugin {
|
||||
|
||||
@Autowired
|
||||
private IWorkItemService iWorkItemService;
|
||||
|
||||
@Autowired
|
||||
private IFormService dbFormService;
|
||||
|
||||
private static AfterItemResultEditEnhance ADTE;
|
||||
|
||||
@PostConstruct
|
||||
public void init(){
|
||||
ADTE = this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(EnhanceContext enhanceContext) {
|
||||
|
||||
Map<String, Object> params = enhanceContext.getParam().getParams();
|
||||
if(!params.containsKey("id")){
|
||||
return;
|
||||
}
|
||||
|
||||
Long id = NumberUtil.toLong(params.get("id").toString());
|
||||
String taskTableName="lc_item_result";
|
||||
String planTableName="lc_work_item";
|
||||
Long taskFormId = ADTE.dbFormService.getDbFormIdByTableName(taskTableName);
|
||||
Long planFormId = ADTE.dbFormService.getDbFormIdByTableName(planTableName);
|
||||
|
||||
// 获取当前任务
|
||||
Map<String, Object> currentTask=ADTE.iWorkItemService.getItemResultById(id);
|
||||
|
||||
if(!Objects.isNull(currentTask)){
|
||||
// 根据当前任务 workItemId 获取当前计划下所有任务
|
||||
Long workItemId = NumberUtil.toLong(currentTask.get("workitemid").toString());
|
||||
List<Map<String, Object>> allTasks=ADTE.iWorkItemService.getItemResultByItemId(workItemId);
|
||||
// 根据所以任务状态 设置 计划状态
|
||||
if(!allTasks.isEmpty()){
|
||||
Integer allTaskNum=allTasks.size();
|
||||
Integer doneTaskNum=0;
|
||||
Integer itemStatus =1;
|
||||
for(Map<String, Object> task:allTasks){
|
||||
if (!Objects.isNull(task))
|
||||
{
|
||||
if(task.get("resultstatus").equals("1")){
|
||||
doneTaskNum++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(doneTaskNum.equals(allTaskNum))
|
||||
{
|
||||
itemStatus =3; //已完成
|
||||
}else if(doneTaskNum>0){
|
||||
itemStatus =2; //进行中
|
||||
}
|
||||
|
||||
// 更新 计划状态
|
||||
Map<String, Object> currentItem =ADTE.iWorkItemService.getWorkItemById(workItemId);
|
||||
currentItem.put("itemSattus", itemStatus);
|
||||
super.editJsonData(planFormId, JSONUtil.parseObj(currentItem));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
|
||||
package com.jeelowcode.module.biz.service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Demo相关
|
||||
*/
|
||||
public interface IWorkItemService {
|
||||
|
||||
Map<String, Object> getWorkItemById(long id);
|
||||
|
||||
Map<String, Object> getItemResultById(long id);
|
||||
|
||||
List<Map<String, Object>> getItemResultByItemId(Long ExamPlanId);
|
||||
}
|
||||
@@ -43,6 +43,7 @@ public class DrillPlanServiceImpl implements IDrillPlanService {
|
||||
wrapper.setTableName("lc_drill_plan_cycle");
|
||||
wrapper.setWhere(where->{
|
||||
where.eq("drill_plan_id",drillPlanId);
|
||||
where.eq("is_deleted",0);
|
||||
});
|
||||
List<Map<String, Object>> dataMapList = sqlService.getDataListByPlus(wrapper);
|
||||
return dataMapList;
|
||||
|
||||
@@ -53,6 +53,7 @@ public class ExamPlanServiceImpl implements IExamPlanService {
|
||||
wrapper.setTableName("lc_exam_record");
|
||||
wrapper.setWhere(where->{
|
||||
where.eq("examId",examPlanId);
|
||||
where.eq("is_deleted",0);
|
||||
});
|
||||
List<Map<String, Object>> dataMapList = sqlService.getDataListByPlus(wrapper);
|
||||
return dataMapList;
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
|
||||
package com.jeelowcode.module.biz.service.impl;
|
||||
|
||||
import com.jeelowcode.core.framework.service.IFrameSqlService;
|
||||
import com.jeelowcode.framework.plus.SqlHelper;
|
||||
import com.jeelowcode.framework.plus.build.buildmodel.wrapper.SqlInfoQueryWrapper;
|
||||
import com.jeelowcode.module.biz.service.IExamPlanService;
|
||||
import com.jeelowcode.module.biz.service.IWorkItemService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
* demo
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class WorkItemServiceImpl implements IWorkItemService {
|
||||
|
||||
|
||||
@Autowired
|
||||
private IFrameSqlService sqlService;
|
||||
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getWorkItemById(long id) {
|
||||
SqlInfoQueryWrapper.Wrapper wrapper = SqlHelper.getQueryWrapper();
|
||||
wrapper.setTableName("lc_work_item");
|
||||
wrapper.setWhere(where->{
|
||||
where.eq("id",id);
|
||||
});
|
||||
Map<String, Object> dataMap = sqlService.getDataOneByPlus(wrapper);
|
||||
return dataMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getItemResultById(long id) {
|
||||
SqlInfoQueryWrapper.Wrapper wrapper = SqlHelper.getQueryWrapper();
|
||||
wrapper.setTableName("lc_item_result");
|
||||
wrapper.setWhere(where->{
|
||||
where.eq("id",id);
|
||||
});
|
||||
Map<String, Object> dataMap = sqlService.getDataOneByPlus(wrapper);
|
||||
return dataMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Map<String, Object>> getItemResultByItemId(Long workItemId) {
|
||||
SqlInfoQueryWrapper.Wrapper wrapper = SqlHelper.getQueryWrapper();
|
||||
wrapper.setTableName("lc_item_result");
|
||||
wrapper.setWhere(where->{
|
||||
where.eq("workItemId",workItemId);
|
||||
where.eq("is_deleted",0);
|
||||
});
|
||||
List<Map<String, Object>> dataMapList = sqlService.getDataListByPlus(wrapper);
|
||||
return dataMapList;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user