Enford 5 anni fa
parent
commit
2d433f09bc

+ 142 - 0
src/main/java/com/jeeplus/modules/sg/managementcenter/projectPlanArrage/entity/ProjectDailyPlan.java

@@ -0,0 +1,142 @@
+package com.jeeplus.modules.sg.managementcenter.projectPlanArrage.entity;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.jeeplus.common.utils.excel.annotation.ExcelField;
+import com.jeeplus.core.persistence.DataEntity;
+
+import java.util.Date;
+
+public class ProjectDailyPlan extends DataEntity<ProjectDailyPlan> {
+    private String projectName; //项目名称
+    private String projectNumber; //项目定义号
+    private String projectLine; //线路
+    private String projectPowerRange; //停电范围
+    private String projectSwitch; //停电开关
+    private Date projectMonthDate; //停电月份
+    private Date projectDate; //停电日
+    private String projectPowerOut; //是否停电
+    private String status; //状态
+
+
+    private String distributionNetwork;//配网项目经理
+    private String constructionUnit;//施工单位项目经理
+    private String operationUnit;//运行单位项目经理
+
+    private String flagYesElectricity;//是否二次涉电
+
+    private String arrangeDailyPlan;//安排日计划的状态(0-未安排 1-已安排)
+
+    public String getArrangeDailyPlan() {
+        return arrangeDailyPlan;
+    }
+
+    public void setArrangeDailyPlan(String arrangeDailyPlan) {
+        this.arrangeDailyPlan = arrangeDailyPlan;
+    }
+
+    @ExcelField(title="项目名称", align=2, sort=1)
+    public String getProjectName() {
+        return projectName;
+    }
+
+    public void setProjectName(String projectName) {
+        this.projectName = projectName;
+    }
+    @ExcelField(title="项目定义号", align=2, sort=2)
+    public String getProjectNumber() {
+        return projectNumber;
+    }
+
+    public void setProjectNumber(String projectNumber) {
+        this.projectNumber = projectNumber;
+    }
+
+    public String getProjectLine() {
+        return projectLine;
+    }
+
+    public void setProjectLine(String projectLine) {
+        this.projectLine = projectLine;
+    }
+    @ExcelField(title="停电范围", align=2, sort=3)
+    public String getProjectPowerRange() {
+        return projectPowerRange;
+    }
+
+    public void setProjectPowerRange(String projectPowerRange) {
+        this.projectPowerRange = projectPowerRange;
+    }
+
+    public String getProjectSwitch() {
+        return projectSwitch;
+    }
+
+    public void setProjectSwitch(String projectSwitch) {
+        this.projectSwitch = projectSwitch;
+    }
+    @JsonFormat(pattern = "YYYY-MM")
+    public Date getProjectMonthDate() {
+        return projectMonthDate;
+    }
+
+    public void setProjectMonthDate(Date projectMonthDate) {
+        this.projectMonthDate = projectMonthDate;
+    }
+    @ExcelField(title="日计划", align=2, sort=4)
+    @JsonFormat(pattern = "YYYY-MM-dd")
+    public Date getProjectDate() {
+        return projectDate;
+    }
+
+    public void setProjectDate(Date projectDate) {
+        this.projectDate = projectDate;
+    }
+    @ExcelField(title="是否停电", align=2, sort=5)
+    public String getProjectPowerOut() {
+        return projectPowerOut;
+    }
+
+    public void setProjectPowerOut(String projectPowerOut) {
+        this.projectPowerOut = projectPowerOut;
+    }
+
+    public String getStatus() {
+        return status;
+    }
+
+    public void setStatus(String status) {
+        this.status = status;
+    }
+    @ExcelField(title="配网项目经理", align=2, sort=6)
+    public String getDistributionNetwork() {
+        return distributionNetwork;
+    }
+
+    public void setDistributionNetwork(String distributionNetwork) {
+        this.distributionNetwork = distributionNetwork;
+    }
+    @ExcelField(title="施工单位项目经理", align=2, sort=7)
+    public String getConstructionUnit() {
+        return constructionUnit;
+    }
+
+    public void setConstructionUnit(String constructionUnit) {
+        this.constructionUnit = constructionUnit;
+    }
+    @ExcelField(title="运行单位人员", align=2, sort=8)
+    public String getOperationUnit() {
+        return operationUnit;
+    }
+
+    public void setOperationUnit(String operationUnit) {
+        this.operationUnit = operationUnit;
+    }
+
+    public String getFlagYesElectricity() {
+        return flagYesElectricity;
+    }
+
+    public void setFlagYesElectricity(String flagYesElectricity) {
+        this.flagYesElectricity = flagYesElectricity;
+    }
+}

+ 35 - 0
src/main/java/com/jeeplus/modules/sg/managementcenter/projectPlanArrage/mapper/ProjectDailyPlanMapper.java

@@ -0,0 +1,35 @@
+package com.jeeplus.modules.sg.managementcenter.projectPlanArrage.mapper;
+
+import com.jeeplus.core.persistence.BaseMapper;
+import com.jeeplus.core.persistence.annotation.MyBatisMapper;
+import com.jeeplus.modules.sg.managementcenter.materialproject.entity.MaterialProject;
+import com.jeeplus.modules.sg.managementcenter.projectPlanArrage.entity.ProjectAssignment;
+import com.jeeplus.modules.sg.managementcenter.projectPlanArrage.entity.ProjectDailyPlan;
+import com.jeeplus.modules.sg.managementcenter.projectPlanArrage.entity.ProjectPlanArrage;
+import com.jeeplus.modules.sg.managementcenter.projectPlanArrage.entity.ProjectQuantity;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+@MyBatisMapper
+public interface ProjectDailyPlanMapper extends BaseMapper<ProjectDailyPlan> {
+    //循环增加项目
+    Integer insertList(@Param("list") List<ProjectDailyPlan> projectDailyPlans);
+
+    //查找项目表中状态为安排日计划的项目(arrangePlan = 3,可包含月计划)
+    List<MaterialProject> findListMaterialProject(MaterialProject materialProject);
+
+    //获取停电范围
+    List<ProjectQuantity> findListQuantity(@Param("list") List<ProjectDailyPlan> list);
+
+    //根据项目名称查找人员表
+    List<ProjectAssignment> findListAssignment(@Param("list") List<ProjectDailyPlan> list);
+
+    //删除月计划项目
+    Integer deleteMonthPlan(@Param("list")List<ProjectDailyPlan> list);
+
+    //修改项目
+    Integer updateMartailDaily(@Param("list")List<ProjectDailyPlan> list);
+
+
+}

