Browse Source

修改入库失败问题

master
lihua 5 years ago
parent
commit
4cf88a9338
  1. 15
      src/main/java/cn/redrock/assetmanage/controller/MaterialController.java
  2. 7
      src/main/java/cn/redrock/assetmanage/controller/StaffAssetController.java
  3. 2
      src/main/java/cn/redrock/assetmanage/mapper/AmStaffAssetMapper.java
  4. 2
      src/main/java/cn/redrock/assetmanage/service/StaffAssetService.java
  5. 5
      src/main/java/cn/redrock/assetmanage/service/impl/MaterialServiceImpl.java
  6. 4
      src/main/java/cn/redrock/assetmanage/service/impl/StaffAssetServiceImpl.java

15
src/main/java/cn/redrock/assetmanage/controller/MaterialController.java

@ -93,12 +93,17 @@ public class MaterialController {
if(list == null || list.isEmpty()){ if(list == null || list.isEmpty()){
return Result.error(ResponseCode.EXCEL_PARSE_ERROR); return Result.error(ResponseCode.EXCEL_PARSE_ERROR);
} }
boolean ret; boolean ret = false;
if(isOverride != null && isOverride){ try {
ret = materialService.batchAdd(list,true); if(isOverride != null && isOverride){
}else{ ret = materialService.batchAdd(list,true);
ret = materialService.batchAdd(list,false); }else{
ret = materialService.batchAdd(list,false);
}
}catch (RuntimeException e){
e.printStackTrace();
} }
if(!ret){ if(!ret){
materialLogService.batchWriteLog(buildBatchLog(user.getId(),Constants.Operate.IN, Constants.Status.FAILED,list,getBatch(file))); materialLogService.batchWriteLog(buildBatchLog(user.getId(),Constants.Operate.IN, Constants.Status.FAILED,list,getBatch(file)));
return Result.error(ResponseCode.ASSET_BATCH_ADD_FAIL); return Result.error(ResponseCode.ASSET_BATCH_ADD_FAIL);

7
src/main/java/cn/redrock/assetmanage/controller/StaffAssetController.java

@ -41,10 +41,9 @@ public class StaffAssetController {
return Result.ok(); return Result.ok();
} }
@PostMapping("/edit") @PostMapping("/edit/{id}")
public Result editAsset(@CurrentUser AmUser user,@Valid @RequestBody Asset asset) { public Result editAsset(@PathVariable("id") Integer id,@Valid @RequestBody Asset asset) {
asset.setUserId(user.getId()); if(!staffAssetService.update(id,asset)){
if(!staffAssetService.update(asset)){
return Result.error(ResponseCode.ASSET_NO_EXISTED); return Result.error(ResponseCode.ASSET_NO_EXISTED);
} }
return Result.ok(); return Result.ok();

2
src/main/java/cn/redrock/assetmanage/mapper/AmStaffAssetMapper.java

@ -13,4 +13,6 @@ public interface AmStaffAssetMapper extends Mapper<AmStaffAsset> {
@Select(value = "select a.*,b.nickname user_name from am_staff_asset a,am_user b where a.user_id=#{userId} and a.name=#{name} and a.user_id=b.id") @Select(value = "select a.*,b.nickname user_name from am_staff_asset a,am_user b where a.user_id=#{userId} and a.name=#{name} and a.user_id=b.id")
AmStaffAsset find(@Param("userId") Integer userId, @Param("name") String name); AmStaffAsset find(@Param("userId") Integer userId, @Param("name") String name);
@Select(value = "select * from am_staff_asset where id=#{id}")
AmStaffAsset findById(Integer id);
} }

2
src/main/java/cn/redrock/assetmanage/service/StaffAssetService.java

@ -15,6 +15,6 @@ import java.util.List;
public interface StaffAssetService { public interface StaffAssetService {
boolean add(Asset asset); boolean add(Asset asset);
List<AmStaffAsset> search(Integer userId,String field, String content, Integer pageNum, Integer pageSize); List<AmStaffAsset> search(Integer userId,String field, String content, Integer pageNum, Integer pageSize);
boolean update(Asset asset); boolean update(Integer id,Asset asset);
boolean delete(Integer id); boolean delete(Integer id);
} }

5
src/main/java/cn/redrock/assetmanage/service/impl/MaterialServiceImpl.java

@ -75,6 +75,7 @@ public class MaterialServiceImpl implements MaterialService {
log.info("update add material success from {} to {} ", JSON.toJSONString(oldMaterial),JSON.toJSONString(newMaterial)); log.info("update add material success from {} to {} ", JSON.toJSONString(oldMaterial),JSON.toJSONString(newMaterial));
}else{ }else{
log.error("update add material failed from {} to {} ", JSON.toJSONString(oldMaterial),JSON.toJSONString(newMaterial)); log.error("update add material failed from {} to {} ", JSON.toJSONString(oldMaterial),JSON.toJSONString(newMaterial));
throw new RuntimeException("update add material failed");
} }
}else{ }else{
BeanUtils.copyProperties(material,newMaterial); BeanUtils.copyProperties(material,newMaterial);
@ -83,10 +84,12 @@ public class MaterialServiceImpl implements MaterialService {
log.info("add material success {}", JSON.toJSONString(newMaterial)); log.info("add material success {}", JSON.toJSONString(newMaterial));
}else{ }else{
log.error("add material failed {}", JSON.toJSONString(newMaterial)); log.error("add material failed {}", JSON.toJSONString(newMaterial));
throw new RuntimeException("add material failed");
} }
} }
}else{ }else{
return false; log.error("add material failed {}", JSON.toJSONString(material));
throw new RuntimeException("add material failed");
} }
} }
return true; return true;

4
src/main/java/cn/redrock/assetmanage/service/impl/StaffAssetServiceImpl.java

@ -55,8 +55,8 @@ public class StaffAssetServiceImpl implements StaffAssetService {
} }
@Override @Override
public boolean update(Asset asset) { public boolean update(Integer id,Asset asset) {
AmStaffAsset staffAsset = staffAssetMapper.find(asset.getUserId(),asset.getName()); AmStaffAsset staffAsset = staffAssetMapper.findById(id);
if(staffAsset == null){ if(staffAsset == null){
log.info("public asset {} not exists",asset.getName()); log.info("public asset {} not exists",asset.getName());
return false; return false;

Loading…
Cancel
Save