|
@@ -15,6 +15,7 @@ import org.springframework.stereotype.Service;
|
|
|
import java.io.File;
|
|
|
import java.io.FileInputStream;
|
|
|
import java.io.IOException;
|
|
|
+import java.math.BigDecimal;
|
|
|
import java.text.ParseException;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
@@ -98,9 +99,19 @@ public class EmsProdplanYearServiceImpl extends BaseServiceImpl<EmsProdplanYear,
|
|
|
lsp = createCheckCar(file);
|
|
|
if (lsp.size()>0)
|
|
|
{
|
|
|
- int spm = emsProdplanYearMapper.batchInsert(lsp);
|
|
|
- }
|
|
|
- else
|
|
|
+ Map map = new HashMap(16);
|
|
|
+ for (EmsProdplanYear model : lsp) {
|
|
|
+ map.put("line",model.getLine());
|
|
|
+ map.put("yearmonth",new SimpleDateFormat("yyyy-MM").format(model.getYearmonth()));
|
|
|
+ map.put("productid",model.getProductid());
|
|
|
+ List list = this.getDateForProduct((HashMap<String, Object>) map);
|
|
|
+ if (list.size()>0){
|
|
|
+ continue;
|
|
|
+ } else {
|
|
|
+ this.add(model);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else
|
|
|
{
|
|
|
rs.setMessage("导入失败,导入数据已经存在!");
|
|
|
rs.setCode("500");
|
|
@@ -118,6 +129,7 @@ public class EmsProdplanYearServiceImpl extends BaseServiceImpl<EmsProdplanYear,
|
|
|
UserPayload payload = UserPayload.getCurrUser();
|
|
|
FileInputStream is = null;
|
|
|
String fileName = file.getName();
|
|
|
+ Calendar calendar1=Calendar.getInstance();
|
|
|
|
|
|
int lastindex = fileName.lastIndexOf("\\");
|
|
|
fileName = fileName.substring(lastindex + 1);
|
|
@@ -126,258 +138,256 @@ public class EmsProdplanYearServiceImpl extends BaseServiceImpl<EmsProdplanYear,
|
|
|
is = new FileInputStream(file);
|
|
|
}
|
|
|
List<List<String[]>> list = ExcelToolUtils.parseExcels(is, fileName, 0);
|
|
|
-
|
|
|
-
|
|
|
+ final Pattern pattern = Pattern.compile("[0-9]*");
|
|
|
try {
|
|
|
- String name = fileName.substring(2, 4);
|
|
|
- for (int i = 1; i < list.size(); i++) {
|
|
|
+ for (int i = 0; i < list.size(); i++) {
|
|
|
+ String[] arr2 = list.get(i).get(1);
|
|
|
for(int j = 1; j < list.get(i).size(); j++) {
|
|
|
String[] arr = list.get(i).get(j);
|
|
|
String[] arr1 = list.get(i).get(0);
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- EmsProdplanYear spp = new EmsProdplanYear();
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- Pattern pattern = Pattern.compile("[0-9]*");
|
|
|
- if(arr[0].length()>8 || !pattern.matcher(arr[0]).matches()){
|
|
|
- throw new MarketSlmException(500,"排产日期(编号)有误!");
|
|
|
- }
|
|
|
- StringBuffer s=new StringBuffer(arr[0]).insert(4,"-").insert(7,"-");
|
|
|
- SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
- simpleDateFormat.setLenient(false);
|
|
|
-
|
|
|
- spp.setStartTime(arr[0]);
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- String maxid = "";
|
|
|
- String strh =maxid.substring(maxid.length() -2,maxid.length());
|
|
|
- Integer seq = Integer.parseInt(strh)+(i-1);
|
|
|
- spp.setId(maxid.replace("-"+strh,seq<10?"-0"+seq.toString():"-"+seq.toString()));
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|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
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- lists.add(spp);
|
|
|
+ if( "".equals(arr[0].trim()) || !pattern.matcher(arr[0]).matches()){
|
|
|
+ arr2 = list.get(i).get(1);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ for(int k =1;k<arr1.length;k++) {
|
|
|
+ EmsProdplanYear spp = new EmsProdplanYear();
|
|
|
+
|
|
|
+ calendar1.set(Calendar.MONTH, Integer.parseInt(arr[0].trim()) - 1 );
|
|
|
+
|
|
|
+ calendar1.set(Calendar.DAY_OF_MONTH, 1);
|
|
|
+
|
|
|
+ calendar1.set(Calendar.HOUR_OF_DAY, 0);
|
|
|
+
|
|
|
+ calendar1.set(Calendar.MINUTE, 0);
|
|
|
+
|
|
|
+ calendar1.set(Calendar.SECOND, 0);
|
|
|
+
|
|
|
+ calendar1.set(Calendar.MILLISECOND, 0);
|
|
|
+ spp.setYearmonth(calendar1.getTime());
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ if (arr1[k].trim().indexOf("1#烧结") != -1) {
|
|
|
+ spp.setParentid("SJ");
|
|
|
+ spp.setLine("AT3013");
|
|
|
+ spp.setUnit("吨");
|
|
|
+ spp.setWeight(new BigDecimal(arr[k].trim()).setScale(0, BigDecimal.ROUND_HALF_UP));
|
|
|
+ } else if (arr1[k].trim().indexOf("2#烧结") != -1) {
|
|
|
+ spp.setParentid("SJ");
|
|
|
+ spp.setLine("AT3014");
|
|
|
+ spp.setUnit("吨");
|
|
|
+ spp.setWeight(new BigDecimal(arr[k].trim()).setScale(0, BigDecimal.ROUND_HALF_UP));
|
|
|
+ } else if (arr1[k].trim().indexOf("3#烧结") != -1) {
|
|
|
+ spp.setParentid("SJ");
|
|
|
+ spp.setLine("AT3015");
|
|
|
+ spp.setUnit("吨");
|
|
|
+ spp.setWeight(new BigDecimal(arr[k].trim()).setScale(0, BigDecimal.ROUND_HALF_UP));
|
|
|
+ }
|
|
|
+
|
|
|
+ else if (arr1[k].trim().indexOf("1#高炉") != -1) {
|
|
|
+ spp.setParentid("LT");
|
|
|
+ spp.setLine("AT3001");
|
|
|
+ spp.setUnit("吨");
|
|
|
+ spp.setWeight(new BigDecimal(arr[k].trim()).setScale(0, BigDecimal.ROUND_HALF_UP));
|
|
|
+ } else if (arr1[k].trim().indexOf("2#高炉") != -1) {
|
|
|
+ spp.setParentid("LT");
|
|
|
+ spp.setLine("AT3002");
|
|
|
+ spp.setUnit("吨");
|
|
|
+ spp.setWeight(new BigDecimal(arr[k].trim()).setScale(0, BigDecimal.ROUND_HALF_UP));
|
|
|
+ } else if (arr1[k].trim().indexOf("3#高炉") != -1) {
|
|
|
+ spp.setParentid("LT");
|
|
|
+ spp.setLine("AT3003");
|
|
|
+ spp.setUnit("吨");
|
|
|
+ spp.setWeight(new BigDecimal(arr[k].trim()).setScale(0, BigDecimal.ROUND_HALF_UP));
|
|
|
+ } else if (arr1[k].trim().indexOf("4#高炉") != -1) {
|
|
|
+ spp.setParentid("LT");
|
|
|
+ spp.setLine("AT3004");
|
|
|
+ spp.setUnit("吨");
|
|
|
+ spp.setWeight(new BigDecimal(arr[k].trim()).setScale(0, BigDecimal.ROUND_HALF_UP));
|
|
|
+ }
|
|
|
+
|
|
|
+ else if ("供高线一车间方坯".equals(arr1[k].trim())) {
|
|
|
+ spp.setParentid("LG");
|
|
|
+ spp.setLine("AT2005-1");
|
|
|
+ spp.setUnit("吨");
|
|
|
+ spp.setWeight(new BigDecimal(arr[k].trim()).setScale(0, BigDecimal.ROUND_HALF_UP));
|
|
|
+ } else if ("供高线二车间方坯".equals(arr1[k].trim())) {
|
|
|
+ spp.setParentid("LG");
|
|
|
+ spp.setLine("AT2006-1");
|
|
|
+ spp.setUnit("吨");
|
|
|
+ spp.setWeight(new BigDecimal(arr[k].trim()).setScale(0, BigDecimal.ROUND_HALF_UP));
|
|
|
+ } else if ("异形坯".equals(arr1[k].trim())) {
|
|
|
+ spp.setParentid("LG");
|
|
|
+ spp.setLine("AT2007-1");
|
|
|
+ spp.setUnit("吨");
|
|
|
+ spp.setWeight(new BigDecimal(arr[k].trim()).setScale(0, BigDecimal.ROUND_HALF_UP));
|
|
|
+ } else if ("外销方坯".equals(arr1[k].trim())) {
|
|
|
+ spp.setParentid("LG");
|
|
|
+ spp.setLine("AT3008-1");
|
|
|
+ spp.setUnit("吨");
|
|
|
+ spp.setWeight(new BigDecimal(arr[k].trim()).setScale(0, BigDecimal.ROUND_HALF_UP));
|
|
|
+ }
|
|
|
+
|
|
|
+ else if ("高线一车间".equals(arr1[k].trim())) {
|
|
|
+ spp.setParentid("ZG");
|
|
|
+ spp.setLine("AT2005");
|
|
|
+ spp.setUnit("吨");
|
|
|
+ spp.setWeight(new BigDecimal(arr[k].trim()).setScale(0, BigDecimal.ROUND_HALF_UP));
|
|
|
+ } else if ("高线二车间".equals(arr1[k].trim())) {
|
|
|
+ spp.setParentid("ZG");
|
|
|
+ spp.setLine("AT2006");
|
|
|
+ spp.setUnit("吨");
|
|
|
+ spp.setWeight(new BigDecimal(arr[k].trim()).setScale(0, BigDecimal.ROUND_HALF_UP));
|
|
|
+ } else if ("H型钢".equals(arr1[k].trim())) {
|
|
|
+ spp.setParentid("ZG");
|
|
|
+ spp.setLine("AT2007");
|
|
|
+ spp.setUnit("吨");
|
|
|
+ spp.setWeight(new BigDecimal(arr[k].trim()).setScale(0, BigDecimal.ROUND_HALF_UP));
|
|
|
+ }
|
|
|
+
|
|
|
+ else if (arr1[k].trim().indexOf("成品焦") != -1) {
|
|
|
+ spp.setProductid("成品焦");
|
|
|
+ spp.setParentid("JJZ");
|
|
|
+ spp.setUnit("吨");
|
|
|
+ spp.setWeight(BigDecimal.ZERO);
|
|
|
+ for (int m = 0;m <= 2; m++ ){
|
|
|
+ if ("高炉用量".equals(arr2[k+m].trim())) {
|
|
|
+ spp.setWeight1(new BigDecimal(arr[k+m].trim()).setScale(0, BigDecimal.ROUND_HALF_UP));
|
|
|
+ } else if ("外销数量".equals(arr2[k+m].trim())) {
|
|
|
+ spp.setWeight2(new BigDecimal(arr[k+m].trim()).setScale(0, BigDecimal.ROUND_HALF_UP));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ k +=2;
|
|
|
+ } else if (arr1[k].trim().indexOf("小粒焦") != -1) {
|
|
|
+ spp.setProductid("小粒焦");
|
|
|
+ spp.setParentid("JJZ");
|
|
|
+ spp.setUnit("吨");
|
|
|
+ spp.setWeight(BigDecimal.ZERO);
|
|
|
+ for (int m = 0;m <= 2; m++ ) {
|
|
|
+ if ("高炉用量".equals(arr2[k+m].trim())) {
|
|
|
+ spp.setWeight1(new BigDecimal(arr[k+m].trim()).setScale(0, BigDecimal.ROUND_HALF_UP));
|
|
|
+ } else if ("外销数量".equals(arr2[k+m].trim())) {
|
|
|
+ spp.setWeight2(new BigDecimal(arr[k+m].trim()).setScale(0, BigDecimal.ROUND_HALF_UP));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ k +=2;
|
|
|
+ } else if (arr1[k].trim().indexOf("除尘焦粉") != -1) {
|
|
|
+ spp.setProductid("除尘焦粉");
|
|
|
+ spp.setParentid("JJZ");
|
|
|
+ spp.setUnit("吨");
|
|
|
+ spp.setWeight(BigDecimal.ZERO);
|
|
|
+ for (int m = 0;m <= 2; m++ ) {
|
|
|
+ if ("高炉用量".equals(arr2[k+m].trim())) {
|
|
|
+ spp.setWeight1(new BigDecimal(arr[k+m].trim()).setScale(0, BigDecimal.ROUND_HALF_UP));
|
|
|
+ } else if ("外销数量".equals(arr2[k+m].trim())) {
|
|
|
+ spp.setWeight2(new BigDecimal(arr[k+m].trim()).setScale(0, BigDecimal.ROUND_HALF_UP));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ k +=2;
|
|
|
+ } else if (arr1[k].trim().indexOf("焦粉") != -1) {
|
|
|
+ spp.setProductid("焦粉");
|
|
|
+ spp.setParentid("JJZ");
|
|
|
+ spp.setUnit("吨");
|
|
|
+ spp.setWeight2(BigDecimal.ZERO);
|
|
|
+ for (int m = 0;m <= 2; m++ ) {
|
|
|
+ if ("烧结用量".equals(arr2[k+m].trim())) {
|
|
|
+ spp.setWeight1(new BigDecimal(arr[k+m].trim()).setScale(0, BigDecimal.ROUND_HALF_UP));
|
|
|
+ } else if ("预计外购".equals(arr2[k+m].trim())) {
|
|
|
+ spp.setWeight(new BigDecimal(arr[k+m].trim()).setScale(0, BigDecimal.ROUND_HALF_UP));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ k +=2;
|
|
|
+ }
|
|
|
+
|
|
|
+ else if (arr1[k].trim().indexOf("40MW") != -1) {
|
|
|
+ spp.setParentid("FDC");
|
|
|
+ spp.setLine("AT4002");
|
|
|
+ spp.setUnit("Kwh");
|
|
|
+ spp.setWeight(new BigDecimal(arr[k].trim()).setScale(0, BigDecimal.ROUND_HALF_UP));
|
|
|
+ } else if (arr1[k].trim().indexOf("45MW") != -1) {
|
|
|
+ spp.setParentid("FDC");
|
|
|
+ spp.setLine("AT4003");
|
|
|
+ spp.setUnit("Kwh");
|
|
|
+ spp.setWeight(new BigDecimal(arr[k].trim()).setScale(0, BigDecimal.ROUND_HALF_UP));
|
|
|
+ } else if (arr1[k].trim().indexOf("25MW") != -1) {
|
|
|
+ spp.setParentid("FDC");
|
|
|
+ spp.setLine("AT4001");
|
|
|
+ spp.setUnit("Kwh");
|
|
|
+ spp.setWeight(new BigDecimal(arr[k].trim()).setScale(0, BigDecimal.ROUND_HALF_UP));
|
|
|
+ } else if (arr1[k].trim().indexOf("15MW") != -1) {
|
|
|
+ spp.setParentid("FDC");
|
|
|
+ spp.setLine("AT4004");
|
|
|
+ spp.setUnit("Kwh");
|
|
|
+ spp.setWeight(new BigDecimal(arr[k].trim()).setScale(0, BigDecimal.ROUND_HALF_UP));
|
|
|
+ } else if (arr1[k].trim().indexOf("TRT") != -1) {
|
|
|
+ spp.setParentid("FDC");
|
|
|
+ spp.setLine("AT3022");
|
|
|
+ spp.setUnit("Kwh");
|
|
|
+ spp.setWeight(new BigDecimal(arr[k].trim()).setScale(0, BigDecimal.ROUND_HALF_UP));
|
|
|
+ }
|
|
|
+
|
|
|
+ else if ("焦油".equals(arr1[k].trim())) {
|
|
|
+ spp.setParentid("JJF");
|
|
|
+ spp.setLine("AT3024");
|
|
|
+ spp.setUnit("吨");
|
|
|
+ spp.setWeight(new BigDecimal(arr[k].trim()).setScale(0, BigDecimal.ROUND_HALF_UP));
|
|
|
+ } else if ("粗笨".equals(arr1[k].trim())) {
|
|
|
+ spp.setParentid("JJF");
|
|
|
+ spp.setLine("AT3009");
|
|
|
+ spp.setUnit("吨");
|
|
|
+ spp.setWeight(new BigDecimal(arr[k].trim()).setScale(0, BigDecimal.ROUND_HALF_UP));
|
|
|
+ } else if ("硫铵".equals(arr1[k].trim())) {
|
|
|
+ spp.setParentid("JJF");
|
|
|
+ spp.setLine("AT3010");
|
|
|
+ spp.setUnit("吨");
|
|
|
+ spp.setWeight(new BigDecimal(arr[k].trim()).setScale(0, BigDecimal.ROUND_HALF_UP));
|
|
|
+ } else if ("硫酸".equals(arr1[k].trim())) {
|
|
|
+ spp.setParentid("JJF");
|
|
|
+ spp.setLine("AT3025");
|
|
|
+ spp.setUnit("吨");
|
|
|
+ spp.setWeight(new BigDecimal(arr[k].trim()).setScale(0, BigDecimal.ROUND_HALF_UP));
|
|
|
+ } else if ("洗煤".equals(arr1[k].trim())) {
|
|
|
+ spp.setParentid("JJH");
|
|
|
+ spp.setProductid("AT2012");
|
|
|
+ spp.setUnit("吨");
|
|
|
+ spp.setWeight(new BigDecimal(arr[k].trim()).setScale(0, BigDecimal.ROUND_HALF_UP));
|
|
|
+ }
|
|
|
+
|
|
|
+ else if (arr1[k].trim().indexOf("1#回转窑") != -1) {
|
|
|
+ spp.setParentid("JCS");
|
|
|
+ spp.setLine("AT3011");
|
|
|
+ spp.setUnit("吨");
|
|
|
+ spp.setWeight(new BigDecimal(arr[k].trim()).setScale(0, BigDecimal.ROUND_HALF_UP));
|
|
|
+ } else if (arr1[k].trim().indexOf("2#回转窑") != -1) {
|
|
|
+ spp.setParentid("JCS");
|
|
|
+ spp.setLine("AT3012");
|
|
|
+ spp.setUnit("吨");
|
|
|
+ spp.setWeight(new BigDecimal(arr[k].trim()).setScale(0, BigDecimal.ROUND_HALF_UP));
|
|
|
+ } else if ("矿渣粉".equals(arr1[k].trim())) {
|
|
|
+ spp.setParentid("JCW");
|
|
|
+ spp.setProductid("AT2014");
|
|
|
+ spp.setUnit("吨");
|
|
|
+ spp.setWeight(new BigDecimal(arr[k].trim()).setScale(0, BigDecimal.ROUND_HALF_UP));
|
|
|
+ } else {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ spp.setCjr(payload.getUserName());
|
|
|
+ spp.setCjsj(new Date());
|
|
|
+ lists.add(spp);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
} catch (Exception e){
|