+ 285 - 0
src/main/java/com/jeeplus/modules/sg/managementcenter/projectPlanArrage/mapper/xml/ProjectDailyPlanMapper.xml

@@ -0,0 +1,285 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.jeeplus.modules.sg.managementcenter.projectPlanArrage.mapper.ProjectDailyPlanMapper">
+	<sql id="constructionColumns">
+		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.projectName AS "projectName",
+		a.projectNumber AS "projectNumber",
+		a.projectLine AS "projectLine",
+		a.projectPowerRange AS "projectPowerRange",
+		a.projectSwitch AS "projectSwitch",
+		a.projectMonthDate AS "projectMonthDate",
+		a.projectDate AS "projectDate",
+		a.projectPowerOut AS "projectPowerOut",
+		a.status AS "status",
+  		a.flagYesElectricity AS "flagYesElectricity"
+	</sql>
+	<select id="get" resultType="com.jeeplus.modules.sg.managementcenter.projectPlanArrage.entity.ProjectDailyPlan" >
+		SELECT
+		<include refid="constructionColumns"/>
+		FROM xm_project_plan_daily a
+		WHERE a.id = #{id}
+	</select>
+
+	<select id="findList" resultType="com.jeeplus.modules.sg.managementcenter.projectPlanArrage.entity.ProjectDailyPlan" >
+		SELECT
+		<include refid="constructionColumns"/>
+		FROM xm_project_plan_daily a
+		<where>
+			a.del_flag = #{DEL_FLAG_NORMAL}
+			${dataScope}
+		</where>
+		<choose>
+			<when test="page !=null and page.orderBy != null and page.orderBy != ''">
+				ORDER BY ${page.orderBy}
+			</when>
+			<otherwise>
+				ORDER BY a.update_date DESC
+			</otherwise>
+		</choose>
+	</select>
+
+	<insert id="insert">
+		  INSERT INTO xm_project_plan_daily(
+			id,
+			create_by,
+			create_date,
+			update_by,
+			update_date,
+			remarks,
+			del_flag,
+			projectName,
+			projectNumber,
+			projectLine,
+			projectPowerRange,
+			projectSwitch,
+			projectMonthDate,
+			projectDate,
+			projectPowerOut,
+			status,
+		  	flagYesElectricity
+		) VALUES
+		(
+			#{id},
+			#{createBy.id},
+			#{createDate},
+			#{updateBy.id},
+			#{updateDate},
+			#{remarks},
+			#{delFlag},
+			#{projectName},
+			#{projectNumber},
+			#{projectLine},
+			#{projectPowerRange},
+			#{projectSwitch},
+			#{projectMonthDate},
+			#{projectDate},
+			#{projectPowerOut},
+			#{status},
+			#{associatedBag},
+			#{powerPackage},
+			#{flagYesElectricity}
+		)
+	</insert>
+
+	<insert id="insertList">
+		replace INTO xm_project_plan_daily(
+		id,
+		create_by,
+		create_date,
+		update_by,
+		update_date,
+		remarks,
+		del_flag,
+		projectName,
+		projectNumber,
+		projectLine,
+		projectPowerRange,
+		projectSwitch,
+		projectMonthDate,
+		projectDate,
+		projectPowerOut	,
+		status,
+		flagYesElectricity
+		) VALUES
+		<foreach collection="list" item="item" index="index" separator="," >
+			(
+			#{item.id},
+			#{item.createBy.id},
+			#{item.createDate},
+			#{item.updateBy.id},
+			#{item.updateDate},
+			#{item.remarks},
+			#{item.delFlag},
+			#{item.projectName},
+			#{item.projectNumber},
+			#{item.projectLine},
+			#{item.projectPowerRange},
+			#{item.projectSwitch},
+			#{item.projectMonthDate},
+			#{item.projectDate},
+			#{item.projectPowerOut},
+			#{item.status},
+			#{item.flagYesElectricity}
+			)
+		</foreach>
+	</insert>
+
+	<update id="update">
+		UPDATE xm_project_plan_daily SET
+			update_by = #{updateBy.id},
+			update_date = #{updateDate},
+			remarks = #{remarks},
+			projectName = #{projectName},
+			projectNumber = #{projectNumber},
+			projectPowerRange = #{projectPowerRange},
+			projectDate = #{projectDate},
+			projectPowerOut = #{projectPowerOut}
+		WHERE id = #{id}
+	</update>
+
+	<delete id="delete">
+		delete from xm_project_plan_daily
+		where id = #{id}
+	</delete>
+
+	<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.reserveProjectName,
+		a.reserveCode,
+		a.projectType,
+		a.batchPlan,
+		a.issuePlan,
+		a.monthPlan,
+		a.hasPlan,
+		a.halfPlan,
+		a.projectName,
+		a.projectId
+    </sql>
+	<!--查询日计划-->
+	<select id="findListMaterialProject" resultType="com.jeeplus.modules.sg.managementcenter.materialproject.entity.MaterialProject">
+		SELECT
+		<include refid="infoColumns"/>
+		FROM xm_material_project a
+		<where>
+			a.del_flag = #{DEL_FLAG_NORMAL}
+			${dataScope}
+			<if test="arrageProject != null and arrageProject != ''">
+				AND a.arrageProject = '1' or a.arrageProject = '2' or a.arrageProject = '0'
+			</if>
+		</where>
+		<choose>
+			<when test="page !=null and page.orderBy != null and page.orderBy != ''">
+				ORDER BY ${page.orderBy}
+			</when>
+			<otherwise>
+				ORDER BY a.update_date DESC
+			</otherwise>
+		</choose>
+	</select>
+
+	<sql id="quantityColumns">
+		 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.reserveProjectName AS "reserveProjectName",
+		a.includeAutomation AS "includeAutomation",
+		a.wayOf AS "wayOf",
+		a.assignmentStyle AS "assignmentStyle",
+		a.operationSubstation AS "operationSubstation",
+		a.namingNumber AS "namingNumber",
+		a.engineeringAcceptance AS "engineeringAcceptance",
+		a.electricalAcceptance AS "electricalAcceptance",
+		a.blackoutLine AS "blackoutLine",
+		a.outageRange AS "outageRange",
+		a.policyIssues AS "policyIssues",
+		a.processingType AS "processingType",
+		a.processingDescription AS "processingDescription"
+	</sql>
+	<select id="findListQuantity" resultType="com.jeeplus.modules.sg.managementcenter.projectPlanArrage.entity.ProjectQuantity">
+		SELECT
+		<include refid="quantityColumns"/>
+		FROM xm_project_quantity a
+		where a.reserveProjectName in
+		<foreach collection="list" item="item" index="index" open="(" close=")" separator=",">
+			#{item.projectName}
+		</foreach>
+	</select>
+
+	<sql id="assignmentColumns">
+		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.reserveProjectName AS "reserveProjectName",
+		a.disclosureType AS "disclosureType",
+		a.projectReleaseBatch AS "projectReleaseBatch",
+		a.deliveryDate AS "deliveryDate",
+		a.packageNo AS "packageNo",
+		a.rate AS "rate",
+		a.assignedUnit AS "assignedUnit",
+		a.constructionUnit AS "constructionUnit",
+		a.constructionSubcontractor AS "constructionSubcontractor",
+		a.behalf AS "behalf",
+		a.constructionFullTime AS "constructionFullTime",
+		a.constructionTechnical AS "constructionTechnical",
+		a.constructionManage AS "constructionManage",
+		a.constructionLeader AS "constructionLeader",
+		a.subcontractingContact AS "subcontractingContact",
+		a.designer AS "designer",
+		a.designLeader AS "designLeader",
+		a.ownerManager AS "ownerManager",
+		a.distribution AS "distribution",
+		a.distributionFullTime AS "distributionFullTime",
+		a.distributionSystem AS "distributionSystem",
+		a.distributionPolicy AS "distributionPolicy",
+		a.centerLeader AS "centerLeader",
+		a.centerTechnical AS "centerTechnical",
+		a.instituteRole AS "instituteRole",
+		a.repUnit AS "repUnit",
+		a.inspectionUnit AS "inspectionUnit"
+	</sql>
+
+	<select id="findListAssignment" resultType="com.jeeplus.modules.sg.managementcenter.projectPlanArrage.entity.ProjectAssignment">
+		SELECT
+		<include refid="assignmentColumns"/>
+		FROM xm_project_assignment a
+		where a.reserveProjectName in
+		<foreach collection="list" item="item" index="index" open="(" close=")" separator=",">
+			#{item.projectName}
+		</foreach>
+	</select>
+
+	<delete id="deleteMonthPlan">
+		delete from xm_project_plan_arrange a
+		where a.reserveProjectName in
+		<foreach collection="list" item="item" index="index" open="(" close=")" separator=",">
+			#{item.projectName}
+		</foreach>
+	</delete>
+
+	<update id="updateMartailDaily">
+		update xm_material_project a set arrageProject = '4'
+		where a.reserveProjectName in
+		<foreach collection="list" item="item" index="index" open="(" close=")" separator=",">
+			#{item.projectName}
+		</foreach>
+	</update>
+</mapper>

