Sfoglia il codice sorgente

井陉第二部分模板导入等已弄好

yuandejingxingkuangqu 4 anni fa
parent
commit
5d8b92817a

+ 19 - 4
yinet-admin/src/main/java/com/yinet/web/controller/review/FormReviewController.java

@@ -6,6 +6,7 @@ import com.yinet.common.core.domain.AjaxResult;
 import com.yinet.common.core.page.TableDataInfo;
 import com.yinet.common.enums.BusinessType;
 import com.yinet.common.utils.poi.ExcelUtil;
+import com.yinet.framework.util.ShiroUtils;
 import com.yinet.review.domain.FormReview;
 import com.yinet.review.service.IFormReviewService;
 import org.apache.shiro.authz.annotation.RequiresPermissions;
@@ -68,22 +69,36 @@ public class FormReviewController extends BaseController
     /**
      * 导入评审项目
      * @param file
-     * @param updateSupport
      * @return
      * @throws Exception
      */
-
+    @Log(title = "评审项目", businessType = BusinessType.IMPORT)
     @RequiresPermissions("review:review:importData")
     @PostMapping("/importData")
     @ResponseBody
-    public AjaxResult importData(MultipartFile file, boolean updateSupport) throws Exception
+    public AjaxResult importData(MultipartFile file) throws Exception
     {
         ExcelUtil<FormReview> util = new ExcelUtil<FormReview>(FormReview.class);
         List<FormReview> formReviewsList = util.importExcel(file.getInputStream());
-        String message = formReviewService.importFormReviewsList(formReviewsList, updateSupport);
+        String operName = ShiroUtils.getSysUser().getLoginName();
+        String message = formReviewService.importFormReviewsList(formReviewsList, operName);
         return AjaxResult.success(message);
     }
 
+    /**
+     * 模板
+     * @return
+     */
+    @RequiresPermissions("review:review:view")
+    @GetMapping("/importTemplate")
+    @ResponseBody
+    public AjaxResult importTemplate()
+    {
+        ExcelUtil<FormReview> util = new ExcelUtil<FormReview>(FormReview.class);
+        return util.importTemplateExcel("评审项目");
+    }
+
+
     /**
      * 新增评审项目
      */

+ 2 - 2
yinet-admin/src/main/resources/application.yml

@@ -92,9 +92,9 @@ shiro:
     # 登录地址
     loginUrl: /login
     # 权限认证失败地址
-    unauthorizedUrl: /touchscreen/index
+    unauthorizedUrl: /login
     # 首页地址
-    indexUrl: /touchscreen/index
+    indexUrl: /login
     # 验证码开关
     captchaEnabled: true
     # 验证码类型 math 数组计算 char 字符

+ 5 - 85
yinet-admin/src/main/resources/templates/review/review/add.html

@@ -110,81 +110,11 @@
                     <input name="mediationphone" class="form-control" type="text" required>
                 </div>
             </div>
