lvzhikai před 4 roky
rodič
revize
3ddc22140f

+ 44 - 35
src/main/java/com/chinaitop/depot/device/controller/StorageDeviceGetController.java

@@ -121,41 +121,30 @@ public class StorageDeviceGetController {
121 121
         StorageDeviceget storageDeviceget = null;
122 122
         try {
123 123
         	//保存领用数据
124
-        	ContentBean cb=(ContentBean)mapper.readValue(contentBeanJson, ContentBean.class);
125
-        	storageDeviceget = (StorageDeviceget)mapper.readValue(deviceGetJson, StorageDeviceget.class);
126
-        	storageDeviceget.setDeviceName(cb.getDeviceName());
127
-        	storageDeviceget.setDeviceType(cb.getDeviceTypeId());
128
-        	storageDeviceget.setModel(cb.getModel());
129
-        	storageDeviceget.setNumber(cb.getNumber());
130
-        	storageDeviceget.setUseCount(cb.getUseCount());
131
-        	storageDeviceget.setBackCount(0);
132
-        	storageDeviceget.setHouseId(storageDeviceget.getHouseId());
133
-        	deviceGetService.save(storageDeviceget);
134
-        	
135
-        	//根据设备编号获取入库表的该设备信息
136
-        	modelMap.put("number", storageDeviceget.getNumber());
137
-        	modelMap.put("model", storageDeviceget.getModel());
138
-        	List<StorageDeviceinput> inputList=deviceInputService.getUseCount(modelMap);
139
-        	inputList.get(0).setStatus(4);//领用状态
140
-        	inputList.get(0).setUseCount(inputList.get(0).getUseCount()-storageDeviceget.getGetCount());//数量减少
141
-        	deviceInputService.updateByPrimaryKeySelective(inputList.get(0));
142
-        	//改变入库的数量
143
-        	/*StorageDeviceinputExample storageDeviceinputExample2 = new StorageDeviceinputExample();
144
-        	Criteria criteria2 = storageDeviceinputExample2.createCriteria();
145
-        	criteria2.andNumberEqualTo(cb.getNumber());
146
-        	List<StorageDeviceinput> list=deviceInputService.queryByNumber(storageDeviceinputExample2);
147
-        	StorageDeviceinputExample storageDeviceinputExample=new StorageDeviceinputExample();
148
-        	StorageDeviceinputExample.Criteria criteria=storageDeviceinputExample.createCriteria();
149
-        	criteria.andIdEqualTo(Integer.valueOf(storageDeviceget.getInputId()));
150
-        	List<StorageDeviceinput> inputlist = deviceInputService.queryByDevice(storageDeviceinputExample);
151
-            if(inputlist!=null){
152
-            	StorageDeviceinput storageDeviceinput=list.get(0);
153
-            	//使其状态改变为领用
154
-            	storageDeviceinput.setStatus(4);
155
-            	storageDeviceinput.setUseCount(storageDeviceinput.getUseCount()-storageDeviceget.getGetCount());
156
-            	deviceInputService.save(storageDeviceinput);
157
-            }*/
158
-            modelMap.put("status", "success");
124
+        	storageDeviceget = (StorageDeviceget) mapper.readValue(deviceGetJson, StorageDeviceget.class);
125
+			if (ParameterUtil.isnull(storageDeviceget.getId())) {
126
+				ContentBean cb=(ContentBean)mapper.readValue(contentBeanJson, ContentBean.class);
127
+				storageDeviceget.setDeviceName(cb.getDeviceName());
128
+				storageDeviceget.setDeviceType(cb.getDeviceTypeId());
129
+				storageDeviceget.setModel(cb.getModel());
130
+				storageDeviceget.setNumber(cb.getNumber());
131
+				storageDeviceget.setUseCount(cb.getUseCount());
132
+				storageDeviceget.setBackCount(0);
133
+				storageDeviceget.setHouseId(storageDeviceget.getHouseId());
134
+				deviceGetService.save(storageDeviceget);
135
+
136
+				//根据设备编号获取入库表的该设备信息
137
+				modelMap.put("number", storageDeviceget.getNumber());
138
+				modelMap.put("model", storageDeviceget.getModel());
139
+				List<StorageDeviceinput> inputList = deviceInputService.getUseCount(modelMap);
140
+				inputList.get(0).setStatus(4);//领用状态
141
+				inputList.get(0).setUseCount(inputList.get(0).getUseCount() - storageDeviceget.getGetCount());//数量减少
142
+				deviceInputService.updateByPrimaryKeySelective(inputList.get(0));
143
+				modelMap.put("status", "success");
144
+			}else{
145
+				deviceGetService.updateByPrimaryKeySelective(storageDeviceget);
146
+				modelMap.put("status", "success");
147
+			}
159 148
         } catch (IOException e) {
160 149
             modelMap.put("status", "error");
161 150
             e.printStackTrace();
@@ -297,6 +286,26 @@ public class StorageDeviceGetController {
297 286
     	list.add(storageDeviceget);
298 287
         return list;
299 288
     }
289
+
290
+
291
+    /**
292
+     * 根据ID获取修改信息
293
+     * @throws Exception
294
+     */
295
+    @RequestMapping(value ="/getEditGetById",produces = MediaType.APPLICATION_JSON_VALUE, method=RequestMethod.GET)
296
+   	@ApiOperation(value="根据ID获取修改信息", notes = "根据ID获取修改信息")
297
+   	@ApiImplicitParams({
298
+   		 @ApiImplicitParam(name = "id", value = "id", paramType = "query")
299
+   	})
300
+    public List<StorageDeviceget> getEditGetById(String id) throws Exception{
301
+    	StorageDeviceget storageDeviceget=null;
302
+    	if(id != null && !"".equals(id)){
303
+    		storageDeviceget=deviceGetService.selectByPrimaryKeys(Integer.valueOf(id));
304
+    	}
305
+    	List<StorageDeviceget> list =new ArrayList<StorageDeviceget>();
306
+    	list.add(storageDeviceget);
307
+        return list;
308
+    }
300 309
     
301 310
     /**
302 311
      * 根据ID获取归还信息

+ 1 - 0
src/main/java/com/chinaitop/depot/device/mapper/StorageDevicegetMapper.java

@@ -21,6 +21,7 @@ public interface StorageDevicegetMapper {
21 21
     List<StorageDeviceget> selectByExample(StorageDevicegetExample example);
22 22
 
23 23
     StorageDeviceget selectByPrimaryKey(Integer id);
24
+    StorageDeviceget selectByPrimaryKeys(Integer id);
24 25
 
25 26
     int updateByExampleSelective(@Param("record") StorageDeviceget record, @Param("example") StorageDevicegetExample example);
26 27
 

+ 25 - 0
src/main/java/com/chinaitop/depot/device/mapper/StorageDevicegetMapper.xml

@@ -396,4 +396,29 @@
396 396
     GROUP BY device_type 
397 397
     order by device_type asc
398 398
   </select>
399
+
400
+  <select id="selectByPrimaryKeys" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
401
+    SELECT
402
+      gets.id,
403
+      gets.device_type,
404
+      gets.get_time,
405
+      gets.device_name,
406
+      gets.model,
407
+      gets.get_count,
408
+      gets.back_count,
409
+      gets.book_keeper,
410
+      gets. HANDLER,
411
+      gets.house_id,
412
+      gets.number,
413
+      gets.collator,
414
+      gets.use_count,
415
+      gets.remark,
416
+      gets.input_id,
417
+      gets.org_id,
418
+      inputs.storage_rack storageRack
419
+    FROM
420
+      storage_deviceget gets
421
+    LEFT JOIN storage_deviceinput inputs ON gets.input_id = inputs.id
422
+    where gets.id = #{id,jdbcType=INTEGER}
423
+  </select>
399 424
 </mapper>

+ 11 - 2
src/main/java/com/chinaitop/depot/device/model/StorageDeviceget.java

@@ -37,8 +37,9 @@ public class StorageDeviceget {
37 37
     
38 38
     //业务字段
39 39
     private String orgName;
40
-    
41
-    
40
+
41
+    //货架
42
+    private String storageRack;
42 43
 
43 44
     public String getOrgName() {
44 45
 		return orgName;
@@ -303,4 +304,12 @@ public class StorageDeviceget {
303 304
     public void setOrgId(Integer orgId) {
304 305
         this.orgId = orgId;
305 306
     }
307
+
308
+    public String getStorageRack() {
309
+        return storageRack;
310
+    }
311
+
312
+    public void setStorageRack(String storageRack) {
313
+        this.storageRack = storageRack;
314
+    }
306 315
 }

+ 1 - 0
src/main/java/com/chinaitop/depot/device/service/StorageDeviceGetService.java

@@ -14,6 +14,7 @@ public interface StorageDeviceGetService {
14 14
 	void save(StorageDeviceget storageDeviceget);
15 15
 
16 16
 	StorageDeviceget selectByPrimaryKey(int id);
17
+	StorageDeviceget selectByPrimaryKeys(int id);
17 18
 
18 19
 	void updateByPrimaryKeySelective(StorageDeviceget storageDeviceget);
19 20
 

+ 6 - 0
src/main/java/com/chinaitop/depot/device/service/impl/StorageDeviceGetServiceImpl.java

@@ -43,6 +43,12 @@ public class StorageDeviceGetServiceImpl implements StorageDeviceGetService{
43 43
 		return deviceGetMapper.selectByPrimaryKey(id);
44 44
 	}
45 45
 
46
+	@Override
47
+	public StorageDeviceget selectByPrimaryKeys(int id) {
48
+		// TODO Auto-generated method stub
49
+		return deviceGetMapper.selectByPrimaryKeys(id);
50
+	}
51
+
46 52
 	//增加归还信息
47 53
 	@Override
48 54
 	public void updateByPrimaryKeySelective(StorageDeviceget storageDeviceget) {