+ 260 - 0
src/main/java/com/jeeplus/modules/sg/managementcenter/projectPlanArrage/service/ProjectDailyPlanService.java

@@ -0,0 +1,260 @@
+package com.jeeplus.modules.sg.managementcenter.projectPlanArrage.service;
+
+import com.jeeplus.core.service.CrudService;
+import com.jeeplus.modules.sg.managementcenter.materialproject.entity.MaterialProject;
+import com.jeeplus.modules.sg.managementcenter.projectPlanArrage.entity.ProjectAssignment;
+import com.jeeplus.modules.sg.managementcenter.projectPlanArrage.entity.ProjectDailyPlan;
+import com.jeeplus.modules.sg.managementcenter.projectPlanArrage.entity.ProjectPlanArrage;
+import com.jeeplus.modules.sg.managementcenter.projectPlanArrage.entity.ProjectQuantity;
+import com.jeeplus.modules.sg.managementcenter.projectPlanArrage.mapper.ProjectDailyPlanMapper;
+import com.jeeplus.modules.sg.managementcenter.projectPlanArrage.mapper.ProjectPlanArrageMapper;
+import com.jeeplus.modules.sg.managementcenter.projectPlanArrage.util.ImportUtil;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.poi.ss.usermodel.Row;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+
+@Service
+@Transactional(readOnly = true)
+public class ProjectDailyPlanService extends CrudService<ProjectDailyPlanMapper, ProjectDailyPlan> {
+    @Autowired
+    private ProjectDailyPlanMapper projectDailyPlanMapper;
+
+    @Transactional(readOnly = false)
+    public void insertList(List<ProjectDailyPlan> projectDailyPlans){
+        for (ProjectDailyPlan projectDailyPlan:projectDailyPlans){
+            projectDailyPlan.preInsert();
+        }
+        projectDailyPlanMapper.insertList(projectDailyPlans);
+    }
+
+    @Transactional(readOnly = false)
+    public void update(ProjectDailyPlan projectDailyPlan){
+        projectDailyPlan.preUpdate();
+        projectDailyPlanMapper.update(projectDailyPlan);
+    }
+
+    //得到可以安排计划数据 统一存放在List<ProjectDailyPlan>集合当中
+    //数据库中根据字段匹配 arrageProject 3 -为已经安排过的日计划 0-1-2为月计划
+    public List<ProjectDailyPlan> getProjectDailyPlan(){
+        //初始化
+        List<ProjectDailyPlan> projectDailyPlans = new ArrayList<ProjectDailyPlan>();
+        MaterialProject materialProject = new MaterialProject();
+        materialProject.setArrageProject("1");
+        //查询项目
+        List<MaterialProject> listMaterialProject = projectDailyPlanMapper.findListMaterialProject(materialProject);
+        //得到立项信息
+        if (!listMaterialProject.isEmpty()){
+            ProjectDailyPlan projectDailyPlan =  null;
+            for (MaterialProject m:listMaterialProject){
+                //判断是否存在项目定义号以及项目名称
+                if (null!=m.getReserveProjectName()&& null!=m.getProjectId() &&!"".equals(m.getReserveProjectName())&&!"".equals(m.getProjectId())){
+                    projectDailyPlan = new ProjectDailyPlan();
+                    projectDailyPlan.setProjectName(m.getReserveProjectName());
+                    projectDailyPlan.setProjectNumber(m.getProjectId());
+                    projectDailyPlans.add(projectDailyPlan);
+                }
+            }
+        }
+        //查找开关信息
+        //得到停电范围和信息数据
+        List<ProjectQuantity> listQuantity = new ArrayList<ProjectQuantity>();
+        if (!projectDailyPlans.isEmpty()){
+            listQuantity = projectDailyPlanMapper.findListQuantity(projectDailyPlans);
+        }
+
+
+        //得到人员信息
+        List<ProjectAssignment> projectAssignments = new ArrayList<ProjectAssignment>();
+        if (!projectDailyPlans.isEmpty()){
+            projectAssignments = projectDailyPlanMapper.findListAssignment(projectDailyPlans);
+        }
+
+        //线路 人员整合一起
+        List<ProjectDailyPlan> plans = new ArrayList<ProjectDailyPlan>();
+        ProjectDailyPlan projectDailyPlan= null;
+        if (!listQuantity.isEmpty()&&!projectAssignments.isEmpty()){
+            for (ProjectQuantity projectQuantity:listQuantity){
+                for (ProjectAssignment projectAssignment:projectAssignments){
+                    if (projectQuantity.getReserveProjectName().equals(projectAssignment.getReserveProjectName())){
+                        projectDailyPlan = new ProjectDailyPlan();
+                        projectDailyPlan.setProjectName(projectQuantity.getReserveProjectName());//项目名称
+                        projectDailyPlan.setProjectPowerOut(projectQuantity.getAssignmentStyle());//是否停电
+                        projectDailyPlan.setProjectPowerRange(projectQuantity.getOutageRange());//停电范围
+                        projectDailyPlan.setConstructionUnit(projectAssignment.getConstructionManage());//施工单位项目经理
+                        projectDailyPlan.setDistributionNetwork(projectAssignment.getOwnerManager());//配网项目经理
+                        projectDailyPlan.setOperationUnit(projectAssignment.getRepUnit());//运行单位项目经理
+                        plans.add(projectDailyPlan);//添加到集合
+                        break;
+                    }
+                }
+            }
+        }
+        if (!projectDailyPlans.isEmpty()&&!plans.isEmpty()){
+            for (ProjectDailyPlan projectDailyPlan1:plans){
+                for (ProjectDailyPlan projectDailyPlan2:projectDailyPlans){
+                    if (projectDailyPlan1.getProjectName().equals(projectDailyPlan2.getProjectName())){
+                        projectDailyPlan1.setProjectNumber(projectDailyPlan2.getProjectNumber());
+                        break;
+                    }
+                }
+            }
+        }
+        return plans;
+    }
+
+    //筛选条件 -- 操作者输入的项目名称 或者项目id
+    public List<ProjectDailyPlan> getSxDailyPlan(List<ProjectDailyPlan> projectDailyPlans,ProjectDailyPlan projectDailyPlan){
+        getIdNameHash(projectDailyPlan,projectDailyPlans);
+        return projectDailyPlans;
+    }
+
+    public void getIdNameHash(ProjectDailyPlan projectDailyPlan,List<ProjectDailyPlan> projectDailyPlans){
+        String[] splitNames = null;
+        String[] splitIds = null;
+        if (null!=projectDailyPlan.getProjectName()&&!"".equals(projectDailyPlan.getProjectName())){
+            splitNames = projectDailyPlan.getProjectName().split(",");
+        }
+        if (null!=projectDailyPlan.getProjectNumber()&&!"".equals(projectDailyPlan.getProjectNumber())){
+            splitIds = projectDailyPlan.getProjectNumber().split(",");
+        }
+        for (ProjectDailyPlan plans:projectDailyPlans){
+            plans.setArrangeDailyPlan("0");
+            if (null!=splitNames){
+                for (String s:splitNames){
+                    if (s.equals(plans)){
+                        plans.setArrangeDailyPlan("1");
+                        break;
+                    }
+                }
+            }
+            if (null!=splitIds){
+                for (String id:splitIds){
+                    if (id.equals(projectDailyPlan.getProjectNumber())){
+                        plans.setArrangeDailyPlan("1");
+                        break;
+                    }
+                }
+            }
+        }
+    }
+
+    //安排日计划
+    public void addPlanDaily(List<ProjectDailyPlan> projectPlans,List<String> strings){
+        for (ProjectDailyPlan plan:projectPlans){
+            for (String str:strings){
+                if (str.equals(plan.getId())){
+                    plan.setArrangeDailyPlan("1");
+                    break;
+                }
+            }
+        }
+    }
+    //取消日计划
+    public void cancelPlanDaily(List<ProjectDailyPlan> projectPlans,List<String> strings){
+        for (ProjectDailyPlan plan:projectPlans){
+            for (String str:strings){
+                if (str.equals(plan.getId())){
+                    plan.setArrangeDailyPlan("0");
+                    break;
+                }
+            }
+        }
+    }
+
+    //检验开关是否为同一停电包--获取用户传入的数据功能
+    public List<ProjectDailyPlan> getInspectionFunction(String ids){
+        //创建list
+        List<ProjectDailyPlan> planArrages = new ArrayList<ProjectDailyPlan>();
+        String[] idsSplite = null;
+        String[] idsSpliteChild = null;
+        String id="";
+        String powerFlag = "";
+        ProjectDailyPlan projectDailyPlan = new ProjectDailyPlan();
+        if (null!=ids){
+            idsSplite = ids.split(";");
+            for (String str : idsSplite){
+                id="";
+                powerFlag="";
+                idsSpliteChild = str.split(",");
+                for (String strChild:idsSpliteChild){
+                    if (strChild.equals("停电")||strChild.equals("带电")){
+                        powerFlag = strChild;
+                    }else {
+                        id = strChild;
+                    }
+                }
+                if (!"".equals(id)){
+                    projectDailyPlan = new ProjectDailyPlan();
+                    projectDailyPlan.setId(id);
+                    projectDailyPlan.setProjectPowerOut(powerFlag);
+                    planArrages.add(projectDailyPlan);
+                }
+            }
+        }
+        return planArrages;
+    }
+    //保存
+    @Transactional(readOnly = false)
+    public void getPlanDaily(List<ProjectDailyPlan> projectPlans,List<ProjectDailyPlan> idsList){
+        List<ProjectDailyPlan> surePlan = new ArrayList<ProjectDailyPlan>();
+        //得到停电集合
+        for (ProjectDailyPlan plan:projectPlans){
+           if (plan.getArrangeDailyPlan().equals("1")){
+               for (ProjectDailyPlan ids:idsList){
+                   if (plan.getId().equals(ids.getId())){
+                       plan.setProjectPowerOut(ids.getProjectPowerOut());
+                       surePlan.add(plan);
+                       break;
+                   }
+               }
+           }
+        }
+        //保存日计划项目
+        insertList(surePlan);
+//        //去除月计划项目
+//        projectDailyPlanMapper.deleteMonthPlan(surePlan);
+//        //修改项目状态
+//        projectDailyPlanMapper.updateMartailDaily(surePlan);
+    }
+
+
+    //导入数据
+    /**
+     * 获取表格数据
+     * @param importUtil
+     * @return List<ErpAccount> 导入表格数据
+     */
+    public List<ProjectDailyPlan> getMaterProUtil(ImportUtil importUtil) throws Exception {
+        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
+        int lastRow = importUtil.getLastDataRowNum();
+        List<ProjectDailyPlan> list = new ArrayList<ProjectDailyPlan>();
+        ProjectDailyPlan projectDailyPlan = null;
+        String projectName="";//物料编码
+        for(int i=2; i<lastRow;i++){
+            projectDailyPlan = new ProjectDailyPlan();
+            Row row = importUtil.getRow(i);
+            projectName = (String)importUtil.getCellValue(row,0);
+            if (StringUtils.isNotBlank(projectName)){
+                projectDailyPlan.setProjectName(projectName);
+                projectDailyPlan.setProjectNumber((String)importUtil.getCellValue(row,1));
+                projectDailyPlan.setProjectPowerRange((String)importUtil.getCellValue(row,2));
+                if (null!=(String)importUtil.getCellValue(row,3)&&!"".equals((String)importUtil.getCellValue(row,3))){
+                    projectDailyPlan.setProjectDate(format.parse((String)importUtil.getCellValue(row,3)));
+                }
+                projectDailyPlan.setProjectPowerOut((String)importUtil.getCellValue(row,4));
+                projectDailyPlan.setDistributionNetwork((String)importUtil.getCellValue(row,5));
+                projectDailyPlan.setConstructionUnit((String)importUtil.getCellValue(row,6));
+                projectDailyPlan.setOperationUnit((String)importUtil.getCellValue(row,7));
+                list.add(projectDailyPlan);
+            }
+        }
+        return list;
+    }
+}