-<!--            <div class="form-group">    -->
-<!--                <label class="col-sm-3 control-label">添加时间:</label>-->
-<!--                <div class="col-sm-8">-->
-<!--                    <div class="input-group date">-->
-<!--                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>-->
-<!--                        <input name="addtime" class="form-control" placeholder="yyyy-MM-dd" type="text" required>-->
-<!--                    </div>-->
-<!--                </div>-->
-<!--            </div>-->
-<!--            <div class="form-group">    -->
-<!--                <label class="col-sm-3 control-label">添加人账号id:</label>-->
-<!--                <div class="col-sm-8">-->
-<!--                    <input name="adduserid" class="form-control" type="text">-->
-<!--                </div>-->
-<!--            </div>-->
-<!--            <div class="form-group">    -->
-<!--                <label class="col-sm-3 control-label">添加人账号名:</label>-->
-<!--                <div class="col-sm-8">-->
-<!--                    <input name="addname" class="form-control" type="text">-->
-<!--                </div>-->
-<!--            </div>-->
-<!--            <div class="form-group">    -->
-<!--                <label class="col-sm-3 control-label">修改时间:</label>-->
-<!--                <div class="col-sm-8">-->
-<!--                    <div class="input-group date">-->
-<!--                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>-->
-<!--                        <input name="modifytime" class="form-control" placeholder="yyyy-MM-dd" type="text">-->
-<!--                    </div>-->
-<!--                </div>-->
-<!--            </div>-->
-<!--            <div class="form-group">    -->
-<!--                <label class="col-sm-3 control-label">修改人ID:</label>-->
-<!--                <div class="col-sm-8">-->
-<!--                    <input name="modifyuserid" class="form-control" type="text">-->
-<!--                </div>-->
-<!--            </div>-->
-<!--            <div class="form-group">    -->
-<!--                <label class="col-sm-3 control-label">修改人账号名称:</label>-->
-<!--                <div class="col-sm-8">-->
-<!--                    <input name="modifyname" class="form-control" type="text">-->
-<!--                </div>-->
-<!--            </div>-->
-<!--            <div class="form-group">    -->
-<!--                <label class="col-sm-3 control-label">是否删除:</label>-->
-<!--                <div class="col-sm-8">-->
-<!--                    <input name="deleteproject" class="form-control" type="text">-->
-<!--                </div>-->
-<!--            </div>-->
-<!--            <div class="form-group">    -->
-<!--                <label class="col-sm-3 control-label">删除日期:</label>-->
-<!--                <div class="col-sm-8">-->
-<!--                    <div class="input-group date">-->
-<!--                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>-->
-<!--                        <input name="deletedate" class="form-control" placeholder="yyyy-MM-dd" type="text">-->
-<!--                    </div>-->
-<!--                </div>-->
-<!--            </div>-->
-<!--            <div class="form-group">    -->
-<!--                <label class="col-sm-3 control-label">删除原因:</label>-->
-<!--                <div class="col-sm-8">-->
-<!--                    <input name="deletecontent" class="form-control" type="text">-->
-<!--                </div>-->
-<!--            </div>-->
-<!--            <div class="form-group">    -->
-<!--                <label class="col-sm-3 control-label">删除人id:</label>-->
-<!--                <div class="col-sm-8">-->
-<!--                    <input name="deleteuserid" class="form-control" type="text">-->
-<!--                </div>-->
-<!--            </div>-->
-<!--            <div class="form-group">    -->
-<!--                <label class="col-sm-3 control-label">删除人账号名称:</label>-->
-<!--                <div class="col-sm-8">-->
-<!--                    <input name="deletename" class="form-control" type="text">-->
-<!--                </div>-->
-<!--            </div>-->
+
+
+            <input name="adduserid" class="form-control" type="hidden"  th:value="${@permission.getPrincipalProperty('userid')}">
+
+            <input name="addname" class="form-control" type="hidden" th:value="${@permission.getPrincipalProperty('userName')}">
         </form>
     </div>
     <th:block th:include="include :: footer" />
@@ -205,16 +135,6 @@
             format: "yyyy-mm-dd",
             minView: "month",
             autoclose: true
-        })
-        $("input[name='addtime']").datetimepicker({
-            format: "yyyy-mm-dd",
-            minView: "month",
-            autoclose: true
-        })
-        $("input[name='modifytime']").datetimepicker({
-            format: "yyyy-mm-dd",
-            minView: "month",
-            autoclose: true
         });
     </script>
 </body>

+ 5 - 92
yinet-admin/src/main/resources/templates/review/review/edit.html

@@ -108,83 +108,11 @@
                 <div class="col-sm-8">
                     <input name="mediationphone" th:field="*{mediationphone}" class="form-control" type="text" required>
                 </div>
