Commit 5c5f3163 by YG6494

HPKC008页面修改,新增日期选择框,默认日期为当前月

parent e2aae5ff
package com.baosight.hpjx.hp.kc.service;
import com.baosight.hpjx.hp.kc.domain.HPKC008;
import com.baosight.hpjx.util.StringUtil;
import com.baosight.iplat4j.core.ei.EiBlock;
import com.baosight.iplat4j.core.ei.EiConstant;
import com.baosight.iplat4j.core.ei.EiInfo;
......@@ -22,8 +23,9 @@ public class ServiceHPKC008 extends ServiceBase {
public EiInfo initLoad(EiInfo inInfo) {
HPKC008 HPKC008 = new HPKC008();
EiInfo outInfo = super.initLoad(inInfo, HPKC008);
outInfo.addBlock(EiConstant.resultBlock).addBlockMeta(HPKC008.eiMetadata);
return inInfo;
outInfo.addBlock(EiConstant.queryBlock).setCell(0,"datemonth",CommonMethod.getCurrentSameYearMonth());
outInfo.getBlock(EiConstant.resultBlock).getRows().clear();
return outInfo;
}
/**
......@@ -31,9 +33,10 @@ public class ServiceHPKC008 extends ServiceBase {
*/
@Override
public EiInfo query(EiInfo inInfo) {
String datemonth = inInfo.getCellStr(EiConstant.queryBlock,0,"datemonth");
inInfo.setCell(EiConstant.queryBlock,0,"datemonth", StringUtil.removeHorizontalLine(datemonth));
/* 调用EI查询方法.*/
EiInfo outInfo = super.query(inInfo, "HPKC008.query", new HPKC008());
return outInfo;
return super.query(inInfo, "HPKC008.query", new HPKC008());
}
......@@ -42,28 +45,13 @@ public class ServiceHPKC008 extends ServiceBase {
*/
@Override
public EiInfo insert(EiInfo inInfo) {
try {
CommonMethod.creatorInfo(inInfo,EiConstant.resultBlock);
super.insert(inInfo,"HPKC008.insert");
// Thpkc008 HPKC008 = new Thpkc008();
// EiBlock eiBlock = inInfo.getBlock(EiConstant.resultBlock);
// for (int i = 0; i < eiBlock.getRowCount(); i++) {
// Map<?, ?> map = eiBlock.getRow(i);
// HPKC008.fromMap(map);
// this.dao.insertBatch()//insert("HPKC008.insert", HPKC008.toMap());
// }
inInfo.setStatus(EiConstant.STATUS_SUCCESS);
inInfo.setMsg("新增成功!");
} catch (PlatException e) {
e.printStackTrace();
inInfo.setStatus(EiConstant.STATUS_FAILURE);
inInfo.setMsg("新增失败!原因参见详细错误描述!");
inInfo.setDetailMsg(e.getMessage());
logError("新增失败", e.getMessage());
return inInfo;
CommonMethod.creatorInfo(inInfo,EiConstant.resultBlock);
for (int i = 0; i < inInfo.getBlock(EiConstant.resultBlock).getRowCount(); i++) {
String datemonth = inInfo.getCellStr(EiConstant.resultBlock,i,"datemonth");
inInfo.setCell(EiConstant.resultBlock,i,"datemonth", StringUtil.removeHorizontalLine(datemonth));
}
return inInfo;
return super.insert(inInfo,"HPKC008.insert");
}
......
......@@ -45,10 +45,10 @@
ID = #id#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="datemonth">
datemonth = #datemonth#
DATEMONTH = #datemonth#
</isNotEmpty>
<isNotEmpty prepend=" AND " property="statisticalNumber">
statisticalNumber = #statisticalNumber#
STATISTICAL_NUMBER = #statisticalNumber#
</isNotEmpty>
<dynamic prepend="ORDER BY">
<isNotEmpty property="orderBy">
......
......@@ -11,6 +11,7 @@ import com.baosight.iplat4j.core.ioc.spring.PlatApplicationContext;
import com.baosight.iplat4j.core.util.DateUtils;
import com.baosight.iplat4j.core.web.threadlocal.UserSession;
import java.util.Calendar;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
......@@ -94,5 +95,41 @@ public class CommonMethod {
block.setCell(i, HPConstants.SQL_FIELD_UPDATED_TIME, time);
}
}
/**
* 得到当前年月的上一月字符串
* DN 21/09/04
*/
/*public static String getCurrentYearMonth() {
int year = Calendar.getInstance().get(Calendar.YEAR);
int month = Calendar.getInstance().get(Calendar.MONTH);
String yearMonth;
if (month==0){
yearMonth=year-1+"12";
}
else if (month<10 && month>0){
yearMonth=year+"0"+month;
}
else {
yearMonth=year+""+month;
}
return yearMonth;
}*/
public static String getCurrentSameYearMonth() {
int year = Calendar.getInstance().get(Calendar.YEAR);
int month = Calendar.getInstance().get(Calendar.MONTH)+1;
String yearMonth;
if (month==0){
yearMonth=year-1+"-12";
}
else if (month<10 && month>0){
yearMonth=year+"-0"+month;
}
else {
yearMonth=year+"-"+month;
}
return yearMonth;
}
}
package com.baosight.hpjx.util;
import org.springframework.util.ObjectUtils;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.regex.Pattern;
public class StringUtil {
/**
* 默认的待去除字符, 用于{@link }静态方法.
*/
private static final Character DEFAULT_CHARACTER_TO_BE_REMOVED = '-';
/**
* 数值字符串正则匹配规则.
*/
private static final String NUMBER_STRING_RULES = "[0-9]*";
/**
* 数值字符串匹配校验器.
*/
private static final Pattern NUMBER_STRING_MATCH_CHECKER = Pattern.compile(StringUtil.NUMBER_STRING_RULES);
public StringUtil() {
}
public static String removeHorizontalLine(String date) {
if (ObjectUtils.isEmpty(date)) {
throw new RuntimeException("传入的字符串是个Null或空, 系统错误信息:" + date);
}
return removeSpecifiedCharacter(date, DEFAULT_CHARACTER_TO_BE_REMOVED);
}
public static String removeSpecifiedCharacter(String str, Character characterToBeRemoved) {
StringBuilder newDateString = new StringBuilder(ObjectUtils.isEmpty(str) ? "" : str);
for (int index = newDateString.length() - 1; index >= 0; index--) {
if (newDateString.charAt(index) == characterToBeRemoved) {
newDateString.deleteCharAt(index);
}
}
return newDateString.toString();
}
public static String getNewNumberString(String sourceStr) {
final StringBuilder newStr = new StringBuilder(sourceStr.length());
for (int i = 0, length = sourceStr.length(); i < length; i++) {
char isNumberChar = sourceStr.charAt(i);
switch (isNumberChar) {
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
newStr.append(isNumberChar);
break;
default:
break;
}
}
return newStr.toString();
}
}
$(function() {
$("#inqu_status-0-datemonth").val(__eiInfo.blocks.inqu_status.rows[0]);
// 查询
$("#QUERY").on("click", function () {
resultGrid.dataSource.page(1); // 点击查询按钮,从第1页开始查询
......
......@@ -22,7 +22,7 @@
<EF:EFColumn ename="id" cname="内码" hidden="true"/>
<EF:EFColumn ename="datemonth" cname="月份" width="100" readonly="false" />
<EF:EFColumn ename="datemonth" cname="月份" editType="date" dateFormat="yyyy-MM" parseFormats="['yyyyMM']" start="year" depth="year" width="100" readonly="false" />
<EF:EFColumn ename="statisticalNumber" cname="统计单单号" width="100" readonly="false" />
<EF:EFColumn ename="materialCode" cname="物料编码" width="100" readonly="false"/>
<EF:EFColumn ename="materialName" cname="物料名称" width="100" readonly="false"/>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment