src/main/java/com/product/contract/config/CmnConst.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/product/contract/config/SystemCode.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/product/contract/controller/ProjectBusinessController.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/product/contract/controller/ProjectScheduleController.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/product/contract/service/ProjectBusinessService.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/product/contract/service/ProjectScheduleService.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/product/contract/service/ide/IProjectBusinessService.java | ●●●●● 补丁 | 查看 | 原始文档 | 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); }