package com.product.contract.service;
|
|
import com.product.common.lang.StringUtils;
|
import com.product.contract.config.CmnConst;
|
import com.product.contract.service.ide.ITaskInfoService;
|
import com.product.core.dao.BaseDao;
|
import com.product.core.entity.DataTableEntity;
|
import com.product.core.entity.FieldSetEntity;
|
import com.product.core.exception.BaseException;
|
import com.product.core.permission.PermissionService;
|
import com.product.core.service.support.AbstractBaseService;
|
import com.product.core.service.support.QueryFilterService;
|
import com.product.core.spring.context.SpringMVCContextHolder;
|
import com.product.core.transfer.Transactional;
|
import com.product.util.BaseUtil;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Component;
|
|
import java.util.Date;
|
/**
|
* Copyright LX
|
*
|
* @Title: TaskInfoService
|
* @Project: product-server
|
* @date: 2021-11-25 10:49
|
* @author: ZhouJie
|
* @Description: 任务分配信息
|
*/
|
@Component
|
public class TaskInfoService extends AbstractBaseService implements ITaskInfoService {
|
@Autowired
|
public BaseDao baseDao;
|
@Autowired
|
PermissionService permissionService;
|
@Autowired
|
QueryFilterService queryFilterService;
|
|
/**
|
* 保存任务分配信息
|
* @param fs
|
* @return
|
* @throws BaseException
|
*/
|
@Override
|
@Transactional
|
public String saveTaskInfo(FieldSetEntity fs) throws BaseException {
|
if(StringUtils.isEmpty(fs.getString(CmnConst.UUID))){
|
fs.setValue("org_level_uuid", SpringMVCContextHolder.getCurrentUser().getOrg_level_uuid());
|
fs.setValue("created_by", SpringMVCContextHolder.getCurrentUser().getUser_id());
|
fs.setValue("created_utc_datetime",new Date());
|
String uuid = baseDao.add(fs,true);
|
DataTableEntity dt = fs.getSubDataTable("product_project_task_allocation_sub");
|
if(dt!=null){
|
for (int i = 0; i < dt.getRows(); i++) {
|
FieldSetEntity fsub = dt.getFieldSetEntity(i);
|
FieldSetEntity fss = new FieldSetEntity();
|
fss.setTableName(CmnConst.LX_PROJECT_TASK_PROGRESS);
|
fss.setValue("task_sub_uuid",fsub.getUUID());
|
fss.setValue("project_name", fsub.getValue("project_uuid"));
|
fss.setValue("task_name",fsub.getString("job_content"));
|
fss.setValue("plan_start_time",fsub.getString("plan_start_time"));
|
fss.setValue("plan_end_time",fsub.getString("plan_end_time"));
|
fss.setValue("reviewer",fsub.getString("reviewer"));
|
fss.setValue("past_progress",0);
|
fss.setValue("person_liable",fsub.getString("person_liable"));
|
fss.setValue("org_level_uuid",SpringMVCContextHolder.getCurrentUser().getOrg_level_uuid());
|
fss.setValue("created_by", SpringMVCContextHolder.getCurrentUser().getUser_id());
|
fss.setValue("created_utc_datetime",new Date());
|
baseDao.add(fss);
|
}
|
}
|
return uuid;
|
} else {
|
fs.setValue("updated_by", SpringMVCContextHolder.getCurrentUser().getUser_id());
|
fs.setValue("updated_utc_datetime",new Date());
|
baseDao.update(fs);
|
return fs.getString(CmnConst.UUID);
|
}
|
}
|
|
/**
|
* 删除任务分配信息
|
* @param fs
|
* @return
|
* @throws BaseException
|
*/
|
@Override
|
@Transactional
|
public boolean deleteTaskInfo(FieldSetEntity fs) throws BaseException {
|
String uuid = fs.getUUID();
|
DataTableEntity dt = baseDao.listTable(CmnConst.LX_PROJECT_TASK_ALLOCATION_SUB,"task_uuid=?",new Object[]{uuid});
|
if(dt!=null){
|
for (int i = 0; i < dt.getRows(); i++) {
|
FieldSetEntity fss = dt.getFieldSetEntity(i);
|
baseDao.delete(CmnConst.LX_PROJECT_TASK_PROGRESS,"task_sub_uuid=?",new Object[]{fss.getUUID()});
|
}
|
}
|
String[] uuids = uuid.split(",");
|
return baseDao.delete(CmnConst.LX_PROJECT_TASK_ALLOCATION, BaseUtil.buildQuestionMarkFilter(CmnConst.UUID, uuids.length, true), uuids);
|
}
|
|
/**
|
* 获取任务分配列表
|
* @param fs
|
* @return
|
*/
|
public DataTableEntity listTaskInfo(FieldSetEntity fs) {
|
String queryFilter=permissionService.getDataFilter(CmnConst.ORG_LEVEL_UUID);
|
if(StringUtils.isEmpty(queryFilter)) {
|
queryFilter = CmnConst.CREATED_BY + " = " + SpringMVCContextHolder.getCurrentUser().getUser_id();
|
}
|
if(!BaseUtil.dataTableIsEmpty(fs.getSubDataTable("systemSeniorQueryString"))){
|
queryFilter = queryFilter +" AND "+ queryFilterService.getQueryFilter(fs);
|
}
|
String filter = "";
|
if(fs.getString("filter") != null){
|
filter += fs.getString("filter") + " AND " + queryFilter;
|
}else{
|
filter += queryFilter;
|
}
|
DataTableEntity dt = baseDao.listTable(CmnConst.LX_PROJECT_TASK_ALLOCATION,filter,new Object[]{},null,null,fs.getInteger(CmnConst.PAGESIZE), fs.getInteger(CmnConst.CPAGE));
|
baseDao.loadPromptData(dt);
|
return dt;
|
}
|
|
/**
|
* 任务分配详情查询
|
* @param fs
|
* @return
|
* @throws BaseException
|
*/
|
public FieldSetEntity getTaskInfo(FieldSetEntity fs) throws BaseException {
|
return baseDao.getFieldSetEntity(CmnConst.LX_PROJECT_TASK_ALLOCATION,fs.getUUID(),true);
|
}
|
|
|
|
}
|