Browse Source

插入时比对

yue 5 năm trước cách đây
mục cha
commit
83747946e5

+ 3 - 3
src/main/java/com/jeeplus/modules/sg/information/entity/Information.java

@@ -27,7 +27,7 @@ public class Information extends DataEntity<Information>  {
 //	项目预算年度
 	private String projectYear;
 //	项目总投资(元)
-	private Double projectTotal;
+	private String projectTotal;
 //	实际开工日期
 	private Date projectStart;
 //	实际竣工日期
@@ -159,11 +159,11 @@ public class Information extends DataEntity<Information>  {
 	}
 
 	@ExcelField(title="项目总投资(元)", align=2, sort=6)
-	public Double getProjectTotal() {
+	public String getProjectTotal() {
 		return projectTotal;
 	}
 
-	public void setProjectTotal(Double projectTotal) {
+	public void setProjectTotal(String projectTotal) {
 		this.projectTotal = projectTotal;
 	}
 

+ 9 - 3
src/main/java/com/jeeplus/modules/sg/information/mapper/xml/InformationMapper.xml

@@ -309,7 +309,10 @@
 		create_date,
 		update_by,
 		update_date,
-		del_flag
+		del_flag,
+		firstFinishDate,
+		secondFinish,
+		secondFinishDate
 		) VALUES
 		<foreach collection="information" item="item" index="index" separator="," >
 		(
@@ -336,7 +339,10 @@
 			#{item.createDate},
 			#{item.updateBy.id},
 			#{item.updateDate},
-			#{item.delFlag}
+			#{item.delFlag},
+			#{item.firstFinishDate},
+			#{item.secondFinish},
+			#{item.secondFinishDate}
             )
 		</foreach>
 	</insert>
@@ -365,7 +371,7 @@
 	</select>
 
 	<select id="findListById" resultType="com.jeeplus.modules.sg.information.entity.Information">
-		select project_id,project_name from project_information where project_Id=#{projectId}
+		select project_id,project_name,firstFinish,firstFinishDate,secondFinish,secondFinishDate from project_information where project_Id=#{projectId}
 	</select>
 
 	<insert id="updateAppend">

+ 130 - 99
src/main/java/com/jeeplus/modules/sg/information/utils/ImportInformation.java

@@ -35,6 +35,7 @@ public  class ImportInformation {
         List<Material> materials = new ArrayList<Material>();
         User user = UserUtils.getUser();
         Double difference = 0.0;
+        List<Material> status = materialService.findStatus();
         for (int i = 1; i < lastDataRowNum; i++) {
             Material material = new Material();
             try {
@@ -51,10 +52,8 @@ public  class ImportInformation {
                 Object materialSmall = ei.getCellValue(row, 13);
                 Object materialMid = ei.getCellValue(row, 14);
                 Object materialBig = ei.getCellValue(row, 15);
-
                 String isBack = "";
 
-
                 if (outboundAmount.equals("")) {
                     outboundAmount = "0.0";
                 }
@@ -71,7 +70,6 @@ public  class ImportInformation {
                     price = "0.0";
                 }
                 difference = Double.parseDouble(outboundNumber.toString()) - Double.parseDouble(authorizedNumber.toString());
-
                 if (difference == 0.0) {
                     isBack = "是";
                     isBackNo = 0;
@@ -79,6 +77,26 @@ public  class ImportInformation {
                     isBack = "否";
                     isBackNo = 1;
                 }
+                if (status.size() > 0) {
+                    for (Material list : status) {
+                        if (list.getProjectId().equals(projectId.toString()) && list.getInforId().equals(inforId.toString()) && list.getAfterNumber().equals(outboundNumber)) {
+                            material.setIsBack(list.getIsBack());
+                            material.setIsBackNo(list.getIsBackNo());
+                            material.setStatus(list.getStatus());
+                            material.setInfo(list.getInfo());
+                            material.setAfterNumber(list.getAfterNumber());
+                        }else {
+                            material.setIsBack(isBack);
+                            material.setIsBackNo(isBackNo);
+                        }
+                    }
+                } else {
+                    material.setIsBack(isBack);
+                    material.setIsBackNo(isBackNo);
+                }
+
+
+
 
                 material.setInforId(inforId.toString());
                 material.setProjectId(projectId.toString());
@@ -94,8 +112,6 @@ public  class ImportInformation {
                 material.setMaterialMid(materialMid.toString());
                 material.setMaterialBig(materialBig.toString());
                 material.preInsert();
-                material.setIsBack(isBack);
-                material.setIsBackNo(isBackNo);
                 material.setCreateBy(user);
                 material.setCreateDate(new Date());
                 material.setUpdateBy(user);
@@ -103,27 +119,31 @@ public  class ImportInformation {
                 materials.add(material);
                 successNum++;
 
-                if (materials.size() == 500) {
+                if (materials.size() == 1000) {
                     materialService.saveMater(materials);
                     List<Material> information = materialService.findInformation(materials);
                     materials.clear();
                     for (Material maInfor:information) {
                         Information upInfor = new Information();
                         Information needInfor = materialService.findNeedInfor(maInfor);
-                        if (maInfor.getDifference().equals(0.0)) {
-                            if (needInfor.getFirstFinish() == "" || needInfor.getFirstFinish() == null) {
-                                upInfor.setFirstFinish("是");
-                                upInfor.setFirstFinishDate(new Date());
-                            } else {
-                                upInfor.setSecondFinish("是");
-                                upInfor.setSecondFinishDate(new Date());
-                            }
-                        } else {
-                            if (needInfor.getFirstFinish() == "" || needInfor.getFirstFinish() == null) {
-                                upInfor.setFirstFinish("否");
+                        if (needInfor != null) {
+                                upInfor.setProjectId(needInfor.getProjectId());
+                            if (maInfor.getIsBackNo() == 0) {
+                                if (needInfor.getFirstFinish() == "" || needInfor.getFirstFinish() == null || ("否").equals(needInfor.getFirstFinish())) {
+                                    upInfor.setFirstFinish("是");
+                                    upInfor.setFirstFinishDate(new Date());
+                                }  else if (("否").equals(needInfor.getSecondFinish())) {
+                                    upInfor.setSecondFinish("是");
+                                    upInfor.setSecondFinishDate(new Date());
+                                }
                             } else {
-                                upInfor.setSecondFinish("否");
+                                if (needInfor.getFirstFinish() == "" || needInfor.getFirstFinish() == null || ("否").equals(needInfor.getFirstFinish())) {
+                                    upInfor.setFirstFinish("否");
+                                } else {
+                                    upInfor.setSecondFinish("否");
+                                }
                             }
+                            materialService.updateNeed(upInfor);
                         }
                     }
                 }
@@ -139,29 +159,25 @@ public  class ImportInformation {
             for (Material maInfor:information) {
                 Information upInfor = new Information();
                 Information needInfor = materialService.findNeedInfor(maInfor);
-                if (maInfor.getDifference().equals(0.0)) {
-                    if (needInfor.getFirstFinish() == "" || needInfor.getFirstFinish() == null || needInfor.getFirstFinish().equals("否")) {
-                        upInfor.setProjectId(needInfor.getProjectId());
-                        upInfor.setFirstFinish("是");
-                        upInfor.setFirstFinishDate(new Date());
-                    }
-                    if (needInfor.getSecondFinish().equals("否")) {
-                        upInfor.setProjectId(needInfor.getProjectId());
-                        upInfor.setSecondFinish("是");
-                        upInfor.setSecondFinishDate(new Date());
-                    }
-                } else {
-                    if (needInfor.getFirstFinish() == "" || needInfor.getFirstFinish() == null) {
-                        upInfor.setProjectId(needInfor.getProjectId());
-                        upInfor.setFirstFinish("否");
-                        upInfor.setSecondFinishDate(null);
-                    } else if (needInfor.getFirstFinish().equals("是")){
-                        upInfor.setProjectId(needInfor.getProjectId());
-                        upInfor.setSecondFinish("否");
-                        upInfor.setSecondFinishDate(null);
+                if (needInfor != null) {
+                    upInfor.setProjectId(needInfor.getProjectId());
+                    if (maInfor.getIsBackNo() == 0) {
+                        if (needInfor.getFirstFinish() == "" || needInfor.getFirstFinish() == null || ("否").equals(needInfor.getFirstFinish())) {
+                            upInfor.setFirstFinish("是");
+                            upInfor.setFirstFinishDate(new Date());
+                        } else if (("否").equals(needInfor.getSecondFinish())) {
+                            upInfor.setSecondFinish("是");
+                            upInfor.setSecondFinishDate(new Date());
+                        }
+                    } else {
+                        if (needInfor.getFirstFinish() == "" || needInfor.getFirstFinish() == null || ("否").equals(needInfor.getFirstFinish())) {
+                            upInfor.setFirstFinish("否");
+                        } else {
+                            upInfor.setSecondFinish("否");
+                        }
                     }
+                    materialService.updateNeed(upInfor);
                 }
-                materialService.updateNeed(upInfor);
             }
         }
 
@@ -181,7 +197,7 @@ public  class ImportInformation {
         SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
         List<Information> informationList = new ArrayList<>();
         User user = UserUtils.getUser();
-        String firstFinish = "";
+        String firstFinish = "";
         for (int i = 2; i < lastDataRowNum; i++) {
             Information information = new Information();
             try {
@@ -189,69 +205,82 @@ public  class ImportInformation {
                 Object projectId = ei.getCellValue(row, 1);
                 Object projectName = ei.getCellValue(row, 2);
                 Object projectType = ei.getCellValue(row, 3);
-                if (projectType.equals("配网建设改造项目")||projectType.equals("配网专项成本")){
-                Object projectGrade = ei.getCellValue(row, 4);
-                Object projectYear = ei.getCellValue(row, 6);
-                Object projectTotal = ei.getCellValue(row, 7);
-                Object projectStart = ei.getCellValue(row, 14);
-                Object projectStop = ei.getCellValue(row, 15);
-                Object department = ei.getCellValue(row, 16);
-                Object projectFirm = ei.getCellValue(row, 38);
-                Object subDate = ei.getCellValue(row, 40);
-                Object releaseDate = ei.getCellValue(row, 41);
-                Object endDate = ei.getCellValue(row, 42);
-                Object resultDate = ei.getCellValue(row, 43);
-                Object approvalDate = ei.getCellValue(row, 44);
-                Object secondUnits = ei.getCellValue(row, 53);
-                Object firstUnits = ei.getCellValue(row, 54);
-                firstFinish = "否";
 
-                if (projectTotal.equals("")) {
-                    projectTotal = "0.0";
-                }
                 if (projectId.equals("")) {
                     continue;
                 }
-                information.setProjectId(projectId.toString());
-                information.setProjectName(projectName.toString());
-                information.setProjectType(projectType.toString());
-                information.setProjectGrade(projectGrade.toString());
-                information.setProjectYear(projectYear.toString());
-                information.setProjectTotal(Double.parseDouble(projectTotal.toString()));
-                if (!projectStart.equals("")&&projectStart!=null) {
-                    information.setProjectStart(simpleDateFormat.parse(projectStart.toString()));
-                }
-                if (!projectStop.equals("")&&projectStop!=null) {
-                    information.setProjectStop(simpleDateFormat.parse(projectStop.toString()));
-                }
-                information.setDepartment(department.toString());
-                information.setProjectFirm(projectFirm.toString());
-                if (!subDate.equals("")&&subDate!=null) {
-                    information.setSubDate(simpleDateFormat.parse(subDate.toString()));
-                }
-                if (!releaseDate.equals("")&&releaseDate!=null) {
-                    information.setReleaseDate(simpleDateFormat.parse(releaseDate.toString()));
-                }
-                if (!endDate.equals("")&&endDate!=null) {
-                    information.setEndDate(simpleDateFormat.parse(endDate.toString()));
-                }
-                if (!resultDate.equals("")&&resultDate!=null) {
-                    information.setResultDate(simpleDateFormat.parse(resultDate.toString()));
-                }
-                if (!approvalDate.equals("")&&approvalDate!=null) {
-                    information.setApprovalDate(simpleDateFormat.parse(approvalDate.toString()));
-                }
-                information.setSecondUnits(secondUnits.toString());
-                information.setFirstUnits(firstUnits.toString());
-                information.setFirstFinish(firstFinish);
-                information.preInsert();
-                information.setCreateBy(user);
-                information.setCreateDate(new Date());
-                information.setUpdateBy(user);
-                information.setUpdateDate(new Date());
-                informationList.add(information);
-                successNum++;
-            }
+                if (projectType.equals("配网建设改造项目")||projectType.equals("配网专项成本")){
+                    Information inforById = informationService.findListById(projectId.toString());
+                    if (inforById.getFirstFinish() != null || inforById.getFirstFinish()!="") {
+                        information.setFirstFinish(inforById.getFirstFinish());
+                    }else{
+                        information.setFirstFinish(firstFinish);
+                    }
+                    if (inforById.getFirstFinishDate() != null) {
+                        information.setFirstFinishDate(inforById.getFirstFinishDate());
+                    }
+                    if (inforById.getSecondFinish() != null || inforById.getSecondFinish()!="") {
+                        information.setSecondFinish(inforById.getSecondFinish());
+                    }
+                    if (inforById.getSecondFinishDate() != null) {
+                        information.setSecondFinishDate(inforById.getSecondFinishDate());
+                    }
+                    Object projectGrade = ei.getCellValue(row, 4);
+                    Object projectYear = ei.getCellValue(row, 6);
+                    Object projectTotal = ei.getCellValue(row, 7);
+                    Object projectStart = ei.getCellValue(row, 14);
+                    Object projectStop = ei.getCellValue(row, 15);
+                    Object department = ei.getCellValue(row, 16);
+                    Object projectFirm = ei.getCellValue(row, 38);
+                    Object subDate = ei.getCellValue(row, 40);
+                    Object releaseDate = ei.getCellValue(row, 41);
+                    Object endDate = ei.getCellValue(row, 42);
+                    Object resultDate = ei.getCellValue(row, 43);
+                    Object approvalDate = ei.getCellValue(row, 44);
+                    Object secondUnits = ei.getCellValue(row, 53);
+                    Object firstUnits = ei.getCellValue(row, 54);
+                    if (projectTotal.equals("")) {
+                        projectTotal = "0.0";
+                    }
+                    information.setProjectId(projectId.toString());
+                    information.setProjectName(projectName.toString());
+                    information.setProjectType(projectType.toString());
+                    information.setProjectGrade(projectGrade.toString());
+                    information.setProjectYear(projectYear.toString());
+                    information.setProjectTotal(projectTotal.toString());
+                        if (!projectStart.equals("")&&projectStart!=null) {
+                            information.setProjectStart(simpleDateFormat.parse(projectStart.toString()));
+                        }
+                        if (!projectStop.equals("")&&projectStop!=null) {
+                            information.setProjectStop(simpleDateFormat.parse(projectStop.toString()));
+                        }
+                        information.setDepartment(department.toString());
+                        information.setProjectFirm(projectFirm.toString());
+                        if (!subDate.equals("")&&subDate!=null) {
+                            information.setSubDate(simpleDateFormat.parse(subDate.toString()));
+                        }
+                        if (!releaseDate.equals("")&&releaseDate!=null) {
+                            information.setReleaseDate(simpleDateFormat.parse(releaseDate.toString()));
+                        }
+                        if (!endDate.equals("")&&endDate!=null) {
+                            information.setEndDate(simpleDateFormat.parse(endDate.toString()));
+                        }
+                        if (!resultDate.equals("")&&resultDate!=null) {
+                            information.setResultDate(simpleDateFormat.parse(resultDate.toString()));
+                        }
+                        if (!approvalDate.equals("")&&approvalDate!=null) {
+                            information.setApprovalDate(simpleDateFormat.parse(approvalDate.toString()));
+                        }
+                    information.setSecondUnits(secondUnits.toString());
+                    information.setFirstUnits(firstUnits.toString());
+                    information.preInsert();
+                    information.setCreateBy(user);
+                    information.setCreateDate(new Date());
+                    information.setUpdateBy(user);
+                    information.setUpdateDate(new Date());
+                    informationList.add(information);
+                    successNum++;
+             }
                 if (informationList.size() == 1000) {
                     informationService.saveInfo(informationList);
                     informationList.clear();
@@ -307,6 +336,8 @@ public  class ImportInformation {
                     }
                     material.setInfo(infoW);
                     material.setIsBackNo(0);
+                    Double outboundNumber1 = myProIn.getOutboundNumber();
+                    material.setAfterNumber(outboundNumber1);
                     materialList.add(material);
                 }
 

+ 22 - 19
src/main/java/com/jeeplus/modules/sg/information/web/InformationController.java

@@ -542,17 +542,19 @@ public class InformationController extends BaseController {
 				e.printStackTrace();
 			}
 			List<Material> proId = materialService.findProId(tList);
-			List<Information> informationList = materialService.proIdName(proId);
-			for (int i = 0; i < informationList.size(); i++) {
-				stringBuilder.append(i + 1 + "." + informationList.get(i).getProjectName() + "(" + informationList.get(i).getProjectId() + ")");
-				Information information1 = informationList.get(i);
-				List<Material> mateial = materialService.findMateial(information1);
-				for (int k = 0; k < mateial.size(); k++) {
+			if (proId.size()!=0) {
+				List<Information> informationList = materialService.proIdName(proId);
+				for (int i = 0; i < informationList.size(); i++) {
+					stringBuilder.append(i + 1 + "." + informationList.get(i).getProjectName() + "(" + informationList.get(i).getProjectId() + ")");
+					Information information1 = informationList.get(i);
+					List<Material> mateial = materialService.findMateial(information1);
+					for (int k = 0; k < mateial.size(); k++) {
+						stringBuilder.append("<w:p></w:p>");
+						stringBuilder.append(k + 1 + "." + mateial.get(k).getMaterialName() + "(" + mateial.get(k).getInforId() + "),出库数量为" + mateial.get(k).getOutboundNumber() + ",审定数量为" + mateial.get(k).getAuthorizedNumber() + ",由于原因" + mateial.get(k).getStatus() + ":" + mateial.get(k).getInfo() + ",已完成甲供物资领退料。");
+					}
+					stringBuilder.append("<w:p></w:p>");
 					stringBuilder.append("<w:p></w:p>");
-					stringBuilder.append(k + 1 + "." + mateial.get(k).getMaterialName() + "(" + mateial.get(k).getInforId() + "),出库数量为" + mateial.get(k).getOutboundNumber() + ",审定数量为" + mateial.get(k).getAuthorizedNumber() + ",由于原因" + mateial.get(k).getStatus() + ":" + mateial.get(k).getInfo() + ",已完成甲供物资领退料。");
 				}
-				stringBuilder.append("<w:p></w:p>");
-				stringBuilder.append("<w:p></w:p>");
 			}
 		} else {
 			Information infor = new Information();
@@ -565,19 +567,20 @@ public class InformationController extends BaseController {
 			tList.add(infor);
 			List<Information> idByList = informationService.findIdByList(tList);
 			List<Material> proId = materialService.findProId(idByList);
-			List<Information> informationList = materialService.proIdName(proId);
-			for (int i = 0; i < informationList.size(); i++) {
-				stringBuilder.append(i + 1 + "." + informationList.get(i).getProjectName() + "(" + informationList.get(i).getProjectId() + ")");
-				Information information1 = informationList.get(i);
-				List<Material> mateial = materialService.findMateial(information1);
-				for (int k = 0; k < mateial.size(); k++) {
+			if (proId.size()!=0) {
+				List<Information> informationList = materialService.proIdName(proId);
+				for (int i = 0; i < informationList.size(); i++) {
+					stringBuilder.append(i + 1 + "." + informationList.get(i).getProjectName() + "(" + informationList.get(i).getProjectId() + ")");
+					Information information1 = informationList.get(i);
+					List<Material> mateial = materialService.findMateial(information1);
+					for (int k = 0; k < mateial.size(); k++) {
+						stringBuilder.append("<w:p></w:p>");
+						stringBuilder.append(k + 1 + "." + mateial.get(k).getMaterialName() + "(" + mateial.get(k).getInforId() + "),出库数量为" + mateial.get(k).getOutboundNumber() + ",审定数量为" + mateial.get(k).getAuthorizedNumber() + ",由于原因" + mateial.get(k).getStatus() + ":" + mateial.get(k).getInfo() + ",已完成甲供物资领退料。");
+					}
+					stringBuilder.append("<w:p></w:p>");
 					stringBuilder.append("<w:p></w:p>");
-					stringBuilder.append(k + 1 + "." + mateial.get(k).getMaterialName() + "(" + mateial.get(k).getInforId() + "),出库数量为" + mateial.get(k).getOutboundNumber() + ",审定数量为" + mateial.get(k).getAuthorizedNumber() + ",由于原因" + mateial.get(k).getStatus() + ":" + mateial.get(k).getInfo() + ",已完成甲供物资领退料。");
 				}
-				stringBuilder.append("<w:p></w:p>");
-				stringBuilder.append("<w:p></w:p>");
 			}
-
 		}
 		data.put("mb",stringBuilder);
 		File docFile = new File("D:/甲供物资超欠供说明.doc");

+ 10 - 0
src/main/java/com/jeeplus/modules/sg/material/entity/Material.java

@@ -51,6 +51,16 @@ public class Material extends DataEntity<Material>  {
     //判断是否完成领退料
     private int isBackNo;
 
+    private Double afterNumber;
+
+    public Double getAfterNumber() {
+        return afterNumber;
+    }
+
+    public void setAfterNumber(Double afterNumber) {
+        this.afterNumber = afterNumber;
+    }
+
     public int getIsBackNo() {
         return isBackNo;
     }

+ 3 - 0
src/main/java/com/jeeplus/modules/sg/material/mapper/MaterialMapper.java

@@ -45,4 +45,7 @@ public interface MaterialMapper extends BaseMapper<Material> {
     List<Material> findMateial(Information information);
 
 
+    List<Material> findStatus();
+
+
 }

+ 16 - 4
src/main/java/com/jeeplus/modules/sg/material/mapper/xml/MaterialMapper.xml

@@ -18,6 +18,8 @@
 		material_mid,
 		material_big,
 		isBack,
+		isBackNo,
+		afterNumber,
 		status,
 		info
 	</sql>
@@ -105,7 +107,8 @@
         create_date,
         update_by,
         update_date,
-        del_flag
+        del_flag,
+        afterNumber
         ) VALUES
         <foreach collection="list" item="material" index="index" separator=",">
             (
@@ -131,7 +134,8 @@
             #{material.createDate},
             #{material.updateBy.id},
             #{material.updateDate},
-            #{material.delFlag}
+            #{material.delFlag},
+            #{material.afterNumber}
             )
         </foreach>
     </insert>
@@ -216,7 +220,7 @@
     </select>
 
     <select id="findInformation"  resultType="com.jeeplus.modules.sg.material.entity.Material">
-        select project_id,SUM(difference) as difference
+        select project_id,SUM(isBackNo) as isBackNo
         from material_information
         where project_id
         in (
@@ -234,7 +238,7 @@
     <update id="updateNeed" parameterType="com.jeeplus.modules.sg.information.entity.Information">
         update project_information
         <trim prefix="set" suffixOverrides=",">
-                secondFinishDate=#{secondFinishDate},
+            secondFinishDate=#{secondFinishDate},
             <if test="firstFinish!=null and firstFinish != ''">
                 firstFinish=#{firstFinish},
             </if>
@@ -264,6 +268,9 @@
                 <if test="item.info!=null and item.info != ''">
                     info=#{item.info},
                 </if>
+                <if test="item.afterNumber!=null">
+                    afterNumber=#{item.afterNumber}
+                </if>
             </trim>
             where project_id=#{item.projectId} and infor_id=#{item.inforId}
         </foreach>
@@ -304,4 +311,9 @@
         or status != '')
         and project_id=#{projectId}
     </select>
+    
+    
+    <select id="findStatus" resultType="com.jeeplus.modules.sg.material.entity.Material">
+        select * from material_information where status is not null
+    </select>
 </mapper>

+ 5 - 0
src/main/java/com/jeeplus/modules/sg/material/service/MaterialService.java

@@ -77,6 +77,7 @@ public class MaterialService extends CrudService<MaterialMapper, Material> {
 
 	@Transactional(readOnly = false)
 	public Integer updateInfo(Material material) {
+		material.setIsBackNo(0);
 		return materialMapper.updateInfo(material);
 	}
 
@@ -119,5 +120,9 @@ public class MaterialService extends CrudService<MaterialMapper, Material> {
 		return materialMapper.findMateial(information);
 	}
 
+	public List<Material> findStatus() {
+		return materialMapper.findStatus();
+	}
+
 
 }