| | |
| | | public static final String TOTAL_OUTBOUND_WEIGHT="total_outbound_weight"; |
| | | public static final String PROJECT_NAME="project_name"; |
| | | public static final String PROJECT_ITEMIZE="project_itemize"; |
| | | public static final String PROJECT_ITEMIZE_UUID="project_itemize_uuid"; |
| | | public static final String ITEMIZE="itemize"; |
| | | public static final String ITEMIZE_CODE="itemize_code"; |
| | | public static final String ITEMIZE_TYPE="itemize_type"; |
| | | public static final String ITEMIZE_PARENT_CODE="itemize_parent_code"; |
| | | public static final String ITEMIZE_FULL_NAME="itemize_full_name"; |
| | | public static final String BUDGET_CODE="budget_code"; |
| | | |
| | | |
| | |
| | | SYSTEM_ACQUIRE_PARAM_FAIL("è·ååæ°å¤±è´¥", ModuleEnum.SYSTEM.getValue() + "996"), |
| | | SYSTEM_CPAGES_NOT_NULL("å页忰ä¸è½ä¸ºç©º", ModuleEnum.SYSTEM.getValue() + "995"), |
| | | |
| | | PROJECT_MANAGEMENT_ITEMIZE_DEL_FAIL("项ç®å项å é¤å¤±è´¥ï¼å·²ç»çæé¢ç®",""), |
| | | PROJECT_MAMAGERENT_ITEMIZE_GENERAL_ERROR("项ç®å项æä½é误ï¼",""), |
| | | PROJECT_INFO_OPERATE_ERROR("项ç®ä¿¡æ¯æä½å¤±è´¥:", ""), |
| | | PROJECT_ITEMIZE_OPERATE_ERROR("项ç®å项æä½é误ï¼",""), |
| | | PROJECT_ITEMIZE_DEL_FAIL_HAS_BUDGET("项ç®å项å é¤å¤±è´¥ï¼å·²ç»çæé¢ç®",""), |
| | | PROJECT_ITEMIZE_DEL_FAIL("项ç®å项å é¤å¤±è´¥",""), |
| | | PROJECT_BUDGET_IMPORT_FAIL("项ç®é¢ç®å¯¼å
¥å¤±è´¥",""), |
| | | ; |
| | | |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.product.project.management.controller; |
| | | |
| | | public class ProjectBudgetController { |
| | | |
| | | } |
| | |
| | | return this.error(e); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return this.error(SystemCode.PROJECT_MAMAGERENT_ITEMIZE_GENERAL_ERROR.getValue(), |
| | | SystemCode.PROJECT_MAMAGERENT_ITEMIZE_GENERAL_ERROR.getText() + e.getMessage()); |
| | | return this.error(SystemCode.PROJECT_INFO_OPERATE_ERROR.getValue(), |
| | | SystemCode.PROJECT_INFO_OPERATE_ERROR.getText() + e.getMessage()); |
| | | } |
| | | } |
| | | |
| | |
| | | return this.error(e); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return this.error(SystemCode.PROJECT_MAMAGERENT_ITEMIZE_GENERAL_ERROR.getValue(), |
| | | SystemCode.PROJECT_MAMAGERENT_ITEMIZE_GENERAL_ERROR.getText() + e.getMessage()); |
| | | return this.error(SystemCode.PROJECT_INFO_OPERATE_ERROR.getValue(), |
| | | SystemCode.PROJECT_INFO_OPERATE_ERROR.getText() + e.getMessage()); |
| | | } |
| | | } |
| | | |
| | |
| | | return this.error(e); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return this.error(SystemCode.PROJECT_MAMAGERENT_ITEMIZE_GENERAL_ERROR.getValue(), |
| | | SystemCode.PROJECT_MAMAGERENT_ITEMIZE_GENERAL_ERROR.getText() + e.getMessage()); |
| | | return this.error(SystemCode.PROJECT_INFO_OPERATE_ERROR.getValue(), |
| | | SystemCode.PROJECT_INFO_OPERATE_ERROR.getText() + e.getMessage()); |
| | | } |
| | | } |
| | | |
| | |
| | | return this.error(e); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return this.error(SystemCode.PROJECT_MAMAGERENT_ITEMIZE_GENERAL_ERROR.getValue(), |
| | | SystemCode.PROJECT_MAMAGERENT_ITEMIZE_GENERAL_ERROR.getText() + e.getMessage()); |
| | | return this.error(SystemCode.PROJECT_INFO_OPERATE_ERROR.getValue(), |
| | | SystemCode.PROJECT_INFO_OPERATE_ERROR.getText() + e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * è·å项ç®åææ°æ® |
| | | * |
| | | * @param request |
| | | * @return |
| | | */ |
| | | @RequestMapping(value = "/statist-analysis-report/{version}", method = RequestMethod.POST) |
| | | @ApiVersion(1) |
| | | public String statistAnalysis(HttpServletRequest request) { |
| | | try { |
| | | //è·ååæ° |
| | | FieldSetEntity fse = BaseUtil.getFieldSetEntity(request); |
| | | |
| | | //夿uuidæ¯å¦ä¸ºç©º |
| | | if (BaseUtil.strIsNull(fse.getString(Cmnconst.PROJECT_UUID))) { |
| | | return this.error(SystemCode.SYSTEM_FORM_COUNT.getValue(), SystemCode.SYSTEM_FORM_COUNT.getText()); |
| | | } |
| | | return ResultInfo.success(projectInfoService.statistAnalysis(fse.getString(Cmnconst.PROJECT_UUID))); |
| | | // return OK_List(projectInfoService.statistAnalysis(fse.getString(Cmnconst.PROJECT_UUID))); |
| | | } catch (BaseException e) { |
| | | e.printStackTrace(); |
| | | return this.error(e); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return this.error(SystemCode.PROJECT_MAMAGERENT_ITEMIZE_GENERAL_ERROR.getValue(), |
| | | SystemCode.PROJECT_MAMAGERENT_ITEMIZE_GENERAL_ERROR.getText() + e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * å é¤å个项ç®å项éªè¯ï¼æ ¹æ®é¢ç®éªè¯æ¯å¦å é¤ï¼ |
| | |
| | | return this.error(e); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return this.error(SystemCode.PROJECT_MAMAGERENT_ITEMIZE_GENERAL_ERROR.getValue(), |
| | | SystemCode.PROJECT_MAMAGERENT_ITEMIZE_GENERAL_ERROR.getText() + e.getMessage()); |
| | | return this.error(SystemCode.PROJECT_INFO_OPERATE_ERROR.getValue(), |
| | | SystemCode.PROJECT_INFO_OPERATE_ERROR.getText() + e.getMessage()); |
| | | } |
| | | } |
| | | |
| | |
| | | return this.error(e); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return this.error(SystemCode.PROJECT_MAMAGERENT_ITEMIZE_GENERAL_ERROR.getValue(), |
| | | SystemCode.PROJECT_MAMAGERENT_ITEMIZE_GENERAL_ERROR.getText() + e.getMessage()); |
| | | return this.error(SystemCode.PROJECT_INFO_OPERATE_ERROR.getValue(), |
| | | SystemCode.PROJECT_INFO_OPERATE_ERROR.getText() + e.getMessage()); |
| | | } |
| | | } |
| | | |
| | |
| | | return this.error(e); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return this.error(SystemCode.PROJECT_MAMAGERENT_ITEMIZE_GENERAL_ERROR.getValue(), |
| | | SystemCode.PROJECT_MAMAGERENT_ITEMIZE_GENERAL_ERROR.getText() + e.getMessage()); |
| | | return this.error(SystemCode.PROJECT_INFO_OPERATE_ERROR.getValue(), |
| | | SystemCode.PROJECT_INFO_OPERATE_ERROR.getText() + e.getMessage()); |
| | | } |
| | | } |
| | | |
| | |
| | | return this.error(e); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return this.error(SystemCode.PROJECT_MAMAGERENT_ITEMIZE_GENERAL_ERROR.getValue(), |
| | | SystemCode.PROJECT_MAMAGERENT_ITEMIZE_GENERAL_ERROR.getText() + e.getMessage()); |
| | | return this.error(SystemCode.PROJECT_INFO_OPERATE_ERROR.getValue(), |
| | | SystemCode.PROJECT_INFO_OPERATE_ERROR.getText() + e.getMessage()); |
| | | } |
| | | } |
| | | |
| | |
| | | return this.error(e); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return this.error(SystemCode.PROJECT_MAMAGERENT_ITEMIZE_GENERAL_ERROR.getValue(), |
| | | SystemCode.PROJECT_MAMAGERENT_ITEMIZE_GENERAL_ERROR.getText() + e.getMessage()); |
| | | return this.error(SystemCode.PROJECT_INFO_OPERATE_ERROR.getValue(), |
| | | SystemCode.PROJECT_INFO_OPERATE_ERROR.getText() + e.getMessage()); |
| | | } |
| | | } |
| | | |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.product.project.management.controller; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | |
| | | 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.core.config.CoreConst; |
| | | 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.project.management.config.Cmnconst; |
| | | import com.product.project.management.config.SystemCode; |
| | | import com.product.project.management.service.ProjectItemizeService; |
| | | import com.product.util.BaseUtil; |
| | | |
| | | /** |
| | | * 项ç®åé¨å项 |
| | | * @author 86151 |
| | | * |
| | | */ |
| | | @RequestMapping("/api/project-itemize") |
| | | @RestController |
| | | public class ProjectItemizeController extends AbstractBaseController{ |
| | | |
| | | @Autowired |
| | | ProjectItemizeService projectItemizeService; |
| | | |
| | | /** |
| | | * 项ç®å项-é¡¹ç®æ ï¼ä¸»å项ç®ï¼ |
| | | * |
| | | * @param request |
| | | * @return |
| | | */ |
| | | @RequestMapping(value = "/project-tree/{version}", method = RequestMethod.POST) |
| | | @ApiVersion(1) |
| | | public String getProjectTree(HttpServletRequest request) { |
| | | try { |
| | | // è·ååæ° |
| | | FieldSetEntity fse = BaseUtil.getFieldSetEntity(request); |
| | | |
| | | // 夿uuidæ¯å¦ä¸ºç©º |
| | | if (BaseUtil.strIsNull(fse.getString(Cmnconst.PROJECT_UUID))) { |
| | | return this.error(SystemCode.SYSTEM_FORM_COUNT.getValue(), SystemCode.SYSTEM_FORM_COUNT.getText()); |
| | | } |
| | | return OK_List(projectItemizeService.getProjectTree(fse.getString(Cmnconst.PROJECT_UUID))); |
| | | } catch (BaseException e) { |
| | | e.printStackTrace(); |
| | | return this.error(e); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return this.error(SystemCode.PROJECT_ITEMIZE_OPERATE_ERROR.getValue(), |
| | | SystemCode.PROJECT_ITEMIZE_OPERATE_ERROR.getText() + e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 项ç®å项-å项å表 |
| | | * |
| | | * @param request |
| | | * @return |
| | | */ |
| | | @RequestMapping(value = "/list/{version}", method = RequestMethod.POST) |
| | | @ApiVersion(1) |
| | | public String listProjectItem(HttpServletRequest request) { |
| | | try { |
| | | // è·ååæ° |
| | | FieldSetEntity fse = BaseUtil.getFieldSetEntity(request); |
| | | |
| | | //夿uuidæ¯å¦ä¸ºç©º |
| | | if (BaseUtil.strIsNull(fse.getString(Cmnconst.PROJECT_UUID))) { |
| | | return this.error(SystemCode.SYSTEM_FORM_COUNT.getValue(), SystemCode.SYSTEM_FORM_COUNT.getText()); |
| | | } |
| | | |
| | | //夿å页忰æ¯å¦ä¸ºç©º |
| | | if (BaseUtil.strIsNull(fse.getString(CoreConst.CPAGE)) || BaseUtil.strIsNull(fse.getString(CoreConst.PAGESIZE))) { |
| | | return this.error(SystemCode.SYSTEM_CPAGES_NOT_NULL.getValue(), SystemCode.SYSTEM_CPAGES_NOT_NULL.getText()); |
| | | } |
| | | return OK_List(projectItemizeService.listProjectItem(fse.getString(Cmnconst.PROJECT_UUID),fse.getString(Cmnconst.ITEMIZE_CODE), fse.getInteger(CoreConst.CPAGE), fse.getInteger(CoreConst.PAGESIZE))); |
| | | } catch (BaseException e) { |
| | | e.printStackTrace(); |
| | | return this.error(e); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return this.error(SystemCode.PROJECT_ITEMIZE_OPERATE_ERROR.getValue(), |
| | | SystemCode.PROJECT_ITEMIZE_OPERATE_ERROR.getText() + e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 项ç®å项-ä¿å |
| | | * |
| | | * @param request |
| | | * @return |
| | | */ |
| | | @RequestMapping(value = "/save/{version}", method = RequestMethod.POST) |
| | | @ApiVersion(1) |
| | | public String saveProjectItem(HttpServletRequest request) { |
| | | try { |
| | | // è·ååæ° |
| | | FieldSetEntity fse = BaseUtil.getFieldSetEntity(request); |
| | | return OK_List(projectItemizeService.saveProjectItem(fse)); |
| | | } catch (BaseException e) { |
| | | e.printStackTrace(); |
| | | return this.error(e); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return this.error(SystemCode.PROJECT_ITEMIZE_OPERATE_ERROR.getValue(), |
| | | SystemCode.PROJECT_ITEMIZE_OPERATE_ERROR.getText() + e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 项ç®å项-å é¤ |
| | | * |
| | | * @param request |
| | | * @return |
| | | */ |
| | | @RequestMapping(value = "/delete/{version}", method = RequestMethod.POST) |
| | | @ApiVersion(1) |
| | | public String deleteProjectItem(HttpServletRequest request) { |
| | | try { |
| | | // è·ååæ° |
| | | FieldSetEntity fse = BaseUtil.getFieldSetEntity(request); |
| | | |
| | | //夿project_uuidæ¯å¦ä¸ºç©º |
| | | if (BaseUtil.strIsNull(fse.getString(Cmnconst.PROJECT_UUID)) || BaseUtil.strIsNull(fse.getString(Cmnconst.PROJECT_UUID))) { |
| | | return this.error(SystemCode.SYSTEM_FORM_COUNT.getValue(), SystemCode.SYSTEM_FORM_COUNT.getText()); |
| | | } |
| | | |
| | | boolean succ = projectItemizeService.deleteProjectItem(fse.getUUID(), fse.getString(Cmnconst.PROJECT_UUID)); |
| | | if (succ) { |
| | | return OK(); |
| | | } |
| | | return this.error(SystemCode.PROJECT_ITEMIZE_DEL_FAIL.getValue(), SystemCode.PROJECT_ITEMIZE_DEL_FAIL.getText()); |
| | | } catch (BaseException e) { |
| | | e.printStackTrace(); |
| | | return this.error(e); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return this.error(SystemCode.PROJECT_ITEMIZE_OPERATE_ERROR.getValue(), |
| | | SystemCode.PROJECT_ITEMIZE_OPERATE_ERROR.getText() + e.getMessage()); |
| | | } |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.product.project.management.controller; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | |
| | | 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.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.project.management.config.Cmnconst; |
| | | import com.product.project.management.config.SystemCode; |
| | | import com.product.project.management.service.ProjectStatisticAnalysisService; |
| | | import com.product.util.BaseUtil; |
| | | import com.product.util.ResultInfo; |
| | | |
| | | @RequestMapping("/api/project-statistic") |
| | | @RestController |
| | | public class ProjectStatisticAnalysisController extends AbstractBaseController{ |
| | | |
| | | @Autowired |
| | | ProjectStatisticAnalysisService projectStatisticAnalysisService; |
| | | |
| | | /** |
| | | * è·å项ç®åææ°æ® |
| | | * |
| | | * @param request |
| | | * @return |
| | | */ |
| | | @RequestMapping(value = "/statist-analysis-report/{version}", method = RequestMethod.POST) |
| | | @ApiVersion(1) |
| | | public String statistAnalysis(HttpServletRequest request) { |
| | | try { |
| | | //è·ååæ° |
| | | FieldSetEntity fse = BaseUtil.getFieldSetEntity(request); |
| | | |
| | | //夿uuidæ¯å¦ä¸ºç©º |
| | | if (BaseUtil.strIsNull(fse.getString(Cmnconst.PROJECT_UUID))) { |
| | | return this.error(SystemCode.SYSTEM_FORM_COUNT.getValue(), SystemCode.SYSTEM_FORM_COUNT.getText()); |
| | | } |
| | | return ResultInfo.success(projectStatisticAnalysisService.statistAnalysis(fse.getString(Cmnconst.PROJECT_UUID))); |
| | | } catch (BaseException e) { |
| | | e.printStackTrace(); |
| | | return this.error(e); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return this.error(SystemCode.PROJECT_INFO_OPERATE_ERROR.getValue(), SystemCode.PROJECT_INFO_OPERATE_ERROR.getText() + e.getMessage()); |
| | | } |
| | | } |
| | | } |
| | |
| | | package com.product.project.management.service; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | import com.product.core.service.support.AbstractBaseService; |
| | | import com.product.project.management.config.Cmnconst; |
| | | import com.product.project.management.config.SystemCode; |
| | | import com.product.project.management.util.ProjectItemUtil; |
| | | import com.product.util.BaseUtil; |
| | | |
| | | import cn.hutool.core.lang.UUID; |
| | | |
| | | @Service("projectBudget") |
| | | public class ProjectBudgetService extends AbstractBaseService{ |
| | | |
| | | @Autowired |
| | | BaseDao baseDao; |
| | | |
| | | /** |
| | | * 项ç®é¢ç®å¯¼å
¥ |
| | | * @param dtParseData è§£ææ°æ® |
| | | * @param headerDataList excelæ 颿°æ® |
| | | */ |
| | | public DataTableEntity importBudget2(DataTableEntity dtParseData, List<List<String>> headerDataList) { |
| | | //夿æ¯å¦æè§£æEXCELæ°æ® |
| | | if (BaseUtil.dataTableIsEmpty(dtParseData)) { |
| | | return null; |
| | | } |
| | | //临æ¶åå¨éå |
| | | Map<String, String> itemizeFullNameAndUUID = new HashMap<>(); |
| | | Map<String, String> itemizeFullNameAndCode = new HashMap<>(); |
| | | Map<String, String> itemizeFullNameAndMaxCode = new HashMap<>(); |
| | | DataTableEntity dtNewProjectItem = new DataTableEntity(); |
| | | |
| | | //éåexcelè½¬æ¢æ°æ® |
| | | for (int i = 0; i < dtParseData.getRows(); i++) { |
| | | //è·åexcelè¡æ°æ® |
| | | FieldSetEntity fseParseData = dtParseData.getFieldSetEntity(i); |
| | | String uuid = autoCreateProjectItem(dtNewProjectItem, fseParseData, itemizeFullNameAndUUID, itemizeFullNameAndCode, itemizeFullNameAndMaxCode); |
| | | fseParseData.setValue(Cmnconst.PROJECT_ITEMIZE_UUID, uuid); |
| | | } |
| | | if (!BaseUtil.dataTableIsEmpty(dtNewProjectItem)) { |
| | | try { |
| | | baseDao.add(dtNewProjectItem); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | return dtParseData; |
| | | } |
| | | |
| | | /** |
| | | * éè¿field1,field2,field3,field4,field5,field6æ°æ®èªå¨çæé¡¹ç®åé¡¹æ°æ® |
| | | * 妿项ç®å项已å卿°æ®åºæè
æ°çæï¼å°åå
¥mapéåä¸ä»¥ä¾¿ä½¿ç¨ |
| | | * 妿项ç®å项ä¸åå¨äºæ°æ®åºåçæé¡¹ç®åé¡¹æ°æ® |
| | | * @param dtNewProjectItem |
| | | * @param fseParseData |
| | | * @param itemizeFullNameAndUUID |
| | | * @param itemizeFullNameAndCode |
| | | * @param itemizeFullNameAndMaxCode |
| | | * @return |
| | | */ |
| | | public String autoCreateProjectItem(DataTableEntity dtNewProjectItem, FieldSetEntity fseParseData, Map<String, String> itemizeFullNameAndUUID, Map<String, String> itemizeFullNameAndCode, Map<String, String> itemizeFullNameAndMaxCode) { |
| | | String itemizFullName = null; |
| | | String finalUUID = null; |
| | | //循ç¯field1~field6åæ®µï¼éæ¥çæå¯¹åºç项ç®åé¡¹æ°æ® |
| | | for (int i = 1; i < 7; i++) { |
| | | |
| | | //è·åå项åç§°,夿æ¯å¦ä¸ºç©º |
| | | String itemize = fseParseData.getString("field"+i); |
| | | //夿项ç®å项åç§°æ¯å¦ä¸ºç©ºï¼å¦ä¸ºç©ºï¼å该é¢ç®å¯¹åºç项ç®å项çæå®æ¯ï¼é¢ç®å
³èçUUID为ä¸ä¸ä¸ªfieldå项对åºçUUID |
| | | if (BaseUtil.strIsNull(itemize)) { |
| | | finalUUID = itemizeFullNameAndUUID.get(itemizFullName); |
| | | break; |
| | | } |
| | | |
| | | //è·åä¸çº§å项åå½åå项å
¨ç§°ï¼å¦å½åå项没æä¸çº§ï¼åå
¨ç§°çäºåç§°ï¼å¦æä¸çº§ï¼åå
¨ç§°çäºä¸çº§å
¨ç§°/åç§°ï¼ |
| | | String itemizeParent = null; |
| | | //è·åå项å
¨ç§° |
| | | if (BaseUtil.strIsNull(itemizFullName)) { |
| | | itemizFullName = itemize; |
| | | }else { |
| | | itemizeParent = itemizFullName; |
| | | itemizFullName = itemizFullName + "/" + itemize; |
| | | } |
| | | |
| | | //夿项ç®å项æ¯å¦åå¨äºéåä¸ |
| | | if(!itemizeFullNameAndCode.containsKey(itemizFullName)) { |
| | | //æ¥è¯¢å项åä¸çº§å项æ¯å¦åå¨äºæ°æ®åºä¸ |
| | | FieldSetEntity fseProjectItem = baseDao.getFieldSetEntityByFilter(Cmnconst.PRODUCT_PROJECT_ITEM, "itemize_full_name=?", new Object[] {itemizFullName}, false); |
| | | if (fseProjectItem == null) { |
| | | String uuid = UUID.randomUUID().toString(); |
| | | String code; |
| | | |
| | | if (!BaseUtil.strIsNull(itemizeFullNameAndMaxCode.get(itemizeParent))) { |
| | | code = ProjectItemUtil.autoAddOneCode(itemizeFullNameAndMaxCode.get(itemizeParent)); |
| | | }else { |
| | | FieldSetEntity fseMaxProjectItem; |
| | | if(BaseUtil.strIsNull(itemizeParent)) { |
| | | fseMaxProjectItem = baseDao.getFieldSetEntityByFilter(Cmnconst.PRODUCT_PROJECT_ITEM, new String[] {"Max(itemize_code)itemize_code"}, "itemize_parent_code IS NULL", new Object[] {}, false, null); |
| | | }else { |
| | | fseMaxProjectItem = baseDao.getFieldSetEntityByFilter(Cmnconst.PRODUCT_PROJECT_ITEM, new String[] {"Max(itemize_code)itemize_code"}, "itemize_parent_code = ?", new Object[] {itemizeFullNameAndCode.get(itemizeParent)}, false, null); |
| | | } |
| | | if (fseMaxProjectItem==null || BaseUtil.strIsNull(fseMaxProjectItem.getString(Cmnconst.ITEMIZE_CODE))) { |
| | | code = ProjectItemUtil.autoCreateCode(itemizeFullNameAndCode.get(itemizeParent)); |
| | | }else { |
| | | code = ProjectItemUtil.autoAddOneCode(fseMaxProjectItem.getString(Cmnconst.ITEMIZE_CODE)); |
| | | } |
| | | } |
| | | FieldSetEntity fseNewProject = new FieldSetEntity(Cmnconst.PRODUCT_PROJECT_ITEM); |
| | | fseNewProject.setValue(Cmnconst.UUID, uuid); |
| | | fseNewProject.setValue("~type~", "add"); |
| | | // fseNewProject.setValue(Cmnconst.PROJECT_UUID, ); |
| | | fseNewProject.setValue(Cmnconst.ITEMIZE, itemize); |
| | | fseNewProject.setValue(Cmnconst.ITEMIZE_CODE, code); |
| | | fseNewProject.setValue(Cmnconst.ITEMIZE_PARENT_CODE, itemizeFullNameAndCode.get(itemizeParent)); |
| | | fseNewProject.setValue(Cmnconst.ITEMIZE_FULL_NAME, itemizFullName); |
| | | dtNewProjectItem.addFieldSetEntity(fseNewProject); |
| | | |
| | | itemizeFullNameAndUUID.put(itemizFullName, uuid); |
| | | itemizeFullNameAndCode.put(itemizFullName, code); |
| | | itemizeFullNameAndMaxCode.put(itemizeParent, code); |
| | | }else { |
| | | String uuid = fseProjectItem.getUUID(); |
| | | String code = fseProjectItem.getString(Cmnconst.ITEMIZE_CODE); |
| | | FieldSetEntity fseMaxProjectItem; |
| | | if (BaseUtil.strIsNull(fseProjectItem.getString(Cmnconst.ITEMIZE_PARENT_CODE))) { |
| | | fseMaxProjectItem = baseDao.getFieldSetEntityByFilter(Cmnconst.PRODUCT_PROJECT_ITEM, new String[] {"Max(itemize_code)itemize_code"}, "itemize_parent_code IS NULL", new Object[] {}, false, null); |
| | | }else { |
| | | fseMaxProjectItem = baseDao.getFieldSetEntityByFilter(Cmnconst.PRODUCT_PROJECT_ITEM, new String[] {"Max(itemize_code)itemize_code"}, "itemize_parent_code=?", new Object[] {fseProjectItem.getString(Cmnconst.ITEMIZE_PARENT_CODE)}, false, null); |
| | | } |
| | | itemizeFullNameAndUUID.put(itemizFullName, uuid); |
| | | itemizeFullNameAndCode.put(itemizFullName, code); |
| | | itemizeFullNameAndMaxCode.put(itemizeParent, fseMaxProjectItem.getString(Cmnconst.ITEMIZE_CODE)); |
| | | } |
| | | } |
| | | } |
| | | return finalUUID; |
| | | } |
| | | |
| | | /** |
| | | * 项ç®é¢ç®å¯¼å
¥ |
| | |
| | | return baseDao.listTable(Cmnconst.PRODUCT_PROJECT_QXLW, null, null, new Object[]{CoreConst.UUID, Cmnconst.PROJECT_NAME}); |
| | | } |
| | | |
| | | /** |
| | | * é¡¹ç®æ°æ®åæ |
| | | * |
| | | * @param project_uuid |
| | | * @return |
| | | */ |
| | | public JSONObject statistAnalysis(String project_uuid) { |
| | | |
| | | JSONObject returnJson = new JSONObject(); |
| | | |
| | | //æ°æ®åºåºåºä¿¡æ¯æ±æ» |
| | | StringBuilder outboundInfo = new StringBuilder(512); |
| | | outboundInfo.append(" WITH outbound AS( ") |
| | | .append(" SELECT project_uuid,itemize,material_type,material_code,SUM(outbound_weight)outbound_weight FROM ( ") |
| | | .append(" SELECT ") |
| | | .append(" A.project_uuid, ") |
| | | .append(" B.material_type,B.material_code,B.outbound_weight, ") |
| | | .append(" (SELECT itemize FROM product_project_item WHERE project_uuid = A.project_uuid AND itemize_code = substring(C.itemize_code,1,7)) itemize ") |
| | | .append(" FROM product_project_outbound A ") |
| | | .append(" LEFT JOIN product_project_outbound_sub B ON A.uuid=B.outbound_uuid ") |
| | | .append(" LEFT JOIN product_project_item C ON C.uuid = A.project_itemize ") |
| | | .append(" WHERE A.flow_flag=2 AND A.project_uuid=? ") |
| | | .append(" )A GROUP BY project_uuid,itemize,material_type,material_code ") |
| | | .append(" )"); |
| | | //åºåºä¿¡æ¯æä½ï¼æ¶ç«çå声æµç®¡ä¸å±ç¤ºåå·æ±æ»æ±åè¡è½¬åï¼æ®éé¢çåç½çå±ç¤ºåå·ï¼æ ¹æ®é¡¹ç®å项å
³èæ±æ»ï¼ |
| | | StringBuilder operateInfo = new StringBuilder(1024); |
| | | operateInfo.append(" ,getItemizeSum AS( ") |
| | | .append(" SELECT itemize,SUM(outbound_weight)total_outbound_weight FROM outbound WHERE material_type IN (0,1) GROUP BY itemize ") |
| | | .append(" ),allitemize AS( ") |
| | | .append(" SELECT itemize FROM outbound GROUP BY itemize ") |
| | | .append(" ),intermediateData1 AS( ") |
| | | .append(" SELECT A.itemize,SUM(IF(`material_type`='1',outbound_weight,0)) as 'JLJ',SUM(IF(`material_type`='2',outbound_weight,0)) as 'SCG' ") |
| | | .append(" FROM ( SELECT itemize FROM outbound GROUP BY itemize )A ") |
| | | .append(" LEFT JOIN ( ") |
| | | .append(" SELECT project_uuid,itemize,material_type,CASE WHEN material_type=1 THEN 'æ¶ç«ç' ELSE '声æµç®¡' END AS material_code,SUM(outbound_weight)outbound_weight ") |
| | | .append(" FROM outbound ") |
| | | .append(" WHERE material_type IN (1,2) ") |
| | | .append(" GROUP BY project_uuid,itemize,material_type ") |
| | | .append(" ) B ON A.itemize = B.itemize ") |
| | | .append(" GROUP BY A.itemize ") |
| | | .append(" ),intermediateData2 AS( ") |
| | | .append(" SELECT project_uuid,itemize,material_type,material_code,outbound_weight FROM outbound WHERE material_type IN (0,3) ") |
| | | .append(" ),intermediateData3 AS( ") |
| | | .append(" SELECT A.itemize,A.total_outbound_weight,A.jlj,A.scg,B.material_type,material_code,outbound_weight FROM( ") |
| | | .append(" SELECT A.itemize,C.total_outbound_weight,B.jlj,B.scg ") |
| | | .append(" FROM allitemize A ") |
| | | .append(" LEFT JOIN intermediateData1 B ON A.itemize = B.itemize ") |
| | | .append(" LEFT JOIN getItemizeSum C ON A.itemize = C.itemize ") |
| | | .append(" )A ") |
| | | .append(" LEFT JOIN intermediateData2 B ON A.itemize = B.itemize ") |
| | | .append(" ) ") |
| | | .append(" select * from intermediateData3 "); |
| | | |
| | | StringBuilder totalSum = new StringBuilder(""); |
| | | totalSum.append(" SELECT material_code,SUM(outbound_weight)outbound_weight FROM outbound WHERE material_type IN (0,3) GROUP BY material_code ") |
| | | .append(" UNION ALL ") |
| | | .append(" SELECT CASE WHEN material_type=1 THEN 'JLJ' WHEN material_type=2 THEN 'SCG' END,SUM(outbound_weight) FROM outbound WHERE material_type IN (1,2) GROUP BY material_type ") |
| | | .append(" UNION ALL ") |
| | | .append(" SELECT 'å计',SUM(outbound_weight) FROM outbound WHERE material_type IN (0,1,3) GROUP BY project_uuid "); |
| | | |
| | | //è·åSQLè§£æçåºæ¬æ°æ®ï¼å©ç¨JAVAå°é¡¹ç®å项对åºçä¸åææè¡è½¬å |
| | | DataTableEntity dtItemizeInfo = baseDao.listTable(outboundInfo.toString() + operateInfo.toString(), new Object[]{project_uuid}); |
| | | if (!BaseUtil.dataTableIsEmpty(dtItemizeInfo)) { |
| | | |
| | | Map<String, FieldSetEntity> convertData = new HashMap<>(); |
| | | String[] materialTypes = new String[4]; |
| | | |
| | | //éè¿Java循ç¯å°"ææ"å"åºåºé"æ°æ®è¡è½¬å |
| | | for (int i = 0; i < dtItemizeInfo.getRows(); i++) { |
| | | FieldSetEntity fseItemize = dtItemizeInfo.getFieldSetEntity(i); |
| | | |
| | | //è·åææç¼ç ï¼ææç±»åï¼åºåºé |
| | | String materialCode = fseItemize.getString(Cmnconst.MATERIAL_CODE); |
| | | String outboundWeight = fseItemize.getString(Cmnconst.OUTBOUND_WEIGHT); |
| | | Integer materialType = fseItemize.getInteger(Cmnconst.MATERIAL_TYPE); |
| | | |
| | | //æ¶éè·åææè¡¨å¤´åï¼ææç¼ç ï¼,æ¶ç«çå声æµç®¡æ²¡æè¡¨å¤´ |
| | | if (!BaseUtil.strIsNull(materialCode)) { |
| | | if (BaseUtil.strIsNull(materialTypes[materialType])) { |
| | | materialTypes[materialType] = materialCode; |
| | | } else { |
| | | if(materialTypes[fseItemize.getInteger(Cmnconst.MATERIAL_TYPE)].indexOf(materialCode)<0) { |
| | | materialTypes[fseItemize.getInteger(Cmnconst.MATERIAL_TYPE)] += "," + materialCode; |
| | | } |
| | | } |
| | | } |
| | | |
| | | //æ¶éè¡è½¬åæ°æ® |
| | | String itemize = fseItemize.getString(Cmnconst.ITEMIZE); |
| | | if (convertData.containsKey(itemize)) { |
| | | convertData.get(itemize).setValue(materialCode, outboundWeight); |
| | | } else { |
| | | FieldSetEntity fseConvertData = new FieldSetEntity(Cmnconst.PRODUCT_PROJECT_QXLW); |
| | | fseConvertData.setValue(Cmnconst.ITEMIZE, itemize); |
| | | fseConvertData.setValue(Cmnconst.TOTAL_OUTBOUND_WEIGHT, fseItemize.getString(Cmnconst.TOTAL_OUTBOUND_WEIGHT)); |
| | | fseConvertData.setValue(materialCode, outboundWeight); |
| | | fseConvertData.setValue("jlj", fseItemize.getString("jlj")); |
| | | fseConvertData.setValue("scg", fseItemize.getString("scg")); |
| | | convertData.put(itemize, fseConvertData); |
| | | } |
| | | } |
| | | |
| | | //è®¡ç®æ±æ» |
| | | DataTableEntity dtTotalInfo = baseDao.listTable(outboundInfo.toString() + totalSum.toString(), new Object[]{project_uuid}); |
| | | FieldSetEntity fseConvertData = new FieldSetEntity(Cmnconst.PRODUCT_PROJECT_QXLW); |
| | | if (!BaseUtil.dataTableIsEmpty(dtTotalInfo)) { |
| | | for (int i = 0; i < dtTotalInfo.getRows(); i++) { |
| | | FieldSetEntity fseTotalInfo = dtTotalInfo.getFieldSetEntity(i); |
| | | String materialCode = fseTotalInfo.getString(Cmnconst.MATERIAL_CODE); |
| | | String outboundWeight = fseTotalInfo.getString(Cmnconst.OUTBOUND_WEIGHT); |
| | | if (!BaseUtil.strIsNull(materialCode) && !BaseUtil.strIsNull(outboundWeight)) { |
| | | if ("å计".equals(materialCode)) { |
| | | fseConvertData.setValue(Cmnconst.ITEMIZE, "å计"); |
| | | fseConvertData.setValue(Cmnconst.TOTAL_OUTBOUND_WEIGHT, outboundWeight); |
| | | }else { |
| | | fseConvertData.setValue(materialCode, outboundWeight); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | //å°æ°æ®è½¬ä¸ºDataTableEntityè¿å |
| | | if (!convertData.isEmpty()) { |
| | | DataTableEntity finalConvertData = new DataTableEntity(); |
| | | convertData.forEach((k, v) -> { |
| | | finalConvertData.addFieldSetEntity(v); |
| | | }); |
| | | finalConvertData.addFieldSetEntity(fseConvertData); |
| | | returnJson.set("data", BaseUtil.dataTableEntityToJson(finalConvertData)); |
| | | } |
| | | //å°è¡¨å¤´æ°æ®è¿å |
| | | for (int i = 0; i < materialTypes.length; i++) { |
| | | if (!BaseUtil.strIsNull(materialTypes[i])) { |
| | | returnJson.set("type" + i, materialTypes[i]); |
| | | } |
| | | } |
| | | } |
| | | return returnJson; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * å é¤å项éªè¯ï¼å·²ç»çæé¢ç®çå项ä¸è½å é¤ï¼ |
| | |
| | | public void deleteItemizeValidate(String uuid) { |
| | | DataTableEntity dtBudget = baseDao.listTable(Cmnconst.PRODUCT_PROJECT_BUDGET, "budget_code=?", new Object[]{uuid}); |
| | | if (!BaseUtil.dataTableIsEmpty(dtBudget)) { |
| | | throw new BaseException(SystemCode.PROJECT_MANAGEMENT_ITEMIZE_DEL_FAIL.getValue(), SystemCode.PROJECT_MANAGEMENT_ITEMIZE_DEL_FAIL.getText()); |
| | | throw new BaseException(SystemCode.PROJECT_ITEMIZE_DEL_FAIL_HAS_BUDGET.getValue(), SystemCode.PROJECT_ITEMIZE_DEL_FAIL_HAS_BUDGET.getText()); |
| | | } |
| | | } |
| | | |
| | |
| | | public DataTableEntity listMaterialV(String uuid, Integer capge, Integer pageSize) { |
| | | return baseDao.listTable("product_project_base_material_v","project_itemize_uuid=?",new String[]{uuid},null,null,pageSize, capge); |
| | | } |
| | | |
| | | /** |
| | | * æ´å
·ä»åºåææè·ååºå |
| | | * @return |
| | |
| | | public FieldSetEntity findInventoryV(String warehouse_uuid, String material_uuid) { |
| | | return baseDao.getFieldSetByFilter("product_project_inventory_v","warehouse_uuid=? and uuid=?",new String[]{warehouse_uuid,material_uuid},false); |
| | | } |
| | | |
| | | /** |
| | | * æ ¹æ®é¡¹ç®uuidè·å项ç®å项æ ç»æ |
| | | * @param uuid |
| | | * @return |
| | | */ |
| | | |
| | | public JSONArray getTreeProjectItem(String uuid) { |
| | | DataTableEntity dtProjectItemize = baseDao.listTable(Cmnconst.PRODUCT_PROJECT_ITEM, "project_uuid=?", new Object[]{uuid}, new Object[]{CoreConst.UUID, Cmnconst.ITEMIZE, Cmnconst.ITEMIZE_CODE, Cmnconst.ITEMIZE_PARENT_CODE}); |
| | | DataTableEntity newDtProjectItem = BaseUtil.dataTableToTreeTable(dtProjectItemize, Cmnconst.ITEMIZE_CODE, Cmnconst.ITEMIZE_PARENT_CODE, null); |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.product.project.management.service; |
| | | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | 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.exception.BaseException; |
| | | import com.product.core.service.support.AbstractBaseService; |
| | | import com.product.project.management.config.Cmnconst; |
| | | import com.product.project.management.config.SystemCode; |
| | | import com.product.project.management.util.ProjectItemUtil; |
| | | import com.product.util.BaseUtil; |
| | | |
| | | @Component |
| | | public class ProjectItemizeService extends AbstractBaseService{ |
| | | |
| | | @Autowired |
| | | BaseDao baseDao; |
| | | |
| | | |
| | | /** |
| | | * 项ç®å项-é¡¹ç®æ ï¼ä¸»å项ç®ï¼ |
| | | * @param projectUUID 项ç®UUID |
| | | * @return |
| | | */ |
| | | public DataTableEntity getProjectTree(String projectUUID) { |
| | | FieldSetEntity fseProjectInfo = baseDao.getFieldSetEntity(Cmnconst.PRODUCT_PROJECT_QXLW, projectUUID, false); |
| | | if (fseProjectInfo == null) { |
| | | return null; |
| | | } |
| | | DataTableEntity dtProjectItemize = baseDao.listTable(Cmnconst.PRODUCT_PROJECT_ITEM, "project_uuid=?", new Object[]{projectUUID}, new Object[]{CoreConst.UUID, Cmnconst.ITEMIZE, Cmnconst.ITEMIZE_CODE, Cmnconst.ITEMIZE_PARENT_CODE}); |
| | | if (!BaseUtil.dataTableIsEmpty(dtProjectItemize)) { |
| | | DataTableEntity newDtProjectItem = BaseUtil.dataTableToTreeTable(dtProjectItemize, Cmnconst.ITEMIZE_CODE, Cmnconst.ITEMIZE_PARENT_CODE, null); |
| | | return newDtProjectItem; |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * 项ç®å项-å表ï¼å±ç¤ºéä¸å项çä¸ä¸çº§åè¡¨ï¼ |
| | | * @param projectUUID |
| | | * @param itemizeCode |
| | | * @param capge |
| | | * @param pageSize |
| | | * @return |
| | | */ |
| | | public DataTableEntity listProjectItem(String projectUUID, String itemizeCode, Integer capge, Integer pageSize) { |
| | | DataTableEntity dtItemizeBudget; |
| | | if(BaseUtil.strIsNull(itemizeCode) || "000".equals(itemizeCode)) { |
| | | dtItemizeBudget = baseDao.listTable(Cmnconst.PRODUCT_PROJECT_ITEM, "project_uuid=? AND itemize_parent_code IS NULL", new Object[] {projectUUID}, null, null, pageSize, capge); |
| | | }else { |
| | | dtItemizeBudget = baseDao.listTable(Cmnconst.PRODUCT_PROJECT_ITEM, "project_uuid=? AND itemize_parent_code=?", new Object[] {projectUUID,itemizeCode}, null, null, pageSize, capge); |
| | | } |
| | | |
| | | //æ¥è¯¢éä¸èç¹ä¸ææé¡¹ç®å项 |
| | | if (!BaseUtil.dataTableIsEmpty(dtItemizeBudget)) { |
| | | baseDao.loadPromptData(dtItemizeBudget); |
| | | } |
| | | return dtItemizeBudget; |
| | | } |
| | | |
| | | /** |
| | | * ä¿å项ç®å项 |
| | | * @param fse |
| | | * @return |
| | | */ |
| | | public FieldSetEntity saveProjectItem(FieldSetEntity fse) { |
| | | //夿æ¯å¦æ¯æ°å¢ |
| | | if (BaseUtil.strIsNull(fse.getUUID())) { |
| | | String projectUUID = fse.getString(Cmnconst.PROJECT_UUID); |
| | | FieldSetEntity fseMaxProjectItem; |
| | | String itemizeCode; |
| | | String itemizeFullName = null; |
| | | //夿æ¯å¦æä¸çº§ |
| | | if (BaseUtil.strIsNull(fse.getString(Cmnconst.ITEMIZE_PARENT_CODE))) { |
| | | fseMaxProjectItem = baseDao.getFieldSetEntityByFilter(Cmnconst.PRODUCT_PROJECT_ITEM, new String[] {"Max(itemize_code)itemize_code"}, "project_uuid = ? AND itemize_parent_code IS NULL", new Object[] {projectUUID}, false, null); |
| | | if (fseMaxProjectItem==null || BaseUtil.strIsNull(fseMaxProjectItem.getString(Cmnconst.ITEMIZE_CODE))) { |
| | | itemizeCode = "001"; |
| | | }else { |
| | | itemizeCode = ProjectItemUtil.autoAddOneCode(fseMaxProjectItem.getString(Cmnconst.ITEMIZE_CODE)); |
| | | } |
| | | itemizeFullName = fse.getString(Cmnconst.ITEMIZE); |
| | | }else { |
| | | fseMaxProjectItem = baseDao.getFieldSetEntityByFilter(Cmnconst.PRODUCT_PROJECT_ITEM, new String[] {"Max(itemize_code)itemize_code"}, "project_uuid = ? AND itemize_parent_code = ?", new Object[] {projectUUID, fse.getString(Cmnconst.ITEMIZE_PARENT_CODE)}, false, null); |
| | | if (fseMaxProjectItem==null || BaseUtil.strIsNull(fseMaxProjectItem.getString(Cmnconst.ITEMIZE_CODE))) { |
| | | itemizeCode = ProjectItemUtil.autoCreateCode(fse.getString(Cmnconst.ITEMIZE_PARENT_CODE)); |
| | | }else { |
| | | itemizeCode = ProjectItemUtil.autoAddOneCode(fseMaxProjectItem.getString(Cmnconst.ITEMIZE_CODE)); |
| | | } |
| | | FieldSetEntity itemizeParent = baseDao.getFieldSetEntityByFilter(Cmnconst.PRODUCT_PROJECT_ITEM, "project_uuid =? AND itemize_code=?", new Object[] {projectUUID, fse.getString(Cmnconst.ITEMIZE_PARENT_CODE)}, false); |
| | | if (itemizeParent!=null) { |
| | | itemizeFullName = itemizeParent.getString(Cmnconst.ITEMIZE_FULL_NAME) + "/" + fse.getString(Cmnconst.ITEMIZE); |
| | | } |
| | | } |
| | | fse.setValue(Cmnconst.ITEMIZE_CODE, itemizeCode); |
| | | fse.setValue(Cmnconst.ITEMIZE_FULL_NAME, itemizeFullName); |
| | | } |
| | | baseDao.saveFieldSetEntity(fse); |
| | | return fse; |
| | | } |
| | | |
| | | /** |
| | | * å é¤é¡¹ç®å项 |
| | | * @param uuids |
| | | * @return |
| | | */ |
| | | public boolean deleteProjectItem(String uuids, String projectUUID) { |
| | | //éªè¯æ¯å¦çæé¢ç® |
| | | StringBuilder sbValidate = new StringBuilder(128); |
| | | sbValidate.append(" SELECT * FROM product_project_budget ") |
| | | .append(" WHERE project_itemize_uuid IN( ") |
| | | .append(" select uuid from product_project_item ") |
| | | .append(" WHERE project_uuid = ? AND itemize_code REGEXP ( ") |
| | | .append(" SELECT CONCAT('^',GROUP_CONCAT(itemize_code SEPARATOR '|^')) FROM product_project_item ") |
| | | .append(" WHERE ") |
| | | .append(BaseUtil.buildQuestionMarkFilter(Cmnconst.UUID, uuids.split(","), true)) |
| | | .append(" ) ") |
| | | .append(" ) "); |
| | | DataTableEntity dtBudget = baseDao.listTable(sbValidate.toString(), new Object[] {projectUUID}); |
| | | if (!BaseUtil.dataTableIsEmpty(dtBudget)) { |
| | | throw new BaseException(SystemCode.PROJECT_ITEMIZE_DEL_FAIL_HAS_BUDGET.getText(), SystemCode.PROJECT_ITEMIZE_DEL_FAIL_HAS_BUDGET.getValue()); |
| | | } |
| | | //å é¤ |
| | | StringBuilder sbDelete = new StringBuilder(128); |
| | | sbDelete.append(" DELETE from product_project_item ") |
| | | .append(" WHERE uuid IN( ") |
| | | .append(" SELECT * FROM( ") |
| | | .append(" SELECT uuid FROM product_project_item ") |
| | | .append(" WHERE project_uuid = ? AND itemize_code REGEXP ( ") |
| | | .append(" SELECT CONCAT('^',GROUP_CONCAT(itemize_code SEPARATOR '|^')) FROM product_project_item ") |
| | | .append(" WHERE ") |
| | | .append(BaseUtil.buildQuestionMarkFilter(Cmnconst.UUID, uuids.split(","), true)) |
| | | .append(" ) ") |
| | | .append(" )A ") |
| | | .append(" ) "); |
| | | |
| | | return baseDao.executeUpdate(sbDelete.toString(), new Object[] {projectUUID}); |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.product.project.management.service; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | 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.project.management.config.Cmnconst; |
| | | import com.product.util.BaseUtil; |
| | | |
| | | import cn.hutool.json.JSONObject; |
| | | |
| | | @Component |
| | | public class ProjectStatisticAnalysisService extends AbstractBaseService{ |
| | | |
| | | |
| | | @Autowired |
| | | BaseDao baseDao; |
| | | |
| | | /** |
| | | * é¡¹ç®æ°æ®åæ |
| | | * |
| | | * @param project_uuid |
| | | * @return |
| | | */ |
| | | public JSONObject statistAnalysis(String project_uuid) { |
| | | |
| | | JSONObject returnJson = new JSONObject(); |
| | | |
| | | List<List<String>> listMaterialType = getReportMaterialType(); |
| | | |
| | | //æ°æ®åºåºåºä¿¡æ¯æ±æ» |
| | | StringBuilder outboundInfo = new StringBuilder(512); |
| | | outboundInfo.append(" WITH outbound AS( ") |
| | | .append(" SELECT project_uuid,itemize,material_type,material_code,SUM(outbound_weight)outbound_weight FROM ( ") |
| | | .append(" SELECT ") |
| | | .append(" A.project_uuid,B.material_type,B.material_code,B.outbound_weight, ") |
| | | .append(" (SELECT itemize FROM product_project_item WHERE project_uuid = A.project_uuid AND itemize_code = substring(C.itemize_code,1,11)) itemize ") |
| | | .append(" FROM product_project_outbound A ") |
| | | .append(" LEFT JOIN product_project_outbound_sub B ON A.uuid=B.outbound_uuid ") |
| | | .append(" LEFT JOIN product_project_item C ON C.uuid = A.project_itemize ") |
| | | .append(" WHERE A.flow_flag=2 AND A.project_uuid=? ") |
| | | .append(" )A GROUP BY project_uuid,itemize,material_type,material_code ") |
| | | .append(" )"); |
| | | //åºåºä¿¡æ¯æä½ï¼getItemizeSum[é¢çåæ¶ç«çå·¦ä¾§æ±æ»]ï¼allitemize[ææä¸çº§å项]ï¼intermediateData1[é¢çæ¶ç«çæåé¡¹æ±æ»]ï¼intermediateData2[é¢çç½çæåé¡¹åæææ±æ»]ï¼intermediateData3[æ¥è¡¨æå]ï¼ |
| | | StringBuilder operateInfo = new StringBuilder(1024); |
| | | operateInfo.append(" ,getItemizeSum AS( ") |
| | | .append(" SELECT itemize,ROUND(SUM(outbound_weight)/1000,1) total_outbound_weight FROM outbound WHERE ") |
| | | .append(BaseUtil.buildQuestionMarkFilter(Cmnconst.MATERIAL_TYPE, listMaterialType.get(0).toArray(), true)) |
| | | .append(" GROUP BY itemize ") |
| | | .append(" )") |
| | | |
| | | .append(",allitemize AS( ") |
| | | .append(" SELECT itemize FROM outbound GROUP BY itemize ") |
| | | .append(" )") |
| | | |
| | | .append(",intermediateData1 AS( ") |
| | | .append(" SELECT A.itemize "); |
| | | for (int i = 0; i < listMaterialType.get(2).size(); i++) { |
| | | operateInfo.append(",SUM(IF(material_type=") |
| | | .append(listMaterialType.get(2).get(i)) |
| | | .append(",outbound_weight,0)) as ") |
| | | .append(listMaterialType.get(3).get(i)); |
| | | } |
| | | operateInfo.append(" FROM ( SELECT itemize FROM outbound GROUP BY itemize )A ") |
| | | .append(" LEFT JOIN ( ") |
| | | .append(" SELECT project_uuid,itemize,material_type,SUM(outbound_weight)outbound_weight,CASE "); |
| | | for (int i = 0; i < listMaterialType.get(2).size(); i++) { |
| | | operateInfo.append(" WHEN material_type=") |
| | | .append(listMaterialType.get(2).get(i)) |
| | | .append(" THEN ") |
| | | .append("'").append(listMaterialType.get(3).get(i)).append("'"); |
| | | } |
| | | |
| | | operateInfo.append(" END AS material_code ") |
| | | .append(" FROM outbound ") |
| | | .append(" WHERE ") |
| | | .append(BaseUtil.buildQuestionMarkFilter(Cmnconst.MATERIAL_TYPE, listMaterialType.get(1).toArray(), false)) |
| | | .append(" GROUP BY project_uuid,itemize,material_type ") |
| | | .append(" ) B ON A.itemize = B.itemize ") |
| | | .append(" GROUP BY A.itemize ") |
| | | .append(" )") |
| | | |
| | | .append(",intermediateData2 AS( ") |
| | | .append(" SELECT project_uuid,itemize,material_type,material_code,outbound_weight FROM outbound WHERE ") |
| | | .append(BaseUtil.buildQuestionMarkFilter(Cmnconst.MATERIAL_TYPE, listMaterialType.get(1).toArray(), true)) |
| | | .append(" )") |
| | | |
| | | .append(",intermediateData3 AS( ") |
| | | .append(" SELECT A.itemize,A.total_outbound_weight,B.material_type,material_code,outbound_weight"); |
| | | for (int i = 0; i < listMaterialType.get(3).size(); i++) { |
| | | operateInfo.append(",A.").append(listMaterialType.get(3).get(i)); |
| | | } |
| | | operateInfo.append(" FROM( ") |
| | | .append(" SELECT A.itemize,C.total_outbound_weight "); |
| | | for (int i = 0; i < listMaterialType.get(3).size(); i++) { |
| | | operateInfo.append(",B.").append(listMaterialType.get(3).get(i)); |
| | | } |
| | | operateInfo.append(" FROM allitemize A ") |
| | | .append(" LEFT JOIN intermediateData1 B ON A.itemize = B.itemize ") |
| | | .append(" LEFT JOIN getItemizeSum C ON A.itemize = C.itemize ") |
| | | .append(" )A ") |
| | | .append(" LEFT JOIN intermediateData2 B ON A.itemize = B.itemize ") |
| | | .append(" ) ") |
| | | .append(" select * from intermediateData3 "); |
| | | |
| | | StringBuilder totalSum = new StringBuilder(""); |
| | | totalSum.append(" SELECT material_code,ROUND(SUM(outbound_weight),1) outbound_weight FROM outbound WHERE ") |
| | | .append(BaseUtil.buildQuestionMarkFilter(Cmnconst.MATERIAL_TYPE, listMaterialType.get(1).toArray(), true)) |
| | | .append(" GROUP BY material_code ") |
| | | .append(" UNION ALL ") |
| | | .append(" SELECT CASE "); |
| | | for (int i = 0; i < listMaterialType.get(2).size(); i++) { |
| | | totalSum.append(" WHEN material_type=") |
| | | .append(listMaterialType.get(2).get(i)) |
| | | .append(" THEN ") |
| | | .append("'").append(listMaterialType.get(3).get(i)).append("'"); |
| | | } |
| | | totalSum.append(" END, ROUND(SUM(outbound_weight),1)") |
| | | .append(" FROM outbound WHERE ") |
| | | .append(BaseUtil.buildQuestionMarkFilter(Cmnconst.MATERIAL_TYPE, listMaterialType.get(2).toArray(), true)) |
| | | .append(" GROUP BY material_type ") |
| | | .append(" UNION ALL ") |
| | | .append(" SELECT 'å计',ROUND(SUM(outbound_weight)/1000,1) FROM outbound WHERE material_type IN (0,1,3) GROUP BY project_uuid "); |
| | | |
| | | //è·åSQLè§£æçåºæ¬æ°æ®ï¼å©ç¨JAVAå°é¡¹ç®å项对åºçä¸åææè¡è½¬å |
| | | DataTableEntity dtItemizeInfo = baseDao.listTable(outboundInfo.toString() + operateInfo.toString(), new Object[]{project_uuid}); |
| | | if (!BaseUtil.dataTableIsEmpty(dtItemizeInfo)) { |
| | | |
| | | Map<String, FieldSetEntity> convertData = new HashMap<>(); |
| | | String[] materialTypes = new String[4]; |
| | | |
| | | //éè¿Java循ç¯å°"ææ"å"åºåºé"æ°æ®è¡è½¬å |
| | | for (int i = 0; i < dtItemizeInfo.getRows(); i++) { |
| | | FieldSetEntity fseItemize = dtItemizeInfo.getFieldSetEntity(i); |
| | | |
| | | //è·åææç¼ç ï¼ææç±»åï¼åºåºé |
| | | String materialCode = fseItemize.getString(Cmnconst.MATERIAL_CODE); |
| | | String outboundWeight = fseItemize.getString(Cmnconst.OUTBOUND_WEIGHT); |
| | | Integer materialType = fseItemize.getInteger(Cmnconst.MATERIAL_TYPE); |
| | | |
| | | //æ¶éè·åææè¡¨å¤´åï¼ææç¼ç ï¼,æ¶ç«çå声æµç®¡æ²¡æè¡¨å¤´ |
| | | if (!BaseUtil.strIsNull(materialCode)) { |
| | | if (BaseUtil.strIsNull(materialTypes[materialType])) { |
| | | materialTypes[materialType] = materialCode; |
| | | } else { |
| | | if(materialTypes[fseItemize.getInteger(Cmnconst.MATERIAL_TYPE)].indexOf(materialCode)<0) { |
| | | materialTypes[fseItemize.getInteger(Cmnconst.MATERIAL_TYPE)] += "," + materialCode; |
| | | } |
| | | } |
| | | } |
| | | |
| | | //æ¶éè¡è½¬åæ°æ® |
| | | String itemize = fseItemize.getString(Cmnconst.ITEMIZE); |
| | | if (convertData.containsKey(itemize)) { |
| | | convertData.get(itemize).setValue(materialCode, outboundWeight); |
| | | } else { |
| | | FieldSetEntity fseConvertData = new FieldSetEntity(Cmnconst.PRODUCT_PROJECT_QXLW); |
| | | fseConvertData.setValue(Cmnconst.ITEMIZE, itemize); |
| | | fseConvertData.setValue(Cmnconst.TOTAL_OUTBOUND_WEIGHT, fseItemize.getString(Cmnconst.TOTAL_OUTBOUND_WEIGHT)); |
| | | fseConvertData.setValue(materialCode, outboundWeight); |
| | | for (int j = 0; j < listMaterialType.get(3).size(); j++) { |
| | | fseConvertData.setValue(listMaterialType.get(3).get(j), fseItemize.getString(listMaterialType.get(3).get(j))); |
| | | } |
| | | fseConvertData.setValue("jlj", fseItemize.getString("jlj")); |
| | | fseConvertData.setValue("scg", fseItemize.getString("scg")); |
| | | convertData.put(itemize, fseConvertData); |
| | | } |
| | | } |
| | | |
| | | //è®¡ç®æ±æ» |
| | | DataTableEntity dtTotalInfo = baseDao.listTable(outboundInfo.toString() + totalSum.toString(), new Object[]{project_uuid}); |
| | | FieldSetEntity fseConvertData = new FieldSetEntity(Cmnconst.PRODUCT_PROJECT_QXLW); |
| | | if (!BaseUtil.dataTableIsEmpty(dtTotalInfo)) { |
| | | for (int i = 0; i < dtTotalInfo.getRows(); i++) { |
| | | FieldSetEntity fseTotalInfo = dtTotalInfo.getFieldSetEntity(i); |
| | | String materialCode = fseTotalInfo.getString(Cmnconst.MATERIAL_CODE); |
| | | String outboundWeight = fseTotalInfo.getString(Cmnconst.OUTBOUND_WEIGHT); |
| | | if (!BaseUtil.strIsNull(materialCode) && !BaseUtil.strIsNull(outboundWeight)) { |
| | | if ("å计".equals(materialCode)) { |
| | | fseConvertData.setValue(Cmnconst.ITEMIZE, "å计"); |
| | | fseConvertData.setValue(Cmnconst.TOTAL_OUTBOUND_WEIGHT, outboundWeight); |
| | | }else { |
| | | fseConvertData.setValue(materialCode, outboundWeight); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | //å°æ°æ®è½¬ä¸ºDataTableEntityè¿å |
| | | if (!convertData.isEmpty()) { |
| | | DataTableEntity finalConvertData = new DataTableEntity(); |
| | | convertData.forEach((k, v) -> { |
| | | finalConvertData.addFieldSetEntity(v); |
| | | }); |
| | | finalConvertData.addFieldSetEntity(fseConvertData); |
| | | returnJson.set("data", BaseUtil.dataTableEntityToJson(finalConvertData)); |
| | | } |
| | | //å°è¡¨å¤´æ°æ®è¿å |
| | | for (int i = 0; i < materialTypes.length; i++) { |
| | | if (!BaseUtil.strIsNull(materialTypes[i])) { |
| | | returnJson.set("type" + i, materialTypes[i]); |
| | | } |
| | | } |
| | | } |
| | | return returnJson; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * è¿åææç±»åä¿¡æ¯ |
| | | * listSummary éè¦æ±æ»çææ |
| | | * listShowMaterialCode éè¦å±ç¤ºææç¼ç çææ |
| | | * listNotShowMaterialCode ä¸éè¦å±ç¤ºææç¼ç çææ |
| | | * listNotShowMaterialCodeName ä¸éè¦å±ç¤ºææç¼ç çææç±»ååç§° |
| | | * @return |
| | | */ |
| | | public List<List<String>> getReportMaterialType() { |
| | | |
| | | DataTableEntity dtMaterialType = baseDao.listTable("product_sys_dict", "dict_name = ?", new Object[] {Cmnconst.MATERIAL_TYPE}, new Object[] {"dict_value","dict_label"}); |
| | | if (!BaseUtil.dataTableIsEmpty(dtMaterialType)) { |
| | | |
| | | List<List<String>> returnList = new ArrayList<>(); |
| | | List<String> listSummary = new ArrayList<>(); |
| | | List<String> listShowMaterialCode = new ArrayList<>(); |
| | | List<String> listNotShowMaterialCode = new ArrayList<>(); |
| | | List<String> listNotShowMaterialCodeName = new ArrayList<>(); |
| | | |
| | | for (int i = 0; i < dtMaterialType.getRows(); i++) { |
| | | String dictValue = dtMaterialType.getFieldSetEntity(i).getString("dict_value"); |
| | | String dictLabel = dtMaterialType.getFieldSetEntity(i).getString("dict_label"); |
| | | if ("0".equals(dictValue)) { |
| | | listSummary.add(dictValue); |
| | | listShowMaterialCode.add(dictValue); |
| | | }else if ("1".equals(dictValue)) { |
| | | listSummary.add(dictValue); |
| | | listNotShowMaterialCode.add(dictValue); |
| | | listNotShowMaterialCodeName.add(dictLabel); |
| | | }else if ("3".equals(dictValue)) { |
| | | listShowMaterialCode.add(dictValue); |
| | | }else { |
| | | listNotShowMaterialCode.add(dictValue); |
| | | listNotShowMaterialCodeName.add(dictLabel); |
| | | } |
| | | } |
| | | returnList.add(listSummary); |
| | | returnList.add(listShowMaterialCode); |
| | | returnList.add(listNotShowMaterialCode); |
| | | returnList.add(listNotShowMaterialCodeName); |
| | | |
| | | return returnList; |
| | | } |
| | | return null; |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.product.project.management.util; |
| | | |
| | | import com.product.util.BaseUtil; |
| | | |
| | | public class ProjectItemUtil { |
| | | |
| | | /** |
| | | * æ ¹æ®å级æå¤§ç¼ç ï¼èªå¨çæå½åç¼ç |
| | | * @param oldCode å级æå¤§ç¼ç |
| | | * @return |
| | | */ |
| | | public static String autoAddOneCode(String oldCode) { |
| | | if (BaseUtil.strIsNull(oldCode)) { |
| | | oldCode = "000"; |
| | | } |
| | | String lastCode = null; |
| | | String prefixCode = null; |
| | | if (oldCode.contains("-")) { |
| | | lastCode = oldCode.substring(oldCode.lastIndexOf("-")+1, oldCode.length()); |
| | | prefixCode = oldCode.substring(0, oldCode.lastIndexOf("-")+1); |
| | | }else { |
| | | lastCode = oldCode; |
| | | } |
| | | |
| | | int codeNum = Integer.parseInt(lastCode); |
| | | codeNum++; |
| | | |
| | | String finalLastCode; |
| | | if (codeNum<10) { |
| | | finalLastCode="00"+codeNum; |
| | | }else if(codeNum<100) { |
| | | finalLastCode = "0"+codeNum; |
| | | }else { |
| | | finalLastCode = ""+codeNum; |
| | | } |
| | | |
| | | return (BaseUtil.strIsNull(prefixCode)) ? finalLastCode:prefixCode+finalLastCode; |
| | | } |
| | | |
| | | public static String autoCreateCode(String parentCode) { |
| | | if (BaseUtil.strIsNull(parentCode)) { |
| | | return "001"; |
| | | }else { |
| | | return parentCode+"-001"; |
| | | } |
| | | } |
| | | |
| | | public static void main(String[] args) { |
| | | System.out.println(autoCreateCode("")); |
| | | } |
| | | } |