首页 新闻 会员 周边 捐助

麻烦各位大佬帮忙看一下,菜鸟求教

0
悬赏园豆:80 [已关闭问题] 关闭于 2019-06-04 09:25

有两个问题,第一个问题是我在做社保模块的增加功能,在增加页面有一个搜索框,需要在这里输入姓名或者身份证号来搜索另外一张基本信息表里面是否有该用户的信息,如果有的话则在下面显示出来,点击确定后该用户姓名和身份证号回显至下面的输入框中从而完成信息添加,而现在我想保证社保信息的唯一性,不允许统一用户重复添加,所以我在用户信息后面那个确定按钮那做一个判断,判断我的社保表里面是否有该用户的社保信息,请问该怎么做?

html代码:
<h3><b>社保信息增加</b><span></span></h3>

<div class="increase_main">
<table width="60%" align="center">
<tr>
<td valign="middle" align="center" style="text-align:right; width:90%;">
<input type="text" class="input_k2" placeholder="请输入姓名或身份证号" value="" id="inputname">
</td>
<td valign="middle" style="align:center; width:10%;">
<input type="button" value="查询" class="button_2" onclick="findOut()"/>
</td>
</tr>
</table>

<c:if test="${not empty informationList}">
<table width="96%" border="0" align="center" cellpadding="0" cellspacing="0" class="box_news_show assessment_show" style="padding-top: 20px" id="info">

<tr>
<th width="20%" align="center" valign="middle" class="borderright">姓名</th>
<th width="40%" align="center" valign="middle" class="borderright">身份证号码</th>
<th align="center" valign="middle" class="borderright">录入人员</th>
<th width="5%" align="center" valign="middle">操作</th>
</tr>
<s:iterator value="informationList" status="st">
<input type="hidden" id="informationId" name="information.informationId" value='<s:property value="informationId"/>' />
<tr onMouseOut="this.style.backgroundColor='#ffffff'" onMouseOver="this.style.backgroundColor='#edf5ff'">
<td align="center" valign="middle" class="borderright borderbottom"><s:property value="informationname" /></td>
<td align="center" valign="middle" class="borderright borderbottom"><s:property value="idnumber"/></td>
<td align="center" valign="middle" class="borderright borderbottom"><s:property value="entrypersonnel"/></td>
<td>
<input type="button" value="确定" class="button_1" onclick="yes('<s:property value="informationId"/>')"/>
</td>
</tr>
</s:iterator>
</table>
</c:if>

该按钮的js方法(之前写的被我注释掉了,因为有一个bug,当查询到同一姓名但是身份证号不同的两条信息时,就报空指针异常,没用):
function yes(id){
/* var formData = jQuery("#form1").serializeArray();
var saveURL = "${pageContext.request.contextPath}/socialAction!getByIdCard?information.informationId="+id+"";

    alert(saveURL);
    jQuery.post(saveURL, formData, function(jsonData) {
        var message = jsonData.message;
        var flag = jsonData.flag;
        if (flag == true) {
            mizhu.alert('','已存在该用户的社保信息!!','');
            setTimeout(function(){
            var saveURL="${pageContext.request.contextPath}/socialAction!add?";
            window.location.href = saveURL;
            },2000);
        } else{ */
    var saveURL = "${pageContext.request.contextPath}/socialAction!getById?information.informationId="+id+"";
    window.location.href = saveURL;  
    
   /*  } 
    },"json"); */
    return false; 

}

然后是action中的方法:

/*
 *通过身份证查询 
 * 
 */
public String getByIdCard() throws Exception{
    
    
    information = informationService.getById(information.getInformationId());

    social.setSocialIdNumber(information.getIdnumber());
    list=socialService.getBySocialNumber(social.getSocialIdNumber());

    MessageBean messageBean = new MessageBean();
    messageBean.setFlag(false);
    if (list.size() > 0) {
        
        messageBean.setFlag(true);
    }
    PrintWriter out = response.getWriter();
    out.print(JsonUtil.objectToJson(messageBean));
    return NONE;
}

