package com.product.contract.service;
|
|
import com.product.common.lang.StringUtils;
|
import com.product.contract.config.CmnConst;
|
import com.product.contract.service.ide.IAwardedService;
|
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.tool.flow.service.FlowService;
|
import com.product.util.BaseUtil;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Component;
|
|
import java.util.Date;
|
|
/**
|
* Copyright LX
|
*
|
* @Title: AwardedService
|
* @Project: product-server
|
* @date: 2021-06-18 14:03
|
* @author: ZhouJie
|
* @Description: 中标项目任务
|
*/
|
@Component
|
public class AwardedService extends AbstractBaseService implements IAwardedService {
|
@Autowired
|
public BaseDao baseDao;
|
@Autowired
|
PermissionService permissionService;
|
@Autowired
|
QueryFilterService queryFilterService;
|
@Autowired
|
FlowService flowService;
|
|
/**
|
* 中标项目任务保存
|
* @param fs
|
* @return
|
*/
|
@Override
|
@Transactional
|
public String saveAwarded(FieldSetEntity fs) {
|
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);
|
FieldSetEntity fss = new FieldSetEntity();
|
fss.setTableName(fs.getTableName());
|
fss.setValue("flow_uuid","a561ea69-35f2-4de8-abb4-836ab8d3e99c");
|
fss.setValue("type_code","db748af3-716c-4902-a901-7ad66b76919a");
|
fss.setValue("~table~",fs.getTableName());
|
fss.setValue("accepters",fs.getString("assignment_person"));
|
fss.setValue("uuid",fs.getString("uuid"));
|
fss.setValue("flow_title","中标项目任务流程");
|
flowService.autoSendFlow(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
|
* @return
|
*/
|
public String autoLaunch(String uuid) {
|
FieldSetEntity fs = baseDao.getFieldSetEntity("product_project_awarded",uuid,true);
|
FieldSetEntity fsfunction = null;
|
FieldSetEntity fstb = null;
|
FieldSetEntity fsflow = null;
|
FieldSetEntity fsOth = new FieldSetEntity();
|
String uuids = "";
|
FieldSetEntity fss = new FieldSetEntity();
|
FieldSetEntity fsub = baseDao.getFieldSetEntityByFilter("product_project_awarded_sub","contract_awarded_uuid=?",new Object[]{uuid},false);
|
if(fsub!=null){
|
fsfunction = baseDao.getFieldSetEntity("product_sys_functions",fsub.getString("task_item"),false);
|
}
|
if(fsfunction!=null){
|
fstb = baseDao.getFieldSetEntity("product_sys_datamodel_table",fsfunction.getString("table_uuid"),false);
|
}
|
if(fstb!=null){
|
fss.setTableName(fstb.getString("table_name"));
|
fss.setValue("~table~",fstb.getString("table_name"));
|
fss.setValue("accepters",fsub.getString("user_name"));
|
fsflow = baseDao.getFieldSetEntityByFilter("product_sys_flow_model","table_uuid=? and org_level_uuid is not null",new Object[]{fstb.getString("table_name")},false);
|
}
|
if(fsflow!=null){
|
fss.setValue("flow_uuid",fsflow.getUUID());
|
fss.setValue("type_code",fsflow.getString("type_code"));
|
fss.setValue("flow_title",fsflow.getString("title"));
|
}
|
fsOth.setTableName(fstb.getString("table_name"));
|
fsOth.setValue("org_level_uuid", fs.getString("org_level_uuid"));
|
fsOth.setValue("created_by", fs.getString("created_by"));
|
fsOth.setValue("created_utc_datetime",new Date());
|
if("product_project_performance_bond".equals(fstb.getString("table_name"))){
|
fsOth.setValue("project_uuid",fs.getString("project_name"));
|
fsOth.setValue("owner",fs.getString("owner_name"));
|
fsOth.setValue("business_type",fs.getString("business_type"));
|
fsOth.setValue("project_nature",fs.getString("project_nature"));
|
}
|
if("product_project_contract_info".equals(fstb.getString("table_name"))){
|
fsOth.setValue("project_uuid",fs.getString("project_name"));
|
fsOth.setValue("owner",fs.getString("owner_name"));
|
fsOth.setValue("business_type",fs.getString("business_type"));
|
}
|
uuids = baseDao.add(fsOth);
|
fss.setValue("uuid",fsOth.getString("uuid"));
|
flowService.autoSendFlow(fss);
|
return uuids;
|
}
|
|
|
/**
|
* 中标项目任务删除
|
* @param fs
|
* @return
|
*/
|
@Override
|
@Transactional
|
public boolean deleteAwarded(FieldSetEntity fs) {
|
String uuid = fs.getUUID();
|
String[] uuids = uuid.split(",");
|
return baseDao.delete(CmnConst.LX_PROJECT_AWARDED, BaseUtil.buildQuestionMarkFilter(CmnConst.UUID, uuids.length, true), uuids);
|
}
|
|
/**
|
* 获取中标项目任务列表
|
* @param fs
|
* @return
|
*/
|
public DataTableEntity listAwarded(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 = fs.getString("filter") + " AND " + queryFilter;
|
DataTableEntity dt = baseDao.listTable(CmnConst.LX_PROJECT_AWARDED,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 findAwaded(FieldSetEntity fs) throws BaseException {
|
return baseDao.getFieldSetEntity(CmnConst.LX_PROJECT_AWARDED,fs.getUUID(),true);
|
}
|
|
|
|
|
}
|