+ 29 - 1
src/main/java/com/jeeplus/modules/sg/managementcenter/projectPlanArrage/util/BookStrapTreeUtil.java

@@ -2,15 +2,17 @@ package com.jeeplus.modules.sg.managementcenter.projectPlanArrage.util;
 
 import com.google.common.collect.Lists;
 import com.google.common.collect.Maps;
+import com.jeeplus.modules.sg.managementcenter.projectPlanArrage.entity.ProjectDailyPlan;
 import com.jeeplus.modules.sg.managementcenter.projectPlanArrage.entity.ProjectPlanArrage;
 import com.jeeplus.modules.sys.utils.UserUtils;
 
+import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
 public class BookStrapTreeUtil {
-
+    //月计划安排树
     public static List<Map<String,Object>> getAllBookStrapTree(List<Map<String,Object>> objects, List<ProjectPlanArrage> projectPlanArrages,String bs){
         List<Map<String, Object>> bookStrapTree = getBookStrapTree(objects, projectPlanArrages,bs);
         List<Map<String,Object>> allBookStrapTree = Lists.newArrayList();
@@ -76,4 +78,30 @@ public class BookStrapTreeUtil {
         }
         return flag;
     }
+
+    //日计划安排树
+    //获取树
+    public static List<Map<String,Object>> getDailyBookStrapTree(List<Map<String,Object>> objects, List<ProjectDailyPlan> projectDailyPlans){
+        List<Map<String, Object>> dailyChildTree = getDailyChildTree(projectDailyPlans);
+        Map<String,Object> map = Maps.newHashMap();
+        map.put("id","-1");
+        map.put("name","未安排的日计划项目");
+        map.put("children",dailyChildTree);
+        objects.add(map);
+        return objects;
+    }
+    //获取子类树
+    public static List<Map<String,Object>>  getDailyChildTree(List<ProjectDailyPlan> projectDailyPlans){
+        List<Map<String,Object>> objects = Lists.newArrayList();
+        Map<String,Object> maps = null;
+        for (ProjectDailyPlan plan:projectDailyPlans){
+            if (!plan.getArrangeDailyPlan().equals("1")){
+                maps = Maps.newHashMap();
+                maps.put("id",plan.getId());
+                maps.put("name",plan.getProjectName());
+                objects.add(maps);
+            }
+        }
+        return objects;
+    }
 }

