gaodd 1 rok temu
rodzic
commit
6d9af3dec6

+ 19 - 9
src/main/java/com/chinaitop/depot/device/controller/BusinessImAssetController.java

@@ -1,6 +1,5 @@
1 1
 package com.chinaitop.depot.device.controller;
2 2
 
3
-import java.io.IOException;
4 3
 import java.util.HashMap;
5 4
 import java.util.List;
6 5
 import java.util.Map;
@@ -9,6 +8,7 @@ import javax.annotation.Resource;
9 8
 import javax.servlet.http.HttpServletRequest;
10 9
 
11 10
 import org.springframework.http.MediaType;
11
+import org.springframework.web.bind.annotation.RequestBody;
12 12
 import org.springframework.web.bind.annotation.RequestMapping;
13 13
 import org.springframework.web.bind.annotation.RequestMethod;
14 14
 import org.springframework.web.bind.annotation.RestController;
@@ -32,7 +32,7 @@ import io.swagger.annotations.ApiOperation;
32 32
  */
33 33
 
34 34
 @RestController
35
-@RequestMapping(value= {"/businessImAsset"})
35
+@RequestMapping(value= "/businessImAsset")
36 36
 @Api(value= "BusinessImAssetController", description = "资产管理")
37 37
 public class BusinessImAssetController {
38 38
 
@@ -101,18 +101,15 @@ public class BusinessImAssetController {
101 101
      */
102 102
 	 @RequestMapping(value="/save",produces = MediaType.APPLICATION_JSON_VALUE, method=RequestMethod.POST)
103 103
 	 @ApiOperation(value="保存数据", notes = "保存")
104
-	 @ApiImplicitParams({
105
-	    	@ApiImplicitParam(name="businessImAssetJson", value="表数据", paramType="form")
106
-	 })
107
-    public Map<String, Object> save(String businessImAssetJson) {
104
+	
105
+    public Map<String, Object> save(@RequestBody BusinessImAsset businessImAsset) {
108 106
         Map<String, Object> modelMap = new HashMap<>();
109 107
         // JSON字符串转对象
110 108
         ObjectMapper mapper = new ObjectMapper();
111 109
         try {
112
-        	BusinessImAsset businessImAsset = (BusinessImAsset)mapper.readValue(businessImAssetJson, BusinessImAsset.class);
113 110
         	businessImAssetService.save(businessImAsset);
114 111
             modelMap.put("status", "success");
115
-        } catch (IOException e) {
112
+        } catch (Exception e) {
116 113
             modelMap.put("status", "error");
117 114
             modelMap.put("msg", "保存失败!");
118 115
             e.printStackTrace();
@@ -137,5 +134,18 @@ public class BusinessImAssetController {
137 134
        return new BusinessImAsset();
138 135
     }
139 136
    
140
-    
137
+	 
138
+	 /**
139
+	  * 资产编号获取
140
+	  */
141
+	@RequestMapping(value ="/getAssetCode", produces = MediaType.APPLICATION_JSON_VALUE, method=RequestMethod.GET)
142
+	@ApiOperation(value="资产编号获取", notes = "资产编号获取")
143
+	@ApiImplicitParams({
144
+			@ApiImplicitParam(name = "orgId", value = "单位id", paramType = "query")
145
+	})
146
+    public String getAssetCode(Integer orgId){
147
+		
148
+	   return businessImAssetService.getAssetCode(orgId);
149
+    }
150
+	
141 151
 }

+ 2 - 0
src/main/java/com/chinaitop/depot/device/service/BusinessImAssetService.java

@@ -16,4 +16,6 @@ public interface BusinessImAssetService {
16 16
 
17 17
 	BusinessImAsset loadDataById(int id);
18 18
 
19
+	String getAssetCode(Integer orgId);
20
+
19 21
 }

+ 57 - 193
src/main/java/com/chinaitop/depot/device/service/impl/BusinessImAssetServiceImpl.java

@@ -1,4 +1,6 @@
1 1
 package com.chinaitop.depot.device.service.impl;
2
+import java.util.Calendar;
3
+import java.util.Date;
2 4
 import java.util.List;
3 5
 
4 6
 import javax.annotation.Resource;
@@ -9,6 +11,7 @@ import com.chinaitop.depot.device.mapper.BusinessImAssetMapper;
9 11
 import com.chinaitop.depot.device.model.BusinessImAsset;
10 12
 import com.chinaitop.depot.device.model.BusinessImAssetExample;
11 13
 import com.chinaitop.depot.device.service.BusinessImAssetService;
14
+import com.chinaitop.depot.utils.ParameterUtil;
12 15
 
13 16
 
14 17
 @Service
@@ -43,8 +46,10 @@ public class BusinessImAssetServiceImpl implements BusinessImAssetService{
43 46
 	public void save(BusinessImAsset businessImAsset) {
44 47
 		// TODO Auto-generated method stub
45 48
 		if (businessImAsset.getId() == null) {
46
-			businessImAssetMapper.insert(businessImAsset);// 新增数据
49
+			businessImAsset.setCreatedate(new Date());
50
+			businessImAssetMapper.insertSelective(businessImAsset);// 新增数据
47 51
 		} else {
52
+			businessImAsset.setUpdatedate(new Date());
48 53
 			businessImAssetMapper.updateByPrimaryKeySelective(businessImAsset);// 修改数据
49 54
 		}
50 55
 	}
@@ -58,205 +63,64 @@ public class BusinessImAssetServiceImpl implements BusinessImAssetService{
58 63
 		// TODO Auto-generated method stub
59 64
 		return businessImAssetMapper.selectByPrimaryKey(id);
60 65
 	}
61
-	
62
-	
63
-	/**
64
-	 * 根据id删除数据
65
-	 *//*
66
-	
67
-
68
-	*//**
69
-	 * 提交修改和新增
70
-	 *//*
71
-	
72 66
 
73
-	*//**
74
-	 * 根据id查询数据
75
-	 *//*
76
-	
77
-
78
-	 *//**
79
-     * 获取入库的仓房名
80
-     *//*
67
+	//编号规则:ZC+年份+日期+00n 
81 68
 	@Override
82
-	public List<HouseNameBean> getHouseList() {
69
+	public String getAssetCode(Integer orgId) {
83 70
 		// TODO Auto-generated method stub
71
+		Calendar calendar = Calendar.getInstance();
72
+		String year = calendar.get(Calendar.YEAR)+"";
73
+		String month = calendar.get(Calendar.MONTH)+1+"";
74
+		String dayOfMonth = calendar.get(Calendar.DAY_OF_MONTH)+"";
75
+		 if(month.length()==1){
76
+			 month = "0"+month;
77
+		 }
78
+		 if(dayOfMonth.length()==1){
79
+			 dayOfMonth = "0" +dayOfMonth;
80
+		 }
81
+		String str = "ZC"+year+""+month+""+dayOfMonth;
84 82
 		
85
-		return deviceInputMapper.getHouseList();
86
-	}
87
-
88
-	@Override
89
-	public List<HouseTypeBean> getTypeList(Integer depotId) {
90
-		// TODO Auto-generated method stub
91
-		return deviceInputMapper.getTypeList(depotId);
83
+		BusinessImAssetExample businessImAssetExample=new BusinessImAssetExample();
84
+		BusinessImAssetExample.Criteria criteria=businessImAssetExample.createCriteria();
85
+    	
86
+    	if(ParameterUtil.isnotnull(orgId)){
87
+    		criteria.andOrgIdEqualTo(orgId);
88
+    	}
89
+
90
+        //排序
91
+    	businessImAssetExample.setOrderByClause("id desc");
92
+    	List<BusinessImAsset> list = businessImAssetMapper.selectByExample(businessImAssetExample);
93
+    	if(list.size()>0){
94
+    		String assetCode= list.get(0).getAssetCode();
95
+    		String lastThreeChars  = assetCode.substring(assetCode.length()-3);
96
+    		
97
+    		String a = Integer.valueOf(lastThreeChars)+1+"";
98
+    		if(a.length()==1){
99
+    			a = "00"+a;
100
+    		}else if(a.length()==2){
101
+    			a = "0"+a;
102
+    		}
103
+    		
104
+    		String yearChars  = assetCode.substring(2,6);
105
+    		String monthChars  = assetCode.substring(6,10);
106
+
107
+    		if(!year.equals(yearChars)){
108
+    			if(!month.equals(monthChars)){
109
+        			str = str + "001";
110
+    			}
111
+    		}else{
112
+    			if((month+""+dayOfMonth).equals(monthChars)){
113
+        			str = str + a;
114
+    			}
115
+    		}
116
+    		
117
+    	}else{
118
+    		str = str + "001";     
119
+    	}
120
+		return str;
92 121
 	}
93 122
 	
94
-	//根据类型获取名称
95
-	@Override
96
-	public List<ShelfContentBean> getNameList(Integer depotTypeId) {
97
-		// TODO Auto-generated method stub
98
-		return deviceInputMapper.getNameList(depotTypeId);
99
-	}
100
-	
101
-	@Override
102
-	public ContentBean getcontentGetList(String deviceName) {
103
-		// TODO Auto-generated method stub
104
-		Map<String, Object> map  = new HashMap<>();
105
-		map.put("deviceName", deviceName);
106
-		return deviceInputMapper.getcontentGetList(map);
107
-	}
108
-	
109
-	//根据类型获取货架
110
-	@Override
111
-	public List<ContentBean> getShelfGetList(String deviceName) {
112
-		// TODO Auto-generated method stub
113
-		return deviceInputMapper.getShelfGetList(deviceName);
114
-	}
115
-
116
-	@Override
117
-	public List<StorageDeviceinput> queryByNumber(StorageDeviceinputExample example) {
118
-		return deviceInputMapper.selectByExample(example);
119
-	}
120
-
121
-	//查询仓房对应的设备名称
122
-	@Override
123
-	public List<StorageDeviceinput> getDeviceInputList(Integer depotId) {
124
-		// TODO Auto-generated method stub
125
-		return deviceInputMapper.getDeviceInputList(depotId);
126
-	}
127
-
128
-	//查询设备名称对应的型号
129
-	@Override
130
-	public List<StorageDeviceinput> getModelList(String deviceName) {
131
-		// TODO Auto-generated method stub
132
-		return deviceInputMapper.getModelList(deviceName);
133
-	}
134 123
 	
135
-	//查询型号对应的编号
136
-	@Override
137
-	public List<StorageDeviceinput> getNumberList(String deviceModel) {
138
-		// TODO Auto-generated method stub
139
-		return deviceInputMapper.getNumberList(deviceModel);
140
-	}
141 124
 
142
-	//查询型号对应的数量
143
-	@Override
144
-	public List<StorageDeviceinput> getCountList(String number) {
145
-		// TODO Auto-generated method stub
146
-		return deviceInputMapper.getCountList(number);
147
-	}
148
-
149
-	//报废
150
-	@Override
151
-	public void updateByPrimaryKeySelective(StorageDeviceinput storageDeviceinput) {
152
-		// TODO Auto-generated method stub
153
-		deviceInputMapper.updateByPrimaryKeySelective(storageDeviceinput);
154
-	}
155
-
156
-	@Override
157
-	public List<StorageDeviceinput> getAllList(String number) {
158
-		return deviceInputMapper.getAllList(number);
159
-	}
160
-
161
-	// 获取货架获取规格型号getModelGetList
162
-	@Override
163
-	public List<ContentBean> getModelGetList(Map<String, Object> map) {
164
-		// TODO Auto-generated method stub
165
-		return deviceInputMapper.getModelGetList(map);
166
-	}
167
-
168
-	//获取规格型号对应的编号getNumberGetList
169
-	@Override
170
-	public List<StorageDeviceinput> getNumberGetList(String model) {
171
-		// TODO Auto-generated method stub
172
-		return deviceInputMapper.getNumberGetList(model);
173
-	}
174
-
175
-	//根据编号获取可用数量
176
-	@Override
177
-	public List<StorageDeviceinput> getUseCountGetList(String number) {
178
-		// TODO Auto-generated method stub
179
-		return deviceInputMapper.getUseCountGetList(number);
180
-	}
181
-
182
-	//获取编号和规格型号
183
-	@Override
184
-	public List<String> getDeviceModelList(Map<String,String> map) {
185
-		// TODO Auto-generated method stub
186
-		return deviceInputMapper.getDeviceModelList(map);
187
-	}
188
-
189
-	@Override
190
-	public List<String> deviceSbCodeModelList(String deviceName, String model) {
191
-		return deviceInputMapper.deviceSbCodeModelList(deviceName,model);
192
-	}
193
-
194
-	//查询原有数量
195
-	@Override
196
-	public StorageDeviceinput selectById(Integer number) {
197
-		// TODO Auto-generated method stub
198
-		return deviceInputMapper.selectByPrimaryKey(number);
199
-	}
200
-
201
-	//获取保养名称
202
-	@Override
203
-	public List<String> getdevieName(String orgId) {
204
-		// TODO Auto-generated method stub
205
-		return deviceInputMapper.getdevieName(orgId);
206
-	}
207
-
208
-	//获取维修名称
209
-	@Override
210
-	public List<String> getRepairNameList(String orgId) {
211
-		// TODO Auto-generated method stub
212
-		return deviceInputMapper.getdevieName(orgId);
213
-	}
214
-
215
-	//领用时,根据规格型号和编号获取可用数量
216
-	@Override
217
-	public List<StorageDeviceinput> getUseCount(Map<String, Object> map) {
218
-		// TODO Auto-generated method stub
219
-		return deviceInputMapper.getUseCount(map);
220
-	}
221
-
222
-	
223
-	//获取设备数据
224
-	@Override
225
-	public List<StorageDeviceinput> queryDevice(HashMap<Object, Object> map) {
226
-		// TODO Auto-generated method stub
227
-		return deviceInputMapper.queryDevice(map);
228
-	}
229
-
230
-	//获取维修的规格型号和编号
231
-	@Override
232
-	public List<StorageDeviceinput> getDeviceModelRepair(String deviceName) {
233
-		// TODO Auto-generated method stub
234
-		return deviceInputMapper.getDeviceModelRepair(deviceName);
235
-	}
236
-
237
-	@Override
238
-	public List<StorageDeviceinput> getDeviceModelListRepair(String deviceName) {
239
-		// TODO Auto-generated method stub
240
-		return null;
241
-	}
242
-
243
-	//获取每一类型入库的总数量
244
-	@Override
245
-	public List<Map<String, Object>> queryCountByType() {
246
-		// TODO Auto-generated method stub
247
-		return deviceInputMapper.queryCountByType();
248
-	}
249
-
250
-	@Override
251
-	public List<StorageDeviceinput> queryDeviceAccount(StorageDeviceinputExample storageDeviceinputExample) {
252
-		// TODO Auto-generated method stub
253
-		return deviceInputMapper.queryDeviceAccount(storageDeviceinputExample);
254
-	}
255
-
256
-	@Override
257
-	public int deviceBySbCode(String sbCdoe) {
258
-		return Integer.valueOf(deviceInputMapper.deviceBySbCode(sbCdoe));
259
-	}
260 125
 
261
-*/
262 126
 }