-                <h1>奥术</h1>
-            </div>
-<!--            <div class="form-group">    -->
-<!--                <label class="col-sm-3 control-label">添加时间:</label>-->
-<!--                <div class="col-sm-8">-->
-<!--                    <div class="input-group date">-->
-<!--                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>-->
-<!--                        <input name="addtime" th:value="${#dates.format(formReview.addtime, 'yyyy-MM-dd')}" class="form-control" placeholder="yyyy-MM-dd" type="text" required>-->
-<!--                    </div>-->
-<!--                </div>-->
-<!--            </div>-->
-<!--            <div class="form-group">    -->
-<!--                <label class="col-sm-3 control-label">添加人账号id:</label>-->
-<!--                <div class="col-sm-8">-->
-<!--                    <input name="adduserid" th:field="*{adduserid}" class="form-control" type="text">-->
-<!--                </div>-->
-<!--            </div>-->
-<!--            <div class="form-group">    -->
-<!--                <label class="col-sm-3 control-label">添加人账号名:</label>-->
-<!--                <div class="col-sm-8">-->
-<!--                    <input name="addname" th:field="*{addname}" class="form-control" type="text">-->
-<!--                </div>-->
-<!--            </div>-->
-<!--            <div class="form-group">    -->
-<!--                <label class="col-sm-3 control-label">修改时间:</label>-->
-<!--                <div class="col-sm-8">-->
-<!--                    <div class="input-group date">-->
-<!--                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>-->
-<!--                        <input name="modifytime" th:value="${#dates.format(formReview.modifytime, 'yyyy-MM-dd')}" class="form-control" placeholder="yyyy-MM-dd" type="text">-->
-<!--                    </div>-->
-<!--                </div>-->
-<!--            </div>-->
-<!--            <div class="form-group">    -->
-<!--                <label class="col-sm-3 control-label">修改人ID:</label>-->
-<!--                <div class="col-sm-8">-->
-<!--                    <input name="modifyuserid" th:field="*{modifyuserid}" class="form-control" type="text">-->
-<!--                </div>-->
-<!--            </div>-->
-<!--            <div class="form-group">    -->
-<!--                <label class="col-sm-3 control-label">修改人账号名称:</label>-->
-<!--                <div class="col-sm-8">-->
-<!--                    <input name="modifyname" th:field="*{modifyname}" class="form-control" type="text">-->
-<!--                </div>-->
-<!--            </div>-->
-<!--            <div class="form-group">    -->
-<!--                <label class="col-sm-3 control-label">是否删除:</label>-->
-<!--                <div class="col-sm-8">-->
-<!--                    <input name="deleteproject" th:field="*{deleteproject}" class="form-control" type="text">-->
-<!--                </div>-->
-<!--            </div>-->
-<!--            <div class="form-group">    -->
-<!--                <label class="col-sm-3 control-label">删除日期:</label>-->
-<!--                <div class="col-sm-8">-->
-<!--                    <div class="input-group date">-->
-<!--                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>-->
-<!--                        <input name="deletedate" th:value="${#dates.format(formReview.deletedate, 'yyyy-MM-dd')}" class="form-control" placeholder="yyyy-MM-dd" type="text">-->
-<!--                    </div>-->
-<!--                </div>-->
-<!--            </div>-->
-<!--            <div class="form-group">    -->
-<!--                <label class="col-sm-3 control-label">删除原因:</label>-->
-<!--                <div class="col-sm-8">-->
-<!--                    <input name="deletecontent" th:field="*{deletecontent}" class="form-control" type="text">-->
-<!--                </div>-->
-<!--            </div>-->
-<!--            <div class="form-group">    -->
-<!--                <label class="col-sm-3 control-label">删除人id:</label>-->
-<!--                <div class="col-sm-8">-->
-<!--                    <input name="deleteuserid" th:field="*{deleteuserid}" class="form-control" type="text">-->
-<!--                </div>-->
-<!--            </div>-->
-<!--            <div class="form-group">    -->
-<!--                <label class="col-sm-3 control-label">删除人账号名称:</label>-->
-<!--                <div class="col-sm-8">-->
-<!--                    <input name="deletename" th:field="*{deletename}" class="form-control" type="text">-->
-<!--                </div>-->
-<!--            </div>-->
+
+            </div>
+
+            <input name="modifyuserid" class="form-control" type="hidden"  th:value="${@permission.getPrincipalProperty('userid')}">
+            <input name="modifyname" class="form-control" type="hidden" th:value="${@permission.getPrincipalProperty('userName')}">
         </form>
     </div>
     <th:block th:include="include :: footer" />
@@ -205,21 +133,6 @@
             format: "yyyy-mm-dd",
             minView: "month",
             autoclose: true
-        })
-        $("input[name='addtime']").datetimepicker({
-            format: "yyyy-mm-dd",
-            minView: "month",
-            autoclose: true
-        })
-        $("input[name='modifytime']").datetimepicker({
-            format: "yyyy-mm-dd",
-            minView: "month",
-            autoclose: true
-        })
-        $("input[name='deletedate']").datetimepicker({
-            format: "yyyy-mm-dd",
-            minView: "month",
-            autoclose: true
         });
     </script>
 </body>

+ 7 - 1
yinet-admin/src/main/resources/templates/review/review/review.html

@@ -149,7 +149,7 @@
                     <i class="fa fa-download"></i> 导出
                  </a>
 
