|
@@ -9,10 +9,8 @@ import com.google.gson.JsonParser;
|
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
-import org.apache.shiro.authz.annotation.RequiresPermissions;
|
|
|
import org.jeecg.common.api.vo.Result;
|
|
|
import org.jeecg.common.aspect.annotation.AutoLog;
|
|
|
-import org.jeecg.common.exception.JeecgBootException;
|
|
|
import org.jeecg.common.system.base.controller.JeecgController;
|
|
|
import org.jeecg.common.system.query.QueryGenerator;
|
|
|
import org.jeecg.modules.system.app.entity.AppDevice;
|
|
@@ -68,7 +66,9 @@ public class AppDeviceController extends JeecgController<AppDevice, IAppDeviceSe
|
|
|
Page<AppDevice> page = new Page<AppDevice>(pageNo, pageSize);
|
|
|
IPage<AppDevice> pageList = AppDeviceService.page(page, queryWrapper);
|
|
|
pageList.getRecords().forEach(item->{
|
|
|
- item.setSiteName(appSiteMapper.selectById(item.getSiteId()).getName());
|
|
|
+ if(!item.getSiteId().isEmpty()){
|
|
|
+ item.setSiteName(appSiteMapper.selectById(item.getSiteId()).getName());
|
|
|
+ }
|
|
|
});
|
|
|
return Result.OK(pageList);
|
|
|
}
|
|
@@ -80,7 +80,6 @@ public class AppDeviceController extends JeecgController<AppDevice, IAppDeviceSe
|
|
|
*/
|
|
|
@AutoLog(value = "nm_device-添加")
|
|
|
@Operation(summary="nm_device-添加")
|
|
|
- @RequiresPermissions("com:nm_device:add")
|
|
|
@PostMapping(value = "/add")
|
|
|
@Transactional
|
|
|
public Result<String> add(@RequestBody AppDevice appDevice){
|
|
@@ -91,40 +90,37 @@ public class AppDeviceController extends JeecgController<AppDevice, IAppDeviceSe
|
|
|
return Result.error("设备已存在!");
|
|
|
}
|
|
|
AppDeviceService.save(appDevice);
|
|
|
- try {
|
|
|
- if(appDevice.getDeviceSerial() != null && appDevice.getValidateCode() != null){
|
|
|
- String addDevice = addDevice(appDevice.getDeviceSerial(), appDevice.getValidateCode());
|
|
|
- String userWeekPlan = addUserWeekPlan(appDevice.getDeviceSerial());
|
|
|
- String userPlanTemplate = addUserPlanTemplate(appDevice.getDeviceSerial());
|
|
|
- JsonObject deviceJson = JsonParser.parseString(addDevice).getAsJsonObject();
|
|
|
- JsonObject userWeekPlanJson = JsonParser.parseString(userWeekPlan).getAsJsonObject();
|
|
|
- JsonObject userPlanTemplateJson = JsonParser.parseString(userPlanTemplate).getAsJsonObject();
|
|
|
- if(deviceJson.get("code").getAsInt() == 0
|
|
|
- && userWeekPlanJson.get("code").getAsInt() == 0
|
|
|
- && userPlanTemplateJson.get("code").getAsInt() == 0){
|
|
|
- return Result.OK("添加成功!");
|
|
|
- }else {
|
|
|
- return Result.OK("添加失败!");
|
|
|
- }
|
|
|
- }
|
|
|
- }catch (Exception e){
|
|
|
- throw new JeecgBootException("添加失败!");
|
|
|
- }
|
|
|
return Result.OK("添加成功!");
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 编辑
|
|
|
*
|
|
|
- * @param AppDevice
|
|
|
+ * @param appDevice
|
|
|
* @return
|
|
|
*/
|
|
|
@AutoLog(value = "nm_device-编辑")
|
|
|
@Operation(summary="nm_device-编辑")
|
|
|
- @RequiresPermissions("com:nm_device:edit")
|
|
|
@PostMapping(value = "/edit")
|
|
|
- public Result<String> edit(@RequestBody AppDevice AppDevice) {
|
|
|
- AppDeviceService.updateById(AppDevice);
|
|
|
+ @Transactional
|
|
|
+ public Result<String> edit(@RequestBody AppDevice appDevice) {
|
|
|
+ appDevice.setOrgCode(appSiteMapper.selectById(appDevice.getSiteId()).getOrgCode());
|
|
|
+ AppDeviceService.updateById(appDevice);
|
|
|
+ if(appDevice.getDeviceSerial() != null && appDevice.getValidateCode() != null && appDevice.getSiteId() != null){
|
|
|
+ String addDevice = addDevice(appDevice.getDeviceSerial(), appDevice.getValidateCode());
|
|
|
+ String userWeekPlan = addUserWeekPlan(appDevice.getDeviceSerial());
|
|
|
+ String userPlanTemplate = addUserPlanTemplate(appDevice.getDeviceSerial());
|
|
|
+ JsonObject deviceJson = JsonParser.parseString(addDevice).getAsJsonObject();
|
|
|
+ JsonObject userWeekPlanJson = JsonParser.parseString(userWeekPlan).getAsJsonObject();
|
|
|
+ JsonObject userPlanTemplateJson = JsonParser.parseString(userPlanTemplate).getAsJsonObject();
|
|
|
+ if(deviceJson.get("code").getAsInt() == 0
|
|
|
+ && userWeekPlanJson.get("code").getAsInt() == 0
|
|
|
+ && userPlanTemplateJson.get("code").getAsInt() == 0){
|
|
|
+ return Result.OK("添加成功!");
|
|
|
+ }else {
|
|
|
+ return Result.OK("添加失败!");
|
|
|
+ }
|
|
|
+ }
|
|
|
return Result.OK("编辑成功!");
|
|
|
}
|
|
|
|
|
@@ -136,7 +132,6 @@ public class AppDeviceController extends JeecgController<AppDevice, IAppDeviceSe
|
|
|
*/
|
|
|
@AutoLog(value = "nm_device-通过id删除")
|
|
|
@Operation(summary="nm_device-通过id删除")
|
|
|
- @RequiresPermissions("com:nm_device:delete")
|
|
|
@DeleteMapping(value = "/delete")
|
|
|
public Result<String> delete(@RequestParam(name="id",required=true) String id) {
|
|
|
AppDeviceService.removeById(id);
|
|
@@ -151,7 +146,6 @@ public class AppDeviceController extends JeecgController<AppDevice, IAppDeviceSe
|
|
|
*/
|
|
|
@AutoLog(value = "nm_device-批量删除")
|
|
|
@Operation(summary="nm_device-批量删除")
|
|
|
- @RequiresPermissions("com:nm_device:deleteBatch")
|
|
|
@DeleteMapping(value = "/deleteBatch")
|
|
|
public Result<String> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
|
|
|
this.AppDeviceService.removeByIds(Arrays.asList(ids.split(",")));
|
|
@@ -172,7 +166,9 @@ public class AppDeviceController extends JeecgController<AppDevice, IAppDeviceSe
|
|
|
if(appDevice==null) {
|
|
|
return Result.error("未找到对应数据");
|
|
|
}
|
|
|
- appDevice.setSiteName(appSiteMapper.selectById(appDevice.getSiteId()).getName());
|
|
|
+ if(!appDevice.getSiteId().isEmpty()){
|
|
|
+ appDevice.setSiteName(appSiteMapper.selectById(appDevice.getSiteId()).getName());
|
|
|
+ }
|
|
|
return Result.OK(appDevice);
|
|
|
}
|
|
|
|
|
@@ -182,7 +178,6 @@ public class AppDeviceController extends JeecgController<AppDevice, IAppDeviceSe
|
|
|
* @param request
|
|
|
* @param AppDevice
|
|
|
*/
|
|
|
- @RequiresPermissions("com:nm_device:exportXls")
|
|
|
@RequestMapping(value = "/exportXls")
|
|
|
public ModelAndView exportXls(HttpServletRequest request, AppDevice AppDevice) {
|
|
|
return super.exportXls(request, AppDevice, AppDevice.class, "nm_device");
|
|
@@ -195,7 +190,6 @@ public class AppDeviceController extends JeecgController<AppDevice, IAppDeviceSe
|
|
|
* @param response
|
|
|
* @return
|
|
|
*/
|
|
|
- @RequiresPermissions("com:nm_device:importExcel")
|
|
|
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
|
|
|
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
|
|
|
return super.importExcel(request, response, AppDevice.class);
|