zm
2024-07-23 9df5fcf6974977866bd73551e35961f849a625b2
项目立项和项目进度汇报
已添加5个文件
已修改2个文件
409 ■■■■■ 文件已修改
src/main/java/com/product/contract/config/CmnConst.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/product/contract/config/SystemCode.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/product/contract/controller/ProjectBusinessController.java 93 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/product/contract/controller/ProjectScheduleController.java 76 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/product/contract/service/ProjectBusinessService.java 65 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/product/contract/service/ProjectScheduleService.java 156 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/product/contract/service/ide/IProjectBusinessService.java 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/product/contract/config/CmnConst.java
@@ -20,6 +20,11 @@
    public static final String LX_PROJECT_TASK_ALLOCATION = "product_project_task_allocation"; //任务分配表
    public static final String LX_PROJECT_TASK_ALLOCATION_SUB = "product_project_task_allocation_sub"; //任务分配表
    public static final String LX_PROJECT_TASK_PROGRESS = "product_project_task_progress"; //任务进度表
    public static final String PRODUCT_PROJECT_SCHEDULE = "product_project_schedule";//任务进度
    public static final String PRODUCT_PROJECT_BUSINESS = "product_project_business";//项目表
    public static final String PRODUCT_PROJECT_BUSINESS_PLAN = "product_project_business_plan";//项目计划表
    public static final String PRODUCT_PROJECT_MANAGER_DATA_LIST = "product_project_manager_data_list";//资料表
    //常量定义
    public static final String UUID = "uuid"; // uuid
src/main/java/com/product/contract/config/SystemCode.java
@@ -85,6 +85,9 @@
    SYSTEM_SAVE_TASK_PROGRESS_FAIL("保存任务进度失败", ModuleEnum.CONTRACT.getValue() + "043"),
    SYSTEM_LIST_TASK_PROGRESS_FAIL("获取任务进度列表失败", ModuleEnum.CONTRACT.getValue() + "044"),
    SYSTEM_GET_TASK_PROGRESS_FAIL("获取任务进度详情失败", ModuleEnum.CONTRACT.getValue() + "045"),
    PROJECT_SCHEDULE_OPERATE_FAIL("项目进度信息操作失败:", ModuleEnum.CONTRACT.getValue() +"046"),
    PROJECT_SCHEDULE_SAVE_FAIL("项目进度保存失败", ModuleEnum.CONTRACT.getValue() +"047"),
    ;
    private String text;