第二个问题就是,我做这个模块的导入导出功能,想给时间format一下,但是不知道怎么写,
这是导入之前可以预览的方法:
/**

  • 导入预览
  • @return
  • @throws Exception
    */
    public String addExcelSocial() throws Exception {
    path = ServletActionContext.getRequest().getRealPath("/leading");
    String today=DateUtil.getTimeStamp();
    fileFileName="Excel3_"+today+"."+"xls";
    File destFile = new File(path, fileFileName);
    OutputStream os = new FileOutputStream(destFile);
    InputStream is = new FileInputStream(file);
    byte[] buffer = new byte[1024];
    int length = 0;
    while(-1 != (length = is.read(buffer))){
    os.write(buffer, 0, length);
    }
    is.close();
    os.close();
    String[] names = new String[] { "姓名", "身份证号","参保地","退伍证编号", "参保时间",
    "录入时间","录入人员","修改时间","修改人员" };
    LinkedHashMap<String, String> fieldMaps = new LinkedHashMap<String, String>();

     fieldMaps.put("socialName", "姓名");
     fieldMaps.put("socialIdNumber", "身份证号");
     fieldMaps.put("socialAddress", "参保地");
     fieldMaps.put("dischargeId", "退伍证编号");
    
     fieldMaps.put("insuredTime", "参保时间");
    
     fieldMaps.put("crateTime", "录入时间");
     fieldMaps.put("entrypersonnel", "录入人员");
     fieldMaps.put("modifyTime", "修改时间");
     fieldMaps.put("modifyStaff", "修改人员");
    
    
     List<Social> list = ExcelUitl.importoutSocial(destFile,names,fieldMaps);
    
     List<Social> resultlist1 = new ArrayList<Social>();
     List<Social> resultlist2 = new ArrayList<Social>();
     List<Social> resultlist3 = new ArrayList<Social>();
    
     for (Social sl : list) {
    
         if ("".equals(sl.getSocialName())
                 || "".equals(sl.getSocialIdNumber())
                 || sl.getSocialName() == null
                 || sl.getSocialIdNumber()== null){
             resultlist1.add(sl);
         }
         List<Social> staa=socialService.getBySocialNme(sl.getSocialName());
             if(staa.size()> 0){
                 resultlist2.add(sl);
             }
         List<Social> stm=socialService.getBySocialNumber(sl.getSocialIdNumber());
         if(stm.size()>0){
             resultlist3.add(sl);
         }
    
    
    
    
     }
     if (resultlist1.size() > 0) {
         if (resultlist1.size() > 300) {
             resultlist = resultlist1.subList(0, 300);
         } else {
             resultlist = resultlist1;
         }
         result_number = 1;
     } else if (resultlist1.size() == 0 && resultlist2.size() > 0) {
         if (resultlist2.size() > 300) {
             resultlist = resultlist2.subList(0, 300);
         } else {
             resultlist = resultlist2;
         }
         result_number = 2;
     }else if(resultlist1.size() == 0 && resultlist2.size() == 0 && resultlist3.size() > 0){
         if (resultlist3.size() > 300) {
             resultlist = resultlist3.subList(0, 300);
         } else {
             resultlist = resultlist3;
         }
         result_number = 3;
         }else{
    
         if (list.size() > 300) {
             resultlist = list.subList(0, 300);
         } else {
             resultlist = list;
         }
    
         result_number = 4;
     }
    
     return "preview";

    }

ppplum的主页 ppplum | 初学一级 | 园豆:3
提问于:2019-06-03 15:13

第一个问题你不是自己写判断了嘛?有问题嘛?

但乱红尘 5年前

@但乱红尘: 第一个问题刚解决了,把formData删了就好了,大佬第二个问题会吗,网上搜过了,但还是不知道该怎么在我自己这个方法中给日期format转换格式

ppplum 5年前
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册