-                <a class="btn btn-info" onclick="$.table.importExcel();" >   <!--shiro:hasPermission="review:review:import"-->
+                <a class="btn btn-info" onclick="$.table.importExcel();" shiro:hasPermission="review:review:import" >
                     <i class="fa fa-upload"></i> 导入
                 </a>
 
@@ -188,6 +188,7 @@
                 removeUrl: prefix + "/remove",
                 exportUrl: prefix + "/export",
                 importUrl: prefix + "/importData",
+                importTemplateUrl: prefix + "/importTemplate",
                 modalName: "评审项目",
                 columns: [{
                     checkbox: true
@@ -340,6 +341,11 @@
     <form enctype="multipart/form-data" class="mt20 mb10">
         <div class="col-xs-offset-1">
             <input type="file" id="file" name="file"/>
+            <div class="mt10 pt5">
+                <!--                <input type="checkbox" id="updateSupport" name="updateSupport" title="如果登录账户已经存在,更新这条数据。"> 是否更新已经存在的用户数据-->
+                &nbsp;	<a onclick="$.table.importTemplate()" class="btn btn-default btn-xs"><i class="fa fa-file-excel-o"></i> 下载模板</a>
+            </div>
+
             <font color="red" class="pull-left mt10">
                 提示:仅允许导入“xls”或“xlsx”格式文件!
             </font>

+ 2 - 2
yinet-system/src/main/java/com/yinet/review/domain/FormReview.java

@@ -105,7 +105,7 @@ public class FormReview extends BaseEntity
     private Long modifyuserid;
 
     /** 修改人账号名称 */
-    @Excel(name = "修改人账号名称")
+  //  @Excel(name = "修改人账号名称")
     private String modifyname;
 
     /** 是否删除 */
@@ -125,7 +125,7 @@ public class FormReview extends BaseEntity
     private Long deleteuserid;
 
     /** 删除人账号名称 */
-    @Excel(name = "删除人账号名称")
+   // @Excel(name = "删除人账号名称")
     private String deletename;
 
     public void setId(Long id) 

+ 1 - 1
yinet-system/src/main/java/com/yinet/review/service/IFormReviewService.java

@@ -59,5 +59,5 @@ public interface IFormReviewService
      */
     public int deleteFormReviewById(Long id);
 
-    String importFormReviewsList(List<FormReview> formReviewsList, boolean updateSupport);
+    String importFormReviewsList(List<FormReview> formReviewsList, String operName);
 }

+ 8 - 7
yinet-system/src/main/java/com/yinet/review/service/impl/FormReviewServiceImpl.java

@@ -92,14 +92,14 @@ public class FormReviewServiceImpl implements IFormReviewService {
 
     /**
      * @param formReviewsList 用户数据列表
-     * @param updateSupport   是否更新支持,如果已存在,则进行更新数据
      * @return
      */
     @Override
-    public String importFormReviewsList(List<FormReview> formReviewsList, boolean updateSupport) {
+    public String importFormReviewsList(List<FormReview> formReviewsList,String operName) {
         if (StringUtils.isNull(formReviewsList) || formReviewsList.size() == 0) {
             throw new BusinessException("导入用户数据不能为空!");
         }
+
         int successNum = 0;
         int failureNum = 0;
         StringBuilder successMsg = new StringBuilder();
@@ -108,16 +108,17 @@ public class FormReviewServiceImpl implements IFormReviewService {
         for (FormReview formReview : formReviewsList) {
             try {
 
+                formReview.setCreateBy(operName);
                 this.insertFormReview(formReview);
-
                 successNum++;
+                successMsg.append("<br/>" + successNum + "、项目编号 " + formReview.getNumber() + " 导入成功");
             } catch (Exception e) {
                 failureNum++;
-                String msg = "<br/>" + failureNum + "、账号 " + formReview.getProjectname() + " 导入失败:";
+                String msg = "<br/>" + failureNum + "、项目编号 " +  formReview.getNumber()+ " 导入失败:";
                 failureMsg.append(msg + e.getMessage());
-               log.error(msg, e);
-            }
-        }
+                log.error(msg, e);}
+
+                }
 
         if (failureNum > 0) {
             failureMsg.insert(0, "很抱歉,导入失败!共 " + failureNum + " 条数据格式不正确,错误如下:");