src/main/java/com/product/contract/controller/ProjectBusinessController.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,93 @@
package com.product.contract.controller;
import com.product.contract.config.CmnConst;
import com.product.contract.config.SystemCode;
import com.product.contract.service.ProjectBusinessService;
import com.product.contract.service.ide.IProjectBusinessService;
import com.product.core.config.CoreConst;
import com.product.core.controller.support.AbstractBaseController;
import com.product.core.entity.FieldSetEntity;
import com.product.core.entity.RequestParameterEntity;
import com.product.core.exception.BaseException;
import com.product.core.spring.context.SpringMVCContextHolder;
import com.product.module.sys.version.ApiVersion;
import com.product.util.BaseUtil;
import com.product.util.ResultInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
@RequestMapping("/api/project/business")
@RestController
public class ProjectBusinessController extends AbstractBaseController {
    @Autowired
    ProjectBusinessService projectBusinessService;
    /**
     *     é¡¹ç›®ç«‹é¡¹è¯¦æƒ…
     * @param request
     * @return
     */
    @RequestMapping(value="/find/{version}", method = RequestMethod.POST)
    @ApiVersion(1)
    public String find(HttpServletRequest request) {
        try {
            //获取参数
            FieldSetEntity fse = null;
            Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA);
            if (bean != null) {
                RequestParameterEntity reqp = (RequestParameterEntity) bean;
                fse = reqp.getFormData();
            }
            // åˆ¤æ–­å‚数是否为空
            if (bean == null || fse == null) {
                SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_FORM_NODATA.getValue(),
                        SystemCode.SYSTEM_FORM_NODATA.getText());
                return this.error(SystemCode.SYSTEM_FORM_NODATA.getValue(), SystemCode.SYSTEM_FORM_NODATA.getText());
            }
            // åˆ¤æ–­uuid是否为空
            if (com.alibaba.druid.util.StringUtils.isEmpty(fse.getString(CmnConst.UUID))) {
                SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_FORM_COUNT.getValue(),
                        SystemCode.SYSTEM_FORM_COUNT.getText());
                return this.error(SystemCode.SYSTEM_FORM_COUNT.getValue(), SystemCode.SYSTEM_FORM_COUNT.getText());
            }
            return ResultInfo.success(projectBusinessService.findProject(fse));
        } catch (BaseException e) {
            e.printStackTrace();
            return error(e);
        } catch (Exception e) {
            e.printStackTrace();
            return error(SystemCode.SYSTEM_FIND_CONTRACT_PROJECT_FAIL.getValue(), SystemCode.SYSTEM_FIND_CONTRACT_PROJECT_FAIL.getText() + e.getMessage());
        }
    }
    /**
     *     é¡¹ç›®ç«‹é¡¹ä¿å­˜
     * @param request
     * @return
     */
    @RequestMapping(value="/save/{version}", method = RequestMethod.POST)
    @ApiVersion(1)
    public String save(HttpServletRequest request) {
        try {
            //获取参数
            FieldSetEntity fse = BaseUtil.getFieldSetEntity(request, CmnConst.PRODUCT_PROJECT_SCHEDULE);
            IProjectBusinessService service = (IProjectBusinessService) getProxyInstance(projectBusinessService);
            boolean succ = service.saveProject(fse);
            if (succ) {
                return OK();
            }
            return error(SystemCode.SYSTEM_SAVE_PROJECT_FAIL.getValue(), SystemCode.SYSTEM_SAVE_PROJECT_FAIL.getText());
        } catch (BaseException e) {
            e.printStackTrace();
            return error(e);
        } catch (Exception e) {
            e.printStackTrace();
            return error(SystemCode.SYSTEM_SAVE_PROJECT_FAIL.getValue(), SystemCode.SYSTEM_SAVE_PROJECT_FAIL.getText() + e.getMessage());
        }
    }
}
src/main/java/com/product/contract/controller/ProjectScheduleController.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,76 @@
package com.product.contract.controller;
import com.product.contract.service.ProjectScheduleService;
import com.product.core.controller.support.AbstractBaseController;
import com.product.core.entity.FieldSetEntity;
import com.product.core.exception.BaseException;
import com.product.module.sys.version.ApiVersion;
import com.product.util.BaseUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.product.contract.config.CmnConst;
import com.product.contract.config.SystemCode;
import javax.servlet.http.HttpServletRequest;
/**
 *    é¡¹ç›®è¿›åº¦
 *
 */
