xs 5 éve
szülő
commit
5c1c683953

+ 20 - 8
src/main/java/com/jeeplus/modules/sg/overheadline/util/SettementUtil.java

@@ -759,9 +759,13 @@ public class SettementUtil {
         }
         return reason;
     }
-    /*
-      措施费对比
-   */
+
+    /**
+     * 措施费对比
+     * @param csxm  措施费常量
+     * @param settlement bean
+     * @return reason
+     */
     public static String getCsfJoint(String csxm,Settlement settlement){
         String status =settlement.getStatus();
         String[] amout=settlement.getTheAmount().split(",");
@@ -836,9 +840,13 @@ public class SettementUtil {
         }
         return reason;
     }
-    /*
-      投标报价
-   */
+
+    /**
+     * 工程投标价格匹配方法
+     * @param settlement bean
+     * @param booleans 判断 匹配字段 是否存在
+     * @return reason
+     */
     public static String getBDZJoint(Settlement settlement,boolean[] booleans){
         String reason="";
         String[] amout=settlement.getTheAmount().split(",");
@@ -872,8 +880,12 @@ public class SettementUtil {
         }
         return reason;
     }
-    /*
-        结算汇总拼接
+
+    /**
+     * 工程结算
+     * @param settlement bean
+     * @param booleans 判断工程结算 对比 字段 是否存在
+     * @return bean rason
      */
     public static String getJshzJoint(Settlement settlement,boolean[] booleans){
         String reason="";

+ 3 - 0
src/main/java/com/jeeplus/modules/sg/project/mapper/ItemMapper.java

@@ -4,6 +4,7 @@ import com.jeeplus.core.persistence.BaseMapper;
 import com.jeeplus.core.persistence.annotation.MyBatisMapper;
 import com.jeeplus.modules.sg.project.entity.WbsItem;
 import com.jeeplus.modules.sg.project.entity.WbsSelection;
+import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
 
@@ -13,4 +14,6 @@ public interface ItemMapper extends BaseMapper<WbsItem> {
     List<WbsItem> findList(WbsSelection wbsSelection);
     int insert(WbsItem wbsItem);
 
+    //根据名称获取项目
+    List<WbsItem> findItemByName(@Param("itemName")String itemName,@Param("projectId") String projectId);
 }

+ 12 - 1
src/main/java/com/jeeplus/modules/sg/project/mapper/xml/ItemMapper.xml

@@ -131,5 +131,16 @@
 	<select id="findUniqueByProperty" resultType="Goods" statementType="STATEMENT">
 		select * FROM sg_wbs_item  where ${propertyName} = '${value}'
 	</select>
-	
+
+	<select id="findItemByName" parameterType="String" resultType="com.jeeplus.modules.sg.project.entity.WbsItem">
+		SELECT
+		id AS id,
+		unit AS unit,
+		item_name AS itemName,
+		project_id AS projectId,
+		parent_node AS parentNode,
+		create_date AS createDate
+		FROM sg_wbs_item
+		WHERE item_name = #{itemName} and project_id =#{projectId}
+	</select>
 </mapper>

+ 4 - 0
src/main/java/com/jeeplus/modules/sg/project/service/ItemService.java

@@ -45,4 +45,8 @@ public class ItemService extends CrudService<ItemMapper, WbsItem> {
     public void delete(WbsItem wbsItem) {
         super.delete(wbsItem);
     }
+
+    public List<WbsItem> findItemByName(String itemName,String projectId){
+        return itemMapper.findItemByName(itemName,projectId);
+    }
 }

+ 6 - 0
src/main/java/com/jeeplus/modules/sg/project/web/ProjectController.java

@@ -68,6 +68,12 @@ public class ProjectController extends BaseController {
     @RequestMapping("/save")
     public AjaxJson save(WbsProject wbsProject, Model model, RedirectAttributes redirectAttributes){
         AjaxJson j = new AjaxJson();
+        List<WbsProject> projects =  projectService.findByName(wbsProject.getProjectName());
+        if (projects!=null&&!projects.isEmpty()){
+           j.setSuccess(false);
+           j.setMsg("添加失败!工程名称:"+wbsProject.getProjectName()+"以存在");
+           return j;
+        }
         //数据验证
         String errMsg = beanValidator(wbsProject);
         if (StringUtils.isNotBlank(errMsg)){

+ 29 - 4
src/main/java/com/jeeplus/modules/sg/project/web/ProjectTemController.java

@@ -2,8 +2,10 @@ package com.jeeplus.modules.sg.project.web;
 
 import com.jeeplus.core.web.BaseController;
 import com.jeeplus.modules.sg.overheadline.service.OverheadLineService;
+import com.jeeplus.modules.sg.project.entity.WbsItem;
 import com.jeeplus.modules.sg.project.entity.WbsProject;
 import com.jeeplus.modules.sg.project.entity.WbsSelection;
+import com.jeeplus.modules.sg.project.service.ItemService;
 import com.jeeplus.modules.sg.project.service.ProjectService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Controller;
@@ -29,6 +31,8 @@ public class ProjectTemController extends BaseController {
     private ProjectService projectService;
     @Autowired
     private OverheadLineService overheadLineService;
+    @Autowired
+    private ItemService itemService;
 
 
 
@@ -55,13 +59,20 @@ public class ProjectTemController extends BaseController {
     @ResponseBody
     @RequestMapping("/import")
     public HashMap importFile(@RequestParam(value = "file")MultipartFile[] file,String projectName,String[] itemNames,String[] itemTypes)  {
+        HashMap map = new HashMap();
+        List<WbsProject> projects =  projectService.findByName(projectName);
+        if (projects!=null&&!projects.isEmpty()){
+            map.put("code",0);
+            map.put("msg","工程名称已存在");
+            return map;
+        }
         WbsProject wbsProject = new WbsProject();
         wbsProject.setProjectName(projectName);
         projectService.save(wbsProject);
-        List<WbsProject> wbsProjects = projectService.findByName(projectName);
-        WbsProject wbsProject1 = wbsProjects.get(0);
-        String projectId = wbsProject1.getId();
-        HashMap map = new HashMap();
+//        List<WbsProject> wbsProjects = projectService.findByName(projectName);
+//        WbsProject wbsProject1 = wbsProjects.get(0);
+        String projectId = wbsProject.getId();
+
         try {
             for(int i = 0;i<itemTypes.length;i++) {
 //            保存数据到数据库
@@ -170,4 +181,18 @@ public class ProjectTemController extends BaseController {
         return newDate+result;
     }
 
+    @RequestMapping("/verfiy")
+    @ResponseBody
+    public HashMap getVerfiy(String projectName,String projectId){
+        HashMap map = new HashMap();
+        List<WbsItem> wbsItemList = itemService.findItemByName(projectName,projectId);
+        if (wbsItemList!=null&&!wbsItemList.isEmpty()){
+            map.put("code",1);
+            map.put("msg","项目名称已存在");
+            return map;
+        }
+        map.put("msg","导入成功");
+        return map;
+    }
+
 }

+ 25 - 2
src/main/webapp/webpage/modules/sg/project/addItemForm.js

@@ -14,8 +14,31 @@
     var newText1 = parent.$('#addtext').val();
     $("#newText1").val(newText1);
 })
-    function doSubmit(obj){//回调函数,在编辑和保存动作时,供openDialog调用提交表单。
-    $("#inputForm").submit();
+    function doSubmit(obj){
+    if ($("#myfile").val()==null||$("#myfile").val()==""){
+    layer.msg("请选择文件",{icon: 5});
+    throw SyntaxError;
+}
+    if ($("#inputwrite").val()==null||$("#inputwrite").val()==""){
+    layer.msg("请输入项目名称",{icon:5});
+    throw SyntaxError;
+}
+    //获取项目名称
+    var project_name=$("#inputwrite").val();
+    //获取工程id
+    var project_id=$("#newText1").val();
+    $.ajax({
+        url: "${ctx}/project/tem/verfiy",
+        type: "post",
+        data: {"projectName":project_name,"projectId":project_id},
+        success:function (result) {
+            if (result.code == 1){
+                alert(result.msg);
+            }else {
+                $("#inputForm").submit();
+            }
+        }
+    });
 }
 $("#btnxz").click(function(){
     $("#myfile").trigger("click");

+ 1 - 1
src/main/webapp/webpage/modules/sg/project/addItemForm.jsp

@@ -4,7 +4,6 @@
 <link rel="stylesheet" href="${ctxp}/static/plugin/assets/common.css"/>
 <script type="text/javascript" src="${ctxp}/static/plugin/assets/jquery-3.2.1.min.js"></script>
 <script src="${ctxp}/static/plugin/assets/layui/layui.js"></script>
-<%@include file="addItemForm.js"%>
 <html>
 <head>
     <title>添加工程</title>
@@ -58,5 +57,6 @@
         </div>
     </div>
 </form>
+<%@include file="addItemForm.js"%>
 </body>
 </html>

+ 2 - 2
src/main/webapp/webpage/modules/sg/project/management.js

@@ -165,10 +165,10 @@ function addProject(){
             dataType: "json",
             success: function(data){
                 if(data.success){
-                    layer.msg(data.msg, {icon: 1});
+                    layer.msg(data.msg, {icon: 6});
                     window.location.reload();
                 }else{
-                    layer.msg('添加失败', {icon: 1});
+                    layer.msg(data.msg, {icon: 5});
                 }
             }
         });

+ 17 - 0
src/main/webapp/webpage/modules/sg/projecttem/addItem.js

@@ -15,11 +15,28 @@
     layer.msg("请输入项目名称",{icon:5});
     throw SyntaxError;
 }
+    //获取项目名称
+    var project_name=$("#inputwrite").val();
+    //获取工程id
+    var project_id=$("#newText1").val();
+    $.ajax({
+    url: "${ctx}/project/tem/verfiy",
+    type: "post",
+    data: {"projectName":project_name,"projectId":project_id},
+    success:function (result) {
+    if (result.code == 1){
+    alert(result.msg);
+}else {
     $("#inputForm").submit();
 }
+}
+});
+}
+
     $("#btnxz").click(function(){
     $("#myfile").trigger("click");
 })
+
     $("#myfile").bind("change",function(){
     var solr_file= $("#myfile").val();
     $("#myspan").html('&nbsp;'+solr_file);

+ 6 - 25
src/main/webapp/webpage/modules/sg/projecttem/manageList.jsp

@@ -12,31 +12,12 @@
     <%@ include file="manageList.js"%>
 </head>
 <style>
-    .layui-input{
-        height: 28px;
-        margin-top: 5px;
-        width: 260px;
-    }
-    .input-meself-time{
-        font-size: 13px;
-        width: 140px;
-    }
-    .btn_out{
-        width: 100px;
-        margin: 0;
-        float: right;
-        margin-right:2%;
-    }
-    .div_main_form{
-        width: 50%;
-        margin-left: 10px;
-    }
-    .layui-icon-layer{
-        display: none;
-    }
-    .layui-icon-file{
-        display: none;
-    }
+    .layui-input{height: 28px; margin-top: 5px;width: 260px;}
+    .input-meself-time{font-size: 13px;width: 140px;}
+    .btn_out{ width: 100px; margin: 0;float: right;margin-right:2%;}
+    .div_main_form{width: 50%;margin-left: 10px;}
+    .layui-icon-layer{ display: none;}
+    .layui-icon-file{display: none;}
     .layui-table-view .layui-table {width:100%}
 </style>
 <body style="height:100%">