+ 322 - 0
src/main/java/com/jeeplus/modules/sg/managementcenter/projectPlanArrage/web/ProjectDailyPlanController.java

@@ -0,0 +1,322 @@
+package com.jeeplus.modules.sg.managementcenter.projectPlanArrage.web;
+
+import com.google.common.collect.Lists;
+import com.jeeplus.common.json.AjaxJson;
+import com.jeeplus.common.utils.DateUtils;
+import com.jeeplus.common.utils.excel.ExportExcel;
+import com.jeeplus.core.persistence.Page;
+import com.jeeplus.core.web.BaseController;
+import com.jeeplus.modules.sg.managementcenter.projectPlanArrage.entity.ProjectActProclnsAss;
+import com.jeeplus.modules.sg.managementcenter.projectPlanArrage.entity.ProjectDailyPlan;
+import com.jeeplus.modules.sg.managementcenter.projectPlanArrage.entity.ProjectPlanArrage;
+import com.jeeplus.modules.sg.managementcenter.projectPlanArrage.service.ProjectDailyPlanService;
+import com.jeeplus.modules.sg.managementcenter.projectPlanArrage.service.ProjectPlanArrageService;
+import com.jeeplus.modules.sg.managementcenter.projectPlanArrage.util.BookStrapTreeUtil;
+import com.jeeplus.modules.sg.managementcenter.projectPlanArrage.util.ImportUtil;
+import com.jeeplus.modules.sg.managementcenter.projectPlanArrage.util.PackagingUtil;
+import com.jeeplus.modules.sg.managementcenter.projectPlanArrage.util.Result;
+import com.jeeplus.modules.sys.utils.UserUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.Model;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.multipart.MultipartFile;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import static com.jeeplus.core.service.BaseService.dataRuleFilter;
+
+/**
+ * 日计划
+ */
+@Controller
+@RequestMapping(value = "${adminPath}/sg/managementCenter/projectDailyPlan")
+public class ProjectDailyPlanController extends BaseController {
+
+    @Autowired
+    private ProjectPlanArrageService projectPlanArrageService;
+
+    @Autowired
+    private ProjectDailyPlanService projectDailyPlanService;
+    //主页面 list
+    @RequestMapping(value = {"list", ""})
+    public String list(ProjectDailyPlan projectDailyPlan, Model model) {
+        model.addAttribute("projectDailyPlan", projectDailyPlan);
+        return "modules/sg/managementcenter/projectPlanArrage/dailyPlan/projectDailyPlanList";
+    }
+
+    //新增页面
+    @RequestMapping(value = "formProject")
+    public String List(ProjectDailyPlan projectDailyPlan,Model model){
+        return "modules/sg/managementcenter/projectPlanArrage/dailyPlan/projectDailyDateForm";
+    }
+
+    @ResponseBody
+//	@RequiresPermissions("managementcenter:materialproject:list")
+    @RequestMapping(value = "data")
+    public Map<String, Object> data(ProjectDailyPlan projectDailyPlan, HttpServletRequest request, HttpServletResponse response, Model model) {
+        Page<ProjectDailyPlan> page = projectDailyPlanService.findPage(new Page<ProjectDailyPlan>(request, response), projectDailyPlan);
+        return getBootstrapData(page);
+    }
+
+    //删除操作
+    @ResponseBody
+    @RequestMapping(value = "deleteAll")
+    public AjaxJson deleteAll(ProjectDailyPlan projectDailyPlan,String ids,HttpServletRequest request){
+        AjaxJson ajaxJson = new AjaxJson();
+        ProjectDailyPlan dailyPlan = null;
+        try {
+            if (ids.contains(",")){
+                String[] split = ids.split(",");
+                for (String str : split){
+                    dailyPlan = new ProjectDailyPlan();
+                    dailyPlan.setId(str);
+                    projectDailyPlanService.delete(dailyPlan);
+                }
+            }else {
+                dailyPlan = new ProjectDailyPlan();
+                dailyPlan.setId(ids);
+                projectDailyPlanService.delete(dailyPlan);
+            }
+            ajaxJson.setSuccess(true);
+            ajaxJson.setMsg("删除成功");
+            return ajaxJson;
+        }catch (Exception e){
+            e.printStackTrace();
+        }
+        ajaxJson.setSuccess(false);
+        ajaxJson.setMsg("删除失败");
+        return ajaxJson;
+    }
+
+    @ResponseBody
+    @RequestMapping(value = "export")
+    public AjaxJson exportFile(ProjectDailyPlan projectDailyPlan, HttpServletRequest request, HttpServletResponse response) {
+        AjaxJson j = new AjaxJson();
+        try {
+            String fileName = "日计划安排表"+ DateUtils.getDate("yyyyMMddHHmmss")+".xlsx";
+            Page<ProjectDailyPlan> page = projectDailyPlanService.findPage(new Page<ProjectDailyPlan>(request, response, -1), projectDailyPlan);
+            new ExportExcel("日计划安排表", ProjectDailyPlan.class).setDataList(page.getList()).write(response, fileName).dispose();
+            j.setSuccess(true);
+            j.setMsg("导出成功!");
+            return j;
+        } catch (Exception e) {
+            j.setSuccess(false);
+            j.setMsg("导出日计划安排记录失败!失败信息:"+e.getMessage());
+        }
+        return j;
+    }
+
+    //新增日计划选择项目定义号,或者项目名称后走的方法(可不选)
+    @RequestMapping(value = "initAddDailyPlan")
+    public String getInitAddDailyPlan(ProjectDailyPlan projectDailyPlan,Model model,HttpServletRequest request){
+        //获取所有为安排的日计划
+        List<ProjectDailyPlan> projectDailyPlans = projectDailyPlanService.getProjectDailyPlan();
+        List<ProjectDailyPlan> sxDailyPlan = projectDailyPlanService.getSxDailyPlan(projectDailyPlans, projectDailyPlan);
+        for (ProjectDailyPlan plan:sxDailyPlan){
+            plan.preInsert();
+        }
+        request.getSession().setAttribute("sxDailyPlan",sxDailyPlan);
+        return "modules/sg/managementcenter/projectPlanArrage/dailyPlan/projectDailyArrageForm";
+    }
+    //初始安排的计划项目--操作列表
+    @ResponseBody
+    @RequestMapping(value = "dailyPlanProject")
+    public Map<String, Object> initArragePlanProject(ProjectDailyPlan projectDailyPlan,Model model,HttpServletRequest request,HttpServletResponse response){
+        projectDailyPlan.setArrangeDailyPlan("1");
+        List<ProjectDailyPlan> projectPlans = (List<ProjectDailyPlan>)request.getSession().getAttribute("sxDailyPlan");
+        Page<ProjectDailyPlan> page = findPageList(new Page<ProjectDailyPlan>(request, response),projectDailyPlan,projectPlans);
+        return getBootstrapData(page);
+    }
+    public Page<ProjectDailyPlan> findPageList(Page<ProjectDailyPlan> page, ProjectDailyPlan entity,List<ProjectDailyPlan> list) {
+        dataRuleFilter(entity);
+        entity.setPage(page);
+        List<ProjectDailyPlan> planArrages = new ArrayList<ProjectDailyPlan>();
+        if (null!=list){
+            for (ProjectDailyPlan projectDailyPlan:list){
+                if (entity.getArrangeDailyPlan().equals(projectDailyPlan.getArrangeDailyPlan())){
+                    planArrages.add(projectDailyPlan);
+                }
+            }
+        }
+        page.setList(planArrages);
+        return page;
+    }
+
+    //所有未安排的计划-树形表格展示
+    @ResponseBody
+    @RequestMapping(value = "bootstrapTreeTable")
+    public List<Map<String,Object>> getArrageNoPlan(ProjectDailyPlan projectDailyPlan,HttpServletRequest request){
+        //创建树形表格
+        List<Map<String,Object>> objects = Lists.newArrayList();
+        List<ProjectDailyPlan> projectPlans = (List<ProjectDailyPlan>)request.getSession().getAttribute("sxDailyPlan");
+        List<Map<String, Object>> dailyBookStrapTree = BookStrapTreeUtil.getDailyBookStrapTree(objects, projectPlans);
+        return dailyBookStrapTree;
+    }
+
+    //安排日计划
+    @ResponseBody
+    @RequestMapping(value = "unDailyPlanned")
+    public Result getUnplanned(ProjectDailyPlan projectDailyPlan, String ids, HttpServletRequest request){
+        Result j = new Result();
+        List<String> strings = PackagingUtil.getString(ids);
+        try {
+            //获取项目信息
+            List<ProjectDailyPlan> projectPlans = (List<ProjectDailyPlan>)request.getSession().getAttribute("sxDailyPlan");
+            if (!projectPlans.isEmpty()&&!strings.isEmpty()){
+                projectDailyPlanService.addPlanDaily(projectPlans,strings);
+            }
+            List<Map<String,Object>> objects = Lists.newArrayList();
+            List<Map<String, Object>> bookStrapTree = BookStrapTreeUtil.getDailyBookStrapTree(objects, projectPlans);
+            j.setMapListTree(bookStrapTree);
+            j.setSuccess(true);
+            j.setMessage("安排日计划成功");
+            return j;
+        }catch (Exception e){
+            e.printStackTrace();
+        }
+        j.setSuccess(false);
+        j.setMessage("安排日计划失败");
+        return j;
+    }
+
+    //取消日计划
+    @ResponseBody
+    @RequestMapping(value = "cancelPackage")
+    public Result getCancelPackage(ProjectDailyPlan projectDailyPlan,String ids,HttpServletRequest request){
+        Result j = new Result();
+        List<String> strings = PackagingUtil.getString(ids);
+        try {
+            //获取项目信息
+            List<ProjectDailyPlan> projectPlans = (List<ProjectDailyPlan>)request.getSession().getAttribute("sxDailyPlan");
+            if (!projectPlans.isEmpty()&&!strings.isEmpty()){
+                projectDailyPlanService.cancelPlanDaily(projectPlans,strings);
+            }
+            List<Map<String,Object>> objects = Lists.newArrayList();
+            List<Map<String, Object>> bookStrapTree = BookStrapTreeUtil.getDailyBookStrapTree(objects, projectPlans);
+            j.setMapListTree(bookStrapTree);
+            j.setSuccess(true);
+            j.setMessage("取消计划成功");
+            return j;
+        }catch (Exception e){
+            e.printStackTrace();
+        }
+        j.setSuccess(false);
+        j.setMessage("取消计划失败");
+        return j;
+    }
+
+    //安排停电开关和具体时间页面
+    @RequestMapping(value = "planDateAndOut")
+    public String planDateAndOut(ProjectDailyPlan projectDailyPlan){
+        return "modules/sg/managementcenter/projectPlanArrage/dailyPlan/dailyDateList";
+    }
+
+    //安排停电开关和具体时间列表页面
+    //初始安排的计划项目--操作列表
+    @ResponseBody
+    @RequestMapping(value = "initdailyPlanProject")
+    public Map<String, Object> initdailyPlanProject(ProjectDailyPlan projectDailyPlan,Model model,HttpServletRequest request,HttpServletResponse response){
+        projectDailyPlan.setArrangeDailyPlan("1");
+        List<ProjectDailyPlan> projectPlans = (List<ProjectDailyPlan>)request.getSession().getAttribute("sxDailyPlan");
+        Page<ProjectDailyPlan> page = findPageList(new Page<ProjectDailyPlan>(request, response),projectDailyPlan,projectPlans);
+        return getBootstrapData(page);
+    }
+
+    //安排停电开关和具体时间列表页面
+    //安排时间
+    @ResponseBody
+    @RequestMapping(value = "addtimeNet")
+    public AjaxJson getAddtimeNet(ProjectDailyPlan projectDailyPlan,HttpServletRequest request){
+        AjaxJson ajaxJson = new AjaxJson();
+        List<ProjectDailyPlan> projectPlans = (List<ProjectDailyPlan>)request.getSession().getAttribute("sxDailyPlan");
+        try {
+            for (ProjectDailyPlan plan:projectPlans){
+                if (plan.getId().equals(projectDailyPlan.getId())){
+                    plan.setProjectDate(projectDailyPlan.getProjectDate());
+                    break;
+                }
+            }
+            ajaxJson.setSuccess(true);
+            ajaxJson.setMsg("安排时间成功");
+            return ajaxJson;
+        }catch (Exception e){
+            e.printStackTrace();
+        }
+        ajaxJson.setSuccess(false);
+        ajaxJson.setMsg("安排时间失败");
+        return ajaxJson;
+    }
+
+    @ResponseBody
+    @RequestMapping(value = "sureInspection")
+    public AjaxJson sureInspection(String ids,ProjectDailyPlan projectDailyPlan,Model model,HttpServletRequest request,HttpServletResponse response){
+        AjaxJson j = new AjaxJson();
+        try {
+            List<ProjectDailyPlan> projectPlans = (List<ProjectDailyPlan>)request.getSession().getAttribute("sxDailyPlan");
+            List<ProjectDailyPlan> idsList = projectDailyPlanService.getInspectionFunction(ids);
+            projectDailyPlanService.getPlanDaily(projectPlans,idsList);
+            j.setSuccess(true);
+            j.setMsg("安排日计划成功");
+            request.getSession().setAttribute("sxDailyPlan","");
+            return j;
+        }catch (Exception e){
+            e.printStackTrace();
+        }
+        j.setSuccess(false);
+        j.setMsg("安排日计划失败");
+        return j;
+    }
+
+    @ResponseBody
+    @RequestMapping(value = "import")
+    public AjaxJson importFile(@RequestParam("file") MultipartFile file, HttpServletResponse response, HttpServletRequest request){
+        AjaxJson j = new AjaxJson();
+        try {
+            StringBuilder failureMsg = new StringBuilder();
+            ImportUtil importUtil = new ImportUtil(file,0,0);
+            List<ProjectDailyPlan> materProUtil = projectDailyPlanService.getMaterProUtil(importUtil);
+            projectDailyPlanService.insertList(materProUtil);
+            j.setMsg( "已成功导入项目"+materProUtil.size()+"条计划安排记录记录");
+        } catch (Exception e) {
+            j.setSuccess(false);
+            j.setMsg("导入失败!失败信息:"+e.getMessage());
+        }
+        return j;
+    }
+
+    //修改查看功能
+    @RequestMapping(value = "updateAndView")
+    public String updateAndView(ProjectDailyPlan projectDailyPlan,Model model){
+        ProjectDailyPlan projectDaily = null;
+        if (null!=projectDailyPlan.getId()&&!projectDailyPlan.getId().equals("")){
+           projectDaily = projectDailyPlanService.get(projectDailyPlan.getId());
+        }
+        model.addAttribute("projectDailyPlan",projectDaily);
+        return "modules/sg/managementcenter/projectPlanArrage/dailyPlan/projectDailyPlanForm";
+    }
+
+    //保存
+    @ResponseBody
+    @RequestMapping(value = "update")
+    public AjaxJson update(ProjectDailyPlan projectDailyPlan){
+        AjaxJson j = new AjaxJson();
+        try {
+            projectDailyPlanService.update(projectDailyPlan);
+            j.setSuccess(true);
+            j.setMsg("修改成功");
+            return j;
+        }catch (Exception e){
+            e.printStackTrace();
+        }
+        j.setSuccess(false);
+        j.setMsg("修改失败");
+        return j;
+    }
+}