From 9df5fcf6974977866bd73551e35961f849a625b2 Mon Sep 17 00:00:00 2001 From: zm <2369059705qq.com> Date: 星期二, 23 七月 2024 18:03:59 +0800 Subject: [PATCH] 项目立项和项目进度汇报 --- src/main/java/com/product/contract/controller/ProjectScheduleController.java | 76 ++++++++++ src/main/java/com/product/contract/service/ProjectScheduleService.java | 156 ++++++++++++++++++++++ src/main/java/com/product/contract/config/CmnConst.java | 5 src/main/java/com/product/contract/controller/ProjectBusinessController.java | 93 +++++++++++++ src/main/java/com/product/contract/service/ide/IProjectBusinessService.java | 11 + src/main/java/com/product/contract/config/SystemCode.java | 3 src/main/java/com/product/contract/service/ProjectBusinessService.java | 65 +++++++++ 7 files changed, 409 insertions(+), 0 deletions(-) diff --git a/src/main/java/com/product/contract/config/CmnConst.java b/src/main/java/com/product/contract/config/CmnConst.java index 6373b73..5151e40 100644 --- a/src/main/java/com/product/contract/config/CmnConst.java +++ b/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 diff --git a/src/main/java/com/product/contract/config/SystemCode.java b/src/main/java/com/product/contract/config/SystemCode.java index f3f0386..2ab41d3 100644 --- a/src/main/java/com/product/contract/config/SystemCode.java +++ b/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; diff --git a/src/main/java/com/product/contract/controller/ProjectBusinessController.java b/src/main/java/com/product/contract/controller/ProjectBusinessController.java new file mode 100644 index 0000000..0f85c62 --- /dev/null +++ b/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()); + } + } + +} diff --git a/src/main/java/com/product/contract/controller/ProjectScheduleController.java b/src/main/java/com/product/contract/controller/ProjectScheduleController.java new file mode 100644 index 0000000..ce1f4b9 --- /dev/null +++ b/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()); + } + } +} diff --git a/src/main/java/com/product/contract/service/ProjectBusinessService.java b/src/main/java/com/product/contract/service/ProjectBusinessService.java new file mode 100644 index 0000000..d18dd2e --- /dev/null +++ b/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; + } +} diff --git a/src/main/java/com/product/contract/service/ProjectScheduleService.java b/src/main/java/com/product/contract/service/ProjectScheduleService.java new file mode 100644 index 0000000..9a0f662 --- /dev/null +++ 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; + } + /** + * 椤圭洰鏈綊妗e師鍥犱繚瀛� + * @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; + } +} diff --git a/src/main/java/com/product/contract/service/ide/IProjectBusinessService.java b/src/main/java/com/product/contract/service/ide/IProjectBusinessService.java new file mode 100644 index 0000000..e8921b6 --- /dev/null +++ b/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); +} -- Gitblit v1.9.2