@RequestMapping("/api/project-schedule")
@RestController
public class ProjectScheduleController extends AbstractBaseController{
    @Autowired
    ProjectScheduleService projectScheduleService;
    /**
     *     ä¸ªäººé¡¹ç›®è¿›åº¦
     * @param request
     * @return
     */
    @RequestMapping(value="/list/{version}", method = RequestMethod.POST)
    @ApiVersion(1)
    public String listProjectSchedule(HttpServletRequest request) {
        try {
            //获取参数
            FieldSetEntity fse = BaseUtil.getFieldSetEntity(request, CmnConst.PRODUCT_PROJECT_SCHEDULE);
            return OK_List(projectScheduleService.getList());
        } catch (BaseException e) {
            e.printStackTrace();
            return error(e);
        } catch (Exception e) {
            e.printStackTrace();
            return error(SystemCode.PROJECT_SCHEDULE_OPERATE_FAIL.getValue(), SystemCode.PROJECT_SCHEDULE_OPERATE_FAIL.getText() + e.getMessage());
        }
    }
    /**
     *     ä¸ªäººé¡¹ç›®è¿›åº¦ä¿å­˜
     * @param request
     * @return
     */
    @RequestMapping(value="/save/{version}", method = RequestMethod.POST)
    @ApiVersion(1)
    public String save(HttpServletRequest request) {
        try {
            //获取参数
            FieldSetEntity fse = BaseUtil.getFieldSetEntity(request, CmnConst.PRODUCT_PROJECT_SCHEDULE);
            boolean succ = projectScheduleService.save(fse.getSubDataTable(CmnConst.PRODUCT_PROJECT_SCHEDULE));
            if (succ) {
                return OK();
            }
            return error(SystemCode.PROJECT_SCHEDULE_SAVE_FAIL.getValue(), SystemCode.PROJECT_SCHEDULE_SAVE_FAIL.getText());
        } catch (BaseException e) {
            e.printStackTrace();
            return error(e);
        } catch (Exception e) {
            e.printStackTrace();
            return error(SystemCode.PROJECT_SCHEDULE_OPERATE_FAIL.getValue(), SystemCode.PROJECT_SCHEDULE_OPERATE_FAIL.getText() + e.getMessage());
        }
    }
}
src/main/java/com/product/contract/service/ProjectBusinessService.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,65 @@
package com.product.contract.service;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.product.contract.config.CmnConst;
import com.product.contract.service.ide.IProjectBusinessService;
import com.product.core.dao.BaseDao;
import com.product.core.entity.DataTableEntity;
import com.product.core.entity.FieldSetEntity;
import com.product.core.service.support.AbstractBaseService;
import com.product.core.transfer.Transactional;
import com.product.util.BaseUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class ProjectBusinessService extends AbstractBaseService implements IProjectBusinessService {
    @Autowired
    public BaseDao baseDao;
    @Override
    public JSONObject findProject(FieldSetEntity fse) {
        FieldSetEntity fsData = baseDao.getFieldSet(CmnConst.PRODUCT_PROJECT_BUSINESS, fse.getUUID(), false);
        //封装项目计划数据接口
        JSONObject json = new JSONObject();
        DataTableEntity planData=baseDao.listTable(CmnConst.PRODUCT_PROJECT_BUSINESS_PLAN,"project_uuid=?",new String[]{fse.getUUID()});
        for (int i = 0; i <planData.getRows() ; i++) {
            FieldSetEntity fs = planData.getFieldSetEntity(i);
            JSONObject jsonObject = BaseUtil.fieldSetEntityToJson(fs);
            JSONArray projectTask = json.getJSONArray(fs.getString("project_task"));
            if (projectTask==null){
                JSONArray objects = new JSONArray();
                objects.add(jsonObject);
                json.put(fs.getString("project_task"),objects);
            }else {
                projectTask.add(jsonObject);
            }
        }
        JSONObject rejson=BaseUtil.fieldSetEntityToJson(fsData);
        rejson.put(CmnConst.PRODUCT_PROJECT_BUSINESS_PLAN,json);
        //封装项目进度数据结构
        DataTableEntity scheduleDt =baseDao.listTable("select  project_task_sub,a.*  from product_project_schedule a\n" +
                "LEFT JOIN product_project_business_plan b  on a.business_sub_uuid =b.uuid\n" +
                "where b.project_uuid=? order by a.business_sub_uuid,a.reporting_time",new String[]{fse.getUUID()});
        rejson.put(CmnConst.PRODUCT_PROJECT_SCHEDULE,BaseUtil.dataTableEntityToJson(scheduleDt));
        //封装资料数据结构
        DataTableEntity dataList = baseDao.listTable(CmnConst.PRODUCT_PROJECT_MANAGER_DATA_LIST, "project_type=?", new String[]{fsData.getString("project_type")});
        rejson.put(CmnConst.PRODUCT_PROJECT_MANAGER_DATA_LIST,BaseUtil.dataTableEntityToJson(dataList));
        return rejson;
    }
    @Transactional
    @Override
    public boolean saveProject(FieldSetEntity fse) {
        boolean b = baseDao.saveFieldSetEntity(fse);
//        if (b){
//            DataTableEntity dt = fse.getSubDataTable(CmnConst.PRODUCT_PROJECT_MANAGER_DATA_LIST);
//            return baseDao.update(dt);
//        }
        return b;
    }
}
src/main/java/com/product/contract/service/ProjectScheduleService.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,156 @@
package com.product.contract.service;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.product.common.lang.StringUtils;
import com.product.core.config.CoreConst;
import com.product.core.dao.BaseDao;
import com.product.core.entity.DataTableEntity;
import com.product.core.entity.FieldSetEntity;
import com.product.core.service.support.AbstractBaseService;
import com.product.core.spring.context.SpringMVCContextHolder;
import com.product.util.BaseUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Date;
import java.util.LinkedHashMap;
import java.util.Map;
@Service
public class ProjectScheduleService extends AbstractBaseService {
    @Autowired
    BaseDao baseDao;
    /**
     * åŽç«¯å¤„理项目进度列表
     * @return
     */
    public DataTableEntity getList() {
        String curUserId = SpringMVCContextHolder.getCurrentUserId();
        StringBuilder sql = new StringBuilder();
        sql.append("SELECT c.uuid,a.uuid business_uuid,b.uuid business_sub_uuid,a.project_name project_name,b.project_task_sub,c.reporter,c.reporting_time,c.reporting_content,c.progress_rate \n");
        sql.append("FROM product_project_business a \n");
        sql.append("LEFT JOIN product_project_business_plan b ON a.uuid=b.project_uuid\n");
        sql.append("LEFT JOIN product_project_schedule c on b.uuid=c.business_sub_uuid\n");
        sql.append("WHERE  a.project_name is not null \n");
        sql.append("AND (CONCAT(',',a.team_members,',') LIKE ? OR a.group_leader = ?) \n");
        sql.append("ORDER BY a.project_name,b.start_date");
        DataTableEntity dt = baseDao.listTable(sql.toString(), new String[]{"%," + curUserId + ",%", curUserId});
        baseDao.loadPromptData(dt);
        JSONObject projectJsob = new JSONObject(new LinkedHashMap<>());
        for (int i = 0; i < dt.getRows(); i++) {
            FieldSetEntity fs = dt.getFieldSetEntity(i);
            JSONObject subJsob = projectJsob.getJSONObject(fs.getString("business_uuid"));
            if (subJsob==null){
                subJsob=new JSONObject(new LinkedHashMap<>());
                JSONArray arr = new JSONArray();
                arr.add(BaseUtil.fieldSetEntityToJson(fs));
                subJsob.put(fs.getString("business_sub_uuid"), arr);
                projectJsob.put(fs.getString("business_uuid"),subJsob);
            }else {
                JSONArray arr = subJsob.getJSONArray(fs.getString("business_sub_uuid"));
                if (arr==null){
                    arr = new JSONArray();
                    arr.add(BaseUtil.fieldSetEntityToJson(fs));
                    subJsob.put(fs.getString("business_sub_uuid"),arr);
                }else {
                    arr.add(BaseUtil.fieldSetEntityToJson(fs));
                }
            }
        }
        // èŽ·å–å½“å‰æ—¶é—´
        LocalDateTime now = LocalDateTime.now();
        // å®šä¹‰æ—¶é—´æ ¼å¼
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
        // å°†å½“前时间格式化为字符串
        String timeString = now.format(formatter);
        //总数居
        DataTableEntity data = new DataTableEntity();
        for (Map.Entry<String, Object> key : projectJsob.entrySet()) {
            //计算
            int num=0;
            //大项目下的数据
            DataTableEntity d = new DataTableEntity();
            JSONObject subJsob=projectJsob.getJSONObject(key.getKey());
            for (Map.Entry<String, Object> entry : subJsob.entrySet()) {
                //获取子项目下的数组数据
                JSONArray jsonArray = subJsob.getJSONArray(entry.getKey());
                /**
                 * åˆ¤å®šæ˜¯å¦æ–°å¢žæ•°æ®
                 */
                if (jsonArray.size()==1&&jsonArray.getJSONObject(0).getString("uuid")==null){
                    num=num+1;
                    JSONObject json = jsonArray.getJSONObject(0);
                    json.put("reporter", SpringMVCContextHolder.getCurrentUser().getUser_name());
                    json.put("reporting_time", timeString);
                    json.put("number1", 1);
                }else {
                    jsonArray.getJSONObject(0).put("number1",jsonArray.size()+1);
                    num=num+jsonArray.size()+1;
                    //新增颗填写数据
                    JSONObject j = new JSONObject();
                    j.put("business_uuid",jsonArray.getJSONObject(0).getString("business_uuid"));
                    j.put("business_sub_uuid",jsonArray.getJSONObject(0).getString("business_sub_uuid"));
                    j.put("project_name",jsonArray.getJSONObject(0).getString("project_name"));
                    j.put("project_task_sub",jsonArray.getJSONObject(0).getString("project_task_sub"));
                    j.put("reporter", SpringMVCContextHolder.getCurrentUser().getUser_name());
                    j.put("reporting_time", timeString);
                    jsonArray.add(j);
                }
                for (int i = 0; i <jsonArray.size() ; i++) {
                    JSONObject a = jsonArray.getJSONObject(i);
                    FieldSetEntity fs = new FieldSetEntity();
                    fs.setTableName("product_project_unfiled");
                    fs.setValue("uuid",a.getString("uuid"));
                    fs.setValue("business_uuid",a.getString("business_uuid"));
                    fs.setValue("business_sub_uuid",a.getString("business_sub_uuid"));
                    fs.setValue("project_name",a.getString("project_name"));
                    fs.setValue("project_task_sub",a.getString("project_task_sub"));
                    fs.setValue("reporter",a.getString("reporter"));
                    fs.setValue("reporting_time",a.getString("reporting_time"));
                    fs.setValue("reporting_content",a.getString("reporting_content"));
                    fs.setValue("progress_rate",a.getString("progress_rate"));
                    if (!StringUtils.isEmpty(a.getString("number1"))) {
                        fs.setValue("number1", a.getInteger("number1"));
                    }
                    d.addFieldSetEntity(fs);
                }
            }
            d.setFieldValue(0,"number",num);
            data.addFieldSetEntity(d);
        }
        return data;
    }
    /**
     *     é¡¹ç›®æœªå½’档原因保存
     * @param dt
     * @return
     */
    public boolean save(DataTableEntity dt){
        boolean re=true;
        for (int i = 0; i < dt.getRows(); i++) {
            FieldSetEntity fs = dt.getFieldSetEntity(i);
            if (StringUtils.isEmpty(fs.getString(CoreConst.UUID))&&(!StringUtils.isEmpty(fs.getString("reporting_content"))||!StringUtils.isEmpty(fs.getString("progress_rate")))){
                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());
                fs.setValue("reporter",SpringMVCContextHolder.getCurrentUser().getUser_id());
                boolean a = baseDao.saveFieldSetEntity(fs);
                if (!a) re= false;
            }
        }
        return  re;
    }
}
src/main/java/com/product/contract/service/ide/IProjectBusinessService.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,11 @@
package com.product.contract.service.ide;
import com.alibaba.fastjson.JSONObject;
import com.product.core.entity.FieldSetEntity;
public interface IProjectBusinessService {
    JSONObject findProject(FieldSetEntity fse);
    boolean saveProject(FieldSetEntity fse);
}