蔡德晨 5 年之前
父節點
當前提交
71cd635b18

+ 57 - 14
src/main/java/com/jeeplus/modules/sg/project/mapper/xml/ProjectMapper.xml

@@ -4,22 +4,48 @@
     
 	<sql id="infoColumns">
 		a.id AS "id",
-		a.create_by AS "createBy.id",
-		a.create_date AS "createDate",
-		a.update_by AS "updateBy.id",
-		a.update_date AS "updateDate",
-		a.remarks AS "remarks",
-		a.del_flag AS "delFlag",
-		a.project_name AS "projectName",
-		a.number AS "number",
-		a.parent_node AS "parentNode",
-		b.name AS "userName"
+		a.create_by,
+		a.create_date ,
+		a.update_by ,
+		a.update_date ,
+		a.remarks ,
+		a.del_flag,
+		a.project_name,
+		a.number ,
+		b.name ,
+		d.item_name ,
+		d.unit,
+		d.type,
+		d.project_id,
+		d.create_date AS "d.create_date"
 	</sql>
 
-	<select id="get" resultType="WbsProject" >
+	<resultMap id="projectResult" type="WbsProject">
+		<id property="id" column="id"/>
+		<result property="createBy.id" column="create_by"/>
+		<result property="createDate" column="create_date"/>
+		<result property="updateBy.id" column="update_by"/>
+		<result property="updateDate" column="update_date"/>
+		<result property="remarks" column="remarks"/>
+		<result property="delFlag" column="del_flag"/>
+		<result property="projectName" column="project_name"/>
+		<result property="number" column="number"/>
+		<result property="userName" column="name"/>
+		<collection property="wbsItems" ofType="com.jeeplus.modules.sg.project.entity.WbsItem">
+			<result property="itemName" column="item_name"/>
+			<result property="unit" column="unit"/>
+			<result property="type" column="type"/>
+			<result property="projectId" column="project_id"/>
+			<result property="createDate" column="d.create_date"/>
+		</collection>
+	</resultMap>
+
+	<select id="get" resultMap="projectResult" >
 		SELECT 
 			<include refid="infoColumns"/>
-		FROM sg_wbs_project a   left join sys_user b on a.create_by = b.id
+		FROM sg_wbs_project a
+		left join sys_user b on a.create_by = b.id
+		left join sg_wbs_item d on a.id = d.project_id
 		WHERE a.id = #{id}
 	</select>
 
@@ -41,10 +67,12 @@
 		order by a.create_date DESC
 	</select>
 	
-	<select id="getList" resultType="WbsProject" parameterType="com.jeeplus.modules.sg.project.entity.WbsSelection" >
+	<select id="getList" resultMap="projectResult" parameterType="com.jeeplus.modules.sg.project.entity.WbsSelection" >
 		SELECT 
 			<include refid="infoColumns"/>
-		FROM sg_wbs_project a   left join sys_user b on a.create_by = b.id
+		FROM sg_wbs_project a
+		left join sys_user b on a.create_by = b.id
+		left join sg_wbs_item d on a.id = d.project_id
 		<where>
 		    <if test="projectId !=null and projectId != ''">
 				a.id = #{projectId} AND
@@ -61,6 +89,21 @@
 			<if test="projectEndDate != null and projectEndDate != ''">
 				 a.create_date &lt;= #{projectEndDate} AND
 			</if>
+			<if test="itemName != null and itemName != ''">
+				 d.item_name LIKE CONCAT(CONCAT('%',#{itemName},'%')) AND
+			</if>
+			<if test="type != null  and type != ''">
+				 d.type LIKE CONCAT(CONCAT('%',#{type},'%')) AND
+			</if>
+			<if test="unit != null  and unit != ''">
+				 d.unit LIKE CONCAT(CONCAT('%',#{unit},'%')) AND
+			</if>
+			<if test="itemStartDate != null and itemEndDate != ''">
+				 d.create_date &gt;= #{itemStartDate} AND
+			</if>
+			<if test="itemEndDate != null and itemEndDate != ''">
+				 d.create_date &lt;= #{itemEndDate} AND
+			</if>
 			1 = 1
 		</where>
 		 ORDER BY a.update_date DESC

+ 15 - 15
src/main/java/com/jeeplus/modules/sg/project/service/ProjectService.java

@@ -36,21 +36,21 @@ public class ProjectService extends CrudService<ProjectMapper, WbsProject> {
 
     public List<WbsProject> findList(WbsSelection wbsSelection) {
         List<WbsProject> list =  projectMapper.getList(wbsSelection);
-            for(WbsProject wbsProject1 : list){
-                String id = wbsProject1.getId();
-                wbsSelection.setProjectId(id);
-                List<WbsItem> items = itemService.findList(wbsSelection);
-                wbsProject1.setWbsItems(items);
-            }
-         if(StringUtils.isNoneBlank(wbsSelection.getItemName()) || wbsSelection.getItemStartDate() != null || wbsSelection.getItemEndDate() != null || StringUtils.isNoneBlank(wbsSelection.getUnit()) || StringUtils.isNoneBlank(wbsSelection.getType())){
-             List<WbsProject> wbsProjects = new ArrayList<>();
-             for(WbsProject wbsProject : list){
-                 if(wbsProject.getWbsItems().size()>0){
-                     wbsProjects.add(wbsProject);
-                 }
-             }
-             return wbsProjects;
-         }
+//            for(WbsProject wbsProject1 : list){
+//                String id = wbsProject1.getId();
+//                wbsSelection.setProjectId(id);
+//                List<WbsItem> items = itemService.findList(wbsSelection);
+//                wbsProject1.setWbsItems(items);
+//            }
+//         if(StringUtils.isNoneBlank(wbsSelection.getItemName()) || wbsSelection.getItemStartDate() != null || wbsSelection.getItemEndDate() != null || StringUtils.isNoneBlank(wbsSelection.getUnit()) || StringUtils.isNoneBlank(wbsSelection.getType())){
+//             List<WbsProject> wbsProjects = new ArrayList<>();
+//             for(WbsProject wbsProject : list){
+//                 if(wbsProject.getWbsItems().size()>0){
+//                     wbsProjects.add(wbsProject);
+//                 }
+//             }
+//             return wbsProjects;
+//         }
         return list;
     }
 

+ 0 - 2
src/main/java/com/jeeplus/modules/sg/project/web/ProjectTemController.java

@@ -68,8 +68,6 @@ public class ProjectTemController extends BaseController {
         WbsProject wbsProject = new WbsProject();
         wbsProject.setProjectName(projectName);
         projectService.save(wbsProject);
-//        List<WbsProject> wbsProjects = projectService.findByName(projectName);
-//        WbsProject wbsProject1 = wbsProjects.get(0);
         String projectId = wbsProject.getId();
         try {
             for(int i = 0;i<itemTypes.length;i++) {