|
@@ -21,8 +21,10 @@ import org.springframework.web.servlet.ModelAndView;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.Arrays;
|
|
|
import java.util.List;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* @Description: 点检项
|
|
@@ -40,6 +42,16 @@ public class CmmsSpotcheckItemController extends JeecgController<CmmsSpotcheckIt
|
|
|
@Autowired
|
|
|
private AutoCodeUtil autoCodeUtil;
|
|
|
|
|
|
+ /**
|
|
|
+ * 根据设备id查询该设备现在点检内容已启用数量
|
|
|
+ * */
|
|
|
+ @ApiOperation("根据设备id查询该设备现在点检内容已启用数量")
|
|
|
+ @GetMapping(value = "/numByEquipmentid/{equipmentid}")
|
|
|
+ public Result<Integer> numByEquipmentid(@PathVariable("equipmentid") String equipmentid){
|
|
|
+ return Result.OK(cmmsSpotcheckItemService.numByEquipmentid(equipmentid));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* 依据设备ID获取点检项信息
|
|
|
*/
|
|
@@ -65,7 +77,9 @@ public class CmmsSpotcheckItemController extends JeecgController<CmmsSpotcheckIt
|
|
|
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
|
|
|
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
|
|
|
HttpServletRequest req) {
|
|
|
- CmmsSpotcheckItem cmmsSpotcheckItem1 = CmmsSpotcheckItemConvert.INSTANCE.convert(cmmsSpotcheckItem.getEquipmenttreeid(),cmmsSpotcheckItem.getItemtype());
|
|
|
+ CmmsSpotcheckItem cmmsSpotcheckItem1 = new CmmsSpotcheckItem();
|
|
|
+ cmmsSpotcheckItem1.setEquipmenttreeid(cmmsSpotcheckItem.getEquipmenttreeid());
|
|
|
+ cmmsSpotcheckItem1.setItemtype(cmmsSpotcheckItem.getItemtype());
|
|
|
QueryWrapper<CmmsSpotcheckItem> queryWrapper = QueryGenerator.initQueryWrapper(cmmsSpotcheckItem1, req.getParameterMap());
|
|
|
queryWrapper.like(cmmsSpotcheckItem.getItemcode()!=null && !"".equals(cmmsSpotcheckItem.getItemcode()),"itemcode",cmmsSpotcheckItem.getItemcode());
|
|
|
queryWrapper.like(cmmsSpotcheckItem.getItemname()!=null && !"".equals(cmmsSpotcheckItem.getItemname()),"itemname",cmmsSpotcheckItem.getItemname());
|
|
@@ -87,11 +101,16 @@ public class CmmsSpotcheckItemController extends JeecgController<CmmsSpotcheckIt
|
|
|
//@RequiresPermissions("org.jeecg.modules:ems_cmms_spotcheck_item:add")
|
|
|
@PostMapping(value = "/add")
|
|
|
public Result<String> add(@RequestBody CmmsSpotcheckItem cmmsSpotcheckItem) {
|
|
|
- //生成点检项编号
|
|
|
- if (cmmsSpotcheckItem.getItemcode() == null || "".equals(cmmsSpotcheckItem.getItemcode())) {
|
|
|
- cmmsSpotcheckItem.setItemcode(autoCodeUtil.genSerialCode(UserConstants.CMMSSPOTCHECKITEM_CODE, null));
|
|
|
+ List<CmmsSpotcheckItem> list = new ArrayList<>();
|
|
|
+ if(cmmsSpotcheckItem.getEquipmenttreeid()!=null && !"".equals(cmmsSpotcheckItem.getEquipmenttreeid())){
|
|
|
+ String[] strings = cmmsSpotcheckItem.getEquipmenttreeid().split(",");
|
|
|
+ for(String equipmenttreeid : strings){
|
|
|
+ String itemcode = autoCodeUtil.genSerialCode(UserConstants.CMMSSPOTCHECKITEM_CODE, null);
|
|
|
+ CmmsSpotcheckItem item = CmmsSpotcheckItemConvert.INSTANCE.convert(cmmsSpotcheckItem, itemcode, equipmenttreeid);
|
|
|
+ list.add(item);
|
|
|
+ }
|
|
|
}
|
|
|
- cmmsSpotcheckItemService.save(cmmsSpotcheckItem);
|
|
|
+ cmmsSpotcheckItemService.saveBatch(list);
|
|
|
return Result.OK("添加成功!");
|
|
|
}
|
|
|
|